mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +00:00
refactor(FE): Validate recording date and handle null location
This commit is contained in:
@@ -103,6 +103,7 @@ export const RecordingGrowingFormSchema: Yup.ObjectSchema<RecordingGrowingFormSc
|
||||
Yup.object({
|
||||
record_date: Yup.string()
|
||||
.required('Tanggal recording wajib diisi!')
|
||||
.min(1, 'Tanggal recording wajib diisi!')
|
||||
.typeError('Tanggal recording wajib diisi!'),
|
||||
location: Yup.object({
|
||||
value: Yup.number().min(1).required(),
|
||||
|
||||
@@ -1175,7 +1175,7 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
||||
// ===== EVENT HANDLERS =====
|
||||
const locationChangeHandler = (val: OptionType | OptionType[] | null) => {
|
||||
const location = val as OptionType | null;
|
||||
const locationId = Number(location?.value);
|
||||
const locationId = location ? Number(location.value) : 0;
|
||||
|
||||
formik.setFieldTouched('location', true);
|
||||
formik.setFieldValue('location', location);
|
||||
|
||||
Reference in New Issue
Block a user