add frontend files

This commit is contained in:
João Geonizeli
2021-08-04 00:08:22 -03:00
parent 72e4c29612
commit 8d089c0b7a
32 changed files with 4850 additions and 91 deletions

View File

@@ -0,0 +1,28 @@
import React, { createContext, Dispatch, FC, SetStateAction, useContext, useState } from 'react'
export type AppContext = {
setSideNavExpanded: Dispatch<SetStateAction<boolean>>
sideNavExpanded: boolean
}
const Context = createContext<AppContext | null>(null)
export const useAppContext = (): AppContext => {
const context = useContext(Context);
if (context === null) {
throw new Error("You probably forgot to put <AppContext>.");
}
return context;
};
export const AppContext: FC = ({ children }) => {
const [sideNavExpanded, setSideNavExpanded] = useState(false)
return (
<Context.Provider value={{ sideNavExpanded, setSideNavExpanded }}>
{children}
</Context.Provider>
)
}

View File

@@ -0,0 +1,22 @@
import { Auth0Provider } from '@auth0/auth0-react'
import React, { FC } from 'react'
export const AuthProvider: FC = ({children}) => {
// @ts-ignore
const domain = window.AUTH_DOMAIN
// @ts-ignore
const clientId = window.AUTH_CLIENT_ID
// @ts-ignore
const audience = window.AUTH_AUDIENCE
return (
<Auth0Provider
domain={domain}
clientId={clientId}
audience={audience}
redirectUri={window.location.origin}
>
{children}
</Auth0Provider>
)
}