fix: 5 issues - leads 500, prepaid amount/invoice, install RESOLVED, dup tickets, confirm fail

This commit is contained in:
Nemo
2026-03-24 14:52:40 +08:00
parent 16cf1c0616
commit 882e416a40
3 changed files with 40 additions and 32 deletions

View File

@@ -72,14 +72,13 @@ export default function LeadDetailScreen() {
});
const client = clientRes.data;
// Create installation ticket
const ticketRes = await api.post('/api/v1/tickets', {
clientId: client.id,
subject: `New Installation — ${lead.firstName} ${lead.lastName !== '—' ? lead.lastName : ''}`.trim(),
type: 'INSTALLATION',
priority: 'NORMAL',
});
const ticket = ticketRes.data;
// Fetch the auto-created installation ticket (API creates one on client creation)
let ticket: any = null;
try {
const tRes = await api.get(`/api/v1/tickets?clientId=${client.id}&type=INSTALLATION&limit=1`);
const items = tRes.data?.data ?? tRes.data ?? [];
ticket = items[0] ?? null;
} catch {}
// Mark lead as CONVERTED
await api.patch(`/api/v1/leads/${id}`, {