️ 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 4555d156 authored by TJHeeringa's avatar TJHeeringa

Minor fixes

parent 81b91b6b
......@@ -61,6 +61,10 @@ const prependKeys = (prefactor, obj) =>
{}
);
const interleave = ([ x, ...xs ], ys = []) =>
x === undefined
? ys // base: no x
: [ x, ...interleave (ys, xs) ]; // inductive: some x
const Matchings = ({ association }) => {
const classes = useStyles();
......@@ -284,7 +288,7 @@ const Matchings = ({ association }) => {
const base_headers = deriveMemberTableHeadersFromDataFields(data_fields);
const left_headers = base_headers.map(({name: name, title: title}) => ({name: "left_"+name, title: "Left "+title}));
const right_headers = base_headers.map(({name: name, title: title}) => ({name: "right_"+name, title: "Right "+title}));
return left_headers.concat(right_headers).concat({name: "email_send", title: "Got email"});
return interleave(left_headers, right_headers).concat({name: "email_send", title: "Got email"});
}, [data_fields]);
const defaultHiddenColumnNames = useMemo(()=>{
const base_headers = ["given_name", "surname", "email", "type"].concat(data_fields.map(field=>field.name));
......@@ -403,35 +407,35 @@ const Matchings = ({ association }) => {
custom_miscelaneous_plugins={custom_miscelaneous_plugins}
/>
</Block>
<Container>
<Block>
<Row>
<Col>
<Typography variant={"h4"}>Matchings</Typography>
</Col>
<Col>
<div className={"text-right"}>
<Button color={"secondary"} variant={"outlined"} onClick={openModal} disabled={!allowEmailModal}>
Email
</Button>
&nbsp;
<Button variant={"outlined"} onClick={toggleShowMatches}>
{ show ? "Hide Matches" : "Show Matches" }
</Button>
</div>
</Col>
</Row>
<hr className={"box-title-separator"}/>
<div style={{display: show ? "block" : "none"}}>
<EnhancedTable
headers={["name", "name"]}
rows={matches || []}
filterProperties={["left_name", "right_name"]}
onDelete={onDelete}
/>
</div>
</Block>
</Container>
{/*<Container>*/}
{/* <Block>*/}
{/* <Row>*/}
{/* <Col>*/}
{/* <Typography variant={"h4"}>Matchings</Typography>*/}
{/* </Col>*/}
{/* <Col>*/}
{/* <div className={"text-right"}>*/}
{/* <Button color={"secondary"} variant={"outlined"} onClick={openModal} disabled={!allowEmailModal}>*/}
{/* Email*/}
{/* </Button>*/}
{/* &nbsp;*/}
{/* <Button variant={"outlined"} onClick={toggleShowMatches}>*/}
{/* { show ? "Hide Matches" : "Show Matches" }*/}
{/* </Button>*/}
{/* </div>*/}
{/* </Col>*/}
{/* </Row>*/}
{/* <hr className={"box-title-separator"}/>*/}
{/* <div style={{display: show ? "block" : "none"}}>*/}
{/* <EnhancedTable*/}
{/* headers={["name", "name"]}*/}
{/* rows={matches || []}*/}
{/* filterProperties={["left_name", "right_name"]}*/}
{/* onDelete={onDelete}*/}
{/* />*/}
{/* </div>*/}
{/* </Block>*/}
{/*</Container>*/}
<Row>
<Col className={classes.column}>
<MemberList
......
// function PostsList() {
// const { data: posts } = api.useGetPostsQuery()
//
// return (
// <ul>
// {posts?.data?.map((post) => (
// <PostById key={post.id} id={post.id} />
// ))}
// </ul>
// )
// }
//
// function PostById({ id }: { id: number }) {
// // Will select the post with the given id, and will only rerender if the given posts data changes
// const { post } = api.useGetPostsQuery(undefined, {
// selectFromResult: ({ data }) => ({
// post: data?.find((post) => post.id === id),
// }),
// })
//
// return <li>{post?.name}</li>
// }
......@@ -31,6 +31,7 @@ const providesListTags = (resultsWithIds, tagType, listTag) => {
// initialize an empty api service that we'll inject endpoints into later as needed
const emptySplitApi = createApi({
reducerPath: "api",
keepUnusedDataFor: 30 * 60,
baseQuery: baseQuery,
endpoints: () => ({}),
});
......
......@@ -28,5 +28,10 @@ const newsApi = emptySplitApi
overrideExisting: false
});
export const { useGetNewsByAssociationQuery, useAddNewsMutation, usePatchNewsMutation, useDeleteNewsMutation } = newsApi;
export const {
useGetNewsByAssociationQuery,
useAddNewsMutation,
usePatchNewsMutation,
useDeleteNewsMutation
} = newsApi;
export default newsApi;
\ No newline at end of file
......@@ -7,13 +7,38 @@ const userDataApi = emptySplitApi
getUserData: build.query({
query: () => ({ url: "/users/me", params: { expand: "profiles"} }),
providesTags: [{ type: "User" }],
transformResponse: (response) => {
return response;
}
transformResponse: (sunmember) => ({
...sunmember,
preferred_profile: sunmember.profiles.find(profile=>profile.url === sunmember.preferred_profile),
association_memberships: sunmember.association_memberships.map(association_membership=>({
...association_membership,
profile: sunmember.profiles.find(profile=>profile.url === association_membership.profile.url)
}))
})
}),
}),
overrideExisting: false
});
const usePreferredProfile = () => {
const { preferred_profile } = useGetUserDataQuery(undefined, {
selectFromResult: ({ data }) => ({
preferred_profile: data?.preferred_profile,
}),
});
return preferred_profile;
};
const useMemberships = () => {
const { association_memberships } = useGetUserDataQuery(undefined, {
selectFromResult: ({ data }) => ({
association_memberships: data?.association_memberships,
}),
});
return association_memberships;
};
export { usePreferredProfile, useMemberships };
export const { useGetUserDataQuery } = userDataApi;
export default userDataApi;
\ No newline at end of file
export default userDataApi;
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