-
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.
Place campaign listing history (#79)
* History on campaigns * Require selected campaign * Fix import
- Loading branch information
Showing
26 changed files
with
340 additions
and
210 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
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
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
32 changes: 22 additions & 10 deletions
32
...lectionHelpers/ApplicationPlaceHelper.tsx → ...cationsHelpers/ApplicationPlaceHelper.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
20 changes: 20 additions & 0 deletions
20
web/components/Account/Application/Place/ApplicationsHelpers/ClosedCampaign.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,20 @@ | ||
import { Box, HStack, Text } from '@chakra-ui/react' | ||
import PreselectionsValidated from 'public/assets/img/preselectionsValidated.svg' | ||
import { useTranslation } from 'next-i18next' | ||
|
||
const ClosedCampaign = () => { | ||
const { t } = useTranslation('application') | ||
|
||
return ( | ||
<Box paddingY={2}> | ||
<HStack backgroundColor="gray.50" borderRadius="4px" p={4}> | ||
<PreselectionsValidated /> | ||
<Text as="span" color="gray.700" pl={1}> | ||
{t('place.helper.closed_campaign')} | ||
</Text> | ||
</HStack> | ||
</Box> | ||
) | ||
} | ||
|
||
export default ClosedCampaign |
1 change: 0 additions & 1 deletion
1
...ce/SelectionHelpers/ConfirmSelections.tsx → ...ApplicationsHelpers/ConfirmSelections.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
File renamed without changes.
File renamed without changes.
49 changes: 49 additions & 0 deletions
49
web/components/Account/Application/Place/CampaignSelector/CampaignSelector.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,49 @@ | ||
import { HStack, Text } from '@chakra-ui/react' | ||
import { useTranslation } from 'next-i18next' | ||
import { useRouter } from 'next/router' | ||
import { useEffect } from 'react' | ||
import CampaignSelectorField from '~components/Account/Application/Place/CampaignSelector/CampaignSelectorField' | ||
import useCampaignContext from '~components/Campaign/useCampaignContext' | ||
import { ROUTE_ACCOUNT_APPLICATIONS } from '~constants' | ||
|
||
const CampaignSelector = ({ children }) => { | ||
const router = useRouter() | ||
const { campaign } = router.query | ||
const { allPlaceCampaigns } = useCampaignContext() | ||
const { t } = useTranslation('application') | ||
|
||
// If no campaign defined in url select last one | ||
useEffect(() => { | ||
if (!campaign && allPlaceCampaigns) { | ||
router.push( | ||
`${ROUTE_ACCOUNT_APPLICATIONS}?campaign=${allPlaceCampaigns?.[0]?.id}`, | ||
) | ||
} | ||
}, [allPlaceCampaigns]) | ||
|
||
const selectedCampaign = allPlaceCampaigns?.find( | ||
(c) => c.id?.toString() === campaign?.toString(), | ||
) | ||
|
||
if (!selectedCampaign) return null | ||
|
||
return ( | ||
<> | ||
<HStack pt={{ base: 4, md: 8 }} pb={4}> | ||
<Text | ||
textStyle="accountTitle" | ||
pl={4} | ||
fontSize="24px" | ||
fontWeight="400" | ||
fontFamily="mabry" | ||
> | ||
{t('place.title')} | ||
</Text> | ||
<CampaignSelectorField /> | ||
</HStack> | ||
{selectedCampaign && children} | ||
</> | ||
) | ||
} | ||
|
||
export default CampaignSelector |
51 changes: 51 additions & 0 deletions
51
web/components/Account/Application/Place/CampaignSelector/CampaignSelectorField.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,51 @@ | ||
import { Select, Text } from '@chakra-ui/react' | ||
import { useTranslation } from 'next-i18next' | ||
import { useRouter } from 'next/router' | ||
import useCampaignContext from '~components/Campaign/useCampaignContext' | ||
|
||
const CampaignSelectorField = () => { | ||
const { t } = useTranslation('application') | ||
const router = useRouter() | ||
const { allPlaceCampaigns, isLoadingAllPlaceCampaigns } = useCampaignContext() | ||
if (isLoadingAllPlaceCampaigns || !allPlaceCampaigns) { | ||
return null | ||
} | ||
|
||
if (allPlaceCampaigns.length === 1) { | ||
return ( | ||
<Text | ||
backgroundColor="blue.100" | ||
color="blue.500" | ||
p={2} | ||
borderRadius="18px" | ||
paddingX={4} | ||
> | ||
{t('place.title_single_tag', { title: allPlaceCampaigns[0]?.title })} | ||
</Text> | ||
) | ||
} | ||
return ( | ||
<Select | ||
width="auto" | ||
borderRadius="18px" | ||
backgroundColor="blue.100" | ||
color="blue.500" | ||
borderColor="transparent" | ||
value={router.query.campaign} | ||
onChange={(e) => { | ||
router.push({ | ||
pathname: router.pathname, | ||
query: { campaign: e.target.value }, | ||
}) | ||
}} | ||
> | ||
{allPlaceCampaigns.map((campaign) => ( | ||
<option key={campaign.id} value={campaign.id}> | ||
{campaign.title} | ||
</option> | ||
))} | ||
</Select> | ||
) | ||
} | ||
|
||
export default CampaignSelectorField |
Oops, something went wrong.