No decisions found. Create one to get started!
diff --git a/src/app/components/decision-list/decision-list.component.ts b/src/app/components/decision-list/decision-list.component.ts
index 48aac5b..432a775 100644
--- a/src/app/components/decision-list/decision-list.component.ts
+++ b/src/app/components/decision-list/decision-list.component.ts
@@ -1,9 +1,9 @@
-import { Component, OnInit } from '@angular/core';
+import { Component, OnInit, OnDestroy } from '@angular/core';
import { CommonModule } from '@angular/common';
import { ActivatedRoute, RouterModule } from '@angular/router';
import { Decision } from '../../models/decision.model';
import { DecisionService } from '../../services/decision.service';
-import { Observable } from 'rxjs';
+import { Observable, Subject, takeUntil, startWith, switchMap, catchError, of } from 'rxjs';
@Component({
selector: 'app-decision-list',
@@ -12,8 +12,11 @@ import { Observable } from 'rxjs';
templateUrl: './decision-list.component.html',
styleUrls: ['./decision-list.component.css']
})
-export class DecisionListComponent implements OnInit {
+export class DecisionListComponent implements OnInit, OnDestroy {
decisions$: Observable
| undefined;
+ error: string | null = null;
+ private refresh$ = new Subject();
+ private destroy$ = new Subject();
private workspaceId: string | null = null;
constructor(
@@ -24,15 +27,37 @@ export class DecisionListComponent implements OnInit {
ngOnInit(): void {
this.workspaceId = this.getWorkspaceIdFromRoute();
if (this.workspaceId) {
- this.decisions$ = this.decisionService.getDecisions(this.workspaceId);
+ this.decisions$ = this.refresh$.pipe(
+ startWith(undefined),
+ switchMap(() => this.decisionService.getDecisions(this.workspaceId!).pipe(
+ catchError(err => {
+ this.error = 'Failed to load decisions. Please try again.';
+ return of([]);
+ })
+ ))
+ );
}
}
+ ngOnDestroy(): void {
+ this.destroy$.next();
+ this.destroy$.complete();
+ }
+
deleteDecision(id: string): void {
if (confirm('Are you sure you want to delete this decision?') && this.workspaceId) {
- this.decisionService.deleteDecision(this.workspaceId, id).subscribe(() => {
- this.decisions$ = this.decisionService.getDecisions(this.workspaceId!);
- });
+ this.error = null;
+ this.decisionService.deleteDecision(this.workspaceId, id)
+ .pipe(takeUntil(this.destroy$))
+ .subscribe({
+ next: () => {
+ this.refresh$.next();
+ },
+ error: (err) => {
+ console.error('Delete failed', err);
+ this.error = 'Failed to delete decision. Please try again.';
+ }
+ });
}
}
diff --git a/src/app/components/workspace/create-workspace.css b/src/app/components/workspace/create-workspace.css
index d01db84..9354c9e 100644
--- a/src/app/components/workspace/create-workspace.css
+++ b/src/app/components/workspace/create-workspace.css
@@ -450,3 +450,16 @@ label {
transform: translateY(0);
}
}
+
+.spinner {
+ width: 18px;
+ height: 18px;
+ border: 2px solid rgba(255, 255, 255, 0.3);
+ border-radius: 50%;
+ border-top-color: #ffffff;
+ animation: spin 0.8s linear infinite;
+}
+
+@keyframes spin {
+ to { transform: rotate(360deg); }
+}
diff --git a/src/app/components/workspace/create-workspace.html b/src/app/components/workspace/create-workspace.html
index 9e40e29..f5e41a0 100644
--- a/src/app/components/workspace/create-workspace.html
+++ b/src/app/components/workspace/create-workspace.html
@@ -96,8 +96,9 @@ Create Workspace
diff --git a/src/app/components/workspace/create-workspace.ts b/src/app/components/workspace/create-workspace.ts
index 736bf1e..eccfa0b 100644
--- a/src/app/components/workspace/create-workspace.ts
+++ b/src/app/components/workspace/create-workspace.ts
@@ -88,8 +88,8 @@ export class CreateWorkspace {
this.error = 'An error occurred while loading the dashboard.';
});
},
- error: () => {
- this.error = 'Unable to create workspace. Please try again.';
+ error: (err) => {
+ this.error = err.message || 'Unable to create workspace. Please try again.';
this.isSubmitting = false;
}
});