Commit bce15abd authored by TJHeeringa's avatar TJHeeringa

Fixed weird behavior after update of membertypes

parent c6219c4e
......@@ -211,10 +211,12 @@ export const AssociationMembertypes = ({ association }) => {
const [membertypes, setMembertypes] = useState([]);
console.log(membertypes);
const getAssociationMembertypes = () => {
API.callv4({
url: "/membertypes",
queryParams: {ordering: "name", association__slug: association.slug},
queryParams: {association__slug: association.slug},
method: "GET",
on_succes: (response)=>{
setMembertypes(response.results);
......@@ -226,11 +228,11 @@ export const AssociationMembertypes = ({ association }) => {
};
// eslint-disable-next-line react-hooks/exhaustive-deps
useEffect(()=>getAssociationMembertypes(), ["on mount only"]);
useEffect(getAssociationMembertypes, ["on mount only"]);
const addMembertype = (membertype) => setMembertypes(prevState => prevState.concat(membertype));
const editMembertype = (edited_membertype) => setMembertypes(prevState =>
prevState.map(membertype=>membertype.slug === edited_membertype.slug ? edited_membertype : membertype)
prevState.map(membertype=>membertype.url === edited_membertype.url ? edited_membertype : membertype)
);
return (
......
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