diff --git a/src/Components/Case/CaseListPage.js b/src/Components/Case/CaseListPage.js
index 274fe21..dcd7271 100644
--- a/src/Components/Case/CaseListPage.js
+++ b/src/Components/Case/CaseListPage.js
@@ -83,6 +83,7 @@ const CaseListPage = ({ perPage }) => {
);
};
+
const dropDownOptions = [
{ label: "Case name a - z", value: "caption" },
{ label: "Case name z - a", value: "caption2" },
@@ -159,11 +160,17 @@ const CaseListPage = ({ perPage }) => {
>
) : (
-
You have not created any cases yet.
+
Please create your first case.
- 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.
+
+ Then, you will upload a document (i.e. interrogatories or a
+ complaint), for use in generating a request/response.
+
+
Click "Create New Case" to get started.
{createNewButton()}
)
diff --git a/src/Components/Home/HomePage.js b/src/Components/Home/HomePage.js
index b9fa37d..9e1bdc6 100644
--- a/src/Components/Home/HomePage.js
+++ b/src/Components/Home/HomePage.js
@@ -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 = () => {
@@ -90,7 +243,7 @@ const HomePage = () => {
@@ -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"
/>
) : (
diff --git a/src/Components/Modals/ConfirmModal.js b/src/Components/Modals/ConfirmModal.js
index 83be986..5611757 100644
--- a/src/Components/Modals/ConfirmModal.js
+++ b/src/Components/Modals/ConfirmModal.js
@@ -22,6 +22,7 @@ const ConfirmModal = ({
isPromoModal,
cancelButtonText,
}) => {
+ const [inputValue, setInputValue] = useState("");
const title = titleText ? titleText : "Confirmation";
return (
@@ -53,11 +54,11 @@ const ConfirmModal = ({
setIssueText(e.target.value)}
+ onChange={(e) => setInputValue(e.target.value)}
label={
- issueText
+ inputValue
? ""
: isPromoModal
? "Enter your promotional code"
@@ -79,7 +80,7 @@ const ConfirmModal = ({
onConfirm(inputValue)}
labelText={buttonLabelText}
/>
diff --git a/src/Components/SignupPage/SignupPage.js b/src/Components/SignupPage/SignupPage.js
index c2e51f5..7d37d64 100644
--- a/src/Components/SignupPage/SignupPage.js
+++ b/src/Components/SignupPage/SignupPage.js
@@ -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 = () => {
Create A Novodraft Account
{!isUpgrade ? (
- Start a free trial - save hours and draft smarter discovery
+ Create an account to start a free trial - save time and draft
+ smarter
) : (
<>>