Commit 904fa02a authored by TJHeeringa's avatar TJHeeringa

Fix study on Profile

parent 7be4e921
......@@ -9,12 +9,12 @@ import TextInfoContent from "@mui-treasury/components/content/textInfo";
import { useOverShadowStyles } from "@mui-treasury/styles/shadow/over";
import { useBlogTextInfoContentStyles } from "@mui-treasury/styles/textInfoContent/blog";
import cx from "clsx";
import Image from "img/default_photo.jpg"; // Import using relative path
import PropTypes from "prop-types";
import React from "react";
import LinesEllipsis from "react-lines-ellipsis";
import { loremIpsum } from "react-lorem-ipsum";
import { useHistory } from "react-router-dom";
import Image from "img/default_photo.jpg"; // Import using relative path
import Info from "../Info/Info";
......@@ -72,17 +72,12 @@ const useStyles = makeStyles(theme => ({
},
}));
const AssociationCard = (props) => {
const AssociationCard = ({ name, description, photo, slug, onBecomeMemberClick, becomeMemberButton }) => {
const styles = useStyles();
let history = useHistory();
const {
button: buttonStyles,
...contentStyles
} = useBlogTextInfoContentStyles();
const shadowStyles = useOverShadowStyles();
const { name, description, photo, slug, onBecomeMemberClick, becomeMemberButton } = props;
console.log(description);
const text = description || loremIpsum()[0];
return (
......@@ -106,7 +101,7 @@ const AssociationCard = (props) => {
<Divider/>
<div className={styles.buttonSeparator}>
<Button variant={"contained"} color={"primary"} onClick={()=>history.push("/protected/associations/" + slug + "/info")}>Read more</Button>
{becomeMemberButton && <Button variant={"contained"} color={"primary"} onClick={onBecomeMemberClick}>Become Member</Button>}
{ becomeMemberButton && <Button variant={"contained"} color={"primary"} onClick={onBecomeMemberClick}>Become Member</Button> }
</div>
</CardContent>
</Card>
......
......@@ -3,11 +3,11 @@ import Container from "@material-ui/core/Container";
import MenuItem from "@material-ui/core/MenuItem";
import Typography from "@material-ui/core/Typography";
import { Osiris } from "App/Components/Forms/Osiris";
import { getBIC } from "bic-from-iban";
import PropTypes from "prop-types";
import React, {useEffect} from "react";
import { ValidatorForm } from "react-material-ui-form-validator";
import { useGet } from "restful-react";
import { getBIC } from "bic-from-iban";
import { useAlertHandler} from "../../Contexts/AlertHandler";
import {useAPI} from "../../Contexts/API";
......@@ -82,10 +82,18 @@ 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(profile);
patchProfile(new_profile);
} else {
postProfile(profile);
postProfile(new_profile);
}
};
......@@ -107,7 +115,8 @@ const ProfileFormWithoutContainer = ({ update, profile, onSuccess, disabled, han
const patchProfile = (profile) => {
return API.callv3({
url: profile.url,
method: "PUT",
method: "PATCH",
// object: {study: null},
object: profile,
on_succes: () => {
alerthandler.handleAlertHandler("green", "Save successful");
......@@ -118,6 +127,15 @@ const ProfileFormWithoutContainer = ({ update, profile, onSuccess, disabled, han
});
};
const urlToStudy = (url) => {
console.log(url);
studies.find(study=>study.url===url);
return url !== "" ? studies.find(study=>study.url===url) : null;
};
console.log(profile.study);
console.log(profile.study ? profile.study.url : profile.study);
console.log(profile);
return (
<ValidatorForm
onSubmit={handleSubmit}
......@@ -235,14 +253,6 @@ const ProfileFormWithoutContainer = ({ update, profile, onSuccess, disabled, han
required
/>
</Wrapper>
{/*<Wrapper>*/}
{/* <TextField*/}
{/* name={"BIC"}*/}
{/* value={profile.iban && getBIC(profile.iban)}*/}
{/* helperText={"This will be derived from your IBAN. This will be entered automatically when the IBAN is valid."}*/}
{/* disabled*/}
{/* />*/}
{/*</Wrapper>*/}
<Typography variant={"h5"}>Education</Typography>
<Wrapper>
<SelectField
......@@ -258,11 +268,12 @@ const ProfileFormWithoutContainer = ({ update, profile, onSuccess, disabled, han
<Wrapper>
<SelectField
name={"Study"}
value={profile.study}
onChange={(event) => handleProfileChange("study", event.target.value)}
value={profile.study ? profile.study.url : profile.study}
onChange={(event) => handleProfileChange("study", urlToStudy(event.target.value))}
required
disabled={disabled}
>
<MenuItem value={null}>Not Listed</MenuItem>
{/*<MenuItem value={""}>Not Listed</MenuItem>*/}
{ studies && studies.map((study, s) =>
<MenuItem key={s} value={study.url}>{ study.studycode } -- { study.name_en }</MenuItem>
) }
......
......@@ -23,11 +23,10 @@ const ProfileInfo = ({ profile }) => {
};
data["Financial"] = {
"IBAN:": profile.iban,
// "BIC": profile.bic_code
};
data["Education"] = {
"Phase:": profile.is_master ? "Master" : "Bachelor",
"Study": profile.study
"Study": profile.study.name_en
};
return data;
};
......
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