"use client";
import { useState, useTransition } from "react";
import { Button } from "@/components/ui/button";
import {
Dialog,
DialogContent,
DialogFooter,
DialogHeader,
DialogTitle,
} from "@/components/ui/dialog";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import { createList } from "@/modules/lists/server/actions";
type Props = {
open: boolean;
onOpenChange: (open: boolean) => void;
};
export function ListCreateDialog({ open, onOpenChange }: Props) {
return (
);
}
function ListCreateForm({ onDone }: { onDone: () => void }) {
const [type, setType] = useState("shopping");
const [name, setName] = useState("");
const [isPending, startTransition] = useTransition();
function handleSubmit(e: React.FormEvent) {
e.preventDefault();
if (!type.trim() || !name.trim()) return;
startTransition(async () => {
await createList({ type: type.trim(), name: name.trim() });
onDone();
});
}
return (
<>