1
0
Code Issues Pull Requests Actions Packages Projects Releases Wiki Activity Security Code Quality

Update customer form field

This commit is contained in:
2025-07-09 09:45:35 +07:00
parent adbe09d074
commit ddba65ed5c
10 changed files with 536 additions and 145 deletions

View File

@@ -104,8 +104,8 @@ export async function PUT(
...db.data!.customerDependants[dependantIndex],
firstNameEn: body.dependantInfo.firstNameEn,
lastNameEn: body.dependantInfo.lastNameEn,
originAdd1: body.dependantInfo.originAdd1,
localAdd1: body.dependantInfo.localAdd1,
originAdd1: body.dependantContact.originAdd1,
localAdd1: body.dependantContact.localAdd1,
email: body.dependantContact.email,
mobile: body.dependantContact.mobile,
};

View File

@@ -116,10 +116,14 @@ export async function PUT(
...db.data!.customers[customerIndex],
firstNameEn: body.customerInfo.firstNameEn,
lastNameEn: body.customerInfo.lastNameEn,
originAdd1: body.customerInfo.originAdd1,
localAdd1: body.customerInfo.localAdd1,
firstNameJp: body.customerInfo.firstNameJp,
lastNameJp: body.customerInfo.lastNameJp,
firstNameJpKana: body.customerInfo.firstNameJpKana,
lastNameJpKana: body.customerInfo.lastNameJpKana,
email: body.customerContact.email,
mobile: body.customerContact.mobile,
originAdd1: body.customerContact.originAdd1,
localAdd1: body.customerContact.localAdd1,
};
db.data!.customers[customerIndex] = updatedCustomer;
@@ -140,10 +144,14 @@ export async function PUT(
custId: customerId,
firstNameEn: dependant.dependantInfo.firstNameEn,
lastNameEn: dependant.dependantInfo.lastNameEn,
originAdd1: dependant.dependantInfo.originAdd1,
localAdd1: dependant.dependantInfo.localAdd1,
firstNameJp: dependant.dependantInfo.firstNameJp,
lastNameJp: dependant.dependantInfo.lastNameJp,
firstNameJpKana: dependant.dependantInfo.firstNameJpKana,
lastNameJpKana: dependant.dependantInfo.lastNameJpKana,
email: dependant.dependantContact.email,
mobile: dependant.dependantContact.mobile,
originAdd1: dependant.dependantContact.originAdd1,
localAdd1: dependant.dependantContact.localAdd1,
};
newDependants.push(newDependant);
db.data!.customerDependants.push(newDependant);

View File

@@ -19,10 +19,14 @@ export async function POST(request: NextRequest) {
id: getNextId(db.data!.customers),
firstNameEn: validatedData.customerInfo.firstNameEn,
lastNameEn: validatedData.customerInfo.lastNameEn,
firstNameJp: validatedData.customerInfo.firstNameJp,
lastNameJp: validatedData.customerInfo.lastNameJp,
firstNameJpKana: validatedData.customerInfo.firstNameJpKana,
lastNameJpKana: validatedData.customerInfo.lastNameJpKana,
email: validatedData.customerContact.email,
mobile: validatedData.customerContact.mobile,
originAdd1: validatedData.customerInfo.originAdd1,
localAdd1: validatedData.customerInfo.localAdd1,
originAdd1: validatedData.customerContact.originAdd1,
localAdd1: validatedData.customerContact.localAdd1,
};
// Add customer to database
@@ -38,10 +42,14 @@ export async function POST(request: NextRequest) {
custId: newCustomer.id,
firstNameEn: dependant.dependantInfo.firstNameEn,
lastNameEn: dependant.dependantInfo.lastNameEn,
firstNameJp: dependant.dependantInfo.firstNameJp,
lastNameJp: dependant.dependantInfo.lastNameJp,
firstNameJpKana: dependant.dependantInfo.firstNameJpKana,
lastNameJpKana: dependant.dependantInfo.lastNameJpKana,
email: dependant.dependantContact.email,
mobile: dependant.dependantContact.mobile,
originAdd1: dependant.dependantInfo.originAdd1,
localAdd1: dependant.dependantInfo.localAdd1,
originAdd1: dependant.dependantContact.originAdd1,
localAdd1: dependant.dependantContact.localAdd1,
};
customerDependants.push(newDependant);
db.data!.customerDependants.push(newDependant);

View File

@@ -41,12 +41,16 @@ export default function CustomerEditPage() {
customerInfo: {
firstNameEn: "",
lastNameEn: "",
originAdd1: "",
localAdd1: "",
firstNameJp: "",
lastNameJp: "",
firstNameJpKana: "",
lastNameJpKana: "",
},
customerContact: {
email: "",
mobile: "",
originAdd1: "",
localAdd1: "",
},
customerDependants: [],
},
@@ -59,12 +63,16 @@ export default function CustomerEditPage() {
dependantInfo: {
firstNameEn: "",
lastNameEn: "",
originAdd1: "",
localAdd1: "",
firstNameJp: "",
lastNameJp: "",
firstNameJpKana: "",
lastNameJpKana: "",
},
dependantContact: {
email: "",
mobile: "",
originAdd1: "",
localAdd1: "",
},
},
});
@@ -84,16 +92,28 @@ export default function CustomerEditPage() {
// Populate form with customer data
form.setValue("customerInfo.firstNameEn", customerData.firstNameEn);
form.setValue("customerInfo.lastNameEn", customerData.lastNameEn);
form.setValue("customerInfo.originAdd1", customerData.originAdd1);
form.setValue("customerInfo.localAdd1", customerData.localAdd1);
form.setValue("customerInfo.firstNameJp", customerData.firstNameJp);
form.setValue("customerInfo.lastNameJp", customerData.lastNameJp);
form.setValue("customerInfo.firstNameJpKana", customerData.firstNameJpKana);
form.setValue("customerInfo.lastNameJpKana", customerData.lastNameJpKana);
form.setValue("customerInfo.firstNameJp", customerData.firstNameJp);
form.setValue("customerInfo.lastNameJp", customerData.lastNameJp);
form.setValue("customerInfo.firstNameJpKana", customerData.firstNameJpKana);
form.setValue("customerInfo.lastNameJpKana", customerData.lastNameJpKana);
form.setValue("customerContact.email", customerData.email);
form.setValue("customerContact.mobile", customerData.mobile);
form.setValue("customerContact.originAdd1", customerData.originAdd1);
form.setValue("customerContact.localAdd1", customerData.localAdd1);
// Convert dependants to the expected format
const dependants: CustomerDependantForm[] = customerData.dependants.map((dep: {
id: number;
firstNameEn: string;
lastNameEn: string;
firstNameJp: string;
lastNameJp: string;
firstNameJpKana: string;
lastNameJpKana: string;
email: string;
mobile: string;
originAdd1: string;
@@ -103,12 +123,16 @@ export default function CustomerEditPage() {
dependantInfo: {
firstNameEn: dep.firstNameEn,
lastNameEn: dep.lastNameEn,
originAdd1: dep.originAdd1,
localAdd1: dep.localAdd1,
firstNameJp: dep.firstNameJp,
lastNameJp: dep.lastNameJp,
firstNameJpKana: dep.firstNameJpKana,
lastNameJpKana: dep.lastNameJpKana,
},
dependantContact: {
email: dep.email,
mobile: dep.mobile,
originAdd1: dep.originAdd1,
localAdd1: dep.localAdd1,
},
}));
@@ -173,12 +197,20 @@ export default function CustomerEditPage() {
dep.id === editingDependant.id
? {
...dep,
firstNameEn: data.dependantInfo.firstNameEn,
lastNameEn: data.dependantInfo.lastNameEn,
originAdd1: data.dependantInfo.originAdd1,
localAdd1: data.dependantInfo.localAdd1,
email: data.dependantContact.email,
mobile: data.dependantContact.mobile,
dependantInfo: {
firstNameEn: data.dependantInfo.firstNameEn,
lastNameEn: data.dependantInfo.lastNameEn,
firstNameJp: data.dependantInfo.firstNameJp,
lastNameJp: data.dependantInfo.lastNameJp,
firstNameJpKana: data.dependantInfo.firstNameJpKana,
lastNameJpKana: data.dependantInfo.lastNameJpKana,
},
dependantContact: {
email: data.dependantContact.email,
mobile: data.dependantContact.mobile,
originAdd1: data.dependantContact.originAdd1,
localAdd1: data.dependantContact.localAdd1,
},
}
: dep
);
@@ -191,12 +223,16 @@ export default function CustomerEditPage() {
dependantInfo: {
firstNameEn: data.dependantInfo.firstNameEn,
lastNameEn: data.dependantInfo.lastNameEn,
originAdd1: data.dependantInfo.originAdd1,
localAdd1: data.dependantInfo.localAdd1,
firstNameJp: data.dependantInfo.firstNameJp,
lastNameJp: data.dependantInfo.lastNameJp,
firstNameJpKana: data.dependantInfo.firstNameJpKana,
lastNameJpKana: data.dependantInfo.lastNameJpKana,
},
dependantContact: {
email: data.dependantContact.email,
mobile: data.dependantContact.mobile,
originAdd1: data.dependantContact.originAdd1,
localAdd1: data.dependantContact.localAdd1,
},
};
@@ -220,10 +256,14 @@ export default function CustomerEditPage() {
setEditingDependant(dependant);
dependantForm.setValue("dependantInfo.firstNameEn", dependant.dependantInfo.firstNameEn);
dependantForm.setValue("dependantInfo.lastNameEn", dependant.dependantInfo.lastNameEn);
dependantForm.setValue("dependantInfo.originAdd1", dependant.dependantInfo.originAdd1);
dependantForm.setValue("dependantInfo.localAdd1", dependant.dependantInfo.localAdd1);
dependantForm.setValue("dependantInfo.firstNameJp", dependant.dependantInfo.firstNameJp);
dependantForm.setValue("dependantInfo.lastNameJp", dependant.dependantInfo.lastNameJp);
dependantForm.setValue("dependantInfo.firstNameJpKana", dependant.dependantInfo.firstNameJpKana);
dependantForm.setValue("dependantInfo.lastNameJpKana", dependant.dependantInfo.lastNameJpKana);
dependantForm.setValue("dependantContact.email", dependant.dependantContact.email);
dependantForm.setValue("dependantContact.mobile", dependant.dependantContact.mobile);
dependantForm.setValue("dependantContact.originAdd1", dependant.dependantContact.originAdd1);
dependantForm.setValue("dependantContact.localAdd1", dependant.dependantContact.localAdd1);
setDependantDialogOpen(true);
setDependantDialogTab("info");
};
@@ -252,8 +292,6 @@ export default function CustomerEditPage() {
const isValid = await form.trigger([
"customerInfo.firstNameEn",
"customerInfo.lastNameEn",
"customerInfo.originAdd1",
"customerInfo.localAdd1",
]);
if (isValid) {
setActiveTab("contact");
@@ -262,7 +300,12 @@ export default function CustomerEditPage() {
}
} else if (activeTab === "contact") {
// Validate customer contact fields before proceeding
const isValid = await form.trigger(["customerContact.email", "customerContact.mobile"]);
const isValid = await form.trigger([
"customerContact.email",
"customerContact.mobile",
"customerContact.originAdd1",
"customerContact.localAdd1"
]);
if (isValid) {
setActiveTab("dependants");
} else {
@@ -287,19 +330,19 @@ export default function CustomerEditPage() {
return (
values.customerInfo?.firstNameEn?.trim() !== "" &&
values.customerInfo?.lastNameEn?.trim() !== "" &&
values.customerInfo?.originAdd1?.trim() !== "" &&
values.customerInfo?.localAdd1?.trim() !== "" &&
!errors.customerInfo?.firstNameEn &&
!errors.customerInfo?.lastNameEn &&
!errors.customerInfo?.originAdd1 &&
!errors.customerInfo?.localAdd1
!errors.customerInfo?.lastNameEn
);
} else if (tabName === "contact") {
return (
values.customerContact?.email?.trim() !== "" &&
values.customerContact?.mobile?.trim() !== "" &&
values.customerContact?.originAdd1?.trim() !== "" &&
values.customerContact?.localAdd1?.trim() !== "" &&
!errors.customerContact?.email &&
!errors.customerContact?.mobile
!errors.customerContact?.mobile &&
!errors.customerContact?.originAdd1 &&
!errors.customerContact?.localAdd1
);
}
return true;
@@ -395,16 +438,14 @@ export default function CustomerEditPage() {
</FormItem>
)}
/>
</div>
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
<FormField
control={form.control}
name="customerInfo.originAdd1"
name="customerInfo.firstNameJp"
render={({ field }) => (
<FormItem>
<FormLabel>Origin Address</FormLabel>
<FormLabel>First Name (Japanese)</FormLabel>
<FormControl>
<Input placeholder="Enter origin address" {...field} />
<Input placeholder="名前を入力してください" {...field} />
</FormControl>
<FormMessage />
</FormItem>
@@ -412,12 +453,38 @@ export default function CustomerEditPage() {
/>
<FormField
control={form.control}
name="customerInfo.localAdd1"
name="customerInfo.lastNameJp"
render={({ field }) => (
<FormItem>
<FormLabel>Local Address</FormLabel>
<FormLabel>Last Name (Japanese)</FormLabel>
<FormControl>
<Input placeholder="Enter local address" {...field} />
<Input placeholder="姓を入力してください" {...field} />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={form.control}
name="customerInfo.firstNameJpKana"
render={({ field }) => (
<FormItem>
<FormLabel>First Name (Japanese Kana)</FormLabel>
<FormControl>
<Input placeholder="ナマエ" {...field} />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={form.control}
name="customerInfo.lastNameJpKana"
render={({ field }) => (
<FormItem>
<FormLabel>Last Name (Japanese Kana)</FormLabel>
<FormControl>
<Input placeholder="セイ" {...field} />
</FormControl>
<FormMessage />
</FormItem>
@@ -458,6 +525,34 @@ export default function CustomerEditPage() {
)}
/>
</div>
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
<FormField
control={form.control}
name="customerContact.originAdd1"
render={({ field }) => (
<FormItem>
<FormLabel>Origin Address</FormLabel>
<FormControl>
<Input placeholder="Enter origin address" {...field} />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={form.control}
name="customerContact.localAdd1"
render={({ field }) => (
<FormItem>
<FormLabel>Local Address</FormLabel>
<FormControl>
<Input placeholder="Enter local address" {...field} />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
</div>
<div className="flex justify-between">
<Button type="button" variant="outline" onClick={handlePreviousTab}>
Previous
@@ -476,14 +571,14 @@ export default function CustomerEditPage() {
Add Dependant
</Button>
</DialogTrigger>
<DialogContent className="max-w-2xl">
<DialogContent className="max-w-[1200px] w-full min-w-[900px]">
<DialogHeader>
<DialogTitle>
{editingDependant ? "Edit Dependant" : "Add New Dependant"}
</DialogTitle>
</DialogHeader>
<Form {...dependantForm}>
<form className="space-y-4">
<form className="space-y-4 w-full">
<Tabs value={dependantDialogTab} onValueChange={setDependantDialogTab} className="w-full">
<TabsList className="grid w-full grid-cols-2">
<TabsTrigger value="info">Dependant Info</TabsTrigger>
@@ -518,16 +613,14 @@ export default function CustomerEditPage() {
</FormItem>
)}
/>
</div>
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
<FormField
control={dependantForm.control}
name="dependantInfo.originAdd1"
name="dependantInfo.firstNameJp"
render={({ field }) => (
<FormItem>
<FormLabel>Origin Address</FormLabel>
<FormLabel>First Name (Japanese)</FormLabel>
<FormControl>
<Input placeholder="Enter origin address" {...field} />
<Input placeholder="名前を入力してください" {...field} />
</FormControl>
<FormMessage />
</FormItem>
@@ -535,12 +628,38 @@ export default function CustomerEditPage() {
/>
<FormField
control={dependantForm.control}
name="dependantInfo.localAdd1"
name="dependantInfo.lastNameJp"
render={({ field }) => (
<FormItem>
<FormLabel>Local Address</FormLabel>
<FormLabel>Last Name (Japanese)</FormLabel>
<FormControl>
<Input placeholder="Enter local address" {...field} />
<Input placeholder="姓を入力してください" {...field} />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={dependantForm.control}
name="dependantInfo.firstNameJpKana"
render={({ field }) => (
<FormItem>
<FormLabel>First Name (Japanese Kana)</FormLabel>
<FormControl>
<Input placeholder="ナマエ" {...field} />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={dependantForm.control}
name="dependantInfo.lastNameJpKana"
render={({ field }) => (
<FormItem>
<FormLabel>Last Name (Japanese Kana)</FormLabel>
<FormControl>
<Input placeholder="セイ" {...field} />
</FormControl>
<FormMessage />
</FormItem>
@@ -554,8 +673,10 @@ export default function CustomerEditPage() {
const isValid = await dependantForm.trigger([
"dependantInfo.firstNameEn",
"dependantInfo.lastNameEn",
"dependantInfo.originAdd1",
"dependantInfo.localAdd1"
"dependantInfo.firstNameJp",
"dependantInfo.lastNameJp",
"dependantInfo.firstNameJpKana",
"dependantInfo.lastNameJpKana"
]);
if (isValid) {
setDependantDialogTab("contact");
@@ -598,6 +719,34 @@ export default function CustomerEditPage() {
)}
/>
</div>
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
<FormField
control={dependantForm.control}
name="dependantContact.originAdd1"
render={({ field }) => (
<FormItem>
<FormLabel>Origin Address</FormLabel>
<FormControl>
<Input placeholder="Enter origin address" {...field} />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={dependantForm.control}
name="dependantContact.localAdd1"
render={({ field }) => (
<FormItem>
<FormLabel>Local Address</FormLabel>
<FormControl>
<Input placeholder="Enter local address" {...field} />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
</div>
<div className="flex justify-start">
<Button
type="button"
@@ -663,8 +812,8 @@ export default function CustomerEditPage() {
<TableCell>{dependant.dependantInfo.lastNameEn}</TableCell>
<TableCell>{dependant.dependantContact.email}</TableCell>
<TableCell>{dependant.dependantContact.mobile}</TableCell>
<TableCell>{dependant.dependantInfo.originAdd1}</TableCell>
<TableCell>{dependant.dependantInfo.localAdd1}</TableCell>
<TableCell>{dependant.dependantContact.originAdd1}</TableCell>
<TableCell>{dependant.dependantContact.localAdd1}</TableCell>
<TableCell>
<div className="flex space-x-2">
<Button

View File

@@ -35,12 +35,16 @@ export default function CustomerAddPage() {
customerInfo: {
firstNameEn: "",
lastNameEn: "",
originAdd1: "",
localAdd1: "",
firstNameJp: "",
lastNameJp: "",
firstNameJpKana: "",
lastNameJpKana: "",
},
customerContact: {
email: "",
mobile: "",
originAdd1: "",
localAdd1: "",
},
customerDependants: [],
},
@@ -53,12 +57,16 @@ export default function CustomerAddPage() {
dependantInfo: {
firstNameEn: "",
lastNameEn: "",
originAdd1: "",
localAdd1: "",
firstNameJp: "",
lastNameJp: "",
firstNameJpKana: "",
lastNameJpKana: "",
},
dependantContact: {
email: "",
mobile: "",
originAdd1: "",
localAdd1: "",
},
},
});
@@ -102,12 +110,16 @@ export default function CustomerAddPage() {
dependantInfo: {
firstNameEn: data.dependantInfo.firstNameEn,
lastNameEn: data.dependantInfo.lastNameEn,
originAdd1: data.dependantInfo.originAdd1,
localAdd1: data.dependantInfo.localAdd1,
firstNameJp: data.dependantInfo.firstNameJp,
lastNameJp: data.dependantInfo.lastNameJp,
firstNameJpKana: data.dependantInfo.firstNameJpKana,
lastNameJpKana: data.dependantInfo.lastNameJpKana,
},
dependantContact: {
email: data.dependantContact.email,
mobile: data.dependantContact.mobile,
originAdd1: data.dependantContact.originAdd1,
localAdd1: data.dependantContact.localAdd1,
},
};
@@ -139,8 +151,10 @@ export default function CustomerAddPage() {
const isValid = await form.trigger([
"customerInfo.firstNameEn",
"customerInfo.lastNameEn",
"customerInfo.originAdd1",
"customerInfo.localAdd1"
"customerInfo.firstNameJp",
"customerInfo.lastNameJp",
"customerInfo.firstNameJpKana",
"customerInfo.lastNameJpKana"
]);
if (isValid) {
setActiveTab("contact");
@@ -149,7 +163,12 @@ export default function CustomerAddPage() {
}
} else if (activeTab === "contact") {
// Validate customer contact fields before proceeding
const isValid = await form.trigger(["customerContact.email", "customerContact.mobile"]);
const isValid = await form.trigger([
"customerContact.email",
"customerContact.mobile",
"customerContact.originAdd1",
"customerContact.localAdd1"
]);
if (isValid) {
setActiveTab("dependants");
} else {
@@ -174,19 +193,19 @@ export default function CustomerAddPage() {
return (
values.customerInfo?.firstNameEn?.trim() !== "" &&
values.customerInfo?.lastNameEn?.trim() !== "" &&
values.customerInfo?.originAdd1?.trim() !== "" &&
values.customerInfo?.localAdd1?.trim() !== "" &&
!errors.customerInfo?.firstNameEn &&
!errors.customerInfo?.lastNameEn &&
!errors.customerInfo?.originAdd1 &&
!errors.customerInfo?.localAdd1
!errors.customerInfo?.lastNameEn
);
} else if (tabName === "contact") {
return (
values.customerContact?.email?.trim() !== "" &&
values.customerContact?.mobile?.trim() !== "" &&
values.customerContact?.originAdd1?.trim() !== "" &&
values.customerContact?.localAdd1?.trim() !== "" &&
!errors.customerContact?.email &&
!errors.customerContact?.mobile
!errors.customerContact?.mobile &&
!errors.customerContact?.originAdd1 &&
!errors.customerContact?.localAdd1
);
}
return true;
@@ -276,16 +295,14 @@ export default function CustomerAddPage() {
</FormItem>
)}
/>
</div>
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
<FormField
control={form.control}
name="customerInfo.originAdd1"
name="customerInfo.firstNameJp"
render={({ field }) => (
<FormItem>
<FormLabel>Origin Address</FormLabel>
<FormLabel>First Name (Japanese)</FormLabel>
<FormControl>
<Input placeholder="Enter origin address" {...field} />
<Input placeholder="名前を入力してください" {...field} />
</FormControl>
<FormMessage />
</FormItem>
@@ -293,12 +310,38 @@ export default function CustomerAddPage() {
/>
<FormField
control={form.control}
name="customerInfo.localAdd1"
name="customerInfo.lastNameJp"
render={({ field }) => (
<FormItem>
<FormLabel>Local Address</FormLabel>
<FormLabel>Last Name (Japanese)</FormLabel>
<FormControl>
<Input placeholder="Enter local address" {...field} />
<Input placeholder="姓を入力してください" {...field} />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={form.control}
name="customerInfo.firstNameJpKana"
render={({ field }) => (
<FormItem>
<FormLabel>First Name (Japanese Kana)</FormLabel>
<FormControl>
<Input placeholder="ナマエ" {...field} />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={form.control}
name="customerInfo.lastNameJpKana"
render={({ field }) => (
<FormItem>
<FormLabel>Last Name (Japanese Kana)</FormLabel>
<FormControl>
<Input placeholder="セイ" {...field} />
</FormControl>
<FormMessage />
</FormItem>
@@ -342,6 +385,34 @@ export default function CustomerAddPage() {
)}
/>
</div>
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
<FormField
control={form.control}
name="customerContact.originAdd1"
render={({ field }) => (
<FormItem>
<FormLabel>Origin Address</FormLabel>
<FormControl>
<Input placeholder="Enter origin address" {...field} />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={form.control}
name="customerContact.localAdd1"
render={({ field }) => (
<FormItem>
<FormLabel>Local Address</FormLabel>
<FormControl>
<Input placeholder="Enter local address" {...field} />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
</div>
<div className="flex justify-between">
<Button type="button" variant="outline" onClick={handlePreviousTab}>
Previous
@@ -403,16 +474,14 @@ export default function CustomerAddPage() {
</FormItem>
)}
/>
</div>
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
<FormField
control={dependantForm.control}
name="dependantInfo.originAdd1"
name="dependantInfo.firstNameJp"
render={({ field }) => (
<FormItem>
<FormLabel>Origin Address</FormLabel>
<FormLabel>First Name (Japanese)</FormLabel>
<FormControl>
<Input placeholder="Enter origin address" {...field} />
<Input placeholder="名前を入力してください" {...field} />
</FormControl>
<FormMessage />
</FormItem>
@@ -420,12 +489,38 @@ export default function CustomerAddPage() {
/>
<FormField
control={dependantForm.control}
name="dependantInfo.localAdd1"
name="dependantInfo.lastNameJp"
render={({ field }) => (
<FormItem>
<FormLabel>Local Address</FormLabel>
<FormLabel>Last Name (Japanese)</FormLabel>
<FormControl>
<Input placeholder="Enter local address" {...field} />
<Input placeholder="姓を入力してください" {...field} />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={dependantForm.control}
name="dependantInfo.firstNameJpKana"
render={({ field }) => (
<FormItem>
<FormLabel>First Name (Japanese Kana)</FormLabel>
<FormControl>
<Input placeholder="ナマエ" {...field} />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={dependantForm.control}
name="dependantInfo.lastNameJpKana"
render={({ field }) => (
<FormItem>
<FormLabel>Last Name (Japanese Kana)</FormLabel>
<FormControl>
<Input placeholder="セイ" {...field} />
</FormControl>
<FormMessage />
</FormItem>
@@ -439,8 +534,10 @@ export default function CustomerAddPage() {
const isValid = await dependantForm.trigger([
"dependantInfo.firstNameEn",
"dependantInfo.lastNameEn",
"dependantInfo.originAdd1",
"dependantInfo.localAdd1"
"dependantInfo.firstNameJp",
"dependantInfo.lastNameJp",
"dependantInfo.firstNameJpKana",
"dependantInfo.lastNameJpKana"
]);
if (isValid) {
setDependantDialogTab("contact");
@@ -483,6 +580,34 @@ export default function CustomerAddPage() {
)}
/>
</div>
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
<FormField
control={dependantForm.control}
name="dependantContact.originAdd1"
render={({ field }) => (
<FormItem>
<FormLabel>Origin Address</FormLabel>
<FormControl>
<Input placeholder="Enter origin address" {...field} />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={dependantForm.control}
name="dependantContact.localAdd1"
render={({ field }) => (
<FormItem>
<FormLabel>Local Address</FormLabel>
<FormControl>
<Input placeholder="Enter local address" {...field} />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
</div>
<div className="flex justify-start">
<Button
type="button"
@@ -544,8 +669,8 @@ export default function CustomerAddPage() {
<TableCell>{dependant.dependantInfo.lastNameEn}</TableCell>
<TableCell>{dependant.dependantContact.email}</TableCell>
<TableCell>{dependant.dependantContact.mobile}</TableCell>
<TableCell>{dependant.dependantInfo.originAdd1}</TableCell>
<TableCell>{dependant.dependantInfo.localAdd1}</TableCell>
<TableCell>{dependant.dependantContact.originAdd1}</TableCell>
<TableCell>{dependant.dependantContact.localAdd1}</TableCell>
<TableCell>
<Button
type="button"

View File

@@ -4,10 +4,10 @@ export interface Customer {
id: number;
firstNameEn: string;
lastNameEn: string;
// firstNameJp: string;
// lastNameJp: string;
// firstNameJpKana: string;
// lastNameJpKana: string;
firstNameJp: string;
lastNameJp: string;
firstNameJpKana: string;
lastNameJpKana: string;
email: string;
// email2?: string;
mobile: string;
@@ -73,10 +73,10 @@ export interface CustomerDependant {
// deptSeq: number;
firstNameEn: string;
lastNameEn: string;
// firstNameJp: string;
// lastNameJp: string;
// firstNameJpKana: string;
// lastNameJpKana: string;
firstNameJp: string;
lastNameJp: string;
firstNameJpKana: string;
lastNameJpKana: string;
email: string;
// email2?: string;
mobile: string;

View File

@@ -4,6 +4,10 @@
"id": 1,
"firstNameEn": "John",
"lastNameEn": "Smith",
"firstNameJp": "ジョン",
"lastNameJp": "スミス",
"firstNameJpKana": "ジョン",
"lastNameJpKana": "スミス",
"email": "john.smith@email.com",
"mobile": "+1-555-0101",
"originAdd1": "123 Main Street, New York, NY 10001, USA",
@@ -13,6 +17,10 @@
"id": 2,
"firstNameEn": "Sarah",
"lastNameEn": "Johnson",
"firstNameJp": "サラ",
"lastNameJp": "ジョンソン",
"firstNameJpKana": "サラ",
"lastNameJpKana": "ジョンソン",
"email": "sarah.johnson@email.com",
"mobile": "+1-555-0102",
"originAdd1": "789 Pine Road, Los Angeles, CA 90210, USA",
@@ -22,6 +30,10 @@
"id": 3,
"firstNameEn": "Michael",
"lastNameEn": "Brown",
"firstNameJp": "マイケル",
"lastNameJp": "ブラウン",
"firstNameJpKana": "マイケル",
"lastNameJpKana": "ブラウン",
"email": "michael.brown@email.com",
"mobile": "+44-20-7946-0958",
"originAdd1": "42 Victoria Street, London, UK SW1H 0TL",
@@ -31,6 +43,10 @@
"id": 4,
"firstNameEn": "Emily",
"lastNameEn": "Davis",
"firstNameJp": "エミリー",
"lastNameJp": "デイビス",
"firstNameJpKana": "エミリー",
"lastNameJpKana": "デイビス",
"email": "emily.davis@email.com",
"mobile": "+61-2-9876-5432",
"originAdd1": "15 Collins Street, Melbourne, VIC 3000, Australia",
@@ -40,19 +56,14 @@
"id": 5,
"firstNameEn": "David",
"lastNameEn": "Wilson",
"firstNameJp": "デイビッド",
"lastNameJp": "ウィルソン",
"firstNameJpKana": "デイビッド",
"lastNameJpKana": "ウィルソン",
"email": "david.wilson@email.com",
"mobile": "+1-416-555-0199",
"originAdd1": "100 Queen Street West, Toronto, ON M5H 2N2, Canada",
"localAdd1": "987 Ginza District, Tokyo, Japan 104-0061"
},
{
"id": 6,
"firstNameEn": "Đỗ",
"lastNameEn": "Thanh Tùng",
"email": "dothanhtung196@gmail.com",
"mobile": "0987417491",
"originAdd1": "123",
"localAdd1": "sdfgsdfg"
}
],
"users": [
@@ -232,6 +243,26 @@
"userId": 1,
"permissionId": 15
},
{
"id": 16,
"userId": 2,
"permissionId": 4
},
{
"id": 17,
"userId": 2,
"permissionId": 5
},
{
"id": 18,
"userId": 2,
"permissionId": 8
},
{
"id": 19,
"userId": 2,
"permissionId": 11
},
{
"id": 20,
"userId": 3,
@@ -426,26 +457,6 @@
"id": 58,
"userId": 11,
"permissionId": 12
},
{
"id": 59,
"userId": 2,
"permissionId": 4
},
{
"id": 60,
"userId": 2,
"permissionId": 5
},
{
"id": 61,
"userId": 2,
"permissionId": 8
},
{
"id": 62,
"userId": 2,
"permissionId": 11
}
],
"permissions": [
@@ -546,6 +557,10 @@
"custId": 1,
"firstNameEn": "Jane",
"lastNameEn": "Smith",
"firstNameJp": "ジェーン",
"lastNameJp": "スミス",
"firstNameJpKana": "ジェーン",
"lastNameJpKana": "スミス",
"email": "jane.smith@email.com",
"mobile": "+1-555-0111",
"originAdd1": "123 Main Street, New York, NY 10001, USA",
@@ -556,6 +571,10 @@
"custId": 1,
"firstNameEn": "Tommy",
"lastNameEn": "Smith",
"firstNameJp": "トミー",
"lastNameJp": "スミス",
"firstNameJpKana": "トミー",
"lastNameJpKana": "スミス",
"email": "tommy.smith@email.com",
"mobile": "+1-555-0112",
"originAdd1": "123 Main Street, New York, NY 10001, USA",
@@ -566,6 +585,10 @@
"custId": 2,
"firstNameEn": "Mark",
"lastNameEn": "Johnson",
"firstNameJp": "マーク",
"lastNameJp": "ジョンソン",
"firstNameJpKana": "マーク",
"lastNameJpKana": "ジョンソン",
"email": "mark.johnson@email.com",
"mobile": "+1-555-0121",
"originAdd1": "789 Pine Road, Los Angeles, CA 90210, USA",
@@ -576,6 +599,10 @@
"custId": 2,
"firstNameEn": "Lisa",
"lastNameEn": "Johnson",
"firstNameJp": "リサ",
"lastNameJp": "ジョンソン",
"firstNameJpKana": "リサ",
"lastNameJpKana": "ジョンソン",
"email": "lisa.johnson@email.com",
"mobile": "+1-555-0122",
"originAdd1": "789 Pine Road, Los Angeles, CA 90210, USA",
@@ -586,6 +613,10 @@
"custId": 3,
"firstNameEn": "Anna",
"lastNameEn": "Brown",
"firstNameJp": "アンナ",
"lastNameJp": "ブラウン",
"firstNameJpKana": "アンナ",
"lastNameJpKana": "ブラウン",
"email": "anna.brown@email.com",
"mobile": "+44-20-7946-0959",
"originAdd1": "42 Victoria Street, London, UK SW1H 0TL",
@@ -596,6 +627,10 @@
"custId": 4,
"firstNameEn": "James",
"lastNameEn": "Davis",
"firstNameJp": "ジェームズ",
"lastNameJp": "デイビス",
"firstNameJpKana": "ジェームズ",
"lastNameJpKana": "デイビス",
"email": "james.davis@email.com",
"mobile": "+61-2-9876-5433",
"originAdd1": "15 Collins Street, Melbourne, VIC 3000, Australia",
@@ -606,6 +641,10 @@
"custId": 4,
"firstNameEn": "Sophie",
"lastNameEn": "Davis",
"firstNameJp": "ソフィー",
"lastNameJp": "デイビス",
"firstNameJpKana": "ソフィー",
"lastNameJpKana": "デイビス",
"email": "sophie.davis@email.com",
"mobile": "+61-2-9876-5434",
"originAdd1": "15 Collins Street, Melbourne, VIC 3000, Australia",
@@ -616,6 +655,10 @@
"custId": 4,
"firstNameEn": "Oliver",
"lastNameEn": "Davis",
"firstNameJp": "オリバー",
"lastNameJp": "デイビス",
"firstNameJpKana": "オリバー",
"lastNameJpKana": "デイビス",
"email": "oliver.davis@email.com",
"mobile": "+61-2-9876-5435",
"originAdd1": "15 Collins Street, Melbourne, VIC 3000, Australia",
@@ -626,20 +669,14 @@
"custId": 5,
"firstNameEn": "Rachel",
"lastNameEn": "Wilson",
"firstNameJp": "レイチェル",
"lastNameJp": "ウィルソン",
"firstNameJpKana": "レイチェル",
"lastNameJpKana": "ウィルソン",
"email": "rachel.wilson@email.com",
"mobile": "+1-416-555-0191",
"originAdd1": "100 Queen Street West, Toronto, ON M5H 2N2, Canada",
"localAdd1": "987 Ginza District, Tokyo, Japan 104-0061"
},
{
"id": 10,
"custId": 6,
"firstNameEn": "Đỗ",
"lastNameEn": "Thanh Tùng",
"email": "dothanhtung196@gmail.com",
"mobile": "0987417491",
"originAdd1": "123",
"localAdd1": "sdfgsdfg"
}
]
}

View File

@@ -7,6 +7,10 @@ export const sampleCustomerDependants: CustomerDependant[] = [
custId: 1,
firstNameEn: "Jane",
lastNameEn: "Smith",
firstNameJp: "ジェーン",
lastNameJp: "スミス",
firstNameJpKana: "ジェーン",
lastNameJpKana: "スミス",
email: "jane.smith@email.com",
mobile: "+1-555-0111",
originAdd1: "123 Main Street, New York, NY 10001, USA",
@@ -17,6 +21,10 @@ export const sampleCustomerDependants: CustomerDependant[] = [
custId: 1,
firstNameEn: "Tommy",
lastNameEn: "Smith",
firstNameJp: "トミー",
lastNameJp: "スミス",
firstNameJpKana: "トミー",
lastNameJpKana: "スミス",
email: "tommy.smith@email.com",
mobile: "+1-555-0112",
originAdd1: "123 Main Street, New York, NY 10001, USA",
@@ -28,6 +36,10 @@ export const sampleCustomerDependants: CustomerDependant[] = [
custId: 2,
firstNameEn: "Mark",
lastNameEn: "Johnson",
firstNameJp: "マーク",
lastNameJp: "ジョンソン",
firstNameJpKana: "マーク",
lastNameJpKana: "ジョンソン",
email: "mark.johnson@email.com",
mobile: "+1-555-0121",
originAdd1: "789 Pine Road, Los Angeles, CA 90210, USA",
@@ -38,6 +50,10 @@ export const sampleCustomerDependants: CustomerDependant[] = [
custId: 2,
firstNameEn: "Lisa",
lastNameEn: "Johnson",
firstNameJp: "リサ",
lastNameJp: "ジョンソン",
firstNameJpKana: "リサ",
lastNameJpKana: "ジョンソン",
email: "lisa.johnson@email.com",
mobile: "+1-555-0122",
originAdd1: "789 Pine Road, Los Angeles, CA 90210, USA",
@@ -49,6 +65,10 @@ export const sampleCustomerDependants: CustomerDependant[] = [
custId: 3,
firstNameEn: "Anna",
lastNameEn: "Brown",
firstNameJp: "アンナ",
lastNameJp: "ブラウン",
firstNameJpKana: "アンナ",
lastNameJpKana: "ブラウン",
email: "anna.brown@email.com",
mobile: "+44-20-7946-0959",
originAdd1: "42 Victoria Street, London, UK SW1H 0TL",
@@ -60,6 +80,10 @@ export const sampleCustomerDependants: CustomerDependant[] = [
custId: 4,
firstNameEn: "James",
lastNameEn: "Davis",
firstNameJp: "ジェームズ",
lastNameJp: "デイビス",
firstNameJpKana: "ジェームズ",
lastNameJpKana: "デイビス",
email: "james.davis@email.com",
mobile: "+61-2-9876-5433",
originAdd1: "15 Collins Street, Melbourne, VIC 3000, Australia",
@@ -70,6 +94,10 @@ export const sampleCustomerDependants: CustomerDependant[] = [
custId: 4,
firstNameEn: "Sophie",
lastNameEn: "Davis",
firstNameJp: "ソフィー",
lastNameJp: "デイビス",
firstNameJpKana: "ソフィー",
lastNameJpKana: "デイビス",
email: "sophie.davis@email.com",
mobile: "+61-2-9876-5434",
originAdd1: "15 Collins Street, Melbourne, VIC 3000, Australia",
@@ -80,6 +108,10 @@ export const sampleCustomerDependants: CustomerDependant[] = [
custId: 4,
firstNameEn: "Oliver",
lastNameEn: "Davis",
firstNameJp: "オリバー",
lastNameJp: "デイビス",
firstNameJpKana: "オリバー",
lastNameJpKana: "デイビス",
email: "oliver.davis@email.com",
mobile: "+61-2-9876-5435",
originAdd1: "15 Collins Street, Melbourne, VIC 3000, Australia",
@@ -91,6 +123,10 @@ export const sampleCustomerDependants: CustomerDependant[] = [
custId: 5,
firstNameEn: "Rachel",
lastNameEn: "Wilson",
firstNameJp: "レイチェル",
lastNameJp: "ウィルソン",
firstNameJpKana: "レイチェル",
lastNameJpKana: "ウィルソン",
email: "rachel.wilson@email.com",
mobile: "+1-416-555-0191",
originAdd1: "100 Queen Street West, Toronto, ON M5H 2N2, Canada",

View File

@@ -5,6 +5,10 @@ export const sampleCustomers: Customer[] = [
id: 1,
firstNameEn: "John",
lastNameEn: "Smith",
firstNameJp: "ジョン",
lastNameJp: "スミス",
firstNameJpKana: "ジョン",
lastNameJpKana: "スミス",
email: "john.smith@email.com",
mobile: "+1-555-0101",
originAdd1: "123 Main Street, New York, NY 10001, USA",
@@ -14,6 +18,10 @@ export const sampleCustomers: Customer[] = [
id: 2,
firstNameEn: "Sarah",
lastNameEn: "Johnson",
firstNameJp: "サラ",
lastNameJp: "ジョンソン",
firstNameJpKana: "サラ",
lastNameJpKana: "ジョンソン",
email: "sarah.johnson@email.com",
mobile: "+1-555-0102",
originAdd1: "789 Pine Road, Los Angeles, CA 90210, USA",
@@ -23,6 +31,10 @@ export const sampleCustomers: Customer[] = [
id: 3,
firstNameEn: "Michael",
lastNameEn: "Brown",
firstNameJp: "マイケル",
lastNameJp: "ブラウン",
firstNameJpKana: "マイケル",
lastNameJpKana: "ブラウン",
email: "michael.brown@email.com",
mobile: "+44-20-7946-0958",
originAdd1: "42 Victoria Street, London, UK SW1H 0TL",
@@ -32,6 +44,10 @@ export const sampleCustomers: Customer[] = [
id: 4,
firstNameEn: "Emily",
lastNameEn: "Davis",
firstNameJp: "エミリー",
lastNameJp: "デイビス",
firstNameJpKana: "エミリー",
lastNameJpKana: "デイビス",
email: "emily.davis@email.com",
mobile: "+61-2-9876-5432",
originAdd1: "15 Collins Street, Melbourne, VIC 3000, Australia",
@@ -41,6 +57,10 @@ export const sampleCustomers: Customer[] = [
id: 5,
firstNameEn: "David",
lastNameEn: "Wilson",
firstNameJp: "デイビッド",
lastNameJp: "ウィルソン",
firstNameJpKana: "デイビッド",
lastNameJpKana: "ウィルソン",
email: "david.wilson@email.com",
mobile: "+1-416-555-0199",
originAdd1: "100 Queen Street West, Toronto, ON M5H 2N2, Canada",

View File

@@ -3,25 +3,33 @@ import { z } from "zod";
export const customerInfoSchema = z.object({
firstNameEn: z.string().min(1, "First name is required"),
lastNameEn: z.string().min(1, "Last name is required"),
originAdd1: z.string().min(1, "Origin address is required"),
localAdd1: z.string().min(1, "Local address is required"),
firstNameJp: z.string().min(1, "First name in Japanese is required"),
lastNameJp: z.string().min(1, "Last name in Japanese is required"),
firstNameJpKana: z.string().min(1, "First name in Japanese Kana is required"),
lastNameJpKana: z.string().min(1, "Last name in Japanese Kana is required"),
});
export const customerContactSchema = z.object({
email: z.string().email("Invalid email address"),
mobile: z.string().min(1, "Mobile number is required"),
originAdd1: z.string().min(1, "Origin address is required"),
localAdd1: z.string().min(1, "Local address is required"),
});
export const customerDependantInfoSchema = z.object({
firstNameEn: z.string().min(1, "First name is required"),
lastNameEn: z.string().min(1, "Last name is required"),
originAdd1: z.string().min(1, "Origin address is required"),
localAdd1: z.string().min(1, "Local address is required"),
firstNameJp: z.string().min(1, "First name in Japanese is required"),
lastNameJp: z.string().min(1, "Last name in Japanese is required"),
firstNameJpKana: z.string().min(1, "First name in Japanese Kana is required"),
lastNameJpKana: z.string().min(1, "Last name in Japanese Kana is required"),
});
export const customerDependantContactSchema = z.object({
email: z.string().email("Invalid email address"),
mobile: z.string().min(1, "Mobile number is required"),
originAdd1: z.string().min(1, "Origin address is required"),
localAdd1: z.string().min(1, "Local address is required"),
});
export const customerDependantFormSchema = z.object({