diff --git a/src/app/(dashboard)/settings/workspace/components/workspace-form.tsx b/src/app/(dashboard)/settings/workspace/components/workspace-form.tsx new file mode 100644 index 0000000..7e6a758 --- /dev/null +++ b/src/app/(dashboard)/settings/workspace/components/workspace-form.tsx @@ -0,0 +1,192 @@ +"use client"; + +import { useActionState, useEffect } from "react"; +import { Building2, Loader2, Receipt, Save } from "lucide-react"; +import { toast } from "sonner"; + +import { Button } from "@/components/ui/button"; +import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; +import { Input } from "@/components/ui/input"; +import { Label } from "@/components/ui/label"; +import { Textarea } from "@/components/ui/textarea"; +import { updateWorkspaceSettingsAction } from "@/lib/appwrite/workspace-actions"; +import { initialWorkspaceSettingsState } from "@/lib/appwrite/workspace-types"; + +type Defaults = { + companyName: string; + companyTaxId: string; + companyAddress: string; + companyEmail: string; + companyPhone: string; + defaultVatRate: number; + invoicePrefix: string; + invoiceCounter: number; +}; + +export function WorkspaceSettingsForm({ + canEdit, + defaults, +}: { + canEdit: boolean; + defaults: Defaults; +}) { + const [state, formAction, isPending] = useActionState( + updateWorkspaceSettingsAction, + initialWorkspaceSettingsState, + ); + + useEffect(() => { + if (state.ok) toast.success("Bilgiler güncellendi."); + else if (state.error) toast.error(state.error); + }, [state]); + + return ( +
+
+ + + + + Şirket + + Resmi şirket bilgileriniz. + + +
+ + + {state.fieldErrors?.companyName && ( +

{state.fieldErrors.companyName}

+ )} +
+ +
+ + +
+ +
+ + +
+ +
+ + + {state.fieldErrors?.companyEmail && ( +

{state.fieldErrors.companyEmail}

+ )} +
+ +
+ +