From e4b40f7d526eecd2cebfc59be7a6d26f4194fe19 Mon Sep 17 00:00:00 2001 From: JulienBenoit7 Date: Wed, 8 Jan 2025 15:14:36 +0100 Subject: [PATCH] calendar positioning adjustment --- frontend/src/components/Layout.tsx | 43 ++++++++++----------- frontend/src/components/Navbar.tsx | 30 +++++++++++++-- frontend/src/components/ProductCard.tsx | 34 +++++++++-------- frontend/src/pages/Home.tsx | 51 ++++++++++++++++--------- 4 files changed, 99 insertions(+), 59 deletions(-) diff --git a/frontend/src/components/Layout.tsx b/frontend/src/components/Layout.tsx index dfd9dd0..45bf089 100644 --- a/frontend/src/components/Layout.tsx +++ b/frontend/src/components/Layout.tsx @@ -3,7 +3,7 @@ import { Outlet } from "react-router-dom"; import Navbar from "./Navbar"; import Footer from "./Footer"; import { useWhoAmIQuery } from "../generated/graphql-types"; -import { Layout as AntLayout } from "antd" +import { Layout as AntLayout } from "antd"; import { Content } from "antd/es/layout/layout"; export const UserContext = createContext({ @@ -22,32 +22,31 @@ function Layout() { return

Loading...

; } if (error) { - console.log("error", error); return

Error

; } if (data) { return ( - - - - - - -
-
-
-
-
+ + + + + + +
+
+
+
+
); } diff --git a/frontend/src/components/Navbar.tsx b/frontend/src/components/Navbar.tsx index c390f23..5b8f856 100644 --- a/frontend/src/components/Navbar.tsx +++ b/frontend/src/components/Navbar.tsx @@ -9,7 +9,7 @@ import { MenuOutlined, SearchOutlined, } from "@ant-design/icons"; -import { Input, Button, message, Drawer } from "antd"; +import { Input, Button, message, Drawer, DatePicker } from "antd"; import { Link } from "react-router-dom"; import { UserContext } from "../components/Layout"; import { useLogoutLazyQuery } from "../generated/graphql-types"; @@ -26,6 +26,9 @@ function Navbar() { const userInfo = useContext(UserContext); const [visible, setVisible] = useState(false); + const [startDate, setStartDate] = useState(null); + const [endDate, setEndDate] = useState(null); + const categories = [ { name: "Randonnée", path: "/category/randonnee" }, { name: "Natation", path: "/category/natation" }, @@ -40,6 +43,12 @@ function Navbar() { } }; + const handleDateChange = () => { + if (startDate && endDate) { + navigate(`/search?start=${startDate}&end=${endDate}`); + } + }; + const showDrawer = () => setVisible(true); const onClose = () => setVisible(false); @@ -159,8 +168,23 @@ function Navbar() { } /> -
- +
+ { + setStartDate((dateString as string) || null); + handleDateChange(); + }} + placeholder="Date de début" + style={{ width: "100%", marginBottom: "0.5rem" }} + /> + { + setEndDate((dateString as string) || null); + handleDateChange(); + }} + placeholder="Date de fin" + style={{ width: "100%" }} + />
{userInfo.isLoggedIn && (

diff --git a/frontend/src/components/ProductCard.tsx b/frontend/src/components/ProductCard.tsx index e9e942f..8609c6b 100644 --- a/frontend/src/components/ProductCard.tsx +++ b/frontend/src/components/ProductCard.tsx @@ -1,12 +1,13 @@ -import { Card, Button } from "antd"; -import Meta from "antd/es/card/Meta"; +import { Card, Button, Typography } from "antd"; import { Product } from "../interface/types"; +const { Text } = Typography; + function ProductCard({ product }: { product: Product }) { return ( } > -

- {product.name}
} - description={ -
-
{product.description}
-
- {product.price} euros / jour -
-
- } - /> +
+
+ {product.name} +
+ +
+ {product.description} +
+ +
+ {product.price} euros / jour +
+ diff --git a/frontend/src/pages/Home.tsx b/frontend/src/pages/Home.tsx index ee22f49..17b1756 100644 --- a/frontend/src/pages/Home.tsx +++ b/frontend/src/pages/Home.tsx @@ -8,44 +8,55 @@ const { Title, Text } = Typography; const HomePage = () => { const { data, loading, error } = useGetAllProductsQuery(); - if (loading) return

Loading...

; - if (error) return

Error: {error.message}

; + if (loading) return

Chargement...

; + if (error) + return ( +

+ Erreur: {error.message} +

+ ); const carouselProducts = Array.isArray(data?.getAllProducts) ? data.getAllProducts.slice(0, 5) : []; return ( -
-

+
+

Produits vedettes

-
- +
+ {carouselProducts.map((product) => ( -
- - +
+ + {product.name}
- + <Title + level={4} + className="text-2xl text-[#50A5B1] font-semibold mb-3" + > {product.name} - + {product.price} € - + {product.description} @@ -53,7 +64,7 @@ const HomePage = () => { type="primary" size="large" block - className="bg-blue-900 text-white transition-colors duration-300 hover:bg-orange-600 mt-4" + className="bg-blue-900 text-white transition-colors duration-300 hover:bg-orange-600 rounded-md" > En savoir plus @@ -67,14 +78,18 @@ const HomePage = () => {
-

+

Tous les produits

-
+
{data?.getAllProducts.map((product) => ( - -
+ +