diff --git a/admin-wcc-app/components/EditMentor/MentorshipAvailabilitySection.tsx b/admin-wcc-app/components/EditMentor/MentorshipAvailabilitySection.tsx index e0e9cba9..6ec1def6 100644 --- a/admin-wcc-app/components/EditMentor/MentorshipAvailabilitySection.tsx +++ b/admin-wcc-app/components/EditMentor/MentorshipAvailabilitySection.tsx @@ -9,8 +9,8 @@ import { Typography, } from '@mui/material'; import Grid from '@mui/material/Grid2'; -import { Controller } from 'react-hook-form'; -import { MENTORSHIP_TYPES } from '@/lib/mentorshipTypes'; +import { Controller, useWatch } from 'react-hook-form'; +import { MENTORSHIP_TYPE_VALUES, MENTORSHIP_TYPES } from '@/lib/mentorshipTypes'; import { FormSectionProps } from './types'; const MONTHS = [ @@ -31,6 +31,13 @@ const MONTHS = [ const monthLabel = (month: string) => month.charAt(0) + month.slice(1).toLowerCase(); export default function MentorshipAvailabilitySection({ control, errors }: FormSectionProps) { + const mentorshipType = useWatch({ + control, + name: 'mentorshipType', + }); + + const hasAdHocMentorship = mentorshipType?.includes(MENTORSHIP_TYPE_VALUES.AD_HOC); + return ( @@ -119,54 +126,56 @@ export default function MentorshipAvailabilitySection({ control, errors }: FormS /> - - - Month Availability - - - {MONTHS.map((month, index) => ( - - - ( - field.onChange(e.target.checked)} - size="small" - /> - } - label={monthLabel(month)} - sx={{ minWidth: 110 }} - /> - )} - /> - ( - - onChange(e.target.value === '' ? 0 : Number(e.target.value)) - } - type="number" - size="small" - label="hours" - slotProps={{ htmlInput: { min: 0, max: 200 } }} - sx={{ width: 80 }} - /> - )} - /> - - - ))} + {hasAdHocMentorship && ( + + + Month Availability + + + {MONTHS.map((month, index) => ( + + + ( + field.onChange(e.target.checked)} + size="small" + /> + } + label={monthLabel(month)} + sx={{ minWidth: 110 }} + /> + )} + /> + ( + + onChange(e.target.value === '' ? 0 : Number(e.target.value)) + } + type="number" + size="small" + label="hours" + slotProps={{ htmlInput: { min: 0, max: 200 } }} + sx={{ width: 80 }} + /> + )} + /> + + + ))} + - + )} ); diff --git a/admin-wcc-app/lib/mentorshipTypes.ts b/admin-wcc-app/lib/mentorshipTypes.ts index 0153f979..e956e0c8 100644 --- a/admin-wcc-app/lib/mentorshipTypes.ts +++ b/admin-wcc-app/lib/mentorshipTypes.ts @@ -1,4 +1,9 @@ +export const MENTORSHIP_TYPE_VALUES = { + AD_HOC: 'AD_HOC', + LONG_TERM: 'LONG_TERM', +} as const; + export const MENTORSHIP_TYPES = [ - { value: 'AD_HOC', label: 'Ad Hoc' }, - { value: 'LONG_TERM', label: 'Long Term' }, + { value: MENTORSHIP_TYPE_VALUES.AD_HOC, label: 'Ad Hoc' }, + { value: MENTORSHIP_TYPE_VALUES.LONG_TERM, label: 'Long Term' }, ];