From 1829478ef836a40957b570f05f2fdfe3fc9bf8b0 Mon Sep 17 00:00:00 2001 From: antonisdev Date: Thu, 12 Dec 2024 10:44:00 +0100 Subject: [PATCH] Fixed some types in front --- frontend/src/components/ReservationCard.tsx | 22 ++++++++++++------- .../components/ValidateReservationButton.tsx | 10 +++++++-- frontend/src/interface/types.tsx | 19 ++++++++-------- 3 files changed, 31 insertions(+), 20 deletions(-) diff --git a/frontend/src/components/ReservationCard.tsx b/frontend/src/components/ReservationCard.tsx index a1c96ce..d17c5a2 100644 --- a/frontend/src/components/ReservationCard.tsx +++ b/frontend/src/components/ReservationCard.tsx @@ -2,13 +2,17 @@ import { Card, Divider } from "antd"; import ValidateReservationButton from "./ValidateReservationButton"; import { ReservationData } from "../interface/types"; -export const ReservationCard = ( {reservationData} : {reservationData: ReservationData}) => { - const formattedStartDate = new Date(reservationData.reservation.startDate).toLocaleDateString( - "fr-FR" - ); - const formattedEndDate = new Date(reservationData.reservation.endDate).toLocaleDateString( - "fr-FR" - ); +export const ReservationCard = ({ + reservationData, +}: { + reservationData: ReservationData; +}) => { + const formattedStartDate = new Date( + reservationData.reservation.startDate + ).toLocaleDateString("fr-FR"); + const formattedEndDate = new Date( + reservationData.reservation.endDate + ).toLocaleDateString("fr-FR"); const reservationId = reservationData.reservation.id; return ( <> @@ -19,7 +23,9 @@ export const ReservationCard = ( {reservationData} : {reservationData: Reservati

Prix : {reservationData.totalPrice} euros

Status : {reservationData.reservation.status}

{reservationData.reservation.status === "pending" && ( - + )} diff --git a/frontend/src/components/ValidateReservationButton.tsx b/frontend/src/components/ValidateReservationButton.tsx index 694e202..50475e7 100644 --- a/frontend/src/components/ValidateReservationButton.tsx +++ b/frontend/src/components/ValidateReservationButton.tsx @@ -7,7 +7,13 @@ import { GetReservationsByUserIdDocument, } from "../generated/graphql-types"; -function ValidateReservationButton({ reservation }: Reservation) { +type ValidateReservationButtonProps = { + reservation: Reservation; +}; + +const ValidateReservationButton = ({ + reservation, +}: ValidateReservationButtonProps) => { const [updateReservationStatus] = useMutation(UPDATE_RESERVATION_STATUS, { onCompleted: () => { message.success("La réservation a bien été validée."); @@ -40,6 +46,6 @@ function ValidateReservationButton({ reservation }: Reservation) { ); -} +}; export default ValidateReservationButton; diff --git a/frontend/src/interface/types.tsx b/frontend/src/interface/types.tsx index 781436c..16bce0f 100644 --- a/frontend/src/interface/types.tsx +++ b/frontend/src/interface/types.tsx @@ -61,20 +61,19 @@ export interface NewProductFormValues { export type Article = { id: number; product?: ProductCard; - reservations?: Reservation[] | null + reservations?: Reservation[] | null; }; export type Reservation = { - reservation: { - id: number; - startDate: string; - endDate: string; - articles: Article[]; - status: string; - createdAt?: string; - }; + id: number; + startDate: string; + endDate: string; + articles: Article[]; + status: string; + createdAt?: string; }; -export type ReservationData = Reservation & { +export type ReservationData = { + reservation: Reservation; totalPrice?: number; };