Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Footer #224

Merged
merged 9 commits into from
Dec 9, 2023
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/components/PageLayout/DebugFooter/DebugFooter.module.scss
Original file line number Diff line number Diff line change
@@ -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;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export type Styles = {
debugFooter: string
}

export type ClassNames = keyof Styles

declare const styles: Styles

export default styles
27 changes: 27 additions & 0 deletions src/components/PageLayout/DebugFooter/DebugFooter.tsx
Original file line number Diff line number Diff line change
@@ -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<Profile>(`/api/personal/profiles/myprofile`),
enabled: isAuthed,
})
const profile = data?.data

return (
<div className={styles.debugFooter}>
<span>Debug info: </span>
<span>user name: {profile?.first_name + ' ' + profile?.last_name} </span>
<span>isAuthed: {`${isAuthed}`}</span>
</div>
)
}
40 changes: 31 additions & 9 deletions src/components/PageLayout/Footer/Footer.module.scss
Original file line number Diff line number Diff line change
@@ -1,13 +1,35 @@
.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 {
padding: 0px 5px;
border-bottom: 5px solid white;
color: white;
background-color: inherit;
}
}

.menuItem:hover {
background-color: white;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nie som nadseny z novych class ale chapem nechut k skusaniu prepisania do MUI... 😄


a {
color: black;
border-color: black;
background-color: inherit;
}
}
4 changes: 3 additions & 1 deletion src/components/PageLayout/Footer/Footer.module.scss.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
export type Styles = {
footer: string
container: string
content: string
menuItem: string
}

export type ClassNames = keyof Styles
Expand Down
58 changes: 46 additions & 12 deletions src/components/PageLayout/Footer/Footer.tsx
Original file line number Diff line number Diff line change
@@ -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<Profile>(`/api/personal/profiles/myprofile`),
enabled: isAuthed,
const {
data: menuItemsData,
isLoading: menuItemsIsLoading,
error: menuItemsError,
} = useQuery({
queryKey: ['cms', 'menu-item', 'on-site', seminarId],
queryFn: () => axios.get<MenuItemShort[]>(`/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<ILogo[]>('/api/cms/logo'),
})
const logos = logosData?.data.filter((logo) => !logo.disabled) ?? []

return (
<div className={styles.footer}>
<span>Debug info: </span>
<span>user name: {profile?.first_name + ' ' + profile?.last_name} </span>
<span>isAuthed: {`${isAuthed}`}</span>
<div className={styles.container}>
<div className={styles.content}>
<Stack direction="row" m={2} gap={2} justifyContent="center" sx={{flexWrap: 'wrap'}}>
{menuItemsIsLoading && <Loading />}
{menuItems.map((item) => (
<div key={item.id} className={styles.menuItem}>
<Link variant="button2" href={`/${seminar}${item.url}`}>
{item.caption}
</Link>
</div>
))}
{menuItemsError && <p>{menuItemsError.message}</p>}
</Stack>
<Stack direction="row" m={2} gap={2} justifyContent="center" sx={{flexWrap: 'wrap'}}>
{logosIsLoading && <Loading />}
{logos.map((logo) => (
<Logo key={logo.id} {...logo} />
))}
{logosError && <p>{logosError.message}</p>}
</Stack>
</div>
</div>
)
}
22 changes: 22 additions & 0 deletions src/components/PageLayout/Footer/Logo.tsx
Original file line number Diff line number Diff line change
@@ -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<ILogo> = ({name, image}) => {
return (
<Box
component={'img'}
src={image}
alt={name} // TODO: alt from backend
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment

sx={{
maxHeight: '9rem',
}}
/>
)
}
9 changes: 2 additions & 7 deletions src/components/PageLayout/MenuMain/MenuMain.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -31,7 +26,7 @@ export const MenuMain: FC = () => {

const {data: menuItemsData, isLoading: menuItemsIsLoading} = useQuery({
queryKey: ['cms', 'menu-item', 'on-site', seminarId],
queryFn: () => axios.get<MenuItemInterface[]>(`/api/cms/menu-item/on-site/${seminarId}`),
queryFn: () => axios.get<MenuItemShort[]>(`/api/cms/menu-item/on-site/${seminarId}`),
})
const menuItems = menuItemsData?.data ?? []

Expand Down
4 changes: 4 additions & 0 deletions src/components/PageLayout/PageLayout.module.scss
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 3 additions & 1 deletion src/components/PageLayout/PageLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -41,8 +42,8 @@ export const PageLayout: FC<PageLayoutProps> = ({contentWidth = 2, title = '', c
<div className={styles.pageContainer}>
<TopGrid />
<MenuMain />
<StromLogo />
<div className={styles.grid}>
<StromLogo />
<div
className={clsx(
styles.mainContent,
Expand All @@ -55,6 +56,7 @@ export const PageLayout: FC<PageLayoutProps> = ({contentWidth = 2, title = '', c
</div>
</div>
<Footer />
<DebugFooter />
</div>
</BannerContainer.Provider>
</PageTitleContainer.Provider>
Expand Down
Loading