From f22271e85cc829071115db269b4e5facf25ac799 Mon Sep 17 00:00:00 2001 From: shinework Date: Mon, 18 Mar 2024 18:45:19 +0100 Subject: [PATCH] feat: folder improvement and bug fix --- .../application/controllers/application.js | 7 +++--- .../1.0.0/full_documentation.json | 2 +- web/components/Account/AccountMenu.tsx | 4 +++- web/components/Campaign/CampaignProvider.tsx | 6 +++++ .../Home/ApplicationsCampaignInsert.tsx | 20 +++++++++------- web/components/Place/PlacesCampaignTabs.tsx | 24 +++++++++---------- web/pages/api/pdfs/selected/[id].tsx | 17 +++++++++---- web/pages/compte/mes-candidatures/index.tsx | 7 +++++- 8 files changed, 56 insertions(+), 31 deletions(-) diff --git a/back/api/application/controllers/application.js b/back/api/application/controllers/application.js index 75939ab..7849a4d 100644 --- a/back/api/application/controllers/application.js +++ b/back/api/application/controllers/application.js @@ -18,9 +18,9 @@ module.exports = { const query = type === 'place' ? { - ...initialQuery, - 'disponibility.espace.users_permissions_user.id': id, - } + ...initialQuery, + 'disponibility.espace.users_permissions_user.id': id, + } : { ...initialQuery, company: id } const populate = type === 'place' @@ -59,6 +59,7 @@ module.exports = { 'creation_file', 'campaign', 'company', + 'espace', ], ) diff --git a/back/extensions/documentation/documentation/1.0.0/full_documentation.json b/back/extensions/documentation/documentation/1.0.0/full_documentation.json index a5563b5..3863c63 100644 --- a/back/extensions/documentation/documentation/1.0.0/full_documentation.json +++ b/back/extensions/documentation/documentation/1.0.0/full_documentation.json @@ -14,7 +14,7 @@ "name": "Apache 2.0", "url": "https://www.apache.org/licenses/LICENSE-2.0.html" }, - "x-generation-date": "03/10/2024 10:56:56 PM" + "x-generation-date": "03/18/2024 6:34:37 PM" }, "x-strapi-config": { "path": "/documentation", diff --git a/web/components/Account/AccountMenu.tsx b/web/components/Account/AccountMenu.tsx index 9ae93bf..c7cf88d 100644 --- a/web/components/Account/AccountMenu.tsx +++ b/web/components/Account/AccountMenu.tsx @@ -160,7 +160,9 @@ const AccountMenu = ({ user }: { user: UsersPermissionsUser }) => { currentCampaign.mode !== 'closed') const hideApplication = - currentCampaign?.mode === 'preselections' && + ['waiting_preselections', 'preselections'].includes( + currentCampaign?.mode, + ) && !applications?.length && user?.type === 'company' diff --git a/web/components/Campaign/CampaignProvider.tsx b/web/components/Campaign/CampaignProvider.tsx index 8cecfe5..14683b1 100644 --- a/web/components/Campaign/CampaignProvider.tsx +++ b/web/components/Campaign/CampaignProvider.tsx @@ -56,6 +56,11 @@ const CampaignProvider = ({ children }: ICampaignProvider) => { today <= getEndDateTime(campaign.application_end) ) { return 'applications' + } else if ( + today > getEndDateTime(campaign.application_end) && + today < getStartDateTime(campaign.preselection_start) + ) { + return 'waiting_preselections' } else if ( today >= getStartDateTime(campaign.preselection_start) && today <= getEndDateTime(campaign.preselection_end) @@ -64,6 +69,7 @@ const CampaignProvider = ({ children }: ICampaignProvider) => { } else if (today >= getEndDateTime(campaign.preselection_end)) { return 'closed' } + return null } diff --git a/web/components/Campaign/Home/ApplicationsCampaignInsert.tsx b/web/components/Campaign/Home/ApplicationsCampaignInsert.tsx index df1ac0b..c90c51d 100644 --- a/web/components/Campaign/Home/ApplicationsCampaignInsert.tsx +++ b/web/components/Campaign/Home/ApplicationsCampaignInsert.tsx @@ -1,14 +1,14 @@ -import { VStack, Text, Box, Button, HStack, Stack } from '@chakra-ui/react' -import Hands from 'public/assets/img/hands-outline.svg' -import theme from '~theme' +import { Box, Button, HStack, Stack, Text, VStack } from '@chakra-ui/react' +import { motion } from 'framer-motion' import { useTranslation } from 'next-i18next' -import { ROUTE_PLACES } from '~constants' -import Tag from '~components/Tag' -import Link from '~components/Link' +import Hands from 'public/assets/img/hands-outline.svg' +import ApplicationCounter from '~components/Campaign/ApplicationCounter' import useCampaignContext from '~components/Campaign/useCampaignContext' +import Link from '~components/Link' +import Tag from '~components/Tag' +import { ROUTE_PLACES } from '~constants' +import theme from '~theme' import { format } from '~utils/date' -import ApplicationCounter from '~components/Campaign/ApplicationCounter' -import { motion } from 'framer-motion' const ApplicationsCampaignInsert = () => { const { currentCampaign } = useCampaignContext() @@ -28,7 +28,9 @@ const ApplicationsCampaignInsert = () => { transition="3s linear" > - {t(`campaign.title`,{title: currentCampaign?.title})} + + {t(`campaign.title`, { title: currentCampaign?.title })} + diff --git a/web/components/Place/PlacesCampaignTabs.tsx b/web/components/Place/PlacesCampaignTabs.tsx index 7659536..2d7f2c4 100644 --- a/web/components/Place/PlacesCampaignTabs.tsx +++ b/web/components/Place/PlacesCampaignTabs.tsx @@ -1,20 +1,20 @@ -import React, { useEffect, useState } from 'react' import { - Tabs, - TabPanels, - TabPanel, - TabList, - Tab, + Box, HStack, + Tab, + TabList, + TabPanel, + TabPanels, + Tabs, Text, - Box, } from '@chakra-ui/react' -import { format } from '~utils/date' -import Tag from '~components/Tag' import { useTranslation } from 'next-i18next' -import PlacesPage from '~components/Place/PlacesPage' -import useCampaignContext from '~components/Campaign/useCampaignContext' import { useRouter } from 'next/router' +import { useEffect, useState } from 'react' +import useCampaignContext from '~components/Campaign/useCampaignContext' +import PlacesPage from '~components/Place/PlacesPage' +import Tag from '~components/Tag' +import { format } from '~utils/date' const PlacesCampaignTabs = () => { const router = useRouter() @@ -87,7 +87,7 @@ const PlacesCampaignTabs = () => { paddingY={2} borderRadius="12px" > - {t(`campaign.title`,{title: currentCampaign?.title})} + {t(`campaign.title`, { title: currentCampaign?.title })} diff --git a/web/pages/api/pdfs/selected/[id].tsx b/web/pages/api/pdfs/selected/[id].tsx index 6e8a5ff..1468ddf 100644 --- a/web/pages/api/pdfs/selected/[id].tsx +++ b/web/pages/api/pdfs/selected/[id].tsx @@ -4,6 +4,7 @@ import AdmZip from 'adm-zip' import { getSession } from 'next-auth/client' import { client } from '~api/client-api' import ApplicationDocument from '~components/pdfs/ApplicationDocument' +import { format } from '~utils/date' import { formatCampaignZipName, getBufferFromStream } from '~utils/pdf' const SelectedCampaignApplications = async (req, res) => { @@ -18,7 +19,7 @@ const SelectedCampaignApplications = async (req, res) => { const zip = new AdmZip() const { data: campaign } = await client.campaigns.campaignsDetail(campaignId) - console.log({jwt:session.user.jwt}) + console.log({ jwt: session.user.jwt }) try { const { @@ -32,7 +33,6 @@ const SelectedCampaignApplications = async (req, res) => { }, ) - // Group by place const groupedApplications = selectedApplications.reduce( (grouped, application) => { @@ -64,6 +64,7 @@ const SelectedCampaignApplications = async (req, res) => { for (const userId of userIds) { const applications = groupedApplications[userId] + const place = applications[0]?.disponibility?.espace?.users_permissions_user const name = place?.structureName @@ -76,9 +77,17 @@ const SelectedCampaignApplications = async (req, res) => { ) const refLabel = `Ref. ${application.id}` + + const disponibilityLabel = `${format( + application.disponibility?.start, + 'dd-MM', + )} au ${format(application.disponibility?.end, 'dd-MM')}` + + const subFolder = `${application?.espace?.name} - ${disponibilityLabel} - ${refLabel} - ${structureName}` + const streamBuffer = await getBufferFromStream(stream) await zip.addFile( - `${name}/${refLabel} - ${structureName}/${refLabel} - Candidature.pdf`, + `${name}/${subFolder}/${refLabel} - Candidature.pdf`, streamBuffer, ) @@ -88,7 +97,7 @@ const SelectedCampaignApplications = async (req, res) => { const creationFileArrayBuffer = await creationFile.buffer() await zip.addFile( - `${name}/${refLabel} - ${structureName}/${refLabel} - Dossier artistique.pdf`, + `${name}/${subFolder}/${refLabel} - Dossier artistique.pdf`, creationFileArrayBuffer, ) } diff --git a/web/pages/compte/mes-candidatures/index.tsx b/web/pages/compte/mes-candidatures/index.tsx index efcea90..efe4300 100644 --- a/web/pages/compte/mes-candidatures/index.tsx +++ b/web/pages/compte/mes-candidatures/index.tsx @@ -45,7 +45,12 @@ const CompanyApplications = ({ user }: Props) => { return null } - if (currentCampaign?.mode === 'preselections' && applications?.length === 0) { + if ( + ['preselections', 'waiting_preselections'].includes( + currentCampaign?.mode, + ) && + applications?.length === 0 + ) { router.push(ROUTE_ACCOUNT) return null }