From adb3b28b099914e11fc8b24c81509cdb157e5392 Mon Sep 17 00:00:00 2001 From: fikretellek Date: Fri, 8 Mar 2024 16:12:02 +0000 Subject: [PATCH] duration of nights added as a column --- src/components/SearchResults/SearchResults.jsx | 16 ++++++++++------ src/components/SearchResults/TableBody.jsx | 7 ++++--- src/components/SearchResults/TableHead.jsx | 7 ++++--- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/components/SearchResults/SearchResults.jsx b/src/components/SearchResults/SearchResults.jsx index 330e68b..523dee6 100644 --- a/src/components/SearchResults/SearchResults.jsx +++ b/src/components/SearchResults/SearchResults.jsx @@ -1,9 +1,10 @@ // SearchResults.jsx -import React from 'react'; -import TableHead from './TableHead'; -import TableBody from './TableBody'; +import React from "react"; +import TableHead from "./TableHead"; +import TableBody from "./TableBody"; +import dayjs from "dayjs"; -const SearchResults = ({results}) => { +const SearchResults = ({ results }) => { return ( @@ -17,13 +18,16 @@ const SearchResults = ({results}) => { title={booking.title} firstName={booking.firstName} surName={booking.surname} + nights={dayjs(booking.checkOutDate) + .diff(dayjs(booking.checkInDate), "days") + .toString() + .padStart(2, "0")} email={booking.email} /> ))}
); -} +}; export default SearchResults; - diff --git a/src/components/SearchResults/TableBody.jsx b/src/components/SearchResults/TableBody.jsx index 515f587..84d71ae 100644 --- a/src/components/SearchResults/TableBody.jsx +++ b/src/components/SearchResults/TableBody.jsx @@ -1,15 +1,16 @@ -import React from 'react'; +import React from "react"; -const TableBody = ({ id, title, firstName, surName, email }) => { +const TableBody = ({ id, title, firstName, surName, email, nights }) => { return ( {id} {title} {firstName} {surName} + {nights} {email} ); -} +}; export default TableBody; diff --git a/src/components/SearchResults/TableHead.jsx b/src/components/SearchResults/TableHead.jsx index f7d7f59..6390fec 100644 --- a/src/components/SearchResults/TableHead.jsx +++ b/src/components/SearchResults/TableHead.jsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React from "react"; const TableHead = () => { return ( @@ -7,9 +7,10 @@ const TableHead = () => { Title First Name Last Name + Nights Email ); -} +}; -export default TableHead; \ No newline at end of file +export default TableHead;