mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-25 15:55:48 +00:00
chore: remove time_type default value and check activity form time type validity
This commit is contained in:
@@ -144,7 +144,7 @@ export function MasterAktivitasContent() {
|
|||||||
id: '',
|
id: '',
|
||||||
name: '',
|
name: '',
|
||||||
description: '',
|
description: '',
|
||||||
time_type: 'umum',
|
time_type: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
// Phase handlers
|
// Phase handlers
|
||||||
@@ -273,7 +273,7 @@ export function MasterAktivitasContent() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setActivityModalMode('create');
|
setActivityModalMode('create');
|
||||||
setActivityForm({ id: '', name: '', description: '', time_type: 'umum' });
|
setActivityForm({ id: '', name: '', description: '', time_type: '' });
|
||||||
setShowActivityModal(true);
|
setShowActivityModal(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -289,16 +289,25 @@ export function MasterAktivitasContent() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleSaveActivity = async () => {
|
const handleSaveActivity = async () => {
|
||||||
if (!activityForm.name.trim()) {
|
const isTimeTypeValid = Boolean(activityForm.time_type);
|
||||||
|
const isNameValid = Boolean(activityForm.name.trim());
|
||||||
|
const isNameLengthValid = activityForm.name.trim().length >= 3;
|
||||||
|
|
||||||
|
if (!isNameValid) {
|
||||||
toast.error('Nama aktivitas harus diisi');
|
toast.error('Nama aktivitas harus diisi');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (activityForm.name.trim().length < 3) {
|
if (!isNameLengthValid) {
|
||||||
toast.error('Nama aktivitas minimal 3 karakter!');
|
toast.error('Nama aktivitas minimal 3 karakter!');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isTimeTypeValid) {
|
||||||
|
toast.error('Tipe waktu harus diisi');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!selectedPhase) {
|
if (!selectedPhase) {
|
||||||
toast.error('Pilih phase terlebih dahulu');
|
toast.error('Pilih phase terlebih dahulu');
|
||||||
return;
|
return;
|
||||||
@@ -352,7 +361,7 @@ export function MasterAktivitasContent() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setShowActivityModal(false);
|
setShowActivityModal(false);
|
||||||
setActivityForm({ id: '', name: '', description: '', time_type: 'umum' });
|
setActivityForm({ id: '', name: '', description: '', time_type: '' });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error saving activity:', error);
|
console.error('Error saving activity:', error);
|
||||||
toast.error('Terjadi kesalahan saat menyimpan aktivitas');
|
toast.error('Terjadi kesalahan saat menyimpan aktivitas');
|
||||||
|
|||||||
Reference in New Issue
Block a user