update title
This commit is contained in:
@ -9,11 +9,11 @@ const AldeiasMaster = () => {
|
||||
return (
|
||||
<>
|
||||
<Helmet>
|
||||
<title>TPAY | Manage Aldeias</title>
|
||||
<title>TPAY | Manage Aldeia</title>
|
||||
</Helmet>
|
||||
<ManageAldeiasContextProvider>
|
||||
<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 }}>
|
||||
<Link underline="none" color="inherit" href="/">
|
||||
<span className="text-sm hover:underline">Dashboard</span>
|
||||
@ -24,7 +24,7 @@ const AldeiasMaster = () => {
|
||||
</Link>
|
||||
|
||||
<Link underline="none" color="inherit">
|
||||
<span className="text-sm">Manage Aldeias</span>
|
||||
<span className="text-sm">Manage Aldeia</span>
|
||||
</Link>
|
||||
</Breadcrumbs>
|
||||
|
||||
|
||||
@ -69,18 +69,18 @@ const AddDialog = () => {
|
||||
if (response?.status) {
|
||||
resetForm();
|
||||
handleAddDialog(false);
|
||||
toast.success('Success Create Aldeias');
|
||||
toast.success('Success Create Aldeia');
|
||||
reload();
|
||||
const createActivity = {
|
||||
module: 'Manage Aldeias',
|
||||
module: 'Manage Aldeia',
|
||||
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.' });
|
||||
toast.error('Error Create Aldeia');
|
||||
setAlert({ show: true, message: 'Failed to create Aldeia. Please try again.' });
|
||||
}
|
||||
},
|
||||
[formField]
|
||||
@ -100,7 +100,8 @@ const AddDialog = () => {
|
||||
// console.log('SUCOS', response?.data);
|
||||
setSucos(response?.data.list);
|
||||
} 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)}>
|
||||
<DialogContent className="container-fixed max-w-[768px] flex flex-col p-5 overflow-hidden">
|
||||
<DialogHeader>
|
||||
<DialogTitle>Aldeias - Create</DialogTitle>
|
||||
<DialogTitle>Aldeia - Create</DialogTitle>
|
||||
<DialogDescription></DialogDescription>
|
||||
</DialogHeader>
|
||||
<DialogBody ref={parentRef}>
|
||||
@ -157,7 +158,7 @@ const AddDialog = () => {
|
||||
<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">
|
||||
Name<span className="text-red-500">*</span>
|
||||
Aldeia Name<span className="text-red-500">*</span>
|
||||
</label>
|
||||
<Input
|
||||
className="input"
|
||||
@ -175,10 +176,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' }}
|
||||
>
|
||||
{sucos.find((suco) => suco.sucos_id === formField.sucosId)?.sucos_name ||
|
||||
'Select Sucos'}
|
||||
</button>
|
||||
|
||||
@ -32,11 +32,11 @@ const DeleteDialog = () => {
|
||||
if (response?.status) {
|
||||
setAlert({ show: false, message: '' });
|
||||
handleDeleteDialog(false, null);
|
||||
toast.success('Success Delete Aldeias');
|
||||
toast.success('Success Delete Aldeia');
|
||||
reload();
|
||||
|
||||
const createActivity = {
|
||||
module: 'Manage Aldeias',
|
||||
module: 'Manage Aldeia',
|
||||
description: `Delete Aldeia => ${selectedAldeias}`,
|
||||
action: 'D'
|
||||
};
|
||||
@ -44,7 +44,7 @@ const DeleteDialog = () => {
|
||||
doSaveLogActivity(createActivity);
|
||||
} else {
|
||||
setAlert({ show: true, message: response?.message });
|
||||
toast.error('Failed Delete Aldeias');
|
||||
toast.error('Failed Delete Aldeia');
|
||||
}
|
||||
}, [selectedAldeias, DeleteData, handleDeleteDialog, reload]);
|
||||
|
||||
|
||||
@ -68,18 +68,18 @@ const EditDialog = () => {
|
||||
if (response?.status) {
|
||||
resetForm();
|
||||
handleEditDialog(false, null);
|
||||
toast.success('Success Update Aldeias');
|
||||
toast.success('Success Update Aldeia');
|
||||
reload();
|
||||
const createActivity = {
|
||||
module: 'Manage Aldeias',
|
||||
module: 'Manage Aldeia',
|
||||
description: `Edit Aldeia => ${selectedAldeias}`,
|
||||
action: 'U'
|
||||
};
|
||||
|
||||
doSaveLogActivity(createActivity);
|
||||
} else {
|
||||
toast.error('Error Update Aldeias');
|
||||
setAlert({ show: true, message: 'Error Update Aldeias' });
|
||||
toast.error('Error Update Aldeia');
|
||||
setAlert({ show: true, message: 'Error Update Aldeia' });
|
||||
}
|
||||
},
|
||||
[selectedAldeias, formField]
|
||||
@ -99,7 +99,8 @@ const EditDialog = () => {
|
||||
// console.log('SUCOS', response?.data);
|
||||
setSucos(response?.data.list);
|
||||
} 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)}>
|
||||
<DialogContent className="container-fixed max-w-[768px] flex flex-col p-5 overflow-hidden">
|
||||
<DialogHeader>
|
||||
<DialogTitle>Aldeias - Update</DialogTitle>
|
||||
<DialogTitle>Aldeia - Update</DialogTitle>
|
||||
<DialogDescription></DialogDescription>
|
||||
</DialogHeader>
|
||||
<DialogBody>
|
||||
@ -180,7 +181,7 @@ const EditDialog = () => {
|
||||
<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">
|
||||
Name<span className="text-red-500">*</span>
|
||||
Aldeia Name<span className="text-red-500">*</span>
|
||||
</label>
|
||||
<Input
|
||||
className="input"
|
||||
|
||||
@ -15,7 +15,7 @@ const ListToolbar = () => {
|
||||
<KeenIcon icon="magnifier" />
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Search Aldeias"
|
||||
placeholder="Search Aldeia"
|
||||
value={(table.getColumn('name')?.getFilterValue() as string) ?? ''}
|
||||
onChange={(event) => table.getColumn('name')?.setFilterValue(event.target.value)}
|
||||
/>
|
||||
|
||||
@ -80,7 +80,7 @@ const ManageAldeiasContextProvider = ({ children }: { children: React.ReactNode
|
||||
{
|
||||
accessorFn: (row) => row.name,
|
||||
id: 'name',
|
||||
header: ({ column }) => <DataGridColumnHeader title="Name" column={column} />,
|
||||
header: ({ column }) => <DataGridColumnHeader title="Aldeia Name" column={column} />,
|
||||
enableSorting: true,
|
||||
enableHiding: false,
|
||||
meta: {
|
||||
@ -90,7 +90,7 @@ const ManageAldeiasContextProvider = ({ children }: { children: React.ReactNode
|
||||
{
|
||||
accessorFn: (row) => row.sucos.name,
|
||||
id: 'sucos_name',
|
||||
header: ({ column }) => <DataGridColumnHeader title="Sucos" column={column} />,
|
||||
header: ({ column }) => <DataGridColumnHeader title="Sucos Name" column={column} />,
|
||||
enableSorting: true,
|
||||
enableHiding: false,
|
||||
meta: {
|
||||
|
||||
@ -11,11 +11,11 @@ const Municipios = () => {
|
||||
return (
|
||||
<>
|
||||
<Helmet>
|
||||
<title>TPAY | Municipios</title>
|
||||
<title>TPAY | Municipio</title>
|
||||
</Helmet>
|
||||
<ManageMunicipiosProvider>
|
||||
<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 }}>
|
||||
<Link underline="none" color="inherit" href="/">
|
||||
<span className="text-sm hover:underline">Dashboard</span>
|
||||
@ -26,7 +26,7 @@ const Municipios = () => {
|
||||
</Link>
|
||||
|
||||
<Link underline="none" color="inherit">
|
||||
<span className="text-sm">Manage Municipios</span>
|
||||
<span className="text-sm">Manage Municipio</span>
|
||||
</Link>
|
||||
</Breadcrumbs>
|
||||
<div className="grid gap-5 lg:gap-7.5">
|
||||
|
||||
@ -56,7 +56,7 @@ const AddDialog = () => {
|
||||
reload();
|
||||
toast.success('Municipio created successfully!');
|
||||
const createActivity = {
|
||||
module: 'Manage Municipios',
|
||||
module: 'Manage Municipio',
|
||||
description: `Create Municipio => ${formField.name}`,
|
||||
action: 'C'
|
||||
};
|
||||
@ -107,52 +107,36 @@ const AddDialog = () => {
|
||||
|
||||
return (
|
||||
<Dialog open={showAddDialog} onOpenChange={(open) => handleAddDialog(open)}>
|
||||
<DialogContent className="container-fixed max-w-96 flex flex-col p-5 overflow-hidden [&>button]:hidden">
|
||||
<DialogTitle></DialogTitle>
|
||||
<DialogDescription></DialogDescription>
|
||||
<DialogHeader className="p-2 border-0">
|
||||
<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>
|
||||
<DialogContent className="container-fixed max-w-[768px] flex flex-col p-5 overflow-hidden">
|
||||
<DialogHeader>
|
||||
<DialogTitle>Municipio - Create</DialogTitle>
|
||||
<DialogDescription></DialogDescription>
|
||||
</DialogHeader>
|
||||
<DialogBody className="scrollable-y px-0 pb-0" ref={parentRef}>
|
||||
<div className="flex flex-col px-0">
|
||||
<DialogBody>
|
||||
<div className="flex flex-col">
|
||||
{alert.show && (
|
||||
<Alert variant="danger" className="mb-5">
|
||||
{alert.message}
|
||||
<Alert variant="danger">
|
||||
<h3>{alert.message}</h3>
|
||||
</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
|
||||
className="input col-span-6"
|
||||
type="text"
|
||||
autoComplete="off"
|
||||
value={formField.name}
|
||||
onChange={({ target }) =>
|
||||
setFormField((prev) => ({ ...prev, name: target.value }))
|
||||
}
|
||||
/>
|
||||
<form onSubmit={handleSubmit}>
|
||||
<div className="card-body grid gap-5">
|
||||
<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">
|
||||
Municipio Name<span className="text-red-500">*</span>
|
||||
</label>
|
||||
<Input
|
||||
className="input"
|
||||
type="text"
|
||||
value={formField.name}
|
||||
onChange={(e) => setFormField({ ...formField, name: e.target.value })}
|
||||
/>
|
||||
</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}>
|
||||
Reset
|
||||
</Button>
|
||||
|
||||
@ -43,7 +43,7 @@ const DeleteDialog = () => {
|
||||
reload();
|
||||
|
||||
const createActivity = {
|
||||
module: 'Manage Municipios',
|
||||
module: 'Manage Municipio',
|
||||
description: `Delete Municipio => ${selectedMunicipios}`,
|
||||
action: 'D'
|
||||
};
|
||||
|
||||
@ -21,7 +21,6 @@ import { doSaveLogActivity } from '@/actions/GlobalActions';
|
||||
const API_URL = apiConfig.service_master_data;
|
||||
|
||||
const EditDialog = () => {
|
||||
const parentRef = useRef<any | null>(null);
|
||||
const { showEditDialog, handleEditDialog, selectedMunicipios, municipios } =
|
||||
useManageMunicipiosContext();
|
||||
const { reload } = useDataGrid();
|
||||
@ -131,7 +130,7 @@ const EditDialog = () => {
|
||||
<Dialog open={showEditDialog} onOpenChange={(open) => handleEditDialog(open, null)}>
|
||||
<DialogContent className="container-fixed max-w-[768px] flex flex-col p-5 overflow-hidden">
|
||||
<DialogHeader>
|
||||
<DialogTitle>Municipios - Update</DialogTitle>
|
||||
<DialogTitle>Municipio - Update</DialogTitle>
|
||||
<DialogDescription></DialogDescription>
|
||||
</DialogHeader>
|
||||
<DialogBody>
|
||||
@ -147,7 +146,7 @@ const EditDialog = () => {
|
||||
<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">
|
||||
Name<span className="text-red-500">*</span>
|
||||
Municipio Name<span className="text-red-500">*</span>
|
||||
</label>
|
||||
<Input
|
||||
className="input"
|
||||
@ -158,7 +157,7 @@ const EditDialog = () => {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex justify-end">
|
||||
<div className="flex justify-end pt-2.5">
|
||||
<Button className="btn btn-primary">Save Changes</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -28,7 +28,7 @@ const ListToolbar = () => {
|
||||
<KeenIcon icon="magnifier" />
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Search Municipios"
|
||||
placeholder="Search Municipio"
|
||||
value={(table.getColumn('name')?.getFilterValue() as string) ?? ''}
|
||||
onChange={(event) => table.getColumn('name')?.setFilterValue(event.target.value)}
|
||||
/>
|
||||
|
||||
@ -75,7 +75,6 @@ const ManageMunicipiosProvider = ({ children }: { children: React.ReactNode }) =
|
||||
const [selectedMunicipios, setSelectedMunicipios] = useState<string | null>(null);
|
||||
const [municipios, setMunicipios] = useState<MunicipiosProps[]>([]);
|
||||
const { GetData } = useCallApi();
|
||||
const navigate = useNavigate();
|
||||
|
||||
const handleSearchDialog = useCallback((show: boolean) => {
|
||||
setShowSearchDialog(show);
|
||||
@ -95,18 +94,13 @@ const ManageMunicipiosProvider = ({ children }: { children: React.ReactNode }) =
|
||||
setShowDeleteDialog(show);
|
||||
}, []);
|
||||
|
||||
const handleNavigate = (path: string) => {
|
||||
const url = navigate(`${API_URL}/municipios/postoadms/${path}`);
|
||||
console.log(url);
|
||||
};
|
||||
|
||||
const columns = useMemo<ColumnDef<any>[]>(
|
||||
() => [
|
||||
{
|
||||
// accessorFn: (row) => row.name,
|
||||
// id: 'name',
|
||||
accessorKey: 'name',
|
||||
header: ({ column }) => <DataGridColumnHeader title="Municipios Name" column={column} />,
|
||||
header: ({ column }) => <DataGridColumnHeader title="Municipio Name" column={column} />,
|
||||
enableSorting: true,
|
||||
enableHiding: false,
|
||||
meta: {
|
||||
@ -158,12 +152,6 @@ const ManageMunicipiosProvider = ({ children }: { children: React.ReactNode }) =
|
||||
order_direction: sorting[0].desc == false ? 'ASC' : 'DESC',
|
||||
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);
|
||||
return { data: response?.data.list, totalCount: response?.data.total_count };
|
||||
} catch (error) {
|
||||
|
||||
@ -72,17 +72,20 @@ const AddDialog = () => {
|
||||
handleAddDialog(false);
|
||||
resetForm();
|
||||
reload();
|
||||
toast.success('Posto Adm created successfully!');
|
||||
toast.success('Postu Administrativo created successfully!');
|
||||
const createActivity = {
|
||||
module: 'Manage Posto Administrativo',
|
||||
description: `Create PostoAdms => ${formField.name}`,
|
||||
description: `Create Postu Administrativo => ${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.' });
|
||||
toast.error('Failed to create Postu Administrativo. Please try again.');
|
||||
setAlert({
|
||||
show: true,
|
||||
message: 'Failed to create Postu Administrativo. Please try again.'
|
||||
});
|
||||
}
|
||||
},
|
||||
[formField]
|
||||
@ -102,7 +105,8 @@ const AddDialog = () => {
|
||||
// console.log(response?.data);
|
||||
setMunicipios(response?.data.list);
|
||||
} 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="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<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>
|
||||
<Input
|
||||
className="input"
|
||||
@ -179,7 +183,7 @@ const AddDialog = () => {
|
||||
<PopoverTrigger asChild>
|
||||
<button type="button" className="input col-span-5 text-left">
|
||||
{municipios.find((municipio) => municipio.id === formField.municipio_id)
|
||||
?.name || 'Select Municipios'}
|
||||
?.name || 'Select Municipio'}
|
||||
</button>
|
||||
</PopoverTrigger>
|
||||
<PopoverContent
|
||||
@ -187,7 +191,7 @@ const AddDialog = () => {
|
||||
onWheel={(e) => e.stopPropagation()}
|
||||
>
|
||||
<Command>
|
||||
<CommandInput placeholder="Search Municipios..." />
|
||||
<CommandInput placeholder="Search Municipio..." />
|
||||
<CommandList className="max-h-[300px] overflow-y-auto pointer-events-auto">
|
||||
<CommandEmpty>No Municipio found.</CommandEmpty>
|
||||
<CommandGroup>
|
||||
|
||||
@ -28,7 +28,7 @@ const DeleteDialog = () => {
|
||||
|
||||
const doDeletePostoAdm = useCallback(async () => {
|
||||
if (!selectedPostoAdms) {
|
||||
toast.error('No Posto Adm selected');
|
||||
toast.error('No Postu Administrativo selected');
|
||||
return;
|
||||
}
|
||||
|
||||
@ -39,18 +39,18 @@ const DeleteDialog = () => {
|
||||
if (response?.status) {
|
||||
setAlert({ show: false, message: '' });
|
||||
handleDeleteDialog(false, null);
|
||||
toast.success('Success Delete Posto Adm');
|
||||
toast.success('Success Delete Postu Administrativo');
|
||||
reload();
|
||||
const createActivity = {
|
||||
module: 'Manage Posto Administrativo',
|
||||
description: `Delete PostoAdms => ${selectedPostoAdms}`,
|
||||
module: 'Manage Postu Administrativo',
|
||||
description: `Delete Postu Administrativo => ${selectedPostoAdms}`,
|
||||
action: 'D'
|
||||
};
|
||||
|
||||
doSaveLogActivity(createActivity);
|
||||
} else {
|
||||
setAlert({ show: true, message: response?.message });
|
||||
toast.error('Failed Delete Posto Adm');
|
||||
toast.error('Failed Delete Postu Administrativo');
|
||||
}
|
||||
}, [selectedPostoAdms, DeleteData, handleDeleteDialog, reload]);
|
||||
|
||||
|
||||
@ -71,19 +71,22 @@ const EditDialog = () => {
|
||||
if (response?.status) {
|
||||
handleEditDialog(false, null);
|
||||
resetForm();
|
||||
toast.success('Success Update Posto Adm');
|
||||
toast.success('Success Update Postu Administrativo');
|
||||
reload();
|
||||
|
||||
const createActivity = {
|
||||
module: 'Manage Posto Administrativo',
|
||||
description: `Edit PostoAdms => ${selectedPostoAdms}`,
|
||||
module: 'Manage Postu Administrativo',
|
||||
description: `Edit Postu Administrativo => ${selectedPostoAdms}`,
|
||||
action: 'U'
|
||||
};
|
||||
|
||||
doSaveLogActivity(createActivity);
|
||||
} else {
|
||||
toast.error('Error Update Posto Adm');
|
||||
setAlert({ show: true, message: 'Failed to update posto adm. Please try again.' });
|
||||
toast.error('Error Update Postu Administrativo');
|
||||
setAlert({
|
||||
show: true,
|
||||
message: 'Failed to update Postu Administrativo Please try again.'
|
||||
});
|
||||
}
|
||||
},
|
||||
[selectedPostoAdms, formField]
|
||||
@ -103,7 +106,8 @@ const EditDialog = () => {
|
||||
// console.log('MUNICIPIOS: ', response?.data);
|
||||
setMunicipios(response?.data.list);
|
||||
} 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)}>
|
||||
<DialogContent className="container-fixed max-w-[768px] flex flex-col p-5 overflow-hidden">
|
||||
<DialogHeader>
|
||||
<DialogTitle>Posto Adm - Update</DialogTitle>
|
||||
<DialogTitle>Postu Administrativo - Update</DialogTitle>
|
||||
<DialogDescription></DialogDescription>
|
||||
</DialogHeader>
|
||||
<DialogBody>
|
||||
@ -185,7 +189,7 @@ const EditDialog = () => {
|
||||
<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">
|
||||
Name<span className="text-red-500">*</span>
|
||||
Postu Administrativo Name<span className="text-red-500">*</span>
|
||||
</label>
|
||||
<Input
|
||||
className="input"
|
||||
@ -205,12 +209,12 @@ const EditDialog = () => {
|
||||
<PopoverTrigger asChild>
|
||||
<button type="button" className="input col-span-5 text-left">
|
||||
{municipios.find((municipio) => municipio.id === formField.municipio_id)
|
||||
?.name || 'Select Municipios'}
|
||||
?.name || 'Select Municipio'}
|
||||
</button>
|
||||
</PopoverTrigger>
|
||||
<PopoverContent className="w-[400px] p-0">
|
||||
<Command>
|
||||
<CommandInput placeholder="Search Municipios..." />
|
||||
<CommandInput placeholder="Search Municipio..." />
|
||||
<CommandList>
|
||||
<CommandEmpty>No Municipio found.</CommandEmpty>
|
||||
<CommandGroup>
|
||||
|
||||
@ -16,7 +16,7 @@ const ListToolbar = () => {
|
||||
<KeenIcon icon="magnifier" />
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Search Postu"
|
||||
placeholder="Search Postu Administrativo"
|
||||
value={(table.getColumn('name')?.getFilterValue() as string) ?? ''}
|
||||
onChange={(event) => table.getColumn('name')?.setFilterValue(event.target.value)}
|
||||
/>
|
||||
|
||||
@ -88,7 +88,7 @@ const ManagePostoAdmsContextProvider = ({ children }: { children: React.ReactNod
|
||||
id: 'name',
|
||||
// accessorKey: 'PostoAdms_name',
|
||||
header: ({ column }) => (
|
||||
<DataGridColumnHeader title="Posto Administrativo Name" column={column} />
|
||||
<DataGridColumnHeader title="Postu Administrativo Name" column={column} />
|
||||
),
|
||||
enableSorting: true,
|
||||
enableHiding: false,
|
||||
@ -99,7 +99,7 @@ const ManagePostoAdmsContextProvider = ({ children }: { children: React.ReactNod
|
||||
{
|
||||
accessorFn: (row) => row.municipios_name,
|
||||
id: 'municipios_name',
|
||||
header: ({ column }) => <DataGridColumnHeader title="Municipios Name" column={column} />,
|
||||
header: ({ column }) => <DataGridColumnHeader title="Municipio Name" column={column} />,
|
||||
enableSorting: false,
|
||||
enableHiding: false,
|
||||
meta: {
|
||||
|
||||
@ -72,7 +72,7 @@ const AddDialog = () => {
|
||||
toast.success('Sucos created successfully!');
|
||||
const createActivity = {
|
||||
module: 'Manage Sucos',
|
||||
description: `Create Suco => ${formField.name}`,
|
||||
description: `Create Sucos => ${formField.name}`,
|
||||
action: 'C'
|
||||
};
|
||||
|
||||
@ -128,7 +128,8 @@ const AddDialog = () => {
|
||||
// console.log('ini data posto :', response?.data);
|
||||
setPostoadms(response?.data.list || []);
|
||||
} 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="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<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>
|
||||
<Input
|
||||
className="input"
|
||||
@ -169,13 +170,13 @@ const AddDialog = () => {
|
||||
<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">
|
||||
Posto Adm ID<span className="text-red-500">*</span>
|
||||
Postu Administrativo ID<span className="text-red-500">*</span>
|
||||
</label>
|
||||
<Popover open={open} onOpenChange={setOpen}>
|
||||
<PopoverTrigger asChild>
|
||||
<button type="button" className="input col-span-5 text-left">
|
||||
{posto_adms.find((posto) => posto.PostoAdms_id === formField.postoId)
|
||||
?.PostoAdms_name || 'Select Posto Administrativo'}
|
||||
?.PostoAdms_name || 'Select Postu Administrativo'}
|
||||
</button>
|
||||
</PopoverTrigger>
|
||||
<PopoverContent
|
||||
@ -183,9 +184,9 @@ const AddDialog = () => {
|
||||
onWheel={(e) => e.stopPropagation()}
|
||||
>
|
||||
<Command>
|
||||
<CommandInput placeholder="Search Posto Adms..." />
|
||||
<CommandInput placeholder="Search Postu Administrativo..." />
|
||||
<CommandList>
|
||||
<CommandEmpty>No Posto Adms Found.</CommandEmpty>
|
||||
<CommandEmpty>No Postu Administrativo Found.</CommandEmpty>
|
||||
<CommandGroup>
|
||||
{posto_adms.map((posto) => (
|
||||
<CommandItem
|
||||
|
||||
@ -25,7 +25,7 @@ const DeleteDialog = () => {
|
||||
|
||||
const doDeleteSucos = useCallback(async () => {
|
||||
if (!selectedSucos) {
|
||||
toast.error('No sucos selected');
|
||||
toast.error('No Sucos selected');
|
||||
return;
|
||||
}
|
||||
|
||||
@ -41,7 +41,7 @@ const DeleteDialog = () => {
|
||||
reload();
|
||||
const createActivity = {
|
||||
module: 'Manage Sucos',
|
||||
description: `Delete Suco => ${selectedSucos}`,
|
||||
description: `Delete Sucos => ${selectedSucos}`,
|
||||
action: 'D'
|
||||
};
|
||||
|
||||
|
||||
@ -79,7 +79,7 @@ const EditDialog = () => {
|
||||
reload();
|
||||
const createActivity = {
|
||||
module: 'Manage Sucos',
|
||||
description: `Edit Suco => ${selectedSucos}`,
|
||||
description: `Edit Sucos => ${selectedSucos}`,
|
||||
action: 'U'
|
||||
};
|
||||
|
||||
@ -103,10 +103,11 @@ const EditDialog = () => {
|
||||
order_direction: sorting[0].desc == false ? 'ASC' : 'DESC'
|
||||
});
|
||||
|
||||
setPostoadms(response?.data.list);
|
||||
// console.log('Data Posto Adms:', response?.data.list);
|
||||
setPostoadms(response?.data.list);
|
||||
} 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) => ({
|
||||
...prev,
|
||||
name: response.data.name,
|
||||
postoId: response.data.posto.id // Pastikan ini sesuai dengan PostoAdms_id
|
||||
postoId: response.data.posto.id
|
||||
}));
|
||||
} else {
|
||||
setFormField((prev) => ({
|
||||
@ -126,8 +127,6 @@ const EditDialog = () => {
|
||||
name: ''
|
||||
}));
|
||||
}
|
||||
console.log('Responnya nih:', response);
|
||||
console.log('Data Posto nya nih:', response?.data?.posto);
|
||||
}, []);
|
||||
|
||||
const handleUpdate = (e: React.FormEvent<HTMLFormElement>) => {
|
||||
@ -138,7 +137,7 @@ const EditDialog = () => {
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('Form Field before update:', formField); // Log formField sebelum update
|
||||
// console.log('Form Field before update:', formField);
|
||||
doUpdateSucos(e);
|
||||
setAlert({ show: false, message: '' });
|
||||
};
|
||||
@ -146,14 +145,12 @@ const EditDialog = () => {
|
||||
useEffect(() => {
|
||||
if (showEditDialog) {
|
||||
resetForm();
|
||||
console.log('Edit Dialog Opened'); // Log ketika dialog dibuka
|
||||
}
|
||||
}, [showEditDialog]);
|
||||
|
||||
useEffect(() => {
|
||||
if (selectedSucos) {
|
||||
doFetchData(selectedSucos);
|
||||
console.log('Selected Sucos ID:', selectedSucos); // Log selectedSucos ID
|
||||
}
|
||||
}, [selectedSucos]);
|
||||
|
||||
@ -164,7 +161,6 @@ const EditDialog = () => {
|
||||
updated_by: parsedUser?.username,
|
||||
updated_at: formattedTime
|
||||
});
|
||||
console.log('Form Field after update:', formField); // Log formField setelah update
|
||||
}
|
||||
}, [formattedTime]);
|
||||
|
||||
@ -172,7 +168,6 @@ const EditDialog = () => {
|
||||
doFetchPostoAdms([{ id: 'name', desc: false }]);
|
||||
}, []);
|
||||
|
||||
// console.log(selectedSucos);
|
||||
return (
|
||||
<Dialog open={showEditDialog} onOpenChange={(open) => handleEditDialog(open, null)}>
|
||||
<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="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<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>
|
||||
<Input
|
||||
className="input"
|
||||
@ -207,21 +202,21 @@ const EditDialog = () => {
|
||||
<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">
|
||||
Posto Administrativo Name
|
||||
Postu Administrativo Name
|
||||
<span className="text-red-500">*</span>
|
||||
</label>
|
||||
<Popover open={open} onOpenChange={setOpen}>
|
||||
<PopoverTrigger asChild>
|
||||
<button type="button" className="input col-span-5 text-left">
|
||||
{postoadms.find((posto) => posto.PostoAdms_id === formField.postoId)
|
||||
?.PostoAdms_name || 'Select Posto Adms'}
|
||||
?.PostoAdms_name || 'Select Postu Administrativo'}
|
||||
</button>
|
||||
</PopoverTrigger>
|
||||
<PopoverContent className="w-[400px] p-0">
|
||||
<Command>
|
||||
<CommandInput placeholder="Search Posto Adms..." />
|
||||
<CommandInput placeholder="Search Postu Administrativo..." />
|
||||
<CommandList>
|
||||
<CommandEmpty>No Posto Adms Found.</CommandEmpty>
|
||||
<CommandEmpty>No Postu Administrativo Found.</CommandEmpty>
|
||||
<CommandGroup>
|
||||
{postoadms.map((posto) => (
|
||||
<CommandItem
|
||||
@ -230,7 +225,7 @@ const EditDialog = () => {
|
||||
onSelect={() => {
|
||||
setFormField({
|
||||
...formField,
|
||||
postoId: posto.PostoAdms_id // Gunakan PostoAdms_id
|
||||
postoId: posto.PostoAdms_id
|
||||
});
|
||||
setOpen(false);
|
||||
}}
|
||||
|
||||
@ -106,7 +106,7 @@ const ManageSucosContextProvider = ({ children }: { children: React.ReactNode })
|
||||
const value = row.getValue<string>(columnId);
|
||||
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,
|
||||
enableHiding: false,
|
||||
meta: {
|
||||
|
||||
Reference in New Issue
Block a user