️ 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 680b3eb6 authored by TJHeeringa's avatar TJHeeringa

Fixed couple of bugs in/with MemberTables

parent 25a5b107
......@@ -768,6 +768,7 @@ const ExtremeTable = ({ headers, rows, getRowId, defaultSorting, defaultFilters,
grouping={grouping}
selection={selection}
onSave={onSave}
getRowId={getRowId}
/>
}
</Paper>
......
import React from "react";
import React, {useState} from "react";
import {useHistory} from "react-router-dom";
import MemberTable from "../../Components/Tables/MemberTable";
......@@ -8,10 +8,12 @@ const MembersCurrent = ({ association }) => {
const { members } = useCurrentMembers(association.slug);
const history = useHistory();
const [selection, setSelection] = useState([]);
const onDetail = (clicked) => history.push(clicked);
return (
<MemberTable
selection={{selection: selection, setSelection:setSelection}}
association={association}
allowEdit={false}
allowDelete={true}
......
......@@ -50,7 +50,10 @@ const MembersIncoming = ({ association }) => {
const onEdit = (differences, original_row, edited_row, edited_row_index) => {
acceptOrDenyMembership({slug: original_row.slug, status: edited_row.status});
acceptOrDenyMembership({
slug: original_row.urls.membership.split("/memberships/")[1],
status: edited_row.status
});
};
return (
......
......@@ -52,7 +52,10 @@ const MembersLeaving = ({ association }) => {
const onEdit = (differences, original_row, edited_row, edited_row_index) => {
updateMembership({slug: original_row.slug, financial_obligations_satisfied: edited_row.financial_obligations_satisfied });
updateMembership({
slug: original_row.urls.membership.split("/memberships/")[1],
financial_obligations_satisfied: edited_row.financial_obligations_satisfied
});
};
return (
......
......@@ -57,6 +57,18 @@ const membersApi = emptySplitApi
acceptOrDenyMembership: build.mutation({
query: ({ slug, status }) => ({ url: `/memberships/${slug}`, method: "PATCH", body: {status: status} }),
invalidatesTags: (result) => [{ type: "Member", id: result.association.split("/associations/")[1] }],
async onQueryStarted({ slug }, { dispatch, queryFulfilled }) {
try {
const { data: patchedMembership } = await queryFulfilled;
dispatch(
membersApi.util.updateQueryData("getMembersByAssociationAndStatus", {associationSlug: patchedMembership.association.split("/associations/")[1], status: "Pending"}, (draftMemberships) => {
const index = draftMemberships.findIndex(draftGroupMembership => draftGroupMembership.slug === slug);
draftMemberships.splice(index, 1);
})
);
// eslint-disable-next-line no-empty
} catch {}
}
}),
}),
overrideExisting: false
......
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