Skip to content

Commit

Permalink
Merge pull request #110 from CS3219-AY2425S1/aiden-question-fixes
Browse files Browse the repository at this point in the history
Change error messages
  • Loading branch information
lynnetteeee authored Nov 14, 2024
2 parents b78263a + 4cb281f commit 8671185
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion peer-prep-fe/src/add-page/add-page.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,6 @@ <h2>CATEGORY</h2>
</div>

<div class="saving-button">
<button class="save-button" (click)="saveQuestion()">SAVE</button>
<button class="save-button" (click)="saveQuestion()" [disabled]="questionForm.invalid">SAVE</button>
</div>
</div>
9 changes: 8 additions & 1 deletion peer-prep-fe/src/add-page/add-page.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ export class AddPageComponent {
this.questionForm.markAllAsTouched()
return
}

const selectedCategories = this.question_categories.filter(cat => cat.selected);
if (selectedCategories.length === 0) {
alert("Please select at least one category.");
return;
}

const newQuestion = {
Question_title: this.questionForm.value.question_title,
Question_description: this.questionForm.value.question_description,
Expand All @@ -94,7 +101,7 @@ export class AddPageComponent {
this.onAddComplete()
},
(error) => {
alert("Error adding question")
alert("Question with the same title already exists, duplicate questions aren’t allowed!")
}
)
}
Expand Down
2 changes: 1 addition & 1 deletion peer-prep-fe/src/edit-page/edit-page.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,6 @@ <h2>CATEGORY</h2>
</div>

<div class="saving-button">
<button class="save-button" (click)="saveQuestion()">SAVE</button>
<button class="save-button" (click)="saveQuestion()" [disabled]="questionForm.invalid">SAVE</button>
</div>
</div>
2 changes: 1 addition & 1 deletion peer-prep-fe/src/edit-page/edit-page.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export class EditPageComponent implements OnInit {
this.onEditComplete()
},
(error) => {
alert("Error updating question")
alert("Question with the same title already exists, duplicate questions aren’t allowed!")
}
)
}
Expand Down

0 comments on commit 8671185

Please sign in to comment.