Skip to content

Commit

Permalink
fix: issues with campaign
Browse files Browse the repository at this point in the history
  • Loading branch information
baptadn committed May 16, 2024
1 parent 76ba20c commit d9ff111
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 55 deletions.
28 changes: 11 additions & 17 deletions web/components/Campaign/Places/Detail/CampaignDetailTabs.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
import { Button, HStack } from '@chakra-ui/react'
import { useTranslation } from 'next-i18next'
import useCampaignContext from '~components/Campaign/useCampaignContext'
import { useRouter } from 'next/router'
import { useContext, useEffect, useState } from 'react'
import useCampaignContext from '~components/Campaign/useCampaignContext'
import BookingScheduleContext from '~components/Place/Booking/BookingScheduleContext'

const CampaignDetailTabs = ({
hasSolidarityDispo,
}: {
hasSolidarityDispo: boolean
}) => {
const CampaignDetailTabs = () => {
const { currentCampaign } = useCampaignContext()
const { t } = useTranslation('place')
const router = useRouter()
Expand Down Expand Up @@ -38,17 +34,15 @@ const CampaignDetailTabs = ({
borderRadius="18px"
padding={2}
>
{hasSolidarityDispo && (
<Button
height="auto"
variant={isCampaignTab ? 'unSelected' : 'blueFill'}
onClick={() => handleTabClick('0')}
padding="9px 15px 9px 15px"
borderRadius="12px"
>
{t('detail.campaign.solidarity_slot')}
</Button>
)}
<Button
height="auto"
variant={isCampaignTab ? 'unSelected' : 'blueFill'}
onClick={() => handleTabClick('0')}
padding="9px 15px 9px 15px"
borderRadius="12px"
>
{t('detail.campaign.solidarity_slot')}
</Button>
<Button
height="auto"
variant={isCampaignTab ? 'campaign' : 'unSelected'}
Expand Down
38 changes: 20 additions & 18 deletions web/components/Campaign/Places/Detail/CampaignPlaceDetail.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
import React, { useMemo } from 'react'
import {
AspectRatio,
Box,
Container,
useBreakpointValue,
Stack,
AspectRatio,
VStack,
useBreakpointValue,
} from '@chakra-ui/react'
import PlaceAttributesGridMobile from '~components/Place/PlaceAttributesGridMobile'
import PlaceHeader from '~components/Place/PlaceHeader'
import { Espace } from '~typings/api'
import PlaceDetailMainInfo from '~components/Place/PlaceDetailPage/PlaceDetailMainInfo'
import PlaceDetailLocation from '~components/Place/PlaceDetailPage/PlaceDetailLocation'
import PlaceDetailExtraInfo from '~components/Place/PlaceDetailPage/PlaceDetailExtraInfo'
import PlaceCardCarousel from '~components/Place/PlaceCardCarousel'
import CampaignDetailTabs from '~components/Campaign/Places/Detail/CampaignDetailTabs'
import { useRouter } from 'next/router'
import { useMemo } from 'react'
import CampaignApplicationSchedule from '~components/Campaign/Places/Application/CampaignApplicationSchedule'
import PlaceDetailCalendar from '~components/Place/PlaceDetailPage/PlaceDetailCalendar'
import CampaignDetailSwitcher from '~components/Campaign/Places/Detail/CampaignDetailSwitcher'
import useCampaignDispo from '~hooks/useCampaignDispo'
import CampaignDetailTabs from '~components/Campaign/Places/Detail/CampaignDetailTabs'
import CampaignPlaceFiles from '~components/Campaign/Places/Detail/CampaignPlaceFiles'
import PlaceAttributesGridMobile from '~components/Place/PlaceAttributesGridMobile'
import PlaceCardCarousel from '~components/Place/PlaceCardCarousel'
import PlaceDetailCalendar from '~components/Place/PlaceDetailPage/PlaceDetailCalendar'
import PlaceDetailExtraInfo from '~components/Place/PlaceDetailPage/PlaceDetailExtraInfo'
import PlaceDetailLocation from '~components/Place/PlaceDetailPage/PlaceDetailLocation'
import PlaceDetailMainInfo from '~components/Place/PlaceDetailPage/PlaceDetailMainInfo'
import PlaceHeader from '~components/Place/PlaceHeader'
import useCampaignDispo from '~hooks/useCampaignDispo'
import { Espace } from '~typings/api'

interface Props {
place: Espace
Expand Down Expand Up @@ -64,9 +64,7 @@ const CampaignPlaceDetail = ({ place }: Props) => {
</Box>

<VStack spacing={2}>
<CampaignDetailTabs
hasSolidarityDispo={Boolean(solidarityDisposNum)}
/>
<CampaignDetailTabs />
<PlaceDetailMainInfo
place={place}
displayPrecise={displayPrecise}
Expand All @@ -83,8 +81,12 @@ const CampaignPlaceDetail = ({ place }: Props) => {
<PlaceDetailCalendar place={place} />
)}

{Boolean(solidarityDisposNum && campaignDisposNum) && (
<CampaignDetailSwitcher isCampaignTab={isCampaignTab} />
{Boolean(!isCampaignTab && campaignDisposNum) && (
<CampaignDetailSwitcher isCampaignTab={false} />
)}

{Boolean(isCampaignTab && solidarityDisposNum) && (
<CampaignDetailSwitcher isCampaignTab />
)}

{isMobile && (
Expand Down
38 changes: 18 additions & 20 deletions web/components/Place/PlacesPage.tsx
Original file line number Diff line number Diff line change
@@ -1,34 +1,32 @@
import React, { useRef, useState, useMemo, useEffect } from 'react'
import {
Box,
Button,
ButtonGroup,
Container,
Flex,
Select,
Button,
Stack,
Text,
ButtonGroup,
useBreakpointValue,
Stack,
Box,
} from '@chakra-ui/react'
import PlaceSearch from '~components/Place/PlaceSearch'
import { useInfinitePlaces } from '~hooks/useInfinitePlaces'
import { useScrollBottom } from '~hooks/useScrollBottom'
import PlaceGrid from '~components/Place/PlaceGrid'
import PlaceList from '~components/Place/PlaceList'
import { formatSearch } from '~utils/search'
import Arrow from 'public/assets/img/arrow-bottom.svg'
import { useTranslation } from 'next-i18next'
import { NextSeo } from 'next-seo'
import { useRouter } from 'next/router'
import Arrow from 'public/assets/img/arrow-bottom.svg'
import { useEffect, useMemo, useRef, useState } from 'react'
import { FormProvider, useForm } from 'react-hook-form'
import { SortOptions } from '~utils/search'
import { useQueryClient } from 'react-query'
import NoResult from '~components/Place/NoResult'
import PlacesListCampaignHelper from '~components/Campaign/Places/PlacesListCampaignHelper'
import useCampaignContext from '~components/Campaign/useCampaignContext'
import MobileMap from '~components/Place/MobileMap'
import { useRouter } from 'next/router'
import { NextSeo } from 'next-seo'
import { formatSearchToQuery } from '~utils/search'
import NoResult from '~components/Place/NoResult'
import PlaceGrid from '~components/Place/PlaceGrid'
import PlaceList from '~components/Place/PlaceList'
import PlaceSearch from '~components/Place/PlaceSearch'
import { ROUTE_PLACES } from '~constants'
import useCampaignContext from '~components/Campaign/useCampaignContext'
import PlacesListCampaignHelper from '~components/Campaign/Places/PlacesListCampaignHelper'
import { useInfinitePlaces } from '~hooks/useInfinitePlaces'
import { useScrollBottom } from '~hooks/useScrollBottom'
import { SortOptions, formatSearch, formatSearchToQuery } from '~utils/search'

const styleSelected = {
color: 'blue.500',
Expand Down Expand Up @@ -77,7 +75,7 @@ const PlacesPage = () => {
isFetching,
} = useInfinitePlaces(
{
_limit: isGridView ? 12 : 6,
_limit: 48,
...searchParams,
},
isCampaignTab ? 'campaignPlaces' : 'solidarityPlaces',
Expand Down

0 comments on commit d9ff111

Please sign in to comment.