Merge branch 'alwi'
This commit is contained in:
@ -3,6 +3,7 @@ interface apiConfigProps {
|
||||
service_customer: string;
|
||||
service_master_data: string;
|
||||
service_transaction: string;
|
||||
service_wallet: string;
|
||||
}
|
||||
|
||||
const API_URL = import.meta.env.VITE_APP_API_URL;
|
||||
@ -12,7 +13,8 @@ const apiConfig: apiConfigProps = {
|
||||
service_customer: `${API_URL}/c`,
|
||||
// service_master_data: `${API_URL}/m`
|
||||
service_master_data: `${API_URL}/t`,
|
||||
service_transaction: `${API_URL}/tt`
|
||||
service_transaction: `${API_URL}/tt`,
|
||||
service_wallet: `${API_URL}/w`
|
||||
};
|
||||
|
||||
export { apiConfig };
|
||||
|
||||
@ -20,17 +20,17 @@ const ListToolbar = () => {
|
||||
onChange={(event) => table.getColumn('name')?.setFilterValue(event.target.value)}
|
||||
/>
|
||||
</label>
|
||||
<DefaultTooltip title={'Filter'} placement={'top'}>
|
||||
{/* <DefaultTooltip title={'Filter'} placement={'top'}>
|
||||
<Button
|
||||
variant="outline"
|
||||
className="h-7.5 disabled:bg-gray-400"
|
||||
// disabled={isLoading}
|
||||
// onClick={handleFilterData}
|
||||
disabled={isLoading}
|
||||
onClick={handleFilterData}
|
||||
>
|
||||
{/* {loadingButton === 'filter' ? <ContentLoader /> : <KeenIcon icon="filter" />} */}
|
||||
{loadingButton === 'filter' ? <ContentLoader /> : <KeenIcon icon="filter" />}
|
||||
<KeenIcon icon="filter" />
|
||||
</Button>
|
||||
</DefaultTooltip>
|
||||
</DefaultTooltip> */}
|
||||
{/* <Button
|
||||
variant="outline"
|
||||
className="h-7.5 text-[0.8rem]"
|
||||
|
||||
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;
|
||||
@ -33,17 +33,17 @@ const ListToolbar = () => {
|
||||
onChange={(event) => table.getColumn('name')?.setFilterValue(event.target.value)}
|
||||
/>
|
||||
</label>
|
||||
<DefaultTooltip title={'Filter'} placement={'top'}>
|
||||
{/* <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" />} */}
|
||||
{loadingButton === 'filter' ? <ContentLoader /> : <KeenIcon icon="filter" />}
|
||||
<KeenIcon icon="filter" />
|
||||
</Button>
|
||||
</DefaultTooltip>
|
||||
</DefaultTooltip> */}
|
||||
{/* <Button
|
||||
variant="outline"
|
||||
className="h-7.5 text-[0.8rem]"
|
||||
|
||||
@ -23,17 +23,17 @@ const ListToolbar = () => {
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<DefaultTooltip title={'Filter'} placement={'top'}>
|
||||
{/* <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" />} */}
|
||||
{loadingButton === 'filter' ? <ContentLoader /> : <KeenIcon icon="filter" />}
|
||||
<KeenIcon icon="filter" />
|
||||
</Button>
|
||||
</DefaultTooltip>
|
||||
</DefaultTooltip> */}
|
||||
{/* <Button
|
||||
variant="outline"
|
||||
className="h-7.5 text-[0.8rem]"
|
||||
|
||||
@ -24,8 +24,8 @@ import {
|
||||
} from '@/components/ui/select';
|
||||
|
||||
interface ProviderProps {
|
||||
id: number;
|
||||
name: string;
|
||||
provider_id: number;
|
||||
provider_name: string;
|
||||
}
|
||||
|
||||
const API_URL = apiConfig.service_master_data;
|
||||
@ -40,17 +40,17 @@ const AddDialog = () => {
|
||||
message: ''
|
||||
});
|
||||
const initialState = {
|
||||
name: '',
|
||||
code: '',
|
||||
type: '',
|
||||
description: '',
|
||||
price_point: 0,
|
||||
price_cash: 0,
|
||||
cashback_point: 0,
|
||||
cashback_cash: 0,
|
||||
status: '',
|
||||
provider: '',
|
||||
process_on_third_party: '',
|
||||
products_name: '',
|
||||
products_code: '',
|
||||
products_type: '',
|
||||
products_description: '',
|
||||
products_price_point: 0,
|
||||
products_price_cash: 0,
|
||||
products_cashback_point: 0,
|
||||
products_cashback_cash: 0,
|
||||
products_status: '',
|
||||
products_provider: '',
|
||||
products_process_on_third_party: '',
|
||||
created_by: '',
|
||||
created_at: ''
|
||||
};
|
||||
@ -104,15 +104,15 @@ const AddDialog = () => {
|
||||
e.preventDefault();
|
||||
|
||||
if (
|
||||
formField.name.trim() === '' ||
|
||||
formField.type.trim() === '' ||
|
||||
formField.code.trim() === '' ||
|
||||
formField.description.trim() === '' ||
|
||||
formField.price_point === 0 ||
|
||||
formField.price_cash === 0 ||
|
||||
formField.cashback_point === 0 ||
|
||||
formField.cashback_cash === 0 ||
|
||||
formField.status.trim() === '' ||
|
||||
formField.products_name.trim() === '' ||
|
||||
formField.products_type.trim() === '' ||
|
||||
formField.products_code.trim() === '' ||
|
||||
formField.products_description.trim() === '' ||
|
||||
formField.products_price_point === 0 ||
|
||||
formField.products_price_cash === 0 ||
|
||||
formField.products_cashback_point === 0 ||
|
||||
formField.products_cashback_cash === 0 ||
|
||||
formField.products_status.trim() === '' ||
|
||||
formField.created_by.trim() === '' ||
|
||||
formField.created_at.trim() === ''
|
||||
) {
|
||||
@ -152,7 +152,7 @@ const AddDialog = () => {
|
||||
<DialogTitle>Product - Create</DialogTitle>
|
||||
<DialogDescription></DialogDescription>
|
||||
</DialogHeader>
|
||||
<DialogBody ref={parentRef} className='overflow-y-auto'>
|
||||
<DialogBody ref={parentRef} className="overflow-y-auto">
|
||||
<div className="flex flex-col">
|
||||
{alert.show && (
|
||||
<Alert variant="danger">
|
||||
@ -170,8 +170,10 @@ const AddDialog = () => {
|
||||
<Input
|
||||
className="input"
|
||||
type="text"
|
||||
value={formField.name}
|
||||
onChange={(e) => setFormField({ ...formField, name: e.target.value })}
|
||||
value={formField.products_name}
|
||||
onChange={(e) =>
|
||||
setFormField({ ...formField, products_name: e.target.value })
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@ -184,8 +186,10 @@ const AddDialog = () => {
|
||||
<Input
|
||||
className="input"
|
||||
type="text"
|
||||
value={formField.type}
|
||||
onChange={(e) => setFormField({ ...formField, type: e.target.value })}
|
||||
value={formField.products_type}
|
||||
onChange={(e) =>
|
||||
setFormField({ ...formField, products_type: e.target.value })
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@ -198,8 +202,10 @@ const AddDialog = () => {
|
||||
<Input
|
||||
className="input"
|
||||
type="text"
|
||||
value={formField.code}
|
||||
onChange={(e) => setFormField({ ...formField, code: e.target.value })}
|
||||
value={formField.products_code}
|
||||
onChange={(e) =>
|
||||
setFormField({ ...formField, products_code: e.target.value })
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@ -212,8 +218,10 @@ const AddDialog = () => {
|
||||
<Input
|
||||
className="input"
|
||||
type="text"
|
||||
value={formField.description}
|
||||
onChange={(e) => setFormField({ ...formField, description: e.target.value })}
|
||||
value={formField.products_description}
|
||||
onChange={(e) =>
|
||||
setFormField({ ...formField, products_description: e.target.value })
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@ -228,10 +236,13 @@ const AddDialog = () => {
|
||||
type="number"
|
||||
min={0}
|
||||
step={0.01}
|
||||
value={formField.price_point}
|
||||
value={formField.products_price_point}
|
||||
onChange={(e) => {
|
||||
const value = parseFloat(e.target.value);
|
||||
setFormField({ ...formField, price_point: isNaN(value) ? 0 : value });
|
||||
setFormField({
|
||||
...formField,
|
||||
products_price_point: isNaN(value) ? 0 : value
|
||||
});
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
@ -247,10 +258,13 @@ const AddDialog = () => {
|
||||
type="number"
|
||||
min={0}
|
||||
step={0.01}
|
||||
value={formField.price_cash}
|
||||
value={formField.products_price_cash}
|
||||
onChange={(e) => {
|
||||
const value = parseFloat(e.target.value);
|
||||
setFormField({ ...formField, price_cash: isNaN(value) ? 0 : value });
|
||||
setFormField({
|
||||
...formField,
|
||||
products_price_cash: isNaN(value) ? 0 : value
|
||||
});
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
@ -266,10 +280,13 @@ const AddDialog = () => {
|
||||
type="number"
|
||||
min={0}
|
||||
step={0.01}
|
||||
value={formField.cashback_point}
|
||||
value={formField.products_cashback_point}
|
||||
onChange={(e) => {
|
||||
const value = parseFloat(e.target.value);
|
||||
setFormField({ ...formField, cashback_point: isNaN(value) ? 0 : value });
|
||||
setFormField({
|
||||
...formField,
|
||||
products_cashback_point: isNaN(value) ? 0 : value
|
||||
});
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
@ -285,10 +302,13 @@ const AddDialog = () => {
|
||||
type="number"
|
||||
min={0}
|
||||
step={0.01}
|
||||
value={formField.cashback_cash}
|
||||
value={formField.products_cashback_cash}
|
||||
onChange={(e) => {
|
||||
const value = parseFloat(e.target.value);
|
||||
setFormField({ ...formField, cashback_cash: isNaN(value) ? 0 : value });
|
||||
setFormField({
|
||||
...formField,
|
||||
products_cashback_cash: isNaN(value) ? 0 : value
|
||||
});
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
@ -300,8 +320,10 @@ const AddDialog = () => {
|
||||
Status<span className="text-red-500">*</span>
|
||||
</label>
|
||||
<Select
|
||||
value={formField.status}
|
||||
onValueChange={(value) => setFormField({ ...formField, status: value })}
|
||||
value={formField.products_status}
|
||||
onValueChange={(value) =>
|
||||
setFormField({ ...formField, products_status: value })
|
||||
}
|
||||
>
|
||||
<SelectTrigger>
|
||||
<SelectValue placeholder="Select Status" />
|
||||
@ -320,9 +342,9 @@ const AddDialog = () => {
|
||||
Provider ID
|
||||
</label>
|
||||
<Select
|
||||
value={formField.provider}
|
||||
value={formField.products_provider}
|
||||
onValueChange={(value) =>
|
||||
setFormField({ ...formField, provider: value.toString() })
|
||||
setFormField({ ...formField, products_provider: value.toString() })
|
||||
}
|
||||
>
|
||||
<SelectTrigger>
|
||||
@ -330,8 +352,11 @@ const AddDialog = () => {
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{providers.map((provider) => (
|
||||
<SelectItem key={provider.id} value={provider.id.toString()}>
|
||||
{provider.name}
|
||||
<SelectItem
|
||||
key={provider.provider_id}
|
||||
value={provider.provider_id.toString()}
|
||||
>
|
||||
{provider.provider_name}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
@ -345,9 +370,9 @@ const AddDialog = () => {
|
||||
Process on Third Party<span className="text-red-500">*</span>
|
||||
</label>
|
||||
<Select
|
||||
value={formField.process_on_third_party}
|
||||
value={formField.products_process_on_third_party}
|
||||
onValueChange={(value) =>
|
||||
setFormField({ ...formField, process_on_third_party: value })
|
||||
setFormField({ ...formField, products_process_on_third_party: value })
|
||||
}
|
||||
>
|
||||
<SelectTrigger>
|
||||
|
||||
@ -24,8 +24,8 @@ import {
|
||||
} from '@/components/ui/select';
|
||||
|
||||
interface ProviderProps {
|
||||
id: string;
|
||||
name: string;
|
||||
provider_id: string;
|
||||
provider_name: string;
|
||||
}
|
||||
|
||||
const API_URL = apiConfig.service_master_data;
|
||||
@ -114,7 +114,7 @@ const EditDialog = () => {
|
||||
cashback_point: response.data.cashback_point,
|
||||
cashback_cash: response.data.cashback_cash,
|
||||
status: response.data.status,
|
||||
provider: response.data.provider_id,
|
||||
provider: response.data.provider.id,
|
||||
process_on_third_party: response.data.process_on_third_party
|
||||
}));
|
||||
} else {
|
||||
@ -356,8 +356,8 @@ const EditDialog = () => {
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{providers.map((provider) => (
|
||||
<SelectItem key={provider.id} value={provider.id}>
|
||||
{provider.name}
|
||||
<SelectItem key={provider.provider_id} value={provider.provider_id}>
|
||||
{provider.provider_name}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
|
||||
@ -20,17 +20,17 @@ const ListToolbar = () => {
|
||||
onChange={(event) => table.getColumn('name')?.setFilterValue(event.target.value)}
|
||||
/>
|
||||
</label>
|
||||
<DefaultTooltip title={'Filter'} placement={'top'}>
|
||||
{/* <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" />} */}
|
||||
{loadingButton === 'filter' ? <ContentLoader /> : <KeenIcon icon="filter" />}
|
||||
<KeenIcon icon="filter" />
|
||||
</Button>
|
||||
</DefaultTooltip>
|
||||
</DefaultTooltip> */}
|
||||
</div>
|
||||
<div className="flex gap-3 items-center">
|
||||
<Button
|
||||
|
||||
@ -7,12 +7,12 @@ import { Toaster } from 'sonner';
|
||||
import ListToolbar from '../blocks/ListToolbar';
|
||||
|
||||
interface ProductsProps {
|
||||
name: string;
|
||||
description: string;
|
||||
price_point: number;
|
||||
price_cash: number;
|
||||
status: string;
|
||||
providerId: string;
|
||||
products_name: string;
|
||||
products_description: string;
|
||||
products_price_point: number;
|
||||
products_price_cash: number;
|
||||
products_status: string;
|
||||
products_providerId: string;
|
||||
}
|
||||
|
||||
interface ContextProps {
|
||||
@ -73,7 +73,7 @@ const ManageProductsContextProvider = ({ children }: { children: React.ReactNode
|
||||
const columns = useMemo<ColumnDef<any>[]>(
|
||||
() => [
|
||||
{
|
||||
accessorFn: (row) => row.id,
|
||||
accessorFn: (row) => row.products_id,
|
||||
id: 'id',
|
||||
header: ({ column }) => <DataGridColumnHeader title="ID" column={column} />,
|
||||
enableSorting: true,
|
||||
@ -83,7 +83,7 @@ const ManageProductsContextProvider = ({ children }: { children: React.ReactNode
|
||||
}
|
||||
},
|
||||
{
|
||||
accessorFn: (row) => row.name,
|
||||
accessorFn: (row) => row.products_name,
|
||||
id: 'name',
|
||||
header: ({ column }) => <DataGridColumnHeader title="Name" column={column} />,
|
||||
enableSorting: true,
|
||||
@ -93,7 +93,7 @@ const ManageProductsContextProvider = ({ children }: { children: React.ReactNode
|
||||
}
|
||||
},
|
||||
{
|
||||
accessorFn: (row) => row.description,
|
||||
accessorFn: (row) => row.products_description,
|
||||
id: 'description',
|
||||
header: ({ column }) => <DataGridColumnHeader title="Description" column={column} />,
|
||||
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',
|
||||
header: ({ column }) => <DataGridColumnHeader title="Price Point" column={column} />,
|
||||
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',
|
||||
header: ({ column }) => <DataGridColumnHeader title="Price Cash" column={column} />,
|
||||
enableSorting: true,
|
||||
@ -133,13 +133,13 @@ const ManageProductsContextProvider = ({ children }: { children: React.ReactNode
|
||||
<>
|
||||
<button
|
||||
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" />
|
||||
</button>
|
||||
<button
|
||||
className="btn btn-sm btn-icon btn-clear btn-light"
|
||||
onClick={() => handleDeleteDialog(true, row.id)}
|
||||
onClick={() => handleDeleteDialog(true, row.products_id)}
|
||||
>
|
||||
<KeenIcon icon="trash" />
|
||||
</button>
|
||||
@ -167,7 +167,7 @@ const ManageProductsContextProvider = ({ children }: { children: React.ReactNode
|
||||
order_direction: sorting[0].desc == false ? 'ASC' : 'DESC',
|
||||
filter: JSON.stringify(filter)
|
||||
});
|
||||
// console.log(response?.data);
|
||||
console.log(response?.data);
|
||||
setProducts(response?.data.list);
|
||||
return { data: response?.data.list, totalCount: response?.data.total_count };
|
||||
} catch (error) {
|
||||
|
||||
@ -22,17 +22,17 @@ const ListToolbar = () => {
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<DefaultTooltip title={'Filter'} placement={'top'}>
|
||||
{/* <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" />} */}
|
||||
{loadingButton === 'filter' ? <ContentLoader /> : <KeenIcon icon="filter" />}
|
||||
<KeenIcon icon="filter" />
|
||||
</Button>
|
||||
</DefaultTooltip>
|
||||
</DefaultTooltip> */}
|
||||
</div>
|
||||
<div className="flex gap-3 items-center">
|
||||
<Button
|
||||
|
||||
@ -20,17 +20,17 @@ const ListToolbar = () => {
|
||||
onChange={(event) => table.getColumn('name')?.setFilterValue(event.target.value)}
|
||||
/>
|
||||
</label>
|
||||
<DefaultTooltip title={'Filter'} placement={'top'}>
|
||||
{/* <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" />} */}
|
||||
{loadingButton === 'filter' ? <ContentLoader /> : <KeenIcon icon="filter" />}
|
||||
<KeenIcon icon="filter" />
|
||||
</Button>
|
||||
</DefaultTooltip>
|
||||
</DefaultTooltip> */}
|
||||
</div>
|
||||
<div className="flex gap-3 items-center">
|
||||
<Button
|
||||
|
||||
@ -22,17 +22,17 @@ const ListToolbar = () => {
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<DefaultTooltip title={'Filter'} placement={'top'}>
|
||||
{/* <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" />} */}
|
||||
{loadingButton === 'filter' ? <ContentLoader /> : <KeenIcon icon="filter" />}
|
||||
<KeenIcon icon="filter" />
|
||||
</Button>
|
||||
</DefaultTooltip>
|
||||
</DefaultTooltip> */}
|
||||
{/* <Button
|
||||
variant="outline"
|
||||
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 };
|
||||
@ -34,6 +34,8 @@ import ProfessionMaster from '@/pages/master/profession/ProfessionMaster';
|
||||
import ProductsMaster from '@/pages/master/products/ProductsMaster';
|
||||
import ProviderMaster from '@/pages/master/provider/ProviderMaster';
|
||||
import Transaction from '@/pages/transaction/transaction';
|
||||
import ConversionMaster from '@/pages/master/conversion/ConversionMaster';
|
||||
import WalletRuleMaster from '@/pages/master/walletRule/WalletRuleMaster';
|
||||
|
||||
const AppRoutingSetup = (): ReactElement => {
|
||||
return (
|
||||
@ -50,7 +52,12 @@ const AppRoutingSetup = (): ReactElement => {
|
||||
<Route path="/master-data/profession" element={<ProfessionMaster />} />
|
||||
<Route path="/master-data/products" element={<ProductsMaster />} />
|
||||
<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 />} />
|
||||
|
||||
@ -77,7 +84,9 @@ const AppRoutingSetup = (): ReactElement => {
|
||||
<Route path="/webservice/webservice-management" element={<ManageWebServices />} />
|
||||
<Route path="/settings/user-management/manage-user" element={<ManageUserPage />} />
|
||||
<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>
|
||||
|
||||
Reference in New Issue
Block a user