From 5a75014766537f6ff1b5b84535ac3dd2411c8ede Mon Sep 17 00:00:00 2001 From: Michal Masrna <38047051+michalmasrna1@users.noreply.github.com> Date: Sat, 9 Dec 2023 21:20:34 +0100 Subject: [PATCH] Footer (#224) * renaming Footer to DebugFooter * basic footer layout and positioning * Footer positioning * Addedd Logo component * Footer containing logos * Change position of Footer * Style images in Footer * Add menuitems to Footer * Fix some thinks after review --------- Co-authored-by: matushl --- .../DebugFooter/DebugFooter.module.scss | 13 +++++ .../DebugFooter/DebugFooter.module.scss.d.ts | 9 +++ .../PageLayout/DebugFooter/DebugFooter.tsx | 27 +++++++++ .../PageLayout/Footer/Footer.module.scss | 39 ++++++++++--- .../PageLayout/Footer/Footer.module.scss.d.ts | 4 +- src/components/PageLayout/Footer/Footer.tsx | 58 +++++++++++++++---- src/components/PageLayout/Footer/Logo.tsx | 22 +++++++ .../PageLayout/MenuMain/MenuMain.tsx | 9 +-- .../PageLayout/PageLayout.module.scss | 4 ++ src/components/PageLayout/PageLayout.tsx | 4 +- 10 files changed, 159 insertions(+), 30 deletions(-) create mode 100644 src/components/PageLayout/DebugFooter/DebugFooter.module.scss create mode 100644 src/components/PageLayout/DebugFooter/DebugFooter.module.scss.d.ts create mode 100644 src/components/PageLayout/DebugFooter/DebugFooter.tsx create mode 100644 src/components/PageLayout/Footer/Logo.tsx diff --git a/src/components/PageLayout/DebugFooter/DebugFooter.module.scss b/src/components/PageLayout/DebugFooter/DebugFooter.module.scss new file mode 100644 index 00000000..342c7b23 --- /dev/null +++ b/src/components/PageLayout/DebugFooter/DebugFooter.module.scss @@ -0,0 +1,13 @@ +.debugFooter { + position: fixed; + left: 25%; + right: 0; + bottom: 0; + + background-color: black; + color: white; + + display: flex; + flex-direction: row; + gap: 40px; +} diff --git a/src/components/PageLayout/DebugFooter/DebugFooter.module.scss.d.ts b/src/components/PageLayout/DebugFooter/DebugFooter.module.scss.d.ts new file mode 100644 index 00000000..2ca50e6b --- /dev/null +++ b/src/components/PageLayout/DebugFooter/DebugFooter.module.scss.d.ts @@ -0,0 +1,9 @@ +export type Styles = { + debugFooter: string +} + +export type ClassNames = keyof Styles + +declare const styles: Styles + +export default styles diff --git a/src/components/PageLayout/DebugFooter/DebugFooter.tsx b/src/components/PageLayout/DebugFooter/DebugFooter.tsx new file mode 100644 index 00000000..c89d3cf4 --- /dev/null +++ b/src/components/PageLayout/DebugFooter/DebugFooter.tsx @@ -0,0 +1,27 @@ +import {useQuery} from '@tanstack/react-query' +import axios from 'axios' +import {FC} from 'react' + +import {Profile} from '@/types/api/personal' +import {AuthContainer} from '@/utils/AuthContainer' + +import styles from './DebugFooter.module.scss' + +export const DebugFooter: FC = () => { + const {isAuthed} = AuthContainer.useContainer() + + const {data} = useQuery({ + queryKey: ['personal', 'profiles', 'myprofile'], + queryFn: () => axios.get(`/api/personal/profiles/myprofile`), + enabled: isAuthed, + }) + const profile = data?.data + + return ( +
+ Debug info: + user name: {profile?.first_name + ' ' + profile?.last_name} + isAuthed: {`${isAuthed}`} +
+ ) +} diff --git a/src/components/PageLayout/Footer/Footer.module.scss b/src/components/PageLayout/Footer/Footer.module.scss index f16ed242..f746a6fc 100644 --- a/src/components/PageLayout/Footer/Footer.module.scss +++ b/src/components/PageLayout/Footer/Footer.module.scss @@ -1,13 +1,34 @@ -.footer { - position: fixed; - left: 25%; - right: 0; - bottom: 0; - +.container { + width: 100%; + display: grid; + grid-template-columns: repeat(4, 1fr); background-color: black; color: white; + // bottom offset because of sticky debug footer + padding-bottom: 1rem; +} - display: flex; - flex-direction: row; - gap: 40px; +.content { + grid-column-start: 2; + grid-column-end: 4; } + +.menuItem { + background-color: transparent; + + a { + border-color: white; + color: white; + background-color: inherit; + } +} + +.menuItem:hover { + background-color: white; + + a { + color: black; + border-color: black; + background-color: inherit; + } +} \ No newline at end of file diff --git a/src/components/PageLayout/Footer/Footer.module.scss.d.ts b/src/components/PageLayout/Footer/Footer.module.scss.d.ts index 8356d22f..028117b1 100644 --- a/src/components/PageLayout/Footer/Footer.module.scss.d.ts +++ b/src/components/PageLayout/Footer/Footer.module.scss.d.ts @@ -1,5 +1,7 @@ export type Styles = { - footer: string + container: string + content: string + menuItem: string } export type ClassNames = keyof Styles diff --git a/src/components/PageLayout/Footer/Footer.tsx b/src/components/PageLayout/Footer/Footer.tsx index 872ef70e..6825a39c 100644 --- a/src/components/PageLayout/Footer/Footer.tsx +++ b/src/components/PageLayout/Footer/Footer.tsx @@ -1,27 +1,61 @@ +import {Stack} from '@mui/material' import {useQuery} from '@tanstack/react-query' import axios from 'axios' import {FC} from 'react' -import {Profile} from '@/types/api/personal' -import {AuthContainer} from '@/utils/AuthContainer' +import {Link} from '@/components/Clickable/Link' +import {Loading} from '@/components/Loading/Loading' +import {ILogo, Logo} from '@/components/PageLayout/Footer/Logo' +import {MenuItemShort} from '@/types/api/cms' +import {useSeminarInfo} from '@/utils/useSeminarInfo' import styles from './Footer.module.scss' export const Footer: FC = () => { - const {isAuthed} = AuthContainer.useContainer() + const {seminar, seminarId} = useSeminarInfo() - const {data} = useQuery({ - queryKey: ['personal', 'profiles', 'myprofile'], - queryFn: () => axios.get(`/api/personal/profiles/myprofile`), - enabled: isAuthed, + const { + data: menuItemsData, + isLoading: menuItemsIsLoading, + error: menuItemsError, + } = useQuery({ + queryKey: ['cms', 'menu-item', 'on-site', seminarId], + queryFn: () => axios.get(`/api/cms/menu-item/on-site/${seminarId}`), }) - const profile = data?.data + const menuItems = menuItemsData?.data ?? [] + + const { + data: logosData, + isLoading: logosIsLoading, + error: logosError, + } = useQuery({ + queryKey: ['cms', 'logo'], + queryFn: () => axios.get('/api/cms/logo'), + }) + const logos = logosData?.data.filter((logo) => !logo.disabled) ?? [] return ( -
- Debug info: - user name: {profile?.first_name + ' ' + profile?.last_name} - isAuthed: {`${isAuthed}`} +
+
+ + {menuItemsIsLoading && } + {menuItems.map((item) => ( +
+ + {item.caption} + +
+ ))} + {menuItemsError &&

{menuItemsError.message}

} +
+ + {logosIsLoading && } + {logos.map((logo) => ( + + ))} + {logosError &&

{logosError.message}

} +
+
) } diff --git a/src/components/PageLayout/Footer/Logo.tsx b/src/components/PageLayout/Footer/Logo.tsx new file mode 100644 index 00000000..4dfbe101 --- /dev/null +++ b/src/components/PageLayout/Footer/Logo.tsx @@ -0,0 +1,22 @@ +import {Box} from '@mui/material' +import {FC} from 'react' + +export interface ILogo { + id: number + name: string + disabled: string + image: string +} + +export const Logo: FC = ({name, image}) => { + return ( + + ) +} diff --git a/src/components/PageLayout/MenuMain/MenuMain.tsx b/src/components/PageLayout/MenuMain/MenuMain.tsx index c842ee27..2fc63502 100644 --- a/src/components/PageLayout/MenuMain/MenuMain.tsx +++ b/src/components/PageLayout/MenuMain/MenuMain.tsx @@ -9,18 +9,13 @@ import {FC, useState} from 'react' import {CloseButton} from '@/components/CloseButton/CloseButton' import {Loading} from '@/components/Loading/Loading' import Menu from '@/svg/menu.svg' +import {MenuItemShort} from '@/types/api/cms' import {useHasPermissions} from '@/utils/useHasPermissions' import {useSeminarInfo} from '@/utils/useSeminarInfo' import {Authentication} from '../Authentication/Authentication' import styles from './MenuMain.module.scss' -interface MenuItemInterface { - id: number - caption: string - url: string -} - export const MenuMain: FC = () => { const {seminar, seminarId} = useSeminarInfo() @@ -31,7 +26,7 @@ export const MenuMain: FC = () => { const {data: menuItemsData, isLoading: menuItemsIsLoading} = useQuery({ queryKey: ['cms', 'menu-item', 'on-site', seminarId], - queryFn: () => axios.get(`/api/cms/menu-item/on-site/${seminarId}`), + queryFn: () => axios.get(`/api/cms/menu-item/on-site/${seminarId}`), }) const menuItems = menuItemsData?.data ?? [] diff --git a/src/components/PageLayout/PageLayout.module.scss b/src/components/PageLayout/PageLayout.module.scss index 7429dc9c..8acd266c 100644 --- a/src/components/PageLayout/PageLayout.module.scss +++ b/src/components/PageLayout/PageLayout.module.scss @@ -1,8 +1,12 @@ .pageContainer { min-height: 100vh; + position: relative; + display: flex; + flex-direction: column; } .grid { + flex: 1; display: grid; grid-template-columns: repeat(4, 1fr); // bottom offset because of sticky debug footer diff --git a/src/components/PageLayout/PageLayout.tsx b/src/components/PageLayout/PageLayout.tsx index 0173c82c..2ced9a35 100644 --- a/src/components/PageLayout/PageLayout.tsx +++ b/src/components/PageLayout/PageLayout.tsx @@ -6,6 +6,7 @@ import {BannerContainer} from '@/utils/BannerContainer' import {PageTitleContainer} from '@/utils/PageTitleContainer' import {Seminar, useSeminarInfo} from '@/utils/useSeminarInfo' +import {DebugFooter} from './DebugFooter/DebugFooter' import {Footer} from './Footer/Footer' import {MenuMain} from './MenuMain/MenuMain' import styles from './PageLayout.module.scss' @@ -41,8 +42,8 @@ export const PageLayout: FC = ({contentWidth = 2, title = '', c
+
-
= ({contentWidth = 2, title = '', c