Enhance customer profile settings with additional fields

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 9111ef36-26c8-4085-84ca-a35dc1fec1b5
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/7083d608-d6d3-4a6a-9a27-6286c5109627/c7a47568-2783-4e31-92cd-42768d11495c.jpg
This commit is contained in:
alphaeusmote
2025-04-12 01:13:20 +00:00
parent 0ac919eaa1
commit f16ae7800d
+56 -14
View File
@@ -58,12 +58,40 @@ import { Loader2, Moon, Sun, Lock, Laptop } from "lucide-react";
// Customer form schema // Customer form schema
const customerFormSchema = z.object({ const customerFormSchema = z.object({
name: z.string().min(1, "Customer name is required"), name: z.string().min(1, "Customer name is required"),
description: z.string().optional(),
email: z.string().email("Please enter a valid email").optional().or(z.literal('')),
phone: z.string().optional().or(z.literal('')),
address: z.string().optional().or(z.literal('')),
city: z.string().optional().or(z.literal('')),
state: z.string().optional().or(z.literal('')),
zipCode: z.string().optional().or(z.literal('')),
country: z.string().optional().or(z.literal('')),
website: z.string().url("Please enter a valid URL").optional().or(z.literal('')),
industry: z.string().optional().or(z.literal('')),
notes: z.string().optional().or(z.literal('')),
accountManager: z.string().optional().or(z.literal('')),
billingEmail: z.string().email("Please enter a valid email").optional().or(z.literal('')),
billingAddress: z.string().optional().or(z.literal('')),
isActive: z.boolean().default(true), isActive: z.boolean().default(true),
}); });
// Create customer form schema // Create customer form schema
const createCustomerFormSchema = z.object({ const createCustomerFormSchema = z.object({
name: z.string().min(1, "Customer name is required"), name: z.string().min(1, "Customer name is required"),
description: z.string().optional(),
email: z.string().email("Please enter a valid email").optional().or(z.literal('')),
phone: z.string().optional().or(z.literal('')),
address: z.string().optional().or(z.literal('')),
city: z.string().optional().or(z.literal('')),
state: z.string().optional().or(z.literal('')),
zipCode: z.string().optional().or(z.literal('')),
country: z.string().optional().or(z.literal('')),
website: z.string().url("Please enter a valid URL").optional().or(z.literal('')),
industry: z.string().optional().or(z.literal('')),
notes: z.string().optional().or(z.literal('')),
accountManager: z.string().optional().or(z.literal('')),
billingEmail: z.string().email("Please enter a valid email").optional().or(z.literal('')),
billingAddress: z.string().optional().or(z.literal('')),
isActive: z.boolean().default(true), isActive: z.boolean().default(true),
}); });
@@ -97,6 +125,20 @@ export default function SettingsPage() {
resolver: zodResolver(createCustomerFormSchema), resolver: zodResolver(createCustomerFormSchema),
defaultValues: { defaultValues: {
name: "", name: "",
description: "",
email: "",
phone: "",
address: "",
city: "",
state: "",
zipCode: "",
country: "",
website: "",
industry: "",
notes: "",
accountManager: "",
billingEmail: "",
billingAddress: "",
isActive: true, isActive: true,
}, },
}); });
@@ -458,9 +500,9 @@ export default function SettingsPage() {
</CardDescription> </CardDescription>
</CardHeader> </CardHeader>
<CardContent> <CardContent>
<Form {...createOrganizationForm}> <Form {...createCustomerForm}>
<form <form
onSubmit={createOrganizationForm.handleSubmit((data) => { onSubmit={createCustomerForm.handleSubmit((data) => {
createCustomerMutation.mutate(data); createCustomerMutation.mutate(data);
createCustomerForm.reset(); createCustomerForm.reset();
})} })}
@@ -714,9 +756,9 @@ export default function SettingsPage() {
<Button <Button
type="submit" type="submit"
disabled={createOrganizationMutation.isPending} disabled={createCustomerMutation.isPending}
> >
{createOrganizationMutation.isPending ? ( {createCustomerMutation.isPending ? (
<> <>
<Loader2 className="mr-2 h-4 w-4 animate-spin" /> <Loader2 className="mr-2 h-4 w-4 animate-spin" />
Creating... Creating...
@@ -739,10 +781,10 @@ export default function SettingsPage() {
</CardDescription> </CardDescription>
</CardHeader> </CardHeader>
<CardContent> <CardContent>
<Form {...organizationForm}> <Form {...customerForm}>
<form onSubmit={organizationForm.handleSubmit(onOrganizationSubmit)} className="space-y-4"> <form onSubmit={customerForm.handleSubmit(onCustomerSubmit)} className="space-y-4">
<FormField <FormField
control={organizationForm.control} control={customerForm.control}
name="name" name="name"
render={({ field }) => ( render={({ field }) => (
<FormItem> <FormItem>
@@ -756,7 +798,7 @@ export default function SettingsPage() {
/> />
<FormField <FormField
control={organizationForm.control} control={customerForm.control}
name="isActive" name="isActive"
render={({ field }) => ( render={({ field }) => (
<FormItem className="flex flex-row items-center justify-between rounded-lg border p-4"> <FormItem className="flex flex-row items-center justify-between rounded-lg border p-4">
@@ -778,9 +820,9 @@ export default function SettingsPage() {
<Button <Button
type="submit" type="submit"
disabled={updateOrganizationMutation.isPending} disabled={updateCustomerMutation.isPending}
> >
{updateOrganizationMutation.isPending ? ( {updateCustomerMutation.isPending ? (
<> <>
<Loader2 className="mr-2 h-4 w-4 animate-spin" /> <Loader2 className="mr-2 h-4 w-4 animate-spin" />
Saving... Saving...
@@ -893,18 +935,18 @@ export default function SettingsPage() {
<AlertDialogHeader> <AlertDialogHeader>
<AlertDialogTitle>Delete Customer</AlertDialogTitle> <AlertDialogTitle>Delete Customer</AlertDialogTitle>
<AlertDialogDescription> <AlertDialogDescription>
Are you sure you want to delete the customer <strong>{currentOrganization?.name}</strong>? Are you sure you want to delete the customer <strong>{currentCustomer?.name}</strong>?
This action cannot be undone. All domains, DNS records, and related data will be permanently deleted. This action cannot be undone. All domains, DNS records, and related data will be permanently deleted.
</AlertDialogDescription> </AlertDialogDescription>
</AlertDialogHeader> </AlertDialogHeader>
<AlertDialogFooter> <AlertDialogFooter>
<AlertDialogCancel>Cancel</AlertDialogCancel> <AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction <AlertDialogAction
onClick={() => deleteOrganizationMutation.mutate()} onClick={() => deleteCustomerMutation.mutate()}
className="bg-destructive text-destructive-foreground hover:bg-destructive/90" className="bg-destructive text-destructive-foreground hover:bg-destructive/90"
disabled={deleteOrganizationMutation.isPending} disabled={deleteCustomerMutation.isPending}
> >
{deleteOrganizationMutation.isPending ? ( {deleteCustomerMutation.isPending ? (
<> <>
<Loader2 className="mr-2 h-4 w-4 animate-spin" /> <Loader2 className="mr-2 h-4 w-4 animate-spin" />
Deleting... Deleting...