diff --git a/backend/services/core/src/datasources/Mandate.ts b/backend/services/core/src/datasources/Mandate.ts index 4224a14a5..e68effd41 100644 --- a/backend/services/core/src/datasources/Mandate.ts +++ b/backend/services/core/src/datasources/Mandate.ts @@ -21,10 +21,6 @@ export default class MandateAPI extends dbUtils.KnexDataSource { return this.withAccess('core:mandate:read', ctx, async () => { const res = (await this.knex('mandates').select('*').where({ id }))[0]; - if (await this.isStabHidden() && STAB_IDS.includes(res.position_id)) { - return undefined; - } - if (!res) { return undefined; } return convertMandate(res); }); @@ -110,14 +106,6 @@ export default class MandateAPI extends dbUtils.KnexDataSource { query = query.andWhereRaw('CURRENT_DATE BETWEEN start_date AND end_date'); } const res = await query; - if (await this.isStabHidden()) { - // if user has an active stab mandate, hide all other mandates - if (res.some((m) => m.end_date > new Date() && STAB_IDS.includes(m.position_id))) { - return []; - } - // otherwise just filter out their old stab mandates - return res.filter((m) => !STAB_IDS.includes(m.position_id)).map(convertMandate); - } return res.map(convertMandate); }); } diff --git a/backend/services/core/src/datasources/Position.ts b/backend/services/core/src/datasources/Position.ts index bcf56379d..3b00d3ae0 100644 --- a/backend/services/core/src/datasources/Position.ts +++ b/backend/services/core/src/datasources/Position.ts @@ -17,10 +17,6 @@ export default class PositionAPI extends dbUtils.KnexDataSource { return undefined; } - if (await this.isStabHidden() && STAB_IDS.includes(position.id)) { - return undefined; - } - if (!position.active) { await this.withAccess('core:position:inactive:read', ctx, async () => { }); } diff --git a/frontend/pages/members/[id]/index.tsx b/frontend/pages/members/[id]/index.tsx index 352dd381c..4f756238d 100644 --- a/frontend/pages/members/[id]/index.tsx +++ b/frontend/pages/members/[id]/index.tsx @@ -1,6 +1,5 @@ import { - Box, - Button, Paper, Stack, Tooltip, + Box, Button, Paper, Stack, Tooltip, } from '@mui/material'; import { i18n, useTranslation } from 'next-i18next'; import { useRouter } from 'next/router'; @@ -20,13 +19,18 @@ import { useMemberPageQuery, usePingMemberMutation } from '~/generated/graphql'; import { useApiAccess } from '~/providers/ApiAccessProvider'; import { useSetPageName } from '~/providers/PageNameProvider'; import UserContext from '~/providers/UserProvider'; -import routes from '~/routes'; import commonPageStyles from '~/styles/commonPageStyles'; +import routes from '~/routes'; +import commonPageStyles from '~/styles/commonPageStyles'; export default function MemberPage() { const router = useRouter(); const id = router.query.id as string; const { user, loading: userLoading } = useContext(UserContext); - const { loading, data: userData, refetch } = useMemberPageQuery({ + const { + loading, + data: userData, + refetch, + } = useMemberPageQuery({ variables: idOrStudentId(id), }); const member = userData?.member; @@ -43,9 +47,7 @@ export default function MemberPage() { const isMe = user?.id === member?.id; useSetPageName( member ? getFullName(member, false) : MEMBER_TEXT, - isMe - ? selectTranslation(i18n, 'Profil', 'Profile') - : MEMBER_TEXT, + isMe ? selectTranslation(i18n, 'Profil', 'Profile') : MEMBER_TEXT, ); if (loading || userLoading) { @@ -61,52 +63,70 @@ export default function MemberPage() { if (!member) { return <>{t('member:memberError')}; } + if ( + member.activeMandates.some( + (m) => m.position.id === 'dsek.noll.stab.mdlm', + ) + && member.id !== user?.id + && !hasAccess('nolla:admin') + ) { + return <>{t('member:memberError')}; + } return ( - - + + {(member.id === user?.id || hasAccess('core:member:update')) && ( - - - - - - - - - )} - {hasAccess('core:member:ping') && (member.id !== user?.id ? ( - - - - - - ) : ( - - + + + )} + {hasAccess('core:member:ping') + && (member.id !== user?.id ? ( + - {t('member:myPings')} - - - ))} + + + + + ) : ( + + + + ))}