aboutsummaryrefslogtreecommitdiff
path: root/ufund-ui/src/app/components/cupboard/cupboard.component.ts
diff options
context:
space:
mode:
Diffstat (limited to 'ufund-ui/src/app/components/cupboard/cupboard.component.ts')
-rw-r--r--ufund-ui/src/app/components/cupboard/cupboard.component.ts63
1 files changed, 11 insertions, 52 deletions
diff --git a/ufund-ui/src/app/components/cupboard/cupboard.component.ts b/ufund-ui/src/app/components/cupboard/cupboard.component.ts
index ad68c38..85ffd17 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, Input, 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',
@@ -18,8 +18,12 @@ export class CupboardComponent implements OnInit {
protected statusText = new BehaviorSubject("")
selectedForm = "create";
needs: any;
- @ViewChild("needList") needList?: NeedListComponent;
- constructor(private cupboardService: CupboardService, private usersService: UsersService) { }
+ @ViewChild("needList") needList?: NeedListComponent
+
+ constructor(
+ private cupboardService: CupboardService,
+ private authService: AuthService
+ ) {}
ngOnInit(): void {
this.cupboardService.getNeeds().subscribe(n => this.needs = n);
@@ -73,7 +77,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);
}
@@ -89,9 +93,9 @@ export class CupboardComponent implements OnInit {
filterAttributes: [],
current: 0
};
-
+
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) {
@@ -128,7 +132,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) {
@@ -155,48 +159,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',
-};