update date time

This commit is contained in:
Wikzyy
2025-03-04 13:50:43 +07:00
parent 78e3b3d112
commit ea21966453
6 changed files with 22 additions and 24 deletions

View File

@ -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 (
<Dialog open={showAddDialog} onOpenChange={(open) => handleAddDialog(open)}>

View File

@ -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 (
<Dialog open={showEditDialog} onOpenChange={(open) => handleEditDialog(open, null)}>