Skip to content

Commit

Permalink
Profile not loading for new interns bug fixed.
Browse files Browse the repository at this point in the history
  • Loading branch information
thivi committed Jun 26, 2020
1 parent 3653713 commit 1fb0d27
Showing 1 changed file with 25 additions and 22 deletions.
47 changes: 25 additions & 22 deletions src/pages/profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ export const ProfilePage = (): ReactElement => {
dispatch(
Notify({
status: NotificationType.SUCCESS,
message: "Profile was successfully added.",
message: "Profile was successfully added."
})
);
})
.catch((error) => {
dispatch(
Notify({
status: NotificationType.ERROR,
message: error,
message: error
})
);
})
Expand All @@ -67,15 +67,15 @@ export const ProfilePage = (): ReactElement => {
dispatch(
Notify({
status: NotificationType.SUCCESS,
message: "Profile was successfully added.",
message: "Profile was successfully added."
})
);
})
.catch((error) => {
dispatch(
Notify({
status: NotificationType.ERROR,
message: error,
message: error
})
);
})
Expand All @@ -94,7 +94,7 @@ export const ProfilePage = (): ReactElement => {
mentor: profile?.Mentor,
co_mentor: profile?.Co_mentor,
blog: profile?.Blog,
gantt_chart: profile?.Gantt_chart,
gantt_chart: profile?.Gantt_chart
},
validate: (values) => {
const errors: { [key: string]: string } = {};
Expand Down Expand Up @@ -125,7 +125,7 @@ export const ProfilePage = (): ReactElement => {
if (values.co_mentor && !validator.isEmail(values.co_mentor))
errors["co_mentor"] = "Co-mentor email should be a valid email address. " + (errors["co_mentor"] ?? "");
return errors;
},
}
});

const { handleSubmit, touched, errors, values, handleChange, handleBlur, setFieldValue } = formik;
Expand All @@ -140,26 +140,29 @@ export const ProfilePage = (): ReactElement => {
return true;
}
});
const profile: Profile = {
Email_ID: rawProfile[0],
Name: rawProfile[1],
University: rawProfile[2],
Degree: rawProfile[3],
Joined_date: rawProfile[4],
Leaving_date: rawProfile[5],
Contact_no: rawProfile[6],
Mentor: rawProfile[7],
Co_mentor: rawProfile[8],
Blog: rawProfile[9],
Gantt_chart: rawProfile[10],
};

const profile: Profile = rawProfile
? {
Email_ID: rawProfile[0],
Name: rawProfile[1],
University: rawProfile[2],
Degree: rawProfile[3],
Joined_date: rawProfile[4],
Leaving_date: rawProfile[5],
Contact_no: rawProfile[6],
Mentor: rawProfile[7],
Co_mentor: rawProfile[8],
Blog: rawProfile[9],
Gantt_chart: rawProfile[10]
}
: null;
setProfile(profile);
})
.catch((error) => {
dispatch(
Notify({
status: NotificationType.ERROR,
message: error,
message: error
})
);
})
Expand Down Expand Up @@ -260,7 +263,7 @@ export const ProfilePage = (): ReactElement => {
setFieldValue("joined_date", date);
}}
KeyboardButtonProps={{
"aria-label": "change date",
"aria-label": "change date"
}}
error={!!(touched.joined_date && errors.joined_date)}
/>
Expand All @@ -286,7 +289,7 @@ export const ProfilePage = (): ReactElement => {
setFieldValue("leaving_date", date);
}}
KeyboardButtonProps={{
"aria-label": "change date",
"aria-label": "change date"
}}
value={values.leaving_date}
helperText={touched.leaving_date && errors.leaving_date && errors.leaving_date}
Expand Down

0 comments on commit 1fb0d27

Please sign in to comment.