"use client"; import { Store } from "@/db/schema"; import { useState } from "react"; import { TextInputWithLabel } from "../text-input-with-label"; import { Button } from "../ui/button"; import { apiRoutes } from "@/lib/routes"; import { toast } from "../ui/use-toast"; import { Loader2 } from "lucide-react"; import { type updateStore } from "@/server-actions/store"; export const EditStoreFields = (props: { storeDetails: Store; updateStore: typeof updateStore; }) => { const [isLoading, setIsLoading] = useState(false); const [formValues, setFormValues] = useState>({ name: props.storeDetails.name, industry: props.storeDetails.industry, description: props.storeDetails.description, }); const handleUpdateDetails = (e: React.FormEvent) => { e.preventDefault(); setIsLoading(true); props .updateStore({ name: formValues.name, industry: formValues.industry, description: formValues.description, }) .then((res) => { setIsLoading(false); toast({ title: res.message, description: res.action, }); }); }; return (
); };