-
Notifications
You must be signed in to change notification settings - Fork 2
Reworked average calculator #18
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
base: staging
Are you sure you want to change the base?
Changes from all commits
756c26d
db3fa86
844000d
4381797
8e49e20
928e742
f3543f5
1b38d3a
606eaf1
d0ca9f6
90874da
508228a
1bf1c84
01edcbc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| # If you use the docker-based dev environment, keep it commented | ||
| #DATABASE_URL=postgresql:/admin:admin@localhost:5432/admin | ||
|
|
||
| NEXT_PUBLIC_FRONTEND_URL=http://localhost:3000 | ||
| NEXT_PUBLIC_GA_TRACKING_ID=REDACTED | ||
|
|
||
| LYDIA_API_VENDOR_ID=REDACTED | ||
| NEXT_PUBLIC_LYDIA_API_URL=REDACTED | ||
| NEXT_PUBLIC_LYDIA_API_VENDOR_TOKEN=REDACTED | ||
|
|
||
| SESSION_SECRET_KEY=generate_on_https://randomkeygen.com | ||
|
|
||
| SMTP_FROM=your_user@gmail.com | ||
| SMTP_HOST=smtp.gmail.com | ||
| SMTP_PASSWORD=your_password | ||
| SMTP_PORT=587 | ||
| SMTP_USER=your_user |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -55,3 +55,7 @@ lib-cov | |
|
|
||
| .idea | ||
| .vercel | ||
|
|
||
| dev/.db-migrated | ||
| dev/data/db | ||
| dev/data/pg4admin | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| import xlsx from 'xlsx' | ||
| import { useQuery } from 'blitz' | ||
| import Button from '@mui/material/Button' | ||
|
|
||
| import TableChartIcon from '@mui/icons-material/TableChart' | ||
|
|
||
| import Box from '@mui/material/Box' | ||
| import CircularProgress from '@mui/material/CircularProgress' | ||
| import getArticlesWithStats from 'app/entities/articles/queries/getArticlesWithStats' | ||
|
|
||
| export default function ExportArticles() { | ||
| const [{ articles }] = useQuery(getArticlesWithStats, {}) | ||
|
|
||
| const exportToExcel = () => { | ||
| const date = new Date() | ||
|
|
||
| const workBook = xlsx.utils.book_new() | ||
|
|
||
| workBook.Props = { | ||
| Title: 'BDE ISIMA - Utilisateurs', | ||
| Subject: 'Liste des utilisateurs', | ||
| CreatedDate: date, | ||
| } | ||
|
|
||
| workBook.SheetNames.push('Articles') | ||
|
|
||
| const workSheetData = [ | ||
| [ | ||
| 'Nom', | ||
| 'Prix', | ||
| 'Prix cotisants', | ||
| 'Visible', | ||
| 'Ajouté le', | ||
| 'Total ventes (semaine)', | ||
| 'Total ventes (mois)', | ||
| 'Total ventes (année)', | ||
| 'Total ventes', | ||
| ], | ||
| ...articles.map((article) => [ | ||
| article.name, | ||
| article.price, | ||
| article.member_price ?? article.price, | ||
| article.is_enabled ? 'Oui' : 'Non', | ||
| new Date(article.createdAt).toLocaleDateString('fr'), | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Je vais te faire un utilitaire ici pour format les dates, parce que je pense que c'est mieux de s'adapter à la locale du PC |
||
| article.weekCount ?? 0, | ||
| article.monthCount ?? 0, | ||
| article.yearCount ?? 0, | ||
| article.totalCount ?? 0, | ||
| ]), | ||
| ] | ||
|
|
||
| const workSheet = xlsx.utils.aoa_to_sheet(workSheetData) | ||
| workBook.Sheets['Articles'] = workSheet | ||
|
|
||
| workSheet['!autofilter'] = { ref: 'A1:I1' } | ||
|
|
||
| xlsx.writeFile( | ||
| workBook, | ||
| `bde_isima_articles-${date.getFullYear()}-${ | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pareil ici avec l'utilitaire tu pourras format la date à un format précis |
||
| date.getMonth() + 1 | ||
| }-${date.getDate()}_${date.getHours()}-${date.getMinutes()}.xlsx` | ||
| ) | ||
| } | ||
|
|
||
| return ( | ||
| <Button endIcon={<TableChartIcon />} variant="contained" onClick={exportToExcel}> | ||
| Exporter vers Excel | ||
| </Button> | ||
| ) | ||
| } | ||
|
|
||
| export function ExportArticlesFallback() { | ||
| return ( | ||
| <Box sx={{ m: 1, position: 'relative' }}> | ||
| <Button disabled endIcon={<TableChartIcon />} variant={'contained'}> | ||
| Exporter vers Excel | ||
| </Button> | ||
| <CircularProgress | ||
| size={25} | ||
| sx={{ | ||
| position: 'absolute', | ||
| top: '50%', | ||
| left: '50%', | ||
| marginTop: '-12px', | ||
| marginLeft: '-12px', | ||
| }} | ||
| /> | ||
| </Box> | ||
| ); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| import xlsx from 'xlsx' | ||
| import { useQuery } from 'blitz' | ||
|
corentin703 marked this conversation as resolved.
|
||
| import Button from '@mui/material/Button' | ||
|
|
||
| import TableChartIcon from '@mui/icons-material/TableChart' | ||
|
|
||
| import Box from '@mui/material/Box' | ||
| import { Promotion } from '@prisma/client' | ||
| import CircularProgress from '@mui/material/CircularProgress' | ||
| import getPromotions from 'app/entities/promotions/queries/getPromotions' | ||
|
|
||
| export default function ExportPromotions() { | ||
| const [{ promotions }] = useQuery(getPromotions, { | ||
| include: { | ||
| _count: { | ||
| select: { | ||
| User: true, | ||
| }, | ||
| }, | ||
| }, | ||
| orderBy: { | ||
| year: 'asc', | ||
| }, | ||
| }) | ||
|
|
||
| const exportToExcel = () => { | ||
| const date = new Date() | ||
|
|
||
| const workBook = xlsx.utils.book_new() | ||
|
|
||
| workBook.Props = { | ||
| Title: 'BDE ISIMA - Utilisateurs', | ||
| Subject: 'Liste des utilisateurs', | ||
| CreatedDate: date, | ||
| } | ||
|
|
||
| workBook.SheetNames.push('Promotions') | ||
|
|
||
| const workSheetData = [ | ||
| ['Année', 'ID Groupe Facebook', 'Liste de diffusion', "Nombre d'utilisateurs"], | ||
| ...promotions.map((promotion: Promotion & { _count: { User: number }}) => [ | ||
| promotion.year, | ||
| promotion.fb_group_id, | ||
| promotion.list_email, | ||
| promotion._count.User, | ||
| ]), | ||
| ] | ||
|
|
||
| const workSheet = xlsx.utils.aoa_to_sheet(workSheetData) | ||
| workBook.Sheets['Promotions'] = workSheet | ||
|
|
||
| workSheet['!autofilter'] = { ref: 'A1:D1' } | ||
|
|
||
| xlsx.writeFile( | ||
| workBook, | ||
| `bde_isima_promotions-${date.getFullYear()}-${ | ||
| date.getMonth() + 1 | ||
| }-${date.getDate()}_${date.getHours()}-${date.getMinutes()}.xlsx` | ||
| ) | ||
| } | ||
|
|
||
| return ( | ||
| <Button endIcon={<TableChartIcon />} variant={'contained'} onClick={exportToExcel}> | ||
| Exporter vers Excel | ||
| </Button> | ||
| ) | ||
| } | ||
|
|
||
| export function ExportPromotionsFallback() { | ||
| return ( | ||
| <Box sx={{ m: 1, position: 'relative' }}> | ||
| <Button disabled endIcon={<TableChartIcon />} variant={'contained'}> | ||
| Exporter vers Excel | ||
| </Button> | ||
| <CircularProgress | ||
| size={25} | ||
| sx={{ | ||
| position: 'absolute', | ||
| top: '50%', | ||
| left: '50%', | ||
| marginTop: '-12px', | ||
| marginLeft: '-12px', | ||
| }} | ||
| /> | ||
| </Box> | ||
| ); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| import xlsx from 'xlsx' | ||
| import { useQuery } from 'blitz' | ||
|
corentin703 marked this conversation as resolved.
|
||
| import Box from '@mui/material/Box' | ||
| import Button from '@mui/material/Button' | ||
| import { Promotion, User } from '@prisma/client' | ||
| import TableChartIcon from '@mui/icons-material/TableChart' | ||
| import CircularProgress from '@mui/material/CircularProgress' | ||
|
|
||
| import getUsers from 'app/entities/users/queries/getUsers' | ||
|
|
||
| export default function ExportUsers() { | ||
| const [{ users }] = useQuery(getUsers, { | ||
| include: { | ||
| promotion: { | ||
| select: { | ||
| year: true, | ||
| }, | ||
| }, | ||
| }, | ||
| where: { | ||
| is_enabled: true, | ||
| }, | ||
| orderBy: { | ||
| card: 'asc', | ||
| }, | ||
| }) | ||
|
|
||
| const exportToExcel = () => { | ||
| const date = new Date() | ||
|
|
||
| const workBook = xlsx.utils.book_new() | ||
|
|
||
| workBook.Props = { | ||
| Title: 'BDE ISIMA - Utilisateurs', | ||
| Subject: 'Liste des utilisateurs', | ||
| CreatedDate: date, | ||
| } | ||
|
|
||
| workBook.SheetNames.push('Utilisateurs') | ||
|
|
||
| const workSheetData = [ | ||
| ['Numéro carte', 'Prénom', 'Nom', 'Courriel', 'Promotion', 'Solde', 'Cotisant'], | ||
| ...users.map((user: User & { promotion: Promotion }) => [ | ||
| user.card, | ||
| user.firstname, | ||
| user.lastname, | ||
| user.email, | ||
| user.promotion ? user.promotion.year : 'N/A', | ||
| user.balance, | ||
| user.is_member ? 'Oui' : 'Non', | ||
| ]), | ||
| ] | ||
|
|
||
| const workSheet = xlsx.utils.aoa_to_sheet(workSheetData) | ||
| workBook.Sheets['Utilisateurs'] = workSheet | ||
|
|
||
| workSheet['!autofilter'] = { ref: 'A1:G1' } | ||
|
|
||
| xlsx.writeFile( | ||
| workBook, | ||
| `bde_isima_utilisateurs-${date.getFullYear()}-${ | ||
| date.getMonth() + 1 | ||
| }-${date.getDate()}_${date.getHours()}-${date.getMinutes()}.xlsx` | ||
| ) | ||
| } | ||
|
|
||
| return ( | ||
| <Button endIcon={<TableChartIcon />} variant={'contained'} onClick={exportToExcel}> | ||
| Exporter vers Excel | ||
| </Button> | ||
| ) | ||
| } | ||
|
|
||
| export function ExportUserFallback() { | ||
| return ( | ||
| <Box sx={{ m: 1, position: 'relative' }}> | ||
| <Button disabled endIcon={<TableChartIcon />} variant={'contained'}> | ||
| Exporter vers Excel | ||
| </Button> | ||
| <CircularProgress | ||
| size={25} | ||
| sx={{ | ||
| position: 'absolute', | ||
| top: '50%', | ||
| left: '50%', | ||
| marginTop: '-12px', | ||
| marginLeft: '-12px', | ||
| }} | ||
| /> | ||
| </Box> | ||
| ); | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.