-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added login modal to send solution button if user not logged in
- Loading branch information
1 parent
d6ba573
commit 6b9a8f2
Showing
2 changed files
with
58 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 54 additions & 41 deletions
95
src/app/modules/challenge/components/challenge-header/challenge-header.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
}); | ||
} | ||
} |