Skip to content

Commit

Permalink
Create Left Sidebar layout
Browse files Browse the repository at this point in the history
  • Loading branch information
negreirosleo committed Sep 18, 2023
1 parent b0943ba commit ad2aaa8
Show file tree
Hide file tree
Showing 14 changed files with 1,613 additions and 276 deletions.
1,346 changes: 1,333 additions & 13 deletions frontend/package-lock.json

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
"lint": "next lint"
},
"dependencies": {
"@emotion/react": "^11.11.1",
"@emotion/styled": "^11.11.0",
"@fluentui/react-icons": "^2.0.216",
"@mui/joy": "^5.0.0-beta.6",
"@types/node": "20.6.0",
"@types/react": "18.2.21",
"@types/react-dom": "18.2.7",
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/app/auth/AuthProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
'use client'

import { AuthProvider as AuthProviderLib } from 'react-oidc-context'
import type { AuthProviderProps } from 'react-oidc-context'

const oidcConfig = {
const oidcConfig: AuthProviderProps = {
authority: process.env.NEXT_PUBLIC_OIDC_AUTHORITY || '',
client_id: process.env.NEXT_PUBLIC_OIDC_CLIENT_ID || '',
client_secret: process.env.NEXT_PUBLIC_OIDC_CLIENT_SECRET,
Expand Down
35 changes: 35 additions & 0 deletions frontend/src/app/auth/AuthorizedPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
'use client'

import { useEffect } from 'react'
import { useAuth, hasAuthParams } from 'react-oidc-context'

export const AuthorizedPage = ({ children }: { children: React.ReactNode }) => {
const { isAuthenticated, signinRedirect, activeNavigator, error, isLoading } = useAuth()

useEffect(() => {
if (!isAuthenticated && !hasAuthParams()) {
signinRedirect()
}
}, [isAuthenticated, signinRedirect])

switch (activeNavigator) {
case 'signinSilent':
return <div>Signing you in...</div>
case 'signoutRedirect':
return <div>Signing you out...</div>
}

if (isLoading) {
return <div>Loading...</div>
}

if (error) {
return <div>Oops... {error.message}</div>
}

if (!isAuthenticated) {
return <button onClick={() => signinRedirect()}>BOTAO</button>
}

return children
}
1 change: 1 addition & 0 deletions frontend/src/app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ body {
}

body {
display: flex;
color: rgb(var(--foreground-rgb));
background: linear-gradient(
to bottom,
Expand Down
21 changes: 16 additions & 5 deletions frontend/src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import './globals.css'
import type { Metadata } from 'next'
import { Inter } from 'next/font/google'
import { AuthProvider } from './auth/AuthProvider'
import localFont from 'next/font/local'
import { AuthProvider } from '@/app/auth/AuthProvider'
import { Sidebar } from '@/ui/sidebar/Sidebar'
import { CssVarsProvider } from '@mui/joy/styles'
import { theme } from '@/ui/theme'

const inter = Inter({ subsets: ['latin'] })
const monaSans = localFont({
src: '../assets/fonts/Mona-Sans.woff2',
display: 'swap'
})

export const metadata: Metadata = {
title: 'PhpReport',
Expand All @@ -13,8 +19,13 @@ export const metadata: Metadata = {
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html lang="en">
<body className={inter.className}>
<AuthProvider>{children}</AuthProvider>
<body className={monaSans.className}>
<AuthProvider>
<CssVarsProvider theme={theme}>
<Sidebar />
{children}
</CssVarsProvider>
</AuthProvider>
</body>
</html>
)
Expand Down
229 changes: 0 additions & 229 deletions frontend/src/app/page.module.css

This file was deleted.

34 changes: 6 additions & 28 deletions frontend/src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,31 +1,9 @@
'use client'

import { useEffect } from 'react'
import { useAuth, hasAuthParams } from 'react-oidc-context'
import styles from './page.module.css'
import { AuthorizedPage } from '@/app/auth/AuthorizedPage'

export default function Home() {
const auth = useAuth()

useEffect(() => {
if (!hasAuthParams() && !auth.isAuthenticated && !auth.activeNavigator && !auth.isLoading) {
auth.signinRedirect()
}
}, [auth.isAuthenticated, auth.activeNavigator, auth.isLoading, auth.signinRedirect, auth])

switch (auth.activeNavigator) {
case 'signinSilent':
return <div>Signing you in...</div>
case 'signoutRedirect':
return <div>Signing you out...</div>
}

if (auth.isLoading) {
return <div>Loading...</div>
}

if (auth.error) {
return <div>Oops... {auth.error.message}</div>
}
return <main className={styles.main}>Testing auth</main>
return (
<AuthorizedPage>
<main>Testing auth</main>
</AuthorizedPage>
)
}
Binary file added frontend/src/assets/fonts/Mona-Sans.woff2
Binary file not shown.
Binary file added frontend/src/assets/images/full_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/src/assets/images/small_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit ad2aaa8

Please sign in to comment.