Skip to content

Commit

Permalink
positie jaarkiezer verandert
Browse files Browse the repository at this point in the history
  • Loading branch information
Bendemeurichy committed May 20, 2024
1 parent 6b0f8cb commit b46d41c
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 52 deletions.
75 changes: 61 additions & 14 deletions frontend/frontend/src/components/TabSwitcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ import { ReactNode } from 'react'
import { t } from 'i18next'
import theme from '../Theme.ts'
import { grey } from '@mui/material/colors'
import { Box, MenuItem, Select } from '@mui/material'

interface TabSwitcherProps {
selectedYear: number
setSelectedYear: (year: number) => void
titles: string[]
nodes: ReactNode[]
}
Expand All @@ -22,25 +25,69 @@ interface TabSwitcherProps {
* the number of titles and nodes should be the same
*/

export default function TabSwitcher({ titles, nodes }: TabSwitcherProps) {
export default function TabSwitcher({
selectedYear,
setSelectedYear,
titles,
nodes,
}: TabSwitcherProps) {
titles.length !== nodes.length &&
console.error('The number of titles and nodes should be the same')

return (
<Tabs defaultValue={0} color={'background.default'}>
<TabsList>
{titles.map((title, index) => (
<Tab id={`tab${index}`} key={index} value={index}>
{t(title)}
</Tab>
<>
<Tabs defaultValue={0} color={'background.default'}>
<Box
display={'flex'}
flexDirection={'row'}
justifyContent={'space-between'}
>
<TabsList>
{titles.map((title, index) => (
<Tab id={`tab${index}`} key={index} value={index}>
{t(title)}
</Tab>
))}
</TabsList>
<Box
height={'100%'}
display={'flex'}
flexDirection={'column'}
justifyContent={'center'}
alignItems={'flex-start'}
mb={2}
>
<Select
variant={'outlined'}
color={'primary'}
value={selectedYear}
onChange={(e) =>
setSelectedYear(e.target.value as number)
}
label="Select Academic Year"
sx={{
minWidth: 150,
'& .MuiSelect-outlined': {
border: 1.5,
borderColor: 'primary.main',
},
}}
>
{[2022, 2023, 2024, 2025].map((year) => (
<MenuItem key={year} value={year}>
{year}
</MenuItem>
))}
</Select>
</Box>
</Box>
{nodes.map((node, index) => (
<TabPanel id={`node${index}`} key={index} value={index}>
{node}
</TabPanel>
))}
</TabsList>
{nodes.map((node, index) => (
<TabPanel id={`node${index}`} key={index} value={index}>
{node}
</TabPanel>
))}
</Tabs>
</Tabs>
</>
)
}

Expand Down
2 changes: 1 addition & 1 deletion frontend/frontend/src/pages/mainPage/ArchivedView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function ArchivedView({
<>
<Stack
flexDirection={{ xs: 'column-reverse', md: 'row' }}
minWidth={{ md: '47svw', lg: '68svw' }}
minWidth={{ md: '57svw', lg: '78svw' }}
>
<Stack
direction={'column'}
Expand Down
2 changes: 1 addition & 1 deletion frontend/frontend/src/pages/mainPage/CoursesView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function CoursesView({
<>
<Stack
flexDirection={{ xs: 'column-reverse', md: 'row' }}
minWidth={{ md: '47svw', lg: '68svw' }}
minWidth={{ md: '57svw', lg: '78svw' }}
>
<Stack
direction={'column'}
Expand Down
44 changes: 8 additions & 36 deletions frontend/frontend/src/pages/mainPage/MainPage.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Header } from '../../components/Header.tsx'
import { Button } from '../../components/CustomComponents.tsx'
import { Box, MenuItem, Select, Stack } from '@mui/material'
import { Box, Stack } from '@mui/material'
import TabSwitcher from '../../components/TabSwitcher.tsx'
import { ArchivedView } from './ArchivedView.tsx'
import { CoursesView } from './CoursesView.tsx'
Expand Down Expand Up @@ -192,6 +192,8 @@ export default function MainPage() {
CoursesView is a scroll-box with the current courses,
ArchivedView is the same but for the archived courses. */}
<TabSwitcher
selectedYear={selectedYear}
setSelectedYear={setSelectedYear}
titles={['current_courses', 'archived']}
nodes={
loading
Expand All @@ -202,8 +204,8 @@ export default function MainPage() {
md: 'row',
}}
minWidth={{
md: '40svw',
lg: '49svw',
md: '57svw',
lg: '78svw',
}}
>
{[...Array(3)].map((_, index) => (
Expand All @@ -216,8 +218,8 @@ export default function MainPage() {
md: 'row',
}}
minWidth={{
md: '40svw',
lg: '49svw',
md: '57svw',
lg: '78svw',
}}
>
{[...Array(3)].map((_, index) => (
Expand Down Expand Up @@ -322,37 +324,7 @@ export default function MainPage() {
]
}
/>
<Box
height={'100%'}
display={'flex'}
flexDirection={'column'}
justifyContent={'center'}
alignItems={'flex-start'}
mb={2}
>
<Select
variant={'outlined'}
color={'primary'}
value={selectedYear}
onChange={(e) =>
setSelectedYear(e.target.value as number)
}
label="Select Academic Year"
sx={{
minWidth: 150,
'& .MuiSelect-outlined': {
border: 1.5,
borderColor: 'primary.main',
},
}}
>
{[2022, 2023, 2024, 2025].map((year) => (
<MenuItem key={year} value={year}>
{year}
</MenuItem>
))}
</Select>
</Box>

{/* Add a calendar to the right of the mainpage. */}
<Box
aria-label={'calendarView'}
Expand Down

0 comments on commit b46d41c

Please sign in to comment.