|
@@ -4,7 +4,7 @@ import { Router, RouterModule } from '@angular/router';
|
|
|
import { ExtractionService } from '../../services/extraction.service';
|
|
import { ExtractionService } from '../../services/extraction.service';
|
|
|
import { SessionService, User } from '../../services/session.service';
|
|
import { SessionService, User } from '../../services/session.service';
|
|
|
import { ClaimRecord } from '../../services/extraction';
|
|
import { ClaimRecord } from '../../services/extraction';
|
|
|
-import { LucideAngularModule, LogOut, Plus, UserCog, ExternalLink, X, FileText } from 'lucide-angular';
|
|
|
|
|
|
|
+import { LucideAngularModule, LogOut, Plus, UserCog, ExternalLink, X, FileText, Trash2 } from 'lucide-angular';
|
|
|
|
|
|
|
|
@Component({
|
|
@Component({
|
|
|
selector: 'app-dashboard',
|
|
selector: 'app-dashboard',
|
|
@@ -26,6 +26,7 @@ export class DashboardComponent implements OnInit {
|
|
|
readonly ExternalLink = ExternalLink;
|
|
readonly ExternalLink = ExternalLink;
|
|
|
readonly X = X;
|
|
readonly X = X;
|
|
|
readonly FileText = FileText;
|
|
readonly FileText = FileText;
|
|
|
|
|
+ readonly Trash2 = Trash2;
|
|
|
|
|
|
|
|
constructor(
|
|
constructor(
|
|
|
private extractionService: ExtractionService,
|
|
private extractionService: ExtractionService,
|
|
@@ -53,6 +54,32 @@ export class DashboardComponent implements OnInit {
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ deleteClaim(event: Event, claimId: string): void {
|
|
|
|
|
+ event.stopPropagation();
|
|
|
|
|
+
|
|
|
|
|
+ if (confirm('Are you sure you want to delete this claim? The medical allowance will be refunded.')) {
|
|
|
|
|
+ this.extractionService.deleteClaim(claimId).subscribe({
|
|
|
|
|
+ next: () => {
|
|
|
|
|
+ this.loadClaims();
|
|
|
|
|
+ // Update current user balance if they are logged in
|
|
|
|
|
+ if (this.currentUser) {
|
|
|
|
|
+ this.extractionService.getUsers().subscribe(users => {
|
|
|
|
|
+ const updated = users.find(u => u.id === this.currentUser?.id);
|
|
|
|
|
+ if (updated) {
|
|
|
|
|
+ this.sessionService.setCurrentUser(updated);
|
|
|
|
|
+ this.currentUser = updated;
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ error: (err) => {
|
|
|
|
|
+ console.error('Delete failed:', err);
|
|
|
|
|
+ alert('Failed to delete claim.');
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
viewDetail(claim: ClaimRecord): void {
|
|
viewDetail(claim: ClaimRecord): void {
|
|
|
this.selectedClaim = claim;
|
|
this.selectedClaim = claim;
|
|
|
}
|
|
}
|