Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
jin-co committed Sep 7, 2023
1 parent 8a62e67 commit 0caffa1
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions React/test-housing/src/pages/Profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Link, useNavigate } from 'react-router-dom'
import arrowRight from '../assets/svg/keyboardArrowRightIcon.svg'
import homeIcon from '../assets/svg/homeIcon.svg'
import { ListingItem } from '../components/ListingItem'
import { collection, deleteDoc, doc, getDocs } from 'firebase/firestore'
import { collection, deleteDoc, doc, getDocs, orderBy, query, where } from 'firebase/firestore'
import { db } from '../firebase.config'

export const Profile = () => {
Expand All @@ -20,9 +20,27 @@ export const Profile = () => {
const { name, email } = formData

useEffect(() => {
const fetchUserListings = async() => {

const fetchUserListings = async () => {
const listingRef = collection(db, 'listings')
const q = query(
listingRef,
where('userRef', '==', auth.currentUser.uid),
orderBy('timestamp', 'desc')
)

const querySnap = await getDocs(q)
let listings = []

querySnap.forEach((doc) => {
return listings.push({
id: doc.id,
data: doc.data(),
})
})

setListings(listings)
}
fetchUserListings()
fetchListings()
}, [])

Expand Down

0 comments on commit 0caffa1

Please sign in to comment.