Skip to content

Commit

Permalink
fix coach schemal
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohamed Abaker authored and Mohamed Abaker committed Jan 20, 2024
1 parent 0409075 commit 1f915ba
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 12 deletions.
38 changes: 28 additions & 10 deletions client/src/Coach/CoachLandingPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,23 @@ function CoachLandingPage() {
`${URLPREFIX}/coach/student/${res.data._id}`,
);

res2 = await axios.get(`${URLPREFIX}/user/id/${res.data.user_id}`);
if (res.data != null && res.data.user_id != null) {
res2 = await axios.get(`${URLPREFIX}/user/id/${res.data.user_id}`);
}

const teacherRes = await axios.get(
`${URLPREFIX}/user/id/${res.data.teacher_id}`,
);
let teacherRes = null;
if (res.data != null && res.data.user_id != null) {
teacherRes = await axios.get(
`${URLPREFIX}/user/id/${res.data.teacher_id}`,
);
}

const schoolRes = await axios.get(
`${URLPREFIX}/school/${res.data.school_id}`,
);
let schoolRes = null;
if (res.data != null && res.data.user_id != null) {
schoolRes = await axios.get(
`${URLPREFIX}/school/${res.data.school_id}`,
);
}

const blockRes = await axios.get(
`${URLPREFIX}/block/student/${res.data.user_id}`,
Expand All @@ -68,9 +76,19 @@ function CoachLandingPage() {
setStudent({
...res.data,
...res2.data,
school_name: schoolRes.data.name,
school_info: schoolRes.data.info,
teacher: `${teacherRes.data.firstName} ${teacherRes.data.lastName}`,
school_name:
schoolRes != null && schoolRes.data != null
? schoolRes.data.name
: '',
school_info:
schoolRes != null && schoolRes.data != null
? schoolRes.data.info
: ' ',
teacher: `${
teacherRes != null
? `${teacherRes.data.firstName} ${teacherRes.data.lastName}`
: ''
}`,
zoom_link: blockRes.data.zoom,
});
};
Expand Down
4 changes: 2 additions & 2 deletions server/src/models/coach.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ const CoachSchema = new mongoose.Schema({
},
partner_site: {
type: String,
required: true,
required: false,
},
mailing_address: {
type: String,
required: true,
required: false,
},
media_waiver: {
type: Boolean,
Expand Down

0 comments on commit 1f915ba

Please sign in to comment.