fix: quick add opens create ui
Add createKey to quick-add manifests and client create dialog host. FAB and command palette open in-place create UIs instead of navigating away.
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
import { Dialog, DialogContent, DialogHeader, DialogTitle } from "@/components/ui/dialog";
|
||||
import { PlantForm } from "@/modules/garden/components/plant-form";
|
||||
import { listContainers, type ContainerDto } from "@/modules/garden/server/queries";
|
||||
|
||||
type Props = {
|
||||
open: boolean;
|
||||
onOpenChange: (open: boolean) => void;
|
||||
};
|
||||
|
||||
export function PlantCreateDialog({ open, onOpenChange }: Props) {
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||
<DialogContent className="sm:max-w-lg max-h-[90dvh] overflow-y-auto">
|
||||
{open ? <PlantCreateForm onDone={() => onOpenChange(false)} /> : null}
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
||||
function PlantCreateForm({ onDone }: { onDone: () => void }) {
|
||||
const [containers, setContainers] = useState<ContainerDto[]>([]);
|
||||
|
||||
useEffect(() => {
|
||||
listContainers()
|
||||
.then(setContainers)
|
||||
.catch(() => setContainers([]));
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<>
|
||||
<DialogHeader>
|
||||
<DialogTitle>Add plant</DialogTitle>
|
||||
</DialogHeader>
|
||||
<PlantForm containers={containers} onSuccess={() => onDone()} onCancel={onDone} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user