aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGunther6070 <haydenhartman10@yahoo.com>2025-03-17 22:17:28 -0400
committerGunther6070 <haydenhartman10@yahoo.com>2025-03-17 22:17:28 -0400
commit065f90f1f759ed4b97dc22a02e331f7a30eb8ee3 (patch)
tree43b62366e4d2885f14cf2a376d97486bc77ac85e
parentd1b7b81cbedc673cf6f52ac5745438f95083b78e (diff)
downloadJellySolutions-065f90f1f759ed4b97dc22a02e331f7a30eb8ee3.tar.gz
JellySolutions-065f90f1f759ed4b97dc22a02e331f7a30eb8ee3.tar.bz2
JellySolutions-065f90f1f759ed4b97dc22a02e331f7a30eb8ee3.zip
Added statusText to components to disable error messages
-rw-r--r--ufund-ui/src/app/components/cupboard/cupboard.component.html1
-rw-r--r--ufund-ui/src/app/components/cupboard/cupboard.component.ts55
2 files changed, 55 insertions, 1 deletions
diff --git a/ufund-ui/src/app/components/cupboard/cupboard.component.html b/ufund-ui/src/app/components/cupboard/cupboard.component.html
index 65545e8..59d77e0 100644
--- a/ufund-ui/src/app/components/cupboard/cupboard.component.html
+++ b/ufund-ui/src/app/components/cupboard/cupboard.component.html
@@ -19,6 +19,7 @@
<input type="submit" value="Submit">
</form>
<button (click)="back()">Close</button>
+ <span *ngIf="statusText">{{statusText | async}}</span>
</div>
<div id="update-form">
diff --git a/ufund-ui/src/app/components/cupboard/cupboard.component.ts b/ufund-ui/src/app/components/cupboard/cupboard.component.ts
index a930f06..4088ae4 100644
--- a/ufund-ui/src/app/components/cupboard/cupboard.component.ts
+++ b/ufund-ui/src/app/components/cupboard/cupboard.component.ts
@@ -3,6 +3,7 @@ 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';
@Component({
selector: 'app-cupboard',
@@ -12,6 +13,9 @@ import { userType } from '../../models/User';
})
export class CupboardComponent implements OnInit {
+
+ protected statusText = new BehaviorSubject("")
+
needs: any;
constructor(private cupboardService: CupboardService, private usersService: UsersService) { }
@@ -121,7 +125,12 @@ needs: any;
};
console.log("need:", need);
console.log("form submitted. creating need: ", need);
- this.cupboardService.createNeed(need).subscribe(
+ this.cupboardService.createNeed(need)
+ .pipe(catchError((ex, r) => {
+ this.statusText.next("Max goal must be greater than 0 " + friendlyHttpStatus[ex.status])
+ return of()
+ }))
+ .subscribe(
(result) => {
if (result) {
console.log("need created successfully");
@@ -138,3 +147,47 @@ needs: any;
}
}
+
+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',
+ 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',
+}; \ No newline at end of file