From 072fbe77421b70fb615a974c241a9a607271c883 Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 13 Sep 2023 19:33:14 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=80=20Implemented=20client=20usage.=20?= =?UTF-8?q?=F0=9F=8C=9F=20Added=20date=20conversion=20utility.=20?= =?UTF-8?q?=F0=9F=93=8A=20Integrated=20Redux=20for=20state=20management.?= =?UTF-8?q?=20=F0=9F=92=A1=20Improved=20component=20structure.=20?= =?UTF-8?q?=F0=9F=8E=A8=20Enhanced=20UI=20design=20for=20better=20user=20e?= =?UTF-8?q?xperience.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../(car-search-form)/CarsSearchForm.tsx | 166 ++++++++++++++++++ 1 file changed, 166 insertions(+) create mode 100644 src/app/(client-components)/(HeroSearchForm2Mobile)/(car-search-form)/CarsSearchForm.tsx diff --git a/src/app/(client-components)/(HeroSearchForm2Mobile)/(car-search-form)/CarsSearchForm.tsx b/src/app/(client-components)/(HeroSearchForm2Mobile)/(car-search-form)/CarsSearchForm.tsx new file mode 100644 index 0000000..967b368 --- /dev/null +++ b/src/app/(client-components)/(HeroSearchForm2Mobile)/(car-search-form)/CarsSearchForm.tsx @@ -0,0 +1,166 @@ +"use client"; +import converSelectedDateToString from "@/utils/converSelectedDateToString"; +import React, { useState } from "react"; +import DatesRangeInput from "../DatesRangeInput"; +import LocationInput from "../LocationInput"; + +const CarsSearchForm = () => { + // + const [fieldNameShow, setFieldNameShow] = useState< + "locationPickup" | "locationDropoff" | "dates" + >("locationPickup"); + // + const [locationInputPickUp, setLocationInputPickUp] = useState(""); + const [locationInputDropOff, setLocationInputDropOff] = useState(""); + + const [startDate, setStartDate] = useState( + new Date("2023/02/06") + ); + const [endDate, setEndDate] = useState(new Date("2023/02/23")); + + const [dropOffLocationType, setDropOffLocationType] = useState< + "same" | "different" + >("same"); + + const renderInputLocationPickup = () => { + const isActive = fieldNameShow === "locationPickup"; + return ( +
+ {!isActive ? ( + + ) : ( + { + setLocationInputPickUp(value); + if (dropOffLocationType === "different") { + setFieldNameShow("locationDropoff"); + } else { + setFieldNameShow("dates"); + } + }} + /> + )} +
+ ); + }; + + const renderInputLocationDropoff = () => { + const isActive = fieldNameShow === "locationDropoff"; + return ( +
+ {!isActive ? ( + + ) : ( + { + setLocationInputDropOff(value); + setFieldNameShow("dates"); + }} + /> + )} +
+ ); + }; + + const renderInputDates = () => { + const isActive = fieldNameShow === "dates"; + + return ( +
+ {!isActive ? ( + + ) : ( + + )} +
+ ); + }; + + const renderRadioBtn = () => { + return ( +
+
setDropOffLocationType("same")} + > + Same drop off +
+
setDropOffLocationType("different")} + > + Different drop off +
+
+ ); + }; + + return ( +
+
+ {renderRadioBtn()} + + {renderInputLocationPickup()} + {/* */} + {dropOffLocationType === "different" && renderInputLocationDropoff()} + {/* */} + {renderInputDates()} + {/* */} +
+
+ ); +}; + +export default CarsSearchForm;