task-fixdatetime
This commit is contained in:
@@ -5,6 +5,7 @@ import type { Column, ColumnDef } from '@tanstack/react-table';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
import { DataTableColumnHeader } from '@/components/ui/table/data-table-column-header';
|
||||
import { Icons } from '@/components/icons';
|
||||
import { formatNumber } from '@/lib/number-format';
|
||||
import type { QuotationListItem, QuotationReferenceData } from '../api/types';
|
||||
import { QuotationCellAction } from './quotation-cell-action';
|
||||
import { QuotationStatusBadge } from './quotation-status-badge';
|
||||
@@ -31,7 +32,10 @@ export function getQuotationColumns({
|
||||
),
|
||||
cell: ({ row }) => (
|
||||
<div className='flex flex-col'>
|
||||
<Link href={`/dashboard/crm/quotations/${row.original.id}`} className='font-medium hover:underline'>
|
||||
<Link
|
||||
href={`/dashboard/crm/quotations/${row.original.id}`}
|
||||
className='font-medium hover:underline'
|
||||
>
|
||||
{row.original.code}
|
||||
</Link>
|
||||
<span className='text-muted-foreground text-xs'>
|
||||
@@ -90,7 +94,11 @@ export function getQuotationColumns({
|
||||
<DataTableColumnHeader column={column} title='สาขา' />
|
||||
),
|
||||
cell: ({ row }) => (
|
||||
<span>{row.original.branchId ? (branchMap.get(row.original.branchId)?.name ?? 'Unknown') : 'Unassigned'}</span>
|
||||
<span>
|
||||
{row.original.branchId
|
||||
? (branchMap.get(row.original.branchId)?.name ?? 'Unknown')
|
||||
: 'Unassigned'}
|
||||
</span>
|
||||
),
|
||||
meta: {
|
||||
label: 'สาขา',
|
||||
@@ -123,7 +131,10 @@ export function getQuotationColumns({
|
||||
meta: {
|
||||
label: 'โอกาสขาย',
|
||||
variant: 'multiSelect' as const,
|
||||
options: referenceData.opportunities.map((item) => ({ value: item.id, label: `${item.code} - ${item.title}` }))
|
||||
options: referenceData.opportunities.map((item) => ({
|
||||
value: item.id,
|
||||
label: `${item.code} - ${item.title}`
|
||||
}))
|
||||
},
|
||||
enableColumnFilter: true
|
||||
},
|
||||
@@ -150,7 +161,7 @@ export function getQuotationColumns({
|
||||
header: ({ column }: { column: Column<QuotationListItem, unknown> }) => (
|
||||
<DataTableColumnHeader column={column} title='มูลค่ารวม' />
|
||||
),
|
||||
cell: ({ row }) => row.original.totalAmount.toLocaleString()
|
||||
cell: ({ row }) => formatNumber(row.original.totalAmount)
|
||||
},
|
||||
{
|
||||
id: 'actions',
|
||||
@@ -165,4 +176,3 @@ export function getQuotationColumns({
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -4,6 +4,8 @@ import { useSuspenseQuery } from '@tanstack/react-query';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
|
||||
import { Separator } from '@/components/ui/separator';
|
||||
import { formatDate, formatDateTime } from '@/lib/date-format';
|
||||
import { formatNumber } from '@/lib/number-format';
|
||||
import { quotationDocumentPreviewOptions } from '@/features/crm/quotations/document/queries';
|
||||
|
||||
function Field({ label, value }: { label: string; value: string | null | undefined }) {
|
||||
@@ -58,13 +60,13 @@ export function QuotationDocumentPreview({ quotationId }: { quotationId: string
|
||||
<Field label='Revision' value={documentData.quotation.revisionLabel} />
|
||||
<Field
|
||||
label='วันที่ออกใบเสนอราคา'
|
||||
value={new Date(documentData.quotation.quotationDate).toLocaleDateString()}
|
||||
value={formatDate(documentData.quotation.quotationDate)}
|
||||
/>
|
||||
<Field
|
||||
label='ใช้ได้ถึง'
|
||||
value={
|
||||
documentData.quotation.validUntil
|
||||
? new Date(documentData.quotation.validUntil).toLocaleDateString()
|
||||
? formatDate(documentData.quotation.validUntil)
|
||||
: null
|
||||
}
|
||||
/>
|
||||
@@ -131,8 +133,8 @@ export function QuotationDocumentPreview({ quotationId }: { quotationId: string
|
||||
</div>
|
||||
<div>{item.quantity}</div>
|
||||
<div>{item.unitLabel || '-'}</div>
|
||||
<div>{item.unitPrice.toLocaleString()}</div>
|
||||
<div>{item.totalPrice.toLocaleString()}</div>
|
||||
<div>{formatNumber(item.unitPrice)}</div>
|
||||
<div>{formatNumber(item.totalPrice)}</div>
|
||||
</div>
|
||||
))}
|
||||
</CardContent>
|
||||
@@ -183,16 +185,16 @@ export function QuotationDocumentPreview({ quotationId }: { quotationId: string
|
||||
<CardContent className='space-y-3 text-sm'>
|
||||
<div className='flex items-center justify-between'>
|
||||
<span className='text-muted-foreground'>ก่อนภาษี</span>
|
||||
<span>{documentData.quotation.subtotal.toLocaleString()}</span>
|
||||
<span>{formatNumber(documentData.quotation.subtotal)}</span>
|
||||
</div>
|
||||
<div className='flex items-center justify-between'>
|
||||
<span className='text-muted-foreground'>ภาษี</span>
|
||||
<span>{documentData.quotation.taxAmount.toLocaleString()}</span>
|
||||
<span>{formatNumber(documentData.quotation.taxAmount)}</span>
|
||||
</div>
|
||||
<div className='flex items-center justify-between'>
|
||||
<span className='text-muted-foreground'>รวมทั้งสิ้น</span>
|
||||
<span className='font-semibold'>
|
||||
{documentData.quotation.totalAmount.toLocaleString()}
|
||||
{formatNumber(documentData.quotation.totalAmount)}
|
||||
</span>
|
||||
</div>
|
||||
</CardContent>
|
||||
@@ -221,7 +223,7 @@ export function QuotationDocumentPreview({ quotationId }: { quotationId: string
|
||||
</div>
|
||||
<div className='text-muted-foreground'>
|
||||
{item.actorName || '-'}{' '}
|
||||
{item.actedAt ? `เมื่อ ${new Date(item.actedAt).toLocaleString()}` : ''}
|
||||
{item.actedAt ? `เมื่อ ${formatDateTime(item.actedAt)}` : ''}
|
||||
</div>
|
||||
</div>
|
||||
))
|
||||
|
||||
@@ -30,20 +30,7 @@ export function formatPdfDate(
|
||||
return '-';
|
||||
}
|
||||
|
||||
if (language === 'th') {
|
||||
return date.toLocaleDateString('th-TH', {
|
||||
day: 'numeric',
|
||||
month: 'short',
|
||||
year: 'numeric',
|
||||
calendar: 'buddhist'
|
||||
});
|
||||
}
|
||||
|
||||
return date.toLocaleDateString('en-US', {
|
||||
day: 'numeric',
|
||||
month: 'short',
|
||||
year: 'numeric'
|
||||
});
|
||||
return formatDate(date);
|
||||
}
|
||||
|
||||
export function formatPdfCurrency(
|
||||
@@ -191,3 +178,4 @@ export function normalizePdfmeTable(
|
||||
|
||||
return rows.length ? rows : EMPTY_TABLE_FALLBACK;
|
||||
}
|
||||
import { formatDate } from '@/lib/date-format';
|
||||
|
||||
Reference in New Issue
Block a user