generated from KyleKlus/home-page-template
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
93 changed files
with
27,143 additions
and
1,634 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
/** @format */ | ||
import styles from '@/styles/components/Layout.module.css'; | ||
|
||
import Head from 'next/head'; | ||
import Footer from '@/components/footer/Footer'; | ||
import dynamic from 'next/dynamic'; | ||
import Main from '@/components/Main'; | ||
import { RedirectPathOptions, redirectPaths, useAuth } from '@/context/AuthContext'; | ||
import Content from './Content'; | ||
import { useRouter } from 'next/router'; | ||
import { useUserDB } from '@/context/UserDatabaseContext'; | ||
import { IYearDataBaseContext, useYearDB } from '@/context/YearDatabaseContext'; | ||
import { IMonthDataBaseContext, useMonthDB } from '@/context/MonthDatabaseContext'; | ||
|
||
const ThemeButton = dynamic(() => import('@/components/buttons/ThemeButton'), { | ||
ssr: false, | ||
}); | ||
|
||
interface ILayoutProps { | ||
className?: string | ||
} | ||
|
||
export default function Layout(props: React.PropsWithChildren<ILayoutProps>) { | ||
const authContext = useAuth(); | ||
const userDB = useUserDB(); | ||
const yearDBContext: IYearDataBaseContext = useYearDB(); | ||
const monthDBContext: IMonthDataBaseContext = useMonthDB(); | ||
const router = useRouter(); | ||
|
||
const handleLogout = () => { | ||
authContext.logOut(); | ||
} | ||
|
||
return ( | ||
<> | ||
<Head> | ||
<title>Kyle Klus | Receipt Manager 🧾 - Dashboard</title> | ||
<meta | ||
name="description" | ||
content="Receipt Manager web app" | ||
/> | ||
<meta | ||
name="viewport" | ||
content="width=device-width, initial-scale=1" | ||
/> | ||
<link rel="manifest" href={process.env.basePath + "/manifest.webmanifest"}></link> | ||
<link rel="manifest" href={process.env.basePath + "/manifest.json"}></link> | ||
<link | ||
rel="shortcut icon" | ||
href={process.env.basePath + "/favicon.ico"} | ||
/> | ||
<link | ||
rel="apple-touch-icon" | ||
sizes="180x180" | ||
href={process.env.basePath + "/apple-touch-icon.png"} | ||
/> | ||
<link | ||
rel="icon" | ||
type="image/png" | ||
sizes="32x32" | ||
href={process.env.basePath + "/favicon-32x32.png"} | ||
/> | ||
<link | ||
rel="icon" | ||
type="image/png" | ||
sizes="16x16" | ||
href={process.env.basePath + "/favicon-16x16.png"} | ||
/> | ||
</Head> | ||
<Main> | ||
<Content className={[styles.layoutWrapper].join(' ')}> | ||
<div className={[styles.sideBar].join(' ')}> | ||
<div className={[styles.sideBarTop].join(' ')}> | ||
<button | ||
className={[ | ||
styles.functionButton, | ||
applyCurrentWindowStyle(router.pathname, '/dashboard') | ||
].join(' ')} | ||
onClick={() => { | ||
!isCurrentWindow(router.pathname, '/dashboard') | ||
&& router.push('/dashboard') | ||
}} | ||
>📖</button> | ||
<button | ||
disabled={userDB.activeConnections.length === 0 && isCurrentWindow(router.pathname, redirectPaths[RedirectPathOptions.DashBoardPage]) || true}// TODO: remove after implementation | ||
className={[ | ||
styles.functionButton, | ||
applyCurrentWindowStyle(router.pathname, '/items') | ||
].join(' ')} | ||
onClick={() => { | ||
!isCurrentWindow(router.pathname, '/items') && yearDBContext.currentYear !== undefined && monthDBContext.currentMonth !== undefined | ||
&& router.push({ pathname: '/items', query: { token: userDB.selectedConnection, year: yearDBContext.currentYear.name, month: monthDBContext.currentMonth.name } }) | ||
}} | ||
>📜</button> | ||
<button | ||
disabled={userDB.activeConnections.length === 0 && isCurrentWindow(router.pathname, redirectPaths[RedirectPathOptions.DashBoardPage]) || true}// TODO: remove after implementation | ||
className={[ | ||
styles.functionButton, | ||
applyCurrentWindowStyle(router.pathname, '/statistics') | ||
].join(' ')} | ||
onClick={() => { | ||
!isCurrentWindow(router.pathname, '/statistics') && yearDBContext.currentYear !== undefined && monthDBContext.currentMonth !== undefined | ||
&& router.push({ pathname: '/statistics', query: { token: userDB.selectedConnection, year: yearDBContext.currentYear.name, month: monthDBContext.currentMonth.name } }) | ||
}} | ||
>📈</button> | ||
</div> | ||
<div className={[styles.sideBarBottom].join(' ')}> | ||
<hr /> | ||
<ThemeButton /> | ||
<button className={[styles.sideBarUserButton].join(' ')} onClick={handleLogout}> | ||
{authContext.user && authContext.user.displayName | ||
? authContext.user.displayName[0] | ||
: 'U' | ||
} | ||
</button> | ||
</div> | ||
|
||
</div> | ||
<div className={[styles.layoutContent].join(' ')}> | ||
<div id={'top'}></div> | ||
{props.children} | ||
<Footer /> | ||
</div> | ||
</Content> | ||
</Main> | ||
</> | ||
); | ||
} | ||
|
||
function isCurrentWindow(currentPath: string, buttonPath: string): boolean { | ||
const currentPathName: string = currentPath.split('/').reverse()[0].replace('#', ''); | ||
const buttonPathName: string = buttonPath.split('/').reverse()[0].replace('#', ''); | ||
|
||
return (buttonPathName.length === 0 && currentPathName.length === 0) || | ||
(buttonPathName.length !== 0 && currentPathName.length !== 0 && buttonPathName.indexOf(currentPathName) !== -1); | ||
} | ||
|
||
function applyCurrentWindowStyle(currentPath: string, buttonPath: string): string { | ||
return isCurrentWindow(currentPath, buttonPath) | ||
? styles.isCurrentWindow | ||
: ''; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/** @format */ | ||
import styles from '@/styles/components/Modal.module.css'; | ||
import closeIcon from '../../public/close.png'; | ||
import Image from 'next/image'; | ||
|
||
interface IModalProps { | ||
modalClassName?: string; | ||
contentClassName?: string; | ||
backDropClassName?: string; | ||
isModalOpen: boolean; | ||
closeModal: () => void; | ||
} | ||
|
||
export default function Modal(props: React.PropsWithChildren<IModalProps>) { | ||
|
||
return ( | ||
<div className={[ | ||
styles.modalRoot, | ||
!props.isModalOpen && styles.closed, | ||
props.backDropClassName | ||
].join(' ')}> | ||
<div className={[styles.modal, props.modalClassName].join(' ')}> | ||
<button className={[styles.closeButton].join(' ')} type="button" onClick={props.closeModal}> | ||
<Image src={closeIcon} alt='close' width={12} height={12} /> | ||
</button> | ||
<div className={[styles.modalContent, props.contentClassName].join(' ')}> | ||
{props.children} | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} |
Oops, something went wrong.