initial commit
This commit is contained in:
		
							parent
							
								
									3b2be5800a
								
							
						
					
					
						commit
						cbbc6ef33b
					
				|  | @ -14,7 +14,11 @@ export const createUser = functions | ||||||
| 
 | 
 | ||||||
|     const preexistingUser = await getUser(userId) |     const preexistingUser = await getUser(userId) | ||||||
|     if (preexistingUser) |     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) |     const fbUser = await admin.auth().getUser(userId) | ||||||
| 
 | 
 | ||||||
|  | @ -38,6 +42,8 @@ export const createUser = functions | ||||||
|       avatarUrl, |       avatarUrl, | ||||||
|       balance: STARTING_BALANCE, |       balance: STARTING_BALANCE, | ||||||
|       createdTime: Date.now(), |       createdTime: Date.now(), | ||||||
|  |       totalPnLCached: 0, | ||||||
|  |       creatorVolumeCached: 0, | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     await firestore.collection('users').doc(userId).create(user) |     await firestore.collection('users').doc(userId).create(user) | ||||||
|  |  | ||||||
|  | @ -1,3 +1,5 @@ | ||||||
|  | import * as admin from 'firebase-admin' | ||||||
|  | 
 | ||||||
| import { Contract } from '../../common/contract' | import { Contract } from '../../common/contract' | ||||||
| import { User } from '../../common/user' | import { User } from '../../common/user' | ||||||
| import { sendTemplateEmail } from './send-email' | import { sendTemplateEmail } from './send-email' | ||||||
|  | @ -22,6 +24,10 @@ export const sendMarketResolutionEmail = async ( | ||||||
|   const user = await getUser(userId) |   const user = await getUser(userId) | ||||||
|   if (!user) return |   if (!user) return | ||||||
| 
 | 
 | ||||||
|  |   const fbUser = await admin.auth().getUser(userId) | ||||||
|  |   const email = fbUser.email | ||||||
|  |   if (!email) return | ||||||
|  | 
 | ||||||
|   const outcome = toDisplayResolution[resolution] |   const outcome = toDisplayResolution[resolution] | ||||||
| 
 | 
 | ||||||
|   const subject = `Resolved ${outcome}: ${contract.question}` |   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
 |   // https://app.mailgun.com/app/sending/domains/mg.manifold.markets/templates/edit/market-resolved/initial
 | ||||||
|   // Mailgun username: james@mantic.markets
 |   // 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' } | const toDisplayResolution = { YES: 'YES', NO: 'NO', CANCEL: 'N/A', MKT: 'MKT' } | ||||||
|  |  | ||||||
|  | @ -72,7 +72,9 @@ function ProfileSummary(props: { user: User }) { | ||||||
|   return ( |   return ( | ||||||
|     <Col className="avatar items-center sm:flex-row gap-2 sm:gap-0"> |     <Col className="avatar items-center sm:flex-row gap-2 sm:gap-0"> | ||||||
|       <div className="rounded-full w-10 h-10 sm:mr-4"> |       <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> | ||||||
|       <div className="truncate text-left" style={{ maxWidth: 170 }}> |       <div className="truncate text-left" style={{ maxWidth: 170 }}> | ||||||
|         <div className="hidden sm:flex">{user.name}</div> |         <div className="hidden sm:flex">{user.name}</div> | ||||||
|  |  | ||||||
|  | @ -43,7 +43,6 @@ function UserCard(props: { user: User; showPrivateInfo?: boolean }) { | ||||||
| 
 | 
 | ||||||
|         {showPrivateInfo && ( |         {showPrivateInfo && ( | ||||||
|           <> |           <> | ||||||
|             <p>{user?.email}</p> |  | ||||||
|             <p>{formatMoney(user?.balance)}</p> |             <p>{formatMoney(user?.balance)}</p> | ||||||
|             <div className="card-actions"> |             <div className="card-actions"> | ||||||
|               <button |               <button | ||||||
|  |  | ||||||
|  | @ -2,8 +2,8 @@ import { getFirestore } from '@firebase/firestore' | ||||||
| import { initializeApp } from 'firebase/app' | import { initializeApp } from 'firebase/app' | ||||||
| 
 | 
 | ||||||
| // TODO: Reenable this when we have a way to set the Firebase db in dev
 | // 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 = process.env.NODE_ENV === 'production' | ||||||
| export const isProd = true | // export const isProd = true
 | ||||||
| 
 | 
 | ||||||
| const firebaseConfig = isProd | const firebaseConfig = isProd | ||||||
|   ? { |   ? { | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user