From ea21966453ec3763af173ac6f166ad2360e5aec9 Mon Sep 17 00:00:00 2001 From: Wikzyy Date: Tue, 4 Mar 2025 13:50:43 +0700 Subject: [PATCH] update date time --- src/pages/master/municipios/blocks/AddDialog.tsx | 7 ++++--- src/pages/master/municipios/blocks/EditDialog.tsx | 6 +++--- src/pages/master/postoadms/blocks/AddDialog.tsx | 11 +++-------- src/pages/master/postoadms/blocks/EditDialog.tsx | 8 ++++---- src/pages/master/sucos/blocks/AddDialog.tsx | 7 ++++--- src/pages/master/sucos/blocks/EditDialog.tsx | 7 ++++--- 6 files changed, 22 insertions(+), 24 deletions(-) diff --git a/src/pages/master/municipios/blocks/AddDialog.tsx b/src/pages/master/municipios/blocks/AddDialog.tsx index 0db792b..234bd0c 100644 --- a/src/pages/master/municipios/blocks/AddDialog.tsx +++ b/src/pages/master/municipios/blocks/AddDialog.tsx @@ -37,6 +37,9 @@ const AddDialog = () => { }; const [formField, setFormField] = useState(initialState); + const created_time = new Date(); + const formattedTime = created_time.toISOString().slice(0, 19).replace('T', ' '); + const resetForm = () => { setFormField(initialState); }; @@ -92,8 +95,6 @@ const AddDialog = () => { }; useEffect(() => { - const created_time = new Date(); - const formattedTime = created_time.toISOString().slice(0, 19).replace('T', ' '); if (showAddDialog) { setFormField({ name: formField.name, @@ -101,7 +102,7 @@ const AddDialog = () => { created_at: formattedTime }); } - }, [showAddDialog]); + }, [formattedTime]); return ( handleAddDialog(open)}> diff --git a/src/pages/master/municipios/blocks/EditDialog.tsx b/src/pages/master/municipios/blocks/EditDialog.tsx index afb9c3c..0579d28 100644 --- a/src/pages/master/municipios/blocks/EditDialog.tsx +++ b/src/pages/master/municipios/blocks/EditDialog.tsx @@ -39,6 +39,8 @@ const EditDialog = () => { }; const [formField, setFormField] = useState(initialState); + const created_time = new Date(); + const formattedTime = created_time.toISOString().slice(0, 19).replace('T', ' '); const resetForm = () => { setFormField(initialState); @@ -96,8 +98,6 @@ const EditDialog = () => { // }, []); useEffect(() => { - const created_time = new Date(); - const formattedTime = created_time.toISOString().slice(0, 19).replace('T', ' '); if (selectedMunicipios) { setFormField({ name: formField.name, @@ -105,7 +105,7 @@ const EditDialog = () => { updated_at: formattedTime }); } - }, [selectedMunicipios]); + }, [formattedTime]); // console.log(selectedMunicipios); return ( diff --git a/src/pages/master/postoadms/blocks/AddDialog.tsx b/src/pages/master/postoadms/blocks/AddDialog.tsx index 3849e1c..6e47f25 100644 --- a/src/pages/master/postoadms/blocks/AddDialog.tsx +++ b/src/pages/master/postoadms/blocks/AddDialog.tsx @@ -38,6 +38,8 @@ const AddDialog = () => { }; const [formField, setFormField] = useState(initialState); + const created_time = new Date(); + const formattedTime = created_time.toISOString().slice(0, 19).replace('T', ' '); const resetForm = () => { setFormField(initialState); @@ -76,14 +78,7 @@ const AddDialog = () => { setAlert({ show: false, message: '' }); }; - // const handleReset = () => { - // resetForm(); - // setAlert({ show: false, message: '' }); - // }; - useEffect(() => { - const created_time = new Date(); - const formattedTime = created_time.toISOString().slice(0, 19).replace('T', ' '); if (showAddDialog) { setFormField({ ...formField, @@ -91,7 +86,7 @@ const AddDialog = () => { created_at: formattedTime }); } - }, [showAddDialog]); + }, [formattedTime]); return ( handleAddDialog(open)}> diff --git a/src/pages/master/postoadms/blocks/EditDialog.tsx b/src/pages/master/postoadms/blocks/EditDialog.tsx index 2407e1d..8513d83 100644 --- a/src/pages/master/postoadms/blocks/EditDialog.tsx +++ b/src/pages/master/postoadms/blocks/EditDialog.tsx @@ -35,7 +35,10 @@ const EditDialog = () => { updated_by: '', updated_at: '' }; + const [formField, setFormField] = useState(initialState); + const created_time = new Date(); + const formattedTime = created_time.toISOString().slice(0, 19).replace('T', ' '); const resetForm = () => { setFormField(initialState); @@ -75,9 +78,6 @@ const EditDialog = () => { }; useEffect(() => { - const created_time = new Date(); - const formattedTime = created_time.toISOString().slice(0, 19).replace('T', ' '); - if (selectedPostoAdms) { setFormField({ ...formField, @@ -85,7 +85,7 @@ const EditDialog = () => { updated_at: formattedTime }); } - }, [selectedPostoAdms]); + }, [formattedTime]); return ( handleEditDialog(open, null)}> diff --git a/src/pages/master/sucos/blocks/AddDialog.tsx b/src/pages/master/sucos/blocks/AddDialog.tsx index eed5cd9..51909e6 100644 --- a/src/pages/master/sucos/blocks/AddDialog.tsx +++ b/src/pages/master/sucos/blocks/AddDialog.tsx @@ -34,7 +34,10 @@ const AddDialog = () => { created_by: '', created_at: '' }; + const [formField, setFormField] = useState(initialState); + const created_time = new Date(); + const formattedTime = created_time.toISOString().slice(0, 19).replace('T', ' '); const resetForm = () => { setFormField(initialState); @@ -70,8 +73,6 @@ const AddDialog = () => { }; useEffect(() => { - const created_time = new Date(); - const formattedTime = created_time.toISOString().slice(0, 19).replace('T', ' '); if (showAddDialog) { setFormField({ ...formField, @@ -79,7 +80,7 @@ const AddDialog = () => { created_at: formattedTime }); } - }, [showAddDialog]); + }, [formattedTime]); return ( handleAddDialog(open)}> diff --git a/src/pages/master/sucos/blocks/EditDialog.tsx b/src/pages/master/sucos/blocks/EditDialog.tsx index 342c621..f655658 100644 --- a/src/pages/master/sucos/blocks/EditDialog.tsx +++ b/src/pages/master/sucos/blocks/EditDialog.tsx @@ -33,7 +33,10 @@ const EditDialog = () => { updated_by: '', updated_at: '' }; + const [formField, setFormField] = useState(initialState); + const created_time = new Date(); + const formattedTime = created_time.toISOString().slice(0, 19).replace('T', ' '); const resetForm = () => { setFormField(initialState); @@ -76,8 +79,6 @@ const EditDialog = () => { }; useEffect(() => { - const created_time = new Date(); - const formattedTime = created_time.toISOString().slice(0, 19).replace('T', ' '); if (showEditDialog) { setFormField({ ...formField, @@ -85,7 +86,7 @@ const EditDialog = () => { updated_at: formattedTime }); } - }, [showEditDialog]); + }, [formattedTime]); return ( handleEditDialog(open, null)}>