Skip to content

Commit

Permalink
Merge pull request #104 from CS3219-AY2425S1/final-fixes-tresa
Browse files Browse the repository at this point in the history
Fix landing page error
  • Loading branch information
lynnetteeee authored Nov 13, 2024
2 parents 09f699e + eb6bb84 commit 35ed6c1
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions peer-prep-fe/src/landing-page/landing-page.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { Question } from "../app/models/question.model"

export class LandingPageComponent {
@ViewChild(MatchModalComponent) matchModal!: MatchModalComponent;
selectedDifficulty: string = '';
selectedDifficulty: string | null = null;
selectedCategory: string | null = null;
question_categories: string[] = [];
questions: Question[] = [];
Expand Down Expand Up @@ -242,18 +242,20 @@ export class LandingPageComponent {
}

handleFindMatch() {
console.log("selectedDifficulty", this.selectedDifficulty);
console.log('in handle')
this.errorMessage = null;
const hasSelectedDifficulty = this.selectedDifficulty !== null;
// const hasSelectedTopics = this.question_categories.some(topic => topic.selected);
const hasSelectedTopics = this.selectedCategory !== null;
this.matchButtonActive = hasSelectedDifficulty && hasSelectedTopics;

if (!hasSelectedDifficulty && !hasSelectedTopics) {
this.displayError("Please select one difficulty and at least one topic.");
this.displayError("Please select one difficulty to choose a topic.");
} else if (!hasSelectedDifficulty && hasSelectedTopics) {
this.displayError("Please select a difficulty before selecting a topic.");
} else if (hasSelectedDifficulty && !hasSelectedTopics) {
this.displayError("Please select at least one topic.");
this.displayError("Please select one topic.");
}
else {
this.errorMessage = null;
Expand Down

0 comments on commit 35ed6c1

Please sign in to comment.