Having trouble resolving an error in my code. I used zod for data validation and tried using the useMemo function, but when I input the value that has been validated by zod, an error occurs as shown in the image. I even tried adding an index to the value, but it didn't work. Any suggestions on how to fix this?
const apiScheme = z.tuple([
z.object({
total_work_hours: z.number().nullable(),
normal_hours: z.number().nullable(),
overtime: z.number(),
public_holiday_hours: z.number(),
total_work_days: z.number(),
total_medical_leave: z.number(),
total_emergency_leave: z.number(),
total_public_holiday: z.number(),
}),
z.array(
z.object({
date: z.string(),
attendance: z.array(
z.object({
outlet_name: z.string().nullable(),
clock_in_type: z.string().nullable(),
clock_in: z.number().nullable(),
clock_out: z.number().nullable(),
work_hour: z.number().nullable(),
}),
),
}),
),
]);
// console.log(apiScheme);
const data1 = useMemo(() => {
if (responseAttendanceData) {
const parseData = apiScheme.parse(responseAttendanceData);
if (parseData) {
return parseData.map((value)=>{
return{
total_work_hours: value.total_work_hours,
normal_hours: z.number().nullable(),
overtime: z.number(),
public_holiday_hours: z.number(),
total_work_days: z.number(),
total_medical_leave: z.number(),
total_emergency_leave: z.number(),
total_public_holiday: z.number(),
}
})
}
}
return null;
}, [responseAttendanceData]);