-
Notifications
You must be signed in to change notification settings - Fork 16
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
Block with statistics by lessons quantity #2616
Merged
Renatavl
merged 5 commits into
develop
from
feature/459/statistics-block-with-lessons-quantity
Nov 14, 2024
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
src/components/quantity-lessons-card/QuantityLessonChart/QuantityLessonsChart.constants.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import palette from '~/styles/app-theme/app.pallete' | ||
|
||
export const data = { | ||
labels: [ | ||
'JAN', | ||
'FEB', | ||
'MAR', | ||
'APR', | ||
'MAY', | ||
'JUN', | ||
'JUL', | ||
'AUG', | ||
'SEP', | ||
'OCT', | ||
'NOV', | ||
'DEC' | ||
], | ||
datasets: [ | ||
{ | ||
label: 'Lessons', | ||
data: [5, 5, 10, 10, 12, 15, 14, 14, 10, 10, 12, 12], | ||
backgroundColor: palette.success[300], | ||
borderColor: palette.success[300], | ||
borderWidth: 1, | ||
barThickness: 28 | ||
} | ||
] | ||
} | ||
|
||
export const options = { | ||
responsive: true, | ||
maintainAspectRatio: false, | ||
plugins: { | ||
legend: { | ||
display: false | ||
} | ||
}, | ||
scales: { | ||
x: { | ||
grid: { | ||
display: false | ||
}, | ||
ticks: { | ||
color: palette.basic.darkGray, | ||
weight: 'normal' | ||
}, | ||
border: { | ||
display: false | ||
} | ||
}, | ||
y: { | ||
beginAtZero: true, | ||
max: 15, | ||
ticks: { | ||
stepSize: 5 | ||
}, | ||
border: { | ||
display: false | ||
} | ||
} | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
src/components/quantity-lessons-card/QuantityLessonChart/QuantityLessonsChart.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import React, { useMemo } from 'react' | ||
import { Bar } from 'react-chartjs-2' | ||
import { | ||
Chart as ChartJS, | ||
CategoryScale, | ||
LinearScale, | ||
BarElement, | ||
Title, | ||
Tooltip, | ||
Legend | ||
} from 'chart.js' | ||
import { Box } from '@mui/material' | ||
import useBreakpoints from '~/hooks/use-breakpoints' | ||
import { data, options } from './QuantityLessonsChart.constants' | ||
|
||
ChartJS.register(CategoryScale, LinearScale, BarElement, Title, Tooltip, Legend) | ||
|
||
const QuantityLessonsChart = () => { | ||
const { isMobile } = useBreakpoints() | ||
|
||
const dataResponsive = useMemo(() => { | ||
const obj = data | ||
obj.datasets[0].barThickness = isMobile ? 20 : 28 | ||
|
||
return obj | ||
}, [isMobile]) | ||
|
||
return ( | ||
<Box height='181px' key={+isMobile}> | ||
<Bar data={dataResponsive} options={options} /> | ||
</Box> | ||
) | ||
} | ||
|
||
export default QuantityLessonsChart |
54 changes: 54 additions & 0 deletions
54
src/components/quantity-lessons-card/QuantityLessons.constants.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
export const categories = [ | ||
{ | ||
value: 'Music' | ||
}, | ||
|
||
{ | ||
value: 'Marketing' | ||
}, | ||
|
||
{ | ||
value: 'Bology' | ||
}, | ||
|
||
{ | ||
value: 'IT' | ||
} | ||
] | ||
|
||
export const subjects = [ | ||
{ | ||
value: 'Algebra' | ||
}, | ||
|
||
{ | ||
value: 'Geometry' | ||
}, | ||
|
||
{ | ||
value: 'English' | ||
}, | ||
|
||
{ | ||
value: 'French' | ||
} | ||
] | ||
|
||
const currentYear = new Date().getFullYear() | ||
export const years = [ | ||
{ | ||
value: currentYear - 3 | ||
}, | ||
|
||
{ | ||
value: currentYear - 2 | ||
}, | ||
|
||
{ | ||
value: currentYear - 1 | ||
}, | ||
|
||
{ | ||
value: currentYear | ||
} | ||
] |
52 changes: 52 additions & 0 deletions
52
src/components/quantity-lessons-card/QuantityLessonsCard.styles.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { TypographyVariantEnum } from '~/types' | ||
|
||
export const styles = { | ||
cardContainer: { | ||
width: '100%', | ||
maxWidth: '640px', | ||
height: { xs: '450px', sm: '400px' }, | ||
borderRadius: '8px', | ||
backgroundColor: 'basic.white', | ||
mt: '75px', | ||
p: '25px 20px 32px', | ||
boxSizing: 'border-box', | ||
display: 'flex', | ||
flexDirection: 'column' | ||
}, | ||
cardContainerTitle: { | ||
typography: TypographyVariantEnum.H5, | ||
color: 'basic.darkGray', | ||
mb: '5px' | ||
}, | ||
cardContainerCaption: { | ||
typography: TypographyVariantEnum.Body2, | ||
color: 'basic.blueGray', | ||
mb: '15px' | ||
}, | ||
select: { | ||
height: '40px', | ||
border: '1px solid', | ||
borderColor: 'basic.gray', | ||
'& .MuiSelect-select': { | ||
p: '8px 10px' | ||
} | ||
}, | ||
selectAndButtonContainer: { | ||
display: 'flex', | ||
flexDirection: 'row', | ||
alignItems: 'center', | ||
mb: 'auto', | ||
flexWrap: 'wrap', | ||
gap: '8px' | ||
}, | ||
clearAllButton: { | ||
height: '40px', | ||
ml: 'auto', | ||
typography: TypographyVariantEnum.Body1, | ||
color: 'basic.darkGray' | ||
}, | ||
selectedValue: { | ||
display: 'flex', | ||
gap: 1 | ||
} | ||
} |
80 changes: 80 additions & 0 deletions
80
src/components/quantity-lessons-card/QuantityLessonsCard.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import { Box, Button, MenuItem, Select, Typography } from '@mui/material' | ||
import { styles } from './QuantityLessonsCard.styles' | ||
import SchoolIcon from '@mui/icons-material/School' | ||
import EventIcon from '@mui/icons-material/Event' | ||
import QuantityLessonsChart from './QuantityLessonChart/QuantityLessonsChart' | ||
import { useTranslation } from 'react-i18next' | ||
import { categories, subjects, years } from './QuantityLessons.constants' | ||
|
||
function QuantityLessonsCard() { | ||
const { t } = useTranslation() | ||
return ( | ||
<Box sx={styles.cardContainer}> | ||
<Typography sx={styles.cardContainerTitle}> | ||
{t('tutorHomePage.lessonsQuantity.title')} | ||
</Typography> | ||
<Typography sx={styles.cardContainerCaption}> | ||
{t('tutorHomePage.lessonsQuantity.subTitle')} | ||
</Typography> | ||
<Box sx={styles.selectAndButtonContainer}> | ||
<Select | ||
displayEmpty | ||
renderValue={(value: string) => ( | ||
<Box sx={styles.selectedValue}> | ||
<SchoolIcon />{' '} | ||
{value ?? t('tutorHomePage.lessonsQuantity.select.category')} | ||
</Box> | ||
)} | ||
sx={styles.select} | ||
> | ||
{categories.map((option) => ( | ||
<MenuItem key={option.value} value={option.value}> | ||
{option.value} | ||
</MenuItem> | ||
))} | ||
</Select> | ||
|
||
<Select | ||
displayEmpty | ||
renderValue={(value: string) => ( | ||
<Box sx={styles.selectedValue}> | ||
<SchoolIcon />{' '} | ||
{value ?? t('tutorHomePage.lessonsQuantity.select.subject')} | ||
</Box> | ||
)} | ||
sx={styles.select} | ||
> | ||
{subjects.map((option) => ( | ||
<MenuItem key={option.value} value={option.value}> | ||
{option.value} | ||
</MenuItem> | ||
))} | ||
</Select> | ||
|
||
<Select | ||
displayEmpty | ||
renderValue={(value: string) => ( | ||
<Box sx={styles.selectedValue}> | ||
<EventIcon />{' '} | ||
{value ?? t('tutorHomePage.lessonsQuantity.select.year')} | ||
</Box> | ||
)} | ||
sx={styles.select} | ||
> | ||
{years.map((option) => ( | ||
<MenuItem key={option.value} value={option.value}> | ||
{option.value} | ||
</MenuItem> | ||
))} | ||
</Select> | ||
|
||
<Button sx={styles.clearAllButton} variant='text'> | ||
{t('tutorHomePage.lessonsQuantity.resetButton')} | ||
</Button> | ||
</Box> | ||
<QuantityLessonsChart /> | ||
</Box> | ||
) | ||
} | ||
|
||
export default QuantityLessonsCard |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please remove the blank lines