️ This Gitlab will be shut down at 2021-12-31 23:59:59.
Students and staff can migrate to gitlab.utwente.nl.
SNT members can migrate to gitlab.snt.utwente.nl.
Contact bestuur@snt.utwente.nl for more information.

Migrate your projects today!
Export your project using the webinterface or use a script.

Commit c255d5b5 authored by TJHeeringa's avatar TJHeeringa

Fixed studies and persisted profile update

parent 8ea3f0a7
......@@ -83,18 +83,10 @@ const ProfileFormWithoutContainer = ({ update, profile, onSuccess, disabled, han
});
const handleSubmit = (event, values) => {
const new_profile = {...profile};
if (new_profile.study !== undefined) {
if (new_profile.study !== null) {
new_profile.study = new_profile.study.url;
}
} else {
delete new_profile.study;
}
if (update) {
patchProfile(new_profile);
patchProfile(profile);
} else {
postProfile(new_profile);
postProfile(profile);
}
};
......@@ -114,6 +106,7 @@ const ProfileFormWithoutContainer = ({ update, profile, onSuccess, disabled, han
};
const patchProfile = (profile) => {
console.log(profile);
return API.callv3({
url: profile.url,
method: "PATCH",
......@@ -135,7 +128,7 @@ const ProfileFormWithoutContainer = ({ update, profile, onSuccess, disabled, han
// };
//
console.log(studies, profile.study);
const country = useMemo(()=>countries.find(country=>profile.country === country.label),[profile.country])
const country = useMemo(()=>countries.find(country=>profile.country === country.label),[profile.country]);
return (
<ValidatorForm
......
......@@ -8,8 +8,7 @@ const ProfileInfo = ({ profile }) => {
const StudiesApi = useStudies();
const data = useMemo(()=>{
let study = profile.study ? profile.study.name : "Unknown";
console.log(study, profile.study, StudiesApi.collection);
let study = profile.study ? profile.study.name : "Not Listed";
if (StudiesApi.collection && StudiesApi.collection.length > 0) {
study = study || StudiesApi.collection.find(existing_study => existing_study.url === profile.study).name;
}
......
......@@ -8,6 +8,7 @@ import {useGet} from "restful-react";
import { Profile } from "../../Components/InfoForms/Profile";
import Block from "../../Components/PageLayout/Content/Block";
import API, {useAPI} from "../../Contexts/API";
const useStyles = makeStyles(theme=>({
......@@ -22,6 +23,7 @@ const useStyles = makeStyles(theme=>({
const SharedProfile = ({ preferred_profile: propProfile }) => {
const classes = useStyles();
const API = useAPI();
let { data: profile, loading: loadingProfile } = useGet({
path: "/profiles/" + propProfile.slug,
......@@ -61,6 +63,7 @@ const SharedProfile = ({ preferred_profile: propProfile }) => {
update={true}
disabled={false}
container={false}
onSuccess={(profile)=>API.refetch()}
/>
}
</Block>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment