This commit is contained in:
unknown
2025-04-09 14:51:00 +07:00
23 changed files with 141 additions and 147 deletions

View File

@ -9,11 +9,11 @@ const AldeiasMaster = () => {
return ( return (
<> <>
<Helmet> <Helmet>
<title>TPAY | Manage Aldeias</title> <title>TPAY | Manage Aldeia</title>
</Helmet> </Helmet>
<ManageAldeiasContextProvider> <ManageAldeiasContextProvider>
<Container> <Container>
<h1 className="text-xl font-medium leading-none text-gray-900 mb-3">Aldeias</h1> <h1 className="text-xl font-medium leading-none text-gray-900 mb-3">Aldeia</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>
@ -24,7 +24,7 @@ const AldeiasMaster = () => {
</Link> </Link>
<Link underline="none" color="inherit"> <Link underline="none" color="inherit">
<span className="text-sm">Manage Aldeias</span> <span className="text-sm">Manage Aldeia</span>
</Link> </Link>
</Breadcrumbs> </Breadcrumbs>

View File

@ -69,18 +69,18 @@ const AddDialog = () => {
if (response?.status) { if (response?.status) {
resetForm(); resetForm();
handleAddDialog(false); handleAddDialog(false);
toast.success('Success Create Aldeias'); toast.success('Success Create Aldeia');
reload(); reload();
const createActivity = { const createActivity = {
module: 'Manage Aldeias', module: 'Manage Aldeia',
description: `Create Aldeia => ${formField.name}`, description: `Create Aldeia => ${formField.name}`,
action: 'C' action: 'C'
}; };
doSaveLogActivity(createActivity); doSaveLogActivity(createActivity);
} else { } else {
toast.error('Error Create Aldeias'); toast.error('Error Create Aldeia');
setAlert({ show: true, message: 'Failed to create Aldeias. Please try again.' }); setAlert({ show: true, message: 'Failed to create Aldeia. Please try again.' });
} }
}, },
[formField] [formField]
@ -100,7 +100,8 @@ const AddDialog = () => {
// console.log('SUCOS', response?.data); // console.log('SUCOS', response?.data);
setSucos(response?.data.list); setSucos(response?.data.list);
} catch (error) { } catch (error) {
console.error('Error fetching municipios', error); // console.error('Error fetching Municipio', error);
setAlert({ show: true, message: 'Failed to fetch Municipio. Please try again.' });
} }
}; };
@ -141,7 +142,7 @@ const AddDialog = () => {
<Dialog open={showAddDialog} onOpenChange={(open) => handleAddDialog(open)}> <Dialog open={showAddDialog} onOpenChange={(open) => handleAddDialog(open)}>
<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">
<DialogHeader> <DialogHeader>
<DialogTitle>Aldeias - Create</DialogTitle> <DialogTitle>Aldeia - Create</DialogTitle>
<DialogDescription></DialogDescription> <DialogDescription></DialogDescription>
</DialogHeader> </DialogHeader>
<DialogBody ref={parentRef}> <DialogBody ref={parentRef}>
@ -157,7 +158,7 @@ const AddDialog = () => {
<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">
Name<span className="text-red-500">*</span> Aldeia Name<span className="text-red-500">*</span>
</label> </label>
<Input <Input
className="input" className="input"
@ -175,10 +176,11 @@ const AddDialog = () => {
</label> </label>
<Popover open={open} onOpenChange={setOpen}> <Popover open={open} onOpenChange={setOpen}>
<PopoverTrigger asChild> <PopoverTrigger asChild>
<button <button
type="button" type="button"
className="input col-span-5 text-left" className="input col-span-5 text-left"
style={{color:'inherit'}}> style={{ color: 'inherit' }}
>
{sucos.find((suco) => suco.sucos_id === formField.sucosId)?.sucos_name || {sucos.find((suco) => suco.sucos_id === formField.sucosId)?.sucos_name ||
'Select Sucos'} 'Select Sucos'}
</button> </button>

View File

@ -32,11 +32,11 @@ const DeleteDialog = () => {
if (response?.status) { if (response?.status) {
setAlert({ show: false, message: '' }); setAlert({ show: false, message: '' });
handleDeleteDialog(false, null); handleDeleteDialog(false, null);
toast.success('Success Delete Aldeias'); toast.success('Success Delete Aldeia');
reload(); reload();
const createActivity = { const createActivity = {
module: 'Manage Aldeias', module: 'Manage Aldeia',
description: `Delete Aldeia => ${selectedAldeias}`, description: `Delete Aldeia => ${selectedAldeias}`,
action: 'D' action: 'D'
}; };
@ -44,7 +44,7 @@ const DeleteDialog = () => {
doSaveLogActivity(createActivity); doSaveLogActivity(createActivity);
} else { } else {
setAlert({ show: true, message: response?.message }); setAlert({ show: true, message: response?.message });
toast.error('Failed Delete Aldeias'); toast.error('Failed Delete Aldeia');
} }
}, [selectedAldeias, DeleteData, handleDeleteDialog, reload]); }, [selectedAldeias, DeleteData, handleDeleteDialog, reload]);

View File

@ -68,18 +68,18 @@ const EditDialog = () => {
if (response?.status) { if (response?.status) {
resetForm(); resetForm();
handleEditDialog(false, null); handleEditDialog(false, null);
toast.success('Success Update Aldeias'); toast.success('Success Update Aldeia');
reload(); reload();
const createActivity = { const createActivity = {
module: 'Manage Aldeias', module: 'Manage Aldeia',
description: `Edit Aldeia => ${selectedAldeias}`, description: `Edit Aldeia => ${selectedAldeias}`,
action: 'U' action: 'U'
}; };
doSaveLogActivity(createActivity); doSaveLogActivity(createActivity);
} else { } else {
toast.error('Error Update Aldeias'); toast.error('Error Update Aldeia');
setAlert({ show: true, message: 'Error Update Aldeias' }); setAlert({ show: true, message: 'Error Update Aldeia' });
} }
}, },
[selectedAldeias, formField] [selectedAldeias, formField]
@ -99,7 +99,8 @@ const EditDialog = () => {
// console.log('SUCOS', response?.data); // console.log('SUCOS', response?.data);
setSucos(response?.data.list); setSucos(response?.data.list);
} catch (error) { } catch (error) {
console.error('Error fetching municipios', error); console.error('Error fetching Sucos', error);
setAlert({ show: true, message: 'Failed to get Sucos. Please try again.' });
} }
}; };
@ -164,7 +165,7 @@ const EditDialog = () => {
<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">
<DialogHeader> <DialogHeader>
<DialogTitle>Aldeias - Update</DialogTitle> <DialogTitle>Aldeia - Update</DialogTitle>
<DialogDescription></DialogDescription> <DialogDescription></DialogDescription>
</DialogHeader> </DialogHeader>
<DialogBody> <DialogBody>
@ -180,7 +181,7 @@ const EditDialog = () => {
<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">
Name<span className="text-red-500">*</span> Aldeia Name<span className="text-red-500">*</span>
</label> </label>
<Input <Input
className="input" className="input"

View File

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

View File

@ -80,7 +80,7 @@ const ManageAldeiasContextProvider = ({ children }: { children: React.ReactNode
{ {
accessorFn: (row) => row.name, accessorFn: (row) => row.name,
id: 'name', id: 'name',
header: ({ column }) => <DataGridColumnHeader title="Name" column={column} />, header: ({ column }) => <DataGridColumnHeader title="Aldeia Name" column={column} />,
enableSorting: true, enableSorting: true,
enableHiding: false, enableHiding: false,
meta: { meta: {
@ -90,7 +90,7 @@ const ManageAldeiasContextProvider = ({ children }: { children: React.ReactNode
{ {
accessorFn: (row) => row.sucos.name, accessorFn: (row) => row.sucos.name,
id: 'sucos_name', id: 'sucos_name',
header: ({ column }) => <DataGridColumnHeader title="Sucos" column={column} />, header: ({ column }) => <DataGridColumnHeader title="Sucos Name" column={column} />,
enableSorting: true, enableSorting: true,
enableHiding: false, enableHiding: false,
meta: { meta: {

View File

@ -11,11 +11,11 @@ const Municipios = () => {
return ( return (
<> <>
<Helmet> <Helmet>
<title>TPAY | Municipios</title> <title>TPAY | Municipio</title>
</Helmet> </Helmet>
<ManageMunicipiosProvider> <ManageMunicipiosProvider>
<Container className="mb-7"> <Container className="mb-7">
<h1 className="text-xl font-medium leading-none text-gray-900 mb-3">MUNICIPIOS</h1> <h1 className="text-xl font-medium leading-none text-gray-900 mb-3">MUNICIPIO</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>
@ -26,7 +26,7 @@ const Municipios = () => {
</Link> </Link>
<Link underline="none" color="inherit"> <Link underline="none" color="inherit">
<span className="text-sm">Manage Municipios</span> <span className="text-sm">Manage Municipio</span>
</Link> </Link>
</Breadcrumbs> </Breadcrumbs>
<div className="grid gap-5 lg:gap-7.5"> <div className="grid gap-5 lg:gap-7.5">

View File

@ -56,7 +56,7 @@ const AddDialog = () => {
reload(); reload();
toast.success('Municipio created successfully!'); toast.success('Municipio created successfully!');
const createActivity = { const createActivity = {
module: 'Manage Municipios', module: 'Manage Municipio',
description: `Create Municipio => ${formField.name}`, description: `Create Municipio => ${formField.name}`,
action: 'C' action: 'C'
}; };
@ -107,52 +107,36 @@ const AddDialog = () => {
return ( return (
<Dialog open={showAddDialog} onOpenChange={(open) => handleAddDialog(open)}> <Dialog open={showAddDialog} onOpenChange={(open) => handleAddDialog(open)}>
<DialogContent className="container-fixed max-w-96 flex flex-col p-5 overflow-hidden [&>button]:hidden"> <DialogContent className="container-fixed max-w-[768px] flex flex-col p-5 overflow-hidden">
<DialogTitle></DialogTitle> <DialogHeader>
<DialogDescription></DialogDescription> <DialogTitle>Municipio - Create</DialogTitle>
<DialogHeader className="p-2 border-0"> <DialogDescription></DialogDescription>
<div className="flex items-center justify-between flex-wrap grow">
<div className="flex flex-col justify-center">
<h1 className="text-xl font-semibold leading-none text-gray-900">Add Municipios</h1>
<div className="flex items-center gap-2 text-sm font-normal text-gray-700"></div>
</div>
<div
className="cursor-pointer hover:opacity-100 opacity-50"
onClick={() => {
handleAddDialog(false);
resetForm();
}}
>
<KeenIcon icon="cross" className="text-1.5xl" />
</div>
</div>
</DialogHeader> </DialogHeader>
<DialogBody className="scrollable-y px-0 pb-0" ref={parentRef}> <DialogBody>
<div className="flex flex-col px-0"> <div className="flex flex-col">
{alert.show && ( {alert.show && (
<Alert variant="danger" className="mb-5"> <Alert variant="danger">
{alert.message} <h3>{alert.message}</h3>
</Alert> </Alert>
)} )}
<form action="" onSubmit={handleSubmit}>
<div className="card-body grid-cols-6 gap-5 p-0">
<div className="grid grid-cols-8 gap-2 w-full items-center">
<label className="form-label flex items-center gap-1 col-span-2">
Name<span className="text-red-500">*</span>
</label>
<Input <form onSubmit={handleSubmit}>
className="input col-span-6" <div className="card-body grid gap-5">
type="text" <div className="w-full">
autoComplete="off" <div className="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
value={formField.name} <label className="form-label flex items-center gap-1 max-w-56">
onChange={({ target }) => Municipio Name<span className="text-red-500">*</span>
setFormField((prev) => ({ ...prev, name: target.value })) </label>
} <Input
/> className="input"
type="text"
value={formField.name}
onChange={(e) => setFormField({ ...formField, name: e.target.value })}
/>
</div>
</div> </div>
<div className="flex justify-end pt-2.5 gap-5 col-span-6"> <div className="flex justify-end pt-2.5 gap-5">
<Button variant={'outline'} type="reset" onClick={handleReset}> <Button variant={'outline'} type="reset" onClick={handleReset}>
Reset Reset
</Button> </Button>

View File

@ -43,7 +43,7 @@ const DeleteDialog = () => {
reload(); reload();
const createActivity = { const createActivity = {
module: 'Manage Municipios', module: 'Manage Municipio',
description: `Delete Municipio => ${selectedMunicipios}`, description: `Delete Municipio => ${selectedMunicipios}`,
action: 'D' action: 'D'
}; };

View File

@ -21,7 +21,6 @@ import { doSaveLogActivity } from '@/actions/GlobalActions';
const API_URL = apiConfig.service_master_data; const API_URL = apiConfig.service_master_data;
const EditDialog = () => { const EditDialog = () => {
const parentRef = useRef<any | null>(null);
const { showEditDialog, handleEditDialog, selectedMunicipios, municipios } = const { showEditDialog, handleEditDialog, selectedMunicipios, municipios } =
useManageMunicipiosContext(); useManageMunicipiosContext();
const { reload } = useDataGrid(); const { reload } = useDataGrid();
@ -131,7 +130,7 @@ const EditDialog = () => {
<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">
<DialogHeader> <DialogHeader>
<DialogTitle>Municipios - Update</DialogTitle> <DialogTitle>Municipio - Update</DialogTitle>
<DialogDescription></DialogDescription> <DialogDescription></DialogDescription>
</DialogHeader> </DialogHeader>
<DialogBody> <DialogBody>
@ -147,7 +146,7 @@ const EditDialog = () => {
<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">
Name<span className="text-red-500">*</span> Municipio Name<span className="text-red-500">*</span>
</label> </label>
<Input <Input
className="input" className="input"
@ -158,7 +157,7 @@ const EditDialog = () => {
</div> </div>
</div> </div>
<div className="flex justify-end"> <div className="flex justify-end pt-2.5">
<Button className="btn btn-primary">Save Changes</Button> <Button className="btn btn-primary">Save Changes</Button>
</div> </div>
</div> </div>

View File

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

View File

@ -75,7 +75,6 @@ const ManageMunicipiosProvider = ({ children }: { children: React.ReactNode }) =
const [selectedMunicipios, setSelectedMunicipios] = useState<string | null>(null); const [selectedMunicipios, setSelectedMunicipios] = useState<string | null>(null);
const [municipios, setMunicipios] = useState<MunicipiosProps[]>([]); const [municipios, setMunicipios] = useState<MunicipiosProps[]>([]);
const { GetData } = useCallApi(); const { GetData } = useCallApi();
const navigate = useNavigate();
const handleSearchDialog = useCallback((show: boolean) => { const handleSearchDialog = useCallback((show: boolean) => {
setShowSearchDialog(show); setShowSearchDialog(show);
@ -95,18 +94,13 @@ const ManageMunicipiosProvider = ({ children }: { children: React.ReactNode }) =
setShowDeleteDialog(show); setShowDeleteDialog(show);
}, []); }, []);
const handleNavigate = (path: string) => {
const url = navigate(`${API_URL}/municipios/postoadms/${path}`);
console.log(url);
};
const columns = useMemo<ColumnDef<any>[]>( const columns = useMemo<ColumnDef<any>[]>(
() => [ () => [
{ {
// accessorFn: (row) => row.name, // accessorFn: (row) => row.name,
// id: 'name', // id: 'name',
accessorKey: 'name', accessorKey: 'name',
header: ({ column }) => <DataGridColumnHeader title="Municipios Name" column={column} />, header: ({ column }) => <DataGridColumnHeader title="Municipio Name" column={column} />,
enableSorting: true, enableSorting: true,
enableHiding: false, enableHiding: false,
meta: { meta: {
@ -158,12 +152,6 @@ const ManageMunicipiosProvider = ({ 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);
// const sortedList = response.data.data.list.sort((a: MunicipiosProps, b: MunicipiosProps) => {
// if (a.name < b.name) return -1;
// if (a.name > b.name) return 1;
// return 0;
// });
setMunicipios(response?.data.list); setMunicipios(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) {

View File

@ -72,17 +72,20 @@ const AddDialog = () => {
handleAddDialog(false); handleAddDialog(false);
resetForm(); resetForm();
reload(); reload();
toast.success('Posto Adm created successfully!'); toast.success('Postu Administrativo created successfully!');
const createActivity = { const createActivity = {
module: 'Manage Posto Administrativo', module: 'Manage Posto Administrativo',
description: `Create PostoAdms => ${formField.name}`, description: `Create Postu Administrativo => ${formField.name}`,
action: 'C' action: 'C'
}; };
doSaveLogActivity(createActivity); doSaveLogActivity(createActivity);
} else { } else {
toast.error('Failed to create Posto Adm. Please try again.'); toast.error('Failed to create Postu Administrativo. Please try again.');
setAlert({ show: true, message: 'Failed to create Posto Adm. Please try again.' }); setAlert({
show: true,
message: 'Failed to create Postu Administrativo. Please try again.'
});
} }
}, },
[formField] [formField]
@ -102,7 +105,8 @@ const AddDialog = () => {
// console.log(response?.data); // console.log(response?.data);
setMunicipios(response?.data.list); setMunicipios(response?.data.list);
} catch (error) { } catch (error) {
console.error('Error fetching municipios', error); console.error('Error fetching Municipio', error);
setAlert({ show: true, message: 'Failed to get Municipio. Please try again.' });
} }
}; };
@ -159,7 +163,7 @@ const AddDialog = () => {
<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">
Name<span className="text-red-500">*</span> Postu Administrativo Name<span className="text-red-500">*</span>
</label> </label>
<Input <Input
className="input" className="input"
@ -179,7 +183,7 @@ const AddDialog = () => {
<PopoverTrigger asChild> <PopoverTrigger asChild>
<button type="button" className="input col-span-5 text-left"> <button type="button" className="input col-span-5 text-left">
{municipios.find((municipio) => municipio.id === formField.municipio_id) {municipios.find((municipio) => municipio.id === formField.municipio_id)
?.name || 'Select Municipios'} ?.name || 'Select Municipio'}
</button> </button>
</PopoverTrigger> </PopoverTrigger>
<PopoverContent <PopoverContent
@ -187,7 +191,7 @@ const AddDialog = () => {
onWheel={(e) => e.stopPropagation()} onWheel={(e) => e.stopPropagation()}
> >
<Command> <Command>
<CommandInput placeholder="Search Municipios..." /> <CommandInput placeholder="Search Municipio..." />
<CommandList className="max-h-[300px] overflow-y-auto pointer-events-auto"> <CommandList className="max-h-[300px] overflow-y-auto pointer-events-auto">
<CommandEmpty>No Municipio found.</CommandEmpty> <CommandEmpty>No Municipio found.</CommandEmpty>
<CommandGroup> <CommandGroup>

View File

@ -28,7 +28,7 @@ const DeleteDialog = () => {
const doDeletePostoAdm = useCallback(async () => { const doDeletePostoAdm = useCallback(async () => {
if (!selectedPostoAdms) { if (!selectedPostoAdms) {
toast.error('No Posto Adm selected'); toast.error('No Postu Administrativo selected');
return; return;
} }
@ -39,18 +39,18 @@ const DeleteDialog = () => {
if (response?.status) { if (response?.status) {
setAlert({ show: false, message: '' }); setAlert({ show: false, message: '' });
handleDeleteDialog(false, null); handleDeleteDialog(false, null);
toast.success('Success Delete Posto Adm'); toast.success('Success Delete Postu Administrativo');
reload(); reload();
const createActivity = { const createActivity = {
module: 'Manage Posto Administrativo', module: 'Manage Postu Administrativo',
description: `Delete PostoAdms => ${selectedPostoAdms}`, description: `Delete Postu Administrativo => ${selectedPostoAdms}`,
action: 'D' action: 'D'
}; };
doSaveLogActivity(createActivity); doSaveLogActivity(createActivity);
} else { } else {
setAlert({ show: true, message: response?.message }); setAlert({ show: true, message: response?.message });
toast.error('Failed Delete Posto Adm'); toast.error('Failed Delete Postu Administrativo');
} }
}, [selectedPostoAdms, DeleteData, handleDeleteDialog, reload]); }, [selectedPostoAdms, DeleteData, handleDeleteDialog, reload]);

View File

@ -71,19 +71,22 @@ const EditDialog = () => {
if (response?.status) { if (response?.status) {
handleEditDialog(false, null); handleEditDialog(false, null);
resetForm(); resetForm();
toast.success('Success Update Posto Adm'); toast.success('Success Update Postu Administrativo');
reload(); reload();
const createActivity = { const createActivity = {
module: 'Manage Posto Administrativo', module: 'Manage Postu Administrativo',
description: `Edit PostoAdms => ${selectedPostoAdms}`, description: `Edit Postu Administrativo => ${selectedPostoAdms}`,
action: 'U' action: 'U'
}; };
doSaveLogActivity(createActivity); doSaveLogActivity(createActivity);
} else { } else {
toast.error('Error Update Posto Adm'); toast.error('Error Update Postu Administrativo');
setAlert({ show: true, message: 'Failed to update posto adm. Please try again.' }); setAlert({
show: true,
message: 'Failed to update Postu Administrativo Please try again.'
});
} }
}, },
[selectedPostoAdms, formField] [selectedPostoAdms, formField]
@ -103,7 +106,8 @@ const EditDialog = () => {
// console.log('MUNICIPIOS: ', response?.data); // console.log('MUNICIPIOS: ', response?.data);
setMunicipios(response?.data.list); setMunicipios(response?.data.list);
} catch (error) { } catch (error) {
console.error('Error fetching municipios', error); console.error('Error fetching Municipio', error);
setAlert({ show: true, message: 'Failed to get Municipio. Please try again.' });
} }
}, []); }, []);
@ -169,7 +173,7 @@ const EditDialog = () => {
<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">
<DialogHeader> <DialogHeader>
<DialogTitle>Posto Adm - Update</DialogTitle> <DialogTitle>Postu Administrativo - Update</DialogTitle>
<DialogDescription></DialogDescription> <DialogDescription></DialogDescription>
</DialogHeader> </DialogHeader>
<DialogBody> <DialogBody>
@ -185,7 +189,7 @@ const EditDialog = () => {
<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">
Name<span className="text-red-500">*</span> Postu Administrativo Name<span className="text-red-500">*</span>
</label> </label>
<Input <Input
className="input" className="input"
@ -205,12 +209,12 @@ const EditDialog = () => {
<PopoverTrigger asChild> <PopoverTrigger asChild>
<button type="button" className="input col-span-5 text-left"> <button type="button" className="input col-span-5 text-left">
{municipios.find((municipio) => municipio.id === formField.municipio_id) {municipios.find((municipio) => municipio.id === formField.municipio_id)
?.name || 'Select Municipios'} ?.name || 'Select Municipio'}
</button> </button>
</PopoverTrigger> </PopoverTrigger>
<PopoverContent className="w-[400px] p-0"> <PopoverContent className="w-[400px] p-0">
<Command> <Command>
<CommandInput placeholder="Search Municipios..." /> <CommandInput placeholder="Search Municipio..." />
<CommandList> <CommandList>
<CommandEmpty>No Municipio found.</CommandEmpty> <CommandEmpty>No Municipio found.</CommandEmpty>
<CommandGroup> <CommandGroup>

View File

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

View File

@ -88,7 +88,7 @@ const ManagePostoAdmsContextProvider = ({ children }: { children: React.ReactNod
id: 'name', id: 'name',
// accessorKey: 'PostoAdms_name', // accessorKey: 'PostoAdms_name',
header: ({ column }) => ( header: ({ column }) => (
<DataGridColumnHeader title="Posto Administrativo Name" column={column} /> <DataGridColumnHeader title="Postu Administrativo Name" column={column} />
), ),
enableSorting: true, enableSorting: true,
enableHiding: false, enableHiding: false,
@ -99,7 +99,7 @@ const ManagePostoAdmsContextProvider = ({ children }: { children: React.ReactNod
{ {
accessorFn: (row) => row.municipios_name, accessorFn: (row) => row.municipios_name,
id: 'municipios_name', id: 'municipios_name',
header: ({ column }) => <DataGridColumnHeader title="Municipios Name" column={column} />, header: ({ column }) => <DataGridColumnHeader title="Municipio Name" column={column} />,
enableSorting: false, enableSorting: false,
enableHiding: false, enableHiding: false,
meta: { meta: {

View File

@ -72,7 +72,7 @@ const AddDialog = () => {
toast.success('Sucos created successfully!'); toast.success('Sucos created successfully!');
const createActivity = { const createActivity = {
module: 'Manage Sucos', module: 'Manage Sucos',
description: `Create Suco => ${formField.name}`, description: `Create Sucos => ${formField.name}`,
action: 'C' action: 'C'
}; };
@ -128,7 +128,8 @@ const AddDialog = () => {
// console.log('ini data posto :', response?.data); // console.log('ini data posto :', response?.data);
setPostoadms(response?.data.list || []); setPostoadms(response?.data.list || []);
} catch (error) { } catch (error) {
console.log('Error fetching posto', error); console.log('Error fetching Postu Administrativo', error);
setAlert({ show: true, message: 'Failed to get Posto Administrativo. Please try again.' });
} }
}; };
@ -155,7 +156,7 @@ const AddDialog = () => {
<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">
Name<span className="text-red-500">*</span> Sucos Name<span className="text-red-500">*</span>
</label> </label>
<Input <Input
className="input" className="input"
@ -169,13 +170,13 @@ const AddDialog = () => {
<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">
Posto Adm ID<span className="text-red-500">*</span> Postu Administrativo ID<span className="text-red-500">*</span>
</label> </label>
<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">
{posto_adms.find((posto) => posto.PostoAdms_id === formField.postoId) {posto_adms.find((posto) => posto.PostoAdms_id === formField.postoId)
?.PostoAdms_name || 'Select Posto Administrativo'} ?.PostoAdms_name || 'Select Postu Administrativo'}
</button> </button>
</PopoverTrigger> </PopoverTrigger>
<PopoverContent <PopoverContent
@ -183,9 +184,9 @@ const AddDialog = () => {
onWheel={(e) => e.stopPropagation()} onWheel={(e) => e.stopPropagation()}
> >
<Command> <Command>
<CommandInput placeholder="Search Posto Adms..." /> <CommandInput placeholder="Search Postu Administrativo..." />
<CommandList> <CommandList>
<CommandEmpty>No Posto Adms Found.</CommandEmpty> <CommandEmpty>No Postu Administrativo Found.</CommandEmpty>
<CommandGroup> <CommandGroup>
{posto_adms.map((posto) => ( {posto_adms.map((posto) => (
<CommandItem <CommandItem

View File

@ -25,7 +25,7 @@ const DeleteDialog = () => {
const doDeleteSucos = useCallback(async () => { const doDeleteSucos = useCallback(async () => {
if (!selectedSucos) { if (!selectedSucos) {
toast.error('No sucos selected'); toast.error('No Sucos selected');
return; return;
} }
@ -41,7 +41,7 @@ const DeleteDialog = () => {
reload(); reload();
const createActivity = { const createActivity = {
module: 'Manage Sucos', module: 'Manage Sucos',
description: `Delete Suco => ${selectedSucos}`, description: `Delete Sucos => ${selectedSucos}`,
action: 'D' action: 'D'
}; };

View File

@ -79,7 +79,7 @@ const EditDialog = () => {
reload(); reload();
const createActivity = { const createActivity = {
module: 'Manage Sucos', module: 'Manage Sucos',
description: `Edit Suco => ${selectedSucos}`, description: `Edit Sucos => ${selectedSucos}`,
action: 'U' action: 'U'
}; };
@ -103,10 +103,11 @@ const EditDialog = () => {
order_direction: sorting[0].desc == false ? 'ASC' : 'DESC' order_direction: sorting[0].desc == false ? 'ASC' : 'DESC'
}); });
setPostoadms(response?.data.list);
// console.log('Data Posto Adms:', response?.data.list); // console.log('Data Posto Adms:', response?.data.list);
setPostoadms(response?.data.list);
} catch (error) { } catch (error) {
console.log('Error fetching postoadms', error); console.log('Error fetching Postu Administrativo', error);
setAlert({ show: true, message: 'Failed to get Posto Administrativo. Please try again.' });
} }
}, []); }, []);
@ -118,7 +119,7 @@ const EditDialog = () => {
setFormField((prev) => ({ setFormField((prev) => ({
...prev, ...prev,
name: response.data.name, name: response.data.name,
postoId: response.data.posto.id // Pastikan ini sesuai dengan PostoAdms_id postoId: response.data.posto.id
})); }));
} else { } else {
setFormField((prev) => ({ setFormField((prev) => ({
@ -126,8 +127,6 @@ const EditDialog = () => {
name: '' name: ''
})); }));
} }
console.log('Responnya nih:', response);
console.log('Data Posto nya nih:', response?.data?.posto);
}, []); }, []);
const handleUpdate = (e: React.FormEvent<HTMLFormElement>) => { const handleUpdate = (e: React.FormEvent<HTMLFormElement>) => {
@ -138,7 +137,7 @@ const EditDialog = () => {
return; return;
} }
console.log('Form Field before update:', formField); // Log formField sebelum update // console.log('Form Field before update:', formField);
doUpdateSucos(e); doUpdateSucos(e);
setAlert({ show: false, message: '' }); setAlert({ show: false, message: '' });
}; };
@ -146,14 +145,12 @@ const EditDialog = () => {
useEffect(() => { useEffect(() => {
if (showEditDialog) { if (showEditDialog) {
resetForm(); resetForm();
console.log('Edit Dialog Opened'); // Log ketika dialog dibuka
} }
}, [showEditDialog]); }, [showEditDialog]);
useEffect(() => { useEffect(() => {
if (selectedSucos) { if (selectedSucos) {
doFetchData(selectedSucos); doFetchData(selectedSucos);
console.log('Selected Sucos ID:', selectedSucos); // Log selectedSucos ID
} }
}, [selectedSucos]); }, [selectedSucos]);
@ -164,7 +161,6 @@ const EditDialog = () => {
updated_by: parsedUser?.username, updated_by: parsedUser?.username,
updated_at: formattedTime updated_at: formattedTime
}); });
console.log('Form Field after update:', formField); // Log formField setelah update
} }
}, [formattedTime]); }, [formattedTime]);
@ -172,7 +168,6 @@ const EditDialog = () => {
doFetchPostoAdms([{ id: 'name', desc: false }]); doFetchPostoAdms([{ id: 'name', desc: false }]);
}, []); }, []);
// console.log(selectedSucos);
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">
@ -193,7 +188,7 @@ const EditDialog = () => {
<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">
Name<span className="text-red-500">*</span> Sucos Name<span className="text-red-500">*</span>
</label> </label>
<Input <Input
className="input" className="input"
@ -207,21 +202,21 @@ const EditDialog = () => {
<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">
Posto Administrativo Name Postu Administrativo Name
<span className="text-red-500">*</span> <span className="text-red-500">*</span>
</label> </label>
<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">
{postoadms.find((posto) => posto.PostoAdms_id === formField.postoId) {postoadms.find((posto) => posto.PostoAdms_id === formField.postoId)
?.PostoAdms_name || 'Select Posto Adms'} ?.PostoAdms_name || 'Select Postu Administrativo'}
</button> </button>
</PopoverTrigger> </PopoverTrigger>
<PopoverContent className="w-[400px] p-0"> <PopoverContent className="w-[400px] p-0">
<Command> <Command>
<CommandInput placeholder="Search Posto Adms..." /> <CommandInput placeholder="Search Postu Administrativo..." />
<CommandList> <CommandList>
<CommandEmpty>No Posto Adms Found.</CommandEmpty> <CommandEmpty>No Postu Administrativo Found.</CommandEmpty>
<CommandGroup> <CommandGroup>
{postoadms.map((posto) => ( {postoadms.map((posto) => (
<CommandItem <CommandItem
@ -230,7 +225,7 @@ const EditDialog = () => {
onSelect={() => { onSelect={() => {
setFormField({ setFormField({
...formField, ...formField,
postoId: posto.PostoAdms_id // Gunakan PostoAdms_id postoId: posto.PostoAdms_id
}); });
setOpen(false); setOpen(false);
}} }}

View File

@ -106,7 +106,7 @@ const ManageSucosContextProvider = ({ children }: { children: React.ReactNode })
const value = row.getValue<string>(columnId); const value = row.getValue<string>(columnId);
return String(value).includes(String(filterValue)); return String(value).includes(String(filterValue));
}, },
header: ({ column }) => <DataGridColumnHeader title="Posto Name" column={column} />, header: ({ column }) => <DataGridColumnHeader title="Postu Administrativo Name" column={column} />,
enableSorting: true, enableSorting: true,
enableHiding: false, enableHiding: false,
meta: { meta: {

View File

@ -38,7 +38,8 @@ const ApprovalDialog = () => {
const [formField, setFormField] = useState({ const [formField, setFormField] = useState({
transaction_code: '', transaction_code: '',
status: '' status: '',
notes: ''
}); });
const [alert, setAlert] = useState({ const [alert, setAlert] = useState({
@ -61,8 +62,9 @@ const ApprovalDialog = () => {
} }
const response = await PostData(`${API_URL}/transaction/set-approval`, { const response = await PostData(`${API_URL}/transaction/set-approval`, {
transaction_code: transactionDetails.code, transaction_code: transactionDetails.id,
status: formField.status, status: formField.status,
notes: formField.notes
}); });
if (response?.status) { if (response?.status) {
@ -119,8 +121,8 @@ const ApprovalDialog = () => {
<div className="grow"> <div className="grow">
<Select <Select
value={formField.status} value={formField.status}
onValueChange={(status) => setFormField((prev) => ({ ...prev, status }))} onValueChange={(status) => setFormField((prev) => ({ ...prev, status }))}
> >
<SelectTrigger> <SelectTrigger>
<SelectValue placeholder="Select" /> <SelectValue placeholder="Select" />
@ -132,8 +134,21 @@ const ApprovalDialog = () => {
</Select> </Select>
</div> </div>
</div> </div>
</div>
{formField.status === 'N' && (
<div className="flex items-center flex-wrap gap-2.5 mt-4">
<label className="form-label max-w-56">Notes</label>
<div className="grow">
<textarea
name="notes"
id="notes"
value={formField.notes}
></textarea>
</div>
</div>
)}
</div>
<hr /> <hr />
<div className="flex justify-end"> <div className="flex justify-end">

View File

@ -203,6 +203,7 @@ const ApprovalTransactionProvider = ({ children }: { children: React.ReactNode }
setSelectedTransactionIdForApproval(row.id); setSelectedTransactionIdForApproval(row.id);
setShowApprovalDialog(true); setShowApprovalDialog(true);
}} }}
disabled={row.status_approve === 'Y' || row.status_approve === 'N'}
> >
<KeenIcon icon="notepad-edit" /> <KeenIcon icon="notepad-edit" />
</button> </button>