From 8dff75f5ecfe04ad37c8332e9adcaf915e6819fb Mon Sep 17 00:00:00 2001 From: akshat2jain Date: Tue, 26 Dec 2023 16:36:33 +0530 Subject: [PATCH] added no ride available to service page also --- client/src/Steps/Service.jsx | 96 ++++++++++++++++++++++-------------- 1 file changed, 59 insertions(+), 37 deletions(-) diff --git a/client/src/Steps/Service.jsx b/client/src/Steps/Service.jsx index 857e838..224f20b 100644 --- a/client/src/Steps/Service.jsx +++ b/client/src/Steps/Service.jsx @@ -6,9 +6,12 @@ import img from "../assests/service.png"; import { Link } from "react-router-dom"; import { useBooking } from "../contexts/BookingDataContext"; import { message } from "antd"; +import axios from "axios"; +import NoRIdeAvailable from "../pages/NoRIdeAvailable"; const Service = () => { const location = useLocation(); const [selectedService, setSelectedService] = useState(null); + const [value, setValue] = useState(false); const [user, setUser] = useState(null); const { dispatch } = useUser(); const { fetch } = useBooking(); @@ -35,14 +38,25 @@ const Service = () => { duration: 8, }, ]; - - console.log(localStorage.getItem("ShowUi")); + const getBooleanValue = async () => { + try { + const res = await axios.get( + `${process.env.REACT_APP_SECRETROUTE}/getBooleanValue` + ); + localStorage.setItem("ShowUi", res.data.booleanValue); + setValue(res.data.booleanValue); + } catch (error) { + console.log(error); + } + }; const handleServiceSelect = (service) => { setSelectedService(service); fetch({ type: "UPDATE_STEP1", payload: service }); message.success("Service Selected"); }; useEffect(() => { + // get the value of the show ui or not + getBooleanValue(); // Create a flag to track whether the effect has already run let isMounted = true; @@ -81,43 +95,51 @@ const Service = () => { ) : ( <> -

- Select a Service -

-
- {services.map((service, index) => ( -
handleServiceSelect(service)} - > -
- {/* Left-hand side: Image */} - {service.name} - {/* Right-hand side: Service name and price */} -
-

- {service.name} -

-

- Price - {service.price} -

-

- Security - {service.securtiy} -

+ {!value ? ( + <> +

+ Select a Service +

+
+ {services.map((service, index) => ( +
handleServiceSelect(service)} + > +
+ {/* Left-hand side: Image */} + {service.name} + {/* Right-hand side: Service name and price */} +
+

+ {service.name} +

+

+ Price - {service.price} +

+

+ Security - {service.securtiy} +

+
+
-
+ ))}
- ))} -
+ + ) : ( + <> + + + )} )}