This commit is contained in:
Raja Oktafrianto
2025-04-08 11:19:17 +07:00
59 changed files with 1622 additions and 221 deletions

View File

@ -24,6 +24,7 @@ import {
CommandItem,
CommandList
} from '@/components/ui/command';
import { doSaveLogActivity } from '@/actions/GlobalActions';
interface SucosProps {
sucos_id: number;
@ -34,7 +35,7 @@ const API_URL = apiConfig.service_master_data;
const AddDialog = () => {
const parentRef = useRef<any | null>(null);
const { showAddDialog, handleAddDialog } = useManageAldeiasContext();
const { showAddDialog, handleAddDialog, selectedAldeias } = useManageAldeiasContext();
const { reload } = useDataGrid();
const { PostData, GetData } = useCallApi();
const parsedUser = getAuth()?.user;
@ -70,6 +71,13 @@ const AddDialog = () => {
handleAddDialog(false);
toast.success('Success Create Aldeias');
reload();
const createActivity = {
module: 'Manage Aldeias',
description: `Create Aldeia => ${formField.name}`,
action: 'C'
};
doSaveLogActivity(createActivity);
} else {
toast.error('Error Create Aldeias');
setAlert({ show: true, message: 'Failed to create Aldeias. Please try again.' });

View File

@ -6,6 +6,7 @@ import { useCallback, useState } from 'react';
import { toast } from 'sonner';
import { Dialog, DialogContent, DialogFooter, DialogHeader } from '@/components/ui/dialog';
import { Button } from '@/components/ui/button';
import { doSaveLogActivity } from '@/actions/GlobalActions';
const API_URL = apiConfig.service_master_data;
@ -33,6 +34,14 @@ const DeleteDialog = () => {
handleDeleteDialog(false, null);
toast.success('Success Delete Aldeias');
reload();
const createActivity = {
module: 'Manage Aldeias',
description: `Delete Aldeia => ${selectedAldeias}`,
action: 'D'
};
doSaveLogActivity(createActivity);
} else {
setAlert({ show: true, message: response?.message });
toast.error('Failed Delete Aldeias');

View File

@ -24,6 +24,7 @@ import {
CommandItem,
CommandList
} from '@/components/ui/command';
import { doSaveLogActivity } from '@/actions/GlobalActions';
interface SucosProps {
sucos_id: number;
@ -69,6 +70,13 @@ const EditDialog = () => {
handleEditDialog(false, null);
toast.success('Success Update Aldeias');
reload();
const createActivity = {
module: 'Manage Aldeias',
description: `Edit Aldeia => ${selectedAldeias}`,
action: 'U'
};
doSaveLogActivity(createActivity);
} else {
toast.error('Error Update Aldeias');
setAlert({ show: true, message: 'Error Update Aldeias' });

View File

@ -33,6 +33,7 @@ import {
SelectValue
} from '@/components/ui/select';
import { useManageConversionContext } from '../hooks/useManageConversionContext';
import { doSaveLogActivity } from '@/actions/GlobalActions';
interface CurrencyProps {
ID: string;
name: string;
@ -80,6 +81,13 @@ const AddDialog = () => {
resetForm();
handleAddDialog(false);
toast.success('Success Create Conversion');
const createActivity = {
module: 'Manage Conversion',
description: `Create Conversion => ${formField.id_currency_origin} => ${formField.id_currency_destination}`,
action: 'C'
};
doSaveLogActivity(createActivity);
reload();
} else {
toast.error('Error Create Conversion');
@ -246,28 +254,27 @@ const AddDialog = () => {
/>
</div>
<div className="w-full">
<label className="form-label">
Status
<span className="text-red-500">*</span>
</label>
<div className="grow">
<Select
value={formField.status}
onValueChange={(value) =>
setFormField((prev) => ({ ...prev, status: value }))
}
>
<SelectTrigger>
<SelectValue placeholder="Select" />
</SelectTrigger>
<SelectContent>
<SelectItem value="Y">Active</SelectItem>
<SelectItem value="N">Inactive</SelectItem>
</SelectContent>
</Select>
</div>
<label className="form-label">
Status
<span className="text-red-500">*</span>
</label>
<div className="grow">
<Select
value={formField.status}
onValueChange={(value) =>
setFormField((prev) => ({ ...prev, status: value }))
}
>
<SelectTrigger>
<SelectValue placeholder="Select" />
</SelectTrigger>
<SelectContent>
<SelectItem value="Y">Active</SelectItem>
<SelectItem value="N">Inactive</SelectItem>
</SelectContent>
</Select>
</div>
</div>
<div className="flex justify-end gap-5">
<Button type="button" variant="outline" onClick={resetForm}>

View File

@ -13,6 +13,7 @@ import {
} from '@/components/ui/dialog';
import { Button } from '@/components/ui/button';
import { DialogDescription } from '@radix-ui/react-dialog';
import { doSaveLogActivity } from '@/actions/GlobalActions';
const API_URL = apiConfig.service_wallet;
@ -30,23 +31,29 @@ const DeleteDialog = () => {
toast.error('No Conversion selected');
return;
}
console.log(selectedConversion);
const response = await DeleteData(
`${API_URL}/dashboard/conversion/${selectedConversion}`,
{ id: selectedConversion }
);
// console.log(selectedConversion);
const response = await DeleteData(`${API_URL}/dashboard/conversion/${selectedConversion}`, {
id: selectedConversion
});
if (response?.status) {
setAlert({ show: false, message: '' });
handleDeleteDialog(false, null);
toast.success('Success Delete Conversion');
const createActivity = {
module: 'Manage Conversion',
description: `Delete Conversion => ${selectedConversion}`,
action: 'D'
};
doSaveLogActivity(createActivity);
reload();
} else {
setAlert({ show: true, message: response?.message });
toast.error('Failed Delete Conversion');
}
}, [selectedConversion, DeleteData, handleDeleteDialog, reload]);
console.log(selectedConversion);
// console.log(selectedConversion);
return (
<Dialog open={showDeleteDialog} onOpenChange={(open) => handleDeleteDialog(open, null)}>
<DialogContent className="container-fixed max-w-md flex flex-col p-5 overflow-hidden [&>button]:hidden">

View File

@ -33,6 +33,7 @@ import {
SelectValue
} from '@/components/ui/select';
import { useManageConversionContext } from '../hooks/useManageConversionContext';
import { doSaveLogActivity } from '@/actions/GlobalActions';
interface CurrencyProps {
ID: string;
name: string;
@ -82,6 +83,13 @@ const EditDialog = () => {
resetForm();
handleEditDialog(false, null);
toast.success('Success Update Conversion');
const createActivity = {
module: 'Manage Conversion',
description: `Update Conversion => ${selectedConversion}`,
action: 'U'
};
doSaveLogActivity(createActivity);
reload();
} else {
toast.error('Error Create Conversion');

View File

@ -159,7 +159,7 @@ const ManageConversionContextProvider = ({ children }: { children: React.ReactNo
) => {
sorting = sorting.length == 0 ? [{ id: 'name', desc: true }] : sorting;
filter = filter.length == 0 ? {} : { any: filter[0].value?.toLowerCase() };
console.log(sorting);
// console.log(sorting);
const response = await GetData(`${API_URL}/dashboard/conversion/`, {
limit: limit,
page: page + 1,
@ -168,7 +168,7 @@ const ManageConversionContextProvider = ({ children }: { children: React.ReactNo
order_direction: sorting[0].desc ? 'ASC' : 'DESC',
filter: JSON.stringify(filter)
});
console.log(response?.data);
// console.log(response?.data);
return { data: response?.data.list, totalCount: response?.data.total_count };
};

View File

@ -34,6 +34,7 @@ import {
} from '@/components/ui/select';
import { useManageCurrencyContext } from '../hooks/useManageCurrencyContext';
import { prefix } from 'stylis';
import { doSaveLogActivity } from '@/actions/GlobalActions';
interface CurrencyProps {
ID: string;
name: string;
@ -80,6 +81,13 @@ const AddDialog = () => {
resetForm();
handleAddDialog(false);
toast.success('Success Create Currency');
const createActivity = {
module: 'Manage Currency',
description: `Create Currency=> ${formField.name}`,
action: 'C'
};
doSaveLogActivity(createActivity);
reload();
} else {
toast.error('Error Create Currency');

View File

@ -13,6 +13,7 @@ import {
} from '@/components/ui/dialog';
import { Button } from '@/components/ui/button';
import { DialogDescription } from '@radix-ui/react-dialog';
import { doSaveLogActivity } from '@/actions/GlobalActions';
const API_URL = apiConfig.service_wallet;
@ -39,6 +40,13 @@ const DeleteDialog = () => {
setAlert({ show: false, message: '' });
handleDeleteDialog(false, null);
toast.success('Success Delete Currency');
const createActivity = {
module: 'Manage Currency',
description: `Delete Currency=> ${selectedCurrency}`,
action: 'D'
};
doSaveLogActivity(createActivity);
reload();
} else {
setAlert({ show: true, message: response?.message });

View File

@ -33,6 +33,7 @@ import {
SelectValue
} from '@/components/ui/select';
import { useManageCurrencyContext } from '../hooks/useManageCurrencyContext';
import { doSaveLogActivity } from '@/actions/GlobalActions';
interface CurrencyProps {
ID: string;
name: string;
@ -81,6 +82,13 @@ const EditDialog = () => {
resetForm();
handleEditDialog(false, null);
toast.success('Success Update Currency');
const createActivity = {
module: 'Manage Currency',
description: `Update Currency=> ${selectedCurrency}`,
action: 'U'
};
doSaveLogActivity(createActivity);
reload();
} else {
toast.error('Error Create Currency');

View File

@ -55,13 +55,13 @@ const AddDialog = () => {
resetForm();
reload();
toast.success('Municipio created successfully!');
// const createActivity = {
// module: 'Manage Municipio',
// description: `Create Municipio => ${selectedMunicipios}`,
// action: 'C'
// };
const createActivity = {
module: 'Manage Municipios',
description: `Create Municipio => ${formField.name}`,
action: 'C'
};
// doSaveLogActivity(createActivity);
doSaveLogActivity(createActivity);
} else {
toast.error('Failed to create municipio.');
setAlert({ show: true, message: 'Failed to create municipio. Please try again.' });

View File

@ -4,9 +4,16 @@ import { useCallback, useState } from 'react';
import { apiConfig } from '@/config/api.config';
import { useCallApi } from '@/hooks';
import { toast } from 'sonner';
import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle } from '@/components/ui/dialog';
import {
Dialog,
DialogContent,
DialogFooter,
DialogHeader,
DialogTitle
} from '@/components/ui/dialog';
import { Button } from '@/components/ui/button';
import { DialogDescription } from '@radix-ui/react-dialog';
import { doSaveLogActivity } from '@/actions/GlobalActions';
const API_URL = apiConfig.service_master_data;
@ -25,16 +32,23 @@ const DeleteDialog = () => {
return;
}
const response = await DeleteData(
`${API_URL}/municipios/delete/${selectedMunicipios}/false`,
{ id: selectedMunicipios }
);
const response = await DeleteData(`${API_URL}/municipios/delete/${selectedMunicipios}/false`, {
id: selectedMunicipios
});
if (response?.status) {
setAlert({ show: false, message: '' });
handleDeleteDialog(false, null);
toast.success('Success Delete Municipio');
reload();
const createActivity = {
module: 'Manage Municipios',
description: `Delete Municipio => ${selectedMunicipios}`,
action: 'D'
};
doSaveLogActivity(createActivity);
} else {
setAlert({ show: true, message: response?.message });
toast.error('Failed Delete Municipio');
@ -43,7 +57,6 @@ const DeleteDialog = () => {
return (
<Dialog open={showDeleteDialog} onOpenChange={(open) => handleDeleteDialog(open, null)}>
<DialogContent className="container-fixed max-w-md flex flex-col p-5 overflow-hidden [&>button]:hidden">
<DialogHeader className="p-0 border-0 block">
<DialogTitle></DialogTitle>

View File

@ -60,13 +60,13 @@ const EditDialog = () => {
resetForm();
toast.success('Success update municipio');
reload();
// const createActivity = {
// module: 'Manage Municipio',
// description: `Edit Municipio => ${selectedMunicipios}`,
// action: 'U'
// };
const createActivity = {
module: 'Manage Municipios',
description: `Edit Municipio => ${selectedMunicipios}`,
action: 'U'
};
// doSaveLogActivity(createActivity);
doSaveLogActivity(createActivity);
} else {
toast.error('Failed update user');
setAlert({ show: true, message: 'Failed to update municipio. Please try again.' });

View File

@ -24,6 +24,7 @@ import {
CommandItem,
CommandList
} from '@/components/ui/command';
import { doSaveLogActivity } from '@/actions/GlobalActions';
interface MunicipioProps {
id: number;
@ -34,7 +35,7 @@ const API_URL = apiConfig.service_master_data;
const AddDialog = () => {
const parentRef = useRef<any | null>(null);
const { showAddDialog, handleAddDialog } = useManagePostoAdmsContext();
const { showAddDialog, handleAddDialog, selectedPostoAdms } = useManagePostoAdmsContext();
const { reload } = useDataGrid();
const { PostData, GetData } = useCallApi();
const parsedUser = getAuth()?.user;
@ -72,6 +73,13 @@ const AddDialog = () => {
resetForm();
reload();
toast.success('Posto Adm created successfully!');
const createActivity = {
module: 'Manage Posto Administrativo',
description: `Create PostoAdms => ${formField.name}`,
action: 'C'
};
doSaveLogActivity(createActivity);
} else {
toast.error('Failed to create Posto Adm. Please try again.');
setAlert({ show: true, message: 'Failed to create Posto Adm. Please try again.' });

View File

@ -4,8 +4,16 @@ import { useCallApi } from '@/hooks';
import { useCallback, useState } from 'react';
import { apiConfig } from '@/config/api.config';
import { toast } from 'sonner';
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from '@/components/ui/dialog';
import {
Dialog,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle
} from '@/components/ui/dialog';
import { Button } from '@/components/ui/button';
import { doSaveLogActivity } from '@/actions/GlobalActions';
const API_URL = apiConfig.service_master_data;
@ -24,16 +32,22 @@ const DeleteDialog = () => {
return;
}
const response = await DeleteData(
`${API_URL}/postoadms/delete/${selectedPostoAdms}/false`,
{ id: selectedPostoAdms }
);
const response = await DeleteData(`${API_URL}/postoadms/delete/${selectedPostoAdms}/false`, {
id: selectedPostoAdms
});
if (response?.status) {
setAlert({ show: false, message: '' });
handleDeleteDialog(false, null);
toast.success('Success Delete Posto Adm');
reload();
const createActivity = {
module: 'Manage Posto Administrativo',
description: `Delete PostoAdms => ${selectedPostoAdms}`,
action: 'D'
};
doSaveLogActivity(createActivity);
} else {
setAlert({ show: true, message: response?.message });
toast.error('Failed Delete Posto Adm');

View File

@ -24,6 +24,7 @@ import {
CommandItem,
CommandList
} from '@/components/ui/command';
import { doSaveLogActivity } from '@/actions/GlobalActions';
interface MunicipioProps {
id: number;
@ -72,6 +73,14 @@ const EditDialog = () => {
resetForm();
toast.success('Success Update Posto Adm');
reload();
const createActivity = {
module: 'Manage Posto Administrativo',
description: `Edit PostoAdms => ${selectedPostoAdms}`,
action: 'U'
};
doSaveLogActivity(createActivity);
} else {
toast.error('Error Update Posto Adm');
setAlert({ show: true, message: 'Failed to update posto adm. Please try again.' });

View File

@ -22,6 +22,7 @@ import {
SelectTrigger,
SelectValue
} from '@/components/ui/select';
import { doSaveLogActivity } from '@/actions/GlobalActions';
interface ProviderProps {
provider_id: number;
@ -32,7 +33,7 @@ const API_URL = apiConfig.service_master_data;
const AddDialog = () => {
const parentRef = useRef<any | null>(null);
const parsedUser = getAuth()?.user;
const { showAddDialog, handleAddDialog } = useManageProductsContext();
const { showAddDialog, handleAddDialog, selectedProducts } = useManageProductsContext();
const { PostData, GetData } = useCallApi();
const { reload } = useDataGrid();
const [alert, setAlert] = useState({
@ -75,6 +76,14 @@ const AddDialog = () => {
handleAddDialog(false);
toast.success('Success Create Product');
reload();
const createActivity = {
module: 'Manage Products',
description: `Create Product => ${formField.name}`,
action: 'C'
};
doSaveLogActivity(createActivity);
} else {
toast.error('Failed Create Product');
setAlert({ show: true, message: response?.message });
@ -173,9 +182,7 @@ const AddDialog = () => {
className="input"
type="text"
value={formField.name}
onChange={(e) =>
setFormField({ ...formField, name: e.target.value })
}
onChange={(e) => setFormField({ ...formField, name: e.target.value })}
/>
</div>
</div>
@ -189,9 +196,7 @@ const AddDialog = () => {
className="input"
type="text"
value={formField.type}
onChange={(e) =>
setFormField({ ...formField, type: e.target.value })
}
onChange={(e) => setFormField({ ...formField, type: e.target.value })}
/>
</div>
</div>
@ -205,9 +210,7 @@ const AddDialog = () => {
className="input"
type="text"
value={formField.code}
onChange={(e) =>
setFormField({ ...formField, code: e.target.value })
}
onChange={(e) => setFormField({ ...formField, code: e.target.value })}
/>
</div>
</div>
@ -221,9 +224,7 @@ const AddDialog = () => {
className="input"
type="text"
value={formField.description}
onChange={(e) =>
setFormField({ ...formField, description: e.target.value })
}
onChange={(e) => setFormField({ ...formField, description: e.target.value })}
/>
</div>
</div>
@ -323,9 +324,7 @@ const AddDialog = () => {
</label>
<Select
value={formField.status}
onValueChange={(value) =>
setFormField({ ...formField, status: value })
}
onValueChange={(value) => setFormField({ ...formField, status: value })}
>
<SelectTrigger>
<SelectValue placeholder="Select Status" />

View File

@ -4,8 +4,16 @@ import { Alert, useDataGrid } from '@/components';
import { useCallApi } from '@/hooks';
import { useCallback, useState } from 'react';
import { toast } from 'sonner';
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from '@/components/ui/dialog';
import {
Dialog,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle
} from '@/components/ui/dialog';
import { Button } from '@/components/ui/button';
import { doSaveLogActivity } from '@/actions/GlobalActions';
const API_URL = apiConfig.service_master_data;
@ -30,6 +38,13 @@ const DeleteDialog = () => {
handleDeleteDialog(false, null);
toast.success('Success Delete Product');
reload();
const createActivity = {
module: 'Manage Product',
description: `Delete Product',', => ${selectedProducts}`,
action: 'D'
};
doSaveLogActivity(createActivity);
} else {
setAlert({ show: true, message: response?.message });
toast.error('Failed Delete Product');

View File

@ -22,6 +22,7 @@ import {
SelectTrigger,
SelectValue
} from '@/components/ui/select';
import { doSaveLogActivity } from '@/actions/GlobalActions';
interface ProviderProps {
provider_id: string;
@ -74,6 +75,14 @@ const EditDialog = () => {
handleEditDialog(false, null);
toast.success('Product updated successfully.');
reload();
const createActivity = {
module: 'Manage Products',
description: `Edit Product => ${selectedProducts}`,
action: 'U'
};
doSaveLogActivity(createActivity);
} else {
toast.error('Failed to update Product. Please try again.');
setAlert({ show: true, message: 'Failed to update Product. Please try again.' });

View File

@ -73,7 +73,7 @@ const ManageProductsContextProvider = ({ children }: { children: React.ReactNode
const columns = useMemo<ColumnDef<any>[]>(
() => [
{
accessorFn: (row) => row.products_name,
accessorFn: (row) => row.name,
id: 'name',
header: ({ column }) => <DataGridColumnHeader title="Name" column={column} />,
enableSorting: true,
@ -86,7 +86,7 @@ const ManageProductsContextProvider = ({ children }: { children: React.ReactNode
}
},
{
accessorFn: (row) => row.products_description,
accessorFn: (row) => row.description,
id: 'description',
header: ({ column }) => <DataGridColumnHeader title="Description" column={column} />,
enableSorting: true,
@ -96,7 +96,7 @@ const ManageProductsContextProvider = ({ children }: { children: React.ReactNode
}
},
{
accessorFn: (row) => row.products_price_point,
accessorFn: (row) => row.price_point,
id: 'price_point',
header: ({ column }) => <DataGridColumnHeader title="Price Point" column={column} />,
enableSorting: true,
@ -106,7 +106,7 @@ const ManageProductsContextProvider = ({ children }: { children: React.ReactNode
}
},
{
accessorFn: (row) => row.products_price_cash,
accessorFn: (row) => row.price_cash,
id: 'price_cash',
header: ({ column }) => <DataGridColumnHeader title="Price Cash" column={column} />,
enableSorting: true,
@ -189,7 +189,7 @@ const ManageProductsContextProvider = ({ children }: { children: React.ReactNode
pagination={{ size: 10 }}
toolbar={<ListToolbar />}
layout={{ card: true }}
sorting={[{ id: 'id', desc: false }]}
sorting={[{ id: 'Product.id', desc: false }]}
serverSide={true}
onFetchData={({ pageIndex, pageSize, sorting, columnFilters }) =>
getProductsLists(pageIndex, pageSize, sorting, columnFilters)

View File

@ -15,13 +15,14 @@ import {
} from '@/components/ui/dialog';
import { Input } from '@/components/ui/input';
import { Button } from '@/components/ui/button';
import { doSaveLogActivity } from '@/actions/GlobalActions';
const API_URL = apiConfig.service_master_data;
const AddDialog = () => {
const parentRef = useRef<any | null>(null);
const { reload } = useDataGrid();
const { PostData } = useCallApi();
const { showAddDialog, handleAddDialog } = useManageProfessionContext();
const { showAddDialog, handleAddDialog, selectedProfession } = useManageProfessionContext();
const parsedUser = getAuth()?.user;
const [alert, setAlert] = useState({
show: false,
@ -53,6 +54,14 @@ const AddDialog = () => {
handleAddDialog(false);
toast.success('Success Create Profession');
reload();
const createActivity = {
module: 'Manage Profession',
description: `Create Profession => ${formField.name}`,
action: 'C'
};
doSaveLogActivity(createActivity);
} else {
toast.error('Failed Create Profession');
setAlert({ show: true, message: response?.message });

View File

@ -4,8 +4,16 @@ import { Alert, useDataGrid } from '@/components';
import { useCallApi } from '@/hooks';
import { useCallback, useState } from 'react';
import { toast } from 'sonner';
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from '@/components/ui/dialog';
import {
Dialog,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle
} from '@/components/ui/dialog';
import { Button } from '@/components/ui/button';
import { doSaveLogActivity } from '@/actions/GlobalActions';
const API_URL = apiConfig.service_master_data;
@ -29,6 +37,13 @@ const DeleteDialog = () => {
handleDeleteDialog(false, null);
toast.success('Success Delete Profession');
reload();
const createActivity = {
module: 'Manage Profession',
description: `Delete Profession', => ${selectedProfession}`,
action: 'D'
};
doSaveLogActivity(createActivity);
} else {
setAlert({ show: true, message: response?.message });
toast.error('Failed Delete Profession');

View File

@ -15,6 +15,7 @@ import {
} from '@/components/ui/dialog';
import { Input } from '@/components/ui/input';
import { Button } from '@/components/ui/button';
import { doSaveLogActivity } from '@/actions/GlobalActions';
const API_URL = apiConfig.service_master_data;
const EditDialog = () => {
@ -54,6 +55,14 @@ const EditDialog = () => {
handleEditDialog(false, null);
toast.success('Success Update Profession');
reload();
const createActivity = {
module: 'Manage Profession',
description: `Edit Profession => ${selectedProfession}`,
action: 'U'
};
doSaveLogActivity(createActivity);
} else {
toast.error('Failed Update Profession');
setAlert({ show: true, message: 'Failed Update Profession' });

View File

@ -31,6 +31,7 @@ import {
CommandItem,
CommandList
} from '@/components/ui/command';
import { doSaveLogActivity } from '@/actions/GlobalActions';
export interface CustomerProps {
id: string;
@ -50,7 +51,7 @@ const API_URL_MASTERDATA = apiConfig.service_master_data;
const API_URL_TRANSACTION = apiConfig.service_transaction;
const AddDialog = () => {
const { showAddDialog, handleAddDialog } = useManageProviderContext();
const { showAddDialog, handleAddDialog, selectedProvider } = useManageProviderContext();
const { reload } = useDataGrid();
const { PostData, GetData } = useCallApi();
const parentRef = useRef<any | null>(null);
@ -91,6 +92,13 @@ const AddDialog = () => {
resetForm();
handleAddDialog(false);
toast.success('Success Create Provider');
const createActivity = {
module: 'Manage Provider',
description: `Create Provider => ${formField.name}`,
action: 'C'
};
doSaveLogActivity(createActivity);
reload();
} else {
toast.error('Failed Create Provider');
@ -293,11 +301,11 @@ const AddDialog = () => {
</label>
<Popover open={open} onOpenChange={setOpen}>
<PopoverTrigger asChild>
<button
type="button"
className="input col-span-5 text-left"
style={{ color: 'inherit' }}
>
<button
type="button"
className="input col-span-5 text-left"
style={{ color: 'inherit' }}
>
{customers.find((customer) => customer.id === formField.agent)
?.username || 'Select Agent'}
</button>

View File

@ -4,8 +4,16 @@ import { Alert, useDataGrid } from '@/components';
import { useCallApi } from '@/hooks';
import { useCallback, useState } from 'react';
import { toast } from 'sonner';
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from '@/components/ui/dialog';
import {
Dialog,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle
} from '@/components/ui/dialog';
import { Button } from '@/components/ui/button';
import { doSaveLogActivity } from '@/actions/GlobalActions';
const API_URL = apiConfig.service_master_data;
@ -29,6 +37,13 @@ const DeleteDialog = () => {
setAlert({ show: false, message: '' });
handleDeleteDialog(false, null);
toast.success('Success Delete Provider');
const createActivity = {
module: 'Manage Provider',
description: `Delete Provider => ${selectedProvider}`,
action: 'D'
};
doSaveLogActivity(createActivity);
reload();
} else {
setAlert({ show: true, message: response?.message });

View File

@ -32,6 +32,7 @@ import {
CommandItem,
CommandList
} from '@/components/ui/command';
import { doSaveLogActivity } from '@/actions/GlobalActions';
const API_URL_CUSTOMER = apiConfig.service_customer;
const API_URL_MASTERDATA = apiConfig.service_master_data;
@ -82,6 +83,13 @@ const EditDialog = () => {
resetForm();
handleEditDialog(false, null);
toast.success('Provider updated successfully.');
const createActivity = {
module: 'Manage Provider',
description: `Update Provider => ${selectedProvider}`,
action: 'U'
};
doSaveLogActivity(createActivity);
reload();
} else {
toast.error('Failed to update provider.');
@ -308,11 +316,11 @@ const EditDialog = () => {
</label>
<Popover open={open} onOpenChange={setOpen}>
<PopoverTrigger asChild>
<button
type="button"
className="input col-span-5 text-left"
style={{ color: 'inherit' }}
>
<button
type="button"
className="input col-span-5 text-left"
style={{ color: 'inherit' }}
>
{customers.find((customer) => customer.id === formField.agent)
?.fullname || 'Select Agent'}
</button>

View File

@ -16,8 +16,10 @@ const ListToolbar = () => {
<input
type="text"
placeholder="Search Provider"
value={(table.getColumn('name')?.getFilterValue() as string) ?? ''}
onChange={(event) => table.getColumn('name')?.setFilterValue(event.target.value)}
value={(table.getColumn('provider_name')?.getFilterValue() as string) ?? ''}
onChange={(event) =>
table.getColumn('provider_name')?.setFilterValue(event.target.value)
}
/>
</label>
{/* <DefaultTooltip title={'Filter'} placement={'top'}>

View File

@ -75,7 +75,7 @@ const ManageProviderContextProvider = ({ children }: { children: React.ReactNode
() => [
{
accessorFn: (row) => row.provider_name,
id: 'name',
id: 'provider_name',
header: ({ column }) => <DataGridColumnHeader title="Name" column={column} />,
enableSorting: true,
enableHiding: false,
@ -162,8 +162,9 @@ const ManageProviderContextProvider = ({ children }: { children: React.ReactNode
const getProviderLists = async (page: number, limit: number, sorting: any, filter: any) => {
try {
const field = 'Provider.name';
sorting = sorting.length == 0 ? [{ id: 'name', desc: false }] : sorting;
filter = filter.length == 0 ? {} : { any: filter[0].value?.toLowerCase() };
filter = filter.length == 0 ? {} : { [field]: filter[0].value?.toLowerCase() };
const response = await GetData(`${API_URL}/provider/list`, {
limit,
page: page + 1,
@ -172,7 +173,7 @@ const ManageProviderContextProvider = ({ children }: { children: React.ReactNode
order_direction: sorting[0].desc == false ? 'ASC' : 'DESC',
filter: JSON.stringify(filter)
});
console.log(response?.data);
// console.log(response?.data);
setProvider(response?.data.list);
return { data: response?.data.list, totalCount: response?.data.total_count };
} catch (error) {

View File

@ -24,6 +24,7 @@ import {
CommandItem,
CommandList
} from '@/components/ui/command';
import { doSaveLogActivity } from '@/actions/GlobalActions';
interface PostoAdmsProps {
PostoAdms_id: number;
@ -33,7 +34,7 @@ const API_URL = apiConfig.service_master_data;
const AddDialog = () => {
const parentRef = useRef<any | null>(null);
const { showAddDialog, handleAddDialog } = useManageSucosContext();
const { showAddDialog, handleAddDialog, selectedSucos } = useManageSucosContext();
const { reload } = useDataGrid();
const { PostData, GetData } = useCallApi();
const parsedUser = getAuth()?.user;
@ -69,6 +70,13 @@ const AddDialog = () => {
handleAddDialog(false);
reload();
toast.success('Sucos created successfully!');
const createActivity = {
module: 'Manage Sucos',
description: `Create Suco => ${formField.name}`,
action: 'C'
};
doSaveLogActivity(createActivity);
} else {
toast.error('Failed to create Sucos Please try again.');
setAlert({ show: true, message: 'Failed to create Sucos Please try again.' });

View File

@ -4,8 +4,16 @@ import { useCallback, useState } from 'react';
import { useCallApi } from '@/hooks';
import { Alert, useDataGrid } from '@/components';
import { toast } from 'sonner';
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from '@/components/ui/dialog';
import {
Dialog,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle
} from '@/components/ui/dialog';
import { Button } from '@/components/ui/button';
import { doSaveLogActivity } from '@/actions/GlobalActions';
const API_URL = apiConfig.service_master_data;
@ -31,6 +39,13 @@ const DeleteDialog = () => {
handleDeleteDialog(false, null);
toast.success('Success Delete Sucos');
reload();
const createActivity = {
module: 'Manage Sucos',
description: `Delete Suco => ${selectedSucos}`,
action: 'D'
};
doSaveLogActivity(createActivity);
} else {
setAlert({ show: true, message: response?.message });
toast.error('Failed Delete Sucos');

View File

@ -24,6 +24,7 @@ import {
CommandItem,
CommandList
} from '@/components/ui/command';
import { doSaveLogActivity } from '@/actions/GlobalActions';
interface PostoAdmsProps {
PostoAdms_id: number; // Ubah ke PostoAdms_id
@ -76,6 +77,13 @@ const EditDialog = () => {
handleEditDialog(false, null);
toast.success('Success Update Sucos');
reload();
const createActivity = {
module: 'Manage Sucos',
description: `Edit Suco => ${selectedSucos}`,
action: 'U'
};
doSaveLogActivity(createActivity);
} else {
toast.error('Failed Update Sucos');
setAlert({ show: true, message: 'Failed Update Sucos. Please try again' });

View File

@ -153,7 +153,7 @@ const ManageSucosContextProvider = ({ children }: { children: React.ReactNode })
const response = await GetData(`${API_URL}/sucos/list`, {
limit: limit,
page: page + 1,
with_deleted: true,
with_deleted: false,
order_field: sorting[0].id,
order_direction: sorting[0].desc == false ? 'ASC' : 'DESC',
filter: JSON.stringify(filter)

View File

@ -22,6 +22,7 @@ import {
} from '@/components/ui/select';
import { Button } from '@/components/ui/button';
import { Checkbox } from '@/components/ui/checkbox';
import { doSaveLogActivity } from '@/actions/GlobalActions';
interface CurrencyProps {
ID: string;
@ -42,7 +43,7 @@ const API_URL_WALLET = apiConfig.service_wallet;
const API_URL_MASTER_DATA = apiConfig.service_master_data;
const AddDialog = () => {
const { showAddDialog, handleAddDialog } = useManageWalletContext();
const { showAddDialog, handleAddDialog, selectedWallet } = useManageWalletContext();
const { GetData, PostData } = useCallApi();
const { reload } = useDataGrid();
const [alert, setAlert] = useState({
@ -101,6 +102,14 @@ const AddDialog = () => {
handleAddDialog(false);
toast.success('Success Create Wallet');
reload();
const createActivity = {
module: 'Manage Wallet',
description: `Create Wallet => ${selectedWallet?.Wallet_id} - ${selectedWallet?.Wallet_name}`,
action: 'C'
};
doSaveLogActivity(createActivity);
} else {
toast.error('Failed Create Wallet');
setAlert({ show: true, message: 'Failed Create Wallet' });

View File

@ -21,6 +21,7 @@ import {
SelectValue
} from '@/components/ui/select';
import { Button } from '@/components/ui/button';
import { doSaveLogActivity } from '@/actions/GlobalActions';
interface CurrencyProps {
ID: string;
@ -53,13 +54,11 @@ const EditDialog = () => {
description: string;
status: string;
group: string[];
currency_id: string;
} = {
name: '',
description: '',
status: '',
group: [],
currency_id: ''
group: []
};
const [formField, setFormField] = useState(initialState);
const [currencies, setCurrencies] = useState<CurrencyProps[]>([]);
@ -71,18 +70,26 @@ const EditDialog = () => {
};
const doUpdateWallet = useCallback(
async (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault();
async (payload: { name: string; description: string; status: string }) => {
// e.preventDefault();
const response = await PutData(
`${API_URL_MASTER_DATA}/wallet/update/${selectedWallet?.Wallet_id}`,
formField
payload
);
if (response?.status) {
handleEditDialog(false, null);
toast.success('Success Update Wallet');
reload();
const createActivity = {
module: 'Manage Wallet',
description: `Edit Wallet => ${selectedWallet?.Wallet_id} - ${selectedWallet?.Wallet_name}`,
action: 'U'
};
doSaveLogActivity(createActivity);
} else {
toast.error('Failed Update Wallet');
setAlert({ show: true, message: 'Failed Update Wallet' });
@ -94,8 +101,14 @@ const EditDialog = () => {
const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault();
console.log(formField);
doUpdateWallet(e);
// const { name, description, status } = formField;
const payload = {
name: formField.name,
description: formField.description,
status: formField.status
};
// console.log(payload);
doUpdateWallet(payload);
setAlert({ show: false, message: '' });
};
@ -156,8 +169,6 @@ const EditDialog = () => {
.map((g) => g.name)
.join(', ');
const selectedCurrency = currencies.find((currency) => currency.ID === formField.currency_id);
useEffect(() => {
getCurrencyLists([{ id: 'name', desc: false }]);
getGroupLists([{ id: 'name', desc: false }]);
@ -182,7 +193,7 @@ const EditDialog = () => {
resetForm();
}
}, [showEditDialog]);
// console.log(selectedWallet);
return (
<Dialog open={showEditDialog} onOpenChange={(open) => handleEditDialog(open, null)}>
<DialogContent className="container-fixed max-w-[768px] flex flex-col p-5 overflow-hidden">
@ -246,25 +257,25 @@ const EditDialog = () => {
</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">Currency</label>
<Input type="text" placeholder='Empty' value={selectedCurrency?.name || ''} readOnly />
</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">Groups</label>
<Input type="text" placeholder='Empty' value={selectedGroupNames} readOnly />
<div className="relative w-full">
<Input
type="text"
placeholder="Empty"
value={selectedGroupNames}
readOnly
className="bg-gray-100 border border-dashed border-gray-400 text-gray-600 cursor-not-allowed"
/>
</div>
</div>
</div>
<div className="flex justify-end gap-5">
<Button type="button" variant="outline" onClick={resetForm}>
Reset
<Button variant="default" type="submit">
Update
</Button>
<Button variant="default">Update</Button>
</div>
</div>
</form>

View File

@ -15,7 +15,7 @@ const ListToolbar = () => {
<KeenIcon icon="magnifier" />
<input
type="text"
placeholder="Search Provider"
placeholder="Search Wallet"
value={(table.getColumn('name')?.getFilterValue() as string) ?? ''}
onChange={(event) => table.getColumn('name')?.setFilterValue(event.target.value)}
/>

View File

@ -146,7 +146,7 @@ const ManageWalletContextProvider = ({ children }: { children: React.ReactNode }
const getWalletLists = async (page: number, limit: number, sorting: any, filter: any) => {
try {
sorting = sorting.length == 0 ? [{ id: 'name', desc: false }] : sorting;
filter = filter.length == 0 ? {} : { any: filter[0].value?.toLowerCase() };
filter = filter.length == 0 ? {} : { name: filter[0].value?.toLowerCase() };
const response = await GetData(`${API_URL_MASTER_DATA}/wallet/list`, {
limit,
page: page + 1,
@ -183,7 +183,7 @@ const ManageWalletContextProvider = ({ children }: { children: React.ReactNode }
pagination={{ size: 25 }}
toolbar={<ListToolbar />}
layout={{ card: true }}
sorting={[{ id: 'id', desc: false }]}
sorting={[{ id: 'created_at', desc: true }]}
serverSide={true}
onFetchData={({ pageIndex, pageSize, sorting, columnFilters }) =>
getWalletLists(pageIndex, pageSize, sorting, columnFilters)

View File

@ -31,6 +31,7 @@ import {
CommandList
} from '@/components/ui/command';
import { NumericFormat } from 'react-number-format';
import { doSaveLogActivity } from '@/actions/GlobalActions';
interface GroupProps {
ID: string;
@ -48,7 +49,7 @@ interface WalletProps {
const API_URL_WALLET = apiConfig.service_wallet;
const AddDialog = () => {
const { showAddDialog, handleAddDialog } = useManageWalletRuleContext();
const { showAddDialog, handleAddDialog, selectedWalletRule } = useManageWalletRuleContext();
const { reload } = useDataGrid();
const { PostData, GetData } = useCallApi();
const [open, setOpen] = useState(false);
@ -94,6 +95,14 @@ const AddDialog = () => {
handleAddDialog(false);
toast.success('Success Create Wallet Rule');
reload();
const createActivity = {
module: 'Manage Wallet Rule',
description: `Create Wallet Rule => ${selectedWalletRule?.ID}`,
action: 'C'
};
doSaveLogActivity(createActivity);
} else {
toast.error('Failed Create Wallet Rule');
setAlert({ show: true, message: 'Failed Create Wallet Rule' });

View File

@ -13,6 +13,7 @@ import {
DialogTitle
} from '@/components/ui/dialog';
import { Button } from '@/components/ui/button';
import { doSaveLogActivity } from '@/actions/GlobalActions';
const API_URL_WALLET = apiConfig.service_wallet;
@ -37,6 +38,13 @@ const DeleteDialog = () => {
toast.success('Wallet rule deleted successfully');
handleDeleteDialog(false, null);
reload();
const createActivity = {
module: 'Manage Wallet Rule',
description: `Delete Wallet Rule', => ${selectedWalletRule.ID}`,
action: 'D'
};
doSaveLogActivity(createActivity);
setAlert({ show: false, message: '' });
} else {
toast.error('Failed to delete wallet rule');

View File

@ -31,6 +31,7 @@ import {
import { Input } from '@/components/ui/input';
import { Button } from '@/components/ui/button';
import { NumericFormat } from 'react-number-format';
import { doSaveLogActivity } from '@/actions/GlobalActions';
interface GroupProps {
ID: string;
@ -97,6 +98,14 @@ const EditDialog = () => {
handleEditDialog(false, null);
toast.success('Success Update Wallet Rule');
reload();
const createActivity = {
module: 'Manage Wallet Rule',
description: `Edit Wallet Rule => ${selectedWalletRule?.ID}`,
action: 'U'
};
doSaveLogActivity(createActivity);
} else {
toast.error('Failed Update Wallet Rule');
setAlert({ show: true, message: 'Failed Update Wallet Rule' });