diff --git a/src/components/form/MultipleCheckboxList/index.tsx b/src/components/form/MultipleCheckboxList/index.tsx index e216104f..8c84bdd6 100644 --- a/src/components/form/MultipleCheckboxList/index.tsx +++ b/src/components/form/MultipleCheckboxList/index.tsx @@ -5,19 +5,18 @@ import { } from 'react-native'; import { MaterialIcons } from '@expo/vector-icons'; import { GREY } from '../../../styles/colors'; +import { DataOptionsType } from '../../../store/attendanceSheets/slice'; import styles from './styles'; -type CheckboxOptionsType = { label: string, value: string }; - interface MultipleCheckboxListProps { - optionsGroups: CheckboxOptionsType[][], + optionsGroups: DataOptionsType[][], groupTitles: string[], setOptions: (options: string[]) => void, checkedList: string[], } interface RenderItemProps { - item: { label: string, value: string }, + item: DataOptionsType, checkedList: string[], onPressCheckbox: (value: string) => void } diff --git a/src/components/form/RadioButtonList/index.tsx b/src/components/form/RadioButtonList/index.tsx index 8ff90244..51ce9f4a 100644 --- a/src/components/form/RadioButtonList/index.tsx +++ b/src/components/form/RadioButtonList/index.tsx @@ -2,17 +2,16 @@ import { TouchableOpacity, Text } from 'react-native'; import { MaterialIcons } from '@expo/vector-icons'; import styles from './styles'; import { GREY } from '../../../styles/colors'; - -type RadioButtonOptionsType = { label: string, value: string }; +import { DataOptionsType } from '../../../store/attendanceSheets/slice'; interface RadioButtonProps { - options: RadioButtonOptionsType[], + options: DataOptionsType[], setOption: (option: string) => void, checkedRadioButton: string } interface RenderItemProps { - item: { label: string, value: string }, + item: DataOptionsType, checkedRadioButton: string, onPressCheckbox: (value: string) => void } diff --git a/src/screens/courses/profile/AdminCourseProfile/index.tsx b/src/screens/courses/profile/AdminCourseProfile/index.tsx index 551a9484..28af1022 100644 --- a/src/screens/courses/profile/AdminCourseProfile/index.tsx +++ b/src/screens/courses/profile/AdminCourseProfile/index.tsx @@ -80,7 +80,7 @@ const AdminCourseProfile = ({ route, navigation }: AdminCourseProfileProps) => { const stepsById: object = useMemo(() => keyBy(course?.subProgram.steps, '_id'), [course]); const groupedSlotsToBeSigned = useMemo(() => { - if (!isSingle || !course?.slots.length) return []; + if (!isSingle || !course?.slots.length) return {}; const signedSlots = (savedAttendanceSheets as SingleAttendanceSheetType[]) .map(as => get(as, 'slots', []).map(s => s._id)) .flat(); @@ -98,7 +98,7 @@ const AdminCourseProfile = ({ route, navigation }: AdminCourseProfileProps) => { }, [course, isSingle, savedAttendanceSheets, stepsById]); const missingAttendanceSheets = useMemo(() => { - if (!course?.slots.length) return []; + if (!course?.slots.length || !firstSlot) return []; if ([INTRA, INTRA_HOLDING].includes(course?.type)) { const intraOrIntraHoldingCourseSavedSheets = savedAttendanceSheets as IntraOrIntraHoldingAttendanceSheetType[]; diff --git a/src/store/attendanceSheets/hooks.ts b/src/store/attendanceSheets/hooks.ts index d400ffc4..8d580166 100644 --- a/src/store/attendanceSheets/hooks.ts +++ b/src/store/attendanceSheets/hooks.ts @@ -19,7 +19,7 @@ export const useSetCourse = () => { export const useSetMissingAttendanceSheets = () => { const dispatch = useAppDispatch(); - return useCallback((missingAttendanceSheets: DataOptionsType) => + return useCallback((missingAttendanceSheets: DataOptionsType[]) => dispatch(setMissingAttendanceSheets(missingAttendanceSheets)), [dispatch]); }; diff --git a/src/store/attendanceSheets/slice.ts b/src/store/attendanceSheets/slice.ts index 3c81e8e8..cea0324f 100644 --- a/src/store/attendanceSheets/slice.ts +++ b/src/store/attendanceSheets/slice.ts @@ -2,11 +2,11 @@ import { createSlice, PayloadAction } from '@reduxjs/toolkit'; import { resetAllReducers } from '../actions'; import { BlendedCourseType, SlotType } from '../../types/CourseTypes'; -export type DataOptionsType = {value: string; label: string;}[] +export type DataOptionsType = { value: string; label: string } export type AttendanceSheetStateType = { course: BlendedCourseType | null, - missingAttendanceSheets: DataOptionsType, + missingAttendanceSheets: DataOptionsType[], groupedSlotsToBeSigned: Record, } const initialState: AttendanceSheetStateType = { @@ -22,7 +22,7 @@ const setBlendedCourse = (state: AttendanceSheetStateType, action: PayloadAction ); const setMissingAttendanceSheetList = - (state: AttendanceSheetStateType, action: PayloadAction) => ( + (state: AttendanceSheetStateType, action: PayloadAction) => ( { ...state, missingAttendanceSheets: action.payload } );