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

Added Progress Bar for Cooperation Activities #2691

Merged
merged 7 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
3 changes: 3 additions & 0 deletions src/assets/img/cooperation-details/clock.svg
amoutens marked this conversation as resolved.
Show resolved Hide resolved
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,37 @@ export const styles = {
${palette.basic.yellowGreen} ${175 - progress}%,
${palette.basic.fruitSalad} ${200 - progress}%)`
}
})
}),
progressCoop: {
display: 'flex',
alignItems: 'center',
width: '100%',
height: '12px',
backgroundColor: `${palette.basic.turquoise100}`,
borderRadius: '5px',
'& .MuiLinearProgress-bar': {
borderRadius: '5px',
background: `${palette.basic.turquoise500}`
}
},
wrapperProgressCoop: {
width: '100%',
display: 'flex',
flexDirection: { xs: 'row-reverse', sm: 'column' },
alignItems: { xs: 'center' },
amoutens marked this conversation as resolved.
Show resolved Hide resolved
marginBottom: { xs: '2px', sm: '24px' }
amoutens marked this conversation as resolved.
Show resolved Hide resolved
},
labelsCoop: {
width: { xs: 'auto', sm: '100%' },
display: 'flex',
justifyContent: 'space-between',
marginBottom: { xs: '0', sm: '0px' },
amoutens marked this conversation as resolved.
Show resolved Hide resolved
marginLeft: { xs: '20px', sm: '0' }
},
wrapperTypographyProgressCoop: {
width: '100%',
display: 'flex',
justifyContent: 'space-between',
alignItems: 'flex-end'
}
}
52 changes: 45 additions & 7 deletions src/components/app-progress-bar-line/AppProgressBarLine.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,48 @@ import { styles } from '~/components/app-progress-bar-line/AppProgressBarLine.st
import { LinearProgress } from '@mui/material'
import { UserRoleEnum } from '~/types'

import Image from '~/assets/img/cooperation-details/clock.svg'
amoutens marked this conversation as resolved.
Show resolved Hide resolved

interface AppProgressBarLineProps {
value: number
userRole: UserRoleEnum | ''
isCooperationActivities?: boolean
}

const AppProgressBarLine: FC<AppProgressBarLineProps> = ({
value,
userRole
userRole,
isCooperationActivities = false
}) => {
const { isMobile } = useBreakpoints()
const labelsValue =
userRole === UserRoleEnum.Student
? [0, 25, 50, 75, 100]
: [0, 20, 40, 60, 80, 100]
amoutens marked this conversation as resolved.
Show resolved Hide resolved

const labelsWithPercent = isMobile ? (
<Typography color={'primary.500'} variant='subtitle2'>
const labelsWithPercentForCooperation = (
<Box width={'100%'}>
amoutens marked this conversation as resolved.
Show resolved Hide resolved
<Typography color={'primary.500'} fontSize={'12px'} variant='subtitle1'>
Your progress
amoutens marked this conversation as resolved.
Show resolved Hide resolved
</Typography>
<Box sx={styles.wrapperTypographyProgressCoop}>
<Typography color={'#2B6E6E'} fontSize={'20px'} variant='h5'>
{`${value}% completed`}
amoutens marked this conversation as resolved.
Show resolved Hide resolved
</Typography>
<Box display={'flex'}>
<Box component='img' marginRight={'8px'} src={Image} />
<Typography
color={'primary.500'}
fontSize={'12px'}
variant='subtitle1'
>
{`${100 - value}% to complete`}
amoutens marked this conversation as resolved.
Show resolved Hide resolved
</Typography>
</Box>
</Box>
</Box>
)
const labelsWithPercentForProfile = isMobile ? (
<Typography color='primary.500' variant='subtitle2'>
amoutens marked this conversation as resolved.
Show resolved Hide resolved
{`${value}%`}
</Typography>
) : (
Expand All @@ -37,12 +62,25 @@ const AppProgressBarLine: FC<AppProgressBarLineProps> = ({
</Typography>
))
)
const labelsWithPercent = isCooperationActivities
? labelsWithPercentForCooperation
: labelsWithPercentForProfile

return (
<Box sx={styles.wrapperProgress}>
<Box sx={styles.labels}>{labelsWithPercent}</Box>
<Box
sx={
isCooperationActivities
? styles.wrapperProgressCoop
: styles.wrapperProgress
}
>
<Box sx={isCooperationActivities ? styles.labelsCoop : styles.labels}>
{labelsWithPercent}
</Box>
<LinearProgress
sx={styles.progress(value)}
sx={
isCooperationActivities ? styles.progressCoop : styles.progress(value)
}
value={value}
variant='determinate'
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { cooperationsSelector } from '~/redux/features/cooperationsSlice'

import { UserRoleEnum } from '~/types'
import { useAppSelector } from '~/hooks/use-redux'
import AppProgressBarLine from '~/components/app-progress-bar-line/AppProgressBarLine'

interface CooperationActivitiesViewProps {
setEditMode: Dispatch<SetStateAction<boolean>>
Expand All @@ -22,13 +23,20 @@ const CooperationActivitiesView: FC<CooperationActivitiesViewProps> = ({
const { sections } = useAppSelector(cooperationsSelector)
const { userRole } = useAppSelector((state) => state.appMain)
const isTutor = userRole === UserRoleEnum.Tutor

const percentValue = 23
const onEdit = () => {
setEditMode(true)
}

return (
<Box sx={styles.root}>
<Box>
<AppProgressBarLine
isCooperationActivities
userRole={''}
amoutens marked this conversation as resolved.
Show resolved Hide resolved
value={percentValue}
/>
</Box>
{sections.map((item) => (
<CooperationSectionView item={item} key={item.id} />
))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import {
cooperationsSelector,
setResourcesAvailability
} from '~/redux/features/cooperationsSlice'

import { snackbarVariants } from '~/constants'
import {
ResourcesAvailabilityEnum,
Expand Down Expand Up @@ -55,7 +54,6 @@ const CooperationActivities: FC<CooperationActivitiesProps> = ({
const dispatch = useAppDispatch()
const { sections, resourcesAvailability } =
useAppSelector(cooperationsSelector)

const handleResourcesAvailabilityChange = (
status: ResourcesAvailabilityEnum
) => {
Expand Down
2 changes: 2 additions & 0 deletions src/styles/app-theme/app.pallete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ const palette = {
turquoiseChat: '#A0F0F2',
turquoiseLight: '#F5FFFF',
turquoise50: '#F2FAFA',
turquoise100: '#DAF1F1',
turquoise500: '#47B8B8',
turquoise700: '#2B6E6E',
blueGray: '#607D8B',
bismark: '#546E7A',
Expand Down
Loading