Merge branch 'feat/server-side-sorting-purchasing-expense' into 'development'

[FEAT/FE] Server-Side Sorting Purchasing & Expense

See merge request mbugroup/lti-web-client!477
This commit is contained in:
Rivaldi A N S
2026-05-13 08:49:54 +00:00
4 changed files with 51 additions and 23 deletions
+1
View File
@@ -173,6 +173,7 @@ const Table = <TData extends object>({
const tableOptions: TableOptions<TData> = { const tableOptions: TableOptions<TData> = {
columns, columns,
data: isLoading ? (DUMMY_SKELETON_DATA as TData[]) : data, // Type assertion data: isLoading ? (DUMMY_SKELETON_DATA as TData[]) : data, // Type assertion
defaultColumn: { sortDescFirst: false },
getCoreRowModel: getCoreRowModel(), getCoreRowModel: getCoreRowModel(),
getSortedRowModel: getSortedRowModel(), getSortedRowModel: getSortedRowModel(),
getPaginationRowModel: getPaginationRowModel(), getPaginationRowModel: getPaginationRowModel(),
@@ -69,6 +69,7 @@ const ConfirmationModalWithNotes: React.FC<ConfirmationModalWithNotesProps> = ({
secondaryButton={ secondaryButton={
secondaryButton secondaryButton
? { ? {
...secondaryButton,
text: secondaryButton?.text ?? 'Tidak', text: secondaryButton?.text ?? 'Tidak',
onClick: (e) => { onClick: (e) => {
if (secondaryButton && secondaryButton?.onClick) { if (secondaryButton && secondaryButton?.onClick) {
@@ -297,6 +297,8 @@ const MarketingTable = () => {
const [isLoadingExportingToExcel, setIsLoadingExportingToExcel] = const [isLoadingExportingToExcel, setIsLoadingExportingToExcel] =
useState(false); useState(false);
const [isApproveLoading, setIsApproveLoading] = useState(false);
const [isDeliveryLoading, setIsDeliveryLoading] = useState(false);
const filterResetHandler = () => { const filterResetHandler = () => {
updateFilter('product_ids', '', true); updateFilter('product_ids', '', true);
@@ -452,23 +454,33 @@ const MarketingTable = () => {
return; return;
} }
const approveMarketingRes: BaseApiResponse<unknown> | undefined = setIsApproveLoading(true);
approveAction === 'APPROVED'
? await MarketingApi.bulkApprovals(
idsToProcess,
nextApprovalStatus as 'SALES_ORDER' | 'DELIVERY_ORDER',
'',
notes || `APPROVED marketing ${idsToProcess.join(', ')}`
)
: await SalesOrderApi.bulkApprovals(idsToProcess, approveAction, notes);
if (isResponseSuccess(approveMarketingRes)) { try {
confirmationModal.closeModal(); const approveMarketingRes: BaseApiResponse<unknown> | undefined =
toast.success(approveMarketingRes?.message as string); approveAction === 'APPROVED'
setRowSelection({}); ? await MarketingApi.bulkApprovals(
idsToProcess,
nextApprovalStatus as 'SALES_ORDER' | 'DELIVERY_ORDER',
'',
notes || `APPROVED marketing ${idsToProcess.join(', ')}`
)
: await SalesOrderApi.bulkApprovals(
idsToProcess,
approveAction,
notes
);
if (isResponseSuccess(approveMarketingRes)) {
confirmationModal.closeModal();
toast.success(approveMarketingRes?.message as string);
setRowSelection({});
}
refreshMarketing();
} finally {
setIsApproveLoading(false);
} }
refreshMarketing();
}; };
const bulkDeliveryDateChangeHandler: ChangeEventHandler<HTMLInputElement> = ( const bulkDeliveryDateChangeHandler: ChangeEventHandler<HTMLInputElement> = (
@@ -530,13 +542,21 @@ const MarketingTable = () => {
}; };
const confirmationModalDeliveryClickHandler = async (notes: string) => { const confirmationModalDeliveryClickHandler = async (notes: string) => {
const res = await SalesOrderApi.delivery(selectedItem?.id as number, notes); setIsDeliveryLoading(true);
deliveryModal.closeModal(); try {
toast.success(res?.message as string); const res = await SalesOrderApi.delivery(
refreshMarketing?.(); selectedItem?.id as number,
router.push( notes
`/marketing/detail/delivery-orders/edit?id=${selectedItem?.id}` );
); deliveryModal.closeModal();
toast.success(res?.message as string);
refreshMarketing?.();
router.push(
`/marketing/detail/delivery-orders/edit?id=${selectedItem?.id}`
);
} finally {
setIsDeliveryLoading(false);
}
}; };
const getRowCanSelect = useCallback( const getRowCanSelect = useCallback(
@@ -1020,11 +1040,13 @@ const MarketingTable = () => {
text={`Apakah anda yakin ingin ${approveAction == 'APPROVED' ? 'approve' : 'reject'} data penjualan tahap ${selectedApprovalStep ?? '-'} (${idsToProcess.length} data)?`} text={`Apakah anda yakin ingin ${approveAction == 'APPROVED' ? 'approve' : 'reject'} data penjualan tahap ${selectedApprovalStep ?? '-'} (${idsToProcess.length} data)?`}
secondaryButton={{ secondaryButton={{
text: 'Tidak', text: 'Tidak',
isLoading: isApproveLoading,
onClick: confirmationModal.closeModal, onClick: confirmationModal.closeModal,
}} }}
primaryButton={{ primaryButton={{
text: 'Ya', text: 'Ya',
color: approveAction === 'APPROVED' ? 'success' : 'error', color: approveAction === 'APPROVED' ? 'success' : 'error',
isLoading: isApproveLoading,
onClick: approveMarketingHandler, onClick: approveMarketingHandler,
}} }}
/> />
@@ -1048,10 +1070,12 @@ const MarketingTable = () => {
text={`Apakah anda yakin ingin deliver penjualan ${selectedItem?.so_number}?`} text={`Apakah anda yakin ingin deliver penjualan ${selectedItem?.so_number}?`}
secondaryButton={{ secondaryButton={{
text: 'Tidak', text: 'Tidak',
isLoading: isDeliveryLoading,
}} }}
primaryButton={{ primaryButton={{
text: 'Ya', text: 'Ya',
color: 'success', color: 'success',
isLoading: isDeliveryLoading,
onClick: confirmationModalDeliveryClickHandler, onClick: confirmationModalDeliveryClickHandler,
}} }}
/> />
@@ -1111,6 +1135,7 @@ const MarketingTable = () => {
<Button <Button
variant='outline' variant='outline'
color='none' color='none'
disabled={isSubmittingBulkDelivery}
onClick={() => { onClick={() => {
bulkDeliveryModal.closeModal(); bulkDeliveryModal.closeModal();
setBulkDeliveryDate(''); setBulkDeliveryDate('');
@@ -1123,6 +1148,7 @@ const MarketingTable = () => {
<Button <Button
color='success' color='success'
isLoading={isSubmittingBulkDelivery} isLoading={isSubmittingBulkDelivery}
disabled={isSubmittingBulkDelivery}
onClick={() => onClick={() =>
submitBulkDeliveryApprovalHandler( submitBulkDeliveryApprovalHandler(
idsToProcess, idsToProcess,
@@ -266,8 +266,8 @@ const PurchaseTable = () => {
// ===== TABLE COLUMNS DEFINITION ===== // ===== TABLE COLUMNS DEFINITION =====
const purchaseColumns: ColumnDef<Purchase>[] = [ const purchaseColumns: ColumnDef<Purchase>[] = [
{ {
accessorKey: 'po_number',
header: 'No. PR/PO', header: 'No. PR/PO',
enableSorting: false,
cell: (props) => { cell: (props) => {
const { pr_number, po_number } = props.row.original; const { pr_number, po_number } = props.row.original;
return po_number ? po_number : pr_number; return po_number ? po_number : pr_number;