This commit is contained in:
Kenneth Jannette
2024-02-23 22:21:11 -06:00
parent 33f1d6a68a
commit dde81eee2b
2 changed files with 48 additions and 33 deletions

View File

@@ -65,7 +65,8 @@ const SignupPage = () => {
const [isAnnual, setIsAnnual] = useState(1);
const [valX, setValX] = useState(1);
const [valY, setValY] = useState(4);
const userAgentSimple = window.navigator.userAgent;
console.log("simple userAgent", userAgentSimple);
const handleChangeInput = (e, name) => {
const newData = handleFormDataChange(e, name, data, signupFields);
if (newData !== null) {
@@ -146,10 +147,6 @@ const SignupPage = () => {
const validatePaymentData = () => {
const newPaymentData = getValidatedFormData(paymentData, paymentfields);
console.log(
"````````````````````````````````````````newPaymentData",
newPaymentData
);
const hasErrors = isFormDataHasErrors(newPaymentData);
setPaymentData(newPaymentData);
return hasErrors ? null : objectMap(({ value }) => value, newPaymentData);
@@ -209,7 +206,6 @@ const SignupPage = () => {
const fbAuthUid = authId;
let plan = selectedPlan;
let docsAllowedPerMonth;
if (isPromotionalMebership === true) {
docsAllowedPerMonth = 1;
subscriptionId = uuidv4();
@@ -350,30 +346,50 @@ const SignupPage = () => {
});
const type = selectedPlan[0].value ? selectedPlan[0].value : null;
const tempAnnual = isAnnual === 1 ? true : false;
const tempAnnual =
type === "ofCounsel" ? false : isAnnual === 1 ? true : false;
try {
const response = await fetch(`${apiUrl}/create-subscription`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
planType: type,
additionalAccounts: additionalAccounts,
isAnnual: tempAnnual,
customerData: {
email: customerDataValues.email,
name: `${customerDataValues.firstName} ${customerDataValues.lastName}`,
let response;
let data;
if (type === "ofCounsel") {
response = await fetch(`${apiUrl}/new-payment-intent`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
token,
}),
});
const data = await response.json();
//subscriptionId = response.subscriptionId;
//customerId = response.customerId;
body: JSON.stringify({
planType: type,
additionalAccounts: 0,
isAnnual: false,
customerData: {
email: customerDataValues.email,
name: `${customerDataValues.firstName} ${customerDataValues.lastName}`,
},
token,
}),
});
data = await response.json();
} else {
response = await fetch(`${apiUrl}/create-subscription`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
planType: type,
additionalAccounts: additionalAccounts,
isAnnual: tempAnnual,
customerData: {
email: customerDataValues.email,
name: `${customerDataValues.firstName} ${customerDataValues.lastName}`,
},
token,
}),
});
data = await response.json();
}
return {
data,
};
@@ -382,8 +398,8 @@ const SignupPage = () => {
return error;
}
}
// ******************** END STRIPE PAYMENT API CALL ******************** //
// ******************** END STRIPE PAYMENT API CALL ******************** //
const handleSignup = async (e) => {
const paymentDataValues = validatePaymentData();
if (paymentDataValues === null) {
@@ -401,13 +417,13 @@ const SignupPage = () => {
setShowPaymentModal(false);
window.scrollTo({ top: 0, behavior: "smooth" });
setIsBusy(true);
console.log("--------------------> dataValues", dataValues);
try {
const data = await handleStripeAuthorization(
paymentDataValues,
dataValues
);
console.log("9====> ~ ~ ~ ~ data", data);
const customerId = data?.data?.customerId;
const subscriptionCreated = data?.data?.subscriptionCreated;
const subscriptionPeriodStart = data?.data?.subscriptionPeriodStart;