-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Download applications * No wrap white space on home button * White text color on button * Mark parameter as optional
- Loading branch information
Showing
28 changed files
with
1,545 additions
and
100 deletions.
There are no files selected for viewing
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
65 changes: 65 additions & 0 deletions
65
web/components/Account/Application/Place/ApplicationDownloadAll.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,65 @@ | ||
import { Button, useDisclosure } from '@chakra-ui/react' | ||
import { useTranslation } from 'next-i18next' | ||
import { useRouter } from 'next/router' | ||
import { useState } from 'react' | ||
import ApplicationDownloadButton from '~components/Account/Application/Place/ApplicationsPdf/ApplicationDownloadButton' | ||
import { useMyApplications } from '~hooks/useMyApplications' | ||
import useSelectedCampaign from '~hooks/useSelectedCampaign' | ||
|
||
const ApplicationDownloadAll = () => { | ||
const { selectedCampaign } = useSelectedCampaign() | ||
const { t } = useTranslation('application') | ||
const { query } = useRouter() | ||
|
||
const { data: applications, isLoading, isFetching } = useMyApplications({ | ||
name: ['myApplications', query?.disponibility as string], | ||
campaignId: query.campaign as string, | ||
searchParams: { ...query, _sort: 'company.structureName:asc' }, | ||
options: { | ||
enabled: Boolean(query?.disponibility) && Boolean(query?.espace), | ||
}, | ||
}) | ||
|
||
if (['disponibilities', 'applications']?.includes(selectedCampaign?.mode)) { | ||
return null | ||
} | ||
const { onOpen, onClose, isOpen } = useDisclosure() | ||
const [downloadedApplications, setDownloadedApplications] = useState([]) | ||
|
||
return ( | ||
<> | ||
<Button | ||
colorScheme={selectedCampaign?.mode === 'closed' ? 'gray' : 'blue'} | ||
backgroundColor={ | ||
selectedCampaign?.mode === 'closed' ? 'gray.700' : undefined | ||
} | ||
color={'white'} | ||
size="lg" | ||
onClick={() => { | ||
setDownloadedApplications([]) | ||
onOpen() | ||
}} | ||
isLoading={ | ||
isLoading || | ||
isFetching || | ||
(isOpen && applications?.length !== downloadedApplications.length) | ||
} | ||
> | ||
{t('place.download')} | ||
</Button> | ||
{applications?.map((application) => ( | ||
<ApplicationDownloadButton | ||
application={application} | ||
controlledOnClose={onClose} | ||
controlledIsOpen={isOpen} | ||
key={application?.id} | ||
onDownloadFinish={(id) => { | ||
setDownloadedApplications([...downloadedApplications, id]) | ||
}} | ||
/> | ||
))} | ||
</> | ||
) | ||
} | ||
|
||
export default ApplicationDownloadAll |
2 changes: 0 additions & 2 deletions
2
web/components/Account/Application/Place/ApplicationPlaceFetcher.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
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
75 changes: 75 additions & 0 deletions
75
web/components/Account/Application/Place/ApplicationsPdf/ApplicationDownloadButton.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,75 @@ | ||
import { Box, IconButton, useDisclosure } from '@chakra-ui/react' | ||
import DownloadApplication from 'public/assets/img/downloadApplication.svg' | ||
import { useRef, useState } from 'react' | ||
import { downloadPdf } from '~components/Account/Application/Place/ApplicationsPdf/pdfUtils' | ||
import SingleApplication from '~components/Account/Application/Place/SingleApplication' | ||
import useSelectedCampaign from '~hooks/useSelectedCampaign' | ||
import { Application } from '~typings/api' | ||
|
||
const ApplicationDownloadButton = ({ | ||
application, | ||
controlledIsOpen, | ||
controlledOnClose, | ||
onDownloadFinish, | ||
}: { | ||
application: Application | ||
controlledIsOpen?: boolean | ||
controlledOnClose?: () => void | ||
onDownloadFinish?: (id: string) => void | ||
}) => { | ||
const pdfRef = useRef() | ||
const [isLoading, setIsLoading] = useState(false) | ||
const { isOpen, onOpen, onClose } = useDisclosure() | ||
const { selectedCampaign } = useSelectedCampaign() | ||
|
||
return ( | ||
<> | ||
<IconButton | ||
px={2} | ||
py={1} | ||
variant="outline" | ||
color="grayText.1" | ||
colorScheme="gray" | ||
size="sm" | ||
borderRadius="sm" | ||
fontSize="md" | ||
aria-label="dowload" | ||
borderColor="rgba(98,103,130, 0.6)" | ||
icon={<DownloadApplication />} | ||
isLoading={isLoading} | ||
onClick={async () => { | ||
onOpen() | ||
setIsLoading(true) | ||
}} | ||
display={controlledOnClose ? 'none' : 'inherit'} | ||
/> | ||
|
||
{(controlledIsOpen !== undefined ? controlledIsOpen : isOpen) && ( | ||
<Box w="1px" h="1px" overflow={'hidden'}> | ||
<SingleApplication | ||
application={application} | ||
ref={pdfRef} | ||
handleDownload={async (ref) => { | ||
await downloadPdf( | ||
ref, | ||
`application_${ | ||
application.id | ||
}_${application?.company?.structureName | ||
?.split(' ') | ||
?.join('_')}_${selectedCampaign?.title | ||
?.split(' ') | ||
?.join('_')}`, | ||
application?.creation_file[0]?.url, | ||
) | ||
setIsLoading(false) | ||
onDownloadFinish(application.id) | ||
controlledOnClose ? controlledOnClose() : onClose() | ||
}} | ||
/> | ||
</Box> | ||
)} | ||
</> | ||
) | ||
} | ||
|
||
export default ApplicationDownloadButton |
68 changes: 68 additions & 0 deletions
68
web/components/Account/Application/Place/ApplicationsPdf/ApplicationPdfCreation.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,68 @@ | ||
import { Text, Heading, VStack, Divider } from '@chakra-ui/react' | ||
import { useTranslation } from 'next-i18next' | ||
import ApplicationFormTitle from '~components/Campaign/Places/Application/ApplicationFormTitle' | ||
import { Application } from '~typings/api' | ||
|
||
const ApplicationPdfCreation = ({ | ||
application, | ||
}: { | ||
application: Application | ||
}) => { | ||
const { t } = useTranslation('place') | ||
return ( | ||
<VStack alignItems="flex-start"> | ||
<ApplicationFormTitle | ||
title={t('campaignApplication.creation.title')} | ||
position="3." | ||
spacing={6} | ||
/> | ||
|
||
<VStack width="100%" spacing={4}> | ||
<VStack width="100%" alignItems="flex-start"> | ||
<Text fontFamily="mabry medium"> | ||
{t('campaignApplication.creation.field_title')} | ||
</Text> | ||
<Text>{application?.creation_title}</Text> | ||
</VStack> | ||
|
||
<Divider opacity={0.3} /> | ||
|
||
<VStack width="100%" alignItems="flex-start"> | ||
<Text fontFamily="mabry medium"> | ||
{t('campaignApplication.creation.dancers')} | ||
</Text> | ||
<Text>{application?.creation_dancers}</Text> | ||
</VStack> | ||
|
||
<Divider opacity={0.3} /> | ||
|
||
<VStack width="100%" alignItems="flex-start"> | ||
<Text fontFamily="mabry medium"> | ||
{t('campaignApplication.creation.summary')} | ||
</Text> | ||
<Text>{application?.creation_summary}</Text> | ||
</VStack> | ||
|
||
<Divider opacity={0.3} /> | ||
|
||
<VStack width="100%" alignItems="flex-start"> | ||
<Text fontFamily="mabry medium"> | ||
{t('campaignApplication.creation.partnerships')} | ||
</Text> | ||
<Text>{application?.creation_partnerships}</Text> | ||
</VStack> | ||
|
||
<Divider opacity={0.3} /> | ||
|
||
<VStack width="100%" alignItems="flex-start"> | ||
<Text fontFamily="mabry medium"> | ||
{t('campaignApplication.creation.technical')} | ||
</Text> | ||
<Text>{application?.creation_techical_requirements}</Text> | ||
</VStack> | ||
</VStack> | ||
</VStack> | ||
) | ||
} | ||
|
||
export default ApplicationPdfCreation |
48 changes: 48 additions & 0 deletions
48
web/components/Account/Application/Place/ApplicationsPdf/ApplicationPdfGeneral.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,48 @@ | ||
import { Text, Heading, VStack, Divider } from '@chakra-ui/react' | ||
import { useTranslation } from 'next-i18next' | ||
import ApplicationFormTitle from '~components/Campaign/Places/Application/ApplicationFormTitle' | ||
import { Application } from '~typings/api' | ||
|
||
const ApplicationPdfGeneral = ({ | ||
application, | ||
}: { | ||
application: Application | ||
}) => { | ||
const { t } = useTranslation('place') | ||
return ( | ||
<VStack alignItems="flex-start"> | ||
<ApplicationFormTitle | ||
title={t('campaignApplication.general.title')} | ||
position="2." | ||
spacing={6} | ||
/> | ||
|
||
<VStack width="100%" spacing={4}> | ||
<VStack width="100%" alignItems="flex-start"> | ||
<Text fontFamily="mabry medium"> | ||
{t('campaignApplication.general.subtitle', { | ||
place: | ||
// @ts-expect-error | ||
application?.disponibility?.espace?.users_permissions_user | ||
.structureName, | ||
})} | ||
</Text> | ||
<Text> | ||
{application?.already_supported ? t('global.yes') : t('global.no')} | ||
</Text> | ||
</VStack> | ||
|
||
<Divider opacity={0.3} /> | ||
|
||
<VStack width="100%" alignItems="flex-start"> | ||
<Text fontFamily="mabry medium"> | ||
{t('campaignApplication.general.bio')} | ||
</Text> | ||
<Text>{application?.cv}</Text> | ||
</VStack> | ||
</VStack> | ||
</VStack> | ||
) | ||
} | ||
|
||
export default ApplicationPdfGeneral |
Oops, something went wrong.