thai-uxui

This commit is contained in:
phaichayon
2026-06-19 11:11:17 +07:00
parent c0cc880be2
commit 721653f692
47 changed files with 1135 additions and 538 deletions

View File

@@ -90,21 +90,21 @@ export function EnquiryFormSheet({
const createMutation = useMutation({
...createEnquiryMutation,
onSuccess: () => {
toast.success(`${recordLabel} created successfully`);
toast.success(`สร้าง${recordLabel}สำเร็จ`);
onOpenChange(false);
},
onError: (error) =>
toast.error(error instanceof Error ? error.message : `Failed to create ${recordLabel.toLowerCase()}`)
toast.error(error instanceof Error ? error.message : `ไม่สามารถสร้าง${recordLabel}ได้`)
});
const updateMutation = useMutation({
...updateEnquiryMutation,
onSuccess: () => {
toast.success(`${recordLabel} updated successfully`);
toast.success(`อัปเดต${recordLabel}สำเร็จ`);
onOpenChange(false);
},
onError: (error) =>
toast.error(error instanceof Error ? error.message : `Failed to update ${recordLabel.toLowerCase()}`)
toast.error(error instanceof Error ? error.message : `ไม่สามารถอัปเดต${recordLabel}ได้`)
});
const contactsForCustomer = referenceData.contacts.filter(
@@ -179,17 +179,17 @@ export function EnquiryFormSheet({
const isPending = createMutation.isPending || updateMutation.isPending;
const recordLabel = workspace === 'lead' ? 'Lead' : 'Enquiry';
const recordLabel = workspace === 'lead' ? 'ลีด' : 'โอกาสขาย';
return (
<Sheet open={open} onOpenChange={onOpenChange}>
<SheetContent className='flex flex-col sm:max-w-4xl'>
<SheetHeader>
<SheetTitle>{isEdit ? `Edit ${recordLabel}` : `New ${recordLabel}`}</SheetTitle>
<SheetTitle>{isEdit ? `แก้ไข${recordLabel}` : `เพิ่ม${recordLabel}`}</SheetTitle>
<SheetDescription>
{workspace === 'lead'
? 'Capture marketing lead details before assignment to sales.'
: 'Capture sales enquiry details before quotation work begins.'}
? 'บันทึกข้อมูลลีดของฝ่ายการตลาดก่อนส่งต่อให้ฝ่ายขาย'
: 'บันทึกข้อมูลโอกาสขายของฝ่ายขายก่อนเริ่มทำใบเสนอราคา'}
</SheetDescription>
</SheetHeader>
@@ -201,7 +201,7 @@ export function EnquiryFormSheet({
children={(field) => (
<field.FieldSet>
<field.Field>
<field.FieldLabel>Billing Customer *</field.FieldLabel>
<field.FieldLabel> *</field.FieldLabel>
<Select
value={field.state.value ?? ''}
onValueChange={(value) => {
@@ -211,8 +211,8 @@ export function EnquiryFormSheet({
form.setFieldValue('contactId', '');
}}
>
<SelectTrigger aria-label='Customer'>
<SelectValue placeholder='Select customer' />
<SelectTrigger aria-label='ลูกค้า'>
<SelectValue placeholder='เลือกลูกค้า' />
</SelectTrigger>
<SelectContent>
{referenceData.customers.map((customer) => (
@@ -233,7 +233,7 @@ export function EnquiryFormSheet({
children={(field) => (
<field.FieldSet>
<field.Field>
<field.FieldLabel>Contact</field.FieldLabel>
<field.FieldLabel></field.FieldLabel>
<Select
value={field.state.value ?? ''}
onValueChange={(value) => {
@@ -241,19 +241,19 @@ export function EnquiryFormSheet({
field.handleBlur();
}}
>
<SelectTrigger aria-label='Contact'>
<SelectValue placeholder='Select contact' />
<SelectTrigger aria-label='ผู้ติดต่อ'>
<SelectValue placeholder='เลือกผู้ติดต่อ' />
</SelectTrigger>
<SelectContent>
{contactsForCustomer.length ? (
contactsForCustomer.map((contact) => (
<SelectItem key={contact.id} value={contact.id}>
{contact.name}
{contact.isPrimary ? ' (Primary)' : ''}
{contact.isPrimary ? ' (ผู้ติดต่อหลัก)' : ''}
</SelectItem>
))
) : (
<SelectItem value='__none__'>No contact selected</SelectItem>
<SelectItem value='__none__'></SelectItem>
)}
</SelectContent>
</Select>
@@ -265,28 +265,28 @@ export function EnquiryFormSheet({
<FormTextField
name='title'
label='Title'
label='ชื่อรายการ'
required
placeholder='Warehouse crane upgrade enquiry'
/>
<FormTextField
name='projectName'
label='Project Name'
label='ชื่อโครงการ'
placeholder='Bangna Warehouse Expansion'
/>
<FormTextField
name='projectLocation'
label='Project Location'
label='สถานที่โครงการ'
placeholder='Bangkok'
/>
<FormTextField
name='source'
label='Source'
label='ที่มา'
placeholder='Existing customer referral'
/>
<FormSelectField
name='branchId'
label='Branch'
label='สาขา'
options={referenceData.branches.map((branch) => ({
value: branch.id,
label: branch.name
@@ -294,7 +294,7 @@ export function EnquiryFormSheet({
/>
<FormSelectField
name='productType'
label='Product Type'
label='ประเภทสินค้า'
required
options={referenceData.productTypes.map((item) => ({
value: item.id,
@@ -303,7 +303,7 @@ export function EnquiryFormSheet({
/>
<FormSelectField
name='status'
label='Status'
label='สถานะ'
required
options={referenceData.statuses.map((item) => ({
value: item.id,
@@ -312,7 +312,7 @@ export function EnquiryFormSheet({
/>
<FormSelectField
name='priority'
label='Priority'
label='ความสำคัญ'
required
options={referenceData.priorities.map((item) => ({
value: item.id,
@@ -321,7 +321,7 @@ export function EnquiryFormSheet({
/>
<FormSelectField
name='leadChannel'
label='Lead Channel'
label='ที่มาของลีด'
options={referenceData.leadChannels.map((item) => ({
value: item.id,
label: item.label
@@ -329,48 +329,48 @@ export function EnquiryFormSheet({
/>
<FormTextField
name='estimatedValue'
label='Estimated Value'
label='มูลค่าประมาณการ'
type='number'
placeholder='2500000'
/>
<FormTextField name='chancePercent' label='Chance %' type='number' placeholder='60' />
<FormTextField name='chancePercent' label='โอกาสปิดการขาย %' type='number' placeholder='60' />
<FormTextField
name='expectedCloseDate'
label='Expected Close Date'
label='วันที่คาดว่าจะปิดการขาย'
placeholder='YYYY-MM-DD'
/>
<FormTextField name='competitor' label='Competitor' placeholder='Other vendor name' />
<FormTextField name='competitor' label='คู่แข่ง' placeholder='Other vendor name' />
<div className='md:col-span-2'>
<FormTextareaField
name='description'
label='Description'
placeholder='High-level summary of the lead or enquiry'
label='รายละเอียด'
placeholder='สรุปภาพรวมของลีดหรือโอกาสขาย'
/>
</div>
<div className='md:col-span-2'>
<FormTextareaField
name='requirement'
label='Requirement'
placeholder='Specific technical or commercial requirements'
label='ความต้องการ'
placeholder='ความต้องการเชิงเทคนิคหรือเชิงพาณิชย์'
/>
</div>
<div className='md:col-span-2'>
<FormTextareaField
name='notes'
label='Notes'
placeholder='Internal notes, blockers, or handoff guidance'
label='หมายเหตุ'
placeholder='หมายเหตุภายใน อุปสรรค หรือข้อมูลประกอบการส่งต่องาน'
/>
</div>
<div className='md:col-span-2 grid gap-4 md:grid-cols-2'>
<FormSwitchField
name='isHotProject'
label='Hot Project'
description='Use for urgent or highly strategic enquiries.'
label='โครงการด่วน'
description='ใช้สำหรับงานเร่งด่วนหรือโครงการสำคัญเชิงกลยุทธ์'
/>
<FormSwitchField
name='isActive'
label='Active Record'
description='Inactive leads and enquiries stay in history but should not progress further.'
label='ใช้งานอยู่'
description='รายการที่ปิดใช้งานจะยังอยู่ในประวัติ แต่ไม่ควรถูกดำเนินการต่อ'
/>
</div>
<div className='md:col-span-2'>
@@ -387,11 +387,11 @@ export function EnquiryFormSheet({
<SheetFooter>
<Button type='button' variant='outline' onClick={() => onOpenChange(false)}>
Cancel
</Button>
<Button type='submit' form='enquiry-form-sheet' isLoading={isPending}>
<Icons.check className='mr-2 h-4 w-4' />
{isEdit ? `Update ${recordLabel}` : `Create ${recordLabel}`}
{isEdit ? `อัปเดต${recordLabel}` : `สร้าง${recordLabel}`}
</Button>
</SheetFooter>
</SheetContent>
@@ -411,7 +411,7 @@ export function EnquiryFormSheetTrigger({
return (
<>
<Button onClick={() => setOpen(true)}>
<Icons.add className='mr-2 h-4 w-4' /> {workspace === 'lead' ? 'Add Lead' : 'Add Enquiry'}
<Icons.add className='mr-2 h-4 w-4' /> {workspace === 'lead' ? 'เพิ่มลีด' : 'เพิ่มโอกาสขาย'}
</Button>
<EnquiryFormSheet
open={open}