purchase quote list and add
This commit is contained in:
parent
9b787e65d4
commit
f585f23c54
@ -0,0 +1,19 @@
|
|||||||
|
import Grid from '@mui/material/Grid2'
|
||||||
|
|
||||||
|
import PurchaseAddForm from '@/views/apps/purchase/purchase-form/PurchaseAddForm'
|
||||||
|
import PurchaseQuoteAddHeader from '@/views/apps/purchase/purchase-quote/add/PurchaseQuoteAddHeader'
|
||||||
|
|
||||||
|
const PurchaseQuoteAddPage = () => {
|
||||||
|
return (
|
||||||
|
<Grid container spacing={6}>
|
||||||
|
<Grid size={{ xs: 12 }}>
|
||||||
|
<PurchaseQuoteAddHeader />
|
||||||
|
</Grid>
|
||||||
|
<Grid size={{ xs: 12 }}>
|
||||||
|
<PurchaseAddForm />
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default PurchaseQuoteAddPage
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
import PurchaseQuoteList from '@/views/apps/purchase/purchase-quote/list'
|
||||||
|
|
||||||
|
const PurchaseQuotePage = () => {
|
||||||
|
return <PurchaseQuoteList />
|
||||||
|
}
|
||||||
|
|
||||||
|
export default PurchaseQuotePage
|
||||||
@ -106,6 +106,9 @@ const VerticalMenu = ({ dictionary, scrollMenu }: Props) => {
|
|||||||
<MenuItem href={`/${locale}/apps/purchase/purchase-orders`}>
|
<MenuItem href={`/${locale}/apps/purchase/purchase-orders`}>
|
||||||
{dictionary['navigation'].purchase_orders}
|
{dictionary['navigation'].purchase_orders}
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
|
<MenuItem href={`/${locale}/apps/purchase/purchase-quotes`}>
|
||||||
|
{dictionary['navigation'].purchase_quotes}
|
||||||
|
</MenuItem>
|
||||||
</SubMenu>
|
</SubMenu>
|
||||||
<SubMenu label={dictionary['navigation'].inventory} icon={<i className='tabler-salad' />}>
|
<SubMenu label={dictionary['navigation'].inventory} icon={<i className='tabler-salad' />}>
|
||||||
<SubMenu label={dictionary['navigation'].products}>
|
<SubMenu label={dictionary['navigation'].products}>
|
||||||
|
|||||||
@ -117,6 +117,7 @@
|
|||||||
"purchase_text": "Purchase",
|
"purchase_text": "Purchase",
|
||||||
"purchase_orders": "Purchase Orders",
|
"purchase_orders": "Purchase Orders",
|
||||||
"purchase_bills": "Purchase Bills",
|
"purchase_bills": "Purchase Bills",
|
||||||
"purchase_delivery": "Purchase Delivery"
|
"purchase_delivery": "Purchase Delivery",
|
||||||
|
"purchase_quotes": "Purchase Quotes"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -117,6 +117,7 @@
|
|||||||
"purchase_text": "Pembelian",
|
"purchase_text": "Pembelian",
|
||||||
"purchase_orders": "Pesanan Pembelian",
|
"purchase_orders": "Pesanan Pembelian",
|
||||||
"purchase_bills": "Tagihan Pembelian",
|
"purchase_bills": "Tagihan Pembelian",
|
||||||
"purchase_delivery": "Pengiriman Pembelian"
|
"purchase_delivery": "Pengiriman Pembelian",
|
||||||
|
"purchase_quotes": "Penawaran Pembelian"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
224
src/data/dummy/purchase-quote.ts
Normal file
224
src/data/dummy/purchase-quote.ts
Normal file
@ -0,0 +1,224 @@
|
|||||||
|
import { PurchaseQuoteType } from '@/types/apps/purchaseQuoteTypes'
|
||||||
|
|
||||||
|
export const purchaseQuoteData: PurchaseQuoteType[] = [
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
number: 'PQ-001',
|
||||||
|
vendorName: 'Andi Wijaya',
|
||||||
|
vendorCompany: 'PT Sumber Makmur',
|
||||||
|
reference: 'REF-PQ-001',
|
||||||
|
date: '2025-09-01',
|
||||||
|
dueDate: '2025-09-10',
|
||||||
|
status: 'Open',
|
||||||
|
total: 4500000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 2,
|
||||||
|
number: 'PQ-002',
|
||||||
|
vendorName: 'Siti Rahma',
|
||||||
|
vendorCompany: 'CV Cahaya Abadi',
|
||||||
|
reference: 'REF-PQ-002',
|
||||||
|
date: '2025-09-02',
|
||||||
|
dueDate: '2025-09-12',
|
||||||
|
status: 'Selesai',
|
||||||
|
total: 7200000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 3,
|
||||||
|
number: 'PQ-003',
|
||||||
|
vendorName: 'Budi Santoso',
|
||||||
|
vendorCompany: 'UD Sejahtera',
|
||||||
|
reference: 'REF-PQ-003',
|
||||||
|
date: '2025-09-03',
|
||||||
|
dueDate: '2025-09-13',
|
||||||
|
status: 'Dipesan Sebagai',
|
||||||
|
total: 3100000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 4,
|
||||||
|
number: 'PQ-004',
|
||||||
|
vendorName: 'Rina Kartika',
|
||||||
|
vendorCompany: 'PT Mitra Jaya',
|
||||||
|
reference: 'REF-PQ-004',
|
||||||
|
date: '2025-09-04',
|
||||||
|
dueDate: '2025-09-15',
|
||||||
|
status: 'Open',
|
||||||
|
total: 5800000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 5,
|
||||||
|
number: 'PQ-005',
|
||||||
|
vendorName: 'Agus Salim',
|
||||||
|
vendorCompany: 'CV Bumi Persada',
|
||||||
|
reference: 'REF-PQ-005',
|
||||||
|
date: '2025-09-05',
|
||||||
|
dueDate: '2025-09-16',
|
||||||
|
status: 'Selesai',
|
||||||
|
total: 8000000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 6,
|
||||||
|
number: 'PQ-006',
|
||||||
|
vendorName: 'Maya Lestari',
|
||||||
|
vendorCompany: 'PT Tunas Baru',
|
||||||
|
reference: 'REF-PQ-006',
|
||||||
|
date: '2025-09-06',
|
||||||
|
dueDate: '2025-09-17',
|
||||||
|
status: 'Dipesan Sebagai',
|
||||||
|
total: 2600000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 7,
|
||||||
|
number: 'PQ-007',
|
||||||
|
vendorName: 'Hendra Gunawan',
|
||||||
|
vendorCompany: 'UD Prima Sentosa',
|
||||||
|
reference: 'REF-PQ-007',
|
||||||
|
date: '2025-09-07',
|
||||||
|
dueDate: '2025-09-18',
|
||||||
|
status: 'Open',
|
||||||
|
total: 9300000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 8,
|
||||||
|
number: 'PQ-008',
|
||||||
|
vendorName: 'Dewi Anggraini',
|
||||||
|
vendorCompany: 'CV Inti Mandiri',
|
||||||
|
reference: 'REF-PQ-008',
|
||||||
|
date: '2025-09-08',
|
||||||
|
dueDate: '2025-09-19',
|
||||||
|
status: 'Selesai',
|
||||||
|
total: 4100000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 9,
|
||||||
|
number: 'PQ-009',
|
||||||
|
vendorName: 'Yusuf Arifin',
|
||||||
|
vendorCompany: 'PT Surya Kencana',
|
||||||
|
reference: 'REF-PQ-009',
|
||||||
|
date: '2025-09-09',
|
||||||
|
dueDate: '2025-09-20',
|
||||||
|
status: 'Dipesan Sebagai',
|
||||||
|
total: 6900000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 10,
|
||||||
|
number: 'PQ-010',
|
||||||
|
vendorName: 'Nurhayati',
|
||||||
|
vendorCompany: 'UD Cahaya Mulia',
|
||||||
|
reference: 'REF-PQ-010',
|
||||||
|
date: '2025-09-10',
|
||||||
|
dueDate: '2025-09-21',
|
||||||
|
status: 'Open',
|
||||||
|
total: 5500000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 11,
|
||||||
|
number: 'PQ-011',
|
||||||
|
vendorName: 'Fajar Hidayat',
|
||||||
|
vendorCompany: 'PT Bina Karya',
|
||||||
|
reference: 'REF-PQ-011',
|
||||||
|
date: '2025-09-11',
|
||||||
|
dueDate: '2025-09-22',
|
||||||
|
status: 'Selesai',
|
||||||
|
total: 12000000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 12,
|
||||||
|
number: 'PQ-012',
|
||||||
|
vendorName: 'Ratna Sari',
|
||||||
|
vendorCompany: 'CV Mega Utama',
|
||||||
|
reference: 'REF-PQ-012',
|
||||||
|
date: '2025-09-12',
|
||||||
|
dueDate: '2025-09-23',
|
||||||
|
status: 'Dipesan Sebagai',
|
||||||
|
total: 3300000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 13,
|
||||||
|
number: 'PQ-013',
|
||||||
|
vendorName: 'Tono Prasetyo',
|
||||||
|
vendorCompany: 'UD Karya Indah',
|
||||||
|
reference: 'REF-PQ-013',
|
||||||
|
date: '2025-09-13',
|
||||||
|
dueDate: '2025-09-24',
|
||||||
|
status: 'Open',
|
||||||
|
total: 7500000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 14,
|
||||||
|
number: 'PQ-014',
|
||||||
|
vendorName: 'Lina Marlina',
|
||||||
|
vendorCompany: 'PT Harmoni Sejati',
|
||||||
|
reference: 'REF-PQ-014',
|
||||||
|
date: '2025-09-14',
|
||||||
|
dueDate: '2025-09-25',
|
||||||
|
status: 'Selesai',
|
||||||
|
total: 8600000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 15,
|
||||||
|
number: 'PQ-015',
|
||||||
|
vendorName: 'Arman Saputra',
|
||||||
|
vendorCompany: 'CV Sentra Niaga',
|
||||||
|
reference: 'REF-PQ-015',
|
||||||
|
date: '2025-09-15',
|
||||||
|
dueDate: '2025-09-26',
|
||||||
|
status: 'Dipesan Sebagai',
|
||||||
|
total: 2950000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 16,
|
||||||
|
number: 'PQ-016',
|
||||||
|
vendorName: 'Indah Permata',
|
||||||
|
vendorCompany: 'PT Citra Abadi',
|
||||||
|
reference: 'REF-PQ-016',
|
||||||
|
date: '2025-09-16',
|
||||||
|
dueDate: '2025-09-27',
|
||||||
|
status: 'Open',
|
||||||
|
total: 6800000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 17,
|
||||||
|
number: 'PQ-017',
|
||||||
|
vendorName: 'Adi Putra',
|
||||||
|
vendorCompany: 'UD Makmur Bersama',
|
||||||
|
reference: 'REF-PQ-017',
|
||||||
|
date: '2025-09-17',
|
||||||
|
dueDate: '2025-09-28',
|
||||||
|
status: 'Selesai',
|
||||||
|
total: 4700000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 18,
|
||||||
|
number: 'PQ-018',
|
||||||
|
vendorName: 'Sri Wahyuni',
|
||||||
|
vendorCompany: 'CV Bintang Terang',
|
||||||
|
reference: 'REF-PQ-018',
|
||||||
|
date: '2025-09-18',
|
||||||
|
dueDate: '2025-09-29',
|
||||||
|
status: 'Dipesan Sebagai',
|
||||||
|
total: 5300000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 19,
|
||||||
|
number: 'PQ-019',
|
||||||
|
vendorName: 'Eko Prabowo',
|
||||||
|
vendorCompany: 'PT Mandiri Jaya',
|
||||||
|
reference: 'REF-PQ-019',
|
||||||
|
date: '2025-09-19',
|
||||||
|
dueDate: '2025-09-30',
|
||||||
|
status: 'Open',
|
||||||
|
total: 9500000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 20,
|
||||||
|
number: 'PQ-020',
|
||||||
|
vendorName: 'Novi Astuti',
|
||||||
|
vendorCompany: 'UD Sinar Harapan',
|
||||||
|
reference: 'REF-PQ-020',
|
||||||
|
date: '2025-09-20',
|
||||||
|
dueDate: '2025-10-01',
|
||||||
|
status: 'Selesai',
|
||||||
|
total: 4200000
|
||||||
|
}
|
||||||
|
]
|
||||||
11
src/types/apps/purchaseQuoteTypes.ts
Normal file
11
src/types/apps/purchaseQuoteTypes.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
export type PurchaseQuoteType = {
|
||||||
|
id: number
|
||||||
|
number: string
|
||||||
|
vendorName: string
|
||||||
|
vendorCompany: string
|
||||||
|
reference: string
|
||||||
|
date: string
|
||||||
|
dueDate: string
|
||||||
|
status: string
|
||||||
|
total: number
|
||||||
|
}
|
||||||
@ -0,0 +1,19 @@
|
|||||||
|
'use client'
|
||||||
|
|
||||||
|
// MUI Imports
|
||||||
|
import Button from '@mui/material/Button'
|
||||||
|
import Typography from '@mui/material/Typography'
|
||||||
|
|
||||||
|
const PurchaseQuoteAddHeader = () => {
|
||||||
|
return (
|
||||||
|
<div className='flex flex-wrap sm:items-center justify-between max-sm:flex-col gap-6'>
|
||||||
|
<div>
|
||||||
|
<Typography variant='h4' className='mbe-1'>
|
||||||
|
Tambah Penawaran Pembelian
|
||||||
|
</Typography>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default PurchaseQuoteAddHeader
|
||||||
@ -0,0 +1,452 @@
|
|||||||
|
'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 { PurchaseQuoteType } from '@/types/apps/purchaseQuoteTypes'
|
||||||
|
import { purchaseQuoteData } from '@/data/dummy/purchase-quote'
|
||||||
|
|
||||||
|
declare module '@tanstack/table-core' {
|
||||||
|
interface FilterFns {
|
||||||
|
fuzzy: FilterFn<unknown>
|
||||||
|
}
|
||||||
|
interface FilterMeta {
|
||||||
|
itemRank: RankingInfo
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type PurchaseQuoteTypeWithAction = PurchaseQuoteType & {
|
||||||
|
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 for Purchase Quote
|
||||||
|
const getStatusColor = (status: string) => {
|
||||||
|
switch (status) {
|
||||||
|
case 'Open':
|
||||||
|
return 'primary'
|
||||||
|
case 'Dipesan 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<PurchaseQuoteTypeWithAction>()
|
||||||
|
|
||||||
|
const PurchaseQuoteListTable = () => {
|
||||||
|
const dispatch = useDispatch()
|
||||||
|
|
||||||
|
// States
|
||||||
|
const [addQuoteOpen, setAddQuoteOpen] = useState(false)
|
||||||
|
const [rowSelection, setRowSelection] = useState({})
|
||||||
|
const [currentPage, setCurrentPage] = useState(0)
|
||||||
|
const [pageSize, setPageSize] = useState(10)
|
||||||
|
const [openConfirm, setOpenConfirm] = useState(false)
|
||||||
|
const [quoteId, setQuoteId] = useState('')
|
||||||
|
const [search, setSearch] = useState('')
|
||||||
|
const [statusFilter, setStatusFilter] = useState<string>('Semua')
|
||||||
|
const [filteredData, setFilteredData] = useState<PurchaseQuoteType[]>(purchaseQuoteData)
|
||||||
|
|
||||||
|
// Hooks
|
||||||
|
const { lang: locale } = useParams()
|
||||||
|
|
||||||
|
// Filter data based on search and status
|
||||||
|
useEffect(() => {
|
||||||
|
let filtered = purchaseQuoteData
|
||||||
|
|
||||||
|
// Filter by search
|
||||||
|
if (search) {
|
||||||
|
filtered = filtered.filter(
|
||||||
|
quote =>
|
||||||
|
quote.number.toLowerCase().includes(search.toLowerCase()) ||
|
||||||
|
quote.vendorName.toLowerCase().includes(search.toLowerCase()) ||
|
||||||
|
quote.vendorCompany.toLowerCase().includes(search.toLowerCase()) ||
|
||||||
|
quote.status.toLowerCase().includes(search.toLowerCase())
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Filter by status
|
||||||
|
if (statusFilter !== 'Semua') {
|
||||||
|
filtered = filtered.filter(quote => quote.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 handleQuoteClick = (quoteId: string) => {
|
||||||
|
console.log('Navigasi ke detail Quote:', quoteId)
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleStatusFilter = (status: string) => {
|
||||||
|
setStatusFilter(status)
|
||||||
|
}
|
||||||
|
|
||||||
|
const columns = useMemo<ColumnDef<PurchaseQuoteTypeWithAction, 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 Quote',
|
||||||
|
cell: ({ row }) => (
|
||||||
|
<Button
|
||||||
|
variant='text'
|
||||||
|
color='primary'
|
||||||
|
className='p-0 min-w-0 font-medium normal-case justify-start'
|
||||||
|
onClick={() => handleQuoteClick(row.original.id.toString())}
|
||||||
|
sx={{
|
||||||
|
textTransform: 'none',
|
||||||
|
fontWeight: 500,
|
||||||
|
'&:hover': {
|
||||||
|
textDecoration: 'underline',
|
||||||
|
backgroundColor: 'transparent'
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{row.original.number}
|
||||||
|
</Button>
|
||||||
|
)
|
||||||
|
}),
|
||||||
|
columnHelper.accessor('vendorName', {
|
||||||
|
header: 'Vendor',
|
||||||
|
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 PurchaseQuoteType[],
|
||||||
|
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', 'Selesai', 'Dipesan Sebagian'].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 Purchase Quote'
|
||||||
|
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/purchase/purchase-quotes/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 PurchaseQuoteListTable
|
||||||
19
src/views/apps/purchase/purchase-quote/list/index.tsx
Normal file
19
src/views/apps/purchase/purchase-quote/list/index.tsx
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
// MUI Imports
|
||||||
|
import Grid from '@mui/material/Grid2'
|
||||||
|
|
||||||
|
// Type Imports
|
||||||
|
|
||||||
|
// Component Imports
|
||||||
|
import PurchaseQuoteListTable from './PurchaseQuoteListTable'
|
||||||
|
|
||||||
|
const PurchaseQuoteList = () => {
|
||||||
|
return (
|
||||||
|
<Grid container spacing={6}>
|
||||||
|
<Grid size={{ xs: 12 }}>
|
||||||
|
<PurchaseQuoteListTable />
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default PurchaseQuoteList
|
||||||
Loading…
x
Reference in New Issue
Block a user