Skip to content

Commit

Permalink
ran formatting and removed unused imports
Browse files Browse the repository at this point in the history
  • Loading branch information
friedrecursion committed May 19, 2024
1 parent 773c334 commit 98ab637
Show file tree
Hide file tree
Showing 17 changed files with 2,221 additions and 1,623 deletions.
65 changes: 34 additions & 31 deletions frontend/frontend/src/components/CustomComponents.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import { darken } from '@mui/system';
import { darken } from '@mui/system'
import {
Button as BaseButton,
Card as BaseCard,
Divider as BaseDivider,
Box, ButtonProps, CardProps, DividerProps
Box,
ButtonProps,
CardProps,
DividerProps,
} from '@mui/material'
import theme from '../Theme.ts'
import {ReactNode} from "react";
import { ReactNode } from 'react'

interface PrimaryButtonProps extends ButtonProps {
children: ReactNode;
children: ReactNode
}

export const Button = ({ children, ...props }: PrimaryButtonProps) => {
Expand All @@ -24,7 +27,7 @@ export const Button = ({ children, ...props }: PrimaryButtonProps) => {
textTransform: 'none',
color: 'primary.contrastText',
'&:hover': {
backgroundColor: darken(theme.palette.primary.main,0.5),
backgroundColor: darken(theme.palette.primary.main, 0.5),
},
}}
{...props}
Expand All @@ -35,10 +38,13 @@ export const Button = ({ children, ...props }: PrimaryButtonProps) => {
}

interface SecondaryButtonProps extends ButtonProps {
children: ReactNode;
children: ReactNode
}

export const SecondaryButton = ({ children, ...props }: SecondaryButtonProps) => {
export const SecondaryButton = ({
children,
...props
}: SecondaryButtonProps) => {
return (
<BaseButton
variant="contained"
Expand All @@ -50,7 +56,7 @@ export const SecondaryButton = ({ children, ...props }: SecondaryButtonProps) =>
textTransform: 'none',
color: 'secondary.contrastText',
'&:hover': {
backgroundColor: darken(theme.palette.secondary.main,0.2),
backgroundColor: darken(theme.palette.secondary.main, 0.2),
},
}}
{...props}
Expand All @@ -61,7 +67,7 @@ export const SecondaryButton = ({ children, ...props }: SecondaryButtonProps) =>
}

interface CustomCardProps extends CardProps {
children: ReactNode;
children: ReactNode
}

export const Card = ({ children, ...props }: CustomCardProps) => {
Expand All @@ -81,7 +87,7 @@ export const Card = ({ children, ...props }: CustomCardProps) => {
}

interface CustomDividerProps extends DividerProps {
children?: ReactNode;
children?: ReactNode
}

export const Divider = ({ children, ...props }: CustomCardProps) => {
Expand All @@ -99,36 +105,33 @@ export const Divider = ({ children, ...props }: CustomCardProps) => {
}

interface EvenlySpacedRowProps {
items: ReactNode[];
items: ReactNode[]
}

export const EvenlySpacedRow = ({items} : EvenlySpacedRowProps) => {
export const EvenlySpacedRow = ({ items }: EvenlySpacedRowProps) => {
return (
<Box
width={'100%'}
display="flex"
justifyContent={'space-between'}
>
<Box width={'100%'} display="flex" justifyContent={'space-between'}>
{items.map((item, index) => (

<Box
key={index}
width={(index == 0 || index == items.length-1) ? ((50/items.length)+'%') : ((100 - (100/items.length))/(items.length-2) +'%')}
sx={{
//border: '1px solid red',
display: 'flex',
alignItems: 'center',
justifyContent: 'center'
}}>
<Box>
{item}
</Box>
width={
index == 0 || index == items.length - 1
? 50 / items.length + '%'
: (100 - 100 / items.length) / (items.length - 2) +
'%'
}
sx={{
//border: '1px solid red',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
}}
>
<Box>{item}</Box>
</Box>
))}
</Box>
</Box>
)
}



export default { Button, Card, Divider, EvenlySpacedRow }
62 changes: 37 additions & 25 deletions frontend/frontend/src/components/DeadlineCalendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,17 @@ import {
PickersDayProps,
} from '@mui/x-date-pickers'
import dayjs, { Dayjs } from 'dayjs'
import { Badge, SxProps, Stack, Typography, Box, List, ListItem, ListItemButton, ListItemText } from '@mui/material'
import {
Badge,
SxProps,
Stack,
Typography,
Box,
List,
ListItem,
ListItemButton,
ListItemText,
} from '@mui/material'
import { useEffect, useRef, useState } from 'react'
import AssignmentIcon from '@mui/icons-material/Assignment'
import { useNavigate } from 'react-router-dom'
Expand Down Expand Up @@ -95,22 +105,26 @@ function DeadlineMenu({ assignments, selectedDay }: DeadlineMenuProps) {
</Typography>
<List>
{assignments
.filter((assignment: project) =>
dayjs(assignment.deadline).isSame(selectedDay, 'day')
).map((assignment: project) =>
<ListItem>
<ListItemButton
sx={{
border: 1
}}
onClick={() => handleProjectClick(assignment.vak, assignment.project_id)}
>
<ListItemText
primary={assignment.titel}
/>
</ListItemButton>
</ListItem>
)}
.filter((assignment: project) =>
dayjs(assignment.deadline).isSame(selectedDay, 'day')
)
.map((assignment: project) => (
<ListItem>
<ListItemButton
sx={{
border: 1,
}}
onClick={() =>
handleProjectClick(
assignment.vak,
assignment.project_id
)
}
>
<ListItemText primary={assignment.titel} />
</ListItemButton>
</ListItem>
))}
</List>
</Stack>
)
Expand All @@ -121,7 +135,10 @@ interface DeadlineCalendarProps {
assignments: project[]
}

export function DeadlineCalendar({ deadlines, assignments }: DeadlineCalendarProps) {
export function DeadlineCalendar({
deadlines,
assignments,
}: DeadlineCalendarProps) {
const requestAbortController = useRef<AbortController | null>(null)
const [isLoading, setIsLoading] = useState(false)
const [highlightedDays, setHighlightedDays] = useState<number[]>([])
Expand Down Expand Up @@ -173,9 +190,7 @@ export function DeadlineCalendar({ deadlines, assignments }: DeadlineCalendarPro

return (
<>
<Stack
direction={"column"}
>
<Stack direction={'column'}>
{/*Calendar*/}
<DateCalendar
readOnly={false}
Expand All @@ -194,10 +209,7 @@ export function DeadlineCalendar({ deadlines, assignments }: DeadlineCalendarPro
} as never,
}}
/>
<DeadlineMenu
assignments={assignments}
selectedDay={value}
/>
<DeadlineMenu assignments={assignments} selectedDay={value} />
</Stack>
</>
)
Expand Down
61 changes: 33 additions & 28 deletions frontend/frontend/src/components/SubmissionListItemStudentPage.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { EvenlySpacedRow} from "./CustomComponents.tsx";
import { EvenlySpacedRow } from './CustomComponents.tsx'
import {
ListItem,
ListItemButton,
Expand Down Expand Up @@ -53,33 +53,38 @@ export function SubmissionListItemStudentPage({
<>
<ListItem key={realId} sx={{ maxHeight: '30px' }} disablePadding>
<ListItemButton
sx={{maxHeight: '30px'}}
onClick={handleSubmissionClick}>
<EvenlySpacedRow items={[
<ListItemText
sx={{
color: 'primary.main',
'&:hover': {
color: 'primary.light',
},
}}
primary={visualId}
/>,
<ListItemText
primary={timestamp ? timestamp : t('time')}
/>,
<Box sx={{ maxWidth: '24px', }}>
<ListItemIcon sx={{ minWidth: 35 }}>
{status ? (
<CheckCircleOutlineIcon
sx={{ color: 'success.main' }}
/>
) : (
<HighlightOffIcon sx={{ color: 'error.main' }} />
)}
</ListItemIcon>
</Box>
]}/>
sx={{ maxHeight: '30px' }}
onClick={handleSubmissionClick}
>
<EvenlySpacedRow
items={[
<ListItemText
sx={{
color: 'primary.main',
'&:hover': {
color: 'primary.light',
},
}}
primary={visualId}
/>,
<ListItemText
primary={timestamp ? timestamp : t('time')}
/>,
<Box sx={{ maxWidth: '24px' }}>
<ListItemIcon sx={{ minWidth: 35 }}>
{status ? (
<CheckCircleOutlineIcon
sx={{ color: 'success.main' }}
/>
) : (
<HighlightOffIcon
sx={{ color: 'error.main' }}
/>
)}
</ListItemIcon>
</Box>,
]}
/>
</ListItemButton>
</ListItem>
</>
Expand Down
Loading

0 comments on commit 98ab637

Please sign in to comment.