diff --git a/src/Constants/Options.ts b/src/Constants/Options.ts index cf4be2a..2e5e474 100644 --- a/src/Constants/Options.ts +++ b/src/Constants/Options.ts @@ -9,7 +9,8 @@ export const TestTypeOptions: Option[] = [ export const SessionTypeOptions: Option[] = [ { value: 'sign-in', label: 'SignIn' }, { value: 'sign-up', label: 'SignUp' }, - { value: 'sign-in with forgot id', label: 'SignIn with Forgot ID' }, + // Removed as now we are not allowing forgot id + // { value: 'sign-in with forgot id', label: 'SignIn with Forgot ID' }, { value: 'broadcast', label: 'Broadcast' }, ]; diff --git a/src/app/(home)/Table/Actions.tsx b/src/app/(home)/Table/Actions.tsx index 5298a35..1517473 100644 --- a/src/app/(home)/Table/Actions.tsx +++ b/src/app/(home)/Table/Actions.tsx @@ -49,6 +49,7 @@ const TableActions = ({ session }: { session: Session }) => { await patchSession( { is_active: !session.is_active, + meta_data: session.meta_data, }, session.id ?? 0, session diff --git a/src/app/session/[type]/Steps/helper.ts b/src/app/session/[type]/Steps/helper.ts index 8dc05d9..e2aa4db 100644 --- a/src/app/session/[type]/Steps/helper.ts +++ b/src/app/session/[type]/Steps/helper.ts @@ -25,7 +25,6 @@ export const setGroupPreset = (value: string, form: UseFormReturn, apiOptions: A isPopupForm: false, popupFormId: null, noOfFieldsInPopup: '', - isRedirection: true, isIdGeneration: false, parentBatch: '', subBatch: [], @@ -43,7 +42,6 @@ export const setGroupPreset = (value: string, form: UseFormReturn, apiOptions: A isPopupForm: false, popupFormId: null, noOfFieldsInPopup: '', - isRedirection: true, isIdGeneration: true, parentBatch: '', subBatch: [], @@ -62,7 +60,6 @@ export const setGroupPreset = (value: string, form: UseFormReturn, apiOptions: A isPopupForm: false, popupFormId: null, noOfFieldsInPopup: '', - isRedirection: true, isIdGeneration: false, parentBatch: '', subBatch: [], @@ -78,7 +75,6 @@ export const setGroupPreset = (value: string, form: UseFormReturn, apiOptions: A isPopupForm: false, popupFormId: null, noOfFieldsInPopup: '', - isRedirection: true, isIdGeneration: false, parentBatch: '', subBatch: [], @@ -92,7 +88,6 @@ export const setGroupPreset = (value: string, form: UseFormReturn, apiOptions: A isPopupForm: false, popupFormId: null, noOfFieldsInPopup: '', - isRedirection: true, isIdGeneration: false, parentBatch: '', subBatch: [], @@ -283,6 +278,11 @@ export const handleBatchFields = ( fieldsSchema.parentBatch.hide = false; } + if (value === Platform.NoPlatform) { + form.setValue('isRedirection', false, { shouldDirty: true }); + } else { + form.setValue('isRedirection', true, { shouldDirty: true }); + } const selectedGroup = form.watch('group'); if (selectedGroup) { setParentBatchOptions(selectedGroup, form, apiOptions, fieldsSchema); diff --git a/src/lib/time-picker-utils.ts b/src/lib/time-picker-utils.ts index c89028f..d7f1d6e 100644 --- a/src/lib/time-picker-utils.ts +++ b/src/lib/time-picker-utils.ts @@ -171,12 +171,14 @@ export function display12HourValue(hours: number) { } export function utcToISTDate(utcDate: string) { + if (!utcDate) return ''; const parsedDate = new Date(utcDate); const istDate = addMinutes(parsedDate, UTC_IST_OFFSET).toISOString(); return istDate; } export function istToUTCDate(istDate: string) { + if (!istDate) return ''; const parsedDate = new Date(istDate); const utcDate = subMinutes(parsedDate, UTC_IST_OFFSET).toISOString(); return utcDate; diff --git a/src/types/api.types.ts b/src/types/api.types.ts index 6cc589f..bb1fa75 100644 --- a/src/types/api.types.ts +++ b/src/types/api.types.ts @@ -39,7 +39,7 @@ const repeatScheduleSchema = z.object({ }); export const sessionSchema = z.object({ - auth_type: z.string(), + auth_type: z.string().nullable(), created_by_id: z.string().datetime(), end_time: z.string().datetime(), id: z.number().int(), diff --git a/src/types/enums.ts b/src/types/enums.ts index a0d1395..3e7ffa3 100644 --- a/src/types/enums.ts +++ b/src/types/enums.ts @@ -24,6 +24,7 @@ export enum Platform { Others = 'others', Plio = 'AF-plio', SPlio = 'SCERT-plio', + NoPlatform = 'no-platform', } export enum Group { @@ -66,10 +67,11 @@ export const GroupShortName: Record = { export enum AuthType { ID = 'ID', - IDPH = 'ID,PH', IDDOB = 'ID,DOB', - IDPHDOB = 'ID,PH,DOB', CODE = 'CODE', + // Removed as now we are not allowing these. + // IDPH = 'ID,PH', + // IDPHDOB = 'ID,PH,DOB', } export enum Subjects { diff --git a/src/types/form.types.ts b/src/types/form.types.ts index 8eb9336..91a4baa 100644 --- a/src/types/form.types.ts +++ b/src/types/form.types.ts @@ -35,7 +35,7 @@ export const basicSchema = z (value) => SessionTypeOptions.some((option) => option.value === value), 'Invalid option selected' ), - authType: z.string({ required_error: 'This field is required' }), + authType: z.string({ required_error: 'This field is required' }).optional().nullable(), activateSignUp: z.coerce.boolean(), isPopupForm: z.coerce.boolean(), noOfFieldsInPopup: z.coerce @@ -86,6 +86,17 @@ export const basicSchema = z } } + // Validation for sessions with Redirection = true + if (data.isRedirection) { + if (!data.authType) { + context.addIssue({ + code: z.ZodIssueCode.custom, + message: 'This field is required', + path: ['authType'], + }); + } + } + if (data.platform === Platform.Quiz) { // Quiz platform validation if (!data.parentBatch) { @@ -214,7 +225,7 @@ export const liveSchema = z .pipe(z.string().url('This is not a valid url')), platformId: z.string({ required_error: 'This field is required' }), subject: z.array(z.string()).min(1, 'This field is required'), - platform: z.string().optional(), + platform: z.string().optional().nullable(), }) .refine( (data) => {