fix err
This commit is contained in:
@ -33,19 +33,19 @@ const statusMap: Record<StatusCode, StatusInfo> = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const renderStatusBadge = (statusRaw: string | null | undefined) => {
|
export const renderStatusBadge = (statusRaw: string | null | undefined) => {
|
||||||
const status = statusRaw as StatusCode;
|
const status = statusRaw as StatusCode;
|
||||||
const { label, bg, text } = statusMap[status] ?? {
|
const { label, bg, text } = statusMap[status] ?? {
|
||||||
label: 'Unknown',
|
label: 'Unknown',
|
||||||
bg: 'bg-gray-100',
|
bg: 'bg-gray-100',
|
||||||
text: 'text-gray-600',
|
text: 'text-gray-600',
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<span className={`px-2 py-1 text-xs font-semibold rounded-full ${bg} ${text}`}>
|
<span className={`px-2 py-1 text-xs font-semibold rounded-full ${bg} ${text}`}>
|
||||||
{label}
|
{label}
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const DetailTransaction = () => {
|
const DetailTransaction = () => {
|
||||||
const { GetData } = useCallApi();
|
const { GetData } = useCallApi();
|
||||||
@ -114,7 +114,7 @@ const DetailTransaction = () => {
|
|||||||
<td className="px-4 py-2 text-sm text-gray-500">{log.customer.fullname ?? '-'}</td>
|
<td className="px-4 py-2 text-sm text-gray-500">{log.customer.fullname ?? '-'}</td>
|
||||||
<td className="px-4 py-2 text-sm text-gray-500">{log.amount ?? '-'}</td>
|
<td className="px-4 py-2 text-sm text-gray-500">{log.amount ?? '-'}</td>
|
||||||
<td className="px-4 py-2 text-sm text-gray-500">{renderStatusBadge(log.status) ?? '-'}</td>
|
<td className="px-4 py-2 text-sm text-gray-500">{renderStatusBadge(log.status) ?? '-'}</td>
|
||||||
<td className="px-4 py-2 text-sm text-gray-500">{log.request_date && moment(log.request_date).isValid() ? moment(log.request_date).format('YYYY-MM-DD HH:mm:ss') : '-'}</td>
|
<td className="px-4 py-2 text-sm text-gray-500">{log.request_date && moment(log.request_date).isValid() ? moment(log.request_date).format('DD/MM/YYYY HH:mm:ss') : '-'}</td>
|
||||||
<td className="px-4 py-2 text-sm text-gray-500">{log.reference ?? '-'}</td>
|
<td className="px-4 py-2 text-sm text-gray-500">{log.reference ?? '-'}</td>
|
||||||
<td className="px-4 py-2 text-sm text-gray-500">
|
<td className="px-4 py-2 text-sm text-gray-500">
|
||||||
<div key={`actions-${log.id}`}>
|
<div key={`actions-${log.id}`}>
|
||||||
|
|||||||
@ -106,11 +106,11 @@ const TransactionLogViewer = () => {
|
|||||||
</tr>
|
</tr>
|
||||||
<tr className='border-t'>
|
<tr className='border-t'>
|
||||||
<td className="px-4 py-2 text-sm text-gray-500">Prosess Date</td>
|
<td className="px-4 py-2 text-sm text-gray-500">Prosess Date</td>
|
||||||
<td className="px-4 py-2 text-sm text-gray-500">{detailLogData.request_date && moment(detailLogData.request_date).isValid() ? moment(detailLogData.request_date).format('YYYY-MM-DD HH:mm:ss') : '-'}</td>
|
<td className="px-4 py-2 text-sm text-gray-500">{detailLogData.request_date && moment(detailLogData.request_date).isValid() ? moment(detailLogData.request_date).format('DD/MM/YYYY HH:mm:ss') : '-'}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr className='border-t'>
|
<tr className='border-t'>
|
||||||
<td className="px-4 py-2 text-sm text-gray-500">Response Date</td>
|
<td className="px-4 py-2 text-sm text-gray-500">Response Date</td>
|
||||||
<td className="px-4 py-2 text-sm text-gray-500">{detailLogData.response_date && moment(detailLogData.response_date).isValid() ? moment(detailLogData.response_date).format('YYYY-MM-DD HH:mm:ss') : '-'}</td>
|
<td className="px-4 py-2 text-sm text-gray-500">{detailLogData.response_date && moment(detailLogData.response_date).isValid() ? moment(detailLogData.response_date).format('DD/MM/YYYY HH:mm:ss') : '-'}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr className='border-t'>
|
<tr className='border-t'>
|
||||||
<td className="px-4 py-2 text-sm text-gray-500">Reference Number</td>
|
<td className="px-4 py-2 text-sm text-gray-500">Reference Number</td>
|
||||||
|
|||||||
@ -93,15 +93,6 @@ const TransactionProvider = ({ children }: { children: React.ReactNode }) => {
|
|||||||
|
|
||||||
const columns = useMemo<ColumnDef<any>[]>(
|
const columns = useMemo<ColumnDef<any>[]>(
|
||||||
() => [
|
() => [
|
||||||
// {
|
|
||||||
// accessorKey: 'transaction_date',
|
|
||||||
// header: ({ column }) => <DataGridColumnHeader title="Transaction Date" column={column} />,
|
|
||||||
// enableSorting: false,
|
|
||||||
// enableHiding: false,
|
|
||||||
// meta: {
|
|
||||||
// headerClassName: 'w-[250px]'
|
|
||||||
// }
|
|
||||||
// },
|
|
||||||
{
|
{
|
||||||
accessorKey: 'file_name',
|
accessorKey: 'file_name',
|
||||||
header: ({ column }) => <DataGridColumnHeader title="File Name" column={column} />,
|
header: ({ column }) => <DataGridColumnHeader title="File Name" column={column} />,
|
||||||
@ -192,7 +183,7 @@ const TransactionProvider = ({ children }: { children: React.ReactNode }) => {
|
|||||||
header: ({ column }) => <DataGridColumnHeader title="Execution Date" column={column} />,
|
header: ({ column }) => <DataGridColumnHeader title="Execution Date" column={column} />,
|
||||||
enableSorting: true,
|
enableSorting: true,
|
||||||
enableHiding: false,
|
enableHiding: false,
|
||||||
cell: ({ row }) => moment(row.original.execution_date).format('YYYY-MM-DD HH:mm:ss')
|
cell: ({ row }) => moment(row.original.execution_date).format('DD/MM/YYYY HH:mm:ss')
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
accessorFn: (row) => row.done_date,
|
accessorFn: (row) => row.done_date,
|
||||||
@ -200,7 +191,7 @@ const TransactionProvider = ({ children }: { children: React.ReactNode }) => {
|
|||||||
header: ({ column }) => <DataGridColumnHeader title="Done Date" column={column} />,
|
header: ({ column }) => <DataGridColumnHeader title="Done Date" column={column} />,
|
||||||
enableSorting: true,
|
enableSorting: true,
|
||||||
enableHiding: false,
|
enableHiding: false,
|
||||||
cell: ({ row }) => row.original.done_date ? moment(row.original.done_date).format('YYYY-MM-DD HH:mm:ss') : ''
|
cell: ({ row }) => row.original.done_date ? moment(row.original.done_date).format('DD/MM/YYYY HH:mm:ss') : ''
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'actions',
|
id: 'actions',
|
||||||
|
|||||||
37
src/pages/members/kyc-delete-member/ManageKycDeletion.tsx
Normal file
37
src/pages/members/kyc-delete-member/ManageKycDeletion.tsx
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
import { Container, DataGridInner } from '@/components';
|
||||||
|
import { ManageKycDeletionContextProvider } from './hooks/ManageKycDeletionContext';
|
||||||
|
import { Breadcrumbs, Link } from '@mui/material';
|
||||||
|
import { Helmet } from 'react-helmet';
|
||||||
|
|
||||||
|
const ManageKycDeletion = () => {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Helmet>
|
||||||
|
<title>TPAY | List Deletion</title>
|
||||||
|
</Helmet>
|
||||||
|
<ManageKycDeletionContextProvider>
|
||||||
|
<Container className="mb-7">
|
||||||
|
<h1 className="text-xl font-medium leading-none text-gray-900 mb-5">MANAGE KYC DELETION</h1>
|
||||||
|
<Breadcrumbs sx={{ mb: 2 }}>
|
||||||
|
<Link underline="none" color="inherit" href="/">
|
||||||
|
<span className="text-sm hover:underline">Dashboard</span>
|
||||||
|
</Link>
|
||||||
|
|
||||||
|
<Link underline="none" color="inherit">
|
||||||
|
<span className="text-sm">Member</span>
|
||||||
|
</Link>
|
||||||
|
|
||||||
|
<Link underline="none" color="inherit">
|
||||||
|
<span className="text-sm">History Disbursement</span>
|
||||||
|
</Link>
|
||||||
|
</Breadcrumbs>
|
||||||
|
<div className="grid gap-5 lg:gap-7.5">
|
||||||
|
<DataGridInner />
|
||||||
|
</div>
|
||||||
|
</Container>
|
||||||
|
</ManageKycDeletionContextProvider>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ManageKycDeletion;
|
||||||
61
src/pages/members/kyc-delete-member/blocks/ListToolbar.tsx
Normal file
61
src/pages/members/kyc-delete-member/blocks/ListToolbar.tsx
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
import { DefaultTooltip, KeenIcon, useDataGrid } from '@/components';
|
||||||
|
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 (
|
||||||
|
<div className="card-header flex-wrap gap-2 border-b-0 px-5">
|
||||||
|
<div className="flex flex-wrap gap-2 lg:gap-5 w-full">
|
||||||
|
<div className="flex justify-between w-full items-center">
|
||||||
|
<div className="flex gap-3 items-center ml-auto">
|
||||||
|
<DefaultTooltip title={'Refresh'} placement={'top'}>
|
||||||
|
<Button variant="outline" className="h-7.5" onClick={() => reload()}>
|
||||||
|
<KeenIcon icon="arrows-circle" />
|
||||||
|
</Button>
|
||||||
|
</DefaultTooltip>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ListToolbar;
|
||||||
@ -0,0 +1,252 @@
|
|||||||
|
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 { createContext, useCallback, useMemo, useState } from 'react';
|
||||||
|
import ListToolbar from '../blocks/ListToolbar';
|
||||||
|
import { useCallApi } from '@/hooks';
|
||||||
|
import moment from 'moment';
|
||||||
|
|
||||||
|
interface ManageKycDeletionProps {
|
||||||
|
id: string;
|
||||||
|
customers_id: string;
|
||||||
|
group_id: string;
|
||||||
|
username: string;
|
||||||
|
fullname: string;
|
||||||
|
email: string;
|
||||||
|
status: string;
|
||||||
|
created_at: Date;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ContextProps {
|
||||||
|
getKycDeletionList: (
|
||||||
|
limit: number,
|
||||||
|
page: number,
|
||||||
|
with_deleted: boolean,
|
||||||
|
order_field: any,
|
||||||
|
order_direction: any,
|
||||||
|
filter: any
|
||||||
|
) => Promise<{ data: ManageKycDeletionProps[]; totalCount: number } | undefined>;
|
||||||
|
showDetailDialog: boolean;
|
||||||
|
handleDetailDialog: (show: boolean, selected_user: ManageKycDeletionProps | null) => void;
|
||||||
|
showAddDialog: boolean;
|
||||||
|
handleAddDialog: (show: boolean) => void;
|
||||||
|
selectedUser: ManageKycDeletionProps | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const initialProps: ContextProps = {
|
||||||
|
getKycDeletionList: async () => ({ data: [], totalCount: 0 }),
|
||||||
|
showDetailDialog: false,
|
||||||
|
handleDetailDialog: () => {},
|
||||||
|
showAddDialog: false,
|
||||||
|
handleAddDialog: () => {},
|
||||||
|
selectedUser: null
|
||||||
|
};
|
||||||
|
|
||||||
|
const ManageKycDeletionContext = createContext<ContextProps>(initialProps);
|
||||||
|
const API_URL = apiConfig.service_customer;
|
||||||
|
|
||||||
|
type StatusCode = 'W' | 'Y' | 'N' | 'T';
|
||||||
|
|
||||||
|
interface StatusInfo {
|
||||||
|
label: string;
|
||||||
|
bg: string;
|
||||||
|
text: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const statusMap: Record<StatusCode, StatusInfo> = {
|
||||||
|
W: { label: 'Waiting Approval', bg: 'bg-yellow-100', text: 'text-yellow-600' },
|
||||||
|
T: { label: 'No Need', bg: 'bg-blue-100', text: 'text-blue-600' },
|
||||||
|
N: { label: 'Reject', bg: 'bg-red-100', text: 'text-red-600' },
|
||||||
|
Y: { label: 'Approve', bg: 'bg-green-100', text: 'text-green-600' },
|
||||||
|
};
|
||||||
|
|
||||||
|
export const renderStatusBadge = (statusRaw: string | null | undefined) => {
|
||||||
|
const status = statusRaw as StatusCode;
|
||||||
|
const { label, bg, text } = statusMap[status] ?? {
|
||||||
|
label: 'Unknown',
|
||||||
|
bg: 'bg-gray-100',
|
||||||
|
text: 'text-gray-600',
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<span className={`px-2 py-1 text-xs font-semibold rounded-full ${bg} ${text}`}>
|
||||||
|
{label}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const ManageKycDeletionContextProvider = ({ children }: { children: React.ReactNode }) => {
|
||||||
|
const [showDetailDialog, setShowDetailDialog] = useState(false);
|
||||||
|
const [showAddDialog, setShowAddDialog] = useState(false);
|
||||||
|
const [selectedUser, setSelectedUser] = useState<ManageKycDeletionProps | null>(null);
|
||||||
|
const [manageKyc, setManageKyc] = useState<ManageKycDeletionProps[]>([]);
|
||||||
|
const { GetData } = useCallApi();
|
||||||
|
|
||||||
|
const getKycDeletionList = 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 = {
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
const response = await GetData(`${API_URL}/customer_deletion/list`, {
|
||||||
|
limit,
|
||||||
|
page: page + 1,
|
||||||
|
with_deleted: false,
|
||||||
|
order_field: "id",
|
||||||
|
order_direction: 'DESC',
|
||||||
|
filter: JSON.stringify(formattedFilter)
|
||||||
|
});
|
||||||
|
|
||||||
|
setManageKyc(response?.data.list);
|
||||||
|
return { data: response?.data.list, totalCount: response?.data.total_count };
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error fetching transaction', error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleDetailDialog = useCallback((show: boolean, selected_user: ManageKycDeletionProps | null) => {
|
||||||
|
setSelectedUser(show ? selected_user : null);
|
||||||
|
setShowDetailDialog(show);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const handleAddDialog = useCallback((show: boolean) => {
|
||||||
|
setShowAddDialog(show);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const columns = useMemo<ColumnDef<any>[]>(
|
||||||
|
() => [
|
||||||
|
{
|
||||||
|
accessorFn: (row) => row.id,
|
||||||
|
id: 'id',
|
||||||
|
header: ({ column }) => <DataGridColumnHeader title="ID" column={column} />,
|
||||||
|
enableSorting: true,
|
||||||
|
enableHiding: false,
|
||||||
|
meta: {
|
||||||
|
headerClassName: 'w-[100px]'
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accessorFn: (row) => row.created_at,
|
||||||
|
id: 'created_at',
|
||||||
|
header: ({ column }) => <DataGridColumnHeader title="Created Date" column={column} />,
|
||||||
|
enableSorting: true,
|
||||||
|
enableHiding: false,
|
||||||
|
meta: {
|
||||||
|
headerClassName: 'w-[250px]'
|
||||||
|
},
|
||||||
|
cell: ({ row }) => moment(row.original.created_at).format('DD/MM/YYYY HH:mm:ss')
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accessorFn: (row) => row.username,
|
||||||
|
id: 'username',
|
||||||
|
header: ({ column }) => <DataGridColumnHeader title="Username" column={column} />,
|
||||||
|
enableSorting: true,
|
||||||
|
enableHiding: false,
|
||||||
|
meta: {
|
||||||
|
headerClassName: 'w-[350px]'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accessorFn: (row) => row.fullname,
|
||||||
|
id: 'fullname',
|
||||||
|
header: ({ column }) => <DataGridColumnHeader title="Fullname" column={column} />,
|
||||||
|
enableSorting: true,
|
||||||
|
meta: {
|
||||||
|
headerClassName: 'w-[350px]'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accessorFn: (row) => row.registered_email,
|
||||||
|
id: 'email',
|
||||||
|
header: ({ column }) => <DataGridColumnHeader title="Email" column={column} />,
|
||||||
|
enableSorting: true,
|
||||||
|
meta: {
|
||||||
|
headerClassName: 'w-[350px]'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accessorFn: (row) => row.status_approve,
|
||||||
|
id: 'status_approve',
|
||||||
|
header: ({ column }) => <DataGridColumnHeader title="Status" column={column} />,
|
||||||
|
enableSorting: true,
|
||||||
|
meta: {
|
||||||
|
headerClassName: 'w-[350px]'
|
||||||
|
},
|
||||||
|
cell: ({row}) => renderStatusBadge(row.original.status_approve)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'actions',
|
||||||
|
enableSorting: false,
|
||||||
|
header: ({ column }) => <DataGridColumnHeader title="Action" column={column} />,
|
||||||
|
cell: (data: any) => {
|
||||||
|
const row = data.row.original;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<button
|
||||||
|
className="btn btn-sm btn-icon btn-clear btn-light"
|
||||||
|
onClick={() => handleDetailDialog(true, row.id)}
|
||||||
|
>
|
||||||
|
<KeenIcon icon="notepad-edit" />
|
||||||
|
</button>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
meta: {
|
||||||
|
headerClassName: 'w-[100px]',
|
||||||
|
cellClassName: 'text-center'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[handleDetailDialog]
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ManageKycDeletionContext.Provider
|
||||||
|
value={{
|
||||||
|
getKycDeletionList,
|
||||||
|
showDetailDialog,
|
||||||
|
handleDetailDialog,
|
||||||
|
showAddDialog,
|
||||||
|
handleAddDialog,
|
||||||
|
selectedUser
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Toaster expand visibleToasts={9} duration={3000} />
|
||||||
|
|
||||||
|
<DataGridProvider
|
||||||
|
columns={columns}
|
||||||
|
pagination={{ size: 10 }}
|
||||||
|
toolbar={<ListToolbar />}
|
||||||
|
layout={{ card: true }}
|
||||||
|
sorting={[{ id: 'name', desc: false }]}
|
||||||
|
serverSide={true}
|
||||||
|
onFetchData={({ pageIndex, pageSize, sorting, columnFilters }) =>
|
||||||
|
getKycDeletionList(pageIndex, pageSize, sorting, columnFilters)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</DataGridProvider>
|
||||||
|
</ManageKycDeletionContext.Provider>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export { ManageKycDeletionContextProvider, ManageKycDeletionContext };
|
||||||
|
export type { ManageKycDeletionProps };
|
||||||
2
src/pages/members/kyc-delete-member/hooks/index.tsx
Normal file
2
src/pages/members/kyc-delete-member/hooks/index.tsx
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
export * from './ManageKycDeletionContext';
|
||||||
|
export * from './useManageKycDeletionContext';
|
||||||
@ -0,0 +1,12 @@
|
|||||||
|
import { useContext } from 'react';
|
||||||
|
import { ManageKycDeletionContext } from './ManageKycDeletionContext';
|
||||||
|
|
||||||
|
const useManageKycDeletionContext = () => {
|
||||||
|
const context = useContext(ManageKycDeletionContext);
|
||||||
|
|
||||||
|
if (!context) throw new Error('useManageKycDeletionContext must be used within AuthProvider');
|
||||||
|
|
||||||
|
return context;
|
||||||
|
};
|
||||||
|
|
||||||
|
export { useManageKycDeletionContext };
|
||||||
@ -63,14 +63,14 @@ const AddFeeDialog = () => {
|
|||||||
const parentRef = useRef<any | null>(null);
|
const parentRef = useRef<any | null>(null);
|
||||||
const { reload } = useDataGrid();
|
const { reload } = useDataGrid();
|
||||||
const { PostData, PutData, GetData } = useCallApi();
|
const { PostData, PutData, GetData } = useCallApi();
|
||||||
const {
|
const {
|
||||||
showAddFeeDialog,
|
showAddFeeDialog,
|
||||||
handleAddFeeDialog,
|
handleAddFeeDialog,
|
||||||
handleEditFeeDialog,
|
handleEditFeeDialog,
|
||||||
selectedTransferFee,
|
selectedTransferFee,
|
||||||
transactionTypeId
|
transactionTypeId
|
||||||
} = useManageTransferFeeContext();
|
} = useManageTransferFeeContext();
|
||||||
|
|
||||||
const [alert, setAlert] = useState({
|
const [alert, setAlert] = useState({
|
||||||
show: false,
|
show: false,
|
||||||
message: ''
|
message: ''
|
||||||
@ -80,13 +80,13 @@ const AddFeeDialog = () => {
|
|||||||
const [customers, setCustomers] = useState<CustomerProps[]>([]);
|
const [customers, setCustomers] = useState<CustomerProps[]>([]);
|
||||||
const [defaultCustomer, setDefaultCustomer] = useState('');
|
const [defaultCustomer, setDefaultCustomer] = useState('');
|
||||||
const [transactionTypeName, setTransactionTypeName] = useState('');
|
const [transactionTypeName, setTransactionTypeName] = useState('');
|
||||||
|
|
||||||
const [isLoadingTransactionType, setIsLoadingTransactionType] = useState(false);
|
const [isLoadingTransactionType, setIsLoadingTransactionType] = useState(false);
|
||||||
const [isLoadingWallets, setIsLoadingWallets] = useState(false);
|
const [isLoadingWallets, setIsLoadingWallets] = useState(false);
|
||||||
const [isLoadingCustomers, setIsLoadingCustomers] = useState(false);
|
const [isLoadingCustomers, setIsLoadingCustomers] = useState(false);
|
||||||
const customersWithNames = customers.map((customer) => ({
|
const customersWithNames = customers.map((customer) => ({
|
||||||
id: customer.id,
|
id: customer.id,
|
||||||
name: customer.username,
|
name: customer.username
|
||||||
}));
|
}));
|
||||||
const initialState = {
|
const initialState = {
|
||||||
name: '',
|
name: '',
|
||||||
@ -125,15 +125,18 @@ const AddFeeDialog = () => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (showAddFeeDialog && transactionTypeId) {
|
if (showAddFeeDialog && transactionTypeId) {
|
||||||
setIsLoadingTransactionType(true);
|
setIsLoadingTransactionType(true);
|
||||||
|
|
||||||
setFormField(prev => ({
|
setFormField((prev) => ({
|
||||||
...prev,
|
...prev,
|
||||||
transaction_type: transactionTypeId
|
transaction_type: transactionTypeId
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const getTransactionTypeDetails = async () => {
|
const getTransactionTypeDetails = async () => {
|
||||||
try {
|
try {
|
||||||
const response = await GetData(`${API_URL}/transactiontype/getdata/${transactionTypeId}`, {});
|
const response = await GetData(
|
||||||
|
`${API_URL}/transactiontype/getdata/${transactionTypeId}`,
|
||||||
|
{}
|
||||||
|
);
|
||||||
if (response?.status && response?.data) {
|
if (response?.status && response?.data) {
|
||||||
setTransactionTypeName(response.data.name);
|
setTransactionTypeName(response.data.name);
|
||||||
}
|
}
|
||||||
@ -143,17 +146,17 @@ const AddFeeDialog = () => {
|
|||||||
setIsLoadingTransactionType(false);
|
setIsLoadingTransactionType(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
getTransactionTypeDetails();
|
getTransactionTypeDetails();
|
||||||
}
|
}
|
||||||
}, [showAddFeeDialog, transactionTypeId, GetData]);
|
}, [showAddFeeDialog, transactionTypeId, GetData]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const created_time = new Date();
|
const created_time = new Date();
|
||||||
const formattedTime = created_time.toISOString().slice(0, 19).replace('T', ' ');
|
const formattedTime = created_time.toISOString().slice(0, 19).replace('T', ' ');
|
||||||
|
|
||||||
if (showAddFeeDialog) {
|
if (showAddFeeDialog) {
|
||||||
setFormField(prev => ({
|
setFormField((prev) => ({
|
||||||
...prev,
|
...prev,
|
||||||
created_by: parsedUser?.username,
|
created_by: parsedUser?.username,
|
||||||
created_at: formattedTime
|
created_at: formattedTime
|
||||||
@ -193,7 +196,7 @@ const AddFeeDialog = () => {
|
|||||||
page: 1,
|
page: 1,
|
||||||
with_deleted: false,
|
with_deleted: false,
|
||||||
order_field: 'Wallets.name',
|
order_field: 'Wallets.name',
|
||||||
order_direction: 'ASC',
|
order_direction: 'ASC'
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
const response = await GetData(`${API_URL_MASTER_DATA}/wallet/list`, params);
|
const response = await GetData(`${API_URL_MASTER_DATA}/wallet/list`, params);
|
||||||
@ -209,7 +212,7 @@ const AddFeeDialog = () => {
|
|||||||
setIsLoadingWallets(false);
|
setIsLoadingWallets(false);
|
||||||
}
|
}
|
||||||
}, [GetData]);
|
}, [GetData]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!showAddFeeDialog) return;
|
if (!showAddFeeDialog) return;
|
||||||
fetchWallets();
|
fetchWallets();
|
||||||
@ -231,7 +234,7 @@ const AddFeeDialog = () => {
|
|||||||
});
|
});
|
||||||
const customerList = response?.data.list || [];
|
const customerList = response?.data.list || [];
|
||||||
setCustomers(customerList);
|
setCustomers(customerList);
|
||||||
|
|
||||||
if (customerList.length > 0) {
|
if (customerList.length > 0) {
|
||||||
setDefaultCustomer(customerList[0].id);
|
setDefaultCustomer(customerList[0].id);
|
||||||
}
|
}
|
||||||
@ -250,9 +253,9 @@ const AddFeeDialog = () => {
|
|||||||
async (e: React.FormEvent<HTMLFormElement>) => {
|
async (e: React.FormEvent<HTMLFormElement>) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
setIsSubmitting(true);
|
setIsSubmitting(true);
|
||||||
|
|
||||||
const requiredFields = [
|
const requiredFields = [
|
||||||
'name',
|
'name',
|
||||||
'description',
|
'description',
|
||||||
'period_start',
|
'period_start',
|
||||||
'period_end',
|
'period_end',
|
||||||
@ -265,44 +268,44 @@ const AddFeeDialog = () => {
|
|||||||
'credit_to',
|
'credit_to',
|
||||||
'credit_destination_account'
|
'credit_destination_account'
|
||||||
];
|
];
|
||||||
|
|
||||||
for (const field of requiredFields) {
|
for (const field of requiredFields) {
|
||||||
if (formField[field as keyof typeof formField] === '') {
|
if (formField[field as keyof typeof formField] === '') {
|
||||||
setAlert({
|
setAlert({
|
||||||
show: true,
|
show: true,
|
||||||
message: `All required fields must be filled out. Missing: ${field.replace(/_/g, ' ')}`
|
message: `All required fields must be filled out. Missing: ${field.replace(/_/g, ' ')}`
|
||||||
});
|
});
|
||||||
setIsSubmitting(false);
|
setIsSubmitting(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (formField.credit_to === 'I' && !formField.credit_destination) {
|
if (formField.credit_to === 'I' && !formField.credit_destination) {
|
||||||
setAlert({
|
setAlert({
|
||||||
show: true,
|
show: true,
|
||||||
message: 'Credit destination is required when Input Customer is selected'
|
message: 'Credit destination is required when Input Customer is selected'
|
||||||
});
|
});
|
||||||
setIsSubmitting(false);
|
setIsSubmitting(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setAlert({ show: false, message: '' });
|
setAlert({ show: false, message: '' });
|
||||||
|
|
||||||
const payload = { ...formField };
|
const payload = { ...formField };
|
||||||
|
|
||||||
if (formField.credit_to !== 'I') {
|
if (formField.credit_to !== 'I') {
|
||||||
payload.credit_destination = '00000000-0000-0000-0000-000000000000';
|
payload.credit_destination = '00000000-0000-0000-0000-000000000000';
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await PostData(`${API_URL}/transactionfees/create`, payload);
|
const response = await PostData(`${API_URL}/transactionfees/create`, payload);
|
||||||
|
|
||||||
if (response?.status) {
|
if (response?.status) {
|
||||||
toast.success('Successfully created transfer fee');
|
toast.success('Successfully created transfer fee');
|
||||||
reload();
|
reload();
|
||||||
resetForm();
|
resetForm();
|
||||||
handleAddFeeDialog(false);
|
handleAddFeeDialog(false);
|
||||||
|
|
||||||
const createActivity = {
|
const createActivity = {
|
||||||
module: 'Manage Transfer Fee',
|
module: 'Manage Transfer Fee',
|
||||||
description: `Create Transfer Fee => ${formField.name}`,
|
description: `Create Transfer Fee => ${formField.name}`,
|
||||||
@ -323,18 +326,14 @@ const AddFeeDialog = () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const renderSelectWithLoading = (
|
const renderSelectWithLoading = (
|
||||||
value: string,
|
value: string,
|
||||||
onChangeHandler: (value: string) => void,
|
onChangeHandler: (value: string) => void,
|
||||||
options: {id: string, name: string}[] | null,
|
options: { id: string; name: string }[] | null,
|
||||||
placeholder: string,
|
placeholder: string,
|
||||||
isLoading: boolean
|
isLoading: boolean
|
||||||
) => {
|
) => {
|
||||||
return (
|
return (
|
||||||
<Select
|
<Select value={value} onValueChange={onChangeHandler} disabled={isLoading}>
|
||||||
value={value}
|
|
||||||
onValueChange={onChangeHandler}
|
|
||||||
disabled={isLoading}
|
|
||||||
>
|
|
||||||
<SelectTrigger>
|
<SelectTrigger>
|
||||||
{isLoading ? (
|
{isLoading ? (
|
||||||
<div className="flex items-center">
|
<div className="flex items-center">
|
||||||
@ -346,11 +345,12 @@ const AddFeeDialog = () => {
|
|||||||
)}
|
)}
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
<SelectContent>
|
<SelectContent>
|
||||||
{options && options.map((option) => (
|
{options &&
|
||||||
<SelectItem value={option.id} key={option.id}>
|
options.map((option) => (
|
||||||
{option.name}
|
<SelectItem value={option.id} key={option.id}>
|
||||||
</SelectItem>
|
{option.name}
|
||||||
))}
|
</SelectItem>
|
||||||
|
))}
|
||||||
</SelectContent>
|
</SelectContent>
|
||||||
</Select>
|
</Select>
|
||||||
);
|
);
|
||||||
@ -389,7 +389,9 @@ const AddFeeDialog = () => {
|
|||||||
<div className="card flex flex-col gap-5">
|
<div className="card flex flex-col gap-5">
|
||||||
<div className="card-body grid gap-5 p-0">
|
<div className="card-body grid gap-5 p-0">
|
||||||
<div className="w-full">
|
<div className="w-full">
|
||||||
<label className="form-label">Transaction Type ID <span className="text-red-500">*</span></label>
|
<label className="form-label">
|
||||||
|
Transaction Type ID <span className="text-red-500">*</span>
|
||||||
|
</label>
|
||||||
{transactionTypeId ? (
|
{transactionTypeId ? (
|
||||||
<div className="relative">
|
<div className="relative">
|
||||||
<Input
|
<Input
|
||||||
@ -412,13 +414,15 @@ const AddFeeDialog = () => {
|
|||||||
formField.transaction_type,
|
formField.transaction_type,
|
||||||
(transaction_type) => setFormField((prev) => ({ ...prev, transaction_type })),
|
(transaction_type) => setFormField((prev) => ({ ...prev, transaction_type })),
|
||||||
transactionTypes,
|
transactionTypes,
|
||||||
"Select Transaction Type",
|
'Select Transaction Type',
|
||||||
isLoadingTransactionType
|
isLoadingTransactionType
|
||||||
)
|
)
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="w-full">
|
<div className="w-full">
|
||||||
<label className="form-label">Transfer Free Name <span className="text-red-500">*</span></label>
|
<label className="form-label">
|
||||||
|
Transfer Free Name <span className="text-red-500">*</span>
|
||||||
|
</label>
|
||||||
<Input
|
<Input
|
||||||
className="input"
|
className="input"
|
||||||
type="text"
|
type="text"
|
||||||
@ -430,7 +434,9 @@ const AddFeeDialog = () => {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="w-full">
|
<div className="w-full">
|
||||||
<label className="form-label">Description <span className="text-red-500">*</span></label>
|
<label className="form-label">
|
||||||
|
Description <span className="text-red-500">*</span>
|
||||||
|
</label>
|
||||||
<Input
|
<Input
|
||||||
className="input"
|
className="input"
|
||||||
type="text"
|
type="text"
|
||||||
@ -476,7 +482,9 @@ const AddFeeDialog = () => {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="w-full">
|
<div className="w-full">
|
||||||
<label className="form-label">Period Start <span className="text-red-500">*</span></label>
|
<label className="form-label">
|
||||||
|
Period Start <span className="text-red-500">*</span>
|
||||||
|
</label>
|
||||||
<Input
|
<Input
|
||||||
className="input"
|
className="input"
|
||||||
type="date"
|
type="date"
|
||||||
@ -488,7 +496,9 @@ const AddFeeDialog = () => {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="w-full">
|
<div className="w-full">
|
||||||
<label className="form-label">Period End <span className="text-red-500">*</span></label>
|
<label className="form-label">
|
||||||
|
Period End <span className="text-red-500">*</span>
|
||||||
|
</label>
|
||||||
<Input
|
<Input
|
||||||
className="input"
|
className="input"
|
||||||
type="date"
|
type="date"
|
||||||
@ -551,7 +561,9 @@ const AddFeeDialog = () => {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="w-full">
|
<div className="w-full">
|
||||||
<label className="form-label">Deduct From <span className="text-red-500">*</span></label>
|
<label className="form-label">
|
||||||
|
Deduct From <span className="text-red-500">*</span>
|
||||||
|
</label>
|
||||||
<Select
|
<Select
|
||||||
value={formField.deduct_from}
|
value={formField.deduct_from}
|
||||||
onValueChange={(value) => setFormField({ ...formField, deduct_from: value })}
|
onValueChange={(value) => setFormField({ ...formField, deduct_from: value })}
|
||||||
@ -566,24 +578,31 @@ const AddFeeDialog = () => {
|
|||||||
</Select>
|
</Select>
|
||||||
</div>
|
</div>
|
||||||
<div className="w-full">
|
<div className="w-full">
|
||||||
<label className="form-label">Deduct From Destination <span className="text-red-500">*</span></label>
|
<label className="form-label">
|
||||||
|
Deduct From Destination <span className="text-red-500">*</span>
|
||||||
|
</label>
|
||||||
{renderSelectWithLoading(
|
{renderSelectWithLoading(
|
||||||
formField.deduct_from_account,
|
formField.deduct_from_account,
|
||||||
(value) => setFormField({ ...formField, deduct_from_account: value }),
|
(value) => setFormField({ ...formField, deduct_from_account: value }),
|
||||||
wallets,
|
wallets,
|
||||||
"Select Wallet",
|
'Select Wallet',
|
||||||
isLoadingWallets
|
isLoadingWallets
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="w-full">
|
<div className="w-full">
|
||||||
<label className="form-label">Credit To <span className="text-red-500">*</span></label>
|
<label className="form-label">
|
||||||
|
Credit To <span className="text-red-500">*</span>
|
||||||
|
</label>
|
||||||
<Select
|
<Select
|
||||||
value={formField.credit_to}
|
value={formField.credit_to}
|
||||||
onValueChange={(value) => setFormField({
|
onValueChange={(value) =>
|
||||||
...formField,
|
setFormField({
|
||||||
credit_to: value,
|
...formField,
|
||||||
credit_destination: value === 'I' ? '' : '00000000-0000-0000-0000-000000000000'
|
credit_to: value,
|
||||||
})}
|
credit_destination:
|
||||||
|
value === 'I' ? '' : '00000000-0000-0000-0000-000000000000'
|
||||||
|
})
|
||||||
|
}
|
||||||
>
|
>
|
||||||
<SelectTrigger>
|
<SelectTrigger>
|
||||||
<SelectValue placeholder="Select Credit To" />
|
<SelectValue placeholder="Select Credit To" />
|
||||||
@ -597,28 +616,34 @@ const AddFeeDialog = () => {
|
|||||||
</div>
|
</div>
|
||||||
{formField.credit_to === 'I' && (
|
{formField.credit_to === 'I' && (
|
||||||
<div className="w-full">
|
<div className="w-full">
|
||||||
<label className="form-label">Credit Destination <span className="text-red-500">*</span></label>
|
<label className="form-label">
|
||||||
|
Credit Destination <span className="text-red-500">*</span>
|
||||||
|
</label>
|
||||||
{renderSelectWithLoading(
|
{renderSelectWithLoading(
|
||||||
formField.credit_destination,
|
formField.credit_destination,
|
||||||
(value) => setFormField({ ...formField, credit_destination: value }),
|
(value) => setFormField({ ...formField, credit_destination: value }),
|
||||||
customersWithNames,
|
customersWithNames,
|
||||||
"Select Customer",
|
'Select Customer',
|
||||||
isLoadingCustomers
|
isLoadingCustomers
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<div className="w-full">
|
<div className="w-full">
|
||||||
<label className="form-label">Credit Destination Account <span className="text-red-500">*</span></label>
|
<label className="form-label">
|
||||||
|
Credit Destination Account <span className="text-red-500">*</span>
|
||||||
|
</label>
|
||||||
{renderSelectWithLoading(
|
{renderSelectWithLoading(
|
||||||
formField.credit_destination_account,
|
formField.credit_destination_account,
|
||||||
(value) => setFormField({ ...formField, credit_destination_account: value }),
|
(value) => setFormField({ ...formField, credit_destination_account: value }),
|
||||||
wallets,
|
wallets,
|
||||||
"Select Wallet",
|
'Select Wallet',
|
||||||
isLoadingWallets
|
isLoadingWallets
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="w-full">
|
<div className="w-full">
|
||||||
<label className="form-label">Status <span className="text-red-500">*</span></label>
|
<label className="form-label">
|
||||||
|
Status <span className="text-red-500">*</span>
|
||||||
|
</label>
|
||||||
<Select
|
<Select
|
||||||
value={formField.status}
|
value={formField.status}
|
||||||
onValueChange={(value) => setFormField({ ...formField, status: value })}
|
onValueChange={(value) => setFormField({ ...formField, status: value })}
|
||||||
@ -633,7 +658,9 @@ const AddFeeDialog = () => {
|
|||||||
</Select>
|
</Select>
|
||||||
</div>
|
</div>
|
||||||
<div className="w-full">
|
<div className="w-full">
|
||||||
<label className="form-label">Status Include <span className="text-red-500">*</span></label>
|
<label className="form-label">
|
||||||
|
Status Include <span className="text-red-500">*</span>
|
||||||
|
</label>
|
||||||
<Select
|
<Select
|
||||||
value={formField.status_include}
|
value={formField.status_include}
|
||||||
onValueChange={(value) => setFormField({ ...formField, status_include: value })}
|
onValueChange={(value) => setFormField({ ...formField, status_include: value })}
|
||||||
@ -648,7 +675,9 @@ const AddFeeDialog = () => {
|
|||||||
</Select>
|
</Select>
|
||||||
</div>
|
</div>
|
||||||
<div className="w-full">
|
<div className="w-full">
|
||||||
<label className="form-label">Priority <span className="text-red-500">*</span></label>
|
<label className="form-label">
|
||||||
|
Priority <span className="text-red-500">*</span>
|
||||||
|
</label>
|
||||||
<Select
|
<Select
|
||||||
value={formField.priority}
|
value={formField.priority}
|
||||||
onValueChange={(value) => setFormField({ ...formField, priority: value })}
|
onValueChange={(value) => setFormField({ ...formField, priority: value })}
|
||||||
@ -672,10 +701,15 @@ const AddFeeDialog = () => {
|
|||||||
>
|
>
|
||||||
Reset
|
Reset
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
variant={'default'}
|
variant={'default'}
|
||||||
type="submit"
|
type="submit"
|
||||||
disabled={isSubmitting || isLoadingTransactionType || isLoadingWallets || isLoadingCustomers}
|
disabled={
|
||||||
|
isSubmitting ||
|
||||||
|
isLoadingTransactionType ||
|
||||||
|
isLoadingWallets ||
|
||||||
|
isLoadingCustomers
|
||||||
|
}
|
||||||
>
|
>
|
||||||
{isSubmitting ? 'Saving...' : 'Save Changes'}
|
{isSubmitting ? 'Saving...' : 'Save Changes'}
|
||||||
</Button>
|
</Button>
|
||||||
@ -689,4 +723,4 @@ const AddFeeDialog = () => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default AddFeeDialog;
|
export default AddFeeDialog;
|
||||||
|
|||||||
@ -1,4 +1,11 @@
|
|||||||
import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle , DialogDescription} from '@/components/ui/dialog';
|
import {
|
||||||
|
Dialog,
|
||||||
|
DialogContent,
|
||||||
|
DialogFooter,
|
||||||
|
DialogHeader,
|
||||||
|
DialogTitle,
|
||||||
|
DialogDescription
|
||||||
|
} from '@/components/ui/dialog';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import { Alert, useDataGrid } from '@/components';
|
import { Alert, useDataGrid } from '@/components';
|
||||||
import { useCallback, useState } from 'react';
|
import { useCallback, useState } from 'react';
|
||||||
@ -10,7 +17,8 @@ import { useManageTransferFeeContext } from '../hooks/useManageTransferFeeContex
|
|||||||
const API_URL = apiConfig.service_transaction;
|
const API_URL = apiConfig.service_transaction;
|
||||||
|
|
||||||
const DeleteFeeDialog = () => {
|
const DeleteFeeDialog = () => {
|
||||||
const { showDeleteFeeDialog, handleDeleteFeeDialog, selectedTransferFee } = useManageTransferFeeContext();
|
const { showDeleteFeeDialog, handleDeleteFeeDialog, selectedTransferFee } =
|
||||||
|
useManageTransferFeeContext();
|
||||||
const { reload } = useDataGrid();
|
const { reload } = useDataGrid();
|
||||||
const { DeleteData } = useCallApi();
|
const { DeleteData } = useCallApi();
|
||||||
const [alert, setAlert] = useState({
|
const [alert, setAlert] = useState({
|
||||||
@ -19,9 +27,12 @@ const DeleteFeeDialog = () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const doDeleteTransferFee = useCallback(async () => {
|
const doDeleteTransferFee = useCallback(async () => {
|
||||||
const response = await DeleteData(`${API_URL}/transactionfees/delete/${selectedTransferFee}/false`, {
|
const response = await DeleteData(
|
||||||
id: selectedTransferFee
|
`${API_URL}/transactionfees/delete/${selectedTransferFee}/false`,
|
||||||
});
|
{
|
||||||
|
id: selectedTransferFee
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
if (response?.status) {
|
if (response?.status) {
|
||||||
setAlert({ show: false, message: '' });
|
setAlert({ show: false, message: '' });
|
||||||
@ -39,7 +50,9 @@ const DeleteFeeDialog = () => {
|
|||||||
<DialogContent className="container-fixed max-w-md flex flex-col p-5 overflow-hidden [&>button]:hidden">
|
<DialogContent className="container-fixed max-w-md flex flex-col p-5 overflow-hidden [&>button]:hidden">
|
||||||
<DialogHeader className="p-0 border-0 block">
|
<DialogHeader className="p-0 border-0 block">
|
||||||
<DialogTitle className="text-lg">Delete Transfer Type</DialogTitle>
|
<DialogTitle className="text-lg">Delete Transfer Type</DialogTitle>
|
||||||
<DialogDescription className="text-sm">Are you sure you want to delete this data?</DialogDescription>
|
<DialogDescription className="text-sm">
|
||||||
|
Are you sure you want to delete this data?
|
||||||
|
</DialogDescription>
|
||||||
<Alert variant="warning">
|
<Alert variant="warning">
|
||||||
<h3 className="text-lg">Are you sure?</h3>
|
<h3 className="text-lg">Are you sure?</h3>
|
||||||
<span className="text-sm">You will delete this data!</span>
|
<span className="text-sm">You will delete this data!</span>
|
||||||
@ -64,4 +77,3 @@ const DeleteFeeDialog = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default DeleteFeeDialog;
|
export default DeleteFeeDialog;
|
||||||
|
|
||||||
|
|||||||
@ -8,7 +8,14 @@ import {
|
|||||||
SelectValue
|
SelectValue
|
||||||
} from '@/components/ui/select';
|
} from '@/components/ui/select';
|
||||||
import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';
|
import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';
|
||||||
import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList } from '@/components/ui/command';
|
import {
|
||||||
|
Command,
|
||||||
|
CommandEmpty,
|
||||||
|
CommandGroup,
|
||||||
|
CommandInput,
|
||||||
|
CommandItem,
|
||||||
|
CommandList
|
||||||
|
} from '@/components/ui/command';
|
||||||
import {
|
import {
|
||||||
Dialog,
|
Dialog,
|
||||||
DialogBody,
|
DialogBody,
|
||||||
@ -96,7 +103,7 @@ const EditFeeDialog = () => {
|
|||||||
const formattedTime = updated_time.toISOString().slice(0, 19).replace('T', ' ');
|
const formattedTime = updated_time.toISOString().slice(0, 19).replace('T', ' ');
|
||||||
|
|
||||||
if (showEditFeeDialog) {
|
if (showEditFeeDialog) {
|
||||||
setFormField(prevState => ({
|
setFormField((prevState) => ({
|
||||||
...prevState,
|
...prevState,
|
||||||
updated_by: parsedUser?.username,
|
updated_by: parsedUser?.username,
|
||||||
updated_at: formattedTime
|
updated_at: formattedTime
|
||||||
@ -116,9 +123,9 @@ const EditFeeDialog = () => {
|
|||||||
async (e: React.FormEvent<HTMLFormElement>) => {
|
async (e: React.FormEvent<HTMLFormElement>) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
setIsSubmitting(true);
|
setIsSubmitting(true);
|
||||||
|
|
||||||
const requiredFields = [
|
const requiredFields = [
|
||||||
'name',
|
'name',
|
||||||
'description',
|
'description',
|
||||||
'period_start',
|
'period_start',
|
||||||
'period_end',
|
'period_end',
|
||||||
@ -131,38 +138,41 @@ const EditFeeDialog = () => {
|
|||||||
'credit_to',
|
'credit_to',
|
||||||
'credit_destination_account'
|
'credit_destination_account'
|
||||||
];
|
];
|
||||||
|
|
||||||
for (const field of requiredFields) {
|
for (const field of requiredFields) {
|
||||||
if (formField[field as keyof typeof formField] === '') {
|
if (formField[field as keyof typeof formField] === '') {
|
||||||
setAlert({
|
setAlert({
|
||||||
show: true,
|
show: true,
|
||||||
message: `All required fields must be filled out. Missing: ${field.replace(/_/g, ' ')}`
|
message: `All required fields must be filled out. Missing: ${field.replace(/_/g, ' ')}`
|
||||||
});
|
});
|
||||||
setIsSubmitting(false);
|
setIsSubmitting(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (formField.credit_to === 'I' && !formField.credit_destination) {
|
if (formField.credit_to === 'I' && !formField.credit_destination) {
|
||||||
setAlert({
|
setAlert({
|
||||||
show: true,
|
show: true,
|
||||||
message: 'Credit destination is required when Input Customer is selected'
|
message: 'Credit destination is required when Input Customer is selected'
|
||||||
});
|
});
|
||||||
setIsSubmitting(false);
|
setIsSubmitting(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setAlert({ show: false, message: '' });
|
setAlert({ show: false, message: '' });
|
||||||
|
|
||||||
const payload = { ...formField };
|
const payload = { ...formField };
|
||||||
|
|
||||||
if (formField.credit_to !== 'I') {
|
if (formField.credit_to !== 'I') {
|
||||||
payload.credit_destination = '00000000-0000-0000-0000-000000000000';
|
payload.credit_destination = '00000000-0000-0000-0000-000000000000';
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await PutData(`${API_URL}/transactionfees/update/${selectedTransferFee}`, payload);
|
const response = await PutData(
|
||||||
|
`${API_URL}/transactionfees/update/${selectedTransferFee}`,
|
||||||
|
payload
|
||||||
|
);
|
||||||
|
|
||||||
if (response?.status) {
|
if (response?.status) {
|
||||||
toast.success('Successfully updated transfer fee');
|
toast.success('Successfully updated transfer fee');
|
||||||
reload();
|
reload();
|
||||||
@ -191,7 +201,7 @@ const EditFeeDialog = () => {
|
|||||||
page: 1,
|
page: 1,
|
||||||
with_deleted: false,
|
with_deleted: false,
|
||||||
order_field: 'Wallets.name',
|
order_field: 'Wallets.name',
|
||||||
order_direction: 'ASC',
|
order_direction: 'ASC'
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
const response = await GetData(`${API_URL_MASTER_DATA}/wallet/list`, params);
|
const response = await GetData(`${API_URL_MASTER_DATA}/wallet/list`, params);
|
||||||
@ -260,56 +270,58 @@ const EditFeeDialog = () => {
|
|||||||
return dateString.split('T')[0];
|
return dateString.split('T')[0];
|
||||||
};
|
};
|
||||||
|
|
||||||
const fetchTransactionFee = useCallback(async (id: string) => {
|
const fetchTransactionFee = useCallback(
|
||||||
try {
|
async (id: string) => {
|
||||||
const response = await GetData(`${API_URL}/transactionfees/getdata/${id}`, { });
|
try {
|
||||||
|
const response = await GetData(`${API_URL}/transactionfees/getdata/${id}`, {});
|
||||||
if (response?.status) {
|
|
||||||
|
|
||||||
|
if (response?.status) {
|
||||||
setFormField({
|
setFormField({
|
||||||
...initialState,
|
...initialState,
|
||||||
name: response.data.name || '',
|
name: response.data.name || '',
|
||||||
description: response.data.description || '',
|
description: response.data.description || '',
|
||||||
transaction_type: response.data.transaction_type?.id || '',
|
transaction_type: response.data.transaction_type?.id || '',
|
||||||
minimum_amount: response.data.minimum_amount || 0,
|
minimum_amount: response.data.minimum_amount || 0,
|
||||||
maximum_amount: response.data.maximum_amount || 0,
|
maximum_amount: response.data.maximum_amount || 0,
|
||||||
period_start: formatDate(response.data.period_start),
|
period_start: formatDate(response.data.period_start),
|
||||||
period_end: formatDate(response.data.period_end),
|
period_end: formatDate(response.data.period_end),
|
||||||
deduct_amount: response.data.deduct_amount || 0,
|
deduct_amount: response.data.deduct_amount || 0,
|
||||||
deduct_percentage: response.data.deduct_percentage || 0,
|
deduct_percentage: response.data.deduct_percentage || 0,
|
||||||
fee_amount: response.data.fee_amount || 0,
|
fee_amount: response.data.fee_amount || 0,
|
||||||
priority: response.data.priority || '',
|
priority: response.data.priority || '',
|
||||||
status: response.data.status || '',
|
status: response.data.status || '',
|
||||||
status_include: response.data.status_include || '',
|
status_include: response.data.status_include || '',
|
||||||
deduct_from: response.data.deduct_from||'',
|
deduct_from: response.data.deduct_from || '',
|
||||||
deduct_from_account: response.data.deduct_from_account?.id || '',
|
deduct_from_account: response.data.deduct_from_account?.id || '',
|
||||||
credit_to: response.data.credit_to || '',
|
credit_to: response.data.credit_to || '',
|
||||||
credit_destination: response.data.credit_destination?.id || '00000000-0000-0000-0000-000000000000',
|
credit_destination:
|
||||||
credit_destination_account: response.data.credit_destination_account?.id || '',
|
response.data.credit_destination?.id || '00000000-0000-0000-0000-000000000000',
|
||||||
updated_by: parsedUser?.username,
|
credit_destination_account: response.data.credit_destination_account?.id || '',
|
||||||
updated_at: new Date().toISOString().slice(0, 19).replace('T', ' ')
|
updated_by: parsedUser?.username,
|
||||||
});
|
updated_at: new Date().toISOString().slice(0, 19).replace('T', ' ')
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error fetching transaction fee details', error);
|
||||||
|
setAlert({ show: true, message: 'Failed to fetch transaction fee details' });
|
||||||
}
|
}
|
||||||
} catch (error) {
|
},
|
||||||
console.error('Error fetching transaction fee details', error);
|
[GetData, parsedUser?.username]
|
||||||
setAlert({ show: true, message: 'Failed to fetch transaction fee details' });
|
);
|
||||||
}
|
|
||||||
}, [GetData, parsedUser?.username]);
|
|
||||||
|
|
||||||
const hasFetchedRef = useRef(false);
|
const hasFetchedRef = useRef(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (selectedTransferFee && showEditFeeDialog && !hasFetchedRef.current) {
|
if (selectedTransferFee && showEditFeeDialog && !hasFetchedRef.current) {
|
||||||
fetchTransactionFee(selectedTransferFee);
|
fetchTransactionFee(selectedTransferFee);
|
||||||
hasFetchedRef.current = true;
|
hasFetchedRef.current = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!showEditFeeDialog) {
|
if (!showEditFeeDialog) {
|
||||||
hasFetchedRef.current = false;
|
hasFetchedRef.current = false;
|
||||||
}
|
}
|
||||||
}, [selectedTransferFee, showEditFeeDialog, fetchTransactionFee]);
|
}, [selectedTransferFee, showEditFeeDialog, fetchTransactionFee]);
|
||||||
|
|
||||||
const handleCloseDialog = () => {
|
const handleCloseDialog = () => {
|
||||||
setFormField(initialState);
|
setFormField(initialState);
|
||||||
setAlert({ show: false, message: '' });
|
setAlert({ show: false, message: '' });
|
||||||
@ -317,11 +329,14 @@ const EditFeeDialog = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog open={showEditFeeDialog} onOpenChange={(open) => {
|
<Dialog
|
||||||
if (!open) {
|
open={showEditFeeDialog}
|
||||||
handleCloseDialog();
|
onOpenChange={(open) => {
|
||||||
}
|
if (!open) {
|
||||||
}}>
|
handleCloseDialog();
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
<DialogContent className="container-fixed max-w-[1080px] flex flex-col p-5 overflow-hidden [&>button]:hidden">
|
<DialogContent className="container-fixed max-w-[1080px] flex flex-col p-5 overflow-hidden [&>button]:hidden">
|
||||||
<DialogTitle></DialogTitle>
|
<DialogTitle></DialogTitle>
|
||||||
<DialogDescription></DialogDescription>
|
<DialogDescription></DialogDescription>
|
||||||
@ -348,12 +363,14 @@ const EditFeeDialog = () => {
|
|||||||
</Alert>
|
</Alert>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<form action="" onSubmit={doUpdateTransferFee}>
|
<form action="" onSubmit={doUpdateTransferFee}>
|
||||||
<div className="card flex flex-col gap-5">
|
<div className="card flex flex-col gap-5">
|
||||||
<div className="card-body grid gap-5 p-0">
|
<div className="card-body grid gap-5 p-0">
|
||||||
<div className="w-full">
|
<div className="w-full">
|
||||||
<label className="form-label">Transfer Fee Name <span className="text-red-500">*</span></label>
|
<label className="form-label">
|
||||||
|
Transfer Fee Name <span className="text-red-500">*</span>
|
||||||
|
</label>
|
||||||
<Input
|
<Input
|
||||||
className="input"
|
className="input"
|
||||||
type="text"
|
type="text"
|
||||||
@ -364,9 +381,11 @@ const EditFeeDialog = () => {
|
|||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="w-full">
|
<div className="w-full">
|
||||||
<label className="form-label">Description <span className="text-red-500">*</span></label>
|
<label className="form-label">
|
||||||
|
Description <span className="text-red-500">*</span>
|
||||||
|
</label>
|
||||||
<Input
|
<Input
|
||||||
className="input"
|
className="input"
|
||||||
type="text"
|
type="text"
|
||||||
@ -377,7 +396,7 @@ const EditFeeDialog = () => {
|
|||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="w-full">
|
<div className="w-full">
|
||||||
<label className="form-label">Minimum Amount</label>
|
<label className="form-label">Minimum Amount</label>
|
||||||
<NumericFormat
|
<NumericFormat
|
||||||
@ -395,7 +414,7 @@ const EditFeeDialog = () => {
|
|||||||
placeholder="Enter Minimum Amount"
|
placeholder="Enter Minimum Amount"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="w-full">
|
<div className="w-full">
|
||||||
<label className="form-label">Maximum Amount</label>
|
<label className="form-label">Maximum Amount</label>
|
||||||
<NumericFormat
|
<NumericFormat
|
||||||
@ -413,9 +432,11 @@ const EditFeeDialog = () => {
|
|||||||
placeholder="Enter Maximum Amount"
|
placeholder="Enter Maximum Amount"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="w-full">
|
<div className="w-full">
|
||||||
<label className="form-label">Period Start <span className="text-red-500">*</span></label>
|
<label className="form-label">
|
||||||
|
Period Start <span className="text-red-500">*</span>
|
||||||
|
</label>
|
||||||
<Input
|
<Input
|
||||||
className="input"
|
className="input"
|
||||||
type="date"
|
type="date"
|
||||||
@ -426,9 +447,11 @@ const EditFeeDialog = () => {
|
|||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="w-full">
|
<div className="w-full">
|
||||||
<label className="form-label">Period End <span className="text-red-500">*</span></label>
|
<label className="form-label">
|
||||||
|
Period End <span className="text-red-500">*</span>
|
||||||
|
</label>
|
||||||
<Input
|
<Input
|
||||||
className="input"
|
className="input"
|
||||||
type="date"
|
type="date"
|
||||||
@ -439,7 +462,7 @@ const EditFeeDialog = () => {
|
|||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="w-full">
|
<div className="w-full">
|
||||||
<label className="form-label">Deduct Amount</label>
|
<label className="form-label">Deduct Amount</label>
|
||||||
<NumericFormat
|
<NumericFormat
|
||||||
@ -457,7 +480,7 @@ const EditFeeDialog = () => {
|
|||||||
placeholder="Enter Deduct Amount"
|
placeholder="Enter Deduct Amount"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="w-full">
|
<div className="w-full">
|
||||||
<label className="form-label">Deduct Percentage</label>
|
<label className="form-label">Deduct Percentage</label>
|
||||||
<NumericFormat
|
<NumericFormat
|
||||||
@ -475,7 +498,7 @@ const EditFeeDialog = () => {
|
|||||||
placeholder="Enter Deduct Percentage"
|
placeholder="Enter Deduct Percentage"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="w-full">
|
<div className="w-full">
|
||||||
<label className="form-label">Fee Amount</label>
|
<label className="form-label">Fee Amount</label>
|
||||||
<NumericFormat
|
<NumericFormat
|
||||||
@ -493,9 +516,11 @@ const EditFeeDialog = () => {
|
|||||||
placeholder="Enter Fee Amount"
|
placeholder="Enter Fee Amount"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="w-full">
|
<div className="w-full">
|
||||||
<label className="form-label">Deduct From <span className="text-red-500">*</span></label>
|
<label className="form-label">
|
||||||
|
Deduct From <span className="text-red-500">*</span>
|
||||||
|
</label>
|
||||||
<Select
|
<Select
|
||||||
value={formField.deduct_from}
|
value={formField.deduct_from}
|
||||||
onValueChange={(value) => setFormField({ ...formField, deduct_from: value })}
|
onValueChange={(value) => setFormField({ ...formField, deduct_from: value })}
|
||||||
@ -509,12 +534,16 @@ const EditFeeDialog = () => {
|
|||||||
</SelectContent>
|
</SelectContent>
|
||||||
</Select>
|
</Select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="w-full">
|
<div className="w-full">
|
||||||
<label className="form-label">Deduct From Destination <span className="text-red-500">*</span></label>
|
<label className="form-label">
|
||||||
|
Deduct From Destination <span className="text-red-500">*</span>
|
||||||
|
</label>
|
||||||
<Select
|
<Select
|
||||||
value={formField.deduct_from_account}
|
value={formField.deduct_from_account}
|
||||||
onValueChange={(value) => setFormField({ ...formField, deduct_from_account: value })}
|
onValueChange={(value) =>
|
||||||
|
setFormField({ ...formField, deduct_from_account: value })
|
||||||
|
}
|
||||||
>
|
>
|
||||||
<SelectTrigger>
|
<SelectTrigger>
|
||||||
<SelectValue placeholder="Select Wallet" />
|
<SelectValue placeholder="Select Wallet" />
|
||||||
@ -528,16 +557,21 @@ const EditFeeDialog = () => {
|
|||||||
</SelectContent>
|
</SelectContent>
|
||||||
</Select>
|
</Select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="w-full">
|
<div className="w-full">
|
||||||
<label className="form-label">Credit To <span className="text-red-500">*</span></label>
|
<label className="form-label">
|
||||||
|
Credit To <span className="text-red-500">*</span>
|
||||||
|
</label>
|
||||||
<Select
|
<Select
|
||||||
value={formField.credit_to}
|
value={formField.credit_to}
|
||||||
onValueChange={(value) => setFormField({
|
onValueChange={(value) =>
|
||||||
...formField,
|
setFormField({
|
||||||
credit_to: value,
|
...formField,
|
||||||
credit_destination: value === 'I' ? '' : '00000000-0000-0000-0000-000000000000'
|
credit_to: value,
|
||||||
})}
|
credit_destination:
|
||||||
|
value === 'I' ? '' : '00000000-0000-0000-0000-000000000000'
|
||||||
|
})
|
||||||
|
}
|
||||||
>
|
>
|
||||||
<SelectTrigger>
|
<SelectTrigger>
|
||||||
<SelectValue placeholder="Select Credit To" />
|
<SelectValue placeholder="Select Credit To" />
|
||||||
@ -549,13 +583,17 @@ const EditFeeDialog = () => {
|
|||||||
</SelectContent>
|
</SelectContent>
|
||||||
</Select>
|
</Select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{formField.credit_to === 'I' && (
|
{formField.credit_to === 'I' && (
|
||||||
<div className="w-full">
|
<div className="w-full">
|
||||||
<label className="form-label">Credit Destination <span className="text-red-500">*</span></label>
|
<label className="form-label">
|
||||||
|
Credit Destination <span className="text-red-500">*</span>
|
||||||
|
</label>
|
||||||
<Select
|
<Select
|
||||||
value={formField.credit_destination}
|
value={formField.credit_destination}
|
||||||
onValueChange={(value) => setFormField({ ...formField, credit_destination: value })}
|
onValueChange={(value) =>
|
||||||
|
setFormField({ ...formField, credit_destination: value })
|
||||||
|
}
|
||||||
>
|
>
|
||||||
<SelectTrigger>
|
<SelectTrigger>
|
||||||
<SelectValue placeholder="Select Customer" />
|
<SelectValue placeholder="Select Customer" />
|
||||||
@ -570,12 +608,16 @@ const EditFeeDialog = () => {
|
|||||||
</Select>
|
</Select>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<div className="w-full">
|
<div className="w-full">
|
||||||
<label className="form-label">Credit Destination Account <span className="text-red-500">*</span></label>
|
<label className="form-label">
|
||||||
|
Credit Destination Account <span className="text-red-500">*</span>
|
||||||
|
</label>
|
||||||
<Select
|
<Select
|
||||||
value={formField.credit_destination_account}
|
value={formField.credit_destination_account}
|
||||||
onValueChange={(value) => setFormField({ ...formField, credit_destination_account: value })}
|
onValueChange={(value) =>
|
||||||
|
setFormField({ ...formField, credit_destination_account: value })
|
||||||
|
}
|
||||||
>
|
>
|
||||||
<SelectTrigger>
|
<SelectTrigger>
|
||||||
<SelectValue placeholder="Select Wallet" />
|
<SelectValue placeholder="Select Wallet" />
|
||||||
@ -589,9 +631,11 @@ const EditFeeDialog = () => {
|
|||||||
</SelectContent>
|
</SelectContent>
|
||||||
</Select>
|
</Select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="w-full">
|
<div className="w-full">
|
||||||
<label className="form-label">Transaction Type ID <span className="text-red-500">*</span></label>
|
<label className="form-label">
|
||||||
|
Transaction Type ID <span className="text-red-500">*</span>
|
||||||
|
</label>
|
||||||
<Select
|
<Select
|
||||||
value={formField.transaction_type}
|
value={formField.transaction_type}
|
||||||
onValueChange={(transaction_type) =>
|
onValueChange={(transaction_type) =>
|
||||||
@ -610,9 +654,11 @@ const EditFeeDialog = () => {
|
|||||||
</SelectContent>
|
</SelectContent>
|
||||||
</Select>
|
</Select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="w-full">
|
<div className="w-full">
|
||||||
<label className="form-label">Status <span className="text-red-500">*</span></label>
|
<label className="form-label">
|
||||||
|
Status <span className="text-red-500">*</span>
|
||||||
|
</label>
|
||||||
<Select
|
<Select
|
||||||
value={formField.status}
|
value={formField.status}
|
||||||
onValueChange={(value) => setFormField({ ...formField, status: value })}
|
onValueChange={(value) => setFormField({ ...formField, status: value })}
|
||||||
@ -626,9 +672,11 @@ const EditFeeDialog = () => {
|
|||||||
</SelectContent>
|
</SelectContent>
|
||||||
</Select>
|
</Select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="w-full">
|
<div className="w-full">
|
||||||
<label className="form-label">Status Include <span className="text-red-500">*</span></label>
|
<label className="form-label">
|
||||||
|
Status Include <span className="text-red-500">*</span>
|
||||||
|
</label>
|
||||||
<Select
|
<Select
|
||||||
value={formField.status_include}
|
value={formField.status_include}
|
||||||
onValueChange={(value) => setFormField({ ...formField, status_include: value })}
|
onValueChange={(value) => setFormField({ ...formField, status_include: value })}
|
||||||
@ -642,9 +690,11 @@ const EditFeeDialog = () => {
|
|||||||
</SelectContent>
|
</SelectContent>
|
||||||
</Select>
|
</Select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="w-full">
|
<div className="w-full">
|
||||||
<label className="form-label">Priority <span className="text-red-500">*</span></label>
|
<label className="form-label">
|
||||||
|
Priority <span className="text-red-500">*</span>
|
||||||
|
</label>
|
||||||
<Select
|
<Select
|
||||||
value={formField.priority}
|
value={formField.priority}
|
||||||
onValueChange={(value) => setFormField({ ...formField, priority: value })}
|
onValueChange={(value) => setFormField({ ...formField, priority: value })}
|
||||||
@ -658,7 +708,7 @@ const EditFeeDialog = () => {
|
|||||||
</SelectContent>
|
</SelectContent>
|
||||||
</Select>
|
</Select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex justify-end pt-2.5 gap-5">
|
<div className="flex justify-end pt-2.5 gap-5">
|
||||||
<Button variant={'default'} type="submit" disabled={isSubmitting}>
|
<Button variant={'default'} type="submit" disabled={isSubmitting}>
|
||||||
{isSubmitting ? 'Saving...' : 'Save Changes'}
|
{isSubmitting ? 'Saving...' : 'Save Changes'}
|
||||||
@ -673,4 +723,4 @@ const EditFeeDialog = () => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export { EditFeeDialog };
|
export { EditFeeDialog };
|
||||||
|
|||||||
@ -1,391 +1,400 @@
|
|||||||
import { DataGridColumnHeader, DataGridProvider, KeenIcon } from '@/components';
|
import { DataGridColumnHeader, DataGridProvider, KeenIcon } from '@/components';
|
||||||
import { Toaster } from '@/components/ui/sonner';
|
import { Toaster } from '@/components/ui/sonner';
|
||||||
import { apiConfig } from '@/config/api.config';
|
import { apiConfig } from '@/config/api.config';
|
||||||
import { useCallApi } from '@/hooks';
|
import { useCallApi } from '@/hooks';
|
||||||
import { ColumnDef } from '@tanstack/react-table';
|
import { ColumnDef } from '@tanstack/react-table';
|
||||||
import { createContext, useCallback, useEffect, useMemo, useState } from 'react';
|
import { createContext, useCallback, useEffect, useMemo, useState } from 'react';
|
||||||
import ListToolbar from '../blocks/ListToolBar';
|
import ListToolbar from '../blocks/ListToolBar';
|
||||||
import DeleteDialog from '../blocks/DeleteDialog';
|
import DeleteDialog from '../blocks/DeleteDialog';
|
||||||
import { EditFeeDialog } from '../blocks/EditDialog';
|
import { EditFeeDialog } from '../blocks/EditDialog';
|
||||||
import { useManageTransferTypeContext } from '../../transfertype/hooks/useManageTransferTypeContext';
|
import { useManageTransferTypeContext } from '../../transfertype/hooks/useManageTransferTypeContext';
|
||||||
|
|
||||||
interface ContextProps {
|
interface ContextProps {
|
||||||
showEditFeeDialog: boolean;
|
showEditFeeDialog: boolean;
|
||||||
handleEditFeeDialog: (show: boolean, selected_TransferFee: string | null) => void;
|
handleEditFeeDialog: (show: boolean, selected_TransferFee: string | null) => void;
|
||||||
showAddFeeDialog: boolean;
|
showAddFeeDialog: boolean;
|
||||||
handleAddFeeDialog: (show: boolean) => void;
|
handleAddFeeDialog: (show: boolean) => void;
|
||||||
handleDeleteFeeDialog: (show: boolean, selected_TransferFee: string | null) => void;
|
handleDeleteFeeDialog: (show: boolean, selected_TransferFee: string | null) => void;
|
||||||
showDeleteFeeDialog: boolean;
|
showDeleteFeeDialog: boolean;
|
||||||
selectedTransferFee: string | null;
|
selectedTransferFee: string | null;
|
||||||
transactionTypeId: string | null;
|
transactionTypeId: string | null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
const initialProps: ContextProps = {
|
||||||
|
showEditFeeDialog: false,
|
||||||
|
handleEditFeeDialog: () => {},
|
||||||
|
showAddFeeDialog: false,
|
||||||
|
handleAddFeeDialog: () => {},
|
||||||
|
showDeleteFeeDialog: false,
|
||||||
|
handleDeleteFeeDialog: () => {},
|
||||||
|
selectedTransferFee: null,
|
||||||
|
transactionTypeId: null
|
||||||
|
};
|
||||||
|
|
||||||
const initialProps: ContextProps = {
|
interface TransferFeeProps {
|
||||||
showEditFeeDialog: false,
|
name: string;
|
||||||
handleEditFeeDialog: () => {},
|
description: string;
|
||||||
showAddFeeDialog: false,
|
minimum_amount: number;
|
||||||
handleAddFeeDialog: () => {},
|
maximum_amount: number;
|
||||||
showDeleteFeeDialog: false,
|
period_start: string;
|
||||||
handleDeleteFeeDialog: () => {},
|
period_end: string;
|
||||||
selectedTransferFee: null,
|
deduct_amount: number;
|
||||||
transactionTypeId: null,
|
deduct_percentage: number;
|
||||||
|
transaction_type: string;
|
||||||
|
status: string;
|
||||||
|
status_include: string;
|
||||||
|
fee: number;
|
||||||
|
}
|
||||||
|
|
||||||
};
|
const ManageTransferFeeContext = createContext<ContextProps>(initialProps);
|
||||||
|
const API_URL = apiConfig.service_transaction;
|
||||||
|
|
||||||
interface TransferFeeProps {
|
const ManageTransferFeeContextProvider = ({
|
||||||
name: string;
|
children,
|
||||||
description: string;
|
transactionTypeId = null
|
||||||
minimum_amount: number;
|
}: {
|
||||||
maximum_amount:number;
|
children: React.ReactNode;
|
||||||
period_start:string;
|
transactionTypeId?: string | null;
|
||||||
period_end:string;
|
}) => {
|
||||||
deduct_amount: number;
|
const [showEditFeeDialog, setShowEditFeeDialog] = useState(false);
|
||||||
deduct_percentage: number;
|
const [showAddFeeDialog, setShowAddFeeDialog] = useState(false);
|
||||||
transaction_type: string;
|
const [showDeleteFeeDialog, setShowDeleteFeeDialog] = useState(false);
|
||||||
status: string;
|
const { showAddDialog, handleAddDialog, selectedTransferType } = useManageTransferTypeContext();
|
||||||
status_include: string;
|
const [selectedTransferFee, setSelectedTransferFee] = useState<string | null>(null);
|
||||||
fee: number;
|
const { GetData } = useCallApi();
|
||||||
}
|
const handleEditFeeDialog = useCallback((show: boolean, selected_TransferFee: string | null) => {
|
||||||
|
setSelectedTransferFee(show ? selected_TransferFee : null);
|
||||||
|
setShowEditFeeDialog(show);
|
||||||
|
}, []);
|
||||||
|
|
||||||
const ManageTransferFeeContext = createContext<ContextProps>(initialProps);
|
const handleAddFeeDialog = useCallback((show: boolean) => {
|
||||||
const API_URL = apiConfig.service_transaction;
|
setShowAddFeeDialog(show);
|
||||||
|
}, []);
|
||||||
|
|
||||||
const ManageTransferFeeContextProvider = ({ children, transactionTypeId = null }: { children: React.ReactNode; transactionTypeId?: string | null }) => {
|
const handleDeleteFeeDialog = useCallback(
|
||||||
const [showEditFeeDialog, setShowEditFeeDialog] = useState(false);
|
(show: boolean, selected_TransferFee: string | null) => {
|
||||||
const [showAddFeeDialog, setShowAddFeeDialog] = useState(false);
|
|
||||||
const [showDeleteFeeDialog, setShowDeleteFeeDialog] = useState(false);
|
|
||||||
const { showAddDialog, handleAddDialog, selectedTransferType } = useManageTransferTypeContext();
|
|
||||||
const [selectedTransferFee, setSelectedTransferFee] = useState<string | null>(null);
|
|
||||||
const { GetData } = useCallApi();
|
|
||||||
const handleEditFeeDialog = useCallback((show: boolean, selected_TransferFee: string | null) => {
|
|
||||||
setSelectedTransferFee(show ? selected_TransferFee : null);
|
|
||||||
setShowEditFeeDialog(show);
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const handleAddFeeDialog = useCallback((show: boolean) => {
|
|
||||||
setShowAddFeeDialog(show);
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const handleDeleteFeeDialog = useCallback((show: boolean, selected_TransferFee: string | null) => {
|
|
||||||
setSelectedTransferFee(show ? selected_TransferFee : null);
|
setSelectedTransferFee(show ? selected_TransferFee : null);
|
||||||
setShowDeleteFeeDialog(show);
|
setShowDeleteFeeDialog(show);
|
||||||
}, []);
|
},
|
||||||
const doGetTransferFeeListData = async (
|
[]
|
||||||
page: number,
|
);
|
||||||
limit: number,
|
const doGetTransferFeeListData = async (
|
||||||
sorting: any,
|
page: number,
|
||||||
filter: any
|
limit: number,
|
||||||
) => {
|
sorting: any,
|
||||||
if (!selectedTransferType) {
|
filter: any
|
||||||
return { data: [], totalCount: 0 };
|
) => {
|
||||||
}
|
if (!selectedTransferType) {
|
||||||
|
return { data: [], totalCount: 0 };
|
||||||
sorting = sorting.length === 0 ? [{ id: 'id', desc: false }] : sorting;
|
}
|
||||||
filter = filter.length === 0 ? {} : { any: filter[0].value.toLowerCase() };
|
|
||||||
|
|
||||||
try {
|
|
||||||
const response = await GetData(`${API_URL}/transactionfees/getdatabytransactiontype/${selectedTransferType}`, {});
|
|
||||||
|
|
||||||
// console.log('API Response:', response?.data);
|
|
||||||
|
|
||||||
return {
|
|
||||||
data: response?.data ,
|
|
||||||
totalCount: 1
|
|
||||||
};
|
|
||||||
} catch (error) {
|
|
||||||
console.error("Error fetching transaction fees by transaction type:", error);
|
|
||||||
return { data: [], totalCount: 0 };
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const columns = useMemo<ColumnDef<any>[]>(
|
|
||||||
() => [
|
|
||||||
{
|
|
||||||
accessorFn: (row) => row.name,
|
|
||||||
id: 'name',
|
|
||||||
header: ({ column }) => <DataGridColumnHeader title="Name" column={column} />,
|
|
||||||
enableSorting: true,
|
|
||||||
enableHiding: false,
|
|
||||||
meta: { headerClassName: 'w-[200px]' }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
accessorFn: (row) => row.description,
|
|
||||||
id: 'description',
|
|
||||||
header: ({ column }) => <DataGridColumnHeader title="Description" column={column} />,
|
|
||||||
enableSorting: true,
|
|
||||||
enableHiding: false,
|
|
||||||
meta: { headerClassName: 'w-[250px]' }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
accessorFn: (row) => row.minimum_amount,
|
|
||||||
id: 'minimum_amount',
|
|
||||||
header: ({ column }) => <DataGridColumnHeader title="Min Amount" column={column} />,
|
|
||||||
enableSorting: true,
|
|
||||||
enableHiding: false,
|
|
||||||
meta: { headerClassName: 'w-[150px]' }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
accessorFn: (row) => row.maximum_amount,
|
|
||||||
id: 'maximum_amount',
|
|
||||||
header: ({ column }) => <DataGridColumnHeader title="Max Amount" column={column} />,
|
|
||||||
enableSorting: true,
|
|
||||||
enableHiding: false,
|
|
||||||
meta: { headerClassName: 'w-[150px]' }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
accessorFn: (row) => row.fee_amount,
|
|
||||||
id: 'fee_amount',
|
|
||||||
header: ({ column }) => <DataGridColumnHeader title="Fee Amount" column={column} />,
|
|
||||||
enableSorting: true,
|
|
||||||
enableHiding: false,
|
|
||||||
meta: { headerClassName: 'w-[150px]' }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
accessorFn: (row) => row.deduct_amount,
|
|
||||||
id: 'deduct_amount',
|
|
||||||
header: ({ column }) => <DataGridColumnHeader title="Deduct Amount" column={column} />,
|
|
||||||
enableSorting: true,
|
|
||||||
enableHiding: false,
|
|
||||||
meta: { headerClassName: 'w-[150px]' }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
accessorFn: (row) => row.deduct_percentage,
|
|
||||||
id: 'deduct_percentage',
|
|
||||||
header: ({ column }) => <DataGridColumnHeader title="Deduct %" column={column} />,
|
|
||||||
enableSorting: true,
|
|
||||||
enableHiding: false,
|
|
||||||
meta: { headerClassName: 'w-[150px]' }
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
accessorFn: (row) => row.period_start?.split('T')[0],
|
|
||||||
id: 'period_start',
|
|
||||||
header: ({ column }) => <DataGridColumnHeader title="Period Start" column={column} />,
|
|
||||||
enableSorting: true,
|
|
||||||
enableHiding: false,
|
|
||||||
meta: { headerClassName: 'w-[200px]' }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
accessorFn: (row) => row.period_end?.split('T')[0],
|
|
||||||
id: 'period_end',
|
|
||||||
header: ({ column }) => <DataGridColumnHeader title="Period End" column={column} />,
|
|
||||||
enableSorting: true,
|
|
||||||
enableHiding: false,
|
|
||||||
meta: { headerClassName: 'w-[200px]' }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
accessorFn: (row) => row.transaction_type?.name,
|
|
||||||
id: 'transactionTypeId',
|
|
||||||
header: ({ column }) => <DataGridColumnHeader title="Transaction Type" column={column} />,
|
|
||||||
enableSorting: true,
|
|
||||||
enableHiding: false,
|
|
||||||
meta: { headerClassName: 'w-[250px]' }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
accessorFn: (row: { credit_to: string }) => {
|
|
||||||
const mapping: Record<string, string> = {
|
|
||||||
D: 'Destination Member',
|
|
||||||
S: 'Source Member',
|
|
||||||
I: 'Input Customer'
|
|
||||||
};
|
|
||||||
|
|
||||||
return mapping[row.credit_to] || 'Unknown';
|
|
||||||
},
|
|
||||||
id: 'credit_to',
|
|
||||||
header: ({ column }) => (
|
|
||||||
<DataGridColumnHeader title="Credit To" column={column} />
|
|
||||||
),
|
|
||||||
enableSorting: true,
|
|
||||||
enableHiding: false,
|
|
||||||
meta: { headerClassName: 'w-[250px]' }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
accessorFn: (row) => {
|
|
||||||
if (row.credit_to === 'S' || row.credit_to === 'D' || !row.credit_destination) {
|
|
||||||
return 'N/A';
|
|
||||||
}
|
|
||||||
return row.credit_destination?.fullname;
|
|
||||||
},
|
|
||||||
id: 'credit_destination',
|
|
||||||
header: ({ column }) => <DataGridColumnHeader title="Credit Destination" column={column} />,
|
|
||||||
enableSorting: true,
|
|
||||||
enableHiding: false,
|
|
||||||
meta: { headerClassName: 'w-[250px]' }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
accessorFn: (row) => row.credit_destination_account?.description,
|
|
||||||
id: 'credit_destination_account',
|
|
||||||
header: ({ column }) => <DataGridColumnHeader title="Credit Destination Account" column={column} />,
|
|
||||||
enableSorting: true,
|
|
||||||
enableHiding: false,
|
|
||||||
meta: { headerClassName: 'w-[250px]' }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
accessorFn: (row: { deduct_from: string }) => {
|
|
||||||
const mapping: Record<string, string> = {
|
|
||||||
D: 'Destination Member',
|
|
||||||
S: 'Source Member',
|
|
||||||
};
|
|
||||||
|
|
||||||
return mapping[row.deduct_from];
|
|
||||||
},
|
|
||||||
id: 'deduct_from',
|
|
||||||
header: ({ column }) => (
|
|
||||||
<DataGridColumnHeader title="Deduct From" column={column} />
|
|
||||||
),
|
|
||||||
enableSorting: true,
|
|
||||||
enableHiding: false,
|
|
||||||
meta: { headerClassName: 'w-[250px]' }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
accessorFn: (row) => row.deduct_from_account?.description,
|
|
||||||
id: 'deduct_from_account',
|
|
||||||
header: ({ column }) => <DataGridColumnHeader title="Deduct From Account" column={column} />,
|
|
||||||
enableSorting: true,
|
|
||||||
enableHiding: false,
|
|
||||||
meta: { headerClassName: 'w-[250px]' }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
accessorFn: (row) => row.priority,
|
|
||||||
id: 'priority',
|
|
||||||
header: ({ column }) => <DataGridColumnHeader title="Priority" column={column} />,
|
|
||||||
enableSorting: true,
|
|
||||||
enableHiding: false,
|
|
||||||
cell: ({ row }) => {
|
|
||||||
const isActive = row.original.priority === 'Y';
|
|
||||||
|
|
||||||
return (
|
|
||||||
<span
|
|
||||||
className={`px-2 py-1 text-xs font-semibold rounded-full ${
|
|
||||||
isActive ? 'bg-green-100 text-green-600' : 'bg-red-100 text-red-600'
|
|
||||||
}`}
|
|
||||||
>
|
|
||||||
{isActive ? 'Yes' : 'No'}
|
|
||||||
</span>
|
|
||||||
);
|
|
||||||
},
|
|
||||||
meta: {
|
|
||||||
headerClassName: 'w-[100px]',
|
|
||||||
cellClassName: 'text-center'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
accessorFn: (row) => row.status,
|
|
||||||
id: 'status',
|
|
||||||
header: ({ column }) => <DataGridColumnHeader title="Status" column={column} />,
|
|
||||||
enableSorting: true,
|
|
||||||
enableHiding: false,
|
|
||||||
cell: ({ row }) => {
|
|
||||||
const isActive = row.original.status === 'Y';
|
|
||||||
|
|
||||||
return (
|
sorting = sorting.length === 0 ? [{ id: 'id', desc: false }] : sorting;
|
||||||
<span
|
filter = filter.length === 0 ? {} : { any: filter[0].value.toLowerCase() };
|
||||||
className={`px-2 py-1 text-xs font-semibold rounded-full ${
|
|
||||||
isActive ? 'bg-green-100 text-green-600' : 'bg-red-100 text-red-600'
|
|
||||||
}`}
|
|
||||||
>
|
|
||||||
{isActive ? 'Active' : 'Inactive'}
|
|
||||||
</span>
|
|
||||||
);
|
|
||||||
},
|
|
||||||
meta: {
|
|
||||||
headerClassName: 'w-[100px]',
|
|
||||||
cellClassName: 'text-center'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
accessorFn: (row) => row.status_include,
|
|
||||||
id: 'status_include',
|
|
||||||
header: ({ column }) => <DataGridColumnHeader title="Status Include" column={column} />,
|
|
||||||
enableSorting: true,
|
|
||||||
enableHiding: false,
|
|
||||||
cell: ({ row }) => {
|
|
||||||
const isActive = row.original.status_include === 'Y';
|
|
||||||
|
|
||||||
return (
|
try {
|
||||||
<span
|
const response = await GetData(
|
||||||
className={`px-2 py-1 text-xs font-semibold rounded-full ${
|
`${API_URL}/transactionfees/getdatabytransactiontype/${selectedTransferType}`,
|
||||||
isActive ? 'bg-green-100 text-green-600' : 'bg-red-100 text-red-600'
|
{}
|
||||||
}`}
|
);
|
||||||
>
|
|
||||||
{isActive ? 'Yes' : 'No'}
|
|
||||||
</span>
|
|
||||||
);
|
|
||||||
},
|
|
||||||
meta: {
|
|
||||||
headerClassName: 'w-[100px]',
|
|
||||||
cellClassName: 'text-center'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'actions',
|
|
||||||
header: ({ column }) => <DataGridColumnHeader title="Actions" column={column} />,
|
|
||||||
enableSorting: false,
|
|
||||||
enableHiding: false,
|
|
||||||
cell: (data) => {
|
|
||||||
const row = data.row.original;
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<button
|
|
||||||
className="btn btn-sm btn-icon btn-clear btn-light"
|
|
||||||
onClick={() => handleEditFeeDialog(true, row.id)}
|
|
||||||
>
|
|
||||||
<KeenIcon icon="notepad-edit" />
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
className="btn btn-sm btn-icon btn-clear btn-light"
|
|
||||||
onClick={() => handleDeleteFeeDialog(true, row.id)}
|
|
||||||
>
|
|
||||||
<KeenIcon icon="trash" />
|
|
||||||
</button>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
},
|
|
||||||
meta: {
|
|
||||||
headerClassName: 'w-[100px]',
|
|
||||||
cellClassName: 'text-center'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[handleEditFeeDialog, handleDeleteFeeDialog]
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
// console.log('API Response:', response?.data);
|
||||||
<div className="container mx-auto py-5">
|
|
||||||
<div className="flex justify-between items-center mt-6">
|
|
||||||
<h1 className="text-xl font-semibold text-gray-900">Manage Transaction Fee</h1>
|
|
||||||
</div>
|
|
||||||
<ManageTransferFeeContext.Provider
|
|
||||||
value={{
|
|
||||||
showEditFeeDialog,
|
|
||||||
handleEditFeeDialog,
|
|
||||||
showAddFeeDialog,
|
|
||||||
handleAddFeeDialog,
|
|
||||||
selectedTransferFee,
|
|
||||||
showDeleteFeeDialog,
|
|
||||||
handleDeleteFeeDialog,
|
|
||||||
transactionTypeId
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Toaster expand visibleToasts={9} duration={3000} />
|
|
||||||
<DataGridProvider
|
|
||||||
columns={columns}
|
|
||||||
pagination={{ size: 10 }}
|
|
||||||
layout={{ card: true }}
|
|
||||||
toolbar={<ListToolbar />}
|
|
||||||
sorting={[{ id: 'id', desc: true }]}
|
|
||||||
serverSide={true}
|
|
||||||
onFetchData={({ pageIndex, pageSize, sorting, columnFilters }) =>
|
|
||||||
doGetTransferFeeListData(pageIndex, pageSize, sorting, columnFilters)
|
|
||||||
}
|
|
||||||
>
|
|
||||||
{children}
|
|
||||||
|
|
||||||
</DataGridProvider>
|
return {
|
||||||
</ManageTransferFeeContext.Provider>
|
data: response?.data,
|
||||||
</div>
|
totalCount: 1
|
||||||
);
|
};
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error fetching transaction fees by transaction type:', error);
|
||||||
|
return { data: [], totalCount: 0 };
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export { ManageTransferFeeContext, ManageTransferFeeContextProvider };
|
const columns = useMemo<ColumnDef<any>[]>(
|
||||||
|
() => [
|
||||||
|
{
|
||||||
|
accessorFn: (row) => row.name,
|
||||||
|
id: 'name',
|
||||||
|
header: ({ column }) => <DataGridColumnHeader title="Name" column={column} />,
|
||||||
|
enableSorting: true,
|
||||||
|
enableHiding: false,
|
||||||
|
meta: { headerClassName: 'w-[200px]' }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accessorFn: (row) => row.description,
|
||||||
|
id: 'description',
|
||||||
|
header: ({ column }) => <DataGridColumnHeader title="Description" column={column} />,
|
||||||
|
enableSorting: true,
|
||||||
|
enableHiding: false,
|
||||||
|
meta: { headerClassName: 'w-[250px]' }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accessorFn: (row) => row.minimum_amount,
|
||||||
|
id: 'minimum_amount',
|
||||||
|
header: ({ column }) => <DataGridColumnHeader title="Min Amount" column={column} />,
|
||||||
|
enableSorting: true,
|
||||||
|
enableHiding: false,
|
||||||
|
meta: { headerClassName: 'w-[150px]' }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accessorFn: (row) => row.maximum_amount,
|
||||||
|
id: 'maximum_amount',
|
||||||
|
header: ({ column }) => <DataGridColumnHeader title="Max Amount" column={column} />,
|
||||||
|
enableSorting: true,
|
||||||
|
enableHiding: false,
|
||||||
|
meta: { headerClassName: 'w-[150px]' }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accessorFn: (row) => row.fee_amount,
|
||||||
|
id: 'fee_amount',
|
||||||
|
header: ({ column }) => <DataGridColumnHeader title="Fee Amount" column={column} />,
|
||||||
|
enableSorting: true,
|
||||||
|
enableHiding: false,
|
||||||
|
meta: { headerClassName: 'w-[150px]' }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accessorFn: (row) => row.deduct_amount,
|
||||||
|
id: 'deduct_amount',
|
||||||
|
header: ({ column }) => <DataGridColumnHeader title="Deduct Amount" column={column} />,
|
||||||
|
enableSorting: true,
|
||||||
|
enableHiding: false,
|
||||||
|
meta: { headerClassName: 'w-[150px]' }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accessorFn: (row) => row.deduct_percentage,
|
||||||
|
id: 'deduct_percentage',
|
||||||
|
header: ({ column }) => <DataGridColumnHeader title="Deduct %" column={column} />,
|
||||||
|
enableSorting: true,
|
||||||
|
enableHiding: false,
|
||||||
|
meta: { headerClassName: 'w-[150px]' }
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
accessorFn: (row) => row.period_start?.split('T')[0],
|
||||||
|
id: 'period_start',
|
||||||
|
header: ({ column }) => <DataGridColumnHeader title="Period Start" column={column} />,
|
||||||
|
enableSorting: true,
|
||||||
|
enableHiding: false,
|
||||||
|
meta: { headerClassName: 'w-[200px]' }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accessorFn: (row) => row.period_end?.split('T')[0],
|
||||||
|
id: 'period_end',
|
||||||
|
header: ({ column }) => <DataGridColumnHeader title="Period End" column={column} />,
|
||||||
|
enableSorting: true,
|
||||||
|
enableHiding: false,
|
||||||
|
meta: { headerClassName: 'w-[200px]' }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accessorFn: (row) => row.transaction_type?.name,
|
||||||
|
id: 'transactionTypeId',
|
||||||
|
header: ({ column }) => <DataGridColumnHeader title="Transaction Type" column={column} />,
|
||||||
|
enableSorting: true,
|
||||||
|
enableHiding: false,
|
||||||
|
meta: { headerClassName: 'w-[250px]' }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accessorFn: (row: { credit_to: string }) => {
|
||||||
|
const mapping: Record<string, string> = {
|
||||||
|
D: 'Destination Member',
|
||||||
|
S: 'Source Member',
|
||||||
|
I: 'Input Customer'
|
||||||
|
};
|
||||||
|
|
||||||
|
return mapping[row.credit_to] || 'Unknown';
|
||||||
|
},
|
||||||
|
id: 'credit_to',
|
||||||
|
header: ({ column }) => <DataGridColumnHeader title="Credit To" column={column} />,
|
||||||
|
enableSorting: true,
|
||||||
|
enableHiding: false,
|
||||||
|
meta: { headerClassName: 'w-[250px]' }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accessorFn: (row) => {
|
||||||
|
if (row.credit_to === 'S' || row.credit_to === 'D' || !row.credit_destination) {
|
||||||
|
return 'N/A';
|
||||||
|
}
|
||||||
|
return row.credit_destination?.fullname;
|
||||||
|
},
|
||||||
|
id: 'credit_destination',
|
||||||
|
header: ({ column }) => <DataGridColumnHeader title="Credit Destination" column={column} />,
|
||||||
|
enableSorting: true,
|
||||||
|
enableHiding: false,
|
||||||
|
meta: { headerClassName: 'w-[250px]' }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accessorFn: (row) => row.credit_destination_account?.description,
|
||||||
|
id: 'credit_destination_account',
|
||||||
|
header: ({ column }) => (
|
||||||
|
<DataGridColumnHeader title="Credit Destination Account" column={column} />
|
||||||
|
),
|
||||||
|
enableSorting: true,
|
||||||
|
enableHiding: false,
|
||||||
|
meta: { headerClassName: 'w-[250px]' }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accessorFn: (row: { deduct_from: string }) => {
|
||||||
|
const mapping: Record<string, string> = {
|
||||||
|
D: 'Destination Member',
|
||||||
|
S: 'Source Member'
|
||||||
|
};
|
||||||
|
|
||||||
|
return mapping[row.deduct_from];
|
||||||
|
},
|
||||||
|
id: 'deduct_from',
|
||||||
|
header: ({ column }) => <DataGridColumnHeader title="Deduct From" column={column} />,
|
||||||
|
enableSorting: true,
|
||||||
|
enableHiding: false,
|
||||||
|
meta: { headerClassName: 'w-[250px]' }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accessorFn: (row) => row.deduct_from_account?.description,
|
||||||
|
id: 'deduct_from_account',
|
||||||
|
header: ({ column }) => (
|
||||||
|
<DataGridColumnHeader title="Deduct From Account" column={column} />
|
||||||
|
),
|
||||||
|
enableSorting: true,
|
||||||
|
enableHiding: false,
|
||||||
|
meta: { headerClassName: 'w-[250px]' }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accessorFn: (row) => row.priority,
|
||||||
|
id: 'priority',
|
||||||
|
header: ({ column }) => <DataGridColumnHeader title="Priority" column={column} />,
|
||||||
|
enableSorting: true,
|
||||||
|
enableHiding: false,
|
||||||
|
cell: ({ row }) => {
|
||||||
|
const isActive = row.original.priority === 'Y';
|
||||||
|
|
||||||
|
return (
|
||||||
|
<span
|
||||||
|
className={`px-2 py-1 text-xs font-semibold rounded-full ${
|
||||||
|
isActive ? 'bg-green-100 text-green-600' : 'bg-red-100 text-red-600'
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
{isActive ? 'Yes' : 'No'}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
meta: {
|
||||||
|
headerClassName: 'w-[100px]',
|
||||||
|
cellClassName: 'text-center'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accessorFn: (row) => row.status,
|
||||||
|
id: 'status',
|
||||||
|
header: ({ column }) => <DataGridColumnHeader title="Status" column={column} />,
|
||||||
|
enableSorting: true,
|
||||||
|
enableHiding: false,
|
||||||
|
cell: ({ row }) => {
|
||||||
|
const isActive = row.original.status === 'Y';
|
||||||
|
|
||||||
|
return (
|
||||||
|
<span
|
||||||
|
className={`px-2 py-1 text-xs font-semibold rounded-full ${
|
||||||
|
isActive ? 'bg-green-100 text-green-600' : 'bg-red-100 text-red-600'
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
{isActive ? 'Active' : 'Inactive'}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
meta: {
|
||||||
|
headerClassName: 'w-[100px]',
|
||||||
|
cellClassName: 'text-center'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accessorFn: (row) => row.status_include,
|
||||||
|
id: 'status_include',
|
||||||
|
header: ({ column }) => <DataGridColumnHeader title="Status Include" column={column} />,
|
||||||
|
enableSorting: true,
|
||||||
|
enableHiding: false,
|
||||||
|
cell: ({ row }) => {
|
||||||
|
const isActive = row.original.status_include === 'Y';
|
||||||
|
|
||||||
|
return (
|
||||||
|
<span
|
||||||
|
className={`px-2 py-1 text-xs font-semibold rounded-full ${
|
||||||
|
isActive ? 'bg-green-100 text-green-600' : 'bg-red-100 text-red-600'
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
{isActive ? 'Yes' : 'No'}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
meta: {
|
||||||
|
headerClassName: 'w-[100px]',
|
||||||
|
cellClassName: 'text-center'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'actions',
|
||||||
|
header: ({ column }) => <DataGridColumnHeader title="Actions" column={column} />,
|
||||||
|
enableSorting: false,
|
||||||
|
enableHiding: false,
|
||||||
|
cell: (data) => {
|
||||||
|
const row = data.row.original;
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<button
|
||||||
|
className="btn btn-sm btn-icon btn-clear btn-light"
|
||||||
|
onClick={() => handleEditFeeDialog(true, row.id)}
|
||||||
|
>
|
||||||
|
<KeenIcon icon="notepad-edit" />
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
className="btn btn-sm btn-icon btn-clear btn-light"
|
||||||
|
onClick={() => handleDeleteFeeDialog(true, row.id)}
|
||||||
|
>
|
||||||
|
<KeenIcon icon="trash" />
|
||||||
|
</button>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
meta: {
|
||||||
|
headerClassName: 'w-[100px]',
|
||||||
|
cellClassName: 'text-center'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[handleEditFeeDialog, handleDeleteFeeDialog]
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="container mx-auto py-5">
|
||||||
|
<div className="flex justify-between items-center mt-6">
|
||||||
|
<h1 className="text-xl font-semibold text-gray-900">Manage Transaction Fee</h1>
|
||||||
|
</div>
|
||||||
|
<ManageTransferFeeContext.Provider
|
||||||
|
value={{
|
||||||
|
showEditFeeDialog,
|
||||||
|
handleEditFeeDialog,
|
||||||
|
showAddFeeDialog,
|
||||||
|
handleAddFeeDialog,
|
||||||
|
selectedTransferFee,
|
||||||
|
showDeleteFeeDialog,
|
||||||
|
handleDeleteFeeDialog,
|
||||||
|
transactionTypeId
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Toaster expand visibleToasts={9} duration={3000} />
|
||||||
|
<DataGridProvider
|
||||||
|
columns={columns}
|
||||||
|
pagination={{ size: 10 }}
|
||||||
|
layout={{ card: true }}
|
||||||
|
toolbar={<ListToolbar />}
|
||||||
|
sorting={[{ id: 'id', desc: true }]}
|
||||||
|
serverSide={true}
|
||||||
|
onFetchData={({ pageIndex, pageSize, sorting, columnFilters }) =>
|
||||||
|
doGetTransferFeeListData(pageIndex, pageSize, sorting, columnFilters)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</DataGridProvider>
|
||||||
|
</ManageTransferFeeContext.Provider>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export { ManageTransferFeeContext, ManageTransferFeeContextProvider };
|
||||||
|
|||||||
@ -76,7 +76,6 @@ const AddDialog = () => {
|
|||||||
wallet_origin: '',
|
wallet_origin: '',
|
||||||
wallet_destination: '',
|
wallet_destination: '',
|
||||||
|
|
||||||
|
|
||||||
minimum_amount: 0,
|
minimum_amount: 0,
|
||||||
maximum_amount: 0,
|
maximum_amount: 0,
|
||||||
max_transaction_per_day: 0,
|
max_transaction_per_day: 0,
|
||||||
@ -141,13 +140,13 @@ const AddDialog = () => {
|
|||||||
toast.success('Success Create Transfer Type');
|
toast.success('Success Create Transfer Type');
|
||||||
reload();
|
reload();
|
||||||
resetForm();
|
resetForm();
|
||||||
const createActivity = {
|
const createActivity = {
|
||||||
module: 'Manage Transfer Type',
|
module: 'Manage Transfer Type',
|
||||||
description: `Create Transfer Type => ${formField.name}`,
|
description: `Create Transfer Type => ${formField.name}`,
|
||||||
action: 'C'
|
action: 'C'
|
||||||
};
|
};
|
||||||
|
|
||||||
doSaveLogActivity(createActivity);
|
doSaveLogActivity(createActivity);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
@ -222,7 +221,7 @@ const AddDialog = () => {
|
|||||||
page: 1,
|
page: 1,
|
||||||
with_deleted: false,
|
with_deleted: false,
|
||||||
order_field: 'wallets.name',
|
order_field: 'wallets.name',
|
||||||
order_direction: 'ASC',
|
order_direction: 'ASC'
|
||||||
};
|
};
|
||||||
const response = await GetData(`${API_URL_MASTERDATA}/wallet/list`, params);
|
const response = await GetData(`${API_URL_MASTERDATA}/wallet/list`, params);
|
||||||
// console.log(response)
|
// console.log(response)
|
||||||
@ -265,11 +264,11 @@ const AddDialog = () => {
|
|||||||
<DialogBody className="scrollable-y px-0 pb-0" ref={parentRef}>
|
<DialogBody className="scrollable-y px-0 pb-0" ref={parentRef}>
|
||||||
<div className="flex flex-col px-0">
|
<div className="flex flex-col px-0">
|
||||||
{alert.show && (
|
{alert.show && (
|
||||||
<div className="sticky top-0 z-10 bg-white p-3">
|
<div className="sticky top-0 z-10 bg-white p-3">
|
||||||
<Alert variant="danger" className="mb-3">
|
<Alert variant="danger" className="mb-3">
|
||||||
<h3>{alert.message}</h3>
|
<h3>{alert.message}</h3>
|
||||||
</Alert>
|
</Alert>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<form action="" onSubmit={handleSubmit}>
|
<form action="" onSubmit={handleSubmit}>
|
||||||
<div className="card-body grid gap-5 p-0">
|
<div className="card-body grid gap-5 p-0">
|
||||||
@ -439,11 +438,10 @@ const AddDialog = () => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div className="w-full">
|
<div className="w-full">
|
||||||
<div className="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
<div className="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||||
<label className="form-label flex items-center gap-1 max-w-56">
|
<label className="form-label flex items-center gap-1 max-w-56">
|
||||||
Status Transaction Type
|
Status Transaction Type
|
||||||
<span className="text-red-500"> *</span>
|
<span className="text-red-500"> *</span>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
@ -458,7 +456,7 @@ const AddDialog = () => {
|
|||||||
<SelectValue placeholder="Select" />
|
<SelectValue placeholder="Select" />
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
<SelectContent>
|
<SelectContent>
|
||||||
<SelectItem value="D">Disbursement </SelectItem>
|
<SelectItem value="D">Disbursement </SelectItem>
|
||||||
<SelectItem value="O">Other </SelectItem>
|
<SelectItem value="O">Other </SelectItem>
|
||||||
<SelectItem value="CA">Change Group Emoney Customer to Agent </SelectItem>
|
<SelectItem value="CA">Change Group Emoney Customer to Agent </SelectItem>
|
||||||
<SelectItem value="AC">Change Group Emoney Agent to Customer </SelectItem>
|
<SelectItem value="AC">Change Group Emoney Agent to Customer </SelectItem>
|
||||||
|
|||||||
@ -1,4 +1,10 @@
|
|||||||
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 { Button } from '@/components/ui/button';
|
||||||
import { Alert, useDataGrid } from '@/components';
|
import { Alert, useDataGrid } from '@/components';
|
||||||
import { useCallback, useState } from 'react';
|
import { useCallback, useState } from 'react';
|
||||||
@ -12,7 +18,8 @@ import { doSaveLogActivity } from '@/actions/GlobalActions';
|
|||||||
const API_URL = apiConfig.service_transaction;
|
const API_URL = apiConfig.service_transaction;
|
||||||
|
|
||||||
const DeleteDialog = () => {
|
const DeleteDialog = () => {
|
||||||
const { showDeleteDialog, handleDeleteDialog, selectedTransferType } = useManageTransferTypeContext();
|
const { showDeleteDialog, handleDeleteDialog, selectedTransferType } =
|
||||||
|
useManageTransferTypeContext();
|
||||||
const { reload } = useDataGrid();
|
const { reload } = useDataGrid();
|
||||||
const { DeleteData } = useCallApi();
|
const { DeleteData } = useCallApi();
|
||||||
const [alert, setAlert] = useState({
|
const [alert, setAlert] = useState({
|
||||||
@ -26,9 +33,12 @@ const DeleteDialog = () => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = await DeleteData(`${API_URL}/transactiontype/delete/${selectedTransferType}/false`, {
|
const response = await DeleteData(
|
||||||
id: selectedTransferType
|
`${API_URL}/transactiontype/delete/${selectedTransferType}/false`,
|
||||||
});
|
{
|
||||||
|
id: selectedTransferType
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
if (response?.status) {
|
if (response?.status) {
|
||||||
setAlert({ show: false, message: '' });
|
setAlert({ show: false, message: '' });
|
||||||
@ -37,7 +47,7 @@ const DeleteDialog = () => {
|
|||||||
const createActivity = {
|
const createActivity = {
|
||||||
module: 'Manage Transfer Type',
|
module: 'Manage Transfer Type',
|
||||||
description: `Delete Transfer Type => ${selectedTransferType}`,
|
description: `Delete Transfer Type => ${selectedTransferType}`,
|
||||||
action: 'D'
|
action: 'D'
|
||||||
};
|
};
|
||||||
doSaveLogActivity(createActivity);
|
doSaveLogActivity(createActivity);
|
||||||
// setTimeout(() => toast.success('Success Delete Transaction Type'), 0);
|
// setTimeout(() => toast.success('Success Delete Transaction Type'), 0);
|
||||||
@ -51,7 +61,9 @@ const DeleteDialog = () => {
|
|||||||
<DialogContent className="container-fixed max-w-md flex flex-col p-5 overflow-hidden [&>button]:hidden">
|
<DialogContent className="container-fixed max-w-md flex flex-col p-5 overflow-hidden [&>button]:hidden">
|
||||||
<DialogHeader className="p-0 border-0 block">
|
<DialogHeader className="p-0 border-0 block">
|
||||||
<DialogTitle className="text-lg">Delete Transfer Type</DialogTitle>
|
<DialogTitle className="text-lg">Delete Transfer Type</DialogTitle>
|
||||||
<DialogDescription className="text-sm">Are you sure you want to delete this data?</DialogDescription>
|
<DialogDescription className="text-sm">
|
||||||
|
Are you sure you want to delete this data?
|
||||||
|
</DialogDescription>
|
||||||
<Alert variant="warning">
|
<Alert variant="warning">
|
||||||
<h3 className="text-lg">Are you sure?</h3>
|
<h3 className="text-lg">Are you sure?</h3>
|
||||||
<span className="text-sm">You will delete this data!</span>
|
<span className="text-sm">You will delete this data!</span>
|
||||||
|
|||||||
@ -589,7 +589,7 @@ const EditDialog = () => {
|
|||||||
<SelectValue placeholder="Select" />
|
<SelectValue placeholder="Select" />
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
<SelectContent>
|
<SelectContent>
|
||||||
<SelectItem value="D">Disbursement </SelectItem>
|
<SelectItem value="D">Disbursement </SelectItem>
|
||||||
<SelectItem value="O">Other </SelectItem>
|
<SelectItem value="O">Other </SelectItem>
|
||||||
<SelectItem value="CA">Change Group Emoney Customer to Agent </SelectItem>
|
<SelectItem value="CA">Change Group Emoney Customer to Agent </SelectItem>
|
||||||
<SelectItem value="AC">Change Group Emoney Agent to Customer </SelectItem>
|
<SelectItem value="AC">Change Group Emoney Agent to Customer </SelectItem>
|
||||||
|
|||||||
@ -147,21 +147,21 @@ const ManageTransferTypeContextProvider = ({ children }: { children: React.React
|
|||||||
meta: { headerClassName: 'w-[250px]' }
|
meta: { headerClassName: 'w-[250px]' }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
accessorFn: (row: {type: string }) => {
|
accessorFn: (row: { type: string }) => {
|
||||||
const mapping: Record<string, string> = {
|
const mapping: Record<string, string> = {
|
||||||
D: 'Disbursement',
|
D: 'Disbursement',
|
||||||
O: 'Other',
|
O: 'Other',
|
||||||
CA: 'Change Group Emoney Customer to Agent',
|
CA: 'Change Group Emoney Customer to Agent',
|
||||||
AC:'Change Group Emoney Agent to Customer',
|
AC: 'Change Group Emoney Agent to Customer',
|
||||||
PC: 'Change Group Point Agent to Customer',
|
PC: 'Change Group Point Agent to Customer',
|
||||||
PA: 'Change Group Point Customer to Agent',
|
PA: 'Change Group Point Customer to Agent',
|
||||||
CE:'Return Customer Emoney',
|
CE: 'Return Customer Emoney',
|
||||||
AD:'Return Agent Deposit',
|
AD: 'Return Agent Deposit',
|
||||||
AM: 'Return Agent Merchant',
|
AM: 'Return Agent Merchant',
|
||||||
AE: 'Return Agent Emoney',
|
AE: 'Return Agent Emoney',
|
||||||
R: 'Reward Point',
|
R: 'Reward Point'
|
||||||
};
|
};
|
||||||
|
|
||||||
return mapping[row.type] || 'Unknown';
|
return mapping[row.type] || 'Unknown';
|
||||||
},
|
},
|
||||||
id: 'type',
|
id: 'type',
|
||||||
@ -171,7 +171,7 @@ const ManageTransferTypeContextProvider = ({ children }: { children: React.React
|
|||||||
enableSorting: true,
|
enableSorting: true,
|
||||||
enableHiding: false,
|
enableHiding: false,
|
||||||
meta: { headerClassName: 'w-[250px]' }
|
meta: { headerClassName: 'w-[250px]' }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
accessorFn: (row) => (row.status === 'Y' ? 'Active' : 'Inactive'),
|
accessorFn: (row) => (row.status === 'Y' ? 'Active' : 'Inactive'),
|
||||||
id: 'status',
|
id: 'status',
|
||||||
@ -217,20 +217,19 @@ const ManageTransferTypeContextProvider = ({ children }: { children: React.React
|
|||||||
],
|
],
|
||||||
[handleEditDialog, handleDeleteDialog]
|
[handleEditDialog, handleDeleteDialog]
|
||||||
);
|
);
|
||||||
|
|
||||||
const doGetTransferTypeListData = async (
|
const doGetTransferTypeListData = async (
|
||||||
page: number,
|
page: number,
|
||||||
limit: number,
|
limit: number,
|
||||||
sorting: any,
|
sorting: any,
|
||||||
filter: any
|
filter: any
|
||||||
) => {
|
) => {
|
||||||
|
|
||||||
const orderField = 'created_at';
|
const orderField = 'created_at';
|
||||||
|
|
||||||
const orderDirection = sorting.length > 0 ? (sorting[0].desc ? 'DESC' : 'ASC') : 'DESC';
|
const orderDirection = sorting.length > 0 ? (sorting[0].desc ? 'DESC' : 'ASC') : 'DESC';
|
||||||
|
|
||||||
filter = filter.length == 0 ? {} : { any: filter[0].value?.toLowerCase() };
|
filter = filter.length == 0 ? {} : { any: filter[0].value?.toLowerCase() };
|
||||||
|
|
||||||
const response = await GetData(`${API_URL}/transactiontype/list`, {
|
const response = await GetData(`${API_URL}/transactiontype/list`, {
|
||||||
limit: limit,
|
limit: limit,
|
||||||
page: page + 1,
|
page: page + 1,
|
||||||
@ -281,4 +280,4 @@ const ManageTransferTypeContextProvider = ({ children }: { children: React.React
|
|||||||
};
|
};
|
||||||
|
|
||||||
export { ManageTransferTypeContext, ManageTransferTypeContextProvider };
|
export { ManageTransferTypeContext, ManageTransferTypeContextProvider };
|
||||||
export type { TransferType };
|
export type { TransferType };
|
||||||
|
|||||||
@ -15,6 +15,7 @@ import ManagePositionPage from '@/pages/settings/user/manage-position/ManagePosi
|
|||||||
import ManageAccount from '@/pages/account/manage-account/ManageAccount';
|
import ManageAccount from '@/pages/account/manage-account/ManageAccount';
|
||||||
import ManageGroups from '@/pages/groups/ManageGroups';
|
import ManageGroups from '@/pages/groups/ManageGroups';
|
||||||
import ManageMembers from '@/pages/members/manage-members/ManageMembers';
|
import ManageMembers from '@/pages/members/manage-members/ManageMembers';
|
||||||
|
import ManageKycDeletion from '@/pages/members/kyc-delete-member/ManageKycDeletion';
|
||||||
import Kyc from '@/pages/members/kyc/Kyc';
|
import Kyc from '@/pages/members/kyc/Kyc';
|
||||||
import AccessType from '@/pages/access/access-type/AccessType';
|
import AccessType from '@/pages/access/access-type/AccessType';
|
||||||
import MemberCredential from '@/pages/access/member-credentials/MemberCredentials';
|
import MemberCredential from '@/pages/access/member-credentials/MemberCredentials';
|
||||||
@ -79,6 +80,7 @@ const AppRoutingSetup = (): ReactElement => {
|
|||||||
|
|
||||||
<Route path="/members/kyc" element={<Kyc />} />
|
<Route path="/members/kyc" element={<Kyc />} />
|
||||||
<Route path="/members/member-management" element={<ManageMembers />} />
|
<Route path="/members/member-management" element={<ManageMembers />} />
|
||||||
|
<Route path="/members/kyc-delete-member" element={<ManageKycDeletion />} />
|
||||||
<Route path="/members/create-member-credential" element={<MemberCredential />} />
|
<Route path="/members/create-member-credential" element={<MemberCredential />} />
|
||||||
|
|
||||||
<Route path="/access/access-type-management" element={<AccessType />} />
|
<Route path="/access/access-type-management" element={<AccessType />} />
|
||||||
|
|||||||
Reference in New Issue
Block a user