-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #121 from nkc-ug/fix/login_undefined
存在しないフィールドを参照することによって発生するundefinedを潰した。
- Loading branch information
Showing
4 changed files
with
28 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { setDoc, doc } from 'firebase/firestore'; | ||
import { db } from '../../lib/firebase'; | ||
import { USERCOLLECTIONNAME } from '../../lib/firestore'; | ||
import { GetUserData } from './GetUserData'; | ||
|
||
export const AddUserData = async (email: string) => { | ||
const userData = await GetUserData(email); | ||
const collectionRef = doc(db, USERCOLLECTIONNAME, email); | ||
const docData = { | ||
userName: '', | ||
totalEatCount: 0, | ||
battleWinCount: 0, | ||
goatType: '', | ||
goatClothes: 'yagi', | ||
}; | ||
if (docData.userName !== 'NoLogin') { | ||
await setDoc(collectionRef, docData); | ||
} | ||
userData ? await setDoc(collectionRef, userData, { merge: true }) : null; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters