initial commit

This commit is contained in:
mantikoros 2022-01-17 17:14:42 -06:00
parent 3b2be5800a
commit cbbc6ef33b
5 changed files with 19 additions and 6 deletions

View File

@ -14,7 +14,11 @@ export const createUser = functions
const preexistingUser = await getUser(userId)
if (preexistingUser)
return { status: 'error', message: 'User already created' }
return {
status: 'error',
message: 'User already created',
user: preexistingUser,
}
const fbUser = await admin.auth().getUser(userId)
@ -38,6 +42,8 @@ export const createUser = functions
avatarUrl,
balance: STARTING_BALANCE,
createdTime: Date.now(),
totalPnLCached: 0,
creatorVolumeCached: 0,
}
await firestore.collection('users').doc(userId).create(user)

View File

@ -1,3 +1,5 @@
import * as admin from 'firebase-admin'
import { Contract } from '../../common/contract'
import { User } from '../../common/user'
import { sendTemplateEmail } from './send-email'
@ -22,6 +24,10 @@ export const sendMarketResolutionEmail = async (
const user = await getUser(userId)
if (!user) return
const fbUser = await admin.auth().getUser(userId)
const email = fbUser.email
if (!email) return
const outcome = toDisplayResolution[resolution]
const subject = `Resolved ${outcome}: ${contract.question}`
@ -39,7 +45,7 @@ export const sendMarketResolutionEmail = async (
// https://app.mailgun.com/app/sending/domains/mg.manifold.markets/templates/edit/market-resolved/initial
// Mailgun username: james@mantic.markets
await sendTemplateEmail(user.email, subject, 'market-resolved', templateData)
await sendTemplateEmail(email, subject, 'market-resolved', templateData)
}
const toDisplayResolution = { YES: 'YES', NO: 'NO', CANCEL: 'N/A', MKT: 'MKT' }

View File

@ -72,7 +72,9 @@ function ProfileSummary(props: { user: User }) {
return (
<Col className="avatar items-center sm:flex-row gap-2 sm:gap-0">
<div className="rounded-full w-10 h-10 sm:mr-4">
<Image src={user.avatarUrl} width={40} height={40} />
{user.avatarUrl && (
<Image src={user.avatarUrl} width={40} height={40} />
)}
</div>
<div className="truncate text-left" style={{ maxWidth: 170 }}>
<div className="hidden sm:flex">{user.name}</div>

View File

@ -43,7 +43,6 @@ function UserCard(props: { user: User; showPrivateInfo?: boolean }) {
{showPrivateInfo && (
<>
<p>{user?.email}</p>
<p>{formatMoney(user?.balance)}</p>
<div className="card-actions">
<button

View File

@ -2,8 +2,8 @@ import { getFirestore } from '@firebase/firestore'
import { initializeApp } from 'firebase/app'
// TODO: Reenable this when we have a way to set the Firebase db in dev
// export const isProd = process.env.NODE_ENV === 'production'
export const isProd = true
export const isProd = process.env.NODE_ENV === 'production'
// export const isProd = true
const firebaseConfig = isProd
? {