more
This commit is contained in:
@@ -34,13 +34,12 @@ const HomePage = () => {
|
|||||||
subscriptionPeriodEnd,
|
subscriptionPeriodEnd,
|
||||||
subscriptionId,
|
subscriptionId,
|
||||||
isPromotionalMebership,
|
isPromotionalMebership,
|
||||||
docsAllowedPeMonth
|
docsAllowedPeMonth = 1
|
||||||
) {
|
) {
|
||||||
if (!email || !password) {
|
if (!email || !password) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("email, password", email, password);
|
|
||||||
const appUserId = uuidv4();
|
const appUserId = uuidv4();
|
||||||
const firmId = uuidv4();
|
const firmId = uuidv4();
|
||||||
const fbAuthUid = authId;
|
const fbAuthUid = authId;
|
||||||
@@ -91,7 +90,7 @@ const HomePage = () => {
|
|||||||
isPromotionalMebership,
|
isPromotionalMebership,
|
||||||
customerId: customerId,
|
customerId: customerId,
|
||||||
subscriptionId: subscriptionId,
|
subscriptionId: subscriptionId,
|
||||||
//subscriptionPlan: plan,
|
subscriptionPlan: "flordia-spring-promo-plan",
|
||||||
subscriptionCreated: subscriptionCreated,
|
subscriptionCreated: subscriptionCreated,
|
||||||
subscriptionPeriodStart: subscriptionPeriodStart,
|
subscriptionPeriodStart: subscriptionPeriodStart,
|
||||||
subscriptionPeriodEnd: subscriptionPeriodEnd,
|
subscriptionPeriodEnd: subscriptionPeriodEnd,
|
||||||
@@ -107,11 +106,13 @@ const HomePage = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function getFocusData(code) {
|
async function getFocusData(code) {
|
||||||
|
console.log("code in getFocusData", code);
|
||||||
try {
|
try {
|
||||||
const response = await fetch(`${apiUrl}/v1/get-focused-data/${code}`, {
|
const response = await fetch(`${apiUrl}/v1/get-focused-data/${code}`, {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
});
|
});
|
||||||
const res = await response.json();
|
const res = await response.json();
|
||||||
|
console.log("res in getFocusData", res);
|
||||||
return res;
|
return res;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log("Error in get rqst:", err);
|
console.log("Error in get rqst:", err);
|
||||||
@@ -126,60 +127,59 @@ const HomePage = () => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const userData = await getFocusData(code);
|
const userData = await getFocusData(code);
|
||||||
if (!userData) {
|
console.log("userData in returned from getFocusData", userData);
|
||||||
return;
|
const email = userData[0].email;
|
||||||
} else {
|
const password = userData[0].password;
|
||||||
handlePromoSignup(userData);
|
if (email && password) {
|
||||||
|
console.log("123 email, password", email, password);
|
||||||
|
handlePromoSignup(userData, email, password);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const handlePromoSignup = async (dataValues) => {
|
async function handlePromoSignup(dataValues, email, password) {
|
||||||
console.log("dataValues in handlePromoSignup", dataValues);
|
if (!email || !password) {
|
||||||
|
return;
|
||||||
if (dataValues) {
|
|
||||||
try {
|
|
||||||
const customerId = `${uuidv4()}-florida-spring-promo`;
|
|
||||||
const today = new Date();
|
|
||||||
const email = dataValues.email;
|
|
||||||
const password = dataValues.password;
|
|
||||||
const subscriptionCreated = today;
|
|
||||||
const subscriptionPeriodStart = today;
|
|
||||||
console.log("subscriptionPeriodStart", subscriptionPeriodStart);
|
|
||||||
const subscriptionPeriodEnd = today;
|
|
||||||
const subscriptionId = uuidv4();
|
|
||||||
if (!email || !password) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const userCredential = await createUserWithEmailAndPassword(
|
|
||||||
auth,
|
|
||||||
email,
|
|
||||||
password
|
|
||||||
);
|
|
||||||
|
|
||||||
const user = userCredential.user;
|
|
||||||
dataValues = { ...dataValues };
|
|
||||||
|
|
||||||
const isPromotionalMebership = true;
|
|
||||||
console.log("userCredential", userCredential);
|
|
||||||
const res = await saveUserData(
|
|
||||||
user.uid,
|
|
||||||
dataValues,
|
|
||||||
customerId,
|
|
||||||
subscriptionCreated,
|
|
||||||
subscriptionPeriodStart,
|
|
||||||
subscriptionPeriodEnd,
|
|
||||||
subscriptionId,
|
|
||||||
isPromotionalMebership
|
|
||||||
);
|
|
||||||
setIsBusy(false);
|
|
||||||
navigate("/dashboard");
|
|
||||||
} catch (error) {
|
|
||||||
console.log("Error handling request", error, error.message);
|
|
||||||
setIsBusy(false);
|
|
||||||
setNotice("Sorry, something went wrong. Please try again.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
try {
|
||||||
|
const customerId = `${uuidv4()}-florida-spring-promo`;
|
||||||
|
const today = new Date();
|
||||||
|
const subscriptionCreated = today;
|
||||||
|
const subscriptionPeriodStart = today;
|
||||||
|
console.log("subscriptionPeriodStart", subscriptionPeriodStart);
|
||||||
|
const subscriptionPeriodEnd = today;
|
||||||
|
const subscriptionId = uuidv4();
|
||||||
|
|
||||||
|
const userCredential = await createUserWithEmailAndPassword(
|
||||||
|
auth,
|
||||||
|
email,
|
||||||
|
password
|
||||||
|
);
|
||||||
|
|
||||||
|
const user = userCredential.user;
|
||||||
|
dataValues = { ...dataValues };
|
||||||
|
|
||||||
|
const isPromotionalMebership = true;
|
||||||
|
console.log("userCredential", userCredential);
|
||||||
|
const res = await saveUserData(
|
||||||
|
user.uid,
|
||||||
|
dataValues,
|
||||||
|
customerId,
|
||||||
|
subscriptionCreated,
|
||||||
|
subscriptionPeriodStart,
|
||||||
|
subscriptionPeriodEnd,
|
||||||
|
subscriptionId,
|
||||||
|
isPromotionalMebership
|
||||||
|
);
|
||||||
|
console.log("res from saveUserData in handlePromoSignup", res);
|
||||||
|
setIsBusy(false);
|
||||||
|
navigate("/dashboard");
|
||||||
|
} catch (error) {
|
||||||
|
console.log("Error handling request", error, error.message);
|
||||||
|
setIsBusy(false);
|
||||||
|
setNotice("Sorry, something went wrong. Please try again.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const handleTryItButton = () => {
|
const handleTryItButton = () => {
|
||||||
setShowPromoModal(true);
|
setShowPromoModal(true);
|
||||||
@@ -468,7 +468,11 @@ const HomePage = () => {
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
return isBusy ? <LoadingSpinner /> : homeContent;
|
return isBusy ? (
|
||||||
|
<LoadingSpinner message={""} loaderType="MoonLoader" />
|
||||||
|
) : (
|
||||||
|
homeContent
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default HomePage;
|
export default HomePage;
|
||||||
|
|||||||
Reference in New Issue
Block a user