From 0ae6c04c99b79ec0387ee7c60c8d08a722c386b8 Mon Sep 17 00:00:00 2001 From: Lucieo Date: Thu, 22 Feb 2024 14:18:15 +0000 Subject: [PATCH] Link applications to space schedule (#78) --- .../Place/Selectors/ApplicationSelector.tsx | 40 +++++-------------- .../Places/Admin/CampaignScheduleInfo.tsx | 30 +++++++------- 2 files changed, 25 insertions(+), 45 deletions(-) diff --git a/web/components/Account/Application/Place/Selectors/ApplicationSelector.tsx b/web/components/Account/Application/Place/Selectors/ApplicationSelector.tsx index 0891ae15..2de3da91 100644 --- a/web/components/Account/Application/Place/Selectors/ApplicationSelector.tsx +++ b/web/components/Account/Application/Place/Selectors/ApplicationSelector.tsx @@ -1,7 +1,6 @@ import { HStack, Select } from '@chakra-ui/react' import { useRouter } from 'next/router' import { useEffect, useMemo, useState } from 'react' -import SelectMenu from '~components/Account/Application/Place/Selectors/SelectMenu' import useCampaignContext from '~components/Campaign/useCampaignContext' import { ROUTE_ACCOUNT_APPLICATIONS } from '~constants' import { Espace } from '~typings/api' @@ -11,25 +10,24 @@ const ApplicationSelector = ({ places }: { places: Espace[] }) => { const { currentCampaign } = useCampaignContext() const router = useRouter() - const { queryEspace, queryDisponibility } = router.query + const { + espace: queryEspace, + disponibility: queryDisponibility, + } = router.query const [espace, setEspace] = useState(queryEspace) const [disponibility, setDisponibility] = useState(queryDisponibility) - useEffect(() => { - if (queryEspace) { - setEspace(queryEspace) - } - }, [queryEspace]) - const initState = () => { - const espace = places?.[0]?.id + const espace = queryEspace || places?.[0]?.id const disponibility = places?.[0]?.id setEspace(espace) setDisponibility(disponibility) - router.push({ - pathname: router.pathname, - query: { espace, disponibility }, - }) + if (!queryEspace || !queryDisponibility) { + router.push({ + pathname: router.pathname, + query: { espace, disponibility }, + }) + } } useEffect(() => { @@ -56,22 +54,6 @@ const ApplicationSelector = ({ places }: { places: Espace[] }) => { return ( - ({ - value: place.id, - label: place.name, - }))} - onChange={(data) => { - console.log(data) - - // const disponibility = getDispoOptions(e.target.value)[0]?.id - // router.push({ - // pathname: router.pathname, - // query: { espace: e.target.value, disponibility }, - // }) - }} - value={espace as string} - />