diff --git a/src/pages/master/aldeias/AldeiasMaster.tsx b/src/pages/master/aldeias/AldeiasMaster.tsx index 7ec7c77..3ebb197 100644 --- a/src/pages/master/aldeias/AldeiasMaster.tsx +++ b/src/pages/master/aldeias/AldeiasMaster.tsx @@ -3,12 +3,27 @@ import { ManageAldeiasContextProvider } from './hooks/ManageAldeiasContext'; import AddDialog from './blocks/AddDialog'; import EditDialog from './blocks/EditDialog'; import DeleteDialog from './blocks/DeleteDialog'; +import { Breadcrumbs, Link } from '@mui/material'; const AldeiasMaster = () => { return ( -

Aldeias

+

Aldeias

+ + + Dashboard + + + + Master Data + + + + Manage Aldeias + + +
diff --git a/src/pages/master/municipios/Municipios.tsx b/src/pages/master/municipios/Municipios.tsx index 820900c..fd0f24c 100644 --- a/src/pages/master/municipios/Municipios.tsx +++ b/src/pages/master/municipios/Municipios.tsx @@ -4,12 +4,26 @@ import AddDialog from './blocks/AddDialog'; import SearchDialog from './blocks/SearchDialog'; import EditDialog from './blocks/EditDialog'; import DeleteDialog from './blocks/DeleteDialog'; +import { Breadcrumbs, Link } from '@mui/material'; const Municipios = () => { return (

MUNICIPIOS

+ + + Dashboard + + + + Master Data + + + + Manage Municipios + +
diff --git a/src/pages/master/postoadms/PostoAdmsMaster.tsx b/src/pages/master/postoadms/PostoAdmsMaster.tsx index 3ff1138..886c856 100644 --- a/src/pages/master/postoadms/PostoAdmsMaster.tsx +++ b/src/pages/master/postoadms/PostoAdmsMaster.tsx @@ -4,6 +4,7 @@ import EditDialog from './blocks/EditDialog'; import SearchDialog from './blocks/SearchDialog'; import { ManagePostoAdmsContextProvider } from './hooks/ManagePostoAdmsContext'; import { Container, DataGridInner } from '@/components'; +import { Breadcrumbs, Link } from '@mui/material'; const PostoAdmsMaster = () => { return ( @@ -12,6 +13,19 @@ const PostoAdmsMaster = () => {

Postu Administrativo

+ + + Dashboard + + + + Master Data + + + + Manage Postu Administrativo + +
diff --git a/src/pages/master/products/ProductsMaster.tsx b/src/pages/master/products/ProductsMaster.tsx index 49f5eee..a75f02c 100644 --- a/src/pages/master/products/ProductsMaster.tsx +++ b/src/pages/master/products/ProductsMaster.tsx @@ -3,12 +3,26 @@ import { ManageProductsContextProvider } from './hooks/ManageProductsContext'; import AddDialog from './blocks/AddDialog'; import EditDialog from './blocks/EditDialog'; import DeleteDialog from './blocks/DeleteDialog'; +import { Breadcrumbs, Link } from '@mui/material'; const ProductsMaster = () => { return (

Manage Products

+ + + Dashboard + + + + Master Data + + + + Manage Products + +
diff --git a/src/pages/master/profession/ProfessionMaster.tsx b/src/pages/master/profession/ProfessionMaster.tsx index 5f43e43..2507d2d 100644 --- a/src/pages/master/profession/ProfessionMaster.tsx +++ b/src/pages/master/profession/ProfessionMaster.tsx @@ -3,12 +3,26 @@ import { ManageProfessionContextProvider } from './hooks/ManageProfessionContext import AddDialog from './blocks/AddDialog'; import EditDialog from './blocks/EditDialog'; import DeleteDialog from './blocks/DeleteDialog'; +import { Breadcrumbs, Link } from '@mui/material'; const ProfessionMaster = () => { return (

Manage Profession

+ + + Dashboard + + + + Master Data + + + + Manage Profession + +
diff --git a/src/pages/master/provider/ProviderMaster.tsx b/src/pages/master/provider/ProviderMaster.tsx index a073e82..03ed47c 100644 --- a/src/pages/master/provider/ProviderMaster.tsx +++ b/src/pages/master/provider/ProviderMaster.tsx @@ -3,12 +3,26 @@ import { ManageProviderContextProvider } from './hooks/ManageProviderContext'; import AddDialog from './blocks/AddDialog'; import EditDialog from './blocks/EditDialog'; import DeleteDialog from './blocks/DeleteDialog'; +import { Breadcrumbs, Link } from '@mui/material'; const ProviderMaster = () => { return (

Manage Provider

+ + + Dashboard + + + + Master Data + + + + Manage Provider + +
diff --git a/src/pages/master/sucos/SucosMaster.tsx b/src/pages/master/sucos/SucosMaster.tsx index 15043dc..ac7b7e5 100644 --- a/src/pages/master/sucos/SucosMaster.tsx +++ b/src/pages/master/sucos/SucosMaster.tsx @@ -4,15 +4,31 @@ import AddDialog from './blocks/AddDialog'; import EditDialog from './blocks/EditDialog'; import DeleteDialog from './blocks/DeleteDialog'; import SearchDialog from './blocks/SearchDialog'; +import { Breadcrumbs, Link } from '@mui/material'; const SucosMaster = () => { return ( -

Sucos

+

Sucos

+ + + Dashboard + + + + Master Data + + + + Manage Sucos + + +
+ diff --git a/src/pages/master/sucos/blocks/EditDialog.tsx b/src/pages/master/sucos/blocks/EditDialog.tsx index 64c8b94..24dafb5 100644 --- a/src/pages/master/sucos/blocks/EditDialog.tsx +++ b/src/pages/master/sucos/blocks/EditDialog.tsx @@ -2,7 +2,7 @@ import { Alert, useDataGrid } from '@/components'; import { useManageSucosContext } from '../hooks/useManageSucosContext'; import { useCallApi } from '@/hooks'; import { getAuth } from '@/auth'; -import React, { useCallback, useEffect, useState } from 'react'; +import React, { useCallback, useEffect, useRef, useState } from 'react'; import { apiConfig } from '@/config/api.config'; import { toast } from 'sonner'; import { @@ -15,21 +15,40 @@ import { } from '@/components/ui/dialog'; import { Input } from '@/components/ui/input'; import { Button } from '@/components/ui/button'; +import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover'; +import { + Command, + CommandEmpty, + CommandGroup, + CommandInput, + CommandItem, + CommandList +} from '@/components/ui/command'; + +interface PostoAdmsProps { + PostoAdms_id: number; // Ubah ke PostoAdms_id + PostoAdms_name: string; // Ubah ke PostoAdms_name +} const API_URL = apiConfig.service_master_data; const EditDialog = () => { - const { showEditDialog, handleEditDialog, selectedSucos } = useManageSucosContext(); + const parentRef = useRef(null); + const { showEditDialog, handleEditDialog, selectedSucos, sucos } = useManageSucosContext(); const { reload } = useDataGrid(); - const { PutData } = useCallApi(); + const { PutData, GetData } = useCallApi(); const parsedUser = getAuth()?.user; + const [open, setOpen] = useState(false); + const [postoadms, setPostoadms] = useState([]); + const [alert, setAlert] = useState({ show: false, message: '' }); + const initialState = { name: '', - posto_adm_id: 0, + posto_adm_id: 0, // Pastikan ini sesuai dengan PostoAdms_id updated_by: '', updated_at: '' }; @@ -65,6 +84,42 @@ const EditDialog = () => { [selectedSucos, formField] ); + const doFetchPostoAdms = useCallback(async (sorting: any) => { + try { + sorting = sorting.length == 0 ? [{ id: 'name', desc: false }] : sorting; + const response = await GetData(`${API_URL}/postoadms/list`, { + limit: 100, + page: 1, + with_deleted: false, + order_field: sorting[0].id, + order_direction: sorting[0].desc == false ? 'ASC' : 'DESC' + }); + + setPostoadms(response?.data.list); + console.log('Data Posto Adms:', response?.data.list); // Log data postoadms + } catch (error) { + console.log('Error fetching postoadms', error); + } + }, []); + + const doFetchData = useCallback(async (id: string) => { + const response = await GetData(`${API_URL}/sucos/getdata/${id}`, { id }); + console.log('Data Sucos:', response?.data); // Log data sucos + + if (response?.status) { + setFormField((prev) => ({ + ...prev, + name: response.data.name, + posto_adm_id: response.data.posto.id // Pastikan ini sesuai dengan PostoAdms_id + })); + } else { + setFormField((prev) => ({ + ...prev, + name: '' + })); + } + }, []); + const handleUpdate = (e: React.FormEvent) => { e.preventDefault(); @@ -73,21 +128,40 @@ const EditDialog = () => { return; } + console.log('Form Field before update:', formField); // Log formField sebelum update doUpdateSucos(e); - console.log(formField); setAlert({ show: false, message: '' }); }; 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]); + + useEffect(() => { + if (selectedSucos) { setFormField({ ...formField, - updated_by: parsedUser.username, + updated_by: parsedUser?.username, updated_at: formattedTime }); + console.log('Form Field after update:', formField); // Log formField setelah update } }, [formattedTime]); + useEffect(() => { + doFetchPostoAdms([{ id: 'name', desc: false }]); + }, []); + return ( handleEditDialog(open, null)}> @@ -122,23 +196,49 @@ const EditDialog = () => {
- { - const value = parseInt(e.target.value, 10); - setFormField({ ...formField, posto_adm_id: isNaN(value) ? 0 : value }); - }} - /> + + + + + + + + + No Posto Adms Found. + + {postoadms.map((posto) => ( + { + setFormField({ + ...formField, + posto_adm_id: posto.PostoAdms_id // Gunakan PostoAdms_id + }); + setOpen(false); + }} + > + {posto.PostoAdms_name} + + ))} + + + + +
-
+
+
diff --git a/src/pages/master/sucos/hooks/ManageSucosContext.tsx b/src/pages/master/sucos/hooks/ManageSucosContext.tsx index 212be5a..48bee6c 100644 --- a/src/pages/master/sucos/hooks/ManageSucosContext.tsx +++ b/src/pages/master/sucos/hooks/ManageSucosContext.tsx @@ -86,7 +86,7 @@ const ManageSucosContextProvider = ({ children }: { children: React.ReactNode }) const columns = useMemo[]>( () => [ { - accessorFn: (row) => row.sucos_id, + accessorKey: 'sucos_id', id: 'id', header: ({ column }) => , enableSorting: true, @@ -168,52 +168,6 @@ const ManageSucosContextProvider = ({ children }: { children: React.ReactNode }) } }; - const getAldeiasBySucos = async (name: string) => { - try { - const response = await axios.get(`${API_URL}/sucos/aldeias/${name}`); - const data = response.data; - console.log(data); - } catch (error) { - console.log(`Error fetching sucos by ${name}`, error); - } - }; - - const createSucos = async (data: Partial) => { - try { - await axios.post(`${API_URL}/sucos/create`, data); - // getMunicipiosLists(10, 1, false, 'name', 'ASC'); - } catch (error) { - console.error('Error creating municipios', error); - } - }; - - const updateSucos = async (id: number, data: Partial) => { - try { - await axios.put(`${API_URL}/sucos/update/${id}`, data); - // getSucosLists(10, 1, false, 'name', 'ASC'); - } catch (error) { - console.error('Error updating sucos', error); - } - }; - - const deleteSucos = async (id: number, hardDelete?: boolean) => { - try { - await axios.delete(`${API_URL}/sucos/delete/${id}/${hardDelete}`); - // getSucosLists(10, 1, false, 'name', 'ASC'); - } catch (error) { - console.error('Error deleting sucos', error); - } - }; - - const restoreSucos = async (id: number) => { - try { - await axios.put(`${API_URL}/sucos/restore/${id}`); - // getSucosLists(10, 1, false, 'name', 'ASC'); - } catch (error) { - console.error('Error restoring sucos', error); - } - }; - return ( } layout={{ card: true }} sorting={[{ id: 'id', desc: false }]} diff --git a/src/pages/menu/manage-menu/ManageMenu.tsx b/src/pages/menu/manage-menu/ManageMenu.tsx index 75e0925..7dac58a 100644 --- a/src/pages/menu/manage-menu/ManageMenu.tsx +++ b/src/pages/menu/manage-menu/ManageMenu.tsx @@ -3,12 +3,26 @@ import { ManageMenusContextProvider } from './hooks/ManageMenusContext'; import AddDialog from './blocks/AddDIalog'; import EditDialog from './blocks/EditDialog'; import DeleteDialog from './blocks/DeleteDialog'; +import { Breadcrumbs, Link } from '@mui/material'; const ManageMenu = () => { return (

Manage Menus

+ + + Dashboard + + + + Master Data + + + + Manage Menus + +