From 80e86d8bb9293f6a76e25e7d1e0f0ac4aa92bf09 Mon Sep 17 00:00:00 2001 From: sowgro Date: Mon, 7 Apr 2025 14:04:26 -0400 Subject: Add required text and improve validation --- .../app/components/need-edit/need-edit.component.css | 5 +++++ .../app/components/need-edit/need-edit.component.html | 14 +++++++------- .../app/components/need-edit/need-edit.component.ts | 18 +++--------------- 3 files changed, 15 insertions(+), 22 deletions(-) (limited to 'ufund-ui') diff --git a/ufund-ui/src/app/components/need-edit/need-edit.component.css b/ufund-ui/src/app/components/need-edit/need-edit.component.css index b06e061..9ef9292 100644 --- a/ufund-ui/src/app/components/need-edit/need-edit.component.css +++ b/ufund-ui/src/app/components/need-edit/need-edit.component.css @@ -49,3 +49,8 @@ textarea { label { padding: 3px; } + + +.red { + color: red; +} diff --git a/ufund-ui/src/app/components/need-edit/need-edit.component.html b/ufund-ui/src/app/components/need-edit/need-edit.component.html index ed4bfb3..f7eec63 100644 --- a/ufund-ui/src/app/components/need-edit/need-edit.component.html +++ b/ufund-ui/src/app/components/need-edit/need-edit.component.html @@ -3,23 +3,23 @@

{{this.mode}} Need

- Name: + Name *Required
- Image: + Image
- Location: + Location
- Max Goal: + Max Goal *Required
- Type: + Type *Required
- Urgency: + Urgency
- Description: + Description
diff --git a/ufund-ui/src/app/components/need-edit/need-edit.component.ts b/ufund-ui/src/app/components/need-edit/need-edit.component.ts index b63d9c1..3c42c34 100644 --- a/ufund-ui/src/app/components/need-edit/need-edit.component.ts +++ b/ufund-ui/src/app/components/need-edit/need-edit.component.ts @@ -39,7 +39,7 @@ export class NeedEditComponent implements OnChanges { id: this.needCopy.id, //system will control this maxGoal: form.maxGoal, type: GoalType[form.type as keyof typeof GoalType], - urgent: form.urgent, + urgent: form.urgent ?? false, filterAttributes: [], current: 0, description: form.description @@ -56,13 +56,7 @@ export class NeedEditComponent implements OnChanges { need.current = this.need?.current ?? 0 this.cupboardService.updateNeed(need.id, need) .pipe(catchError((ex, _) => { - if (ex.status == 500) { - this.toastService.sendToast(ToastType.ERROR, 'Fields cannot be blank'); - } else if (ex.status == 400) { - this.toastService.sendToast(ToastType.ERROR, ex.error); - } else { - this.toastService.sendToast(ToastType.ERROR, "Error on creating need"); - } + this.toastService.sendToast(ToastType.ERROR, ex.error); return of() })) .subscribe( @@ -83,13 +77,7 @@ export class NeedEditComponent implements OnChanges { createNeed(need: Need) { this.cupboardService.createNeed(need) .pipe(catchError((ex, _) => { - if (ex.status == 500) { - this.toastService.sendToast(ToastType.ERROR, "Fields cannot be blank"); - } else if (ex.status == 400) { - this.toastService.sendToast(ToastType.ERROR, ex.error); - } else { - this.toastService.sendToast(ToastType.ERROR, "Error on creating need"); - } + this.toastService.sendToast(ToastType.ERROR, ex.error); return of() })) .subscribe( -- cgit v1.2.3