From 61211e7e1663c6ec4eb813ec8860c926288f2670 Mon Sep 17 00:00:00 2001 From: Wikzyy Date: Mon, 7 Apr 2025 15:06:20 +0700 Subject: [PATCH] add activity dialog on municipios, postoadm, sucos, and aldeias --- src/pages/master/aldeias/blocks/AddDialog.tsx | 10 +++++++++- src/pages/master/aldeias/blocks/EditDialog.tsx | 8 ++++++++ src/pages/master/municipios/blocks/AddDialog.tsx | 12 ++++++------ src/pages/master/municipios/blocks/EditDialog.tsx | 12 ++++++------ src/pages/master/postoadms/blocks/AddDialog.tsx | 10 +++++++++- src/pages/master/postoadms/blocks/EditDialog.tsx | 9 +++++++++ src/pages/master/sucos/blocks/AddDialog.tsx | 10 +++++++++- src/pages/master/sucos/blocks/EditDialog.tsx | 8 ++++++++ 8 files changed, 64 insertions(+), 15 deletions(-) diff --git a/src/pages/master/aldeias/blocks/AddDialog.tsx b/src/pages/master/aldeias/blocks/AddDialog.tsx index f678f33..97c40b2 100644 --- a/src/pages/master/aldeias/blocks/AddDialog.tsx +++ b/src/pages/master/aldeias/blocks/AddDialog.tsx @@ -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(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 Aldeias => ${selectedAldeias}`, + action: 'C' + }; + + doSaveLogActivity(createActivity); } else { toast.error('Error Create Aldeias'); setAlert({ show: true, message: 'Failed to create Aldeias. Please try again.' }); diff --git a/src/pages/master/aldeias/blocks/EditDialog.tsx b/src/pages/master/aldeias/blocks/EditDialog.tsx index 449197d..fd4f29a 100644 --- a/src/pages/master/aldeias/blocks/EditDialog.tsx +++ b/src/pages/master/aldeias/blocks/EditDialog.tsx @@ -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 Aldeias => ${selectedAldeias}`, + action: 'U' + }; + + doSaveLogActivity(createActivity); } else { toast.error('Error Update Aldeias'); setAlert({ show: true, message: 'Error Update Aldeias' }); diff --git a/src/pages/master/municipios/blocks/AddDialog.tsx b/src/pages/master/municipios/blocks/AddDialog.tsx index d2dfda4..5afd080 100644 --- a/src/pages/master/municipios/blocks/AddDialog.tsx +++ b/src/pages/master/municipios/blocks/AddDialog.tsx @@ -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 Municipio', + description: `Create Municipio => ${selectedMunicipios}`, + action: 'C' + }; - // doSaveLogActivity(createActivity); + doSaveLogActivity(createActivity); } else { toast.error('Failed to create municipio.'); setAlert({ show: true, message: 'Failed to create municipio. Please try again.' }); diff --git a/src/pages/master/municipios/blocks/EditDialog.tsx b/src/pages/master/municipios/blocks/EditDialog.tsx index 50406bc..72995d4 100644 --- a/src/pages/master/municipios/blocks/EditDialog.tsx +++ b/src/pages/master/municipios/blocks/EditDialog.tsx @@ -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 Municipio', + 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.' }); diff --git a/src/pages/master/postoadms/blocks/AddDialog.tsx b/src/pages/master/postoadms/blocks/AddDialog.tsx index eaa8b1e..d489f75 100644 --- a/src/pages/master/postoadms/blocks/AddDialog.tsx +++ b/src/pages/master/postoadms/blocks/AddDialog.tsx @@ -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(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 => ${selectedPostoAdms}`, + 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.' }); diff --git a/src/pages/master/postoadms/blocks/EditDialog.tsx b/src/pages/master/postoadms/blocks/EditDialog.tsx index d170d1a..532403b 100644 --- a/src/pages/master/postoadms/blocks/EditDialog.tsx +++ b/src/pages/master/postoadms/blocks/EditDialog.tsx @@ -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.' }); diff --git a/src/pages/master/sucos/blocks/AddDialog.tsx b/src/pages/master/sucos/blocks/AddDialog.tsx index 4436fd1..7db4e9a 100644 --- a/src/pages/master/sucos/blocks/AddDialog.tsx +++ b/src/pages/master/sucos/blocks/AddDialog.tsx @@ -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(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 Sucos => ${selectedSucos}`, + 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.' }); diff --git a/src/pages/master/sucos/blocks/EditDialog.tsx b/src/pages/master/sucos/blocks/EditDialog.tsx index 68b7bcd..a8d865d 100644 --- a/src/pages/master/sucos/blocks/EditDialog.tsx +++ b/src/pages/master/sucos/blocks/EditDialog.tsx @@ -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 Sucos => ${selectedSucos}`, + action: 'U' + }; + + doSaveLogActivity(createActivity); } else { toast.error('Failed Update Sucos'); setAlert({ show: true, message: 'Failed Update Sucos. Please try again' });