This commit is contained in:
Kenneth Jannette
2024-03-22 21:43:19 -05:00
parent 36be048407
commit 73026972f8
4 changed files with 185 additions and 24 deletions

View File

@@ -83,6 +83,7 @@ const CaseListPage = ({ perPage }) => {
</div>
);
};
const dropDownOptions = [
{ label: "Case name a - z", value: "caption" },
{ label: "Case name z - a", value: "caption2" },
@@ -159,11 +160,17 @@ const CaseListPage = ({ perPage }) => {
</>
) : (
<div className="nodocs-text-container">
<p> You have not created any cases yet.</p>
<p> Please create your first case.</p>
<p>
To get started, click "Create New Case" and enter case
information.
To create a discovery request or response, you will first enter
some basic information about the case they will pertain to -
i.e. the caption and case number.
</p>
<p>
Then, you will upload a document (i.e. interrogatories or a
complaint), for use in generating a request/response.
</p>
<p>Click "Create New Case" to get started.</p>
{createNewButton()}
</div>
)

View File

@@ -1,30 +1,183 @@
import { useEffect, useState } from "react";
import { collection, setDoc, doc } from "firebase/firestore";
import { db } from "../../firebase";
import { db, auth } from "../../firebase";
import Button from "../../pageElements/Button";
import { v4 as uuidv4 } from "uuid";
import arrow from "../../Assets/Images/Arrow.png";
import { useNavigate } from "react-router-dom";
import ConfirmModal from "../Modals/ConfirmModal";
import { marchEmailPrm } from "../../secrets";
import { createUserWithEmailAndPassword } from "firebase/auth";
import { stateDataValues } from "../../Constants/Fields/SignupFields";
import "../../styles/homepage.scss";
const HomePage = () => {
const navigate = useNavigate();
const [showPromoModal, setShowPromoModal] = useState(false);
const issueText = "";
const [isBusy, setIsBusy] = useState(false);
const [notice, setNotice] = useState("");
const handleNavigate = () => {
navigate("/signup");
const apiUrl =
process.env.NODE_ENV === "development"
? process.env.REACT_APP_API_DEV
: process.env.REACT_APP_API_PROD;
async function saveUserData(
authId,
dataValues,
customerId,
subscriptionCreated,
subscriptionPeriodStart,
subscriptionPeriodEnd,
subscriptionId,
isPromotionalMebership
) {
const appUserId = uuidv4();
const firmId = uuidv4();
const fbAuthUid = authId;
//let plan = selectedPlan;
let docsAllowedPerMonth;
if (isPromotionalMebership === true) {
docsAllowedPerMonth = 1;
subscriptionId = uuidv4();
let plan = "promo plan";
} else {
//docsAllowedPerMonth = selectedPlan[0].docsAllowedPerMonth;
}
const docsGenerated = 0;
const {
firstName,
lastName,
firm,
telephone,
streetAddress,
city,
state,
zipCode,
barNumber,
practiceArea,
email,
} = dataValues;
const userState = stateDataValues.filter((value) => {
if (value.name === state) return value;
});
const userData = {
docsAllowedPerMonth,
docsGenerated,
appUserId,
fbAuthUid,
firmId,
firstName,
lastName,
firm,
telephone,
streetAddress,
city,
state: userState,
zipCode,
barNumber,
practiceArea,
email,
isPromotionalMebership,
customerId: customerId,
subscriptionId: subscriptionId,
//subscriptionPlan: plan,
subscriptionCreated: subscriptionCreated,
subscriptionPeriodStart: subscriptionPeriodStart,
subscriptionPeriodEnd: subscriptionPeriodEnd,
};
try {
const usersRef = collection(db, "users");
const res = await setDoc(doc(usersRef, fbAuthUid), userData);
return res;
} catch (error) {
console.log(`Error saving new user to db: ${error}`);
}
}
async function getFocusData(code) {
try {
const response = await fetch(`${apiUrl}/v1/get-focused-data/${code}`, {
method: "GET",
});
const res = await response.json();
return res;
} catch (err) {
console.log("Error in get rqst:", err);
}
}
async function handleProcessPromoSubscription(code) {
console.log("code in handleProcessPromoSubscription", code);
setShowPromoModal(false);
if (!code) {
return;
}
setIsBusy(true);
const userData = await getFocusData(code);
if (!userData) {
return;
} else {
handlePromoSignup(userData);
}
}
const handlePromoSignup = async (dataValues) => {
console.log("dataValues in handlePromoSignup", dataValues);
return;
if (dataValues) {
try {
const customerId = `${uuidv4()}-florida-spring-promo`;
const today = new Date();
const subscriptionCreated = today;
const subscriptionPeriodStart = today;
console.log(subscriptionPeriodStart);
const subscriptionPeriodEnd = today;
const subscriptionId = uuidv4();
const userCredential = await createUserWithEmailAndPassword(
auth,
dataValues.email,
dataValues.password
);
const user = userCredential.user;
dataValues = { ...dataValues };
const isPromotionalMebership = true;
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.");
}
}
};
const handleTryItButton = () => {
setShowPromoModal(true);
};
const handleLogin = () => {
navigate("/login");
};
const handleConfirmPromoCode = () => {
//
};
const handleCancelModal = () => {
setShowPromoModal(!showPromoModal);
navigate("/signup");
@@ -73,7 +226,7 @@ const HomePage = () => {
<Button
className="primary-button homepage-button"
labelText="Try It For Free"
onClick={handleNavigate}
onClick={handleTryItButton}
/>
</div>
</div>
@@ -90,7 +243,7 @@ const HomePage = () => {
<Button
className="primary-button homepage-button"
labelText="Try It For Free"
onClick={handleNavigate}
onClick={handleTryItButton}
/>
</div>
</div>
@@ -300,8 +453,7 @@ const HomePage = () => {
onCancel={handleCancelModal}
buttonLabelText="Enter Code"
isPromoModal={true}
issueText={issueText ? issueText : null}
onConfirm={handleConfirmPromoCode}
onConfirm={handleProcessPromoSubscription}
cancelButtonText="I don't have a code"
/>
) : (

View File

@@ -22,6 +22,7 @@ const ConfirmModal = ({
isPromoModal,
cancelButtonText,
}) => {
const [inputValue, setInputValue] = useState("");
const title = titleText ? titleText : "Confirmation";
return (
@@ -53,11 +54,11 @@ const ConfirmModal = ({
<TextInput
key={"captionTwo"}
name={"captionTwo"}
value={issueText}
value={inputValue}
message={"data.captionTwo.message"}
onChange={(e) => setIssueText(e.target.value)}
onChange={(e) => setInputValue(e.target.value)}
label={
issueText
inputValue
? ""
: isPromoModal
? "Enter your promotional code"
@@ -79,7 +80,7 @@ const ConfirmModal = ({
<Button
disabled={isBusy}
className="primary-button"
onClick={onConfirm}
onClick={() => onConfirm(inputValue)}
labelText={buttonLabelText}
/>
</Modal.Footer>

View File

@@ -75,9 +75,9 @@ const SignupPage = () => {
}
};
const handleConfirmPromoCode = () => {
if (issueText === marchEmailPrm) {
handlePromoSignup();
const handleConfirmPromoCode = (code) => {
if (code === marchEmailPrm) {
handlePromoSignup(code);
}
};
@@ -467,7 +467,7 @@ const SignupPage = () => {
}
};
const handlePromoSignup = async () => {
const handlePromoSignup = async (code) => {
let dataValues = validateUserData();
if (dataValues === null) {
return;
@@ -540,7 +540,8 @@ const SignupPage = () => {
<h1 className="signup-header-text">Create A Novodraft Account</h1>
{!isUpgrade ? (
<h5 className="signup-header-text trial">
Start a free trial - save hours and draft smarter discovery
Create an account to start a free trial - save time and draft
smarter
</h5>
) : (
<></>