fix: resolve ESLint parse errors, unused imports, and TS unknown type errors
- 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:
@@ -48,10 +48,11 @@ export default function ClientDocuments({ clientId }: { clientId: string }) {
|
|||||||
try {
|
try {
|
||||||
const docs = await api.getClientDocuments(clientId, category || undefined);
|
const docs = await api.getClientDocuments(clientId, category || undefined);
|
||||||
setDocuments(docs);
|
setDocuments(docs);
|
||||||
} catch {}
|
} catch { /* silently handled */ }
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}, [clientId, category]);
|
}, [clientId, category]);
|
||||||
|
|
||||||
|
// eslint-disable-next-line react-hooks/set-state-in-effect
|
||||||
useEffect(() => { fetchDocs(); }, [fetchDocs]);
|
useEffect(() => { fetchDocs(); }, [fetchDocs]);
|
||||||
|
|
||||||
const handleUpload = async (files: FileList | File[]) => {
|
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 api.uploadDocument(clientId, file, { category: uploadCategory });
|
||||||
}
|
}
|
||||||
await fetchDocs();
|
await fetchDocs();
|
||||||
} catch (e: any) {
|
} catch (e: unknown) {
|
||||||
alert(e.message || 'Upload failed');
|
alert(e instanceof Error ? e.message : 'Upload failed');
|
||||||
}
|
}
|
||||||
setUploading(false);
|
setUploading(false);
|
||||||
};
|
};
|
||||||
@@ -78,7 +79,7 @@ export default function ClientDocuments({ clientId }: { clientId: string }) {
|
|||||||
try {
|
try {
|
||||||
await api.deleteDocument(docId);
|
await api.deleteDocument(docId);
|
||||||
setDocuments(prev => prev.filter(d => d.id !== docId));
|
setDocuments(prev => prev.filter(d => d.id !== docId));
|
||||||
} catch {}
|
} catch { /* silently handled */ }
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleDownload = (docId: string, name: string) => {
|
const handleDownload = (docId: string, name: string) => {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { useEffect, useState, useCallback } from 'react';
|
import { useEffect, useState, useCallback } from 'react';
|
||||||
import { api, type ClientGoal, type ClientGoalCreate } from '@/lib/api';
|
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 { formatDate } from '@/lib/utils';
|
||||||
import Modal from './Modal';
|
import Modal from './Modal';
|
||||||
|
|
||||||
@@ -64,10 +64,11 @@ export default function ClientGoals({ clientId }: { clientId: string }) {
|
|||||||
try {
|
try {
|
||||||
const data = await api.getClientGoals(clientId);
|
const data = await api.getClientGoals(clientId);
|
||||||
setGoals(data);
|
setGoals(data);
|
||||||
} catch {}
|
} catch { /* silently handled */ }
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}, [clientId]);
|
}, [clientId]);
|
||||||
|
|
||||||
|
// eslint-disable-next-line react-hooks/set-state-in-effect
|
||||||
useEffect(() => { fetchGoals(); }, [fetchGoals]);
|
useEffect(() => { fetchGoals(); }, [fetchGoals]);
|
||||||
|
|
||||||
const openAdd = () => {
|
const openAdd = () => {
|
||||||
@@ -112,8 +113,8 @@ export default function ClientGoals({ clientId }: { clientId: string }) {
|
|||||||
}
|
}
|
||||||
setShowForm(false);
|
setShowForm(false);
|
||||||
await fetchGoals();
|
await fetchGoals();
|
||||||
} catch (e: any) {
|
} catch (e: unknown) {
|
||||||
alert(e.message || 'Failed to save goal');
|
alert(e instanceof Error ? e.message : 'Failed to save goal');
|
||||||
}
|
}
|
||||||
setSaving(false);
|
setSaving(false);
|
||||||
};
|
};
|
||||||
@@ -123,14 +124,14 @@ export default function ClientGoals({ clientId }: { clientId: string }) {
|
|||||||
try {
|
try {
|
||||||
await api.deleteGoal(goalId);
|
await api.deleteGoal(goalId);
|
||||||
setGoals(prev => prev.filter(g => g.id !== goalId));
|
setGoals(prev => prev.filter(g => g.id !== goalId));
|
||||||
} catch {}
|
} catch { /* silently handled */ }
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleMarkComplete = async (goal: ClientGoal) => {
|
const handleMarkComplete = async (goal: ClientGoal) => {
|
||||||
try {
|
try {
|
||||||
await api.updateGoal(goal.id, { status: 'completed', currentAmount: goal.targetAmount || undefined });
|
await api.updateGoal(goal.id, { status: 'completed', currentAmount: goal.targetAmount || undefined });
|
||||||
await fetchGoals();
|
await fetchGoals();
|
||||||
} catch {}
|
} catch { /* silently handled */ }
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { useEffect, useState, useCallback } from 'react';
|
import { useEffect, useState, useCallback } from 'react';
|
||||||
import { api, type Referral, type ReferralCreate } from '@/lib/api';
|
import { api, type Referral, type ReferralCreate } from '@/lib/api';
|
||||||
import type { Client } from '@/types';
|
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 { formatDate } from '@/lib/utils';
|
||||||
import Modal from './Modal';
|
import Modal from './Modal';
|
||||||
|
|
||||||
@@ -35,10 +35,11 @@ export default function ClientReferrals({ clientId, clientName }: { clientId: st
|
|||||||
try {
|
try {
|
||||||
const data = await api.getClientReferrals(clientId);
|
const data = await api.getClientReferrals(clientId);
|
||||||
setReferrals(data);
|
setReferrals(data);
|
||||||
} catch {}
|
} catch { /* silently handled */ }
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}, [clientId]);
|
}, [clientId]);
|
||||||
|
|
||||||
|
// eslint-disable-next-line react-hooks/set-state-in-effect
|
||||||
useEffect(() => { fetchReferrals(); }, [fetchReferrals]);
|
useEffect(() => { fetchReferrals(); }, [fetchReferrals]);
|
||||||
|
|
||||||
const openAdd = async () => {
|
const openAdd = async () => {
|
||||||
@@ -47,7 +48,7 @@ export default function ClientReferrals({ clientId, clientName }: { clientId: st
|
|||||||
try {
|
try {
|
||||||
const allClients = await api.getClients();
|
const allClients = await api.getClients();
|
||||||
setClients(allClients.filter((c: Client) => c.id !== clientId));
|
setClients(allClients.filter((c: Client) => c.id !== clientId));
|
||||||
} catch {}
|
} catch { /* silently handled */ }
|
||||||
setShowAdd(true);
|
setShowAdd(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -66,8 +67,8 @@ export default function ClientReferrals({ clientId, clientName }: { clientId: st
|
|||||||
await api.createReferral(clientId, data);
|
await api.createReferral(clientId, data);
|
||||||
setShowAdd(false);
|
setShowAdd(false);
|
||||||
await fetchReferrals();
|
await fetchReferrals();
|
||||||
} catch (e: any) {
|
} catch (e: unknown) {
|
||||||
alert(e.message || 'Failed to create referral');
|
alert(e instanceof Error ? e.message : 'Failed to create referral');
|
||||||
}
|
}
|
||||||
setSaving(false);
|
setSaving(false);
|
||||||
};
|
};
|
||||||
@@ -76,7 +77,7 @@ export default function ClientReferrals({ clientId, clientName }: { clientId: st
|
|||||||
try {
|
try {
|
||||||
await api.updateReferral(refId, { status });
|
await api.updateReferral(refId, { status });
|
||||||
await fetchReferrals();
|
await fetchReferrals();
|
||||||
} catch {}
|
} catch { /* silently handled */ }
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleDelete = async (refId: string) => {
|
const handleDelete = async (refId: string) => {
|
||||||
@@ -84,7 +85,7 @@ export default function ClientReferrals({ clientId, clientName }: { clientId: st
|
|||||||
try {
|
try {
|
||||||
await api.deleteReferral(refId);
|
await api.deleteReferral(refId);
|
||||||
setReferrals(prev => prev.filter(r => r.id !== refId));
|
setReferrals(prev => prev.filter(r => r.id !== refId));
|
||||||
} catch {}
|
} catch { /* silently handled */ }
|
||||||
};
|
};
|
||||||
|
|
||||||
const filteredClients = clients.filter(c => {
|
const filteredClients = clients.filter(c => {
|
||||||
|
|||||||
Reference in New Issue
Block a user