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

Profil page #155

Merged
merged 3 commits into from
Nov 11, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export const Authentication: FC = () => {
} else {
return (
<div className={styles.authenticationDisplayButtons}>
<Link href={`/${seminar}/profil`}>Profil</Link>
<span onClick={() => logout()}>Odhlásiť</span>
</div>
)
Expand Down
6 changes: 6 additions & 0 deletions src/components/Profile/ProfileDetail.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.label {
font-weight: bold;
text-transform: uppercase;
font-style: italic;
padding-right: .5rem;
}
9 changes: 9 additions & 0 deletions src/components/Profile/ProfileDetail.module.scss.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export type Styles = {
label: string
}

export type ClassNames = keyof Styles

declare const styles: Styles

export default styles
46 changes: 46 additions & 0 deletions src/components/Profile/ProfileDetail.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import {Stack, Typography} 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 styles from './ProfileDetail.module.scss'

type ProfileLineInput = {
label: string
value?: string
}

const ProfileLine: FC<ProfileLineInput> = ({label, value}) => {
return (
// font-size: 30px podla designu
<Typography sx={{fontSize: '1.875rem'}}>
<span className={styles.label}>{label}</span>
{value}
</Typography>
Comment on lines +19 to +22
Copy link
Collaborator

Choose a reason for hiding this comment

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

asi to po #162 bude Stack horizontal gap 1 a Typography osobitne na label a value, ale v poho nateraz

)
}

export const ProfileDetail: 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 (
<Stack spacing={2}>
<ProfileLine label={'meno'} value={profile?.first_name + ' ' + profile?.last_name} />
<ProfileLine label={'e-mail'} value={profile?.email} />
<ProfileLine label={'škola'} value={profile?.school.verbose_name} />
<ProfileLine label={'ročník'} value={profile?.grade_name} />
<ProfileLine label={'tel. č.'} value={profile?.phone || '-'} />
<ProfileLine label={'tel. č. na rodiča'} value={profile?.parent_phone || '-'} />
</Stack>
)
}
9 changes: 9 additions & 0 deletions src/pages/malynar/profil/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import {NextPage} from 'next'

import Page from '../../strom/profil/index'

const Vysledky: NextPage = () => {
return <Page />
}

export default Vysledky
9 changes: 9 additions & 0 deletions src/pages/matik/profil/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import {NextPage} from 'next'

import Page from '../../strom/profil/index'

const Vysledky: NextPage = () => {
return <Page />
}

export default Vysledky
12 changes: 12 additions & 0 deletions src/pages/strom/profil/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import {NextPage} from 'next'
Copy link
Collaborator

Choose a reason for hiding this comment

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

treba este matik a malynar stranky


import {PageLayout} from '@/components/PageLayout/PageLayout'
import {ProfileDetail} from '@/components/Profile/ProfileDetail'

const Profil: NextPage = () => (
<PageLayout contentWidth={2} title="Profil">
<ProfileDetail />
</PageLayout>
)

export default Profil
2 changes: 2 additions & 0 deletions src/types/api/personal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,14 @@ export interface SchoolProfile {
export interface Profile {
first_name: string
last_name: string
email: string
nickname: string | null
school: SchoolProfile
phone: string | null
parent_phone: string | null
gdpr: boolean
grade: number
grade_name: string
is_student: boolean
has_school: boolean
school_id: number
Expand Down
Loading