From ed7aad5712f8d681db4388f4c38c6eabe11fcf37 Mon Sep 17 00:00:00 2001 From: Austin Chen Date: Thu, 21 Apr 2022 10:47:13 -0700 Subject: [PATCH] Fix up API call --- functions/README.md | 3 ++- web/lib/firebase/api-call.ts | 8 +++++++- web/pages/charity/[...slugs]/index.tsx | 10 ++++++---- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/functions/README.md b/functions/README.md index a6e1b4d1..1d8c8cb5 100644 --- a/functions/README.md +++ b/functions/README.md @@ -26,7 +26,8 @@ Adapted from https://firebase.google.com/docs/functions/get-started 0. `$ yarn dev` to spin up the emulators The Emulator UI is at http://localhost:4000; the functions are hosted on :5001. Note: You have to kill and restart emulators when you change code; no hot reload =( -1. Connect to emulators by enabling `functions.useEmulator('localhost', 5001)` + Note2: You may even have to find the process ID of the emulator and kill it manually. +1. Connect by uncommenting the `connectFunctionsEmulator` in `web/lib/firebase/api-call.ts` ## Debugging diff --git a/web/lib/firebase/api-call.ts b/web/lib/firebase/api-call.ts index e1c9bb5e..0f689b70 100644 --- a/web/lib/firebase/api-call.ts +++ b/web/lib/firebase/api-call.ts @@ -1,10 +1,16 @@ -import { getFunctions, httpsCallable } from 'firebase/functions' +import { + getFunctions, + httpsCallable, + connectFunctionsEmulator, +} from 'firebase/functions' import { Fold } from '../../../common/fold' import { User } from '../../../common/user' import { randomString } from '../../../common/util/random' import './init' const functions = getFunctions() +// Uncomment to connect to local emulators: +// connectFunctionsEmulator(functions, 'localhost', 5001) export const cloudFunction = (name: string) => httpsCallable(functions, name) diff --git a/web/pages/charity/[...slugs]/index.tsx b/web/pages/charity/[...slugs]/index.tsx index e51890fb..15b32410 100644 --- a/web/pages/charity/[...slugs]/index.tsx +++ b/web/pages/charity/[...slugs]/index.tsx @@ -117,13 +117,15 @@ function DonationBox(props: { user?: User | null }) { e.preventDefault() setIsSubmitting(true) setError(undefined) - // TODO await sending to db await transact({ amount, - toId: 'asdfsasdf', // TODO hardcode in Manifold Markets official account + // TODO hardcode in Manifold Markets official account. + // Or should we just have it go into a void? + toId: 'igi2zGXsfxYPgB0DJTXVJVmwCOr2', // akrolsmir@gmail in Dev env category: 'TO_CHARITY', - data: { - charityId: 'fjdkslasdf', // TODO fill in + description: `${user?.name} donated M$ ${amount} to wellgive`, + txnData: { + charityId: 'wellgive', // TODO fill in }, }) setIsSubmitting(false)