Sales Order List table
This commit is contained in:
parent
ce9f845fe4
commit
8ec6ba62f3
@ -0,0 +1,7 @@
|
|||||||
|
import SalesOrderList from '@/views/apps/sales/sales-orders/list'
|
||||||
|
|
||||||
|
const SalesOrdersPage = () => {
|
||||||
|
return <SalesOrderList />
|
||||||
|
}
|
||||||
|
|
||||||
|
export default SalesOrdersPage
|
||||||
@ -95,6 +95,7 @@ const VerticalMenu = ({ dictionary, scrollMenu }: Props) => {
|
|||||||
<MenuItem href={`/${locale}/apps/sales/overview`}>{dictionary['navigation'].overview}</MenuItem>
|
<MenuItem href={`/${locale}/apps/sales/overview`}>{dictionary['navigation'].overview}</MenuItem>
|
||||||
<MenuItem href={`/${locale}/apps/sales/sales-bills`}>{dictionary['navigation'].invoices}</MenuItem>
|
<MenuItem href={`/${locale}/apps/sales/sales-bills`}>{dictionary['navigation'].invoices}</MenuItem>
|
||||||
<MenuItem href={`/${locale}/apps/sales/sales-deliveries`}>{dictionary['navigation'].deliveries}</MenuItem>
|
<MenuItem href={`/${locale}/apps/sales/sales-deliveries`}>{dictionary['navigation'].deliveries}</MenuItem>
|
||||||
|
<MenuItem href={`/${locale}/apps/sales/sales-orders`}>{dictionary['navigation'].sales_orders}</MenuItem>
|
||||||
{/* <MenuItem href={`/${locale}/apps/user/view`}>{dictionary['navigation'].view}</MenuItem> */}
|
{/* <MenuItem href={`/${locale}/apps/user/view`}>{dictionary['navigation'].view}</MenuItem> */}
|
||||||
</SubMenu>
|
</SubMenu>
|
||||||
<SubMenu label={dictionary['navigation'].purchase_text} icon={<i className='tabler-user' />}>
|
<SubMenu label={dictionary['navigation'].purchase_text} icon={<i className='tabler-user' />}>
|
||||||
|
|||||||
@ -120,6 +120,7 @@
|
|||||||
"purchase_delivery": "Purchase Delivery",
|
"purchase_delivery": "Purchase Delivery",
|
||||||
"purchase_quotes": "Purchase Quotes",
|
"purchase_quotes": "Purchase Quotes",
|
||||||
"invoices": "Invoices",
|
"invoices": "Invoices",
|
||||||
"deliveries": "Deliveries"
|
"deliveries": "Deliveries",
|
||||||
|
"sales_orders": "Orders"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -120,6 +120,7 @@
|
|||||||
"purchase_delivery": "Pengiriman Pembelian",
|
"purchase_delivery": "Pengiriman Pembelian",
|
||||||
"purchase_quotes": "Penawaran Pembelian",
|
"purchase_quotes": "Penawaran Pembelian",
|
||||||
"invoices": "Tagihan",
|
"invoices": "Tagihan",
|
||||||
"deliveries": "Pengiriman"
|
"deliveries": "Pengiriman",
|
||||||
|
"sales_orders": "Pemesanan"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { SalesBillType, SalesDeliveryType } from '@/types/apps/salesTypes'
|
import { SalesBillType, SalesDeliveryType, SalesOrderType } from '@/types/apps/salesTypes'
|
||||||
|
|
||||||
export const salesBillData: SalesBillType[] = [
|
export const salesBillData: SalesBillType[] = [
|
||||||
{
|
{
|
||||||
@ -425,3 +425,226 @@ export const salesDeliveryData: SalesDeliveryType[] = [
|
|||||||
status: 'Selesai'
|
status: 'Selesai'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
export const salesOrdersData: SalesOrderType[] = [
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
number: 'PO/00040',
|
||||||
|
vendorName: 'Kairav Wijaya Nababan',
|
||||||
|
vendorCompany: 'Yayasan Haryanto Tbk',
|
||||||
|
reference: '',
|
||||||
|
date: '05/09/2025',
|
||||||
|
dueDate: '19/09/2025',
|
||||||
|
status: 'Disetujui',
|
||||||
|
total: 2037170
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 2,
|
||||||
|
number: 'PO/00041',
|
||||||
|
vendorName: 'Sari Melani Hutapea',
|
||||||
|
vendorCompany: 'PT Santoso Jaya',
|
||||||
|
reference: 'REF-2025-001',
|
||||||
|
date: '03/09/2025',
|
||||||
|
dueDate: '17/09/2025',
|
||||||
|
status: 'Draft',
|
||||||
|
total: 1875500
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 3,
|
||||||
|
number: 'PO/00042',
|
||||||
|
vendorName: 'Budi Prasetyo Manullang',
|
||||||
|
vendorCompany: 'CV Wijaya Makmur',
|
||||||
|
reference: 'REF-2025-002',
|
||||||
|
date: '07/09/2025',
|
||||||
|
dueDate: '21/09/2025',
|
||||||
|
status: 'Dikirim Sebagian',
|
||||||
|
total: 3250750
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 4,
|
||||||
|
number: 'PO/00043',
|
||||||
|
vendorName: 'Maya Sari Lumban Gaol',
|
||||||
|
vendorCompany: 'PT Indah Permata',
|
||||||
|
reference: '',
|
||||||
|
date: '02/09/2025',
|
||||||
|
dueDate: '16/09/2025',
|
||||||
|
status: 'Selesai',
|
||||||
|
total: 980250
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 5,
|
||||||
|
number: 'PO/00044',
|
||||||
|
vendorName: 'Rahman Hakim Siahaan',
|
||||||
|
vendorCompany: 'Toko Bahagia Sejahtera',
|
||||||
|
reference: 'REF-2025-003',
|
||||||
|
date: '08/09/2025',
|
||||||
|
dueDate: '22/09/2025',
|
||||||
|
status: 'Draft',
|
||||||
|
total: 4125890
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 6,
|
||||||
|
number: 'PO/00045',
|
||||||
|
vendorName: 'Dewi Anggraini Panjaitan',
|
||||||
|
vendorCompany: 'PT Maju Bersama',
|
||||||
|
reference: 'REF-2025-004',
|
||||||
|
date: '01/09/2025',
|
||||||
|
dueDate: '15/09/2025',
|
||||||
|
status: 'Selesai',
|
||||||
|
total: 2678300
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 7,
|
||||||
|
number: 'PO/00046',
|
||||||
|
vendorName: 'Agung Wijaya Simbolon',
|
||||||
|
vendorCompany: 'CV Karya Mandiri',
|
||||||
|
reference: '',
|
||||||
|
date: '06/09/2025',
|
||||||
|
dueDate: '20/09/2025',
|
||||||
|
status: 'Disetujui',
|
||||||
|
total: 1456780
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 8,
|
||||||
|
number: 'PO/00047',
|
||||||
|
vendorName: 'Fitri Handayani Sitorus',
|
||||||
|
vendorCompany: 'PT Global Nusantara',
|
||||||
|
reference: 'REF-2025-005',
|
||||||
|
date: '04/09/2025',
|
||||||
|
dueDate: '18/09/2025',
|
||||||
|
status: 'Dikirim Sebagian',
|
||||||
|
total: 5892450
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 9,
|
||||||
|
number: 'PO/00048',
|
||||||
|
vendorName: 'Andi Setiawan Tampubolon',
|
||||||
|
vendorCompany: 'Yayasan Pembangunan Tbk',
|
||||||
|
reference: 'REF-2025-006',
|
||||||
|
date: '09/09/2025',
|
||||||
|
dueDate: '23/09/2025',
|
||||||
|
status: 'Draft',
|
||||||
|
total: 3567120
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 10,
|
||||||
|
number: 'PO/00049',
|
||||||
|
vendorName: 'Rina Maharani Hutasoit',
|
||||||
|
vendorCompany: 'PT Sejahtera Abadi',
|
||||||
|
reference: '',
|
||||||
|
date: '05/09/2025',
|
||||||
|
dueDate: '19/09/2025',
|
||||||
|
status: 'Disetujui',
|
||||||
|
total: 2234680
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 11,
|
||||||
|
number: 'PO/00050',
|
||||||
|
vendorName: 'Joko Santoso Nainggolan',
|
||||||
|
vendorCompany: 'CV Berkah Jaya',
|
||||||
|
reference: 'REF-2025-007',
|
||||||
|
date: '03/09/2025',
|
||||||
|
dueDate: '17/09/2025',
|
||||||
|
status: 'Selesai',
|
||||||
|
total: 1789560
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 12,
|
||||||
|
number: 'PO/00051',
|
||||||
|
vendorName: 'Linda Safitri Simanjuntak',
|
||||||
|
vendorCompany: 'PT Harapan Bangsa',
|
||||||
|
reference: 'REF-2025-008',
|
||||||
|
date: '07/09/2025',
|
||||||
|
dueDate: '21/09/2025',
|
||||||
|
status: 'Dikirim Sebagian',
|
||||||
|
total: 4321870
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 13,
|
||||||
|
number: 'PO/00052',
|
||||||
|
vendorName: 'Irfan Maulana Pasaribu',
|
||||||
|
vendorCompany: 'CV Sumber Rejeki',
|
||||||
|
reference: 'REF-2025-009',
|
||||||
|
date: '10/09/2025',
|
||||||
|
dueDate: '24/09/2025',
|
||||||
|
status: 'Draft',
|
||||||
|
total: 2567890
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 14,
|
||||||
|
number: 'PO/00053',
|
||||||
|
vendorName: 'Siska Permata Sinaga',
|
||||||
|
vendorCompany: 'PT Mitra Sukses',
|
||||||
|
reference: '',
|
||||||
|
date: '11/09/2025',
|
||||||
|
dueDate: '25/09/2025',
|
||||||
|
status: 'Disetujui',
|
||||||
|
total: 3456780
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 15,
|
||||||
|
number: 'PO/00054',
|
||||||
|
vendorName: 'Rizky Aditya Siregar',
|
||||||
|
vendorCompany: 'Toko Aman Sentosa',
|
||||||
|
reference: 'REF-2025-010',
|
||||||
|
date: '08/09/2025',
|
||||||
|
dueDate: '22/09/2025',
|
||||||
|
status: 'Selesai',
|
||||||
|
total: 1234567
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 16,
|
||||||
|
number: 'PO/00055',
|
||||||
|
vendorName: 'Nina Sari Hutabarat',
|
||||||
|
vendorCompany: 'PT Cahaya Terang',
|
||||||
|
reference: 'REF-2025-011',
|
||||||
|
date: '12/09/2025',
|
||||||
|
dueDate: '26/09/2025',
|
||||||
|
status: 'Dikirim Sebagian',
|
||||||
|
total: 5678900
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 17,
|
||||||
|
number: 'PO/00056',
|
||||||
|
vendorName: 'Doni Prasetya Situmorang',
|
||||||
|
vendorCompany: 'CV Barokah Makmur',
|
||||||
|
reference: '',
|
||||||
|
date: '09/09/2025',
|
||||||
|
dueDate: '23/09/2025',
|
||||||
|
status: 'Draft',
|
||||||
|
total: 987654
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 18,
|
||||||
|
number: 'PO/00057',
|
||||||
|
vendorName: 'Anita Dewi Marpaung',
|
||||||
|
vendorCompany: 'Yayasan Karya Bhakti',
|
||||||
|
reference: 'REF-2025-012',
|
||||||
|
date: '06/09/2025',
|
||||||
|
dueDate: '20/09/2025',
|
||||||
|
status: 'Disetujui',
|
||||||
|
total: 4567123
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 19,
|
||||||
|
number: 'PO/00058',
|
||||||
|
vendorName: 'Tommy Wijaya Samosir',
|
||||||
|
vendorCompany: 'PT Bintang Timur',
|
||||||
|
reference: 'REF-2025-013',
|
||||||
|
date: '13/09/2025',
|
||||||
|
dueDate: '27/09/2025',
|
||||||
|
status: 'Selesai',
|
||||||
|
total: 2345678
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 20,
|
||||||
|
number: 'PO/00059',
|
||||||
|
vendorName: 'Lestari Indah Pakpahan',
|
||||||
|
vendorCompany: 'CV Harmoni Jaya',
|
||||||
|
reference: '',
|
||||||
|
date: '05/09/2025',
|
||||||
|
dueDate: '19/09/2025',
|
||||||
|
status: 'Dikirim Sebagian',
|
||||||
|
total: 3789012
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|||||||
@ -20,3 +20,15 @@ export type SalesDeliveryType = {
|
|||||||
date: string
|
date: string
|
||||||
status: string
|
status: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type SalesOrderType = {
|
||||||
|
id: number
|
||||||
|
number: string
|
||||||
|
vendorName: string
|
||||||
|
vendorCompany: string
|
||||||
|
reference: string
|
||||||
|
date: string
|
||||||
|
dueDate: string
|
||||||
|
status: string
|
||||||
|
total: number
|
||||||
|
}
|
||||||
|
|||||||
@ -231,7 +231,7 @@ const SalesDeliveryListTable = () => {
|
|||||||
)
|
)
|
||||||
}),
|
}),
|
||||||
columnHelper.accessor('vendorName', {
|
columnHelper.accessor('vendorName', {
|
||||||
header: 'Vendor',
|
header: 'Pelanggan',
|
||||||
cell: ({ row }) => (
|
cell: ({ row }) => (
|
||||||
<div className='flex flex-col'>
|
<div className='flex flex-col'>
|
||||||
<Typography color='text.primary' className='font-medium'>
|
<Typography color='text.primary' className='font-medium'>
|
||||||
|
|||||||
454
src/views/apps/sales/sales-orders/list/SalesOrderListTable.tsx
Normal file
454
src/views/apps/sales/sales-orders/list/SalesOrderListTable.tsx
Normal file
@ -0,0 +1,454 @@
|
|||||||
|
'use client'
|
||||||
|
|
||||||
|
// React Imports
|
||||||
|
import { useCallback, useEffect, useMemo, useState } from 'react'
|
||||||
|
|
||||||
|
// Next Imports
|
||||||
|
import Link from 'next/link'
|
||||||
|
import { useParams } from 'next/navigation'
|
||||||
|
|
||||||
|
// MUI Imports
|
||||||
|
import Button from '@mui/material/Button'
|
||||||
|
import Card from '@mui/material/Card'
|
||||||
|
import CardHeader from '@mui/material/CardHeader'
|
||||||
|
import Checkbox from '@mui/material/Checkbox'
|
||||||
|
import Chip from '@mui/material/Chip'
|
||||||
|
import IconButton from '@mui/material/IconButton'
|
||||||
|
import MenuItem from '@mui/material/MenuItem'
|
||||||
|
import { styled } from '@mui/material/styles'
|
||||||
|
import type { TextFieldProps } from '@mui/material/TextField'
|
||||||
|
import Typography from '@mui/material/Typography'
|
||||||
|
|
||||||
|
// Third-party Imports
|
||||||
|
import type { RankingInfo } from '@tanstack/match-sorter-utils'
|
||||||
|
import { rankItem } from '@tanstack/match-sorter-utils'
|
||||||
|
import type { ColumnDef, FilterFn } from '@tanstack/react-table'
|
||||||
|
import { createColumnHelper, flexRender, getCoreRowModel, useReactTable } from '@tanstack/react-table'
|
||||||
|
import classnames from 'classnames'
|
||||||
|
|
||||||
|
// Type Imports
|
||||||
|
import type { Locale } from '@configs/i18n'
|
||||||
|
|
||||||
|
// Component Imports
|
||||||
|
import CustomTextField from '@core/components/mui/TextField'
|
||||||
|
import OptionMenu from '@core/components/option-menu'
|
||||||
|
|
||||||
|
// Style Imports
|
||||||
|
import tableStyles from '@core/styles/table.module.css'
|
||||||
|
import { Box, CircularProgress, TablePagination } from '@mui/material'
|
||||||
|
import { useDispatch } from 'react-redux'
|
||||||
|
import TablePaginationComponent from '@/components/TablePaginationComponent'
|
||||||
|
import Loading from '@/components/layout/shared/Loading'
|
||||||
|
import { getLocalizedUrl } from '@/utils/i18n'
|
||||||
|
import { salesOrdersData } from '@/data/dummy/sales'
|
||||||
|
import { SalesOrderType } from '@/types/apps/salesTypes'
|
||||||
|
|
||||||
|
declare module '@tanstack/table-core' {
|
||||||
|
interface FilterFns {
|
||||||
|
fuzzy: FilterFn<unknown>
|
||||||
|
}
|
||||||
|
interface FilterMeta {
|
||||||
|
itemRank: RankingInfo
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type SalesOrderTypeWithAction = SalesOrderType & {
|
||||||
|
actions?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
// Styled Components
|
||||||
|
const Icon = styled('i')({})
|
||||||
|
|
||||||
|
const fuzzyFilter: FilterFn<any> = (row, columnId, value, addMeta) => {
|
||||||
|
// Rank the item
|
||||||
|
const itemRank = rankItem(row.getValue(columnId), value)
|
||||||
|
|
||||||
|
// Store the itemRank info
|
||||||
|
addMeta({
|
||||||
|
itemRank
|
||||||
|
})
|
||||||
|
|
||||||
|
// Return if the item should be filtered in/out
|
||||||
|
return itemRank.passed
|
||||||
|
}
|
||||||
|
|
||||||
|
const DebouncedInput = ({
|
||||||
|
value: initialValue,
|
||||||
|
onChange,
|
||||||
|
debounce = 500,
|
||||||
|
...props
|
||||||
|
}: {
|
||||||
|
value: string | number
|
||||||
|
onChange: (value: string | number) => void
|
||||||
|
debounce?: number
|
||||||
|
} & Omit<TextFieldProps, 'onChange'>) => {
|
||||||
|
// States
|
||||||
|
const [value, setValue] = useState(initialValue)
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setValue(initialValue)
|
||||||
|
}, [initialValue])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const timeout = setTimeout(() => {
|
||||||
|
onChange(value)
|
||||||
|
}, debounce)
|
||||||
|
|
||||||
|
return () => clearTimeout(timeout)
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [value])
|
||||||
|
|
||||||
|
return <CustomTextField {...props} value={value} onChange={e => setValue(e.target.value)} />
|
||||||
|
}
|
||||||
|
|
||||||
|
// Status color mapping
|
||||||
|
const getStatusColor = (status: string) => {
|
||||||
|
switch (status) {
|
||||||
|
case 'Draft':
|
||||||
|
return 'secondary'
|
||||||
|
case 'Disetujui':
|
||||||
|
return 'primary'
|
||||||
|
case 'Dikirim Sebagian':
|
||||||
|
return 'warning'
|
||||||
|
case 'Selesai':
|
||||||
|
return 'success'
|
||||||
|
default:
|
||||||
|
return 'default'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Format currency
|
||||||
|
const formatCurrency = (amount: number) => {
|
||||||
|
return new Intl.NumberFormat('id-ID', {
|
||||||
|
style: 'currency',
|
||||||
|
currency: 'IDR',
|
||||||
|
minimumFractionDigits: 0
|
||||||
|
}).format(amount)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Column Definitions
|
||||||
|
const columnHelper = createColumnHelper<SalesOrderTypeWithAction>()
|
||||||
|
|
||||||
|
const SalesOrderListTable = () => {
|
||||||
|
const dispatch = useDispatch()
|
||||||
|
|
||||||
|
// States
|
||||||
|
const [addPOOpen, setAddPOOpen] = useState(false)
|
||||||
|
const [rowSelection, setRowSelection] = useState({})
|
||||||
|
const [currentPage, setCurrentPage] = useState(0)
|
||||||
|
const [pageSize, setPageSize] = useState(10)
|
||||||
|
const [openConfirm, setOpenConfirm] = useState(false)
|
||||||
|
const [poId, setPOId] = useState('')
|
||||||
|
const [search, setSearch] = useState('')
|
||||||
|
const [statusFilter, setStatusFilter] = useState<string>('Semua')
|
||||||
|
const [filteredData, setFilteredData] = useState<SalesOrderType[]>(salesOrdersData)
|
||||||
|
|
||||||
|
// Hooks
|
||||||
|
const { lang: locale } = useParams()
|
||||||
|
|
||||||
|
// Filter data based on search and status
|
||||||
|
useEffect(() => {
|
||||||
|
let filtered = salesOrdersData
|
||||||
|
|
||||||
|
// Filter by search
|
||||||
|
if (search) {
|
||||||
|
filtered = filtered.filter(
|
||||||
|
po =>
|
||||||
|
po.number.toLowerCase().includes(search.toLowerCase()) ||
|
||||||
|
po.vendorName.toLowerCase().includes(search.toLowerCase()) ||
|
||||||
|
po.vendorCompany.toLowerCase().includes(search.toLowerCase()) ||
|
||||||
|
po.status.toLowerCase().includes(search.toLowerCase())
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Filter by status
|
||||||
|
if (statusFilter !== 'Semua') {
|
||||||
|
filtered = filtered.filter(po => po.status === statusFilter)
|
||||||
|
}
|
||||||
|
|
||||||
|
setFilteredData(filtered)
|
||||||
|
setCurrentPage(0)
|
||||||
|
}, [search, statusFilter])
|
||||||
|
|
||||||
|
const totalCount = filteredData.length
|
||||||
|
const paginatedData = useMemo(() => {
|
||||||
|
const startIndex = currentPage * pageSize
|
||||||
|
return filteredData.slice(startIndex, startIndex + pageSize)
|
||||||
|
}, [filteredData, currentPage, pageSize])
|
||||||
|
|
||||||
|
const handlePageChange = useCallback((event: unknown, newPage: number) => {
|
||||||
|
setCurrentPage(newPage)
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
const handlePageSizeChange = useCallback((event: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
|
const newPageSize = parseInt(event.target.value, 10)
|
||||||
|
setPageSize(newPageSize)
|
||||||
|
setCurrentPage(0)
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
const handleDelete = () => {
|
||||||
|
setOpenConfirm(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
const handlePOClick = (poId: string) => {
|
||||||
|
console.log('Navigasi ke detail PO:', poId)
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleStatusFilter = (status: string) => {
|
||||||
|
setStatusFilter(status)
|
||||||
|
}
|
||||||
|
|
||||||
|
const columns = useMemo<ColumnDef<SalesOrderTypeWithAction, any>[]>(
|
||||||
|
() => [
|
||||||
|
{
|
||||||
|
id: 'select',
|
||||||
|
header: ({ table }) => (
|
||||||
|
<Checkbox
|
||||||
|
{...{
|
||||||
|
checked: table.getIsAllRowsSelected(),
|
||||||
|
indeterminate: table.getIsSomeRowsSelected(),
|
||||||
|
onChange: table.getToggleAllRowsSelectedHandler()
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
),
|
||||||
|
cell: ({ row }) => (
|
||||||
|
<Checkbox
|
||||||
|
{...{
|
||||||
|
checked: row.getIsSelected(),
|
||||||
|
disabled: !row.getCanSelect(),
|
||||||
|
indeterminate: row.getIsSomeSelected(),
|
||||||
|
onChange: row.getToggleSelectedHandler()
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
},
|
||||||
|
columnHelper.accessor('number', {
|
||||||
|
header: 'Nomor PO',
|
||||||
|
cell: ({ row }) => (
|
||||||
|
<Button
|
||||||
|
variant='text'
|
||||||
|
color='primary'
|
||||||
|
className='p-0 min-w-0 font-medium normal-case justify-start'
|
||||||
|
onClick={() => handlePOClick(row.original.id.toString())}
|
||||||
|
sx={{
|
||||||
|
textTransform: 'none',
|
||||||
|
fontWeight: 500,
|
||||||
|
'&:hover': {
|
||||||
|
textDecoration: 'underline',
|
||||||
|
backgroundColor: 'transparent'
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{row.original.number}
|
||||||
|
</Button>
|
||||||
|
)
|
||||||
|
}),
|
||||||
|
columnHelper.accessor('vendorName', {
|
||||||
|
header: 'Pelanggan',
|
||||||
|
cell: ({ row }) => (
|
||||||
|
<div className='flex flex-col'>
|
||||||
|
<Typography color='text.primary' className='font-medium'>
|
||||||
|
{row.original.vendorName}
|
||||||
|
</Typography>
|
||||||
|
<Typography variant='body2' color='text.secondary'>
|
||||||
|
{row.original.vendorCompany}
|
||||||
|
</Typography>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}),
|
||||||
|
columnHelper.accessor('reference', {
|
||||||
|
header: 'Referensi',
|
||||||
|
cell: ({ row }) => <Typography color='text.secondary'>{row.original.reference || '-'}</Typography>
|
||||||
|
}),
|
||||||
|
columnHelper.accessor('date', {
|
||||||
|
header: 'Tanggal',
|
||||||
|
cell: ({ row }) => <Typography>{row.original.date}</Typography>
|
||||||
|
}),
|
||||||
|
columnHelper.accessor('dueDate', {
|
||||||
|
header: 'Tanggal Jatuh Tempo',
|
||||||
|
cell: ({ row }) => <Typography>{row.original.dueDate}</Typography>
|
||||||
|
}),
|
||||||
|
columnHelper.accessor('status', {
|
||||||
|
header: 'Status',
|
||||||
|
cell: ({ row }) => (
|
||||||
|
<div className='flex items-center gap-3'>
|
||||||
|
<Chip
|
||||||
|
variant='tonal'
|
||||||
|
label={row.original.status}
|
||||||
|
size='small'
|
||||||
|
color={getStatusColor(row.original.status) as any}
|
||||||
|
className='capitalize'
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}),
|
||||||
|
columnHelper.accessor('total', {
|
||||||
|
header: 'Total',
|
||||||
|
cell: ({ row }) => <Typography className='font-medium'>{formatCurrency(row.original.total)}</Typography>
|
||||||
|
})
|
||||||
|
],
|
||||||
|
[]
|
||||||
|
)
|
||||||
|
|
||||||
|
const table = useReactTable({
|
||||||
|
data: paginatedData as SalesOrderType[],
|
||||||
|
columns,
|
||||||
|
filterFns: {
|
||||||
|
fuzzy: fuzzyFilter
|
||||||
|
},
|
||||||
|
state: {
|
||||||
|
rowSelection,
|
||||||
|
pagination: {
|
||||||
|
pageIndex: currentPage,
|
||||||
|
pageSize
|
||||||
|
}
|
||||||
|
},
|
||||||
|
enableRowSelection: true,
|
||||||
|
onRowSelectionChange: setRowSelection,
|
||||||
|
getCoreRowModel: getCoreRowModel(),
|
||||||
|
manualPagination: true,
|
||||||
|
pageCount: Math.ceil(totalCount / pageSize)
|
||||||
|
})
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Card>
|
||||||
|
{/* Filter Status Tabs */}
|
||||||
|
<div className='p-6 border-bs'>
|
||||||
|
<div className='flex flex-wrap gap-2'>
|
||||||
|
{['Semua', 'Open', 'Dikirim Sebagian', 'Selesai', 'Lainnya'].map(status => (
|
||||||
|
<Button
|
||||||
|
key={status}
|
||||||
|
variant={statusFilter === status ? 'contained' : 'outlined'}
|
||||||
|
color={statusFilter === status ? 'primary' : 'inherit'}
|
||||||
|
onClick={() => handleStatusFilter(status)}
|
||||||
|
size='small'
|
||||||
|
className='rounded-lg'
|
||||||
|
sx={{
|
||||||
|
textTransform: 'none',
|
||||||
|
fontWeight: statusFilter === status ? 600 : 400,
|
||||||
|
borderRadius: '8px',
|
||||||
|
...(statusFilter !== status && {
|
||||||
|
borderColor: '#e0e0e0',
|
||||||
|
color: '#666'
|
||||||
|
})
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{status}
|
||||||
|
</Button>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className='flex justify-between flex-col items-start md:flex-row md:items-center p-6 border-bs gap-4'>
|
||||||
|
<DebouncedInput
|
||||||
|
value={search}
|
||||||
|
onChange={value => setSearch(value as string)}
|
||||||
|
placeholder='Cari Sales Order'
|
||||||
|
className='max-sm:is-full'
|
||||||
|
/>
|
||||||
|
<div className='flex flex-col sm:flex-row max-sm:is-full items-start sm:items-center gap-4'>
|
||||||
|
<CustomTextField
|
||||||
|
select
|
||||||
|
value={pageSize}
|
||||||
|
onChange={handlePageSizeChange}
|
||||||
|
className='max-sm:is-full sm:is-[70px]'
|
||||||
|
>
|
||||||
|
<MenuItem value={10}>10</MenuItem>
|
||||||
|
<MenuItem value={25}>25</MenuItem>
|
||||||
|
<MenuItem value={50}>50</MenuItem>
|
||||||
|
</CustomTextField>
|
||||||
|
<Button
|
||||||
|
color='secondary'
|
||||||
|
variant='tonal'
|
||||||
|
startIcon={<i className='tabler-upload' />}
|
||||||
|
className='max-sm:is-full'
|
||||||
|
>
|
||||||
|
Ekspor
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
variant='contained'
|
||||||
|
component={Link}
|
||||||
|
className='max-sm:is-full is-auto'
|
||||||
|
startIcon={<i className='tabler-plus' />}
|
||||||
|
href={getLocalizedUrl('/apps/Sales/Sales-orders/add', locale as Locale)}
|
||||||
|
>
|
||||||
|
Tambah
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className='overflow-x-auto'>
|
||||||
|
<table className={tableStyles.table}>
|
||||||
|
<thead>
|
||||||
|
{table.getHeaderGroups().map(headerGroup => (
|
||||||
|
<tr key={headerGroup.id}>
|
||||||
|
{headerGroup.headers.map(header => (
|
||||||
|
<th key={header.id}>
|
||||||
|
{header.isPlaceholder ? null : (
|
||||||
|
<>
|
||||||
|
<div
|
||||||
|
className={classnames({
|
||||||
|
'flex items-center': header.column.getIsSorted(),
|
||||||
|
'cursor-pointer select-none': header.column.getCanSort()
|
||||||
|
})}
|
||||||
|
onClick={header.column.getToggleSortingHandler()}
|
||||||
|
>
|
||||||
|
{flexRender(header.column.columnDef.header, header.getContext())}
|
||||||
|
{{
|
||||||
|
asc: <i className='tabler-chevron-up text-xl' />,
|
||||||
|
desc: <i className='tabler-chevron-down text-xl' />
|
||||||
|
}[header.column.getIsSorted() as 'asc' | 'desc'] ?? null}
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</th>
|
||||||
|
))}
|
||||||
|
</tr>
|
||||||
|
))}
|
||||||
|
</thead>
|
||||||
|
{filteredData.length === 0 ? (
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td colSpan={table.getVisibleFlatColumns().length} className='text-center'>
|
||||||
|
Tidak ada data tersedia
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
) : (
|
||||||
|
<tbody>
|
||||||
|
{table.getRowModel().rows.map(row => {
|
||||||
|
return (
|
||||||
|
<tr key={row.id} className={classnames({ selected: row.getIsSelected() })}>
|
||||||
|
{row.getVisibleCells().map(cell => (
|
||||||
|
<td key={cell.id}>{flexRender(cell.column.columnDef.cell, cell.getContext())}</td>
|
||||||
|
))}
|
||||||
|
</tr>
|
||||||
|
)
|
||||||
|
})}
|
||||||
|
</tbody>
|
||||||
|
)}
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<TablePagination
|
||||||
|
component={() => (
|
||||||
|
<TablePaginationComponent
|
||||||
|
pageIndex={currentPage}
|
||||||
|
pageSize={pageSize}
|
||||||
|
totalCount={totalCount}
|
||||||
|
onPageChange={handlePageChange}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
count={totalCount}
|
||||||
|
rowsPerPage={pageSize}
|
||||||
|
page={currentPage}
|
||||||
|
onPageChange={handlePageChange}
|
||||||
|
onRowsPerPageChange={handlePageSizeChange}
|
||||||
|
rowsPerPageOptions={[10, 25, 50]}
|
||||||
|
/>
|
||||||
|
</Card>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default SalesOrderListTable
|
||||||
19
src/views/apps/sales/sales-orders/list/index.tsx
Normal file
19
src/views/apps/sales/sales-orders/list/index.tsx
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
// MUI Imports
|
||||||
|
import Grid from '@mui/material/Grid2'
|
||||||
|
|
||||||
|
// Type Imports
|
||||||
|
|
||||||
|
// Component Imports
|
||||||
|
import SalesOrderListTable from './SalesOrderListTable'
|
||||||
|
|
||||||
|
const SalesOrderList = () => {
|
||||||
|
return (
|
||||||
|
<Grid container spacing={6}>
|
||||||
|
<Grid size={{ xs: 12 }}>
|
||||||
|
<SalesOrderListTable />
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default SalesOrderList
|
||||||
Loading…
x
Reference in New Issue
Block a user