Ran prettier
This commit is contained in:
@@ -19,13 +19,15 @@ export default function AddLiabilityDialog({open, onOpenChange}: Props) {
|
||||
|
||||
const handleSubmit = (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
dispatch(addLiability({
|
||||
id: crypto.randomUUID(),
|
||||
name: form.name,
|
||||
type: form.type as typeof liabilityTypes[number],
|
||||
balance: parseFloat(form.balance) || 0,
|
||||
updatedAt: new Date().toISOString(),
|
||||
}));
|
||||
dispatch(
|
||||
addLiability({
|
||||
id: crypto.randomUUID(),
|
||||
name: form.name,
|
||||
type: form.type as (typeof liabilityTypes)[number],
|
||||
balance: parseFloat(form.balance) || 0,
|
||||
updatedAt: new Date().toISOString()
|
||||
})
|
||||
);
|
||||
onOpenChange(false);
|
||||
setForm({name: '', type: '', balance: ''});
|
||||
};
|
||||
@@ -41,29 +43,55 @@ export default function AddLiabilityDialog({open, onOpenChange}: Props) {
|
||||
<div className="grid gap-4 py-4">
|
||||
<div className="grid gap-2">
|
||||
<Label htmlFor="name">Name</Label>
|
||||
<Input id="name" placeholder="e.g., Car Loan" value={form.name} onChange={e => setForm({...form, name: e.target.value})} className="input-depth" required />
|
||||
<Input
|
||||
id="name"
|
||||
placeholder="e.g., Car Loan"
|
||||
value={form.name}
|
||||
onChange={e => setForm({...form, name: e.target.value})}
|
||||
className="input-depth"
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
<div className="grid gap-2">
|
||||
<Label>Type</Label>
|
||||
<Select value={form.type} onValueChange={v => setForm({...form, type: v})} required>
|
||||
<SelectTrigger className="input-depth"><SelectValue placeholder="Select type" /></SelectTrigger>
|
||||
<SelectTrigger className="input-depth">
|
||||
<SelectValue placeholder="Select type" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{liabilityTypes.map(t => <SelectItem key={t} value={t} className="capitalize">{t.replace('_', ' ')}</SelectItem>)}
|
||||
{liabilityTypes.map(t => (
|
||||
<SelectItem key={t} value={t} className="capitalize">
|
||||
{t.replace('_', ' ')}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
<div className="grid gap-2">
|
||||
<Label htmlFor="balance">Balance</Label>
|
||||
<Input id="balance" type="number" step="0.01" min="0" placeholder="0.00" value={form.balance} onChange={e => setForm({...form, balance: e.target.value})} className="input-depth" required />
|
||||
<Input
|
||||
id="balance"
|
||||
type="number"
|
||||
step="0.01"
|
||||
min="0"
|
||||
placeholder="0.00"
|
||||
value={form.balance}
|
||||
onChange={e => setForm({...form, balance: e.target.value})}
|
||||
className="input-depth"
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<DialogFooter>
|
||||
<Button type="button" variant="secondary" onClick={() => onOpenChange(false)}>Cancel</Button>
|
||||
<Button type="submit" disabled={!form.name || !form.type || !form.balance}>Add Liability</Button>
|
||||
<Button type="button" variant="secondary" onClick={() => onOpenChange(false)}>
|
||||
Cancel
|
||||
</Button>
|
||||
<Button type="submit" disabled={!form.name || !form.type || !form.balance}>
|
||||
Add Liability
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</form>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user