Skip to content

Commit

Permalink
feat: save user info when #
Browse files Browse the repository at this point in the history
  • Loading branch information
zhenyuWang committed Oct 21, 2023
1 parent d1902a6 commit 988e63a
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/components/Modals/#.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useEffect, useState } from 'react'
import { useRouter } from 'next/router'
import { useCreateUserWithEmailAndPassword } from 'react-firebase-hooks/auth'
import { auth, firestore } from '@/firebase/firebase'
// import { doc, setDoc } from "firebase/firestore";
import { doc, setDoc } from 'firebase/firestore'
import { toast } from 'react-toastify'

type #Props = {}
Expand All @@ -29,18 +29,18 @@ const #: React.FC<#Props> = () => {
const newUser = await createUserWithEmailAndPassword(inputs.email, inputs.password)
if (!newUser) return
console.log(newUser)
// const userData = {
// uid: newUser.user.uid,
// email: newUser.user.email,
// displayName: inputs.displayName,
// createdAt: Date.now(),
// updatedAt: Date.now(),
// likedProblems: [],
// dislikedProblems: [],
// solvedProblems: [],
// starredProblems: [],
// };
// await setDoc(doc(firestore, "users", newUser.user.uid), userData);
const userData = {
uid: newUser.user.uid,
email: newUser.user.email,
displayName: inputs.displayName,
createdAt: Date.now(),
updatedAt: Date.now(),
likedProblems: [],
dislikedProblems: [],
solvedProblems: [],
starredProblems: [],
}
await setDoc(doc(firestore, 'users', newUser.user.uid), userData)
router.push('/')
} catch (error: any) {
toast.error(error.message, { position: 'top-center' })
Expand Down

0 comments on commit 988e63a

Please # to comment.