Fix domain creation and enhance customer creation. Added more optional fields to customer creation and fixed a bug preventing domain creation when no customer was selected.

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/c1009a9a-4ed8-4285-853d-b523c88c7bff.jpg
This commit is contained in:
alphaeusmote
2025-04-12 01:08:23 +00:00
parent 28de0a0c6a
commit f9ffe1f2a8
3 changed files with 267 additions and 6 deletions
+6 -1
View File
@@ -92,10 +92,14 @@ export default function DomainsPage() {
// Add domain mutation
const addDomainMutation = useMutation({
mutationFn: async (data: z.infer<typeof domainFormSchema>) => {
if (!currentCustomer?.id) {
throw new Error("No customer selected");
}
// Prepare domain data with customerId
const domainData: InsertDomain = {
...data,
customerId: currentCustomer?.id || "",
customerId: currentCustomer.id,
};
// Add special handling for providerId
@@ -106,6 +110,7 @@ export default function DomainsPage() {
}
console.log("Submitting domain with provider:", domainData.providerId);
console.log("Customer ID:", domainData.customerId);
const res = await apiRequest("POST", "/api/domains", domainData);
return await res.json();
+216 -5
View File
@@ -461,17 +461,17 @@ export default function SettingsPage() {
<Form {...createOrganizationForm}>
<form
onSubmit={createOrganizationForm.handleSubmit((data) => {
createOrganizationMutation.mutate(data);
createOrganizationForm.reset();
createCustomerMutation.mutate(data);
createCustomerForm.reset();
})}
className="space-y-4"
>
<FormField
control={createOrganizationForm.control}
control={createCustomerForm.control}
name="name"
render={({ field }) => (
<FormItem>
<FormLabel>Customer Name</FormLabel>
<FormLabel>Customer Name*</FormLabel>
<FormControl>
<Input {...field} placeholder="Enter customer name" />
</FormControl>
@@ -481,7 +481,218 @@ export default function SettingsPage() {
/>
<FormField
control={createOrganizationForm.control}
control={createCustomerForm.control}
name="description"
render={({ field }) => (
<FormItem>
<FormLabel>Description</FormLabel>
<FormControl>
<Input {...field} placeholder="Brief description of the customer" />
</FormControl>
<FormDescription>
A brief description of the customer's business
</FormDescription>
<FormMessage />
</FormItem>
)}
/>
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
<FormField
control={createCustomerForm.control}
name="email"
render={({ field }) => (
<FormItem>
<FormLabel>Email</FormLabel>
<FormControl>
<Input {...field} placeholder="contact@example.com" type="email" />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={createCustomerForm.control}
name="phone"
render={({ field }) => (
<FormItem>
<FormLabel>Phone</FormLabel>
<FormControl>
<Input {...field} placeholder="+1 (555) 123-4567" />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
</div>
<FormField
control={createCustomerForm.control}
name="website"
render={({ field }) => (
<FormItem>
<FormLabel>Website</FormLabel>
<FormControl>
<Input {...field} placeholder="https://example.com" />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={createCustomerForm.control}
name="industry"
render={({ field }) => (
<FormItem>
<FormLabel>Industry</FormLabel>
<FormControl>
<Input {...field} placeholder="Technology, Healthcare, etc." />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<div className="space-y-1">
<h4 className="text-sm font-medium">Address Information</h4>
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
<FormField
control={createCustomerForm.control}
name="address"
render={({ field }) => (
<FormItem>
<FormLabel>Address</FormLabel>
<FormControl>
<Input {...field} placeholder="123 Main Street" />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={createCustomerForm.control}
name="city"
render={({ field }) => (
<FormItem>
<FormLabel>City</FormLabel>
<FormControl>
<Input {...field} placeholder="San Francisco" />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={createCustomerForm.control}
name="state"
render={({ field }) => (
<FormItem>
<FormLabel>State/Province</FormLabel>
<FormControl>
<Input {...field} placeholder="CA" />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={createCustomerForm.control}
name="zipCode"
render={({ field }) => (
<FormItem>
<FormLabel>ZIP/Postal Code</FormLabel>
<FormControl>
<Input {...field} placeholder="94105" />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={createCustomerForm.control}
name="country"
render={({ field }) => (
<FormItem>
<FormLabel>Country</FormLabel>
<FormControl>
<Input {...field} placeholder="United States" />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
</div>
</div>
<div className="space-y-1">
<h4 className="text-sm font-medium">Billing Information</h4>
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
<FormField
control={createCustomerForm.control}
name="billingEmail"
render={({ field }) => (
<FormItem>
<FormLabel>Billing Email</FormLabel>
<FormControl>
<Input {...field} placeholder="billing@example.com" type="email" />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={createCustomerForm.control}
name="billingAddress"
render={({ field }) => (
<FormItem>
<FormLabel>Billing Address</FormLabel>
<FormControl>
<Input {...field} placeholder="Same as main address or enter different address" />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
</div>
</div>
<FormField
control={createCustomerForm.control}
name="accountManager"
render={({ field }) => (
<FormItem>
<FormLabel>Account Manager</FormLabel>
<FormControl>
<Input {...field} placeholder="Name of assigned account manager" />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={createCustomerForm.control}
name="notes"
render={({ field }) => (
<FormItem>
<FormLabel>Notes</FormLabel>
<FormControl>
<Textarea {...field} placeholder="Additional notes about this customer" />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={createCustomerForm.control}
name="isActive"
render={({ field }) => (
<FormItem className="flex flex-row items-center justify-between rounded-lg border p-4">