Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
jin-co committed Aug 28, 2023
1 parent aff8f72 commit 59e343b
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions React/test-housing/src/pages/CreateListing.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { addDoc, collection } from 'firebase/firestore'
import { addDoc, collection, serverTimestamp } from 'firebase/firestore'
import React, { useState } from 'react'
import { v4 as uuid } from 'uuid'
import { db } from '../firebase.config'
Expand Down Expand Up @@ -92,6 +92,14 @@ export const CreateListing = () => {
})
}

let geolocation = {}
if (geolocationEnabled) {

} else {
geolocation.lat = latitude
geolocation.log = longitude
}

const imageUrls = await Promise.all(
[...images].map(image => storeImage(image))
).catch(() => {
Expand All @@ -100,10 +108,12 @@ export const CreateListing = () => {

const formDataCopy = {
...formData,
imageUrls
imageUrls,
geolocation,
timestamp: serverTimestamp()
}

await addDoc(collection(db, 'listings'), formData)
await addDoc(collection(db, 'listings'), formDataCopy)
}

return (
Expand Down

0 comments on commit 59e343b

Please sign in to comment.