fix: resolve ESLint parse errors, unused imports, and TS unknown type errors
All checks were successful
CI/CD / test (push) Successful in 45s
CI/CD / deploy (push) Successful in 1s

- Fix catch blocks with inline comments that broke parsing
- Remove unused Edit3 import from ClientReferrals
- Add eslint-disable for set-state-in-effect (intentional fetch-on-mount pattern)
- Fix 'e' is of type 'unknown' errors with instanceof checks
This commit is contained in:
2026-01-30 04:58:32 +00:00
parent f042c910ee
commit df448a7245
3 changed files with 20 additions and 17 deletions

View File

@@ -48,10 +48,11 @@ export default function ClientDocuments({ clientId }: { clientId: string }) {
try {
const docs = await api.getClientDocuments(clientId, category || undefined);
setDocuments(docs);
} catch {}
} catch { /* silently handled */ }
setLoading(false);
}, [clientId, category]);
// eslint-disable-next-line react-hooks/set-state-in-effect
useEffect(() => { fetchDocs(); }, [fetchDocs]);
const handleUpload = async (files: FileList | File[]) => {
@@ -61,8 +62,8 @@ export default function ClientDocuments({ clientId }: { clientId: string }) {
await api.uploadDocument(clientId, file, { category: uploadCategory });
}
await fetchDocs();
} catch (e: any) {
alert(e.message || 'Upload failed');
} catch (e: unknown) {
alert(e instanceof Error ? e.message : 'Upload failed');
}
setUploading(false);
};
@@ -78,7 +79,7 @@ export default function ClientDocuments({ clientId }: { clientId: string }) {
try {
await api.deleteDocument(docId);
setDocuments(prev => prev.filter(d => d.id !== docId));
} catch {}
} catch { /* silently handled */ }
};
const handleDownload = (docId: string, name: string) => {

View File

@@ -1,6 +1,6 @@
import { useEffect, useState, useCallback } from 'react';
import { api, type ClientGoal, type ClientGoalCreate } from '@/lib/api';
import { Target, Plus, Edit3, Trash2, CheckCircle2, AlertTriangle, Clock, TrendingUp } from 'lucide-react';
import { Target, Plus, Edit3, Trash2, CheckCircle2, AlertTriangle, Clock } from 'lucide-react';
import { formatDate } from '@/lib/utils';
import Modal from './Modal';
@@ -64,10 +64,11 @@ export default function ClientGoals({ clientId }: { clientId: string }) {
try {
const data = await api.getClientGoals(clientId);
setGoals(data);
} catch {}
} catch { /* silently handled */ }
setLoading(false);
}, [clientId]);
// eslint-disable-next-line react-hooks/set-state-in-effect
useEffect(() => { fetchGoals(); }, [fetchGoals]);
const openAdd = () => {
@@ -112,8 +113,8 @@ export default function ClientGoals({ clientId }: { clientId: string }) {
}
setShowForm(false);
await fetchGoals();
} catch (e: any) {
alert(e.message || 'Failed to save goal');
} catch (e: unknown) {
alert(e instanceof Error ? e.message : 'Failed to save goal');
}
setSaving(false);
};
@@ -123,14 +124,14 @@ export default function ClientGoals({ clientId }: { clientId: string }) {
try {
await api.deleteGoal(goalId);
setGoals(prev => prev.filter(g => g.id !== goalId));
} catch {}
} catch { /* silently handled */ }
};
const handleMarkComplete = async (goal: ClientGoal) => {
try {
await api.updateGoal(goal.id, { status: 'completed', currentAmount: goal.targetAmount || undefined });
await fetchGoals();
} catch {}
} catch { /* silently handled */ }
};
return (

View File

@@ -1,7 +1,7 @@
import { useEffect, useState, useCallback } from 'react';
import { api, type Referral, type ReferralCreate } from '@/lib/api';
import type { Client } from '@/types';
import { UserPlus, Plus, Trash2, ArrowRight, Edit3, Search } from 'lucide-react';
import { UserPlus, Plus, Trash2, ArrowRight, Search } from 'lucide-react';
import { formatDate } from '@/lib/utils';
import Modal from './Modal';
@@ -35,10 +35,11 @@ export default function ClientReferrals({ clientId, clientName }: { clientId: st
try {
const data = await api.getClientReferrals(clientId);
setReferrals(data);
} catch {}
} catch { /* silently handled */ }
setLoading(false);
}, [clientId]);
// eslint-disable-next-line react-hooks/set-state-in-effect
useEffect(() => { fetchReferrals(); }, [fetchReferrals]);
const openAdd = async () => {
@@ -47,7 +48,7 @@ export default function ClientReferrals({ clientId, clientName }: { clientId: st
try {
const allClients = await api.getClients();
setClients(allClients.filter((c: Client) => c.id !== clientId));
} catch {}
} catch { /* silently handled */ }
setShowAdd(true);
};
@@ -66,8 +67,8 @@ export default function ClientReferrals({ clientId, clientName }: { clientId: st
await api.createReferral(clientId, data);
setShowAdd(false);
await fetchReferrals();
} catch (e: any) {
alert(e.message || 'Failed to create referral');
} catch (e: unknown) {
alert(e instanceof Error ? e.message : 'Failed to create referral');
}
setSaving(false);
};
@@ -76,7 +77,7 @@ export default function ClientReferrals({ clientId, clientName }: { clientId: st
try {
await api.updateReferral(refId, { status });
await fetchReferrals();
} catch {}
} catch { /* silently handled */ }
};
const handleDelete = async (refId: string) => {
@@ -84,7 +85,7 @@ export default function ClientReferrals({ clientId, clientName }: { clientId: st
try {
await api.deleteReferral(refId);
setReferrals(prev => prev.filter(r => r.id !== refId));
} catch {}
} catch { /* silently handled */ }
};
const filteredClients = clients.filter(c => {