Skip to content

Commit eff4b86

Browse files
authored
Update partner admin authguard to check whether partner admin is active (chaynHQ#939)
* Update PartnerAdmin interface and initial store state * Run a check against the partner admin active status in the guard * Restore lates base changes
1 parent 6c557c3 commit eff4b86

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

app/partnerAdminSlice.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ import { api, GetUserResponse } from './api';
44

55
export interface PartnerAdmin {
66
id: string | null;
7+
active: boolean | null;
78
createdAt: Date | null;
89
updatedAt: Date | null;
910
partner: PartnerContent | null;
1011
}
1112

1213
const initialState: PartnerAdmin = {
1314
id: null,
15+
active: null,
1416
createdAt: null,
1517
updatedAt: null,
1618
partner: null,

guards/partnerAdminGuard.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Container, Typography } from '@mui/material';
22
import { Box } from '@mui/system';
33
import Head from 'next/head';
4-
import Image from "next/image";
4+
import Image from 'next/image';
55
import { useTranslations } from 'use-intl';
66
import Link from '../components/common/Link';
77
import { useTypedSelector } from '../hooks/store';
@@ -22,11 +22,12 @@ const imageContainerStyle = {
2222

2323
export function PartnerAdminGuard({ children }: { children: JSX.Element }) {
2424
const partnerAdminId = useTypedSelector((state) => state.partnerAdmin.id);
25+
const partnerAdminIsActive = useTypedSelector((state) => state.partnerAdmin.active);
2526

2627
const t = useTranslations('PartnerAdmin.accessGuard');
2728
const tS = useTranslations('Shared');
2829

29-
if (!partnerAdminId) {
30+
if (!partnerAdminId || !partnerAdminIsActive) {
3031
return (
3132
<Container sx={containerStyle}>
3233
<Head>{t('title')}</Head>
@@ -37,8 +38,9 @@ export function PartnerAdminGuard({ children }: { children: JSX.Element }) {
3738
fill
3839
sizes="100vw"
3940
style={{
40-
objectFit: "contain"
41-
}} />
41+
objectFit: 'contain',
42+
}}
43+
/>
4244
</Box>
4345
<Typography variant="h2" component="h2" mb={2}>
4446
{t('title')}

0 commit comments

Comments
 (0)