Merge branch 'master' of https://git.shiblysolution.id/TPAY/dashboard
This commit is contained in:
@ -30,7 +30,7 @@ import {
|
|||||||
DialogDescription,
|
DialogDescription,
|
||||||
DialogHeader,
|
DialogHeader,
|
||||||
DialogTitle,
|
DialogTitle,
|
||||||
DialogTrigger,
|
DialogTrigger
|
||||||
} from './dialog';
|
} from './dialog';
|
||||||
|
|
||||||
interface DataTableProps<TData, TValue> {
|
interface DataTableProps<TData, TValue> {
|
||||||
@ -67,7 +67,7 @@ export function DataTable<TData, TValue>({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<div className="flex items-center py-4 justify-between">
|
<div className="flex items-center py-4 justify-between w-full">
|
||||||
<Input
|
<Input
|
||||||
placeholder="Search"
|
placeholder="Search"
|
||||||
value={(table.getColumn('name')?.getFilterValue() as string) ?? ''}
|
value={(table.getColumn('name')?.getFilterValue() as string) ?? ''}
|
||||||
@ -107,18 +107,20 @@ export function DataTable<TData, TValue>({
|
|||||||
<div className="space-x-2">
|
<div className="space-x-2">
|
||||||
<button
|
<button
|
||||||
className="btn btn-sm btn-icon btn-clear btn-light"
|
className="btn btn-sm btn-icon btn-clear btn-light"
|
||||||
onClick={() => onUpdate(row.original)}>
|
onClick={() => onUpdate(row.original)}
|
||||||
|
>
|
||||||
<KeenIcon icon="notepad-edit" />
|
<KeenIcon icon="notepad-edit" />
|
||||||
</button>
|
</button>
|
||||||
{
|
{onDelete ? (
|
||||||
onDelete ? (
|
<button
|
||||||
<button
|
|
||||||
className="btn btn-sm btn-icon btn-clear btn-light"
|
className="btn btn-sm btn-icon btn-clear btn-light"
|
||||||
onClick={() => onDelete(row.original)}>
|
onClick={() => onDelete(row.original)}
|
||||||
|
>
|
||||||
<KeenIcon icon="trash" />
|
<KeenIcon icon="trash" />
|
||||||
</button>
|
</button>
|
||||||
) : ('')
|
) : (
|
||||||
}
|
''
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
|||||||
@ -3,6 +3,7 @@ interface apiConfigProps {
|
|||||||
service_customer: string;
|
service_customer: string;
|
||||||
service_master_data: string;
|
service_master_data: string;
|
||||||
service_transaction: string;
|
service_transaction: string;
|
||||||
|
service_wallet: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const API_URL = import.meta.env.VITE_APP_API_URL;
|
const API_URL = import.meta.env.VITE_APP_API_URL;
|
||||||
@ -12,7 +13,8 @@ const apiConfig: apiConfigProps = {
|
|||||||
service_customer: `${API_URL}/c`,
|
service_customer: `${API_URL}/c`,
|
||||||
// service_master_data: `${API_URL}/m`
|
// service_master_data: `${API_URL}/m`
|
||||||
service_master_data: `${API_URL}/t`,
|
service_master_data: `${API_URL}/t`,
|
||||||
service_transaction: `${API_URL}/tt`
|
service_transaction: `${API_URL}/tt`,
|
||||||
|
service_wallet: `${API_URL}/w`
|
||||||
};
|
};
|
||||||
|
|
||||||
export { apiConfig };
|
export { apiConfig };
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
import { apiConfig } from '@/config/api.config';
|
import { apiConfig } from '@/config/api.config';
|
||||||
import { Account, columns } from './Columns';
|
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { getData } from '@/utils';
|
import { getData } from '@/utils';
|
||||||
import { useCallApi } from '@/hooks';
|
import { useCallApi } from '@/hooks';
|
||||||
import { DataTable } from '@/components/ui/DataTable';
|
import { DataTable } from '@/components/ui/DataTable';
|
||||||
import { Breadcrumbs, Link } from '@mui/material';
|
import { Breadcrumbs, Link } from '@mui/material';
|
||||||
|
import { Account, columns } from './Columns';
|
||||||
|
|
||||||
const API_URL = apiConfig.service_dashboard;
|
const API_URL = apiConfig.service_dashboard;
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ const ManageAccount = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<div className="container mx-auto p-5">
|
<div className="container mx-auto w-full">
|
||||||
<h1 className="text-xl font-medium leading-none text-gray-900 mb-3">Manage Account</h1>
|
<h1 className="text-xl font-medium leading-none text-gray-900 mb-3">Manage Account</h1>
|
||||||
<Breadcrumbs>
|
<Breadcrumbs>
|
||||||
<Link underline="none" color="inherit" href="/">
|
<Link underline="none" color="inherit" href="/">
|
||||||
|
|||||||
@ -148,7 +148,7 @@ const ManageGroups = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<div className="container mx-auto pt-2">
|
<div className="container mx-auto">
|
||||||
<ConfirmDialog
|
<ConfirmDialog
|
||||||
open={dialogOpen}
|
open={dialogOpen}
|
||||||
onClose={() => setDialogOpen(false)}
|
onClose={() => setDialogOpen(false)}
|
||||||
@ -182,7 +182,7 @@ const ManageGroups = () => {
|
|||||||
onDelete={handleDelete}
|
onDelete={handleDelete}
|
||||||
/>
|
/>
|
||||||
<Dialog open={isDialogOpen} onClose={closeDialog}>
|
<Dialog open={isDialogOpen} onClose={closeDialog}>
|
||||||
<DialogContent className="w-[600px]">
|
<DialogContent className="w-full">
|
||||||
<div className="flex justify-between">
|
<div className="flex justify-between">
|
||||||
<DialogTitle>Create New Group</DialogTitle>
|
<DialogTitle>Create New Group</DialogTitle>
|
||||||
<Box display="flex" justifyContent="flex-end">
|
<Box display="flex" justifyContent="flex-end">
|
||||||
|
|||||||
@ -20,17 +20,17 @@ const ListToolbar = () => {
|
|||||||
onChange={(event) => table.getColumn('name')?.setFilterValue(event.target.value)}
|
onChange={(event) => table.getColumn('name')?.setFilterValue(event.target.value)}
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
<DefaultTooltip title={'Filter'} placement={'top'}>
|
{/* <DefaultTooltip title={'Filter'} placement={'top'}>
|
||||||
<Button
|
<Button
|
||||||
variant="outline"
|
variant="outline"
|
||||||
className="h-7.5 disabled:bg-gray-400"
|
className="h-7.5 disabled:bg-gray-400"
|
||||||
// disabled={isLoading}
|
disabled={isLoading}
|
||||||
// onClick={handleFilterData}
|
onClick={handleFilterData}
|
||||||
>
|
>
|
||||||
{/* {loadingButton === 'filter' ? <ContentLoader /> : <KeenIcon icon="filter" />} */}
|
{loadingButton === 'filter' ? <ContentLoader /> : <KeenIcon icon="filter" />}
|
||||||
<KeenIcon icon="filter" />
|
<KeenIcon icon="filter" />
|
||||||
</Button>
|
</Button>
|
||||||
</DefaultTooltip>
|
</DefaultTooltip> */}
|
||||||
{/* <Button
|
{/* <Button
|
||||||
variant="outline"
|
variant="outline"
|
||||||
className="h-7.5 text-[0.8rem]"
|
className="h-7.5 text-[0.8rem]"
|
||||||
|
|||||||
32
src/pages/master/conversion/ConversionMaster.tsx
Normal file
32
src/pages/master/conversion/ConversionMaster.tsx
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
import { Container, DataGridInner } from '@/components';
|
||||||
|
import { ManageConversionContextProvider } from './hooks/ManageConversionContext';
|
||||||
|
import { Breadcrumbs, Link } from '@mui/material';
|
||||||
|
|
||||||
|
const ConversionMaster = () => {
|
||||||
|
return (
|
||||||
|
<ManageConversionContextProvider>
|
||||||
|
<Container>
|
||||||
|
<h1 className="text-xl font-medium leading-none text-gray-900 mb-5">Conversion</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">Master Data</span>
|
||||||
|
</Link>
|
||||||
|
|
||||||
|
<Link underline="none" color="inherit">
|
||||||
|
<span className="text-sm">Manage Conversion</span>
|
||||||
|
</Link>
|
||||||
|
</Breadcrumbs>
|
||||||
|
|
||||||
|
<div className="grid gap-5 lg:gap-7.5">
|
||||||
|
<DataGridInner />
|
||||||
|
</div>
|
||||||
|
</Container>
|
||||||
|
</ManageConversionContextProvider>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ConversionMaster;
|
||||||
0
src/pages/master/conversion/blocks/AddDialog.tsx
Normal file
0
src/pages/master/conversion/blocks/AddDialog.tsx
Normal file
55
src/pages/master/conversion/blocks/ListToolbar.tsx
Normal file
55
src/pages/master/conversion/blocks/ListToolbar.tsx
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
import { DefaultTooltip, KeenIcon, useDataGrid } from '@/components';
|
||||||
|
import { Button } from '@/components/ui/button';
|
||||||
|
import { useManageConversionContext } from '../hooks/useManageConversionContext';
|
||||||
|
|
||||||
|
const ListToolbar = () => {
|
||||||
|
const { table, reload } = useDataGrid();
|
||||||
|
const { handleAddDialog } = useManageConversionContext();
|
||||||
|
|
||||||
|
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 w-[50%] gap-3 items-center">
|
||||||
|
<label className="input input-sm w-1/3">
|
||||||
|
<KeenIcon icon="magnifier" />
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
placeholder="Search Conversion"
|
||||||
|
value={(table.getColumn('name')?.getFilterValue() as string) ?? ''}
|
||||||
|
onChange={(event) => table.getColumn('name')?.setFilterValue(event.target.value)}
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
{/* <DefaultTooltip title={'Filter'} placement={'top'}>
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
className="h-7.5 disabled:bg-gray-400"
|
||||||
|
disabled={isLoading}
|
||||||
|
onClick={handleFilterData}
|
||||||
|
>
|
||||||
|
{loadingButton === 'filter' ? <ContentLoader /> : <KeenIcon icon="filter" />}
|
||||||
|
<KeenIcon icon="filter" />
|
||||||
|
</Button>
|
||||||
|
</DefaultTooltip> */}
|
||||||
|
</div>
|
||||||
|
<div className="flex gap-3 items-center">
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
className="h-7.5 text-[0.8rem]"
|
||||||
|
onClick={() => handleAddDialog(true)}
|
||||||
|
>
|
||||||
|
Add Data
|
||||||
|
</Button>
|
||||||
|
<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;
|
||||||
177
src/pages/master/conversion/hooks/ManageConversionContext.tsx
Normal file
177
src/pages/master/conversion/hooks/ManageConversionContext.tsx
Normal file
@ -0,0 +1,177 @@
|
|||||||
|
import { DataGridColumnHeader, DataGridProvider, KeenIcon } from '@/components';
|
||||||
|
import { Toaster } from '@/components/ui/sonner';
|
||||||
|
import { apiConfig } from '@/config/api.config';
|
||||||
|
import { useCallApi } from '@/hooks';
|
||||||
|
import { ColumnDef } from '@tanstack/react-table';
|
||||||
|
import { createContext, useCallback, useMemo, useState } from 'react';
|
||||||
|
import ListToolbar from '../blocks/ListToolbar';
|
||||||
|
|
||||||
|
interface ConversionProps {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ContextProps {
|
||||||
|
conversion: ConversionProps[];
|
||||||
|
showAddDialog: boolean;
|
||||||
|
handleAddDialog: (show: boolean) => void;
|
||||||
|
showEditDialog: boolean;
|
||||||
|
handleEditDialog: (show: boolean, selected_conversion: string | null) => void;
|
||||||
|
showDeleteDialog: boolean;
|
||||||
|
handleDeleteDialog: (show: boolean, selected_conversion: string | null) => void;
|
||||||
|
selectedConversion: string | null;
|
||||||
|
getConversionLists: (
|
||||||
|
limit: number,
|
||||||
|
page: number,
|
||||||
|
with_deleted: boolean,
|
||||||
|
order_field: any,
|
||||||
|
order_direction: any
|
||||||
|
) => Promise<{ data: ConversionProps[]; totalCount: number } | undefined>;
|
||||||
|
}
|
||||||
|
|
||||||
|
const initialProps: ContextProps = {
|
||||||
|
conversion: [],
|
||||||
|
showAddDialog: false,
|
||||||
|
handleAddDialog: () => {},
|
||||||
|
showEditDialog: false,
|
||||||
|
handleEditDialog: () => {},
|
||||||
|
showDeleteDialog: false,
|
||||||
|
handleDeleteDialog: () => {},
|
||||||
|
selectedConversion: null,
|
||||||
|
getConversionLists: async () => undefined
|
||||||
|
};
|
||||||
|
|
||||||
|
const ManageConversionContext = createContext<ContextProps>(initialProps);
|
||||||
|
const API_URL_WALLET = apiConfig.service_wallet;
|
||||||
|
|
||||||
|
const ManageConversionContextProvider = ({ children }: { children: React.ReactNode }) => {
|
||||||
|
const [conversions, setConversions] = useState<ConversionProps[]>([]);
|
||||||
|
const [showAddDialog, setShowAddDialog] = useState(false);
|
||||||
|
const [showEditDialog, setShowEditDialog] = useState(false);
|
||||||
|
const [showDeleteDialog, setShowDeleteDialog] = useState(false);
|
||||||
|
const [selectedConversion, setSelectedConversion] = useState<string | null>(null);
|
||||||
|
const { GetData } = useCallApi();
|
||||||
|
|
||||||
|
const handleAddDialog = useCallback((show: boolean) => {
|
||||||
|
setShowAddDialog(show);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const handleEditDialog = useCallback((show: boolean, selected_conversion: string | null) => {
|
||||||
|
setShowEditDialog(show);
|
||||||
|
setSelectedConversion(show ? selected_conversion : null);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const handleDeleteDialog = useCallback((show: boolean, selected_conversion: string | null) => {
|
||||||
|
setShowEditDialog(show);
|
||||||
|
setSelectedConversion(show ? selected_conversion : null);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
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.name,
|
||||||
|
id: 'name',
|
||||||
|
header: ({ column }) => <DataGridColumnHeader title="Name" column={column} />,
|
||||||
|
enableSorting: true,
|
||||||
|
enableHiding: false,
|
||||||
|
meta: {
|
||||||
|
headerClassName: 'w-[250px]'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
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={() => handleEditDialog(true, row.id)}
|
||||||
|
>
|
||||||
|
<KeenIcon icon="notepad-edit" />
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
className="btn btn-sm btn-icon btn-clear btn-light"
|
||||||
|
onClick={() => handleDeleteDialog(true, row.id)}
|
||||||
|
>
|
||||||
|
<KeenIcon icon="trash" />
|
||||||
|
</button>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
meta: {
|
||||||
|
headerClassName: 'w-[100px]',
|
||||||
|
cellClassName: 'text-center'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[]
|
||||||
|
);
|
||||||
|
|
||||||
|
const getConversionLists = async (page: number, limit: number, sorting: any, filter: any) => {
|
||||||
|
try {
|
||||||
|
sorting = sorting.length == 0 ? [{ id: 'name', desc: false }] : sorting;
|
||||||
|
filter = filter.length == 0 ? {} : { any: filter[0].value?.toLowerCase() };
|
||||||
|
const response = await GetData(`${API_URL_WALLET}/dashboard/conversion`, {
|
||||||
|
limit,
|
||||||
|
page: page + 1,
|
||||||
|
with_deleted: false,
|
||||||
|
order_field: sorting[0].id,
|
||||||
|
order_direction: sorting[0].desc == false ? 'ASC' : 'DESC',
|
||||||
|
filter: JSON.stringify(filter)
|
||||||
|
});
|
||||||
|
console.log(response?.data);
|
||||||
|
setConversions(response?.data.list);
|
||||||
|
return { data: response?.data.list, totalCount: response?.data.total_count };
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error fetching Conversion', error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ManageConversionContext.Provider
|
||||||
|
value={{
|
||||||
|
conversion: conversions,
|
||||||
|
showAddDialog,
|
||||||
|
handleAddDialog,
|
||||||
|
showEditDialog,
|
||||||
|
handleEditDialog,
|
||||||
|
showDeleteDialog,
|
||||||
|
handleDeleteDialog,
|
||||||
|
selectedConversion,
|
||||||
|
getConversionLists
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Toaster expand visibleToasts={9} duration={3000} />
|
||||||
|
<DataGridProvider
|
||||||
|
columns={columns}
|
||||||
|
pagination={{ size: 10 }}
|
||||||
|
toolbar={<ListToolbar />}
|
||||||
|
layout={{ card: true }}
|
||||||
|
sorting={[{ id: 'id', desc: false }]}
|
||||||
|
serverSide={true}
|
||||||
|
onFetchData={({ pageIndex, pageSize, sorting, columnFilters }) =>
|
||||||
|
getConversionLists(pageIndex, pageSize, sorting, columnFilters)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</DataGridProvider>
|
||||||
|
</ManageConversionContext.Provider>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export { ManageConversionContext, ManageConversionContextProvider };
|
||||||
|
export type { ConversionProps };
|
||||||
@ -0,0 +1,12 @@
|
|||||||
|
import { useContext } from 'react';
|
||||||
|
import { ManageConversionContext } from './ManageConversionContext';
|
||||||
|
|
||||||
|
const useManageConversionContext = () => {
|
||||||
|
const context = useContext(ManageConversionContext);
|
||||||
|
|
||||||
|
if (!context) throw new Error('useManageConversionContext must be used within AuthProvider');
|
||||||
|
|
||||||
|
return context;
|
||||||
|
};
|
||||||
|
|
||||||
|
export { useManageConversionContext };
|
||||||
@ -33,17 +33,17 @@ const ListToolbar = () => {
|
|||||||
onChange={(event) => table.getColumn('name')?.setFilterValue(event.target.value)}
|
onChange={(event) => table.getColumn('name')?.setFilterValue(event.target.value)}
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
<DefaultTooltip title={'Filter'} placement={'top'}>
|
{/* <DefaultTooltip title={'Filter'} placement={'top'}>
|
||||||
<Button
|
<Button
|
||||||
variant="outline"
|
variant="outline"
|
||||||
className="h-7.5 disabled:bg-gray-400"
|
className="h-7.5 disabled:bg-gray-400"
|
||||||
// disabled={isLoading}
|
// disabled={isLoading}
|
||||||
onClick={handleFilterData}
|
onClick={handleFilterData}
|
||||||
>
|
>
|
||||||
{/* {loadingButton === 'filter' ? <ContentLoader /> : <KeenIcon icon="filter" />} */}
|
{loadingButton === 'filter' ? <ContentLoader /> : <KeenIcon icon="filter" />}
|
||||||
<KeenIcon icon="filter" />
|
<KeenIcon icon="filter" />
|
||||||
</Button>
|
</Button>
|
||||||
</DefaultTooltip>
|
</DefaultTooltip> */}
|
||||||
{/* <Button
|
{/* <Button
|
||||||
variant="outline"
|
variant="outline"
|
||||||
className="h-7.5 text-[0.8rem]"
|
className="h-7.5 text-[0.8rem]"
|
||||||
|
|||||||
@ -23,17 +23,17 @@ const ListToolbar = () => {
|
|||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
<DefaultTooltip title={'Filter'} placement={'top'}>
|
{/* <DefaultTooltip title={'Filter'} placement={'top'}>
|
||||||
<Button
|
<Button
|
||||||
variant="outline"
|
variant="outline"
|
||||||
className="h-7.5 disabled:bg-gray-400"
|
className="h-7.5 disabled:bg-gray-400"
|
||||||
// disabled={isLoading}
|
// disabled={isLoading}
|
||||||
// onClick={handleFilterData}
|
// onClick={handleFilterData}
|
||||||
>
|
>
|
||||||
{/* {loadingButton === 'filter' ? <ContentLoader /> : <KeenIcon icon="filter" />} */}
|
{loadingButton === 'filter' ? <ContentLoader /> : <KeenIcon icon="filter" />}
|
||||||
<KeenIcon icon="filter" />
|
<KeenIcon icon="filter" />
|
||||||
</Button>
|
</Button>
|
||||||
</DefaultTooltip>
|
</DefaultTooltip> */}
|
||||||
{/* <Button
|
{/* <Button
|
||||||
variant="outline"
|
variant="outline"
|
||||||
className="h-7.5 text-[0.8rem]"
|
className="h-7.5 text-[0.8rem]"
|
||||||
|
|||||||
@ -15,31 +15,47 @@ import {
|
|||||||
} from '@/components/ui/dialog';
|
} from '@/components/ui/dialog';
|
||||||
import { Input } from '@/components/ui/input';
|
import { Input } from '@/components/ui/input';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
|
import {
|
||||||
|
Select,
|
||||||
|
SelectContent,
|
||||||
|
SelectItem,
|
||||||
|
SelectTrigger,
|
||||||
|
SelectValue
|
||||||
|
} from '@/components/ui/select';
|
||||||
|
|
||||||
|
interface ProviderProps {
|
||||||
|
provider_id: number;
|
||||||
|
provider_name: string;
|
||||||
|
}
|
||||||
|
|
||||||
const API_URL = apiConfig.service_master_data;
|
const API_URL = apiConfig.service_master_data;
|
||||||
const AddDialog = () => {
|
const AddDialog = () => {
|
||||||
const parentRef = useRef<any | null>(null);
|
const parentRef = useRef<any | null>(null);
|
||||||
const parsedUser = getAuth()?.user;
|
const parsedUser = getAuth()?.user;
|
||||||
const { showAddDialog, handleAddDialog } = useManageProductsContext();
|
const { showAddDialog, handleAddDialog } = useManageProductsContext();
|
||||||
const { PostData } = useCallApi();
|
const { PostData, GetData } = useCallApi();
|
||||||
const { reload } = useDataGrid();
|
const { reload } = useDataGrid();
|
||||||
const [alert, setAlert] = useState({
|
const [alert, setAlert] = useState({
|
||||||
show: false,
|
show: false,
|
||||||
message: ''
|
message: ''
|
||||||
});
|
});
|
||||||
const initialState = {
|
const initialState = {
|
||||||
name: '',
|
products_name: '',
|
||||||
description: '',
|
products_code: '',
|
||||||
price_point: 0,
|
products_type: '',
|
||||||
price_cash: 0,
|
products_description: '',
|
||||||
cashback_point: 0,
|
products_price_point: 0,
|
||||||
cashback_cash: 0,
|
products_price_cash: 0,
|
||||||
status: '',
|
products_cashback_point: 0,
|
||||||
providerId: '',
|
products_cashback_cash: 0,
|
||||||
|
products_status: '',
|
||||||
|
products_provider: '',
|
||||||
|
products_process_on_third_party: '',
|
||||||
created_by: '',
|
created_by: '',
|
||||||
created_at: ''
|
created_at: ''
|
||||||
};
|
};
|
||||||
const [formField, setFormField] = useState(initialState);
|
const [formField, setFormField] = useState(initialState);
|
||||||
|
const [providers, setProviders] = useState<ProviderProps[]>([]);
|
||||||
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', ' ');
|
||||||
|
|
||||||
@ -67,17 +83,36 @@ const AddDialog = () => {
|
|||||||
[formField]
|
[formField]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const doFetchProvider = useCallback(async (sorting: any) => {
|
||||||
|
try {
|
||||||
|
const response = await GetData(`${API_URL}/provider/list`, {
|
||||||
|
limit: 100,
|
||||||
|
page: 1,
|
||||||
|
with_deleted: false,
|
||||||
|
order_field: sorting[0].id,
|
||||||
|
order_direction: sorting[0].desc == false ? 'ASC' : 'DESC'
|
||||||
|
});
|
||||||
|
|
||||||
|
// console.log('PROVIDER: ', response?.data);
|
||||||
|
setProviders(response?.data.list);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error fetching provider', error);
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {
|
const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
if (
|
if (
|
||||||
formField.name.trim() === '' ||
|
formField.products_name.trim() === '' ||
|
||||||
formField.description.trim() === '' ||
|
formField.products_type.trim() === '' ||
|
||||||
formField.price_point === 0 ||
|
formField.products_code.trim() === '' ||
|
||||||
formField.price_cash === 0 ||
|
formField.products_description.trim() === '' ||
|
||||||
formField.cashback_point === 0 ||
|
formField.products_price_point === 0 ||
|
||||||
formField.cashback_cash === 0 ||
|
formField.products_price_cash === 0 ||
|
||||||
formField.status.trim() === '' ||
|
formField.products_cashback_point === 0 ||
|
||||||
|
formField.products_cashback_cash === 0 ||
|
||||||
|
formField.products_status.trim() === '' ||
|
||||||
formField.created_by.trim() === '' ||
|
formField.created_by.trim() === '' ||
|
||||||
formField.created_at.trim() === ''
|
formField.created_at.trim() === ''
|
||||||
) {
|
) {
|
||||||
@ -90,6 +125,10 @@ const AddDialog = () => {
|
|||||||
setAlert({ show: false, message: '' });
|
setAlert({ show: false, message: '' });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
doFetchProvider([{ id: 'id', desc: false }]);
|
||||||
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (showAddDialog) {
|
if (showAddDialog) {
|
||||||
setFormField({
|
setFormField({
|
||||||
@ -113,7 +152,7 @@ const AddDialog = () => {
|
|||||||
<DialogTitle>Product - Create</DialogTitle>
|
<DialogTitle>Product - Create</DialogTitle>
|
||||||
<DialogDescription></DialogDescription>
|
<DialogDescription></DialogDescription>
|
||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
<DialogBody ref={parentRef}>
|
<DialogBody ref={parentRef} className="overflow-y-auto">
|
||||||
<div className="flex flex-col">
|
<div className="flex flex-col">
|
||||||
{alert.show && (
|
{alert.show && (
|
||||||
<Alert variant="danger">
|
<Alert variant="danger">
|
||||||
@ -131,8 +170,42 @@ const AddDialog = () => {
|
|||||||
<Input
|
<Input
|
||||||
className="input"
|
className="input"
|
||||||
type="text"
|
type="text"
|
||||||
value={formField.name}
|
value={formField.products_name}
|
||||||
onChange={(e) => setFormField({ ...formField, name: e.target.value })}
|
onChange={(e) =>
|
||||||
|
setFormField({ ...formField, products_name: e.target.value })
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="w-full">
|
||||||
|
<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">
|
||||||
|
Type<span className="text-red-500">*</span>
|
||||||
|
</label>
|
||||||
|
<Input
|
||||||
|
className="input"
|
||||||
|
type="text"
|
||||||
|
value={formField.products_type}
|
||||||
|
onChange={(e) =>
|
||||||
|
setFormField({ ...formField, products_type: e.target.value })
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="w-full">
|
||||||
|
<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">
|
||||||
|
Code<span className="text-red-500">*</span>
|
||||||
|
</label>
|
||||||
|
<Input
|
||||||
|
className="input"
|
||||||
|
type="text"
|
||||||
|
value={formField.products_code}
|
||||||
|
onChange={(e) =>
|
||||||
|
setFormField({ ...formField, products_code: e.target.value })
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -145,8 +218,10 @@ const AddDialog = () => {
|
|||||||
<Input
|
<Input
|
||||||
className="input"
|
className="input"
|
||||||
type="text"
|
type="text"
|
||||||
value={formField.description}
|
value={formField.products_description}
|
||||||
onChange={(e) => setFormField({ ...formField, description: e.target.value })}
|
onChange={(e) =>
|
||||||
|
setFormField({ ...formField, products_description: e.target.value })
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -161,10 +236,13 @@ const AddDialog = () => {
|
|||||||
type="number"
|
type="number"
|
||||||
min={0}
|
min={0}
|
||||||
step={0.01}
|
step={0.01}
|
||||||
value={formField.price_point}
|
value={formField.products_price_point}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
const value = parseFloat(e.target.value);
|
const value = parseFloat(e.target.value);
|
||||||
setFormField({ ...formField, price_point: isNaN(value) ? 0 : value });
|
setFormField({
|
||||||
|
...formField,
|
||||||
|
products_price_point: isNaN(value) ? 0 : value
|
||||||
|
});
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@ -180,10 +258,13 @@ const AddDialog = () => {
|
|||||||
type="number"
|
type="number"
|
||||||
min={0}
|
min={0}
|
||||||
step={0.01}
|
step={0.01}
|
||||||
value={formField.price_cash}
|
value={formField.products_price_cash}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
const value = parseFloat(e.target.value);
|
const value = parseFloat(e.target.value);
|
||||||
setFormField({ ...formField, price_cash: isNaN(value) ? 0 : value });
|
setFormField({
|
||||||
|
...formField,
|
||||||
|
products_price_cash: isNaN(value) ? 0 : value
|
||||||
|
});
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@ -199,10 +280,13 @@ const AddDialog = () => {
|
|||||||
type="number"
|
type="number"
|
||||||
min={0}
|
min={0}
|
||||||
step={0.01}
|
step={0.01}
|
||||||
value={formField.cashback_point}
|
value={formField.products_cashback_point}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
const value = parseFloat(e.target.value);
|
const value = parseFloat(e.target.value);
|
||||||
setFormField({ ...formField, cashback_point: isNaN(value) ? 0 : value });
|
setFormField({
|
||||||
|
...formField,
|
||||||
|
products_cashback_point: isNaN(value) ? 0 : value
|
||||||
|
});
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@ -218,10 +302,13 @@ const AddDialog = () => {
|
|||||||
type="number"
|
type="number"
|
||||||
min={0}
|
min={0}
|
||||||
step={0.01}
|
step={0.01}
|
||||||
value={formField.cashback_cash}
|
value={formField.products_cashback_cash}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
const value = parseFloat(e.target.value);
|
const value = parseFloat(e.target.value);
|
||||||
setFormField({ ...formField, cashback_cash: isNaN(value) ? 0 : value });
|
setFormField({
|
||||||
|
...formField,
|
||||||
|
products_cashback_cash: isNaN(value) ? 0 : value
|
||||||
|
});
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@ -232,12 +319,20 @@ const AddDialog = () => {
|
|||||||
<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<span className="text-red-500">*</span>
|
Status<span className="text-red-500">*</span>
|
||||||
</label>
|
</label>
|
||||||
<Input
|
<Select
|
||||||
className="input"
|
value={formField.products_status}
|
||||||
type="text"
|
onValueChange={(value) =>
|
||||||
value={formField.status}
|
setFormField({ ...formField, products_status: value })
|
||||||
onChange={(e) => setFormField({ ...formField, status: e.target.value })}
|
}
|
||||||
/>
|
>
|
||||||
|
<SelectTrigger>
|
||||||
|
<SelectValue placeholder="Select Status" />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
<SelectItem value="Y">Yes</SelectItem>
|
||||||
|
<SelectItem value="N">No</SelectItem>
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -246,12 +341,48 @@ const AddDialog = () => {
|
|||||||
<label className="form-label flex items-center gap-1 max-w-56">
|
<label className="form-label flex items-center gap-1 max-w-56">
|
||||||
Provider ID
|
Provider ID
|
||||||
</label>
|
</label>
|
||||||
<Input
|
<Select
|
||||||
className="input"
|
value={formField.products_provider}
|
||||||
type="text"
|
onValueChange={(value) =>
|
||||||
value={formField.providerId}
|
setFormField({ ...formField, products_provider: value.toString() })
|
||||||
onChange={(e) => setFormField({ ...formField, providerId: e.target.value })}
|
}
|
||||||
/>
|
>
|
||||||
|
<SelectTrigger>
|
||||||
|
<SelectValue placeholder="Select Provider" />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
{providers.map((provider) => (
|
||||||
|
<SelectItem
|
||||||
|
key={provider.provider_id}
|
||||||
|
value={provider.provider_id.toString()}
|
||||||
|
>
|
||||||
|
{provider.provider_name}
|
||||||
|
</SelectItem>
|
||||||
|
))}
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="w-full">
|
||||||
|
<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">
|
||||||
|
Process on Third Party<span className="text-red-500">*</span>
|
||||||
|
</label>
|
||||||
|
<Select
|
||||||
|
value={formField.products_process_on_third_party}
|
||||||
|
onValueChange={(value) =>
|
||||||
|
setFormField({ ...formField, products_process_on_third_party: value })
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<SelectTrigger>
|
||||||
|
<SelectValue placeholder="Select Status" />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
<SelectItem value="Y">Yes</SelectItem>
|
||||||
|
<SelectItem value="N">No</SelectItem>
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@ -15,6 +15,18 @@ import {
|
|||||||
} from '@/components/ui/dialog';
|
} from '@/components/ui/dialog';
|
||||||
import { Input } from '@/components/ui/input';
|
import { Input } from '@/components/ui/input';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
|
import {
|
||||||
|
Select,
|
||||||
|
SelectContent,
|
||||||
|
SelectItem,
|
||||||
|
SelectTrigger,
|
||||||
|
SelectValue
|
||||||
|
} from '@/components/ui/select';
|
||||||
|
|
||||||
|
interface ProviderProps {
|
||||||
|
provider_id: string;
|
||||||
|
provider_name: string;
|
||||||
|
}
|
||||||
|
|
||||||
const API_URL = apiConfig.service_master_data;
|
const API_URL = apiConfig.service_master_data;
|
||||||
const EditDialog = () => {
|
const EditDialog = () => {
|
||||||
@ -30,17 +42,21 @@ const EditDialog = () => {
|
|||||||
});
|
});
|
||||||
const initialState = {
|
const initialState = {
|
||||||
name: '',
|
name: '',
|
||||||
|
code: '',
|
||||||
|
type: '',
|
||||||
description: '',
|
description: '',
|
||||||
price_point: 0,
|
price_point: 0,
|
||||||
price_cash: 0,
|
price_cash: 0,
|
||||||
cashback_point: 0,
|
cashback_point: 0,
|
||||||
cashback_cash: 0,
|
cashback_cash: 0,
|
||||||
status: '',
|
status: '',
|
||||||
providerId: '',
|
provider: '',
|
||||||
|
process_on_third_party: '',
|
||||||
updated_by: '',
|
updated_by: '',
|
||||||
updated_at: ''
|
updated_at: ''
|
||||||
};
|
};
|
||||||
const [formField, setFormField] = useState(initialState);
|
const [formField, setFormField] = useState(initialState);
|
||||||
|
const [providers, setProviders] = useState<ProviderProps[]>([]);
|
||||||
|
|
||||||
const resetForm = () => {
|
const resetForm = () => {
|
||||||
setFormField(initialState);
|
setFormField(initialState);
|
||||||
@ -66,19 +82,40 @@ const EditDialog = () => {
|
|||||||
[selectedProducts, formField]
|
[selectedProducts, formField]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const doFetchProvider = useCallback(async (sorting: any) => {
|
||||||
|
try {
|
||||||
|
const response = await GetData(`${API_URL}/provider/list`, {
|
||||||
|
limit: 100,
|
||||||
|
page: 1,
|
||||||
|
with_deleted: false,
|
||||||
|
order_field: sorting[0].id,
|
||||||
|
order_direction: sorting[0].desc == false ? 'ASC' : 'DESC'
|
||||||
|
});
|
||||||
|
// console.log('PROVIDER: ', response?.data);
|
||||||
|
setProviders(response?.data.list);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error fetching provider', error);
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
const doFetchData = useCallback(async (id: string) => {
|
const doFetchData = useCallback(async (id: string) => {
|
||||||
const response = await GetData(`${API_URL}/product/getdata/${selectedProducts}`, { id });
|
const response = await GetData(`${API_URL}/product/getdata/${id}`, { id });
|
||||||
|
console.log(response);
|
||||||
|
|
||||||
if (response?.status) {
|
if (response?.status) {
|
||||||
setFormField((prev) => ({
|
setFormField((prev) => ({
|
||||||
...prev,
|
...prev,
|
||||||
name: response.data.name,
|
name: response.data.name,
|
||||||
|
type: response.data.type,
|
||||||
|
code: response.data.code,
|
||||||
description: response.data.description,
|
description: response.data.description,
|
||||||
price_point: response.data.price_point,
|
price_point: response.data.price_point,
|
||||||
price_cash: response.data.price_cash,
|
price_cash: response.data.price_cash,
|
||||||
cashback_point: response.data.cashback_point,
|
cashback_point: response.data.cashback_point,
|
||||||
cashback_cash: response.data.cashback_cash,
|
cashback_cash: response.data.cashback_cash,
|
||||||
status: response.data.status
|
status: response.data.status,
|
||||||
|
provider: response.data.provider.id,
|
||||||
|
process_on_third_party: response.data.process_on_third_party
|
||||||
}));
|
}));
|
||||||
} else {
|
} else {
|
||||||
setFormField(initialState);
|
setFormField(initialState);
|
||||||
@ -90,6 +127,8 @@ const EditDialog = () => {
|
|||||||
|
|
||||||
if (
|
if (
|
||||||
formField.name.trim() === '' ||
|
formField.name.trim() === '' ||
|
||||||
|
formField.type.trim() === '' ||
|
||||||
|
formField.code.trim() === '' ||
|
||||||
formField.description.trim() === '' ||
|
formField.description.trim() === '' ||
|
||||||
formField.price_point === 0 ||
|
formField.price_point === 0 ||
|
||||||
formField.price_cash === 0 ||
|
formField.price_cash === 0 ||
|
||||||
@ -130,6 +169,10 @@ const EditDialog = () => {
|
|||||||
}
|
}
|
||||||
}, [formattedTime]);
|
}, [formattedTime]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
doFetchProvider([{ id: 'name', desc: false }]);
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog open={showEditDialog} onOpenChange={(open) => handleEditDialog(open, null)}>
|
<Dialog open={showEditDialog} onOpenChange={(open) => handleEditDialog(open, null)}>
|
||||||
<DialogContent className="container-fixed max-w-[768px] flex flex-col p-5 overflow-hidden">
|
<DialogContent className="container-fixed max-w-[768px] flex flex-col p-5 overflow-hidden">
|
||||||
@ -137,7 +180,7 @@ const EditDialog = () => {
|
|||||||
<DialogTitle>Product - Update</DialogTitle>
|
<DialogTitle>Product - Update</DialogTitle>
|
||||||
<DialogDescription></DialogDescription>
|
<DialogDescription></DialogDescription>
|
||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
<DialogBody>
|
<DialogBody className="overflow-y-auto">
|
||||||
<div className="flex flex-col">
|
<div className="flex flex-col">
|
||||||
{alert.show && (
|
{alert.show && (
|
||||||
<Alert variant="danger">
|
<Alert variant="danger">
|
||||||
@ -161,6 +204,34 @@ const EditDialog = () => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div className="w-full">
|
||||||
|
<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">
|
||||||
|
Type<span className="text-red-500">*</span>
|
||||||
|
</label>
|
||||||
|
<Input
|
||||||
|
className="input"
|
||||||
|
type="text"
|
||||||
|
value={formField.type}
|
||||||
|
onChange={(e) => setFormField({ ...formField, type: e.target.value })}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="w-full">
|
||||||
|
<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">
|
||||||
|
Code<span className="text-red-500">*</span>
|
||||||
|
</label>
|
||||||
|
<Input
|
||||||
|
className="input"
|
||||||
|
type="text"
|
||||||
|
value={formField.code}
|
||||||
|
onChange={(e) => setFormField({ ...formField, code: e.target.value })}
|
||||||
|
/>
|
||||||
|
</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">
|
||||||
@ -256,12 +327,18 @@ const EditDialog = () => {
|
|||||||
<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<span className="text-red-500">*</span>
|
Status<span className="text-red-500">*</span>
|
||||||
</label>
|
</label>
|
||||||
<Input
|
<Select
|
||||||
className="input"
|
|
||||||
type="text"
|
|
||||||
value={formField.status}
|
value={formField.status}
|
||||||
onChange={(e) => setFormField({ ...formField, status: e.target.value })}
|
onValueChange={(e) => setFormField({ ...formField, status: e })}
|
||||||
/>
|
>
|
||||||
|
<SelectTrigger>
|
||||||
|
<SelectValue placeholder="Select a Status" />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
<SelectItem value="Y">Active</SelectItem>
|
||||||
|
<SelectItem value="N">Inactive</SelectItem>
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -270,12 +347,43 @@ const EditDialog = () => {
|
|||||||
<label className="form-label flex items-center gap-1 max-w-56">
|
<label className="form-label flex items-center gap-1 max-w-56">
|
||||||
Provider ID
|
Provider ID
|
||||||
</label>
|
</label>
|
||||||
<Input
|
<Select
|
||||||
className="input"
|
value={formField.provider}
|
||||||
type="text"
|
onValueChange={(e) => setFormField({ ...formField, provider: e })}
|
||||||
value={formField.providerId}
|
>
|
||||||
onChange={(e) => setFormField({ ...formField, providerId: e.target.value })}
|
<SelectTrigger>
|
||||||
/>
|
<SelectValue placeholder="Select a Provider" />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
{providers.map((provider) => (
|
||||||
|
<SelectItem key={provider.provider_id} value={provider.provider_id}>
|
||||||
|
{provider.provider_name}
|
||||||
|
</SelectItem>
|
||||||
|
))}
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="w-full">
|
||||||
|
<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">
|
||||||
|
Process on Third Party<span className="text-red-500">*</span>
|
||||||
|
</label>
|
||||||
|
<Select
|
||||||
|
value={formField.process_on_third_party}
|
||||||
|
onValueChange={(value) =>
|
||||||
|
setFormField({ ...formField, process_on_third_party: value })
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<SelectTrigger>
|
||||||
|
<SelectValue placeholder="Select Status" />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
<SelectItem value="Y">Yes</SelectItem>
|
||||||
|
<SelectItem value="N">No</SelectItem>
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@ -20,17 +20,17 @@ const ListToolbar = () => {
|
|||||||
onChange={(event) => table.getColumn('name')?.setFilterValue(event.target.value)}
|
onChange={(event) => table.getColumn('name')?.setFilterValue(event.target.value)}
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
<DefaultTooltip title={'Filter'} placement={'top'}>
|
{/* <DefaultTooltip title={'Filter'} placement={'top'}>
|
||||||
<Button
|
<Button
|
||||||
variant="outline"
|
variant="outline"
|
||||||
className="h-7.5 disabled:bg-gray-400"
|
className="h-7.5 disabled:bg-gray-400"
|
||||||
// disabled={isLoading}
|
// disabled={isLoading}
|
||||||
// onClick={handleFilterData}
|
// onClick={handleFilterData}
|
||||||
>
|
>
|
||||||
{/* {loadingButton === 'filter' ? <ContentLoader /> : <KeenIcon icon="filter" />} */}
|
{loadingButton === 'filter' ? <ContentLoader /> : <KeenIcon icon="filter" />}
|
||||||
<KeenIcon icon="filter" />
|
<KeenIcon icon="filter" />
|
||||||
</Button>
|
</Button>
|
||||||
</DefaultTooltip>
|
</DefaultTooltip> */}
|
||||||
</div>
|
</div>
|
||||||
<div className="flex gap-3 items-center">
|
<div className="flex gap-3 items-center">
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
@ -7,12 +7,12 @@ import { Toaster } from 'sonner';
|
|||||||
import ListToolbar from '../blocks/ListToolbar';
|
import ListToolbar from '../blocks/ListToolbar';
|
||||||
|
|
||||||
interface ProductsProps {
|
interface ProductsProps {
|
||||||
name: string;
|
products_name: string;
|
||||||
description: string;
|
products_description: string;
|
||||||
price_point: number;
|
products_price_point: number;
|
||||||
price_cash: number;
|
products_price_cash: number;
|
||||||
status: string;
|
products_status: string;
|
||||||
providerId: string;
|
products_providerId: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ContextProps {
|
interface ContextProps {
|
||||||
@ -73,7 +73,7 @@ const ManageProductsContextProvider = ({ children }: { children: React.ReactNode
|
|||||||
const columns = useMemo<ColumnDef<any>[]>(
|
const columns = useMemo<ColumnDef<any>[]>(
|
||||||
() => [
|
() => [
|
||||||
{
|
{
|
||||||
accessorFn: (row) => row.id,
|
accessorFn: (row) => row.products_id,
|
||||||
id: 'id',
|
id: 'id',
|
||||||
header: ({ column }) => <DataGridColumnHeader title="ID" column={column} />,
|
header: ({ column }) => <DataGridColumnHeader title="ID" column={column} />,
|
||||||
enableSorting: true,
|
enableSorting: true,
|
||||||
@ -83,7 +83,7 @@ const ManageProductsContextProvider = ({ children }: { children: React.ReactNode
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
accessorFn: (row) => row.name,
|
accessorFn: (row) => row.products_name,
|
||||||
id: 'name',
|
id: 'name',
|
||||||
header: ({ column }) => <DataGridColumnHeader title="Name" column={column} />,
|
header: ({ column }) => <DataGridColumnHeader title="Name" column={column} />,
|
||||||
enableSorting: true,
|
enableSorting: true,
|
||||||
@ -93,7 +93,7 @@ const ManageProductsContextProvider = ({ children }: { children: React.ReactNode
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
accessorFn: (row) => row.description,
|
accessorFn: (row) => row.products_description,
|
||||||
id: 'description',
|
id: 'description',
|
||||||
header: ({ column }) => <DataGridColumnHeader title="Description" column={column} />,
|
header: ({ column }) => <DataGridColumnHeader title="Description" column={column} />,
|
||||||
enableSorting: true,
|
enableSorting: true,
|
||||||
@ -103,7 +103,7 @@ const ManageProductsContextProvider = ({ children }: { children: React.ReactNode
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
accessorFn: (row) => row.price_point,
|
accessorFn: (row) => row.products_price_point,
|
||||||
id: 'price_point',
|
id: 'price_point',
|
||||||
header: ({ column }) => <DataGridColumnHeader title="Price Point" column={column} />,
|
header: ({ column }) => <DataGridColumnHeader title="Price Point" column={column} />,
|
||||||
enableSorting: true,
|
enableSorting: true,
|
||||||
@ -113,7 +113,7 @@ const ManageProductsContextProvider = ({ children }: { children: React.ReactNode
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
accessorFn: (row) => row.price_cash,
|
accessorFn: (row) => row.products_price_cash,
|
||||||
id: 'price_cash',
|
id: 'price_cash',
|
||||||
header: ({ column }) => <DataGridColumnHeader title="Price Cash" column={column} />,
|
header: ({ column }) => <DataGridColumnHeader title="Price Cash" column={column} />,
|
||||||
enableSorting: true,
|
enableSorting: true,
|
||||||
@ -133,13 +133,13 @@ const ManageProductsContextProvider = ({ children }: { children: React.ReactNode
|
|||||||
<>
|
<>
|
||||||
<button
|
<button
|
||||||
className="btn btn-sm btn-icon btn-clear btn-light"
|
className="btn btn-sm btn-icon btn-clear btn-light"
|
||||||
onClick={() => handleEditDialog(true, row.id)}
|
onClick={() => handleEditDialog(true, row.products_id)}
|
||||||
>
|
>
|
||||||
<KeenIcon icon="notepad-edit" />
|
<KeenIcon icon="notepad-edit" />
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
className="btn btn-sm btn-icon btn-clear btn-light"
|
className="btn btn-sm btn-icon btn-clear btn-light"
|
||||||
onClick={() => handleDeleteDialog(true, row.id)}
|
onClick={() => handleDeleteDialog(true, row.products_id)}
|
||||||
>
|
>
|
||||||
<KeenIcon icon="trash" />
|
<KeenIcon icon="trash" />
|
||||||
</button>
|
</button>
|
||||||
@ -167,7 +167,7 @@ const ManageProductsContextProvider = ({ children }: { children: React.ReactNode
|
|||||||
order_direction: sorting[0].desc == false ? 'ASC' : 'DESC',
|
order_direction: sorting[0].desc == false ? 'ASC' : 'DESC',
|
||||||
filter: JSON.stringify(filter)
|
filter: JSON.stringify(filter)
|
||||||
});
|
});
|
||||||
// console.log(response?.data);
|
console.log(response?.data);
|
||||||
setProducts(response?.data.list);
|
setProducts(response?.data.list);
|
||||||
return { data: response?.data.list, totalCount: response?.data.total_count };
|
return { data: response?.data.list, totalCount: response?.data.total_count };
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@ -20,7 +20,7 @@ const API_URL = apiConfig.service_master_data;
|
|||||||
const EditDialog = () => {
|
const EditDialog = () => {
|
||||||
const { showEditDialog, handleEditDialog, selectedProfession } = useManageProfessionContext();
|
const { showEditDialog, handleEditDialog, selectedProfession } = useManageProfessionContext();
|
||||||
const { reload } = useDataGrid();
|
const { reload } = useDataGrid();
|
||||||
const { PutData } = useCallApi();
|
const { PutData, GetData } = useCallApi();
|
||||||
const parsedUser = getAuth()?.user;
|
const parsedUser = getAuth()?.user;
|
||||||
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', ' ');
|
||||||
@ -62,6 +62,19 @@ const EditDialog = () => {
|
|||||||
[selectedProfession, formField]
|
[selectedProfession, formField]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const doFetchData = useCallback(async (id: string) => {
|
||||||
|
const response = await GetData(`${API_URL}/profession/getdata/${id}`, { id });
|
||||||
|
|
||||||
|
if (response?.status) {
|
||||||
|
setFormField((prev) => ({
|
||||||
|
...prev,
|
||||||
|
name: response.data.name
|
||||||
|
}));
|
||||||
|
} else {
|
||||||
|
setFormField(initialState);
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
const handleUpdate = (e: React.FormEvent<HTMLFormElement>) => {
|
const handleUpdate = (e: React.FormEvent<HTMLFormElement>) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
@ -75,6 +88,12 @@ const EditDialog = () => {
|
|||||||
setAlert({ show: false, message: '' });
|
setAlert({ show: false, message: '' });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (selectedProfession) {
|
||||||
|
doFetchData(selectedProfession);
|
||||||
|
}
|
||||||
|
}, [selectedProfession]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (showEditDialog) {
|
if (showEditDialog) {
|
||||||
setFormField({
|
setFormField({
|
||||||
@ -85,6 +104,12 @@ const EditDialog = () => {
|
|||||||
}
|
}
|
||||||
}, [formattedTime]);
|
}, [formattedTime]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (showEditDialog === false) {
|
||||||
|
resetForm();
|
||||||
|
}
|
||||||
|
}, [showEditDialog]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog open={showEditDialog} onOpenChange={(open) => handleEditDialog(open, null)}>
|
<Dialog open={showEditDialog} onOpenChange={(open) => handleEditDialog(open, null)}>
|
||||||
<DialogContent className="container-fixed max-w-[768px] flex flex-col p-5 overflow-hidden">
|
<DialogContent className="container-fixed max-w-[768px] flex flex-col p-5 overflow-hidden">
|
||||||
|
|||||||
@ -22,17 +22,17 @@ const ListToolbar = () => {
|
|||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
<DefaultTooltip title={'Filter'} placement={'top'}>
|
{/* <DefaultTooltip title={'Filter'} placement={'top'}>
|
||||||
<Button
|
<Button
|
||||||
variant="outline"
|
variant="outline"
|
||||||
className="h-7.5 disabled:bg-gray-400"
|
className="h-7.5 disabled:bg-gray-400"
|
||||||
// disabled={isLoading}
|
// disabled={isLoading}
|
||||||
// onClick={handleFilterData}
|
// onClick={handleFilterData}
|
||||||
>
|
>
|
||||||
{/* {loadingButton === 'filter' ? <ContentLoader /> : <KeenIcon icon="filter" />} */}
|
{loadingButton === 'filter' ? <ContentLoader /> : <KeenIcon icon="filter" />}
|
||||||
<KeenIcon icon="filter" />
|
<KeenIcon icon="filter" />
|
||||||
</Button>
|
</Button>
|
||||||
</DefaultTooltip>
|
</DefaultTooltip> */}
|
||||||
</div>
|
</div>
|
||||||
<div className="flex gap-3 items-center">
|
<div className="flex gap-3 items-center">
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
@ -56,7 +56,7 @@ const EditDialog = () => {
|
|||||||
type: '',
|
type: '',
|
||||||
status: '',
|
status: '',
|
||||||
transactionTypeId: '',
|
transactionTypeId: '',
|
||||||
agentId: '',
|
agent: '',
|
||||||
updated_by: '',
|
updated_by: '',
|
||||||
updated_at: ''
|
updated_at: ''
|
||||||
};
|
};
|
||||||
@ -91,22 +91,54 @@ const EditDialog = () => {
|
|||||||
[selectedProvider, formField]
|
[selectedProvider, formField]
|
||||||
);
|
);
|
||||||
|
|
||||||
const doFetchData = useCallback(async () => {
|
const getCustomerList = async (sorting: any) => {
|
||||||
if (selectedProvider) {
|
try {
|
||||||
const data = provider.find((item) => item.id === selectedProvider);
|
sorting = sorting.length == 0 ? [{ id: 'name', desc: false }] : sorting;
|
||||||
if (data) {
|
const response = await GetData(`${API_URL_CUSTOMER}/customer/list`, {
|
||||||
setFormField((prev) => ({
|
limit: 100,
|
||||||
...prev,
|
page: 1,
|
||||||
name: data.name,
|
with_deleted: false,
|
||||||
description: data.description,
|
order_field: sorting[0].id,
|
||||||
type: data.type,
|
order_direction: sorting[0].desc == false ? 'ASC' : 'DESC'
|
||||||
status: data.status,
|
});
|
||||||
transactionTypeId: data.transactionTypeId,
|
|
||||||
agentId: data.agentId
|
// console.log('CUSTOMER: ', response?.data);
|
||||||
}));
|
setCustomers(response?.data.list);
|
||||||
}
|
} catch (error) {
|
||||||
} else {
|
console.error('Error fetching customer', error);
|
||||||
resetForm();
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const getTransactionTypeList = async (sorting: any) => {
|
||||||
|
try {
|
||||||
|
const response = await GetData(`${API_URL_TRANSACTION}/transactiontype/list`, {
|
||||||
|
limit: 100,
|
||||||
|
page: 1,
|
||||||
|
with_deleted: false,
|
||||||
|
order_field: sorting[0].id,
|
||||||
|
order_direction: sorting[0].desc == false ? 'ASC' : 'DESC'
|
||||||
|
});
|
||||||
|
|
||||||
|
// console.log('TRANSACTION TYPE: ', response?.data);
|
||||||
|
setTransactions(response?.data.list);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error fetching transaction type', error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const doFetchData = useCallback(async (id: string) => {
|
||||||
|
const response = await GetData(`${API_URL_MASTERDATA}/provider/getdata/${id}`, { id });
|
||||||
|
console.log(response);
|
||||||
|
if (response?.status) {
|
||||||
|
setFormField((prev) => ({
|
||||||
|
...prev,
|
||||||
|
name: response?.data.name,
|
||||||
|
description: response?.data.description,
|
||||||
|
type: response?.data.type,
|
||||||
|
status: response?.data.status,
|
||||||
|
transactionTypeId: response?.data.transactionTypeId,
|
||||||
|
agent: response?.data.agent
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
@ -119,7 +151,7 @@ const EditDialog = () => {
|
|||||||
formField.type.trim() === '' ||
|
formField.type.trim() === '' ||
|
||||||
formField.status.trim() === '' ||
|
formField.status.trim() === '' ||
|
||||||
formField.transactionTypeId.trim() === '' ||
|
formField.transactionTypeId.trim() === '' ||
|
||||||
formField.agentId.trim() === ''
|
formField.agent.trim() === ''
|
||||||
) {
|
) {
|
||||||
setAlert({ show: true, message: 'Please fill in all required fields.' });
|
setAlert({ show: true, message: 'Please fill in all required fields.' });
|
||||||
return;
|
return;
|
||||||
@ -130,9 +162,15 @@ const EditDialog = () => {
|
|||||||
setAlert({ show: false, message: '' });
|
setAlert({ show: false, message: '' });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (showEditDialog === false) {
|
||||||
|
resetForm();
|
||||||
|
}
|
||||||
|
}, [showEditDialog]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (selectedProvider) {
|
if (selectedProvider) {
|
||||||
doFetchData();
|
doFetchData(selectedProvider);
|
||||||
}
|
}
|
||||||
}, [selectedProvider]);
|
}, [selectedProvider]);
|
||||||
|
|
||||||
@ -147,41 +185,6 @@ const EditDialog = () => {
|
|||||||
}, [formattedTime]);
|
}, [formattedTime]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const getCustomerList = async (sorting: any) => {
|
|
||||||
try {
|
|
||||||
sorting = sorting.length == 0 ? [{ id: 'name', desc: false }] : sorting;
|
|
||||||
const response = await GetData(`${API_URL_CUSTOMER}/customer/list`, {
|
|
||||||
limit: 100,
|
|
||||||
page: 1,
|
|
||||||
with_deleted: false,
|
|
||||||
order_field: sorting[0].id,
|
|
||||||
order_direction: sorting[0].desc == false ? 'ASC' : 'DESC'
|
|
||||||
});
|
|
||||||
|
|
||||||
// console.log('CUSTOMER: ', response?.data);
|
|
||||||
setCustomers(response?.data.list);
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error fetching customer', error);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const getTransactionTypeList = async (sorting: any) => {
|
|
||||||
try {
|
|
||||||
const response = await GetData(`${API_URL_TRANSACTION}/transactiontype/list`, {
|
|
||||||
limit: 100,
|
|
||||||
page: 1,
|
|
||||||
with_deleted: false,
|
|
||||||
order_field: sorting[0].id,
|
|
||||||
order_direction: sorting[0].desc == false ? 'ASC' : 'DESC'
|
|
||||||
});
|
|
||||||
|
|
||||||
// console.log('TRANSACTION TYPE: ', response?.data);
|
|
||||||
setTransactions(response?.data.list);
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error fetching transaction type', error);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
getCustomerList([{ id: 'msisdn', desc: false }]);
|
getCustomerList([{ id: 'msisdn', desc: false }]);
|
||||||
getTransactionTypeList([{ id: 'name', desc: false }]);
|
getTransactionTypeList([{ id: 'name', desc: false }]);
|
||||||
}, []);
|
}, []);
|
||||||
@ -306,7 +309,7 @@ const EditDialog = () => {
|
|||||||
<Popover open={open} onOpenChange={setOpen}>
|
<Popover open={open} onOpenChange={setOpen}>
|
||||||
<PopoverTrigger asChild>
|
<PopoverTrigger asChild>
|
||||||
<button type="button" className="input col-span-5 text-left">
|
<button type="button" className="input col-span-5 text-left">
|
||||||
{customers.find((customer) => customer.msisdn === formField.agentId)
|
{customers.find((customer) => customer.msisdn === formField.agent)
|
||||||
?.fullname || 'Select Agent'}
|
?.fullname || 'Select Agent'}
|
||||||
</button>
|
</button>
|
||||||
</PopoverTrigger>
|
</PopoverTrigger>
|
||||||
@ -323,7 +326,7 @@ const EditDialog = () => {
|
|||||||
onSelect={() => {
|
onSelect={() => {
|
||||||
setFormField({
|
setFormField({
|
||||||
...formField,
|
...formField,
|
||||||
agentId: customer.msisdn
|
agent: customer.msisdn
|
||||||
});
|
});
|
||||||
setOpen(false);
|
setOpen(false);
|
||||||
}}
|
}}
|
||||||
|
|||||||
@ -20,17 +20,17 @@ const ListToolbar = () => {
|
|||||||
onChange={(event) => table.getColumn('name')?.setFilterValue(event.target.value)}
|
onChange={(event) => table.getColumn('name')?.setFilterValue(event.target.value)}
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
<DefaultTooltip title={'Filter'} placement={'top'}>
|
{/* <DefaultTooltip title={'Filter'} placement={'top'}>
|
||||||
<Button
|
<Button
|
||||||
variant="outline"
|
variant="outline"
|
||||||
className="h-7.5 disabled:bg-gray-400"
|
className="h-7.5 disabled:bg-gray-400"
|
||||||
// disabled={isLoading}
|
// disabled={isLoading}
|
||||||
// onClick={handleFilterData}
|
// onClick={handleFilterData}
|
||||||
>
|
>
|
||||||
{/* {loadingButton === 'filter' ? <ContentLoader /> : <KeenIcon icon="filter" />} */}
|
{loadingButton === 'filter' ? <ContentLoader /> : <KeenIcon icon="filter" />}
|
||||||
<KeenIcon icon="filter" />
|
<KeenIcon icon="filter" />
|
||||||
</Button>
|
</Button>
|
||||||
</DefaultTooltip>
|
</DefaultTooltip> */}
|
||||||
</div>
|
</div>
|
||||||
<div className="flex gap-3 items-center">
|
<div className="flex gap-3 items-center">
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
@ -74,7 +74,7 @@ const ManageProviderContextProvider = ({ children }: { children: React.ReactNode
|
|||||||
const columns = useMemo<ColumnDef<any>[]>(
|
const columns = useMemo<ColumnDef<any>[]>(
|
||||||
() => [
|
() => [
|
||||||
{
|
{
|
||||||
accessorFn: (row) => row.id,
|
accessorFn: (row) => row.provider_id,
|
||||||
id: 'id',
|
id: 'id',
|
||||||
header: ({ column }) => <DataGridColumnHeader title="ID" column={column} />,
|
header: ({ column }) => <DataGridColumnHeader title="ID" column={column} />,
|
||||||
enableSorting: true,
|
enableSorting: true,
|
||||||
@ -84,7 +84,7 @@ const ManageProviderContextProvider = ({ children }: { children: React.ReactNode
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
accessorFn: (row) => row.name,
|
accessorFn: (row) => row.provider_name,
|
||||||
id: 'name',
|
id: 'name',
|
||||||
header: ({ column }) => <DataGridColumnHeader title="Name" column={column} />,
|
header: ({ column }) => <DataGridColumnHeader title="Name" column={column} />,
|
||||||
enableSorting: true,
|
enableSorting: true,
|
||||||
@ -94,7 +94,7 @@ const ManageProviderContextProvider = ({ children }: { children: React.ReactNode
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
accessorFn: (row) => row.description,
|
accessorFn: (row) => row.provider_description,
|
||||||
id: 'description',
|
id: 'description',
|
||||||
header: ({ column }) => <DataGridColumnHeader title="Description" column={column} />,
|
header: ({ column }) => <DataGridColumnHeader title="Description" column={column} />,
|
||||||
enableSorting: false,
|
enableSorting: false,
|
||||||
@ -104,7 +104,7 @@ const ManageProviderContextProvider = ({ children }: { children: React.ReactNode
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
accessorFn: (row) => row.type,
|
accessorFn: (row) => row.provider_type,
|
||||||
id: 'type',
|
id: 'type',
|
||||||
header: ({ column }) => <DataGridColumnHeader title="Type" column={column} />,
|
header: ({ column }) => <DataGridColumnHeader title="Type" column={column} />,
|
||||||
enableSorting: false,
|
enableSorting: false,
|
||||||
@ -114,7 +114,7 @@ const ManageProviderContextProvider = ({ children }: { children: React.ReactNode
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
accessorFn: (row) => row.status,
|
accessorFn: (row) => row.provider_status,
|
||||||
id: 'status',
|
id: 'status',
|
||||||
header: ({ column }) => <DataGridColumnHeader title="Status" column={column} />,
|
header: ({ column }) => <DataGridColumnHeader title="Status" column={column} />,
|
||||||
enableSorting: false,
|
enableSorting: false,
|
||||||
@ -134,13 +134,13 @@ const ManageProviderContextProvider = ({ children }: { children: React.ReactNode
|
|||||||
<>
|
<>
|
||||||
<button
|
<button
|
||||||
className="btn btn-sm btn-icon btn-clear btn-light"
|
className="btn btn-sm btn-icon btn-clear btn-light"
|
||||||
onClick={() => handleEditDialog(true, row.id)}
|
onClick={() => handleEditDialog(true, row.provider_id)}
|
||||||
>
|
>
|
||||||
<KeenIcon icon="notepad-edit" />
|
<KeenIcon icon="notepad-edit" />
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
className="btn btn-sm btn-icon btn-clear btn-light"
|
className="btn btn-sm btn-icon btn-clear btn-light"
|
||||||
onClick={() => handleDeleteDialog(true, row.id)}
|
onClick={() => handleDeleteDialog(true, row.provider_id)}
|
||||||
>
|
>
|
||||||
<KeenIcon icon="trash" />
|
<KeenIcon icon="trash" />
|
||||||
</button>
|
</button>
|
||||||
@ -168,7 +168,7 @@ const ManageProviderContextProvider = ({ children }: { children: React.ReactNode
|
|||||||
order_direction: sorting[0].desc == false ? 'ASC' : 'DESC',
|
order_direction: sorting[0].desc == false ? 'ASC' : 'DESC',
|
||||||
filter: JSON.stringify(filter)
|
filter: JSON.stringify(filter)
|
||||||
});
|
});
|
||||||
// console.log(response?.data);
|
console.log(response?.data);
|
||||||
setProvider(response?.data.list);
|
setProvider(response?.data.list);
|
||||||
return { data: response?.data.list, totalCount: response?.data.total_count };
|
return { data: response?.data.list, totalCount: response?.data.total_count };
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@ -22,17 +22,17 @@ const ListToolbar = () => {
|
|||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
<DefaultTooltip title={'Filter'} placement={'top'}>
|
{/* <DefaultTooltip title={'Filter'} placement={'top'}>
|
||||||
<Button
|
<Button
|
||||||
variant="outline"
|
variant="outline"
|
||||||
className="h-7.5 disabled:bg-gray-400"
|
className="h-7.5 disabled:bg-gray-400"
|
||||||
// disabled={isLoading}
|
// disabled={isLoading}
|
||||||
// onClick={handleFilterData}
|
// onClick={handleFilterData}
|
||||||
>
|
>
|
||||||
{/* {loadingButton === 'filter' ? <ContentLoader /> : <KeenIcon icon="filter" />} */}
|
{loadingButton === 'filter' ? <ContentLoader /> : <KeenIcon icon="filter" />}
|
||||||
<KeenIcon icon="filter" />
|
<KeenIcon icon="filter" />
|
||||||
</Button>
|
</Button>
|
||||||
</DefaultTooltip>
|
</DefaultTooltip> */}
|
||||||
{/* <Button
|
{/* <Button
|
||||||
variant="outline"
|
variant="outline"
|
||||||
className="h-7.5 text-[0.8rem]"
|
className="h-7.5 text-[0.8rem]"
|
||||||
|
|||||||
32
src/pages/master/walletRule/WalletRuleMaster.tsx
Normal file
32
src/pages/master/walletRule/WalletRuleMaster.tsx
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
import { Container, DataGridInner } from '@/components';
|
||||||
|
import { ManageWalletRuleContextProvider } from './hooks/ManageWalletRuleContext';
|
||||||
|
import { Breadcrumbs, Link } from '@mui/material';
|
||||||
|
|
||||||
|
const WalletRuleMaster = () => {
|
||||||
|
return (
|
||||||
|
<ManageWalletRuleContextProvider>
|
||||||
|
<Container>
|
||||||
|
<h1 className="text-xl font-medium leading-none text-gray-900 mb-5">Wallet Rule</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">Master Data</span>
|
||||||
|
</Link>
|
||||||
|
|
||||||
|
<Link underline="none" color="inherit">
|
||||||
|
<span className="text-sm">Manage Wallet Rule</span>
|
||||||
|
</Link>
|
||||||
|
</Breadcrumbs>
|
||||||
|
|
||||||
|
<div className="grid gap-5 lg:gap-7.5">
|
||||||
|
<DataGridInner />
|
||||||
|
</div>
|
||||||
|
</Container>
|
||||||
|
</ManageWalletRuleContextProvider>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default WalletRuleMaster;
|
||||||
55
src/pages/master/walletRule/blocks/ListToolbar.tsx
Normal file
55
src/pages/master/walletRule/blocks/ListToolbar.tsx
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
import { DefaultTooltip, KeenIcon, useDataGrid } from '@/components';
|
||||||
|
import { Button } from '@/components/ui/button';
|
||||||
|
import { useManageProductsContext } from '../../products/hooks/useManageProductsContext';
|
||||||
|
|
||||||
|
const ListToolbar = () => {
|
||||||
|
const { table, reload } = useDataGrid();
|
||||||
|
const { handleAddDialog } = useManageProductsContext();
|
||||||
|
|
||||||
|
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 w-[50%] gap-3 items-center">
|
||||||
|
<label className="input input-sm w-1/3">
|
||||||
|
<KeenIcon icon="magnifier" />
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
placeholder="Search Products"
|
||||||
|
value={(table.getColumn('name')?.getFilterValue() as string) ?? ''}
|
||||||
|
onChange={(event) => table.getColumn('name')?.setFilterValue(event.target.value)}
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
{/* <DefaultTooltip title={'Filter'} placement={'top'}>
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
className="h-7.5 disabled:bg-gray-400"
|
||||||
|
// disabled={isLoading}
|
||||||
|
// onClick={handleFilterData}
|
||||||
|
>
|
||||||
|
{loadingButton === 'filter' ? <ContentLoader /> : <KeenIcon icon="filter" />}
|
||||||
|
<KeenIcon icon="filter" />
|
||||||
|
</Button>
|
||||||
|
</DefaultTooltip> */}
|
||||||
|
</div>
|
||||||
|
<div className="flex gap-3 items-center">
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
className="h-7.5 text-[0.8rem]"
|
||||||
|
onClick={() => handleAddDialog(true)}
|
||||||
|
>
|
||||||
|
Add Data
|
||||||
|
</Button>
|
||||||
|
<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;
|
||||||
240
src/pages/master/walletRule/hooks/ManageWalletRuleContext.tsx
Normal file
240
src/pages/master/walletRule/hooks/ManageWalletRuleContext.tsx
Normal file
@ -0,0 +1,240 @@
|
|||||||
|
import { DataGridColumnHeader, DataGridProvider, KeenIcon } from '@/components';
|
||||||
|
import { Toaster } from '@/components/ui/sonner';
|
||||||
|
import { apiConfig } from '@/config/api.config';
|
||||||
|
import { useCallApi } from '@/hooks';
|
||||||
|
import { ColumnDef } from '@tanstack/react-table';
|
||||||
|
import React, { createContext, useCallback, useMemo, useState } from 'react';
|
||||||
|
import ListToolbar from '../blocks/ListToolbar';
|
||||||
|
|
||||||
|
interface WalletRuleProps {
|
||||||
|
name: string;
|
||||||
|
id_currency: string;
|
||||||
|
status: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ContextProps {
|
||||||
|
walletRules: WalletRuleProps[];
|
||||||
|
showAddDialog: boolean;
|
||||||
|
handleAddDialog: (show: boolean) => void;
|
||||||
|
showEditDialog: boolean;
|
||||||
|
handleEditDialog: (show: boolean, selected_walletRule: string | null) => void;
|
||||||
|
showDeleteDialog: boolean;
|
||||||
|
handleDeleteDialog: (show: boolean, selected_walletRule: string | null) => void;
|
||||||
|
selectedWalletRule: string | null;
|
||||||
|
getWalletRuleLists: (
|
||||||
|
limit: number,
|
||||||
|
page: number,
|
||||||
|
with_deleted: boolean,
|
||||||
|
order_field: any,
|
||||||
|
order_direction: any
|
||||||
|
) => Promise<{ data: WalletRuleProps[]; totalCount: number } | undefined>;
|
||||||
|
}
|
||||||
|
|
||||||
|
const initialProps: ContextProps = {
|
||||||
|
walletRules: [],
|
||||||
|
showAddDialog: false,
|
||||||
|
handleAddDialog: (show: boolean) => {},
|
||||||
|
showEditDialog: false,
|
||||||
|
handleEditDialog: (show: boolean, selected_walletRule: string | null) => {},
|
||||||
|
showDeleteDialog: false,
|
||||||
|
handleDeleteDialog: (show: boolean, selected_walletRule: string | null) => {},
|
||||||
|
selectedWalletRule: null,
|
||||||
|
getWalletRuleLists: async () => undefined
|
||||||
|
};
|
||||||
|
|
||||||
|
const ManageWalletRuleContext = createContext<ContextProps>(initialProps);
|
||||||
|
const API_URL_WALLET = apiConfig.service_wallet;
|
||||||
|
|
||||||
|
const ManageWalletRuleContextProvider = ({ children }: { children: React.ReactNode }) => {
|
||||||
|
const [walletRules, setWalletRules] = useState<WalletRuleProps[]>([]);
|
||||||
|
const [showAddDialog, setShowAddDialog] = useState(false);
|
||||||
|
const [showEditDialog, setShowEditDialog] = useState(false);
|
||||||
|
const [showDeleteDialog, setShowDeleteDialog] = useState(false);
|
||||||
|
const [selectedWalletRule, setSelectedWalletRule] = useState<string | null>(null);
|
||||||
|
const { GetData } = useCallApi();
|
||||||
|
|
||||||
|
const handleAddDialog = useCallback((show: boolean) => {
|
||||||
|
setShowAddDialog(show);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const handleEditDialog = useCallback((show: boolean, selected_walletRule: string | null) => {
|
||||||
|
setShowEditDialog(show);
|
||||||
|
setSelectedWalletRule(show ? selected_walletRule : null);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const handleDeleteDialog = useCallback((show: boolean, selected_walletRule: string | null) => {
|
||||||
|
setShowDeleteDialog(show);
|
||||||
|
setSelectedWalletRule(show ? selected_walletRule : null);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
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.IDWallet,
|
||||||
|
id: 'name',
|
||||||
|
header: ({ column }) => <DataGridColumnHeader title="ID Wallet" column={column} />,
|
||||||
|
enableSorting: true,
|
||||||
|
enableHiding: false,
|
||||||
|
meta: {
|
||||||
|
headerClassName: 'w-[250px]'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accessorFn: (row) => row.balance_minimum,
|
||||||
|
id: 'balance_minimum',
|
||||||
|
header: ({ column }) => <DataGridColumnHeader title="Balance Minimum" column={column} />,
|
||||||
|
enableSorting: true,
|
||||||
|
enableHiding: false,
|
||||||
|
meta: {
|
||||||
|
headerClassName: 'w-[250px]'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accessorFn: (row) => row.balance_maximum,
|
||||||
|
id: 'balance_maximum',
|
||||||
|
header: ({ column }) => <DataGridColumnHeader title="Balance Maximum" column={column} />,
|
||||||
|
enableSorting: true,
|
||||||
|
enableHiding: false,
|
||||||
|
meta: {
|
||||||
|
headerClassName: 'w-[250px]'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accessorFn: (row) => row.credit_limit,
|
||||||
|
id: 'credit_limit',
|
||||||
|
header: ({ column }) => <DataGridColumnHeader title="Credit Limit" column={column} />,
|
||||||
|
enableSorting: true,
|
||||||
|
enableHiding: false,
|
||||||
|
meta: {
|
||||||
|
headerClassName: 'w-[250px]'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accessorFn: (row) => row.max_transaction_per_day,
|
||||||
|
id: 'max_transaction_per_day',
|
||||||
|
header: ({ column }) => (
|
||||||
|
<DataGridColumnHeader title="Max Transaction Per Day" column={column} />
|
||||||
|
),
|
||||||
|
enableSorting: true,
|
||||||
|
enableHiding: false,
|
||||||
|
meta: {
|
||||||
|
headerClassName: 'w-[250px]'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accessorFn: (row) => row.monthly_limit,
|
||||||
|
id: 'monthly_limit',
|
||||||
|
header: ({ column }) => <DataGridColumnHeader title="Monthly Limit" column={column} />,
|
||||||
|
enableSorting: true,
|
||||||
|
enableHiding: false,
|
||||||
|
meta: {
|
||||||
|
headerClassName: 'w-[250px]'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accessorFn: (row) => row.status,
|
||||||
|
id: 'status',
|
||||||
|
header: ({ column }) => <DataGridColumnHeader title="Status" column={column} />,
|
||||||
|
enableSorting: true,
|
||||||
|
enableHiding: false,
|
||||||
|
meta: {
|
||||||
|
headerClassName: 'w-[250px]'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
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={() => handleEditDialog(true, row.id)}
|
||||||
|
>
|
||||||
|
<KeenIcon icon="notepad-edit" />
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
className="btn btn-sm btn-icon btn-clear btn-light"
|
||||||
|
onClick={() => handleDeleteDialog(true, row.id)}
|
||||||
|
>
|
||||||
|
<KeenIcon icon="trash" />
|
||||||
|
</button>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
meta: {
|
||||||
|
headerClassName: 'w-[100px]',
|
||||||
|
cellClassName: 'text-center'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[]
|
||||||
|
);
|
||||||
|
|
||||||
|
const getWalletRuleLists = async (page: number, limit: number, sorting: any, filter: any) => {
|
||||||
|
try {
|
||||||
|
sorting = sorting.length == 0 ? [{ id: 'name', desc: false }] : sorting;
|
||||||
|
filter = filter.length == 0 ? {} : { any: filter[0].value?.toLowerCase() };
|
||||||
|
const response = await GetData(`${API_URL_WALLET}/dashboard/wallet_rule`, {
|
||||||
|
limit,
|
||||||
|
page: page + 1,
|
||||||
|
with_deleted: false,
|
||||||
|
order_field: sorting[0].id,
|
||||||
|
order_direction: sorting[0].desc == false ? 'ASC' : 'DESC',
|
||||||
|
filter: JSON.stringify(filter)
|
||||||
|
});
|
||||||
|
console.log(response?.data);
|
||||||
|
setWalletRules(response?.data.list);
|
||||||
|
return { data: response?.data.list, totalCount: response?.data.total_count };
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error fetching Wallet Rule', error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ManageWalletRuleContext.Provider
|
||||||
|
value={{
|
||||||
|
walletRules: walletRules,
|
||||||
|
showAddDialog,
|
||||||
|
handleAddDialog,
|
||||||
|
showEditDialog,
|
||||||
|
handleEditDialog,
|
||||||
|
showDeleteDialog,
|
||||||
|
handleDeleteDialog,
|
||||||
|
selectedWalletRule,
|
||||||
|
getWalletRuleLists
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Toaster expand visibleToasts={9} duration={3000} />
|
||||||
|
<DataGridProvider
|
||||||
|
columns={columns}
|
||||||
|
pagination={{ size: 10 }}
|
||||||
|
toolbar={<ListToolbar />}
|
||||||
|
layout={{ card: true }}
|
||||||
|
sorting={[{ id: 'id', desc: false }]}
|
||||||
|
serverSide={true}
|
||||||
|
onFetchData={({ pageIndex, pageSize, sorting, columnFilters }) =>
|
||||||
|
getWalletRuleLists(pageIndex, pageSize, sorting, columnFilters)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</DataGridProvider>
|
||||||
|
</ManageWalletRuleContext.Provider>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export { ManageWalletRuleContext, ManageWalletRuleContextProvider };
|
||||||
|
export type { WalletRuleProps };
|
||||||
@ -0,0 +1,16 @@
|
|||||||
|
import { useContext } from 'react';
|
||||||
|
import { ManageWalletRuleContext } from './ManageWalletRuleContext';
|
||||||
|
|
||||||
|
const useManageWalletRuleContext = () => {
|
||||||
|
const context = useContext(ManageWalletRuleContext);
|
||||||
|
|
||||||
|
if (!context) {
|
||||||
|
throw new Error(
|
||||||
|
'useManageWalletRuleContext must be used within a ManageWalletRuleContextProvider'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return context;
|
||||||
|
};
|
||||||
|
|
||||||
|
export { useManageWalletRuleContext };
|
||||||
@ -142,7 +142,7 @@ const Kyc = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<div className="container mx-auto">
|
<div className="container mx-auto w-full">
|
||||||
<ConfirmDialog
|
<ConfirmDialog
|
||||||
open={dialogOpen}
|
open={dialogOpen}
|
||||||
onClose={() => setDialogOpen(false)}
|
onClose={() => setDialogOpen(false)}
|
||||||
|
|||||||
@ -132,51 +132,51 @@ export const columns: ColumnDef<Members>[] = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
export const initialMember = {
|
export const initialMember = {
|
||||||
id: "",
|
id: '',
|
||||||
fullname: "",
|
fullname: '',
|
||||||
email: "",
|
email: '',
|
||||||
username: "",
|
username: '',
|
||||||
msisdn: "",
|
msisdn: '',
|
||||||
password: "",
|
password: '',
|
||||||
pin: "",
|
pin: '',
|
||||||
try_pin: "",
|
try_pin: '',
|
||||||
mother_fullname: "",
|
mother_fullname: '',
|
||||||
agent_name: "",
|
agent_name: '',
|
||||||
bank_name: "",
|
bank_name: '',
|
||||||
bank_account: "",
|
bank_account: '',
|
||||||
ibank_number: "",
|
ibank_number: '',
|
||||||
address: "",
|
address: '',
|
||||||
longitude: "",
|
longitude: '',
|
||||||
latitude: "",
|
latitude: '',
|
||||||
nationality: "",
|
nationality: '',
|
||||||
photouser: "",
|
photouser: '',
|
||||||
photomerchant: "",
|
photomerchant: '',
|
||||||
file_selfie: "",
|
file_selfie: '',
|
||||||
file_document_id: "",
|
file_document_id: '',
|
||||||
file_document_id_selfie: "",
|
file_document_id_selfie: '',
|
||||||
file_commercial_license: "",
|
file_commercial_license: '',
|
||||||
identity_type: "",
|
identity_type: '',
|
||||||
identity_number: "",
|
identity_number: '',
|
||||||
license_number: "",
|
license_number: '',
|
||||||
date_birth: "",
|
date_birth: '',
|
||||||
gender: "",
|
gender: '',
|
||||||
status: "N",
|
status: 'N',
|
||||||
isneedapproval: "",
|
isneedapproval: '',
|
||||||
isapproved: "",
|
isapproved: '',
|
||||||
approveddate: "",
|
approveddate: '',
|
||||||
approvedby: "",
|
approvedby: '',
|
||||||
created_by: "",
|
created_by: '',
|
||||||
created_at: "",
|
created_at: '',
|
||||||
updated_by: "",
|
updated_by: '',
|
||||||
updated_at: "",
|
updated_at: '',
|
||||||
deleted_by: "",
|
deleted_by: '',
|
||||||
deleted_at: "",
|
deleted_at: '',
|
||||||
group: "",
|
group: '',
|
||||||
point_tier: "",
|
point_tier: '',
|
||||||
language: "",
|
language: '',
|
||||||
municipio: "",
|
municipio: '',
|
||||||
posto_adms: "",
|
posto_adms: '',
|
||||||
suco: "",
|
suco: '',
|
||||||
aldeia: "",
|
aldeia: '',
|
||||||
profession: "",
|
profession: ''
|
||||||
}
|
};
|
||||||
|
|||||||
@ -115,7 +115,7 @@ const ManageMembers = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<div className="container mx-auto p-5">
|
<div className="container mx-auto w-full">
|
||||||
<ConfirmDialog
|
<ConfirmDialog
|
||||||
open={dialogOpen}
|
open={dialogOpen}
|
||||||
onClose={() => setDialogOpen(false)}
|
onClose={() => setDialogOpen(false)}
|
||||||
|
|||||||
@ -9,7 +9,7 @@ const ManageMenu = () => {
|
|||||||
return (
|
return (
|
||||||
<ManageMenusContextProvider>
|
<ManageMenusContextProvider>
|
||||||
<Container>
|
<Container>
|
||||||
<h1 className="text-xl font-medium leading-none text-gray-900 mb-5">Manage Menus</h1>
|
<h1 className="text-xl font-medium leading-none text-gray-900 mb-3">Manage Menu</h1>
|
||||||
<Breadcrumbs sx={{ mb: 2 }}>
|
<Breadcrumbs sx={{ mb: 2 }}>
|
||||||
<Link underline="none" color="inherit" href="/">
|
<Link underline="none" color="inherit" href="/">
|
||||||
<span className="text-sm hover:underline">Dashboard</span>
|
<span className="text-sm hover:underline">Dashboard</span>
|
||||||
@ -20,7 +20,7 @@ const ManageMenu = () => {
|
|||||||
</Link>
|
</Link>
|
||||||
|
|
||||||
<Link underline="none" color="inherit">
|
<Link underline="none" color="inherit">
|
||||||
<span className="text-sm">Manage Menus</span>
|
<span className="text-sm">Manage Menu</span>
|
||||||
</Link>
|
</Link>
|
||||||
</Breadcrumbs>
|
</Breadcrumbs>
|
||||||
<div className="grid gap-5 lg:gap-7.5">
|
<div className="grid gap-5 lg:gap-7.5">
|
||||||
|
|||||||
@ -83,6 +83,12 @@ const AddDialog = () => {
|
|||||||
const doCreatePosition = useCallback(
|
const doCreatePosition = useCallback(
|
||||||
async (e: React.FormEvent<HTMLFormElement>) => {
|
async (e: React.FormEvent<HTMLFormElement>) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
|
if (formField.name.trim() === '') {
|
||||||
|
setAlert({ show: true, message: 'Please fill in all required fields.' });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const response = await PostData(`${API_URL}/user_role/create`, {
|
const response = await PostData(`${API_URL}/user_role/create`, {
|
||||||
name: formField.name,
|
name: formField.name,
|
||||||
roles: selectMenus,
|
roles: selectMenus,
|
||||||
|
|||||||
@ -91,6 +91,12 @@ const EditDialog = () => {
|
|||||||
const doEditPosition = useCallback(
|
const doEditPosition = useCallback(
|
||||||
async (e: React.FormEvent<HTMLFormElement>) => {
|
async (e: React.FormEvent<HTMLFormElement>) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
|
if (formField.name.trim() === '') {
|
||||||
|
setAlert((prev) => ({ ...prev, show: true, message: 'Please fill name field.' }));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!selectedPosition) {
|
if (!selectedPosition) {
|
||||||
toast.success('Please Select Position');
|
toast.success('Please Select Position');
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { Fragment } from 'react';
|
import { Fragment, useState } from 'react';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
import { FormattedMessage } from 'react-intl';
|
import { FormattedMessage } from 'react-intl';
|
||||||
import { getAuth, useAuthContext } from '@/auth';
|
import { getAuth, useAuthContext } from '@/auth';
|
||||||
@ -15,6 +15,8 @@ import {
|
|||||||
MenuArrow,
|
MenuArrow,
|
||||||
MenuIcon
|
MenuIcon
|
||||||
} from '@/components/menu';
|
} from '@/components/menu';
|
||||||
|
import { Alert, Button, Dialog, DialogContent } from '@mui/material';
|
||||||
|
import { DialogFooter, DialogHeader } from '@/components/ui/dialog';
|
||||||
|
|
||||||
interface IDropdownUserProps {
|
interface IDropdownUserProps {
|
||||||
menuItemRef: any;
|
menuItemRef: any;
|
||||||
@ -26,6 +28,12 @@ interface IDropdownUserProps {
|
|||||||
|
|
||||||
const DropdownUser = ({ menuItemRef }: IDropdownUserProps) => {
|
const DropdownUser = ({ menuItemRef }: IDropdownUserProps) => {
|
||||||
const { logout, auth } = useAuthContext();
|
const { logout, auth } = useAuthContext();
|
||||||
|
const [showLogoutDialog, setShowLogoutDialog] = useState(false);
|
||||||
|
|
||||||
|
const handleLogout = () => {
|
||||||
|
setShowLogoutDialog(false); // Tutup dialog
|
||||||
|
logout(); // Panggil fungsi logout
|
||||||
|
};
|
||||||
|
|
||||||
const buildHeader = () => {
|
const buildHeader = () => {
|
||||||
return (
|
return (
|
||||||
@ -73,7 +81,10 @@ const DropdownUser = ({ menuItemRef }: IDropdownUserProps) => {
|
|||||||
return (
|
return (
|
||||||
<div className="flex flex-col">
|
<div className="flex flex-col">
|
||||||
<div className="menu-item px-4 py-1.5">
|
<div className="menu-item px-4 py-1.5">
|
||||||
<a onClick={logout} className="btn btn-sm btn-light justify-center">
|
<a
|
||||||
|
onClick={() => setShowLogoutDialog(true)}
|
||||||
|
className="btn btn-sm btn-light justify-center"
|
||||||
|
>
|
||||||
<FormattedMessage id="USER.MENU.LOGOUT" />
|
<FormattedMessage id="USER.MENU.LOGOUT" />
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
@ -89,6 +100,25 @@ const DropdownUser = ({ menuItemRef }: IDropdownUserProps) => {
|
|||||||
{buildHeader()}
|
{buildHeader()}
|
||||||
{buildMenu()}
|
{buildMenu()}
|
||||||
{buildFooter()}
|
{buildFooter()}
|
||||||
|
|
||||||
|
<Dialog open={showLogoutDialog} onClose={(open) => setShowLogoutDialog(false)}>
|
||||||
|
<DialogContent className="container-fixed max-w-md flex flex-col p-5 overflow-hidden [&>button]:hidden">
|
||||||
|
<DialogHeader className="p-0 border-0 block">
|
||||||
|
<Alert severity="warning" variant="filled">
|
||||||
|
<h3 className="text-lg">Are you sure?</h3>
|
||||||
|
<span className="text-sm">You are about to log out!</span>
|
||||||
|
</Alert>
|
||||||
|
</DialogHeader>
|
||||||
|
<DialogFooter className="flex justify-end items-center gap-4 mt-3">
|
||||||
|
<Button variant={'outlined'} onClick={() => setShowLogoutDialog(false)}>
|
||||||
|
Cancel
|
||||||
|
</Button>
|
||||||
|
<Button variant="outlined" color="error" onClick={handleLogout}>
|
||||||
|
Logout
|
||||||
|
</Button>
|
||||||
|
</DialogFooter>
|
||||||
|
</DialogContent>
|
||||||
|
</Dialog>
|
||||||
</MenuSub>
|
</MenuSub>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -34,6 +34,8 @@ import ProfessionMaster from '@/pages/master/profession/ProfessionMaster';
|
|||||||
import ProductsMaster from '@/pages/master/products/ProductsMaster';
|
import ProductsMaster from '@/pages/master/products/ProductsMaster';
|
||||||
import ProviderMaster from '@/pages/master/provider/ProviderMaster';
|
import ProviderMaster from '@/pages/master/provider/ProviderMaster';
|
||||||
import Transaction from '@/pages/transaction/transaction';
|
import Transaction from '@/pages/transaction/transaction';
|
||||||
|
import ConversionMaster from '@/pages/master/conversion/ConversionMaster';
|
||||||
|
import WalletRuleMaster from '@/pages/master/walletRule/WalletRuleMaster';
|
||||||
|
|
||||||
const AppRoutingSetup = (): ReactElement => {
|
const AppRoutingSetup = (): ReactElement => {
|
||||||
return (
|
return (
|
||||||
@ -50,7 +52,12 @@ const AppRoutingSetup = (): ReactElement => {
|
|||||||
<Route path="/master-data/profession" element={<ProfessionMaster />} />
|
<Route path="/master-data/profession" element={<ProfessionMaster />} />
|
||||||
<Route path="/master-data/products" element={<ProductsMaster />} />
|
<Route path="/master-data/products" element={<ProductsMaster />} />
|
||||||
<Route path="/master-data/provider" element={<ProviderMaster />} />
|
<Route path="/master-data/provider" element={<ProviderMaster />} />
|
||||||
<Route path="/master-data/municipios/postoadms/:municipioId" element={<PostoAdmsMaster />}/>
|
<Route
|
||||||
|
path="/master-data/municipios/postoadms/:municipioId"
|
||||||
|
element={<PostoAdmsMaster />}
|
||||||
|
/>
|
||||||
|
<Route path="/master-data/conversion" element={<ConversionMaster />} />
|
||||||
|
<Route path="/master-data/wallet-rule" element={<WalletRuleMaster />} />
|
||||||
|
|
||||||
<Route path="/account/home/user-profile" element={<AccountUserProfilePage />} />
|
<Route path="/account/home/user-profile" element={<AccountUserProfilePage />} />
|
||||||
|
|
||||||
@ -77,7 +84,9 @@ const AppRoutingSetup = (): ReactElement => {
|
|||||||
<Route path="/webservice/webservice-management" element={<ManageWebServices />} />
|
<Route path="/webservice/webservice-management" element={<ManageWebServices />} />
|
||||||
<Route path="/settings/user-management/manage-user" element={<ManageUserPage />} />
|
<Route path="/settings/user-management/manage-user" element={<ManageUserPage />} />
|
||||||
<Route path="/settings/user-management/log-activity" element={<LogActivityPage />} />
|
<Route path="/settings/user-management/log-activity" element={<LogActivityPage />} />
|
||||||
<Route path="/settings/user-management/manage-position" element={<ManagePositionPage />}
|
<Route
|
||||||
|
path="/settings/user-management/manage-position"
|
||||||
|
element={<ManagePositionPage />}
|
||||||
/>
|
/>
|
||||||
</Route>
|
</Route>
|
||||||
</Route>
|
</Route>
|
||||||
|
|||||||
Reference in New Issue
Block a user