Skip to content

Commit

Permalink
added types for session
Browse files Browse the repository at this point in the history
  • Loading branch information
Prakhar-commits committed Nov 30, 2023
1 parent 19c6767 commit bc9278c
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 11 deletions.
1 change: 1 addition & 0 deletions src/pages/SessionCreator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export default function SessionCreator() {
student: {},
test: {},
timeline: {},
session: {},
});

const createSession = async () => {
Expand Down
27 changes: 24 additions & 3 deletions src/types/FormTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,28 @@ type TimelineForm = {
endTime: string;
};

type MyForm = StudentForm | TestForm | TimelineForm;
type MyFormKey = keyof StudentForm | keyof TestForm | keyof TimelineForm;
type SessionType = {
number_of_fields_in_pop_form: number | null;
form_schema_id: number | null;
auth_type: null | string;
id_generation: boolean | null;
activate_signup: boolean | null;
redirection: boolean | null;
pop_up_form: boolean | null;
};

type MyForm = StudentForm | TestForm | TimelineForm | SessionType;
type MyFormKey =
| keyof StudentForm
| keyof TestForm
| keyof TimelineForm
| keyof SessionType;

export type { MyForm, MyFormKey, StudentForm, TestForm, TimelineForm };
export type {
MyForm,
MyFormKey,
StudentForm,
TestForm,
TimelineForm,
SessionType,
};
3 changes: 3 additions & 0 deletions src/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ interface RowType {
timeline: {
[key: string]: string | number | boolean | null;
};
session: {
[key: string]: string | number | boolean | null;
};
}

export type { ActiveFormProps, OptionType, RowType };
16 changes: 8 additions & 8 deletions src/utils/FormInputHandling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function formatDateTime(date: string, time: string) {
}
// post data to the server
async function postFormData(formData: RowType) {
const { student, test, timeline, dateCreated } = formData;
const { student, test, timeline, dateCreated, session } = formData;
console.log(timeline);

let start_time = formatDateTime(timeline.startDate, timeline.startTime);
Expand All @@ -48,14 +48,14 @@ async function postFormData(formData: RowType) {
repeat_schedule: { type: "weekly", params: [1, 2, 3, 4, 5, 6, 7] }, // this is hardcoded needs to be changed
session_id: "",
platform_id: "",
form_schema_id: "1",
form_schema_id: session.form_schema_id,
type: "sign-in",
auth_type: "ID",
activate_signup: true,
id_generation: false,
redirection: false,
pop_up_form: true,
number_of_fields_in_pop_form: "3",
auth_type: session.auth_type,
activate_signup: session.activate_signup,
id_generation: session.id_generation,
redirection: session.redirection,
pop_up_form: session.pop_up_form,
number_of_fields_in_pop_form: session.number_of_fields_in_pop_form,
meta_data: {
group: student.group,
batch: student.batch,
Expand Down

0 comments on commit bc9278c

Please sign in to comment.