From 173f21462162ea75839825b2af087aa1ca0553a1 Mon Sep 17 00:00:00 2001 From: Kenneth Jannette Date: Tue, 30 Jan 2024 11:40:03 -0600 Subject: [PATCH] more --- src/Components/SignupPage/SignupPage.js | 43 ++++++++++++------------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/src/Components/SignupPage/SignupPage.js b/src/Components/SignupPage/SignupPage.js index f1d7f62..c27f5fe 100644 --- a/src/Components/SignupPage/SignupPage.js +++ b/src/Components/SignupPage/SignupPage.js @@ -146,7 +146,7 @@ const SignupPage = () => { } } - async function saveUserData(authId, dataValues) { + async function saveUserData(authId, dataValues, customerId, subscriptionId) { const appUserId = uuidv4(); const firmId = uuidv4(); const fbAuthUid = authId; @@ -167,10 +167,11 @@ const SignupPage = () => { practiceArea, email, } = dataValues; - - const subscriptionId = dataValues?.subscriptionId; - const customerId = dataValues?.customerId; - + console.log( + "customerId, subscriptionId in saveUserData", + customerId, + subscriptionId + ); const userData = { docsAllowed, docsGenerated, @@ -188,8 +189,8 @@ const SignupPage = () => { barNumber, practiceArea, email, - //subscriptionId, - //customerId, + customerId: customerId, + subscriptionId: subscriptionId, }; try { @@ -325,18 +326,15 @@ const SignupPage = () => { setIsBusy(true); if (paymentDataValues && dataValues) { try { - const paymentResponse = await handleStripeAuthorization( + const data = await handleStripeAuthorization( paymentDataValues, dataValues ); - console.log( - "----------------------------->>>>>>>>>>>>>>>>>paymentResponse", - paymentResponse - ); - const customerId = data.customerId; - const subscriptionId = data.subscriptionId; + console.log("----------------------------->>>>>>>>>>>>>>>>>data", data); + const customerId = data.data.customerId; + const subscriptionId = data.data.subscriptionId; - if (paymentResponse === false) { + if (data === undefined) { setIsBusy(false); setNotice("Sorry, something went wrong. Please try again."); return; @@ -348,14 +346,13 @@ const SignupPage = () => { ); const user = userCredential.user; - dataValues = { ...dataValues, ...paymentResponse }; - if (subscriptionId) { - dataValues.subscriptionId = subscriptionId; - } - if (customerId) { - dataValues.customerId = customerId; - } - await saveUserData(user.uid, dataValues); + dataValues = { ...dataValues, ...data }; + console.log( + "customerId, subscriptionId in handleSignup right before saveUserData", + customerId, + subscriptionId + ); + await saveUserData(user.uid, dataValues, customerId, subscriptionId); navigate("/dashboard"); } } catch (error) {