Skip to content

Commit

Permalink
on update listing update all associated listings
Browse files Browse the repository at this point in the history
  • Loading branch information
bpmutter committed Aug 13, 2020
1 parent b0b3d75 commit bdd380a
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 11 deletions.
1 change: 0 additions & 1 deletion src/components/DateSelector.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export default function DatePickers({labelText, formSetter, required, defaultVal
const dateStr = dateJStoHTML(date);
formSetter(dateStr);
}
console.log("default value is..." , defaultValue)
return (
<div className={classes.container}>
<KeyboardDatePicker
Expand Down
1 change: 0 additions & 1 deletion src/components/ListingCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ export default function ListingCard({listing}){
const triggerModal = () => {
//TODO add modal for contacting host
}
console.log('background img::', listing.primary_img)
return (
<Paper className={classes.root} elevation={2}>
{listing.primary_img && <div
Expand Down
1 change: 0 additions & 1 deletion src/components/ListingPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ export default function ListingPage(){
const getListing = useCallback(async () => {
const listing = await getListingById(id);
setListing(listing);
console.log('LISTING IS::',listing)
let currentTime = new Date();
currentTime = currentTime.getTime();
const availableFrom = listing.start_date.toMillis();
Expand Down
5 changes: 5 additions & 0 deletions src/components/Profile.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ export default function UserPage() {
contact: {}
});

//make sure goes to top of window on page load
useEffect(() => {
window.scrollTo(0, 0);
}, []);

useEffect(() => {
// TODO: refactor to put in another component...just throwing code elsewhere
// was causing problems...i think it might have to do w fact that this uses
Expand Down
9 changes: 5 additions & 4 deletions src/components/ProfileSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export default function EditProfile(){
});
const [firstName, setFirstName] = useState("");
const [lastName, setLastName] = useState("");
const [username, setUsername] = useState("")
const [email, setEmail] = useState("");
const [phone, setPhone] = useState("");
const [website, setWebsite] = useState("");
Expand Down Expand Up @@ -93,12 +94,13 @@ export default function EditProfile(){
setUser(thisUser);
setLanguages(thisUser.languages);
setFirstName(thisUser.first_name);
setUsername(thisUser.username)
setLastName(thisUser.last_name);
setEmail(thisUser.contact.email);
setPhone(thisUser.contact.phone);
setWebsite(thisUser.contact.website);
setWhatsapp(thisUser.contact.whatsapp);
setProfilePicture(user.profile_picture);
setProfilePicture(thisUser.profile_picture);
setBio(thisUser.bio);
setLocation(thisUser.location || {});
return deactivate();
Expand Down Expand Up @@ -145,13 +147,13 @@ export default function EditProfile(){
const updateProfile = async () => {
const uid = user.uid;
const res = await updateUserAccountInfo({
firstName, lastName, email, phone, website, whatsapp, bio, location, languages, uid, profilePicture
firstName, lastName, email, phone, website, whatsapp, bio, location, languages, uid, profilePicture, username
});
setSnackbar({ msg: res.message.content, severity: res.message.type });
if(res.message.type){
setTimeout(()=>{
history.push('/profile')
}, 100)
}, 1000)
}
}

Expand Down Expand Up @@ -301,7 +303,6 @@ export default function EditProfile(){
<SelectMultiple
name="languages"
label="Languages"
// value={languages}
defaultValue={languages}
options={languageList}
formSetter={setLanguages}
Expand Down
1 change: 0 additions & 1 deletion src/queries/listings/postListing.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export default async function postListing(listing, setRes){
const unsubscribe = firebase.auth().onAuthStateChanged(async function (user) {
if (user) {
const uid = await firebase.auth().currentUser.uid;
console.log('uid::', uid)
let user = await db.collection("users").doc(uid).get();
user = user.data();
const owner = {
Expand Down
5 changes: 2 additions & 3 deletions src/queries/users/updateUserAccountInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {forEach} from 'p-iteration';
import getListingsByHostUsername from '../listings/getListingsByHostUsername';
import geoListings from "../../config/geofirestore";

export default async function createUserInDb({uid, firstName, lastName, email, phone, website, whatsapp, bio, languages, location, profilePicture}) {
export default async function createUserInDb({uid, firstName, lastName, email, phone, website, whatsapp, bio, languages, location, profilePicture, username}) {
if(!firstName || !lastName || !email){
return {
"message":{
Expand All @@ -14,9 +14,8 @@ export default async function createUserInDb({uid, firstName, lastName, email, p
}
}

const {currentUser} = firebase.auth();
const {currentUser} = await firebase.auth();
const uidAuth = currentUser.uid;
const {username} = currentUser;
if(uidAuth !== uid){
return {
"message":{
Expand Down

0 comments on commit bdd380a

Please sign in to comment.