From 9dc48d1bdfd6bd30981ae1ee6014f8da1e988f1a Mon Sep 17 00:00:00 2001 From: jin-co Date: Wed, 20 Sep 2023 08:19:01 +0900 Subject: [PATCH] Update --- React/test-housing/src/pages/Listing.js | 117 +++++++++++++++++++++++- 1 file changed, 116 insertions(+), 1 deletion(-) diff --git a/React/test-housing/src/pages/Listing.js b/React/test-housing/src/pages/Listing.js index 6a20cd737..9c67377bc 100644 --- a/React/test-housing/src/pages/Listing.js +++ b/React/test-housing/src/pages/Listing.js @@ -1,7 +1,122 @@ import React from 'react' +import { useState, useEffect } from 'react' +import { Link, useNavigate, useParams } from 'react-router-dom' +import { getDoc, doc } from 'firebase/firestore' +import { getAuth } from 'firebase/auth' +import { db } from '../firebase.config' +import Spinner from '../components/Spinner' +import shareIcon from '../assets/svg/shareIcon.svg' +// import { MapContainer, Marker, Popup, TileLayer } from 'react-leaflet' +// import SwiperCore, { Navigation, Pagination, Scrollbar, A11y } from 'swiper' +// import { Swiper, SwiperSlide } from 'swiper/react' +// import 'swiper/css' +// import 'swiper/css/navigation'; +// import 'swiper/css/pagination'; +// import 'swiper/css/scrollbar'; export const Listing = () => { + const [listing, setListing] = useState(null) + const [loading, setLoading] = useState(true) + const [shareLinkCopied, setShareLinkCopied] = useState(false) + const navigate = useNavigate() + const params = useParams() + const auth = getAuth() + return ( -
Listing
+
+ {/* + {listing.imageUrls.map((urls, index) => ( + +
+
+ ))} +
*/} + +
{ + navigator.clipboard.writeText(window.location.href) + setShareLinkCopied(true) + setTimeout(() => { + setShareLinkCopied(false) + }, 2000) + }} + > + +
+ {shareLinkCopied &&

Link Copied

} +
+

+ {listing.name} - $ + {listing.offer + ? listing.discountedPrice + .toString() + .replace(/\B(?=(\d{3})+(?!\d))/g, ',') + : listing.regularPrice + .toString() + .replace(/\B(?=(\d{3})+(?!\d))/g, ',')} +

+

{listing.location}

+

+ For {listing.type === 'rent' ? 'Rent' : 'Sale'} +

+ {listing.offer && ( +

+ ${listing.regularPrice - listing.discountedPrice} discount +

+ )} + +
    +
  • + {listing.bedrooms > 1 ? `${listing.bedrooms}bedrooms` : '1 bedroom'} +
  • +
  • + {listing.bathrooms > 1 + ? `${listing.bathrooms}bathrooms` + : '1 bathroom'} +
  • +
  • {listing.parking && 'Parking spot'}
  • +
  • {listing.furnished && 'Furnished'}
  • +
+ +

Location

+ + {/*
+ + + + + {listing.location} + + +
*/} + + {auth.currentUser?.uid !== listing.userRef && ( + + Contact landlord + + )} +
+
) }