Skip to content

Commit

Permalink
Merge pull request #18 from bcgov/feature/ES-207-account-admin-login
Browse files Browse the repository at this point in the history
Feature/es 207 account admin login
  • Loading branch information
nitheesh-aot authored Jul 29, 2024
2 parents d596455 + dd8bb47 commit a51c82b
Show file tree
Hide file tree
Showing 14 changed files with 7,435 additions and 2,226 deletions.
9,357 changes: 7,164 additions & 2,193 deletions submit-web/package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion submit-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"@tanstack/router-devtools": "^1.45.7",
"@tanstack/router-plugin": "^1.45.7",
"axios": "^1.7.2",
"epic.theme": "^1.0.3",
"epic.theme": "^1.0.4",
"keycloak-js": "^25.0.1",
"oidc-client-ts": "^3.0.1",
"react": "^18.2.0",
Expand Down
2 changes: 1 addition & 1 deletion submit-web/src/App.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ describe("<App />", () => {
// add other necessary mocks here
};
mount(<TestApp authentication={mockAuth} />);
cy.contains("Users");
cy.contains("Sign In");
});
});
21 changes: 13 additions & 8 deletions submit-web/src/components/Shared/EAOAppBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ export default function EAOAppBar() {
{AppConfig.appTitle}
</Typography>
</Grid>
<Grid display="flex" justifyContent="center" alignItems="center" paddingRight={"0.75rem"}>
<AccountCircleIcon
fontSize="large"
color="primary"
sx={{ marginRight: "0.25rem" }}
></AccountCircleIcon>
<Grid
display="flex"
justifyContent="center"
alignItems="center"
paddingRight={"0.75rem"}
>
{auth.isAuthenticated ? (
<>
<Box
Expand All @@ -48,7 +48,7 @@ export default function EAOAppBar() {
</Typography>
</Box>
<Button
variant="outlined"
variant="text"
color="primary"
onClick={() => auth.signoutRedirect()}
>
Expand All @@ -57,13 +57,18 @@ export default function EAOAppBar() {
</>
) : (
<Button
variant="outlined"
variant="text"
color="primary"
onClick={() => auth.signinRedirect()}
>
Sign In
</Button>
)}
<AccountCircleIcon
fontSize="large"
color="inherit"
sx={{ marginLeft: "0.25rem" }}
></AccountCircleIcon>
</Grid>
</Grid>
</AppBar>
Expand Down
1 change: 0 additions & 1 deletion submit-web/src/components/Shared/layout/Footer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const Footer = () => {
justifyContent="center"
alignItems="center"
spacing={0}
mt="2em"
>
<Grid
item
Expand Down
121 changes: 119 additions & 2 deletions submit-web/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ import { Route as rootRoute } from './routes/__root'
import { Route as OidcCallbackImport } from './routes/oidc-callback'
import { Route as AuthenticatedImport } from './routes/_authenticated'
import { Route as IndexImport } from './routes/index'
import { Route as EaoPlansIndexImport } from './routes/eao-plans/index'
import { Route as EaoPlansPlanIdImport } from './routes/eao-plans/$planId'
import { Route as AuthenticatedProfileImport } from './routes/_authenticated/profile'
import { Route as AuthenticatedAdminLoginImport } from './routes/_authenticated/admin-login'
import { Route as AuthenticatedUsersIndexImport } from './routes/_authenticated/users/index'
import { Route as AuthenticatedRegistrationCreateAccountImport } from './routes/_authenticated/registration/create-account'

// Create Virtual Routes

Expand Down Expand Up @@ -49,6 +55,37 @@ const IndexRoute = IndexImport.update({
getParentRoute: () => rootRoute,
} as any)

const EaoPlansIndexRoute = EaoPlansIndexImport.update({
path: '/eao-plans/',
getParentRoute: () => rootRoute,
} as any)

const EaoPlansPlanIdRoute = EaoPlansPlanIdImport.update({
path: '/eao-plans/$planId',
getParentRoute: () => rootRoute,
} as any)

const AuthenticatedProfileRoute = AuthenticatedProfileImport.update({
path: '/profile',
getParentRoute: () => AuthenticatedRoute,
} as any)

const AuthenticatedAdminLoginRoute = AuthenticatedAdminLoginImport.update({
path: '/admin-login',
getParentRoute: () => AuthenticatedRoute,
} as any)

const AuthenticatedUsersIndexRoute = AuthenticatedUsersIndexImport.update({
path: '/users/',
getParentRoute: () => AuthenticatedRoute,
} as any)

const AuthenticatedRegistrationCreateAccountRoute =
AuthenticatedRegistrationCreateAccountImport.update({
path: '/registration/create-account',
getParentRoute: () => AuthenticatedRoute,
} as any)

// Populate the FileRoutesByPath interface

declare module '@tanstack/react-router' {
Expand Down Expand Up @@ -88,16 +125,66 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof NewpageLazyImport
parentRoute: typeof rootRoute
}
'/_authenticated/admin-login': {
id: '/_authenticated/admin-login'
path: '/admin-login'
fullPath: '/admin-login'
preLoaderRoute: typeof AuthenticatedAdminLoginImport
parentRoute: typeof AuthenticatedImport
}
'/_authenticated/profile': {
id: '/_authenticated/profile'
path: '/profile'
fullPath: '/profile'
preLoaderRoute: typeof AuthenticatedProfileImport
parentRoute: typeof AuthenticatedImport
}
'/eao-plans/$planId': {
id: '/eao-plans/$planId'
path: '/eao-plans/$planId'
fullPath: '/eao-plans/$planId'
preLoaderRoute: typeof EaoPlansPlanIdImport
parentRoute: typeof rootRoute
}
'/eao-plans/': {
id: '/eao-plans/'
path: '/eao-plans'
fullPath: '/eao-plans'
preLoaderRoute: typeof EaoPlansIndexImport
parentRoute: typeof rootRoute
}
'/_authenticated/registration/create-account': {
id: '/_authenticated/registration/create-account'
path: '/registration/create-account'
fullPath: '/registration/create-account'
preLoaderRoute: typeof AuthenticatedRegistrationCreateAccountImport
parentRoute: typeof AuthenticatedImport
}
'/_authenticated/users/': {
id: '/_authenticated/users/'
path: '/users'
fullPath: '/users'
preLoaderRoute: typeof AuthenticatedUsersIndexImport
parentRoute: typeof AuthenticatedImport
}
}
}

// Create and export the route tree

export const routeTree = rootRoute.addChildren({
IndexRoute,
AuthenticatedRoute: AuthenticatedRoute.addChildren({
AuthenticatedAdminLoginRoute,
AuthenticatedProfileRoute,
AuthenticatedRegistrationCreateAccountRoute,
AuthenticatedUsersIndexRoute,
}),
OidcCallbackRoute,
AboutpageLazyRoute,
NewpageLazyRoute,
EaoPlansPlanIdRoute,
EaoPlansIndexRoute,
})

/* prettier-ignore-end */
Expand All @@ -112,14 +199,22 @@ export const routeTree = rootRoute.addChildren({
"/_authenticated",
"/oidc-callback",
"/aboutpage",
"/newpage"
"/newpage",
"/eao-plans/$planId",
"/eao-plans/"
]
},
"/": {
"filePath": "index.tsx"
},
"/_authenticated": {
"filePath": "_authenticated.tsx"
"filePath": "_authenticated.tsx",
"children": [
"/_authenticated/admin-login",
"/_authenticated/profile",
"/_authenticated/registration/create-account",
"/_authenticated/users/"
]
},
"/oidc-callback": {
"filePath": "oidc-callback.tsx"
Expand All @@ -129,6 +224,28 @@ export const routeTree = rootRoute.addChildren({
},
"/newpage": {
"filePath": "newpage.lazy.tsx"
},
"/_authenticated/admin-login": {
"filePath": "_authenticated/admin-login.tsx",
"parent": "/_authenticated"
},
"/_authenticated/profile": {
"filePath": "_authenticated/profile.tsx",
"parent": "/_authenticated"
},
"/eao-plans/$planId": {
"filePath": "eao-plans/$planId.tsx"
},
"/eao-plans/": {
"filePath": "eao-plans/index.tsx"
},
"/_authenticated/registration/create-account": {
"filePath": "_authenticated/registration/create-account.tsx",
"parent": "/_authenticated"
},
"/_authenticated/users/": {
"filePath": "_authenticated/users/index.tsx",
"parent": "/_authenticated"
}
}
}
Expand Down
17 changes: 5 additions & 12 deletions submit-web/src/routes/__root.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import EAOAppBar from "@/components/Shared/EAOAppBar";
import Footer from "@/components/Shared/layout/Footer";
import PageNotFound from "@/components/Shared/PageNotFound";
import SideNavBar from "@/components/Shared/SideNavBar";
import { Box } from "@mui/system";
import { createRootRouteWithContext, Outlet } from "@tanstack/react-router";
import { TanStackRouterDevtools } from "@tanstack/router-devtools";
Expand All @@ -20,19 +19,13 @@ function Layout() {
return (
<>
<EAOAppBar />
<Box display={"flex"}>
<SideNavBar />
<Box
display={"flex"}
flexDirection={"column"}
flex={1}
padding={"1rem"}
>
<Outlet />
</Box>
<Box
height={"calc(100vh - 88px)"}
>
<Outlet />
</Box>
<Footer />
<TanStackRouterDevtools />
<TanStackRouterDevtools position="bottom-right" />
</>
);
}
7 changes: 5 additions & 2 deletions submit-web/src/routes/_authenticated.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ import { createFileRoute } from '@tanstack/react-router'

export const Route = createFileRoute('/_authenticated')({
beforeLoad: ({ context }) => {
const { isAuthenticated, signinRedirect } = context.authentication;
if (!isAuthenticated) {
const { isAuthenticated, signinRedirect, isLoading } = context.authentication;
// eslint-disable-next-line no-console
console.log(isAuthenticated, isLoading);

if (!isLoading && !isAuthenticated) {
signinRedirect();
}
},
Expand Down
7 changes: 7 additions & 0 deletions submit-web/src/routes/_authenticated/admin-login.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { createFileRoute } from '@tanstack/react-router'

/** This url will be given to Entity Account Admins via link sent by EAO with Business BCeid. */

export const Route = createFileRoute('/_authenticated/admin-login')({
component: () => <div>TODO: if isAuthenticated then redirect to home page, otherwise navigate to login again.</div>
})
Loading

0 comments on commit a51c82b

Please sign in to comment.