more
This commit is contained in:
@@ -26,10 +26,10 @@ const Login = () => {
|
|||||||
email,
|
email,
|
||||||
password
|
password
|
||||||
);
|
);
|
||||||
|
|
||||||
// Signed in
|
// Signed in
|
||||||
userCredential?.user && navigate("/dashboard");
|
userCredential?.user && navigate("/dashboard");
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
console.log("error", error);
|
||||||
if (
|
if (
|
||||||
["auth/invalid-login-credentials", "auth/invalid-email"].includes(
|
["auth/invalid-login-credentials", "auth/invalid-email"].includes(
|
||||||
error.code
|
error.code
|
||||||
|
|||||||
@@ -241,7 +241,6 @@ const SignupPage = () => {
|
|||||||
|
|
||||||
// ******************** STRIPE PAY API CALL ******************** //
|
// ******************** STRIPE PAY API CALL ******************** //
|
||||||
async function handleStripeAuthorization(
|
async function handleStripeAuthorization(
|
||||||
user,
|
|
||||||
paymentDataValues,
|
paymentDataValues,
|
||||||
customerDataValues
|
customerDataValues
|
||||||
) {
|
) {
|
||||||
@@ -326,16 +325,7 @@ const SignupPage = () => {
|
|||||||
setIsBusy(true);
|
setIsBusy(true);
|
||||||
if (paymentDataValues && dataValues) {
|
if (paymentDataValues && dataValues) {
|
||||||
try {
|
try {
|
||||||
const userCredential = await createUserWithEmailAndPassword(
|
|
||||||
auth,
|
|
||||||
dataValues.email,
|
|
||||||
dataValues.password
|
|
||||||
);
|
|
||||||
|
|
||||||
const user = userCredential.user;
|
|
||||||
|
|
||||||
const paymentResponse = await handleStripeAuthorization(
|
const paymentResponse = await handleStripeAuthorization(
|
||||||
user,
|
|
||||||
paymentDataValues,
|
paymentDataValues,
|
||||||
dataValues
|
dataValues
|
||||||
);
|
);
|
||||||
@@ -343,14 +333,30 @@ const SignupPage = () => {
|
|||||||
"----------------------------->>>>>>>>>>>>>>>>>paymentResponse",
|
"----------------------------->>>>>>>>>>>>>>>>>paymentResponse",
|
||||||
paymentResponse
|
paymentResponse
|
||||||
);
|
);
|
||||||
|
const customerId = data.customerId;
|
||||||
|
const subscriptionId = data.subscriptionId;
|
||||||
|
|
||||||
if (paymentResponse === false) {
|
if (paymentResponse === false) {
|
||||||
setIsBusy(false);
|
setIsBusy(false);
|
||||||
setNotice("Sorry, something went wrong. Please try again.");
|
setNotice("Sorry, something went wrong. Please try again.");
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
|
const userCredential = await createUserWithEmailAndPassword(
|
||||||
|
auth,
|
||||||
|
dataValues.email,
|
||||||
|
dataValues.password
|
||||||
|
);
|
||||||
|
|
||||||
|
const user = userCredential.user;
|
||||||
dataValues = { ...dataValues, ...paymentResponse };
|
dataValues = { ...dataValues, ...paymentResponse };
|
||||||
|
if (subscriptionId) {
|
||||||
|
dataValues.subscriptionId = subscriptionId;
|
||||||
|
}
|
||||||
|
if (customerId) {
|
||||||
|
dataValues.customerId = customerId;
|
||||||
|
}
|
||||||
await saveUserData(user.uid, dataValues);
|
await saveUserData(user.uid, dataValues);
|
||||||
navigate("/");
|
navigate("/dashboard");
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setIsBusy(false);
|
setIsBusy(false);
|
||||||
|
|||||||
Reference in New Issue
Block a user