From 563170a832be2822442662e2a500bea17d236744 Mon Sep 17 00:00:00 2001 From: Dovile Date: Fri, 20 Oct 2023 15:34:17 +0300 Subject: [PATCH] fix event time in registration form preview --- src/components/forms/Registration.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/components/forms/Registration.tsx b/src/components/forms/Registration.tsx index 0b1031b..2ac3312 100644 --- a/src/components/forms/Registration.tsx +++ b/src/components/forms/Registration.tsx @@ -39,6 +39,7 @@ import LoaderComponent from "../other/LoaderComponent"; import Modal from "../other/Modal"; import FishStockingPageTitle from "../other/PageTitle"; import Map from "../other/RegistrationMap"; +import {useSearchParams} from "react-router-dom"; const cookies = new Cookies(); @@ -80,6 +81,8 @@ const RegistrationForm = ({ const user = useAppSelector((state) => state?.user?.userData); const [showModal, setShowModal] = useState(false); const users = useAssignedToUsers(); + const [searchParams] = useSearchParams(); + const { repeat } = Object.fromEntries([...Array.from(searchParams)]); const callBacks = useFishStockingCallbacks(); @@ -121,7 +124,9 @@ const RegistrationForm = ({ fishStocking?.assignedTo || fishStocking?.createdBy || null; const initialValues: any = { - eventTime: null, + eventTime: fishStocking?.eventTime && !repeat + ? new Date(fishStocking.eventTime) + : null, fishOriginCompanyName: fishStocking?.fishOriginCompanyName || "", assignedTo: fishStocking?.assignedTo || user || undefined, fishOriginReservoir: fishStocking?.fishOriginReservoir || undefined,