From 237b9197c08c46a11fe45347e2d41428a558f75b Mon Sep 17 00:00:00 2001 From: benal01 Date: Thu, 20 Mar 2025 10:18:43 -0400 Subject: component style refactor for simpler display --- ufund-ui/src/app/components/cupboard/cupboard.component.ts | 2 -- 1 file changed, 2 deletions(-) (limited to 'ufund-ui/src/app/components/cupboard/cupboard.component.ts') diff --git a/ufund-ui/src/app/components/cupboard/cupboard.component.ts b/ufund-ui/src/app/components/cupboard/cupboard.component.ts index 24b3e2d..f8023c3 100644 --- a/ufund-ui/src/app/components/cupboard/cupboard.component.ts +++ b/ufund-ui/src/app/components/cupboard/cupboard.component.ts @@ -55,7 +55,6 @@ export class CupboardComponent implements OnInit { element.style.position = 'relative'; } } - openmenu() { const menuElement = document.getElementById('menu'); this.showElement(menuElement); @@ -79,7 +78,6 @@ export class CupboardComponent implements OnInit { close() { this.hideElement(document.getElementById('create-form')); this.hideElement(document.getElementById('destroy-form')); - this.hideElement(document.getElementById('menu')); this.hideElement(document.getElementById('update-form')); } -- cgit v1.2.3 From e9564ba2514f32c63d2ce4ecfc9eeb9f3269f3dd Mon Sep 17 00:00:00 2001 From: benal01 Date: Sat, 22 Mar 2025 12:14:00 -0400 Subject: [ngClass] tab styling --- .../app/components/cupboard/cupboard.component.ts | 46 ++-------------------- 1 file changed, 4 insertions(+), 42 deletions(-) (limited to 'ufund-ui/src/app/components/cupboard/cupboard.component.ts') diff --git a/ufund-ui/src/app/components/cupboard/cupboard.component.ts b/ufund-ui/src/app/components/cupboard/cupboard.component.ts index f8023c3..646c4ff 100644 --- a/ufund-ui/src/app/components/cupboard/cupboard.component.ts +++ b/ufund-ui/src/app/components/cupboard/cupboard.component.ts @@ -16,7 +16,7 @@ import { NeedListComponent } from '../need-list/need-list.component'; export class CupboardComponent implements OnInit { protected statusText = new BehaviorSubject("") - + selectedForm = "create" needs: any; @ViewChild("needList") needList?: NeedListComponent @@ -24,9 +24,6 @@ export class CupboardComponent implements OnInit { ngOnInit(): void { this.cupboardService.getNeeds().subscribe(n => this.needs = n); - this.close(); - this.openmenu(); - if (this.isManager()) { console.log("Admin view of Cupboard"); } else { @@ -41,44 +38,9 @@ export class CupboardComponent implements OnInit { type: '' }; selectedNeedId: number | null = null; - - private hideElement(element: any) { - if (element) { - element.style.visibility = 'hidden'; - element.style.position = 'absolute'; - } - } - - private showElement(element: any) { - if (element) { - element.style.visibility = 'visible'; - element.style.position = 'relative'; - } - } - openmenu() { - const menuElement = document.getElementById('menu'); - this.showElement(menuElement); - } - - opencreate() { - this.close(); - this.showElement(document.getElementById('create-form')); - } - - openupdate() { - this.close(); - this.showElement(document.getElementById('update-form')); - } - - back() { - this.close(); - this.openmenu(); - } - - close() { - this.hideElement(document.getElementById('create-form')); - this.hideElement(document.getElementById('destroy-form')); - this.hideElement(document.getElementById('update-form')); + + selectForm(name: string) { + this.selectedForm = name; } populateForm(need: any): void { -- cgit v1.2.3 From f0ac1eda74367afc375112a7269c085a511ce490 Mon Sep 17 00:00:00 2001 From: benal01 Date: Mon, 24 Mar 2025 22:23:36 -0400 Subject: viewing search results inside cupboard component --- .../app/components/cupboard/cupboard.component.ts | 28 +++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'ufund-ui/src/app/components/cupboard/cupboard.component.ts') diff --git a/ufund-ui/src/app/components/cupboard/cupboard.component.ts b/ufund-ui/src/app/components/cupboard/cupboard.component.ts index 646c4ff..e38f8c0 100644 --- a/ufund-ui/src/app/components/cupboard/cupboard.component.ts +++ b/ufund-ui/src/app/components/cupboard/cupboard.component.ts @@ -16,10 +16,9 @@ import { NeedListComponent } from '../need-list/need-list.component'; export class CupboardComponent implements OnInit { protected statusText = new BehaviorSubject("") - selectedForm = "create" + selectedForm = "create"; needs: any; - @ViewChild("needList") needList?: NeedListComponent - + @ViewChild("needList") needList?: NeedListComponent; constructor(private cupboardService: CupboardService, private usersService: UsersService) { } ngOnInit(): void { @@ -38,9 +37,32 @@ export class CupboardComponent implements OnInit { type: '' }; selectedNeedId: number | null = null; + searchResults: any[] = []; selectForm(name: string) { + //get search results from the need list + if (this.needList) { + this.searchResults = this.needList.searchResults; + } + console.log(this.searchResults) this.selectedForm = name; + if (name == 'update') { + if (this.searchResults) { + this.searchResults.forEach((element: any) => { + console.log(element) + }); + } + + } + } + + async updateSearchResults() { + if (this.needList) { + while (this.selectedForm == 'update') { + this.searchResults = this.needList.searchResults + await new Promise(resolve => setTimeout(resolve, 100)); + } + } } populateForm(need: any): void { -- cgit v1.2.3 From ea13cf6ab3b71ff5e83fca876ec71fec1f7b00ae Mon Sep 17 00:00:00 2001 From: sowgro Date: Wed, 26 Mar 2025 15:38:46 -0400 Subject: Make frontend work with the new backend checkout system --- .../app/components/cupboard/cupboard.component.ts | 58 +++------------------- 1 file changed, 8 insertions(+), 50 deletions(-) (limited to 'ufund-ui/src/app/components/cupboard/cupboard.component.ts') diff --git a/ufund-ui/src/app/components/cupboard/cupboard.component.ts b/ufund-ui/src/app/components/cupboard/cupboard.component.ts index 24b3e2d..a812baf 100644 --- a/ufund-ui/src/app/components/cupboard/cupboard.component.ts +++ b/ufund-ui/src/app/components/cupboard/cupboard.component.ts @@ -1,10 +1,10 @@ import { Component, OnInit, ViewChild } from '@angular/core'; import { CupboardService } from '../../services/cupboard.service'; -import { UsersService } from '../../services/users.service'; import { Need, GoalType } from '../../models/Need'; import { userType } from '../../models/User'; import { BehaviorSubject, catchError, of } from 'rxjs'; import { NeedListComponent } from '../need-list/need-list.component'; +import {AuthService} from '../../services/auth.service'; @Component({ selector: 'app-cupboard', @@ -20,7 +20,10 @@ export class CupboardComponent implements OnInit { needs: any; @ViewChild("needList") needList?: NeedListComponent - constructor(private cupboardService: CupboardService, private usersService: UsersService) { } + constructor( + private cupboardService: CupboardService, + private authService: AuthService + ) {} ngOnInit(): void { this.cupboardService.getNeeds().subscribe(n => this.needs = n); @@ -88,7 +91,7 @@ export class CupboardComponent implements OnInit { } isManager() { - const type = this.usersService.getCurrentUser()?.type; + const type = this.authService.getCurrentUser()?.type; return type === ("MANAGER" as unknown as userType); } @@ -105,7 +108,7 @@ export class CupboardComponent implements OnInit { console.log("need:", need); console.log(need.id, need, "need updated"); this.cupboardService.updateNeed(need.id, need) - .pipe(catchError((ex, r) => { + .pipe(catchError((ex, _) => { if (ex.status == 500) { this.statusText.next("Fields cannot be blank"); } else if (ex.status == 400) { @@ -140,7 +143,7 @@ export class CupboardComponent implements OnInit { console.log("need:", need); console.log("form submitted. creating need: ", need); this.cupboardService.createNeed(need) - .pipe(catchError((ex, r) => { + .pipe(catchError((ex, _) => { if (ex.status == 500) { this.statusText.next("Fields cannot be blank"); } else if (ex.status == 400) { @@ -167,48 +170,3 @@ export class CupboardComponent implements OnInit { } } - -let friendlyHttpStatus: { [key: number]: string } = { - 200: 'OK', - 201: 'Created', - 202: 'Accepted', - 203: 'Non-Authoritative Information', - 204: 'No Content', - 205: 'Reset Content', - 206: 'Partial Content', - 300: 'Multiple Choices', - 301: 'Moved Permanently', - 302: 'Found', - 303: 'See Other', - 304: 'Not Modified', - 305: 'Use Proxy', - 306: 'Unused', - 307: 'Temporary Redirect', - 400: 'Bad Request', - 401: 'Unauthorized', - 402: 'Payment Required', - 403: 'Forbidden', - 404: 'Not Found', - 405: 'Method Not Allowed', - 406: 'Not Acceptable', - 407: 'Proxy Authentication Required', - 408: 'Request Timeout', - 409: 'Conflict', - 410: 'Gone', - 411: 'Length Required', - 412: 'Precondition Required', - 413: 'Request Entry Too Large', - 414: 'Request-URI Too Long', - 415: 'Unsupported Media Type', - 416: 'Requested Range Not Satisfiable', - 417: 'Expectation Failed', - 418: 'I\'m a teapot', - 422: 'Unprocessable Entity', - 429: 'Too Many Requests', - 500: 'Internal Server Error', - 501: 'Not Implemented', - 502: 'Bad Gateway', - 503: 'Service Unavailable', - 504: 'Gateway Timeout', - 505: 'HTTP Version Not Supported', -}; -- cgit v1.2.3 From 0829feb20e60bc6d323dcc0d9376f4feb45115eb Mon Sep 17 00:00:00 2001 From: sowgro Date: Wed, 26 Mar 2025 18:23:17 -0400 Subject: Push starter code for Input() --- ufund-ui/src/app/components/cupboard/cupboard.component.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'ufund-ui/src/app/components/cupboard/cupboard.component.ts') diff --git a/ufund-ui/src/app/components/cupboard/cupboard.component.ts b/ufund-ui/src/app/components/cupboard/cupboard.component.ts index e38f8c0..cf9b95e 100644 --- a/ufund-ui/src/app/components/cupboard/cupboard.component.ts +++ b/ufund-ui/src/app/components/cupboard/cupboard.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit, ViewChild } from '@angular/core'; +import {Component, Input, OnInit, ViewChild} from '@angular/core'; import { CupboardService } from '../../services/cupboard.service'; import { UsersService } from '../../services/users.service'; import { Need, GoalType } from '../../models/Need'; @@ -38,9 +38,9 @@ export class CupboardComponent implements OnInit { }; selectedNeedId: number | null = null; searchResults: any[] = []; - + selectForm(name: string) { - //get search results from the need list + //get search results from the need list if (this.needList) { this.searchResults = this.needList.searchResults; } -- cgit v1.2.3 From 959aa5101fbba55f20eda46d02addd27a74cf950 Mon Sep 17 00:00:00 2001 From: benal01 Date: Wed, 26 Mar 2025 19:03:16 -0400 Subject: snap form open on edit event --- ufund-ui/src/app/components/cupboard/cupboard.component.ts | 1 + 1 file changed, 1 insertion(+) (limited to 'ufund-ui/src/app/components/cupboard/cupboard.component.ts') diff --git a/ufund-ui/src/app/components/cupboard/cupboard.component.ts b/ufund-ui/src/app/components/cupboard/cupboard.component.ts index cf9b95e..0d2c1f5 100644 --- a/ufund-ui/src/app/components/cupboard/cupboard.component.ts +++ b/ufund-ui/src/app/components/cupboard/cupboard.component.ts @@ -66,6 +66,7 @@ export class CupboardComponent implements OnInit { } populateForm(need: any): void { + this.selectForm('update'); this.selectedNeed = { ...need }; } -- cgit v1.2.3 From d5ae670dbce9e5cabbd594759df490176fd8cecd Mon Sep 17 00:00:00 2001 From: benal01 Date: Wed, 26 Mar 2025 19:12:52 -0400 Subject: use selected id for the update form --- ufund-ui/src/app/components/cupboard/cupboard.component.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'ufund-ui/src/app/components/cupboard/cupboard.component.ts') diff --git a/ufund-ui/src/app/components/cupboard/cupboard.component.ts b/ufund-ui/src/app/components/cupboard/cupboard.component.ts index 0d2c1f5..a8b9c14 100644 --- a/ufund-ui/src/app/components/cupboard/cupboard.component.ts +++ b/ufund-ui/src/app/components/cupboard/cupboard.component.ts @@ -79,14 +79,13 @@ export class CupboardComponent implements OnInit { console.log(form); const need: Need = { name: form.name, - id: form.id, //system will control this + id: this.selectedNeed.id, //system will control this maxGoal: form.maxGoal, type: GoalType[form.type as keyof typeof GoalType], filterAttributes: [], current: 0 }; - console.log("need:", need); - console.log(need.id, need, "need updated"); + this.cupboardService.updateNeed(need.id, need) .pipe(catchError((ex, r) => { if (ex.status == 500) { -- cgit v1.2.3 From 61b5b762b150c82e7d48190bcfe3416bfea96059 Mon Sep 17 00:00:00 2001 From: benal01 Date: Sat, 29 Mar 2025 14:37:57 -0400 Subject: frontend implementation of a needs' urgency and location --- ufund-ui/src/app/components/cupboard/cupboard.component.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'ufund-ui/src/app/components/cupboard/cupboard.component.ts') diff --git a/ufund-ui/src/app/components/cupboard/cupboard.component.ts b/ufund-ui/src/app/components/cupboard/cupboard.component.ts index a8b9c14..540a058 100644 --- a/ufund-ui/src/app/components/cupboard/cupboard.component.ts +++ b/ufund-ui/src/app/components/cupboard/cupboard.component.ts @@ -32,9 +32,11 @@ export class CupboardComponent implements OnInit { selectedNeed: any = { name: '', + location:'', id: null, maxGoal: null, - type: '' + type: '', + urgent: false }; selectedNeedId: number | null = null; searchResults: any[] = []; @@ -79,9 +81,11 @@ export class CupboardComponent implements OnInit { console.log(form); const need: Need = { name: form.name, + location: form.location, id: this.selectedNeed.id, //system will control this maxGoal: form.maxGoal, type: GoalType[form.type as keyof typeof GoalType], + urgent: form.urgent, filterAttributes: [], current: 0 }; @@ -113,9 +117,11 @@ export class CupboardComponent implements OnInit { submit(form: any) { const need: Need = { name: form.name, + location: form.location, id: 0, maxGoal: form.maxGoal, type: form.type, + urgent: form.urgent, filterAttributes: [], current: 0 }; -- cgit v1.2.3 From 760b8efef4d683d26404ebca75b7a9c44a1db3a9 Mon Sep 17 00:00:00 2001 From: benal01 Date: Sun, 30 Mar 2025 00:46:50 -0400 Subject: urgency sorting --- ufund-ui/src/app/components/cupboard/cupboard.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ufund-ui/src/app/components/cupboard/cupboard.component.ts') diff --git a/ufund-ui/src/app/components/cupboard/cupboard.component.ts b/ufund-ui/src/app/components/cupboard/cupboard.component.ts index 540a058..ad68c38 100644 --- a/ufund-ui/src/app/components/cupboard/cupboard.component.ts +++ b/ufund-ui/src/app/components/cupboard/cupboard.component.ts @@ -121,7 +121,7 @@ export class CupboardComponent implements OnInit { id: 0, maxGoal: form.maxGoal, type: form.type, - urgent: form.urgent, + urgent: form.urgent ? true : false, filterAttributes: [], current: 0 }; -- cgit v1.2.3 From d4dd348e81d3aef4cc62335f1dad5a02452dfadd Mon Sep 17 00:00:00 2001 From: benal01 Date: Mon, 31 Mar 2025 10:16:03 -0400 Subject: frontend model support for description --- ufund-ui/src/app/components/cupboard/cupboard.component.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'ufund-ui/src/app/components/cupboard/cupboard.component.ts') diff --git a/ufund-ui/src/app/components/cupboard/cupboard.component.ts b/ufund-ui/src/app/components/cupboard/cupboard.component.ts index 85ffd17..feb39e0 100644 --- a/ufund-ui/src/app/components/cupboard/cupboard.component.ts +++ b/ufund-ui/src/app/components/cupboard/cupboard.component.ts @@ -91,7 +91,8 @@ export class CupboardComponent implements OnInit { type: GoalType[form.type as keyof typeof GoalType], urgent: form.urgent, filterAttributes: [], - current: 0 + current: 0, + description: form.description }; this.cupboardService.updateNeed(need.id, need) @@ -127,7 +128,8 @@ export class CupboardComponent implements OnInit { type: form.type, urgent: form.urgent ? true : false, filterAttributes: [], - current: 0 + current: 0, + description: form.description }; console.log("need:", need); console.log("form submitted. creating need: ", need); -- cgit v1.2.3 From cb5be32bf0d050cc1fd37d7cc9b4c51e1c51fffe Mon Sep 17 00:00:00 2001 From: Gunther6070 Date: Mon, 31 Mar 2025 12:08:22 -0400 Subject: Added dynamic error messaging to the cupboard --- ufund-ui/src/app/components/cupboard/cupboard.component.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'ufund-ui/src/app/components/cupboard/cupboard.component.ts') diff --git a/ufund-ui/src/app/components/cupboard/cupboard.component.ts b/ufund-ui/src/app/components/cupboard/cupboard.component.ts index 85ffd17..88ab46c 100644 --- a/ufund-ui/src/app/components/cupboard/cupboard.component.ts +++ b/ufund-ui/src/app/components/cupboard/cupboard.component.ts @@ -1,4 +1,4 @@ -import {Component, Input, OnInit, ViewChild} from '@angular/core'; +import {Component, OnInit, ViewChild} from '@angular/core'; import { CupboardService } from '../../services/cupboard.service'; import { Need, GoalType } from '../../models/Need'; import { userType } from '../../models/User'; @@ -99,7 +99,7 @@ export class CupboardComponent implements OnInit { if (ex.status == 500) { this.statusText.next("Fields cannot be blank"); } else if (ex.status == 400) { - this.statusText.next("Goal must be greater than 0"); + this.statusText.next(ex.error); } else { this.statusText.next("Error on creating need"); } @@ -136,7 +136,7 @@ export class CupboardComponent implements OnInit { if (ex.status == 500) { this.statusText.next("Fields cannot be blank"); } else if (ex.status == 400) { - this.statusText.next("Goal must be greater than 0"); + this.statusText.next(ex.error); } else { this.statusText.next("Error on creating need"); } -- cgit v1.2.3 From a2e1329a510375fdada021c3d6a2f631a9c162ee Mon Sep 17 00:00:00 2001 From: benal01 Date: Mon, 31 Mar 2025 17:51:17 -0400 Subject: image property frontend support --- ufund-ui/src/app/components/cupboard/cupboard.component.ts | 2 ++ 1 file changed, 2 insertions(+) (limited to 'ufund-ui/src/app/components/cupboard/cupboard.component.ts') diff --git a/ufund-ui/src/app/components/cupboard/cupboard.component.ts b/ufund-ui/src/app/components/cupboard/cupboard.component.ts index feb39e0..9c8a173 100644 --- a/ufund-ui/src/app/components/cupboard/cupboard.component.ts +++ b/ufund-ui/src/app/components/cupboard/cupboard.component.ts @@ -85,6 +85,7 @@ export class CupboardComponent implements OnInit { console.log(form); const need: Need = { name: form.name, + image: form.image, location: form.location, id: this.selectedNeed.id, //system will control this maxGoal: form.maxGoal, @@ -122,6 +123,7 @@ export class CupboardComponent implements OnInit { submit(form: any) { const need: Need = { name: form.name, + image: form.image, location: form.location, id: 0, maxGoal: form.maxGoal, -- cgit v1.2.3 From e1ef22279baccb4b2a5a1ecbb5222e4008d4d523 Mon Sep 17 00:00:00 2001 From: Gunther6070 Date: Mon, 31 Mar 2025 20:28:35 -0400 Subject: Added toasts for error handling --- .../app/components/cupboard/cupboard.component.ts | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'ufund-ui/src/app/components/cupboard/cupboard.component.ts') diff --git a/ufund-ui/src/app/components/cupboard/cupboard.component.ts b/ufund-ui/src/app/components/cupboard/cupboard.component.ts index 9c8a173..653edd4 100644 --- a/ufund-ui/src/app/components/cupboard/cupboard.component.ts +++ b/ufund-ui/src/app/components/cupboard/cupboard.component.ts @@ -1,10 +1,11 @@ -import {Component, Input, OnInit, ViewChild} from '@angular/core'; +import {Component, OnInit, ViewChild} from '@angular/core'; import { CupboardService } from '../../services/cupboard.service'; import { Need, GoalType } from '../../models/Need'; import { userType } from '../../models/User'; -import { BehaviorSubject, catchError, of } from 'rxjs'; +import { catchError, of } from 'rxjs'; import { NeedListComponent } from '../need-list/need-list.component'; import {AuthService} from '../../services/auth.service'; +import {ToastsService, ToastType} from '../../services/toasts.service'; @Component({ selector: 'app-cupboard', @@ -15,14 +16,14 @@ import {AuthService} from '../../services/auth.service'; export class CupboardComponent implements OnInit { - protected statusText = new BehaviorSubject("") selectedForm = "create"; needs: any; @ViewChild("needList") needList?: NeedListComponent constructor( private cupboardService: CupboardService, - private authService: AuthService + private authService: AuthService, + private toastService: ToastsService ) {} ngOnInit(): void { @@ -99,11 +100,11 @@ export class CupboardComponent implements OnInit { this.cupboardService.updateNeed(need.id, need) .pipe(catchError((ex, _) => { if (ex.status == 500) { - this.statusText.next("Fields cannot be blank"); + this.toastService.sendToast(ToastType.INFO, 'Fields cannot be blank'); } else if (ex.status == 400) { - this.statusText.next("Goal must be greater than 0"); + this.toastService.sendToast(ToastType.INFO, "Goal must be greater than 0"); } else { - this.statusText.next("Error on creating need"); + this.toastService.sendToast(ToastType.INFO, "Error on creating need"); } return of() })) @@ -138,11 +139,11 @@ export class CupboardComponent implements OnInit { this.cupboardService.createNeed(need) .pipe(catchError((ex, _) => { if (ex.status == 500) { - this.statusText.next("Fields cannot be blank"); + this.toastService.sendToast(ToastType.INFO, "Fields cannot be blank"); } else if (ex.status == 400) { - this.statusText.next("Goal must be greater than 0"); + this.toastService.sendToast(ToastType.INFO, "Goal must be greater than 0"); } else { - this.statusText.next("Error on creating need"); + this.toastService.sendToast(ToastType.INFO, "Error on creating need"); } return of() })) -- cgit v1.2.3 From 9c9708cc846dafe33234c38c37425468b9877514 Mon Sep 17 00:00:00 2001 From: Gunther6070 Date: Mon, 31 Mar 2025 21:32:55 -0400 Subject: Updated toast's types --- ufund-ui/src/app/components/cupboard/cupboard.component.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'ufund-ui/src/app/components/cupboard/cupboard.component.ts') diff --git a/ufund-ui/src/app/components/cupboard/cupboard.component.ts b/ufund-ui/src/app/components/cupboard/cupboard.component.ts index fff8760..662def4 100644 --- a/ufund-ui/src/app/components/cupboard/cupboard.component.ts +++ b/ufund-ui/src/app/components/cupboard/cupboard.component.ts @@ -100,11 +100,11 @@ export class CupboardComponent implements OnInit { this.cupboardService.updateNeed(need.id, need) .pipe(catchError((ex, _) => { if (ex.status == 500) { - this.toastService.sendToast(ToastType.INFO, 'Fields cannot be blank'); + this.toastService.sendToast(ToastType.ERROR, 'Fields cannot be blank'); } else if (ex.status == 400) { - this.toastService.sendToast(ToastType.INFO, ex.error); + this.toastService.sendToast(ToastType.ERROR, ex.error); } else { - this.toastService.sendToast(ToastType.INFO, "Error on creating need"); + this.toastService.sendToast(ToastType.ERROR, "Error on creating need"); } return of() })) @@ -139,11 +139,11 @@ export class CupboardComponent implements OnInit { this.cupboardService.createNeed(need) .pipe(catchError((ex, _) => { if (ex.status == 500) { - this.toastService.sendToast(ToastType.INFO, "Fields cannot be blank"); + this.toastService.sendToast(ToastType.ERROR, "Fields cannot be blank"); } else if (ex.status == 400) { - this.toastService.sendToast(ToastType.INFO, ex.error); + this.toastService.sendToast(ToastType.ERROR, ex.error); } else { - this.toastService.sendToast(ToastType.INFO, "Error on creating need"); + this.toastService.sendToast(ToastType.ERROR, "Error on creating need"); } return of() })) -- cgit v1.2.3 From 786a6db3f5a22f7bb2cc249731ef654b675c3c86 Mon Sep 17 00:00:00 2001 From: benal01 Date: Mon, 31 Mar 2025 22:15:37 -0400 Subject: moving functionality to new component --- .../app/components/cupboard/cupboard.component.ts | 39 ---------------------- 1 file changed, 39 deletions(-) (limited to 'ufund-ui/src/app/components/cupboard/cupboard.component.ts') diff --git a/ufund-ui/src/app/components/cupboard/cupboard.component.ts b/ufund-ui/src/app/components/cupboard/cupboard.component.ts index 662def4..e70d98f 100644 --- a/ufund-ui/src/app/components/cupboard/cupboard.component.ts +++ b/ufund-ui/src/app/components/cupboard/cupboard.component.ts @@ -82,45 +82,6 @@ export class CupboardComponent implements OnInit { return type === ("MANAGER" as unknown as userType); } - update(form: any) { - console.log(form); - const need: Need = { - name: form.name, - image: form.image, - location: form.location, - id: this.selectedNeed.id, //system will control this - maxGoal: form.maxGoal, - type: GoalType[form.type as keyof typeof GoalType], - urgent: form.urgent, - filterAttributes: [], - current: 0, - description: form.description - }; - - 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"); - } - return of() - })) - .subscribe( - (result) => { - if (result) { - console.log("need updated successfully"); - this.needList?.refresh() - } else { - console.log("need update failed"); - } - } - - ); - } - submit(form: any) { const need: Need = { name: form.name, -- cgit v1.2.3 From 0e9c0803e35a23ef2e873dc7ebf224a49a92f207 Mon Sep 17 00:00:00 2001 From: sowgro Date: Tue, 1 Apr 2025 02:16:04 -0400 Subject: Get everything working enough to go in main --- ufund-ui/src/app/components/cupboard/cupboard.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ufund-ui/src/app/components/cupboard/cupboard.component.ts') diff --git a/ufund-ui/src/app/components/cupboard/cupboard.component.ts b/ufund-ui/src/app/components/cupboard/cupboard.component.ts index e70d98f..2230cd3 100644 --- a/ufund-ui/src/app/components/cupboard/cupboard.component.ts +++ b/ufund-ui/src/app/components/cupboard/cupboard.component.ts @@ -16,7 +16,7 @@ import {ToastsService, ToastType} from '../../services/toasts.service'; export class CupboardComponent implements OnInit { - selectedForm = "create"; + selectedForm?: string = undefined; needs: any; @ViewChild("needList") needList?: NeedListComponent -- cgit v1.2.3