Skip to content

Commit

Permalink
added login modal to send solution button if user not logged in
Browse files Browse the repository at this point in the history
  • Loading branch information
valerioprds committed Nov 13, 2023
1 parent d6ba573 commit 6b9a8f2
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,14 @@ <h3>{{title}}</h3>
</div>
<!-------if not logged show this------>
<div class="w-25 mt-4 button d-none d-md-inline-block">
<button class="btn btn-primary" (click)="clickSendButton()" title="{{'modules.challenge.header.toolTip' | translate }}">
<button class="btn btn-primary"
(click)="userLoggedIn ? clickSendButton() : openLoginModal()"
title="{{'modules.challenge.header.toolTip' | translate }}">
{{'modules.challenge.header.button' | translate }}
</button>
</div>


<!------ if logged show this------>
<!--
<div class="col-3 button">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,46 +1,59 @@
import { Component, Input } from '@angular/core';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { SendSolutionModalComponent } from './../../../modals/send-solution-modal/send-solution-modal.component';
import { RestrictedModalComponent } from './../../../modals/restricted-modal/restricted-modal.component';
import { SolutionService } from '../../../../services/solution.service';
import { Component, Input } from "@angular/core";
import { NgbModal } from "@ng-bootstrap/ng-bootstrap";
import { SendSolutionModalComponent } from "./../../../modals/send-solution-modal/send-solution-modal.component";
import { RestrictedModalComponent } from "./../../../modals/restricted-modal/restricted-modal.component";
import { SolutionService } from "../../../../services/solution.service";
import { LoginModalComponent } from "src/app/modules/modals/login-modal/login-modal.component";

@Component({
selector: 'app-challenge-header',
templateUrl: './challenge-header.component.html',
styleUrls: ['./challenge-header.component.scss'],
selector: "app-challenge-header",
templateUrl: "./challenge-header.component.html",
styleUrls: ["./challenge-header.component.scss"],
})
export class ChallengeHeaderComponent {

constructor(private modalService: NgbModal, private solutionService: SolutionService){}


@Input() title = "";
@Input() creation_date!: Date;
@Input() level = "";

challenge_title: string | undefined = 'hola';
challenge_date: Date | undefined
challenge_level: string | undefined

userLoggedIn = true;

ngOnInit(){
this.challenge_title = this.title;
this.challenge_date = this.creation_date
this.challenge_level = this.level
}

openSendSolutionModal(){
this.modalService.open(SendSolutionModalComponent, { centered : true, size : 'lg' })
}

clickSendButton() {
if (!this.userLoggedIn) {
this.modalService.open(RestrictedModalComponent, { centered: true, size: 'lg' })
} else {
this.solutionService.subject.next(2);
}
}


constructor(
private modalService: NgbModal,
private solutionService: SolutionService
) {}

@Input() title = "";
@Input() creation_date!: Date;
@Input() level = "";

challenge_title: string | undefined = "hola";
challenge_date: Date | undefined;
challenge_level: string | undefined;

userLoggedIn = false; //& tiene que ser ture para que el usuario pueda mandar su solucion

ngOnInit() {
this.challenge_title = this.title;
this.challenge_date = this.creation_date;
this.challenge_level = this.level;
}

openSendSolutionModal() {
this.modalService.open(SendSolutionModalComponent, {
centered: true,
size: "lg",
});
}

clickSendButton() {
if (!this.userLoggedIn) {
this.modalService.open(RestrictedModalComponent, {
centered: true,
size: "lg",
});
} else {
this.solutionService.subject.next(2);
}
}

openLoginModal() {
this.modalService.open(LoginModalComponent, {
centered: true,
size: "lg",
});
}
}

0 comments on commit 6b9a8f2

Please sign in to comment.