Skip to content

Commit

Permalink
Fix style and wording (#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucieo authored Mar 7, 2024
1 parent 032ca78 commit b4f012c
Show file tree
Hide file tree
Showing 11 changed files with 779 additions and 217 deletions.
911 changes: 709 additions & 202 deletions back/extensions/documentation/documentation/1.0.0/full_documentation.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const ApplicationCompanyList = ({ applications = [] }: Props) => {
'myApplications',
query?.disponibility as string,
])
queryClient.refetchQueries(['me'])
} catch (e) {
errorToast(t('company.delete_error'))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ const FullApplications = ({ numApplications }: { numApplications: number }) => {
</Text>
<Text as="span" pl={1}>
{t('company.helper.full_end', {
date: format(currentCampaign.preselection_end),
end_applications_date: format(currentCampaign.application_end),
end_preselections_date: format(currentCampaign.preselection_end),
})}
</Text>
</Box>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const ApplicationDownloadAll = () => {
//@ts-expect-error
disponibility: applications[0]?.disponibility,
onError: () => errorToast(t('error')),
campaign: selectedCampaign,
})
} catch (err) {
console.log(err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,17 @@ const ApplicationPlaceList = ({ applications = [] }: Props) => {
</SimpleGrid>
) : (
<Box p={4} backgroundColor="gray.50" borderRadius={4} width="100%">
<Text>{t('place.no_applications')}</Text>
<Text>
{t(
`place.no_applications${
Boolean(
['closed', 'preselections']?.includes(selectedCampaign?.mode),
)
? '_past'
: ''
}`,
)}
</Text>
</Box>
)}

Expand Down
31 changes: 29 additions & 2 deletions web/components/Campaign/Places/Application/LockedApplications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import BookingScheduleContext from '~components/Place/Booking/BookingScheduleCon
import { ROUTE_ACCOUNT_MY_APPLICATIONS } from '~constants'
import { useCurrentUser } from '~hooks/useCurrentUser'
import { Disponibility } from '~typings/api'
import { format } from '~utils/date'

const LockedApplications = ({
disponibilities,
Expand Down Expand Up @@ -36,11 +37,37 @@ const LockedApplications = ({
),
[disponibilities, selected],
)
const hasReachedMax =

const hasReachedMaxWithSelected =
selected?.length + applications?.length >=
currentCampaign?.applications_max && unselectedDisponibilities?.length > 0

if (hasReachedMax) {
if (remainingApplications === 0) {
return (
<Box backgroundColor="gray.100" p={6} width="100%" borderRadius="8px">
<Text as="span" fontWeight="bold">
{t('detail.campaign.locked_max_start')}
</Text>
<Text as="span" pl={1}>
{t(`detail.campaign.locked_max_middle`, {
title: currentCampaign?.title,
})}
</Text>
<Link href={ROUTE_ACCOUNT_MY_APPLICATIONS}>
<Text as="span" pl={1} textDecoration="underline">
{t(`detail.campaign.locked_max_cta`, {
end_applications_date: format(currentCampaign?.application_end),
})}
</Text>
</Link>
<Text as="span" pl={1}>
{t(`detail.campaign.locked_max_end`)}
</Text>
</Box>
)
}

if (hasReachedMaxWithSelected) {
const plural = remainingApplications === 1 ? 'singular' : 'plural'
return (
<Box backgroundColor="gray.100" p={6} width="100%" borderRadius="8px">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const CampaignPlaceDetail = ({ place }: Props) => {
isMobile={isMobile}
isCampaignTab={isCampaignTab}
/>
<CampaignPlaceFiles place={place} />
{isCampaignTab && <CampaignPlaceFiles place={place} />}
</VStack>
</Stack>

Expand Down
6 changes: 4 additions & 2 deletions web/pages/api/pdfs/all/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const MultipleApplication = async (req, res) => {
)

const disponibility = applications?.[0]?.disponibility
const campaign = applications?.[0]?.campaign

const merger = new PDFMerger()
let finalPDF
Expand All @@ -54,8 +55,9 @@ const MultipleApplication = async (req, res) => {
res.setHeader('Content-Type', 'application/pdf')
res.setHeader(
'Content-Disposition',
// @ts-expect-error
'attachment; filename=' + formatDisponibilityPdfName(disponibility),
'attachment; filename=' +
// @ts-expect-error
formatDisponibilityPdfName(disponibility, campaign),
)
res.send(finalPDF)
}
Expand Down
9 changes: 5 additions & 4 deletions web/public/locales/fr/application.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
"cta": "Voir les espaces partenaires",
"closed_start": "La période de candidature au dispositif {{title}} est maintenant clôturée.",
"closed_end": "La décision de chaque lieu sera connue d’ici au {{date}}. En cas de sélection, le lieu prendra contact directement avec vous hors de cette plateforme.",
"full_start": "Votre candidature est déposée pour le dispositif {{title}}.",
"full_starts": "Vos candidatures sont déposées pour le dispositif {{title}}.",
"full_end": "La décision de chaque lieu sera connue d’ici au {{date}}. En cas de sélection, le lieu prendra contact directement avec vous par email. Merci pour votre participation."
"full_start": "Votre candidature est déposée pour le dispositif.",
"full_starts": "Vos candidatures sont déposées pour le dispositif.",
"full_end": "Vous pouvez changer d'avis et revoir vos choix d'ici le {{end_applications_date}}. Une fois cette date passée, les lieux partenaires recevront l'ensemble des candidatures et leurs décisions seront connues d'ici au {{end_preselections_date}}. En cas de sélection, le lieu prendra contact directement avec vous par email. Merci pour votre participation."
},
"delete_error": "Une erreur est survenue lors de la suppression de votre candidature",
"delete_success": "Votre candidature a bien été supprimée",
Expand Down Expand Up @@ -67,7 +67,8 @@
"confirm_success": "Vos pré-sélections ont bien été transmises à StudioD"
},
"no_places": "Aucun de vos espaces ne propose de créneau pour ce dispositif",
"no_applications": "Aucune candidature n'a été déposée pour ce créneau.",
"no_applications": "Aucune candidature déposée pour ce créneau pour le moment.",
"no_applications_past": "Aucune candidature n'a été déposée pour ce créneau.",
"detail": {
"title": "Candidature n°{{id}}",
"header": {
Expand Down
6 changes: 5 additions & 1 deletion web/public/locales/fr/place.json
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,11 @@
"locked_application_cta_plural": "Annulez l’une de vos candidatures en attente",
"locked_application_cta_singular": "Annulez votre candidature en attente",
"locked_application_end": "pour pouvoir postuler à un ou plusieurs des créneaux de cet espace.",
"locked_application_remaining_end": "pour pouvoir postuler à plus de créneaux de cet espace."
"locked_application_remaining_end": "pour pouvoir postuler à plus de créneaux de cet espace.",
"locked_max_start": "Vous avez atteint le nombre maximal de candidature déposées",
"locked_max_middle": "pour cette session du dispositif {{title}}.",
"locked_max_cta": "Annulez l’une de vos candidatures d'ici le {{end_applications_date}}",
"locked_max_end": "pour pouvoir postuler à un ou plusieurs des créneaux de cet espace."
},
"back": "Retour à la recherche",
"seeMap": "Voir sur la carte",
Expand Down
14 changes: 11 additions & 3 deletions web/utils/pdf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ export const handleApplicationDownload = async ({
link.parentNode?.removeChild(link)
}

export const formatDisponibilityPdfName = (disponibility: Disponibility) => {
export const formatDisponibilityPdfName = (
disponibility: Disponibility,
campaign: Campaign,
) => {
return `${disponibility?.espace?.name?.split(' ').join('_')}_${format(
disponibility?.start,
'dd-MM-yyyy',
Expand All @@ -57,14 +60,16 @@ export const formatDisponibilityPdfName = (disponibility: Disponibility) => {
//@ts-expect-error
)}_${disponibility?.espace?.users_permissions_user?.structureName
?.split(' ')
.join('_')}_${disponibility?.campaign?.title?.split(' ').join('_')}.pdf`
.join('_')}_${campaign?.title?.split(' ').join('_')}.pdf`
}

export const handleDisponibilityDownload = async ({
disponibility,
campaign,
onError,
}: {
disponibility: Disponibility
campaign: Campaign
onError: () => void
}) => {
const res = await fetch(`/api/pdfs/all/${disponibility.id}`)
Expand All @@ -75,7 +80,10 @@ export const handleDisponibilityDownload = async ({
const url = window.URL.createObjectURL(blob)
const link = document.createElement('a')
link.href = url
link.setAttribute('download', formatDisponibilityPdfName(disponibility))
link.setAttribute(
'download',
formatDisponibilityPdfName(disponibility, campaign),
)
document.body.appendChild(link)
link.click()
link.parentNode?.removeChild(link)
Expand Down

0 comments on commit b4f012c

Please sign in to comment.