Skip to content

Commit

Permalink
Fix messages and listings (#94)
Browse files Browse the repository at this point in the history
* Fix messages and listings

* Clean import
  • Loading branch information
Lucieo authored Feb 27, 2024
1 parent c861fd6 commit 0a440e4
Show file tree
Hide file tree
Showing 20 changed files with 537 additions and 289 deletions.
28 changes: 20 additions & 8 deletions web/components/Campaign/CampaignTag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,25 @@ import ApplicationCheck from 'public/assets/img/applicationCheck.svg'

const CampaignTag = ({
isGrid,
isCampaignTab,
mode,
disponibilitiesIds,
hasCampaignDispo,
}: {
isGrid?: boolean
isCampaignTab?: boolean
mode?: 'solidarity' | 'campaign'
disponibilitiesIds?: string[]
hasCampaignDispo?: boolean
}) => {
const { applications } = useCurrentUser()
const { currentCampaign } = useCampaignContext()
const { currentCampaign, hasActiveCampaign } = useCampaignContext()
const { t } = useTranslation('common')

if (
applications
?.map((el) => el?.disponibility)
.some((el) => disponibilitiesIds?.includes(el))
.some((el) => disponibilitiesIds?.includes(el)) &&
hasActiveCampaign &&
mode === 'campaign'
) {
return (
<Box position={isGrid ? 'relative' : undefined}>
Expand All @@ -44,7 +46,7 @@ const CampaignTag = ({
)
}

if (hasCampaignDispo && !isCampaignTab) {
if (hasCampaignDispo && mode === 'solidarity') {
return (
<Box position={isGrid ? 'relative' : undefined}>
<Tag
Expand All @@ -54,10 +56,20 @@ const CampaignTag = ({
}
paddingX={'9px'}
paddingY={'5px'}
maxW="90%"
>
{t('campaign.partner', {
title: currentCampaign?.title,
})}
<Box
style={{
textOverflow: 'ellipsis',
overflow: 'hidden',
whiteSpace: 'nowrap',
maxWidth: '100%', // Adjust this value as needed
}}
>
{t('campaign.partner', {
title: currentCampaign?.title,
})}
</Box>
</Tag>
</Box>
)
Expand Down
78 changes: 78 additions & 0 deletions web/components/Campaign/Home/ApplicationsCampaignInsert.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
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 { useTranslation } from 'next-i18next'
import { ROUTE_PLACES } from '~constants'
import Tag from '~components/Tag'
import Link from '~components/Link'
import useCampaignContext from '~components/Campaign/useCampaignContext'
import { format } from '~utils/date'
import ApplicationCounter from '~components/Campaign/ApplicationCounter'

const ApplicationsCampaignInsert = () => {
const { currentCampaign } = useCampaignContext()
const { title, limitDate } = currentCampaign || {}
const { t } = useTranslation('home')

return (
<VStack
bgColor="white"
borderRadius={{ base: 'none', lg: 'lg' }}
p={4}
alignItems="flex-start"
height={'100%'}
>
<Box>
<Tag status="campaign">{title}</Tag>
</Box>

<Box width="100%">
<Stack
mx="auto"
width="100%"
flexDirection={{ base: 'column', md: 'row' }}
alignItems="flex-start"
>
<HStack w="100%" p={2} alignItems="flex-start">
<Hands
stroke={theme.colors.campaign['dark']}
width="22px"
height="22px"
/>
<Box flex={1}>
<Text fontWeight="bold">
{t(`campaign.insert.applications.title`)}
</Text>
<Text opacity={0.5}>
{t(`campaign.insert.applications.subtitle`, {
date: format(new Date(limitDate), 'd MMMM'),
})}
</Text>
</Box>
</HStack>

<Box>
<Button
size="lg"
alignSelf="center"
variant="campaign"
as={Link}
href={`${ROUTE_PLACES}?tab=1`}
>
{t(`campaign.insert.applications.cta`)}
</Button>
</Box>
</Stack>
<Box paddingLeft={{ base: 0, md: 10 }} paddingTop={{ base: 4, md: 0 }}>
<ApplicationCounter
isFullButton
borderTop="1px solid"
borderColor={'gray.100'}
/>
</Box>
</Box>
</VStack>
)
}

export default ApplicationsCampaignInsert
70 changes: 70 additions & 0 deletions web/components/Campaign/Home/DisponibilitiesCampaignInsert.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
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 { useTranslation } from 'next-i18next'
import { ROUTE_ACCOUNT_PLACES } from '~constants'
import Tag from '~components/Tag'
import Link from '~components/Link'
import useCampaignContext from '~components/Campaign/useCampaignContext'
import { format } from '~utils/date'

const DisponibilitiesCampaingInsert = () => {
const { currentCampaign } = useCampaignContext()
const { title, limitDate } = currentCampaign || {}
const { t } = useTranslation('home')

return (
<VStack
bgColor="white"
borderRadius={{ base: 'none', lg: 'lg' }}
p={4}
alignItems="flex-start"
height={'100%'}
>
<Box>
<Tag status="campaign">{title}</Tag>
</Box>

<Box width="100%">
<Stack
mx="auto"
width="100%"
flexDirection={{ base: 'column', md: 'row' }}
alignItems="flex-start"
>
<HStack w="100%" p={2} alignItems="flex-start">
<Hands
stroke={theme.colors.campaign['dark']}
width="22px"
height="22px"
/>
<Box flex={1}>
<Text fontWeight="bold">
{t(`campaign.insert.disponibilities.title`)}
</Text>
<Text opacity={0.5}>
{t(`campaign.insert.disponibilities.subtitle`, {
date: format(new Date(limitDate), 'd MMMM'),
})}
</Text>
</Box>
</HStack>

<Box>
<Button
size="lg"
alignSelf="center"
variant="campaign"
as={Link}
href={ROUTE_ACCOUNT_PLACES}
>
{t(`campaign.insert.disponibilities.cta`)}
</Button>
</Box>
</Stack>
</Box>
</VStack>
)
}

export default DisponibilitiesCampaingInsert
73 changes: 0 additions & 73 deletions web/components/Campaign/Home/HomeCampaignInsert.tsx

This file was deleted.

50 changes: 50 additions & 0 deletions web/components/Campaign/HomeHelperCampaign.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { Text, Flex, Button, StackProps, VStack, Stack } from '@chakra-ui/react'
import { useTranslation } from 'next-i18next'
import useCampaignContext from '~components/Campaign/useCampaignContext'
import Link from '~components/Link'
import { ROUTE_PLACES } from '~constants'

const HomeHelperCampaign = (props: StackProps) => {
const { t } = useTranslation('common')
const { currentCampaign } = useCampaignContext()

return (
<VStack
backgroundColor={'campaign.light'}
borderRadius="4px"
borderTopLeftRadius={undefined}
paddingX={8}
paddingY={4}
marginBottom={4}
spacing={'1rem'}
height={'auto'}
{...props}
>
<Stack width="100%" spacing={6} direction={{ base: 'column', sm: 'row' }}>
<VStack flex={4} justifyContent="flex-start" alignItems="flex-start">
<Text as="span" fontWeight="bold" marginRight={1}>
{t('campaign.helper_title', { title: currentCampaign?.title })}
</Text>
<Text noOfLines={{ base: 4, md: 3, lg: 2 }}>
{currentCampaign.description}
</Text>
</VStack>
<Flex
flex={1}
justifyContent={{ base: 'flex-start', sm: 'flex-end' }}
alignItems="center"
>
<Button
variant={'campaign'}
as={Link}
href={currentCampaign?.article_link || `${ROUTE_PLACES}?tab=1`}
>
{t('show')}
</Button>
</Flex>
</Stack>
</VStack>
)
}

export default HomeHelperCampaign
51 changes: 51 additions & 0 deletions web/components/Campaign/HomeHelperSolidarity.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { Text, Flex, Button, StackProps, VStack, Stack } from '@chakra-ui/react'
import { useTranslation } from 'next-i18next'
import Link from '~components/Link'
import { ROUTE_PROJECT } from '~constants'

const HomeHelperSolidarity = ({
limitLines,
isHome,
...props
}: {
limitLines?: boolean
isHome?: boolean
} & StackProps) => {
const { t } = useTranslation('common')

return (
<VStack
backgroundColor={'blue.200'}
borderRadius="4px"
borderTopLeftRadius={undefined}
paddingX={8}
paddingY={4}
marginBottom={4}
spacing={'1rem'}
height={'auto'}
{...props}
>
<Stack width="100%" spacing={6} direction={{ base: 'column', sm: 'row' }}>
<VStack flex={4} justifyContent="flex-start" alignItems="flex-start">
<Text as="span" fontWeight="bold" marginRight={1}>
{t('solidarity.helper_title')}
</Text>
<Text noOfLines={limitLines ? { base: 4, md: 3, lg: 2 } : undefined}>
{t('solidarity.helper')}
</Text>
</VStack>
<Flex
flex={1}
justifyContent={{ base: 'flex-start', sm: 'flex-end' }}
alignItems="center"
>
<Button variant={'blueFill'} as={Link} href={ROUTE_PROJECT}>
{t('show')}
</Button>
</Flex>
</Stack>
</VStack>
)
}

export default HomeHelperSolidarity
Loading

0 comments on commit 0a440e4

Please sign in to comment.