From 896e1219526a19400c7143b274193f8b818d6156 Mon Sep 17 00:00:00 2001 From: sowgro Date: Mon, 31 Mar 2025 23:37:00 -0400 Subject: Commit half working changes to move to my laptop --- .../components/need-page/need-page.component.css | 57 ++++++++++++++++++++ .../components/need-page/need-page.component.html | 41 ++++++++++++-- .../components/need-page/need-page.component.ts | 62 ++++++++++++++++++++-- 3 files changed, 153 insertions(+), 7 deletions(-) (limited to 'ufund-ui/src/app/components/need-page') diff --git a/ufund-ui/src/app/components/need-page/need-page.component.css b/ufund-ui/src/app/components/need-page/need-page.component.css index a3a4014..f950171 100644 --- a/ufund-ui/src/app/components/need-page/need-page.component.css +++ b/ufund-ui/src/app/components/need-page/need-page.component.css @@ -8,3 +8,60 @@ flex-direction: column; width: 1000px; } + +.needName { + font-weight: bold; +} + +.needType { + text-transform: uppercase; + font-size: 10pt; +} + +.split { + display: flex; + flex-direction: row; + justify-content: space-between; + + + .left { + display: flex; + flex-direction: column; + } + + .right { + display: flex; + flex-direction: column; + align-items: end; + } +} + +.urgent { + font-size: 11pt; + background-color: rgba(255, 165, 0, 0.27); + color: rgba(255, 165, 0, 1); + padding: 2px; + border-radius: 5px; +} + +.prog { + display: flex; + flex-direction: column; +} + +.actionArea { + display: flex; + padding: 5px; + gap: 5px; +} + +#editor { + position: absolute; + background-color: #4a4a4a; + display: flex; + flex-direction: column; + justify-self: center; + align-self: center; + padding: 20px; + box-shadow: 0 0 100px black; +} diff --git a/ufund-ui/src/app/components/need-page/need-page.component.html b/ufund-ui/src/app/components/need-page/need-page.component.html index a72167c..a8479fd 100644 --- a/ufund-ui/src/app/components/need-page/need-page.component.html +++ b/ufund-ui/src/app/components/need-page/need-page.component.html @@ -13,14 +13,47 @@
+ {{need?.description}} + Need image

Location: {{need?.location}}

Urgent: {{need?.urgent}}

{{need?.current}} / {{need?.maxGoal}} This goal is {{(((need?.current ?? 0)*100) / (need?.maxGoal ?? 0)).toFixed(0)}}% complete! -
- - - +
+ + + +
+ +
+
+
+ {{need.name}} + {{need.type}} +
+ +
+ URGENT + location_on{{need.location}} +
+
+ +
+ +
+ + {{need.current}}/{{need.maxGoal}} ({{((need.current / need.maxGoal) * 100).toFixed(0)}}%) + +
+
+ +
diff --git a/ufund-ui/src/app/components/need-page/need-page.component.ts b/ufund-ui/src/app/components/need-page/need-page.component.ts index e38554c..ad4cacf 100644 --- a/ufund-ui/src/app/components/need-page/need-page.component.ts +++ b/ufund-ui/src/app/components/need-page/need-page.component.ts @@ -1,8 +1,12 @@ import {Component, Input} from '@angular/core'; import {GoalType, Need} from '../../models/Need'; -import {ActivatedRoute} from "@angular/router"; +import {ActivatedRoute, Router} from "@angular/router"; import {CupboardService} from "../../services/cupboard.service"; -import {NgFor} from '@angular/common'; +import {userType} from '../../models/User'; +import {AuthService} from '../../services/auth.service'; +import {catchError, of} from 'rxjs'; +import {ToastsService, ToastType} from '../../services/toasts.service'; +import {UsersService} from '../../services/users.service'; @Component({ selector: 'app-need-page', @@ -14,11 +18,15 @@ export class NeedPageComponent { constructor( private route: ActivatedRoute, private cupboardService: CupboardService, + private authService: AuthService, + private usersService: UsersService, + private toastService: ToastsService, + private router: Router ) {} public GoalType = GoalType; - @Input() need?: Need; + @Input() need!: Need; ngOnInit(): void { const id = Number(this.route.snapshot.paramMap.get('id')); @@ -28,4 +36,52 @@ export class NeedPageComponent { back() { window.history.back(); } + + isManager() { + const type = this.authService.getCurrentUser()?.type; + return type === ("MANAGER" as unknown as userType); + } + + isHelper() { + const type = this.authService.getCurrentUser()?.type; + return type === ("HELPER" as unknown as userType); + } + + add(need: Need) { + const currentUser = this.authService.getCurrentUser(); + //console.log("get current user in angular:", currentUser) + if (currentUser) { + if (!currentUser.basket.includes(need.id)) { + currentUser.basket.push(need.id); + this.usersService.updateUser(currentUser) + .pipe(catchError((err, _) => { + console.error(err); + return of(); + })) + .subscribe(() => { + this.usersService.refreshBasket(); + }); + } else { + this.toastService.sendToast(ToastType.ERROR, "This need is already in your basket!") + } + } + } + + delete(id : number) { + this.cupboardService.deleteNeed(id) + .pipe(catchError((ex, r) => { + this.toastService.sendToast(ToastType.ERROR, ex.error) + return of() + })) + .subscribe(() => { + // this.needs = this.needs.filter(n => n.id !== id) + this.toastService.sendToast(ToastType.INFO, "Need deleted") + this.router.navigate(['/']) + }) + // this.refresh(); + } + + edit(need: Need) { + + } } -- cgit v1.2.3 From 61daadccf89b2b84820386558ac454c0123d4299 Mon Sep 17 00:00:00 2001 From: sowgro Date: Tue, 1 Apr 2025 01:16:49 -0400 Subject: More css cleanup --- .../components/need-page/need-page.component.css | 30 ++++++----- .../components/need-page/need-page.component.html | 60 +++++++++------------- 2 files changed, 41 insertions(+), 49 deletions(-) (limited to 'ufund-ui/src/app/components/need-page') diff --git a/ufund-ui/src/app/components/need-page/need-page.component.css b/ufund-ui/src/app/components/need-page/need-page.component.css index f950171..844410f 100644 --- a/ufund-ui/src/app/components/need-page/need-page.component.css +++ b/ufund-ui/src/app/components/need-page/need-page.component.css @@ -6,7 +6,9 @@ #box { display: flex; flex-direction: column; - width: 1000px; + width: 800px; + justify-content: start; + gap: 10px; } .needName { @@ -15,7 +17,9 @@ .needType { text-transform: uppercase; - font-size: 10pt; + /*font-size: 10pt;*/ + margin-top: -20px; + /*margin-bottom: 20px;*/ } .split { @@ -47,21 +51,23 @@ .prog { display: flex; flex-direction: column; + margin-bottom: 15px; } .actionArea { display: flex; padding: 5px; gap: 5px; + margin-top: 10px; } -#editor { - position: absolute; - background-color: #4a4a4a; - display: flex; - flex-direction: column; - justify-self: center; - align-self: center; - padding: 20px; - box-shadow: 0 0 100px black; -} +/*#editor {*/ +/* position: absolute;*/ +/* background-color: #4a4a4a;*/ +/* display: flex;*/ +/* flex-direction: column;*/ +/* justify-self: center;*/ +/* align-self: center;*/ +/* padding: 20px;*/ +/* box-shadow: 0 0 100px black;*/ +/*}*/ diff --git a/ufund-ui/src/app/components/need-page/need-page.component.html b/ufund-ui/src/app/components/need-page/need-page.component.html index a8479fd..e8d292e 100644 --- a/ufund-ui/src/app/components/need-page/need-page.component.html +++ b/ufund-ui/src/app/components/need-page/need-page.component.html @@ -1,10 +1,29 @@

{{need?.name}}

-
-

Looking for {{need?.type}} Donations.

+ {{need?.type}} GOAL + + Need image + +

{{need?.description}}

+
+ + + This goal is {{(((need?.current ?? 0)*100) / (need?.maxGoal ?? 0)).toFixed(0)}}% complete!
-
-

Tags:

+ + Target Goal: {{need.maxGoal}} + + Amount Currently Collected: {{need.current}} + + Location: {{need.location}} + + Urgency: + Not urgent + URGENT + + +
+ Tags:
  • {{tag}}

    @@ -12,14 +31,6 @@
-
- {{need?.description}} - Need image -

Location: {{need?.location}}

-

Urgent: {{need?.urgent}}

- {{need?.current}} / {{need?.maxGoal}} - - This goal is {{(((need?.current ?? 0)*100) / (need?.maxGoal ?? 0)).toFixed(0)}}% complete!
- -
-
-
- {{need.name}} - {{need.type}} -
- -
- URGENT - location_on{{need.location}} -
-
- -
- -
- - {{need.current}}/{{need.maxGoal}} ({{((need.current / need.maxGoal) * 100).toFixed(0)}}%) - -
- -
- -
-- 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/need-page/need-page.component.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'ufund-ui/src/app/components/need-page') diff --git a/ufund-ui/src/app/components/need-page/need-page.component.html b/ufund-ui/src/app/components/need-page/need-page.component.html index e8d292e..958dfa6 100644 --- a/ufund-ui/src/app/components/need-page/need-page.component.html +++ b/ufund-ui/src/app/components/need-page/need-page.component.html @@ -35,9 +35,9 @@ - + + + -- cgit v1.2.3