Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle Register Sessions #80

Merged
merged 6 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Constants/Options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' },
];

Expand Down
1 change: 1 addition & 0 deletions src/app/(home)/Table/Actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 3 additions & 5 deletions src/app/session/[type]/Steps/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ export const setGroupPreset = (value: string, form: UseFormReturn, apiOptions: A
isPopupForm: false,
popupFormId: null,
noOfFieldsInPopup: '',
isRedirection: true,
isIdGeneration: false,
parentBatch: '',
subBatch: [],
Expand All @@ -43,7 +42,6 @@ export const setGroupPreset = (value: string, form: UseFormReturn, apiOptions: A
isPopupForm: false,
popupFormId: null,
noOfFieldsInPopup: '',
isRedirection: true,
isIdGeneration: true,
parentBatch: '',
subBatch: [],
Expand All @@ -62,7 +60,6 @@ export const setGroupPreset = (value: string, form: UseFormReturn, apiOptions: A
isPopupForm: false,
popupFormId: null,
noOfFieldsInPopup: '',
isRedirection: true,
isIdGeneration: false,
parentBatch: '',
subBatch: [],
Expand All @@ -78,7 +75,6 @@ export const setGroupPreset = (value: string, form: UseFormReturn, apiOptions: A
isPopupForm: false,
popupFormId: null,
noOfFieldsInPopup: '',
isRedirection: true,
isIdGeneration: false,
parentBatch: '',
subBatch: [],
Expand All @@ -92,7 +88,6 @@ export const setGroupPreset = (value: string, form: UseFormReturn, apiOptions: A
isPopupForm: false,
popupFormId: null,
noOfFieldsInPopup: '',
isRedirection: true,
isIdGeneration: false,
parentBatch: '',
subBatch: [],
Expand Down Expand Up @@ -283,6 +278,9 @@ export const handleBatchFields = (
fieldsSchema.parentBatch.hide = false;
}

if (value === Platform.NoPlatform) {
form.setValue('isRedirection', false, { shouldDirty: true });
Drish-xD marked this conversation as resolved.
Show resolved Hide resolved
}
const selectedGroup = form.watch('group');
if (selectedGroup) {
setParentBatchOptions(selectedGroup, form, apiOptions, fieldsSchema);
Expand Down
2 changes: 2 additions & 0 deletions src/lib/time-picker-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/types/api.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
6 changes: 4 additions & 2 deletions src/types/enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export enum Platform {
Others = 'others',
Plio = 'AF-plio',
SPlio = 'SCERT-plio',
NoPlatform = 'no-platform',
}

export enum Group {
Expand Down Expand Up @@ -66,10 +67,11 @@ export const GroupShortName: Record<Group, string> = {

export enum AuthType {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in AuthGroup list can you add "MaharashtraStudents" (in case u are not fetching from authgroup table)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's fetched from authgroup table itself.

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 {
Expand Down
15 changes: 13 additions & 2 deletions src/types/form.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) => {
Expand Down
Loading