Made client optional on cases
X-Lovable-Edit-ID: edt-f665e75b-2d01-4879-ba2f-760799241602 Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com>
This commit is contained in:
@@ -34,7 +34,7 @@ interface CaseOpt {
|
||||
id: string;
|
||||
case_number: string;
|
||||
title: string;
|
||||
client_id: string;
|
||||
client_id: string | null;
|
||||
default_hourly_rate: number | null;
|
||||
}
|
||||
interface FeeItem {
|
||||
|
||||
@@ -30,7 +30,7 @@ interface CaseOption {
|
||||
id: string;
|
||||
case_number: string;
|
||||
title: string;
|
||||
client_id: string;
|
||||
client_id: string | null;
|
||||
default_hourly_rate: number | null;
|
||||
}
|
||||
|
||||
|
||||
@@ -191,7 +191,7 @@ export type Database = {
|
||||
case_number: string
|
||||
case_summary: string | null
|
||||
claim_amount: number | null
|
||||
client_id: string
|
||||
client_id: string | null
|
||||
closed_at: string | null
|
||||
court: string | null
|
||||
court_case_number: string | null
|
||||
@@ -228,7 +228,7 @@ export type Database = {
|
||||
case_number: string
|
||||
case_summary?: string | null
|
||||
claim_amount?: number | null
|
||||
client_id: string
|
||||
client_id?: string | null
|
||||
closed_at?: string | null
|
||||
court?: string | null
|
||||
court_case_number?: string | null
|
||||
@@ -265,7 +265,7 @@ export type Database = {
|
||||
case_number?: string
|
||||
case_summary?: string | null
|
||||
claim_amount?: number | null
|
||||
client_id?: string
|
||||
client_id?: string | null
|
||||
closed_at?: string | null
|
||||
court?: string | null
|
||||
court_case_number?: string | null
|
||||
|
||||
@@ -72,13 +72,13 @@ function NewCase() {
|
||||
|
||||
const onSubmit = async (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
if (!form.client_id || !form.title.trim() || !form.case_number.trim()) {
|
||||
toast.error("Please fill in client, title, and case number.");
|
||||
if (!form.title.trim() || !form.case_number.trim()) {
|
||||
toast.error("Please fill in title and case number.");
|
||||
return;
|
||||
}
|
||||
setSubmitting(true);
|
||||
const payload = {
|
||||
client_id: form.client_id,
|
||||
client_id: form.client_id || null,
|
||||
case_number: form.case_number.trim(),
|
||||
title: form.title.trim(),
|
||||
practice_area: form.practice_area.trim() || null,
|
||||
@@ -110,10 +110,11 @@ function NewCase() {
|
||||
<form onSubmit={onSubmit} className="space-y-4">
|
||||
<div className="grid grid-cols-2 gap-3">
|
||||
<div className="space-y-2">
|
||||
<Label>Client</Label>
|
||||
<Select value={form.client_id} onValueChange={(v) => setForm({ ...form, client_id: v })}>
|
||||
<SelectTrigger><SelectValue placeholder="Select client" /></SelectTrigger>
|
||||
<Label>Client <span className="text-muted-foreground font-normal">(optional)</span></Label>
|
||||
<Select value={form.client_id || "__none"} onValueChange={(v) => setForm({ ...form, client_id: v === "__none" ? "" : v })}>
|
||||
<SelectTrigger><SelectValue placeholder="No client" /></SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="__none">No client (attach later)</SelectItem>
|
||||
{clients.map((c) => <SelectItem key={c.id} value={c.id}>{c.name}</SelectItem>)}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
ALTER TABLE public.cases ALTER COLUMN client_id DROP NOT NULL;
|
||||
Reference in New Issue
Block a user