From 4a6033d7b4812cc66fe31bf7a047747a42f70848 Mon Sep 17 00:00:00 2001 From: wayanrivan Date: Mon, 7 Apr 2025 12:07:59 +0700 Subject: [PATCH 01/19] update transaction detail --- .../ApprovalTransaction.tsx | 31 + .../blocks/DetailApprovalTransaction.tsx | 538 ++++++++++++++++++ .../blocks/ListToolbar.tsx | 82 +++ .../hooks/ApprovalTransactionContext.tsx | 268 +++++++++ .../hooks/useApprovalTransactionContext.tsx | 12 + .../{ => history-transaction}/Transaction.tsx | 2 +- .../blocks/DetailTransaction.tsx | 38 +- .../blocks/ListToolbar.tsx | 0 .../hooks/TransactionContext.tsx | 0 .../hooks/useTransactionContext.tsx | 0 src/routing/AppRoutingSetup.tsx | 4 +- 11 files changed, 972 insertions(+), 3 deletions(-) create mode 100644 src/pages/transaction/approval-transaction/ApprovalTransaction.tsx create mode 100644 src/pages/transaction/approval-transaction/blocks/DetailApprovalTransaction.tsx create mode 100644 src/pages/transaction/approval-transaction/blocks/ListToolbar.tsx create mode 100644 src/pages/transaction/approval-transaction/hooks/ApprovalTransactionContext.tsx create mode 100644 src/pages/transaction/approval-transaction/hooks/useApprovalTransactionContext.tsx rename src/pages/transaction/{ => history-transaction}/Transaction.tsx (93%) rename src/pages/transaction/{ => history-transaction}/blocks/DetailTransaction.tsx (93%) rename src/pages/transaction/{ => history-transaction}/blocks/ListToolbar.tsx (100%) rename src/pages/transaction/{ => history-transaction}/hooks/TransactionContext.tsx (100%) rename src/pages/transaction/{ => history-transaction}/hooks/useTransactionContext.tsx (100%) diff --git a/src/pages/transaction/approval-transaction/ApprovalTransaction.tsx b/src/pages/transaction/approval-transaction/ApprovalTransaction.tsx new file mode 100644 index 0000000..e6aa68b --- /dev/null +++ b/src/pages/transaction/approval-transaction/ApprovalTransaction.tsx @@ -0,0 +1,31 @@ +import { Container, DataGridInner } from '@/components'; +import { ApprovalTransactionProvider } from './hooks/ApprovalTransactionContext'; +import { Breadcrumbs, Link } from '@mui/material'; + +const ApprovalTransaction = () => { + return ( + + +

TRANSACTION

+ + + Dashboard + + + + Transaction + + + + Approval Transaction + + +
+ +
+
+
+ ); +}; + +export default ApprovalTransaction; diff --git a/src/pages/transaction/approval-transaction/blocks/DetailApprovalTransaction.tsx b/src/pages/transaction/approval-transaction/blocks/DetailApprovalTransaction.tsx new file mode 100644 index 0000000..e0d0ecc --- /dev/null +++ b/src/pages/transaction/approval-transaction/blocks/DetailApprovalTransaction.tsx @@ -0,0 +1,538 @@ +import { useTransactionContext } from '../hooks/useApprovalTransactionContext'; +import { useCallApi } from '@/hooks'; +import { apiConfig } from '@/config/api.config'; +import { useEffect, useState } from 'react'; +import { + Dialog, + DialogBody, + DialogContent, + DialogDescription, + DialogHeader, + DialogTitle +} from '@/components/ui/dialog'; + +const API_URL = apiConfig.transaction; + +const DetailApprovalTransaction = () => { + const { GetData } = useCallApi(); + const { + showDetailDialog, + setShowDetailDialog, + selectedTransactionId + } = useTransactionContext(); + + const [transactionDetails, setTransactionDetails] = useState(null); + + useEffect(() => { + const fetchTransactionDetails = async () => { + if (selectedTransactionId) { + try { + const response = await GetData(`${API_URL}/transaction/history/detail/${selectedTransactionId}`, { + id: selectedTransactionId + }); + // console.log(response?.data); + setTransactionDetails(response?.data); + } catch (error) { + console.error('Error fetching transaction', error); + } + } + }; + + if (showDetailDialog && selectedTransactionId) { + fetchTransactionDetails(); + } + }, [showDetailDialog, selectedTransactionId, GetData]); + + const [activeTab, setActiveTab] = useState('detail'); // 'detail', 'log', 'approve' + + return ( + + + + Transaction Details + + + {/* Tabs Navigation */} +
+ + + + + +
+ + {/* Tab Content */} +
+ {activeTab === 'detail' && transactionDetails?.kind === 'P' && ( +
+

+ Transaction Information + + Info + +

+
+
+

Transaction Date

+

{transactionDetails?.transaction_date}

+
+
+

Full Name

+

{transactionDetails?.origin_customer.fullname}

+
+
+

Amount

+

{new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' }).format(transactionDetails?.purchase.amount)}

+
+
+

Fee

+

+ {transactionDetails?.kind === 'P' + ? transactionDetails?.purchase.fee_amount.toLocaleString('en-US', { style: 'currency', currency: 'USD' }) + : transactionDetails?.transfer.fee_amount.toLocaleString('en-US', { style: 'currency', currency: 'USD' })} +

+
+
+

Status

+

+ {(() => { + let status; + if (transactionDetails?.status === 'C') { + status = 'COMPLETE'; + } else if (transactionDetails?.status === 'F') { + status = 'FAILED'; + } else if (transactionDetails?.status === 'O') { + status = 'ON PROCESS'; + } else { + status = 'PENDING'; + } + return status; + })()} +

+
+
+

Transaction Type

+

+ {(() => { + let kind; + if (transactionDetails?.kind === 'T') { + kind = 'TRANSFER'; + } else if (transactionDetails?.kind === 'P') { + kind = 'PURCHASE'; + } else if (transactionDetails?.kind === 'W') { + kind = 'WITHDRAW'; + } else if (transactionDetails?.kind === 'U') { + kind = 'TOP UP'; + } else if (transactionDetails?.kind === 'R') { + kind = 'RETURN'; + } + return kind; + })()} +

+
+
+

Description

+

{transactionDetails?.description}

+
+
+

Name

+

{transactionDetails?.type.name}

+
+
+ +

+ Origin Wallet + + Wallet + +

+
+
+

Name

+

{transactionDetails?.origin_wallet.name}

+
+
+

Description

+

{transactionDetails?.origin_wallet.description}

+
+
+ +

+ Purchase + + Purchase + +

+
+
+

Amount

+

{new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' }).format(transactionDetails?.purchase.amount)}

+
+
+

Cashback

+

{new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' }).format(transactionDetails?.purchase.cashback)}

+
+
+

Cashback Point

+

{transactionDetails?.purchase.cashback_point}

+
+
+

Fee Amount

+

{new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' }).format(transactionDetails?.purchase.fee_amount)}

+
+
+
+ )} + + {activeTab === 'detail' && transactionDetails?.kind != 'P' && transactionDetails?.transfer!=null && ( +
+

+ Transaction Information + + Info + +

+
+
+

Transaction Date

+

{transactionDetails?.transaction_date}

+
+
+

Full Name

+

{transactionDetails?.origin_customer.fullname}

+
+
+

Amount

+

{new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' }).format(transactionDetails?.transfer.amount)}

+
+
+

Fee

+

+ {transactionDetails?.transfer.fee_amount.toLocaleString('en-US', { style: 'currency', currency: 'USD' })} +

+
+
+

Status

+

+ {(() => { + let status; + if (transactionDetails?.status === 'C') { + status = 'COMPLETE'; + } else if (transactionDetails?.status === 'F') { + status = 'FAILED'; + } else if (transactionDetails?.status === 'O') { + status = 'ON PROCESS'; + } else { + status = 'PENDING'; + } + return status; + })()} +

+
+
+

Transaction Type

+

+ {(() => { + let kind; + if (transactionDetails?.kind === 'T') { + kind = 'TRANSFER'; + } else if (transactionDetails?.kind === 'P') { + kind = 'PURCHASE'; + } else if (transactionDetails?.kind === 'W') { + kind = 'WITHDRAW'; + } else if (transactionDetails?.kind === 'U') { + kind = 'TOP UP'; + } else if (transactionDetails?.kind === 'R') { + kind = 'RETURN'; + } + return kind; + })()} +

+
+
+

Description

+

{transactionDetails?.description}

+
+
+

Name

+

{transactionDetails?.type.name}

+
+
+

Reference

+

{transactionDetails?.transfer.reference}

+
+
+

Destination Iban

+

{transactionDetails?.transfer.destination_iban}

+
+
+ +

+ Destination Wallet + + Wallet + +

+
+
+

Name

+

{transactionDetails?.transfer.destination_wallet.name}

+
+
+

Description

+

{transactionDetails?.transfer.destination_wallet.description}

+
+
+ +

+ Destination Customer + + Destination Customer + +

+
+
+

Name

+

{transactionDetails?.transfer.destination_customer.fullname}

+
+
+

MSISDN

+

{transactionDetails?.transfer.destination_customer.msisdn}

+
+
+

Email

+

{transactionDetails?.transfer.destination_customer.email}

+
+
+

MSISDN

+

{transactionDetails?.transfer.destination_customer.username}

+
+
+ +

+ Origin Wallet + + Wallet + +

+
+
+

Name

+

{transactionDetails?.origin_wallet.name}

+
+
+

Description

+

{transactionDetails?.origin_wallet.description}

+
+
+
+ )} + + + {activeTab === 'origincustomer' && ( +
+

Origin Customer

+
+
+

Full Name

+

{transactionDetails?.origin_customer.fullname}

+
+
+

Phone Number

+

{transactionDetails?.origin_customer.msisdn}

+
+
+

Email

+

{transactionDetails?.origin_customer.email}

+
+
+

Username

+

{transactionDetails?.origin_customer.username}

+
+
+
+ )} + + {activeTab === 'log' && ( +
+

Transaction Logs

+
+ + + + + + + + + + + + + {transactionDetails?.log && transactionDetails?.log.length > 0 ? ( + transactionDetails.log.map((log: { request_endpoint: string, status: string; request_date: string; response_date: string; request_body: string; response_body: string; response_code: number }, index: number) => ( + + + + + + + + + )) + ) : ( + + + + )} + +
StatusRequest DateRequest BodyResponse BodyResponse CodeRequest End Point
+ {(() => { + let status; + if (log.status === 'P') { + status = 'PENDING'; + } else if (log.status === 'O') { + status = 'ON PROCESS'; + } else if (log.status === 'F') { + status = 'FAILED'; + } else if (log.status === 'C') { + status = 'COMPLETE'; + } + return status; + })()} + {log.request_date ?? '-'}{log.response_date ?? '-'}{log.request_body ?? '-'}{log.response_body ?? '-'}{log.request_endpoint ?? '-'}
+ No logs available +
+
+
+ )} + + {activeTab === 'approve' && ( +
+

Approval Logs

+ {transactionDetails?.log_approve.length === 0 ? ( +

No data available

+ ) : ( +
+ + + + + + + + + + {transactionDetails?.log_approve && transactionDetails?.log_approve.length > 0 ? ( + transactionDetails.log_approve.map((log: { created_at: string; status: string; updated_at: string }, index: number) => ( + + + + + + )) + ) : ( + + + + )} + +
StatusCreated AtUpdated At
+ {(() => { + let status; + if (log.status === 'W') { + status = 'WAITING'; + } else if (log.status === 'Y') { + status = 'APPROVE'; + } else if (log.status === 'N') { + status = 'REJECT'; + } else if (log.status === 'T') { + status = 'NO NEED'; + } + return status; + })()} + {log.created_at}{log.updated_at}
+ No logs available +
+
+ )} +
+ )} + + {activeTab === 'p24' && ( +
+

P24 Logs

+ {transactionDetails?.p24.length === 0 ? ( +

No data available

+ ) : ( +
+ + + + + + + + + + + + + {transactionDetails?.p24 && transactionDetails?.p24.length > 0 ? ( + transactionDetails.p24.map((log: { request_endpoint: string, type: string; request_date: string; response_date: string; request_body: string; response_body: string; response_code: number }, index: number) => ( + + + + + + + + + )) + ) : ( + + + + )} + +
TypeRequest DateRequest BodyResponse BodyResponse CodeRequest Endpoint
{log.type}{log.request_date}{log.response_date}{log.request_body}{log.response_body}{log.request_endpoint ?? '-'}
+ No logs available +
+
+ )} +
+ )} + +
+
+
+
+ ); +}; + +export default DetailApprovalTransaction; diff --git a/src/pages/transaction/approval-transaction/blocks/ListToolbar.tsx b/src/pages/transaction/approval-transaction/blocks/ListToolbar.tsx new file mode 100644 index 0000000..3247955 --- /dev/null +++ b/src/pages/transaction/approval-transaction/blocks/ListToolbar.tsx @@ -0,0 +1,82 @@ +import { DefaultTooltip, KeenIcon, useDataGrid } from '@/components'; +import { useTransactionContext } from '../hooks/useApprovalTransactionContext'; +import { Button } from '@/components/ui/button'; +import { useCallback, useState, useEffect } from 'react'; +import { toast } from 'sonner'; + +const ListToolbar = () => { + const { table, reload } = useDataGrid(); + + // Set the initial state for trxDate + const [trxDate, settrxDate] = useState({ from: '', to: '' }); + + // Function to format date to YYYY-MM-DD + const formatDate = (date: Date): string => { + return date.toISOString().split('T')[0]; + }; + + // useEffect to set the default date values + useEffect(() => { + const today = new Date(); + const nextWeek = new Date(today); + nextWeek.setDate(today.getDate() + 7); + + settrxDate({ + from: formatDate(today), // Set 'from' to today + to: formatDate(nextWeek), // Set 'to' to 7 days later + }); + }, []); + + const handleFilterData = useCallback(() => { + try { + table.getColumn('transaction_date')?.setFilterValue(trxDate); + } catch (error) { + toast.error('Error applying filter'); + console.error('Error applying filter:', error); + } + }, [trxDate, table]); + + useEffect(() => { + if (trxDate.from && trxDate.to) { + handleFilterData(); + } + }, [trxDate]); + + return ( +
+
+
+
+ + + +
+
+
+
+ ); +}; + +export default ListToolbar; diff --git a/src/pages/transaction/approval-transaction/hooks/ApprovalTransactionContext.tsx b/src/pages/transaction/approval-transaction/hooks/ApprovalTransactionContext.tsx new file mode 100644 index 0000000..91c87c2 --- /dev/null +++ b/src/pages/transaction/approval-transaction/hooks/ApprovalTransactionContext.tsx @@ -0,0 +1,268 @@ +import { DataGridColumnHeader, DataGridProvider, KeenIcon } from '@/components'; +import { Toaster } from '@/components/ui/sonner'; +import { apiConfig } from '@/config/api.config'; +import { ColumnDef } from '@tanstack/react-table'; +import axios from 'axios'; +import React, { createContext, useCallback, useEffect, useMemo, useState } from 'react'; +import { useCallApi } from '@/hooks'; +import ListToolbar from '../blocks/ListToolbar'; +import { Button } from '@/components/ui/button'; +import { useNavigate } from 'react-router'; +import DetailApprovalTransaction from '../blocks/DetailApprovalTransaction'; + +interface ApprovalTransactionProps { + id: number; + name: string; +} + +interface ContextProps { + getTransactionLists: ( + limit: number, + page: number, + with_deleted: boolean, + order_field: any, + order_direction: any, + filter: any + ) => Promise<{ data: ApprovalTransactionProps[]; totalCount: number } | undefined>; + showDetailDialog: boolean; + setShowDetailDialog: React.Dispatch>; + selectedTransactionId: number | null; + setSelectedTransactionId: React.Dispatch>; +} + +const initialProps: ContextProps = { + getTransactionLists: async () => ({ data: [], totalCount: 0 }), + showDetailDialog: false, + setShowDetailDialog: () => { }, + selectedTransactionId: null, + setSelectedTransactionId: () => { } +}; + +const ManageApprovalTransactionContext = createContext(initialProps); +const API_URL = apiConfig.transaction; + +const ApprovalTransactionProvider = ({ children }: { children: React.ReactNode }) => { + const [showDetailDialog, setShowDetailDialog] = useState(false); + const [selectedTransactionId, setSelectedTransactionId] = useState(null); + const [transaction, setTransaction] = useState([]); + const { GetData } = useCallApi(); + const navigate = useNavigate(); + const handleNavigate = (path: string) => { + const url = navigate(`${API_URL}/transaction/history/${path}`); + }; + + const columns = useMemo[]>( + () => [ + // { + // accessorKey: 'transaction_date', + // header: ({ column }) => , + // enableSorting: false, + // enableHiding: false, + // meta: { + // headerClassName: 'w-[250px]' + // } + // }, + { + accessorKey: 'transaction_date', + header: ({ column }) => , + enableSorting: false, + enableHiding: false, + meta: { + headerClassName: 'w-[250px]' + }, + cell: ({ row }) => { + // Memformat tanggal dan waktu dari ISO ke format biasa (DD-MM-YYYY HH:MM:SS) + const transactionDate = new Date(row.original.transaction_date); + const formattedDateTime = transactionDate.toLocaleString('en-GB', { + day: '2-digit', + month: '2-digit', + year: 'numeric', + hour: '2-digit', + minute: '2-digit', + second: '2-digit', + hour12: false // Gunakan format 24 jam + }); + return formattedDateTime; // Format DD-MM-YYYY HH:MM:SS (menggunakan waktu yang sudah ada) + } + }, + { + accessorKey: 'origin_customer.fullname', + header: ({ column }) => , + enableSorting: false, + enableHiding: false, + meta: { + headerClassName: 'w-[250px]' + } + }, + { + accessorFn: (row) => { + const purchaseAmount = row?.purchase?.amount; + const transferAmount = row?.transfer?.amount; + + return new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' }).format(purchaseAmount ?? transferAmount ?? 0); + }, + id: 'amount', + header: ({ column }) => , + enableSorting: false, + enableHiding: false, + meta: { + headerClassName: 'w-[250px]', + }, + }, + { + accessorFn: (row) => { + const purchaseAmount = row?.purchase?.fee_amount; + const transferAmount = row?.transfer?.fee_amount; + + return new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' }).format(purchaseAmount ?? transferAmount ?? 0); + }, + id: 'feeamount', + header: ({ column }) => , + enableSorting: false, + enableHiding: false, + meta: { + headerClassName: 'w-[250px]', + }, + }, + { + accessorFn: (row) => { + let status; + if (row.status === 'C') { + status = 'COMPLETE'; + } else if (row.status === 'F') { + status = 'FAILED'; + } else if (row.status === 'O') { + status = 'ON PROCESS'; + } else { + status = 'PENDING'; + } + return status; + }, + accessorKey: 'status', + header: ({ column }) => , + enableSorting: false, + enableHiding: false, + meta: { + headerClassName: 'w-[250px]', + }, + }, + { + accessorKey: 'description', + header: ({ column }) => , + enableSorting: false, + enableHiding: false, + meta: { + headerClassName: 'w-[250px]' + } + }, + { + accessorKey: 'type.name', + header: ({ column }) => , + enableSorting: false, + enableHiding: false, + meta: { + headerClassName: 'w-[250px]' + } + }, + { + id: 'actions', + header: ({ column }) => , + enableSorting: false, + enableHiding: false, + cell: (data) => { + const row = data.row.original; + return ( +
+ +
+ ); + }, + meta: { + headerClassName: 'w-[100px]', + cellClassName: 'text-center' + } + } + ], + []); + + const getTransactionLists = async (page: number, limit: number, sorting: any, filter: any) => { + try { + let startdate; + let enddate; + let formattedFilter; + + if (filter == undefined || filter.length == 0) { + const today = new Date(); + const nextWeek = new Date(); + nextWeek.setDate(today.getDate() + 7); + + startdate = today.toISOString().split('T')[0]; + enddate = nextWeek.toISOString().split('T')[0]; + } else if (filter != undefined || filter.length != 0) { + startdate = filter[0].value.from; + enddate = filter[0].value.to; + } + + formattedFilter = { + "Transactions.transaction_date": { + from: startdate + " 00:00:00", + to: enddate + " 23:59:59" + } + }; + + const response = await GetData(`${API_URL}/transaction/history`, { + limit, + page: page + 1, + with_deleted: false, + order_field: "Transactions.created_at", + order_direction: 'DESC', + filter: JSON.stringify(formattedFilter) + }); + + setTransaction(response?.data.list); + return { data: response?.data.list, totalCount: response?.data.total_count }; + } catch (error) { + console.error('Error fetching transaction', error); + } + }; + + return ( + + + + + } + layout={{ card: true }} + sorting={[{ id: 'id', desc: false }]} + serverSide={true} + onFetchData={({ pageIndex, pageSize, sorting, columnFilters }) => + getTransactionLists(pageIndex, pageSize, sorting, columnFilters) + } + > + {children} + + + ); +}; + +export { ApprovalTransactionProvider, ManageApprovalTransactionContext }; +export type { ApprovalTransactionProps }; diff --git a/src/pages/transaction/approval-transaction/hooks/useApprovalTransactionContext.tsx b/src/pages/transaction/approval-transaction/hooks/useApprovalTransactionContext.tsx new file mode 100644 index 0000000..3f93690 --- /dev/null +++ b/src/pages/transaction/approval-transaction/hooks/useApprovalTransactionContext.tsx @@ -0,0 +1,12 @@ +import { useContext } from 'react'; +import { ManageApprovalTransactionContext } from './ApprovalTransactionContext'; + +const useTransactionContext = () => { + const context = useContext(ManageApprovalTransactionContext); + + if (!context) throw new Error('useTransactionContext must be used within AuthProvider'); + + return context; +}; + +export { useTransactionContext }; diff --git a/src/pages/transaction/Transaction.tsx b/src/pages/transaction/history-transaction/Transaction.tsx similarity index 93% rename from src/pages/transaction/Transaction.tsx rename to src/pages/transaction/history-transaction/Transaction.tsx index 9456873..3afcc68 100644 --- a/src/pages/transaction/Transaction.tsx +++ b/src/pages/transaction/history-transaction/Transaction.tsx @@ -17,7 +17,7 @@ const Transaction = () => { - Transaction + History Transaction
diff --git a/src/pages/transaction/blocks/DetailTransaction.tsx b/src/pages/transaction/history-transaction/blocks/DetailTransaction.tsx similarity index 93% rename from src/pages/transaction/blocks/DetailTransaction.tsx rename to src/pages/transaction/history-transaction/blocks/DetailTransaction.tsx index ec5dd9f..5f3ad0d 100644 --- a/src/pages/transaction/blocks/DetailTransaction.tsx +++ b/src/pages/transaction/history-transaction/blocks/DetailTransaction.tsx @@ -208,8 +208,44 @@ const DetailTransaction = () => {
)} + {activeTab === 'detail' && transactionDetails?.kind === 'P' && ( +
+

+ Product Information + + Product Info + +

+
+
+

Product Name

+

{transactionDetails?.purchase.product.name}

+
+
+

Price Cash

+ {new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' }).format(transactionDetails?.purchase.product.price_cash)} +
+
+

Price Point

+ {new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' }).format(transactionDetails?.purchase.product.price_point)} +
+
+

Product Type

+

{transactionDetails?.purchase.product.type}

+
+
+

Provider Name

+

{transactionDetails?.purchase.product.provider.description}

+
+
+

Provider Type

+

{transactionDetails?.purchase.product.provider.type}

+
+
+
+ )} - {activeTab === 'detail' && transactionDetails?.kind != 'P' && transactionDetails?.transfer!=null && ( + {activeTab === 'detail' && transactionDetails?.kind != 'P' && transactionDetails?.transfer != null && (

Transaction Information diff --git a/src/pages/transaction/blocks/ListToolbar.tsx b/src/pages/transaction/history-transaction/blocks/ListToolbar.tsx similarity index 100% rename from src/pages/transaction/blocks/ListToolbar.tsx rename to src/pages/transaction/history-transaction/blocks/ListToolbar.tsx diff --git a/src/pages/transaction/hooks/TransactionContext.tsx b/src/pages/transaction/history-transaction/hooks/TransactionContext.tsx similarity index 100% rename from src/pages/transaction/hooks/TransactionContext.tsx rename to src/pages/transaction/history-transaction/hooks/TransactionContext.tsx diff --git a/src/pages/transaction/hooks/useTransactionContext.tsx b/src/pages/transaction/history-transaction/hooks/useTransactionContext.tsx similarity index 100% rename from src/pages/transaction/hooks/useTransactionContext.tsx rename to src/pages/transaction/history-transaction/hooks/useTransactionContext.tsx diff --git a/src/routing/AppRoutingSetup.tsx b/src/routing/AppRoutingSetup.tsx index ae1b8ed..01bd4f6 100644 --- a/src/routing/AppRoutingSetup.tsx +++ b/src/routing/AppRoutingSetup.tsx @@ -8,7 +8,8 @@ import { ErrorsRouting } from '@/errors'; import DashboardHomePage from '@/pages/dashboards/home/DashboardHomePage'; import ManageUserPage from '@/pages/settings/user/manage-user/ManageUserPage'; -import Transaction from '@/pages/transaction/Transaction'; +import Transaction from '@/pages/transaction/history-transaction/Transaction'; +import ApprovalTransaction from '@/pages/transaction/approval-transaction/ApprovalTransaction'; import LogActivityPage from '@/pages/settings/user/log-activity/LogActivityPage'; import ManagePositionPage from '@/pages/settings/user/manage-position/ManagePositionPage'; import ManageAccount from '@/pages/account/manage-account/ManageAccount'; @@ -85,6 +86,7 @@ const AppRoutingSetup = (): ReactElement => { } /> } /> + } /> } /> } /> } /> From 96cd2378ab33993bf8339461141f36bd5f6792ca Mon Sep 17 00:00:00 2001 From: Wikzyy Date: Mon, 7 Apr 2025 14:29:09 +0700 Subject: [PATCH 02/19] Update API call for fetching sucos and modify payload structure - Change `with_deleted` from true to false when fetching sucos - Update payload sent to API to include only name, description, and status --- .../master/sucos/hooks/ManageSucosContext.tsx | 2 +- src/pages/master/wallet/blocks/EditDialog.tsx | 37 +++++++++---------- 2 files changed, 18 insertions(+), 21 deletions(-) diff --git a/src/pages/master/sucos/hooks/ManageSucosContext.tsx b/src/pages/master/sucos/hooks/ManageSucosContext.tsx index 81e38a6..6a888b1 100644 --- a/src/pages/master/sucos/hooks/ManageSucosContext.tsx +++ b/src/pages/master/sucos/hooks/ManageSucosContext.tsx @@ -153,7 +153,7 @@ const ManageSucosContextProvider = ({ children }: { children: React.ReactNode }) const response = await GetData(`${API_URL}/sucos/list`, { limit: limit, page: page + 1, - with_deleted: true, + with_deleted: false, order_field: sorting[0].id, order_direction: sorting[0].desc == false ? 'ASC' : 'DESC', filter: JSON.stringify(filter) diff --git a/src/pages/master/wallet/blocks/EditDialog.tsx b/src/pages/master/wallet/blocks/EditDialog.tsx index c5faae1..16bebcb 100644 --- a/src/pages/master/wallet/blocks/EditDialog.tsx +++ b/src/pages/master/wallet/blocks/EditDialog.tsx @@ -53,13 +53,11 @@ const EditDialog = () => { description: string; status: string; group: string[]; - currency_id: string; } = { name: '', description: '', status: '', - group: [], - currency_id: '' + group: [] }; const [formField, setFormField] = useState(initialState); const [currencies, setCurrencies] = useState([]); @@ -71,12 +69,12 @@ const EditDialog = () => { }; const doUpdateWallet = useCallback( - async (e: React.FormEvent) => { - e.preventDefault(); + async (payload: { name: string; description: string; status: string }) => { + // e.preventDefault(); const response = await PutData( `${API_URL_MASTER_DATA}/wallet/update/${selectedWallet?.Wallet_id}`, - formField + payload ); if (response?.status) { @@ -94,8 +92,14 @@ const EditDialog = () => { const handleSubmit = (e: React.FormEvent) => { e.preventDefault(); - console.log(formField); - doUpdateWallet(e); + // const { name, description, status } = formField; + const payload = { + name: formField.name, + description: formField.description, + status: formField.status + }; + // console.log(payload); + doUpdateWallet(payload); setAlert({ show: false, message: '' }); }; @@ -156,8 +160,6 @@ const EditDialog = () => { .map((g) => g.name) .join(', '); - const selectedCurrency = currencies.find((currency) => currency.ID === formField.currency_id); - useEffect(() => { getCurrencyLists([{ id: 'name', desc: false }]); getGroupLists([{ id: 'name', desc: false }]); @@ -182,7 +184,7 @@ const EditDialog = () => { resetForm(); } }, [showEditDialog]); - // console.log(selectedWallet); + return ( handleEditDialog(open, null)}> @@ -246,17 +248,10 @@ const EditDialog = () => {

-
-
- - -
-
-
- +
@@ -264,7 +259,9 @@ const EditDialog = () => { - + From b24e6f4e18b65eba848d74f015963d7d9b56b50c Mon Sep 17 00:00:00 2001 From: bagusajisaputroo Date: Mon, 7 Apr 2025 14:59:06 +0700 Subject: [PATCH 03/19] fix wallet history --- .../wallet-history/blocks/ListToolbar.tsx | 8 +- .../hooks/ManageWalletHistoryContext.tsx | 151 +++++++++++++----- 2 files changed, 117 insertions(+), 42 deletions(-) diff --git a/src/pages/wallet/wallet-history/blocks/ListToolbar.tsx b/src/pages/wallet/wallet-history/blocks/ListToolbar.tsx index 9b239b2..546a14a 100644 --- a/src/pages/wallet/wallet-history/blocks/ListToolbar.tsx +++ b/src/pages/wallet/wallet-history/blocks/ListToolbar.tsx @@ -11,15 +11,15 @@ const ListToolbar = () => {
- */} {/* + + + ); + }, + meta: { + headerClassName: 'w-[150px]' + } } - // { - // id: 'actions', - // header: ({ column }) => , - // cell: (data) => { - // const row = data.row.original; - // return ( - // <> - // - // - // - // ); - // }, - // meta: { - // headerClassName: 'w-[150px]' - // } - // } ], [] ); + + const getWalletLists = async (page: number, limit: number, sorting: any, filter: any) => { try { sorting = sorting.length == 0 ? [{ id: 'name', desc: false }] : sorting; filter = filter.length == 0 ? {} : { name: filter[0].value?.toLowerCase() }; - const response = await GetData(`${API_URL_WALLET}/dashboard/wallet`, { + const response = await GetData(`${API_URL_WALLET}/dashboard/balance/`, { limit, page: page + 1, with_deleted: false, @@ -167,7 +242,7 @@ const ManageWalletContextProvider = ({ children }: { children: React.ReactNode } order_direction: sorting[0].desc == false ? 'ASC' : 'DESC', // filter: JSON.stringify(filter) }); - console.log(response?.data); + // console.log(response?.data); setWallets(response?.data.list); return { data: response?.data.list, totalCount: response?.data.total_count }; } catch (error) { @@ -192,7 +267,7 @@ const ManageWalletContextProvider = ({ children }: { children: React.ReactNode } } layout={{ card: true }} sorting={[{ id: 'id', desc: false }]} From 61211e7e1663c6ec4eb813ec8860c926288f2670 Mon Sep 17 00:00:00 2001 From: Wikzyy Date: Mon, 7 Apr 2025 15:06:20 +0700 Subject: [PATCH 04/19] add activity dialog on municipios, postoadm, sucos, and aldeias --- src/pages/master/aldeias/blocks/AddDialog.tsx | 10 +++++++++- src/pages/master/aldeias/blocks/EditDialog.tsx | 8 ++++++++ src/pages/master/municipios/blocks/AddDialog.tsx | 12 ++++++------ src/pages/master/municipios/blocks/EditDialog.tsx | 12 ++++++------ src/pages/master/postoadms/blocks/AddDialog.tsx | 10 +++++++++- src/pages/master/postoadms/blocks/EditDialog.tsx | 9 +++++++++ src/pages/master/sucos/blocks/AddDialog.tsx | 10 +++++++++- src/pages/master/sucos/blocks/EditDialog.tsx | 8 ++++++++ 8 files changed, 64 insertions(+), 15 deletions(-) diff --git a/src/pages/master/aldeias/blocks/AddDialog.tsx b/src/pages/master/aldeias/blocks/AddDialog.tsx index f678f33..97c40b2 100644 --- a/src/pages/master/aldeias/blocks/AddDialog.tsx +++ b/src/pages/master/aldeias/blocks/AddDialog.tsx @@ -24,6 +24,7 @@ import { CommandItem, CommandList } from '@/components/ui/command'; +import { doSaveLogActivity } from '@/actions/GlobalActions'; interface SucosProps { sucos_id: number; @@ -34,7 +35,7 @@ const API_URL = apiConfig.service_master_data; const AddDialog = () => { const parentRef = useRef(null); - const { showAddDialog, handleAddDialog } = useManageAldeiasContext(); + const { showAddDialog, handleAddDialog, selectedAldeias } = useManageAldeiasContext(); const { reload } = useDataGrid(); const { PostData, GetData } = useCallApi(); const parsedUser = getAuth()?.user; @@ -70,6 +71,13 @@ const AddDialog = () => { handleAddDialog(false); toast.success('Success Create Aldeias'); reload(); + const createActivity = { + module: 'Manage Aldeias', + description: `Create Aldeias => ${selectedAldeias}`, + action: 'C' + }; + + doSaveLogActivity(createActivity); } else { toast.error('Error Create Aldeias'); setAlert({ show: true, message: 'Failed to create Aldeias. Please try again.' }); diff --git a/src/pages/master/aldeias/blocks/EditDialog.tsx b/src/pages/master/aldeias/blocks/EditDialog.tsx index 449197d..fd4f29a 100644 --- a/src/pages/master/aldeias/blocks/EditDialog.tsx +++ b/src/pages/master/aldeias/blocks/EditDialog.tsx @@ -24,6 +24,7 @@ import { CommandItem, CommandList } from '@/components/ui/command'; +import { doSaveLogActivity } from '@/actions/GlobalActions'; interface SucosProps { sucos_id: number; @@ -69,6 +70,13 @@ const EditDialog = () => { handleEditDialog(false, null); toast.success('Success Update Aldeias'); reload(); + const createActivity = { + module: 'Manage Aldeias', + description: `Edit Aldeias => ${selectedAldeias}`, + action: 'U' + }; + + doSaveLogActivity(createActivity); } else { toast.error('Error Update Aldeias'); setAlert({ show: true, message: 'Error Update Aldeias' }); diff --git a/src/pages/master/municipios/blocks/AddDialog.tsx b/src/pages/master/municipios/blocks/AddDialog.tsx index d2dfda4..5afd080 100644 --- a/src/pages/master/municipios/blocks/AddDialog.tsx +++ b/src/pages/master/municipios/blocks/AddDialog.tsx @@ -55,13 +55,13 @@ const AddDialog = () => { resetForm(); reload(); toast.success('Municipio created successfully!'); - // const createActivity = { - // module: 'Manage Municipio', - // description: `Create Municipio => ${selectedMunicipios}`, - // action: 'C' - // }; + const createActivity = { + module: 'Manage Municipio', + description: `Create Municipio => ${selectedMunicipios}`, + action: 'C' + }; - // doSaveLogActivity(createActivity); + doSaveLogActivity(createActivity); } else { toast.error('Failed to create municipio.'); setAlert({ show: true, message: 'Failed to create municipio. Please try again.' }); diff --git a/src/pages/master/municipios/blocks/EditDialog.tsx b/src/pages/master/municipios/blocks/EditDialog.tsx index 50406bc..72995d4 100644 --- a/src/pages/master/municipios/blocks/EditDialog.tsx +++ b/src/pages/master/municipios/blocks/EditDialog.tsx @@ -60,13 +60,13 @@ const EditDialog = () => { resetForm(); toast.success('Success update municipio'); reload(); - // const createActivity = { - // module: 'Manage Municipio', - // description: `Edit Municipio => ${selectedMunicipios}`, - // action: 'U' - // }; + const createActivity = { + module: 'Manage Municipio', + description: `Edit Municipio => ${selectedMunicipios}`, + action: 'U' + }; - // doSaveLogActivity(createActivity); + doSaveLogActivity(createActivity); } else { toast.error('Failed update user'); setAlert({ show: true, message: 'Failed to update municipio. Please try again.' }); diff --git a/src/pages/master/postoadms/blocks/AddDialog.tsx b/src/pages/master/postoadms/blocks/AddDialog.tsx index eaa8b1e..d489f75 100644 --- a/src/pages/master/postoadms/blocks/AddDialog.tsx +++ b/src/pages/master/postoadms/blocks/AddDialog.tsx @@ -24,6 +24,7 @@ import { CommandItem, CommandList } from '@/components/ui/command'; +import { doSaveLogActivity } from '@/actions/GlobalActions'; interface MunicipioProps { id: number; @@ -34,7 +35,7 @@ const API_URL = apiConfig.service_master_data; const AddDialog = () => { const parentRef = useRef(null); - const { showAddDialog, handleAddDialog } = useManagePostoAdmsContext(); + const { showAddDialog, handleAddDialog, selectedPostoAdms } = useManagePostoAdmsContext(); const { reload } = useDataGrid(); const { PostData, GetData } = useCallApi(); const parsedUser = getAuth()?.user; @@ -72,6 +73,13 @@ const AddDialog = () => { resetForm(); reload(); toast.success('Posto Adm created successfully!'); + const createActivity = { + module: 'Manage Posto Administrativo', + description: `Create PostoAdms => ${selectedPostoAdms}`, + action: 'C' + }; + + doSaveLogActivity(createActivity); } else { toast.error('Failed to create Posto Adm. Please try again.'); setAlert({ show: true, message: 'Failed to create Posto Adm. Please try again.' }); diff --git a/src/pages/master/postoadms/blocks/EditDialog.tsx b/src/pages/master/postoadms/blocks/EditDialog.tsx index d170d1a..532403b 100644 --- a/src/pages/master/postoadms/blocks/EditDialog.tsx +++ b/src/pages/master/postoadms/blocks/EditDialog.tsx @@ -24,6 +24,7 @@ import { CommandItem, CommandList } from '@/components/ui/command'; +import { doSaveLogActivity } from '@/actions/GlobalActions'; interface MunicipioProps { id: number; @@ -72,6 +73,14 @@ const EditDialog = () => { resetForm(); toast.success('Success Update Posto Adm'); reload(); + + const createActivity = { + module: 'Manage Posto Administrativo', + description: `Edit PostoAdms => ${selectedPostoAdms}`, + action: 'U' + }; + + doSaveLogActivity(createActivity); } else { toast.error('Error Update Posto Adm'); setAlert({ show: true, message: 'Failed to update posto adm. Please try again.' }); diff --git a/src/pages/master/sucos/blocks/AddDialog.tsx b/src/pages/master/sucos/blocks/AddDialog.tsx index 4436fd1..7db4e9a 100644 --- a/src/pages/master/sucos/blocks/AddDialog.tsx +++ b/src/pages/master/sucos/blocks/AddDialog.tsx @@ -24,6 +24,7 @@ import { CommandItem, CommandList } from '@/components/ui/command'; +import { doSaveLogActivity } from '@/actions/GlobalActions'; interface PostoAdmsProps { PostoAdms_id: number; @@ -33,7 +34,7 @@ const API_URL = apiConfig.service_master_data; const AddDialog = () => { const parentRef = useRef(null); - const { showAddDialog, handleAddDialog } = useManageSucosContext(); + const { showAddDialog, handleAddDialog, selectedSucos } = useManageSucosContext(); const { reload } = useDataGrid(); const { PostData, GetData } = useCallApi(); const parsedUser = getAuth()?.user; @@ -69,6 +70,13 @@ const AddDialog = () => { handleAddDialog(false); reload(); toast.success('Sucos created successfully!'); + const createActivity = { + module: 'Manage Sucos', + description: `Create Sucos => ${selectedSucos}`, + action: 'C' + }; + + doSaveLogActivity(createActivity); } else { toast.error('Failed to create Sucos Please try again.'); setAlert({ show: true, message: 'Failed to create Sucos Please try again.' }); diff --git a/src/pages/master/sucos/blocks/EditDialog.tsx b/src/pages/master/sucos/blocks/EditDialog.tsx index 68b7bcd..a8d865d 100644 --- a/src/pages/master/sucos/blocks/EditDialog.tsx +++ b/src/pages/master/sucos/blocks/EditDialog.tsx @@ -24,6 +24,7 @@ import { CommandItem, CommandList } from '@/components/ui/command'; +import { doSaveLogActivity } from '@/actions/GlobalActions'; interface PostoAdmsProps { PostoAdms_id: number; // Ubah ke PostoAdms_id @@ -76,6 +77,13 @@ const EditDialog = () => { handleEditDialog(false, null); toast.success('Success Update Sucos'); reload(); + const createActivity = { + module: 'Manage Sucos', + description: `Edit Sucos => ${selectedSucos}`, + action: 'U' + }; + + doSaveLogActivity(createActivity); } else { toast.error('Failed Update Sucos'); setAlert({ show: true, message: 'Failed Update Sucos. Please try again' }); From 5e719eefa2fd280b880ef4184c71085f7cd752b3 Mon Sep 17 00:00:00 2001 From: Wikzyy Date: Mon, 7 Apr 2025 15:20:35 +0700 Subject: [PATCH 05/19] add activity dialog on master data module --- src/pages/master/aldeias/blocks/AddDialog.tsx | 2 +- .../master/aldeias/blocks/DeleteDialog.tsx | 9 ++++++ .../master/aldeias/blocks/EditDialog.tsx | 2 +- .../master/municipios/blocks/AddDialog.tsx | 2 +- .../master/municipios/blocks/DeleteDialog.tsx | 25 +++++++++++---- .../master/municipios/blocks/EditDialog.tsx | 2 +- .../master/postoadms/blocks/DeleteDialog.tsx | 24 +++++++++++--- .../master/products/blocks/AddDialog.tsx | 31 +++++++++---------- .../master/products/blocks/DeleteDialog.tsx | 17 +++++++++- .../master/products/blocks/EditDialog.tsx | 9 ++++++ .../master/profession/blocks/AddDialog.tsx | 11 ++++++- .../master/profession/blocks/DeleteDialog.tsx | 17 +++++++++- .../master/profession/blocks/EditDialog.tsx | 9 ++++++ src/pages/master/sucos/blocks/AddDialog.tsx | 2 +- .../master/sucos/blocks/DeleteDialog.tsx | 17 +++++++++- src/pages/master/sucos/blocks/EditDialog.tsx | 2 +- src/pages/master/wallet/blocks/AddDialog.tsx | 11 ++++++- src/pages/master/wallet/blocks/EditDialog.tsx | 9 ++++++ .../master/walletRule/blocks/AddDialog.tsx | 11 ++++++- .../master/walletRule/blocks/DeleteDialog.tsx | 8 +++++ .../master/walletRule/blocks/EditDialog.tsx | 9 ++++++ 21 files changed, 190 insertions(+), 39 deletions(-) diff --git a/src/pages/master/aldeias/blocks/AddDialog.tsx b/src/pages/master/aldeias/blocks/AddDialog.tsx index 97c40b2..cc2619a 100644 --- a/src/pages/master/aldeias/blocks/AddDialog.tsx +++ b/src/pages/master/aldeias/blocks/AddDialog.tsx @@ -73,7 +73,7 @@ const AddDialog = () => { reload(); const createActivity = { module: 'Manage Aldeias', - description: `Create Aldeias => ${selectedAldeias}`, + description: `Create Aldeia => ${selectedAldeias}`, action: 'C' }; diff --git a/src/pages/master/aldeias/blocks/DeleteDialog.tsx b/src/pages/master/aldeias/blocks/DeleteDialog.tsx index 17c4954..9293c89 100644 --- a/src/pages/master/aldeias/blocks/DeleteDialog.tsx +++ b/src/pages/master/aldeias/blocks/DeleteDialog.tsx @@ -6,6 +6,7 @@ import { useCallback, useState } from 'react'; import { toast } from 'sonner'; import { Dialog, DialogContent, DialogFooter, DialogHeader } from '@/components/ui/dialog'; import { Button } from '@/components/ui/button'; +import { doSaveLogActivity } from '@/actions/GlobalActions'; const API_URL = apiConfig.service_master_data; @@ -33,6 +34,14 @@ const DeleteDialog = () => { handleDeleteDialog(false, null); toast.success('Success Delete Aldeias'); reload(); + + const createActivity = { + module: 'Manage Aldeias', + description: `Edit Aldeia => ${selectedAldeias}`, + action: 'D' + }; + + doSaveLogActivity(createActivity); } else { setAlert({ show: true, message: response?.message }); toast.error('Failed Delete Aldeias'); diff --git a/src/pages/master/aldeias/blocks/EditDialog.tsx b/src/pages/master/aldeias/blocks/EditDialog.tsx index fd4f29a..79eb0ce 100644 --- a/src/pages/master/aldeias/blocks/EditDialog.tsx +++ b/src/pages/master/aldeias/blocks/EditDialog.tsx @@ -72,7 +72,7 @@ const EditDialog = () => { reload(); const createActivity = { module: 'Manage Aldeias', - description: `Edit Aldeias => ${selectedAldeias}`, + description: `Edit Aldeia => ${selectedAldeias}`, action: 'U' }; diff --git a/src/pages/master/municipios/blocks/AddDialog.tsx b/src/pages/master/municipios/blocks/AddDialog.tsx index 5afd080..61a6b3a 100644 --- a/src/pages/master/municipios/blocks/AddDialog.tsx +++ b/src/pages/master/municipios/blocks/AddDialog.tsx @@ -56,7 +56,7 @@ const AddDialog = () => { reload(); toast.success('Municipio created successfully!'); const createActivity = { - module: 'Manage Municipio', + module: 'Manage Municipios', description: `Create Municipio => ${selectedMunicipios}`, action: 'C' }; diff --git a/src/pages/master/municipios/blocks/DeleteDialog.tsx b/src/pages/master/municipios/blocks/DeleteDialog.tsx index f7e6f5d..ee742f5 100644 --- a/src/pages/master/municipios/blocks/DeleteDialog.tsx +++ b/src/pages/master/municipios/blocks/DeleteDialog.tsx @@ -4,9 +4,16 @@ import { useCallback, useState } from 'react'; import { apiConfig } from '@/config/api.config'; import { useCallApi } from '@/hooks'; import { toast } from 'sonner'; -import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle } from '@/components/ui/dialog'; +import { + Dialog, + DialogContent, + DialogFooter, + DialogHeader, + DialogTitle +} from '@/components/ui/dialog'; import { Button } from '@/components/ui/button'; import { DialogDescription } from '@radix-ui/react-dialog'; +import { doSaveLogActivity } from '@/actions/GlobalActions'; const API_URL = apiConfig.service_master_data; @@ -25,16 +32,23 @@ const DeleteDialog = () => { return; } - const response = await DeleteData( - `${API_URL}/municipios/delete/${selectedMunicipios}/false`, - { id: selectedMunicipios } - ); + const response = await DeleteData(`${API_URL}/municipios/delete/${selectedMunicipios}/false`, { + id: selectedMunicipios + }); if (response?.status) { setAlert({ show: false, message: '' }); handleDeleteDialog(false, null); toast.success('Success Delete Municipio'); reload(); + + const createActivity = { + module: 'Manage Municipios', + description: `Edit Municipio',', => ${selectedMunicipios}`, + action: 'D' + }; + + doSaveLogActivity(createActivity); } else { setAlert({ show: true, message: response?.message }); toast.error('Failed Delete Municipio'); @@ -43,7 +57,6 @@ const DeleteDialog = () => { return ( handleDeleteDialog(open, null)}> - diff --git a/src/pages/master/municipios/blocks/EditDialog.tsx b/src/pages/master/municipios/blocks/EditDialog.tsx index 72995d4..e7365c5 100644 --- a/src/pages/master/municipios/blocks/EditDialog.tsx +++ b/src/pages/master/municipios/blocks/EditDialog.tsx @@ -61,7 +61,7 @@ const EditDialog = () => { toast.success('Success update municipio'); reload(); const createActivity = { - module: 'Manage Municipio', + module: 'Manage Municipios', description: `Edit Municipio => ${selectedMunicipios}`, action: 'U' }; diff --git a/src/pages/master/postoadms/blocks/DeleteDialog.tsx b/src/pages/master/postoadms/blocks/DeleteDialog.tsx index fca5448..eaca302 100644 --- a/src/pages/master/postoadms/blocks/DeleteDialog.tsx +++ b/src/pages/master/postoadms/blocks/DeleteDialog.tsx @@ -4,8 +4,16 @@ import { useCallApi } from '@/hooks'; import { useCallback, useState } from 'react'; import { apiConfig } from '@/config/api.config'; import { toast } from 'sonner'; -import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from '@/components/ui/dialog'; +import { + Dialog, + DialogContent, + DialogDescription, + DialogFooter, + DialogHeader, + DialogTitle +} from '@/components/ui/dialog'; import { Button } from '@/components/ui/button'; +import { doSaveLogActivity } from '@/actions/GlobalActions'; const API_URL = apiConfig.service_master_data; @@ -24,16 +32,22 @@ const DeleteDialog = () => { return; } - const response = await DeleteData( - `${API_URL}/postoadms/delete/${selectedPostoAdms}/false`, - { id: selectedPostoAdms } - ); + const response = await DeleteData(`${API_URL}/postoadms/delete/${selectedPostoAdms}/false`, { + id: selectedPostoAdms + }); if (response?.status) { setAlert({ show: false, message: '' }); handleDeleteDialog(false, null); toast.success('Success Delete Posto Adm'); reload(); + const createActivity = { + module: 'Manage Posto Administrativo', + description: `Edit PostoAdms => ${selectedPostoAdms}`, + action: 'D' + }; + + doSaveLogActivity(createActivity); } else { setAlert({ show: true, message: response?.message }); toast.error('Failed Delete Posto Adm'); diff --git a/src/pages/master/products/blocks/AddDialog.tsx b/src/pages/master/products/blocks/AddDialog.tsx index f5b7a57..ad917e2 100644 --- a/src/pages/master/products/blocks/AddDialog.tsx +++ b/src/pages/master/products/blocks/AddDialog.tsx @@ -22,6 +22,7 @@ import { SelectTrigger, SelectValue } from '@/components/ui/select'; +import { doSaveLogActivity } from '@/actions/GlobalActions'; interface ProviderProps { provider_id: number; @@ -32,7 +33,7 @@ const API_URL = apiConfig.service_master_data; const AddDialog = () => { const parentRef = useRef(null); const parsedUser = getAuth()?.user; - const { showAddDialog, handleAddDialog } = useManageProductsContext(); + const { showAddDialog, handleAddDialog, selectedProducts } = useManageProductsContext(); const { PostData, GetData } = useCallApi(); const { reload } = useDataGrid(); const [alert, setAlert] = useState({ @@ -75,6 +76,14 @@ const AddDialog = () => { handleAddDialog(false); toast.success('Success Create Product'); reload(); + + const createActivity = { + module: 'Manage Products', + description: `Create Product => ${selectedProducts}`, + action: 'C' + }; + + doSaveLogActivity(createActivity); } else { toast.error('Failed Create Product'); setAlert({ show: true, message: response?.message }); @@ -173,9 +182,7 @@ const AddDialog = () => { className="input" type="text" value={formField.name} - onChange={(e) => - setFormField({ ...formField, name: e.target.value }) - } + onChange={(e) => setFormField({ ...formField, name: e.target.value })} />
@@ -189,9 +196,7 @@ const AddDialog = () => { className="input" type="text" value={formField.type} - onChange={(e) => - setFormField({ ...formField, type: e.target.value }) - } + onChange={(e) => setFormField({ ...formField, type: e.target.value })} />
@@ -205,9 +210,7 @@ const AddDialog = () => { className="input" type="text" value={formField.code} - onChange={(e) => - setFormField({ ...formField, code: e.target.value }) - } + onChange={(e) => setFormField({ ...formField, code: e.target.value })} /> @@ -221,9 +224,7 @@ const AddDialog = () => { className="input" type="text" value={formField.description} - onChange={(e) => - setFormField({ ...formField, description: e.target.value }) - } + onChange={(e) => setFormField({ ...formField, description: e.target.value })} /> @@ -323,9 +324,7 @@ const AddDialog = () => { table.getColumn('name')?.setFilterValue(event.target.value)} + value={(table.getColumn('provider_name')?.getFilterValue() as string) ?? ''} + onChange={(event) => + table.getColumn('provider_name')?.setFilterValue(event.target.value) + } /> {/* diff --git a/src/pages/master/provider/hooks/ManageProviderContext.tsx b/src/pages/master/provider/hooks/ManageProviderContext.tsx index 0116b1d..7d7bb5f 100644 --- a/src/pages/master/provider/hooks/ManageProviderContext.tsx +++ b/src/pages/master/provider/hooks/ManageProviderContext.tsx @@ -75,7 +75,7 @@ const ManageProviderContextProvider = ({ children }: { children: React.ReactNode () => [ { accessorFn: (row) => row.provider_name, - id: 'name', + id: 'provider_name', header: ({ column }) => , enableSorting: true, enableHiding: false, @@ -162,8 +162,9 @@ const ManageProviderContextProvider = ({ children }: { children: React.ReactNode const getProviderLists = async (page: number, limit: number, sorting: any, filter: any) => { try { + const field = 'Provider.name'; sorting = sorting.length == 0 ? [{ id: 'name', desc: false }] : sorting; - filter = filter.length == 0 ? {} : { any: filter[0].value?.toLowerCase() }; + filter = filter.length == 0 ? {} : { [field]: filter[0].value?.toLowerCase() }; const response = await GetData(`${API_URL}/provider/list`, { limit, page: page + 1, From c274809e56fbe645d99da66604f198591b752a6f Mon Sep 17 00:00:00 2001 From: Wikzyy Date: Mon, 7 Apr 2025 17:10:17 +0700 Subject: [PATCH 09/19] fix search filter manage wallet --- src/pages/master/wallet/blocks/ListToolbar.tsx | 2 +- src/pages/master/wallet/hooks/ManageWalletContext.tsx | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pages/master/wallet/blocks/ListToolbar.tsx b/src/pages/master/wallet/blocks/ListToolbar.tsx index 0d2a427..11b5767 100644 --- a/src/pages/master/wallet/blocks/ListToolbar.tsx +++ b/src/pages/master/wallet/blocks/ListToolbar.tsx @@ -15,7 +15,7 @@ const ListToolbar = () => { table.getColumn('name')?.setFilterValue(event.target.value)} /> diff --git a/src/pages/master/wallet/hooks/ManageWalletContext.tsx b/src/pages/master/wallet/hooks/ManageWalletContext.tsx index 78bc048..0108aa4 100644 --- a/src/pages/master/wallet/hooks/ManageWalletContext.tsx +++ b/src/pages/master/wallet/hooks/ManageWalletContext.tsx @@ -146,7 +146,7 @@ const ManageWalletContextProvider = ({ children }: { children: React.ReactNode } const getWalletLists = async (page: number, limit: number, sorting: any, filter: any) => { try { sorting = sorting.length == 0 ? [{ id: 'name', desc: false }] : sorting; - filter = filter.length == 0 ? {} : { any: filter[0].value?.toLowerCase() }; + filter = filter.length == 0 ? {} : { name: filter[0].value?.toLowerCase() }; const response = await GetData(`${API_URL_MASTER_DATA}/wallet/list`, { limit, page: page + 1, @@ -183,7 +183,7 @@ const ManageWalletContextProvider = ({ children }: { children: React.ReactNode } pagination={{ size: 25 }} toolbar={} layout={{ card: true }} - sorting={[{ id: 'id', desc: false }]} + sorting={[{ id: 'name', desc: false }]} serverSide={true} onFetchData={({ pageIndex, pageSize, sorting, columnFilters }) => getWalletLists(pageIndex, pageSize, sorting, columnFilters) From c171716ee7a796e84b1fd6651f8ffbe9a2345f3d Mon Sep 17 00:00:00 2001 From: Wikzyy Date: Mon, 7 Apr 2025 17:43:33 +0700 Subject: [PATCH 10/19] fix search filter manage products --- .../master/products/hooks/ManageProductsContext.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/pages/master/products/hooks/ManageProductsContext.tsx b/src/pages/master/products/hooks/ManageProductsContext.tsx index 2de1f75..ef16f55 100644 --- a/src/pages/master/products/hooks/ManageProductsContext.tsx +++ b/src/pages/master/products/hooks/ManageProductsContext.tsx @@ -73,7 +73,7 @@ const ManageProductsContextProvider = ({ children }: { children: React.ReactNode const columns = useMemo[]>( () => [ { - accessorFn: (row) => row.products_name, + accessorFn: (row) => row.name, id: 'name', header: ({ column }) => , enableSorting: true, @@ -83,7 +83,7 @@ const ManageProductsContextProvider = ({ children }: { children: React.ReactNode } }, { - accessorFn: (row) => row.products_description, + accessorFn: (row) => row.description, id: 'description', header: ({ column }) => , enableSorting: true, @@ -93,7 +93,7 @@ const ManageProductsContextProvider = ({ children }: { children: React.ReactNode } }, { - accessorFn: (row) => row.products_price_point, + accessorFn: (row) => row.price_point, id: 'price_point', header: ({ column }) => , enableSorting: true, @@ -103,7 +103,7 @@ const ManageProductsContextProvider = ({ children }: { children: React.ReactNode } }, { - accessorFn: (row) => row.products_price_cash, + accessorFn: (row) => row.price_cash, id: 'price_cash', header: ({ column }) => , enableSorting: true, @@ -186,7 +186,7 @@ const ManageProductsContextProvider = ({ children }: { children: React.ReactNode pagination={{ size: 10 }} toolbar={} layout={{ card: true }} - sorting={[{ id: 'id', desc: false }]} + sorting={[{ id: 'Product.id', desc: false }]} serverSide={true} onFetchData={({ pageIndex, pageSize, sorting, columnFilters }) => getProductsLists(pageIndex, pageSize, sorting, columnFilters) From f1fe84bed2582ae47f5fdef3aa02c5fe31c625c0 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 7 Apr 2025 18:16:05 +0700 Subject: [PATCH 11/19] fix member --- .../manage-members/CustomerDetailModal.tsx | 79 ++++++++++++++++++- .../members/manage-members/ManageMembers.tsx | 9 ++- 2 files changed, 80 insertions(+), 8 deletions(-) diff --git a/src/pages/members/manage-members/CustomerDetailModal.tsx b/src/pages/members/manage-members/CustomerDetailModal.tsx index a14815c..08f4617 100644 --- a/src/pages/members/manage-members/CustomerDetailModal.tsx +++ b/src/pages/members/manage-members/CustomerDetailModal.tsx @@ -12,7 +12,7 @@ import { toast } from 'sonner'; const BASE_URL_MASTER_DATA = apiConfig.service_master_data; const BASE_URL_CUSTOMER = apiConfig.service_customer; -const CustomerDialog = ({ open, handleClose, handleSubmit, initialData, viewStats, handleReject, page }: any) => { +const CustomerDialog = ({ open, handleClose, handleSubmit, initialData, viewStats, handleReject, page, fetchCustomers }: any) => { const [formData, setFormData] = useState(initialData || initialMember); const [viewOnly, setViewOnly] = useState(viewStats || false); const [municipios, setMunicipios] = useState([]); @@ -262,7 +262,7 @@ const CustomerDialog = ({ open, handleClose, handleSubmit, initialData, viewStat - {getAdmAccess(page, formData)} + {getAdmAccess(page, formData, handleClose, fetchCustomers)} { page === 'kyc' ? ( <> @@ -327,9 +327,36 @@ function fileTextFile(label: string, value: any, name: string, handleChange: any ) } -function getAdmAccess(page: string, data: any) { +function getAdmAccess(page: string, data: any, handleClose: any, fetchCustomers: any) { const [dialogOpen, setDialogOpen] = useState(false); const [dialogType, setDialogType] = useState(''); + const [changeGroup, setChangeGroup] = useState(''); + const [changeGroupD, setChangeGroupD] = useState(false); + const [groups, setGroups] = useState([]); + + useEffect(() => { + fetchGroups() + }, []); + + const fetchGroups = async () =>{ + try { + let getGroups = await axios.get(`${BASE_URL_CUSTOMER}/groups/list`, { + params: { + limit: 50, + page: 1, + with_deleted: false, + order_field: 'name', + order_direction: 'ASC', + } + }); + setGroups(getGroups.data.data.list); + setChangeGroup(data.group_id); + } catch (error: any) { + console.error(error.message); + toast.error(error.message) + } + } + const handleYes = async () => { try { if (dialogType === "update status") { @@ -347,6 +374,7 @@ function getAdmAccess(page: string, data: any) { toast.error(error.message) } finally { setDialogOpen(false) + handleClose() } } @@ -360,6 +388,24 @@ function getAdmAccess(page: string, data: any) { setDialogOpen(true) } + async function buttonChangeGroup() { + try { + let dataObj = { + customerid: data.id, + destination_group: changeGroup + } + if (dataObj.customerid && dataObj.destination_group) { + await axios.post(`${BASE_URL_CUSTOMER}/customer/change-group`, dataObj) + } + await fetchCustomers() + toast.success('Success Change group') + } catch (error: any) { + toast.error(error.message) + } finally { + setChangeGroupD(false) + } + } + if (page !== "kyc") { return ( @@ -378,7 +424,7 @@ function getAdmAccess(page: string, data: any) { Change Group - + Edit Member @@ -386,6 +432,31 @@ function getAdmAccess(page: string, data: any) { + + setChangeGroupD(false)} fullWidth> + + Groups + + Destination Group + + + + + + + + + setDialogOpen(false)} diff --git a/src/pages/members/manage-members/ManageMembers.tsx b/src/pages/members/manage-members/ManageMembers.tsx index 1132b87..d985211 100644 --- a/src/pages/members/manage-members/ManageMembers.tsx +++ b/src/pages/members/manage-members/ManageMembers.tsx @@ -24,15 +24,15 @@ const ManageMembers = () => { useEffect(() => { setLoading(true); - fetchGroups(); + fetchCustomers(); setLoading(false); }, []); - async function fetchGroups() { + async function fetchCustomers() { try { let groups = await axios.get(`${BASE_URL}/customer/list`, { params: { - limit: 10, + limit: 20, page: 1, with_deleted: false, order_field: 'fullname', @@ -100,7 +100,7 @@ const ManageMembers = () => { if (dialogType === 'update') await axios.put(`${BASE_URL}/customer/update/${selectedMember}`, updateData); // if (dialogType === 'create') await axios.post(`${BASE_URL}/customers/create`, member) - await fetchGroups(); + await fetchCustomers(); setDialogOpen(false); setIsDialogOpen(false); toast.success('Success Update Member'); @@ -130,6 +130,7 @@ const ManageMembers = () => { handleClose={closeDialog} handleSubmit={handleSubmit} initialData={member} + fetchCustomers={fetchCustomers} />

Manage Members

From e2cec8ee079a6ba00d91c13fe499ded3a7116fb3 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 7 Apr 2025 18:54:11 +0700 Subject: [PATCH 12/19] fix member --- .../manage-members/CustomerDetailModal.tsx | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/pages/members/manage-members/CustomerDetailModal.tsx b/src/pages/members/manage-members/CustomerDetailModal.tsx index 08f4617..ad17ae0 100644 --- a/src/pages/members/manage-members/CustomerDetailModal.tsx +++ b/src/pages/members/manage-members/CustomerDetailModal.tsx @@ -262,14 +262,14 @@ const CustomerDialog = ({ open, handleClose, handleSubmit, initialData, viewStat - {getAdmAccess(page, formData, handleClose, fetchCustomers)} + {/* {getAdmAccess(page, formData, handleClose, fetchCustomers)} */} { page === 'kyc' ? ( <> Approval - ) : ('') + ) : (<>{getAdmAccess(page, formData, handleClose, fetchCustomers)}) } @@ -350,7 +350,6 @@ function getAdmAccess(page: string, data: any, handleClose: any, fetchCustomers: } }); setGroups(getGroups.data.data.list); - setChangeGroup(data.group_id); } catch (error: any) { console.error(error.message); toast.error(error.message) @@ -394,6 +393,7 @@ function getAdmAccess(page: string, data: any, handleClose: any, fetchCustomers: customerid: data.id, destination_group: changeGroup } + if (data.group_id === changeGroup) return toast.warning(`You update same group as the exist customer group`) if (dataObj.customerid && dataObj.destination_group) { await axios.post(`${BASE_URL_CUSTOMER}/customer/change-group`, dataObj) } @@ -406,6 +406,11 @@ function getAdmAccess(page: string, data: any, handleClose: any, fetchCustomers: } } + function openChangeGroupDialog() { + setChangeGroup(data.group_id); + setChangeGroupD(true) + } + if (page !== "kyc") { return ( @@ -424,7 +429,7 @@ function getAdmAccess(page: string, data: any, handleClose: any, fetchCustomers: Change Group - + Edit Member @@ -435,9 +440,9 @@ function getAdmAccess(page: string, data: any, handleClose: any, fetchCustomers: setChangeGroupD(false)} fullWidth> - Groups + Are you sure to change customer Group? - Destination Group + Destination Group + @@ -181,7 +188,7 @@ const CustomerDialog = ({ open, handleClose, handleSubmit, initialData, viewStat {/* AGENT & PREMIUM DATA */} - + {fileTextFile("File Selfie", formData.file_selfie, "file_selfie", handleChange)} {"file_selfie"} @@ -269,11 +276,15 @@ const CustomerDialog = ({ open, handleClose, handleSubmit, initialData, viewStat Approval - ) : (<>{getAdmAccess(page, formData, handleClose, fetchCustomers)}) + ) : (<>{getAdmAccess(page, formData, handleClose, fetchCustomers, viewOnly, setViewOnly)}) } - + { + page === 'kyc' ? ( + + ) : ('') + } { formData.isneedapproval == 1 && page === 'kyc' ? ( @@ -327,7 +338,7 @@ function fileTextFile(label: string, value: any, name: string, handleChange: any ) } -function getAdmAccess(page: string, data: any, handleClose: any, fetchCustomers: any) { +function getAdmAccess(page: string, data: any, handleClose: any, fetchCustomers: any, viewOnly: any, setViewOnly: any) { const [dialogOpen, setDialogOpen] = useState(false); const [dialogType, setDialogType] = useState(''); const [changeGroup, setChangeGroup] = useState(''); @@ -434,7 +445,8 @@ function getAdmAccess(page: string, data: any, handleClose: any, fetchCustomers: Edit Member - + {/* */} + diff --git a/src/pages/members/manage-members/ManageMembers.tsx b/src/pages/members/manage-members/ManageMembers.tsx index d985211..a258539 100644 --- a/src/pages/members/manage-members/ManageMembers.tsx +++ b/src/pages/members/manage-members/ManageMembers.tsx @@ -96,6 +96,7 @@ const ManageMembers = () => { delete updateData.group_updated_at; delete updateData.group_deleted_by; delete updateData.group_deleted_at; + delete updateData.updated_at; try { if (dialogType === 'update') await axios.put(`${BASE_URL}/customer/update/${selectedMember}`, updateData); @@ -105,7 +106,6 @@ const ManageMembers = () => { setIsDialogOpen(false); toast.success('Success Update Member'); } catch (error: any) { - alert(error.message); setDialogOpen(false); setIsDialogOpen(false); toast.error(error.message); From 23a1ae2e6d72191a1001892e125c8aba1784358b Mon Sep 17 00:00:00 2001 From: Wikzyy Date: Tue, 8 Apr 2025 09:51:45 +0700 Subject: [PATCH 17/19] update sorting and field readOnly on Manage Wallet --- src/pages/master/wallet/blocks/EditDialog.tsx | 13 +++++++++---- .../master/wallet/hooks/ManageWalletContext.tsx | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/pages/master/wallet/blocks/EditDialog.tsx b/src/pages/master/wallet/blocks/EditDialog.tsx index 09167d3..adce821 100644 --- a/src/pages/master/wallet/blocks/EditDialog.tsx +++ b/src/pages/master/wallet/blocks/EditDialog.tsx @@ -260,14 +260,19 @@ const EditDialog = () => {
- +
+ +
- diff --git a/src/pages/master/wallet/hooks/ManageWalletContext.tsx b/src/pages/master/wallet/hooks/ManageWalletContext.tsx index 0108aa4..57ae4f0 100644 --- a/src/pages/master/wallet/hooks/ManageWalletContext.tsx +++ b/src/pages/master/wallet/hooks/ManageWalletContext.tsx @@ -183,7 +183,7 @@ const ManageWalletContextProvider = ({ children }: { children: React.ReactNode } pagination={{ size: 25 }} toolbar={} layout={{ card: true }} - sorting={[{ id: 'name', desc: false }]} + sorting={[{ id: 'created_at', desc: true }]} serverSide={true} onFetchData={({ pageIndex, pageSize, sorting, columnFilters }) => getWalletLists(pageIndex, pageSize, sorting, columnFilters) From f4ea279d65b1e5c25576fd283ecbf7c669b46526 Mon Sep 17 00:00:00 2001 From: Wikzyy Date: Tue, 8 Apr 2025 09:52:14 +0700 Subject: [PATCH 18/19] fix log activity on module Manage Menu to show menu name --- src/pages/menu/manage-menu/blocks/EditDialog.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/menu/manage-menu/blocks/EditDialog.tsx b/src/pages/menu/manage-menu/blocks/EditDialog.tsx index 42142ae..e55c6bc 100644 --- a/src/pages/menu/manage-menu/blocks/EditDialog.tsx +++ b/src/pages/menu/manage-menu/blocks/EditDialog.tsx @@ -72,7 +72,7 @@ const EditDialog = () => { toast.success('Success Update Menu'); const createActivity = { module: 'Manage Menu', - description: `Update Menu => ${selectedMenu}`, + description: `Update Menu => ${selectedMenu.name}`, action: 'U' }; From 950538f7af3ac457e075d20e825a95ce412cb709 Mon Sep 17 00:00:00 2001 From: Wikzyy Date: Tue, 8 Apr 2025 10:29:41 +0700 Subject: [PATCH 19/19] update log activity object information --- src/pages/master/aldeias/blocks/AddDialog.tsx | 2 +- .../master/aldeias/blocks/DeleteDialog.tsx | 2 +- .../master/conversion/blocks/AddDialog.tsx | 55 +++++++++---------- .../master/conversion/blocks/DeleteDialog.tsx | 21 ++++--- .../master/currency/blocks/AddDialog.tsx | 12 ++-- .../master/currency/blocks/DeleteDialog.tsx | 14 ++--- .../master/municipios/blocks/AddDialog.tsx | 2 +- .../master/municipios/blocks/DeleteDialog.tsx | 2 +- .../master/postoadms/blocks/AddDialog.tsx | 2 +- .../master/postoadms/blocks/DeleteDialog.tsx | 2 +- .../master/products/blocks/AddDialog.tsx | 2 +- .../master/products/blocks/DeleteDialog.tsx | 2 +- .../master/profession/blocks/AddDialog.tsx | 2 +- .../master/profession/blocks/DeleteDialog.tsx | 2 +- .../master/provider/blocks/AddDialog.tsx | 24 ++++---- src/pages/master/sucos/blocks/AddDialog.tsx | 2 +- .../master/sucos/blocks/DeleteDialog.tsx | 2 +- .../master/walletRule/blocks/DeleteDialog.tsx | 2 +- 18 files changed, 75 insertions(+), 77 deletions(-) diff --git a/src/pages/master/aldeias/blocks/AddDialog.tsx b/src/pages/master/aldeias/blocks/AddDialog.tsx index cc2619a..38e4c1b 100644 --- a/src/pages/master/aldeias/blocks/AddDialog.tsx +++ b/src/pages/master/aldeias/blocks/AddDialog.tsx @@ -73,7 +73,7 @@ const AddDialog = () => { reload(); const createActivity = { module: 'Manage Aldeias', - description: `Create Aldeia => ${selectedAldeias}`, + description: `Create Aldeia => ${formField.name}`, action: 'C' }; diff --git a/src/pages/master/aldeias/blocks/DeleteDialog.tsx b/src/pages/master/aldeias/blocks/DeleteDialog.tsx index 9293c89..92e570e 100644 --- a/src/pages/master/aldeias/blocks/DeleteDialog.tsx +++ b/src/pages/master/aldeias/blocks/DeleteDialog.tsx @@ -37,7 +37,7 @@ const DeleteDialog = () => { const createActivity = { module: 'Manage Aldeias', - description: `Edit Aldeia => ${selectedAldeias}`, + description: `Delete Aldeia => ${selectedAldeias}`, action: 'D' }; diff --git a/src/pages/master/conversion/blocks/AddDialog.tsx b/src/pages/master/conversion/blocks/AddDialog.tsx index f516f2a..96270b1 100644 --- a/src/pages/master/conversion/blocks/AddDialog.tsx +++ b/src/pages/master/conversion/blocks/AddDialog.tsx @@ -81,13 +81,13 @@ const AddDialog = () => { resetForm(); handleAddDialog(false); toast.success('Success Create Conversion'); - const createActivity = { - module: 'Manage Conversion', - description: `Create Conversion => ${selectedConversion}`, - action: 'C' - }; - - doSaveLogActivity(createActivity); + const createActivity = { + module: 'Manage Conversion', + description: `Create Conversion => ${formField.id_currency_origin} => ${formField.id_currency_destination}`, + action: 'C' + }; + + doSaveLogActivity(createActivity); reload(); } else { toast.error('Error Create Conversion'); @@ -254,28 +254,27 @@ const AddDialog = () => { />
- - -
- -
+ +
+ +
diff --git a/src/pages/master/sucos/blocks/AddDialog.tsx b/src/pages/master/sucos/blocks/AddDialog.tsx index de45ad3..b8213cf 100644 --- a/src/pages/master/sucos/blocks/AddDialog.tsx +++ b/src/pages/master/sucos/blocks/AddDialog.tsx @@ -72,7 +72,7 @@ const AddDialog = () => { toast.success('Sucos created successfully!'); const createActivity = { module: 'Manage Sucos', - description: `Create Suco => ${selectedSucos}`, + description: `Create Suco => ${formField.name}`, action: 'C' }; diff --git a/src/pages/master/sucos/blocks/DeleteDialog.tsx b/src/pages/master/sucos/blocks/DeleteDialog.tsx index 9786b99..9d50258 100644 --- a/src/pages/master/sucos/blocks/DeleteDialog.tsx +++ b/src/pages/master/sucos/blocks/DeleteDialog.tsx @@ -41,7 +41,7 @@ const DeleteDialog = () => { reload(); const createActivity = { module: 'Manage Sucos', - description: `Edit Suco => ${selectedSucos}`, + description: `Delete Suco => ${selectedSucos}`, action: 'D' }; diff --git a/src/pages/master/walletRule/blocks/DeleteDialog.tsx b/src/pages/master/walletRule/blocks/DeleteDialog.tsx index 1602b3a..518201d 100644 --- a/src/pages/master/walletRule/blocks/DeleteDialog.tsx +++ b/src/pages/master/walletRule/blocks/DeleteDialog.tsx @@ -40,7 +40,7 @@ const DeleteDialog = () => { reload(); const createActivity = { module: 'Manage Wallet Rule', - description: `Edit Wallet Rule', => ${selectedWalletRule.ID}`, + description: `Delete Wallet Rule', => ${selectedWalletRule.ID}`, action: 'D' };