diff --git a/src/Components/Home/HomePageB.js b/src/Components/Home/HomePageB.js new file mode 100644 index 0000000..05ebfce --- /dev/null +++ b/src/Components/Home/HomePageB.js @@ -0,0 +1,538 @@ +import { useEffect, useState } from "react"; +import { collection, setDoc, doc } from "firebase/firestore"; +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 { createUserWithEmailAndPassword } from "firebase/auth"; +import { stateDataValues } from "../../Constants/Fields/SignupFields"; +import "../../styles/homepage.scss"; +import LoadingSpinner from "../../pageElements/LoadingSpinner"; + +const HomePage = () => { + const navigate = useNavigate(); + const [showPromoModal, setShowPromoModal] = useState(false); + const [isBusy, setIsBusy] = useState(false); + const [notice, setNotice] = useState(""); + + const apiUrl = + process.env.NODE_ENV === "development" + ? process.env.REACT_APP_API_DEV + : process.env.REACT_APP_API_PROD; + + useEffect(() => { + if (typeof window.gtag !== "undefined") { + window.gtag("event", "screen_view", { + app_name: "novodraft", + screen_name: "Home", + }); + } + }, []); + + function clickedTryItButton() { + if (typeof window.gtag !== "undefined") { + window.gtag("event", "try_it_click", { + app_name: "novodraft", + screen_name: "Home", + }); + } + } + + function promoSignup() { + if (typeof window.gtag !== "undefined") { + window.gtag("event", "promo_sign_up", { + send_to: "G-J6SQL5DF6V", + }); + } + } + + function clickedExploreLink() { + if (typeof window.gtag !== "undefined") { + window.gtag("event", "explore_click", { + app_name: "novodraft", + screen_name: "Home", + }); + } + } + + async function saveUserData( + authId, + dataValues, + email, + password, + customerId, + subscriptionCreated, + subscriptionPeriodStart, + subscriptionPeriodEnd, + subscriptionId, + isPromotionalMebership = true, + docsAllowedPeMonth = 1 + ) { + if (!email || !password || !dataValues[0]) { + return; + } + const appUserId = uuidv4(); + const firmId = uuidv4(); + const fbAuthUid = authId; + const tpe = password; + let plan = "promo plan"; + let docsAllowedPerMonth; + + docsAllowedPerMonth = 1; + subscriptionId = uuidv4(); + plan = plan; + + const docsGenerated = 0; + + const { + firstName, + lastName, + firm, + telephone, + streetAddress, + city, + state, + zipCode, + barNumber, + practiceArea, + } = dataValues[0]; + + const userState = stateDataValues.filter((value) => { + if (value.name === state) return value; + }); + + const tempData = { + docsAllowedPerMonth, + docsGenerated, + appUserId, + fbAuthUid, + firmId, + firstName, + lastName, + firm, + telephone, + streetAddress, + city, + state: userState, + zipCode, + barNumber, + practiceArea, + email, + tpe: tpe, + isPromotionalMebership, + isPromotionalFirstLogin: true, + customerId: customerId, + subscriptionId: subscriptionId, + subscriptionPlan: "flordia-spring-promo-plan", + subscriptionCreated: subscriptionCreated, + subscriptionPeriodStart: subscriptionPeriodStart, + subscriptionPeriodEnd: subscriptionPeriodEnd, + }; + + function scrubUndef(obj) { + Object.keys(obj).forEach(function (key) { + if (obj[key] === undefined) { + obj[key] = "---"; + } + }); + + return obj; + } + + const userData = scrubUndef(tempData); + + try { + const usersRef = collection(db, "users"); + const res = await setDoc(doc(usersRef, fbAuthUid), userData); + promoSignup(); + 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) { + setIsBusy(true); + setShowPromoModal(false); + if (!code) { + return; + } + + const userData = await getFocusData(code); + let email; + let password; + + if (userData === undefined) { + return; + } else { + email = userData[0].email; + password = userData[0].mspall; + } + + if (email && password) { + handlePromoSignup(userData, email, password); + } else { + setIsBusy(false); + setShowPromoModal(false); + } + } + + async function handlePromoSignup(dataValues, email, password) { + if (!email || !password) { + return; + } + + try { + const customerId = `${uuidv4()}-florida-spring-promo`; + const today = new Date(); + const subscriptionCreated = today; + const subscriptionPeriodStart = today; + const subscriptionPeriodEnd = today; + const subscriptionId = uuidv4(); + + const userCredential = await createUserWithEmailAndPassword( + auth, + email, + password + ); + + const user = userCredential.user; + dataValues = { ...dataValues }; + const isPromotionalMebership = true; + + const res = await saveUserData( + user.uid, + dataValues, + email, + password, + 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 = (e) => { + clickedTryItButton(); + setShowPromoModal(true); + }; + + const handleLogin = () => { + navigate("/login"); + }; + + const handleCancelModal = () => { + setShowPromoModal(!showPromoModal); + navigate("/signup"); + }; + + const handleDemo = () => { + const supReq = null; + navigate("/requestpage/supReq"); + }; + + const homeContent = ( +
+
+
+
+
+
+

Novodraft: Legal AI

+

Novodraft

+

AI-Assisted Legal Drafting

+

+ Draft documents faster and smarter +

+
+
+
+
Discovery requests
+
dramatically fast
+
+
Draft responses to
+
demands in minutes
+
+
+
+
+
+
+
+
+

+ Discovery requests dramatically fast – responses ready in + minutes. +

+

+ Reclaim hours every week. Spend more time growing your practice, + or just get home in time for dinner. +

+
+
+
+
+
+
+ {/* Section 2 */} +
+
+
+
+

+ Made by Attorneys, for Attorneys +

+
+ +
+ image of a laptop computer +
+
+
+
+

Made by Attorneys, for Attorneys.

+
+

+ Legal tech developed by people that understand what you need. +

+
+ +

+ Novodraft understands the demands on your time. For example, + that discovery request on your desk. With a few clicks, and + Novodraft's AI assistant on the task, you can draft a + ready-to-serve response in minutes. It's as easy as uploading a + .pdf file. +

+

+ Novodraft cuts through a mire of rote tasks, but does much more + than automate. +

+

+ Intellidraft AI technology powers persuasive arguments and + boosts bland, boilerplate objections. Configurable for level of + authoritative citation and for infering factual context from + pleadings and briefs. Use it to augment your drafting as much or + as little as you prefer. +

+
clickedExploreLink()} + > +
+ Explore Novodraft + +
+
+
+
+
+
+ {/* Section 3 */} +
+
+

+ AI-Powered Legal Drafting Technology{" "} +

+

+ Novo Drafting Technology +

+

+ Created by litigators to give you an edge. +

+
+
+ {/*********** CARD ONE *********** */} +
+
+ ai hand +
+
+
+
+

Discovery Requests

+
+
+
+ +
+

+ Generate interrogatories and requests for + production/admissions leveraging AI. +

+

+ Edit or add special language with tags. Concise yet + comprehensive demands, done in minutes. +

+
+
+
+ {/*********** CARD TWO *********** */} +
+
+ scales image +
+
+
+
+

Discovery Responses

+
+
+
+ +
+

+ Use Novodraft AI to quickly draft responses including + compelling arguments about what you withhold from disclosure. + Finish in minutes with a downloadable .docx file. +

+
+
+
+ {/*********** CARD THREE *********** */} +
+
+ +
+
+
+
+

Proactive Alerts

+
+
+
+
+

+ Your dashboard displays important deadlines, alerts, and can + be configured to auto-draft documents with reminders for tasks + such as service or hearings. +

+
+
+
+
+
+
+
+
+
+
+

+ Questions about our services?

+ We're here to answer! +

+

+ Questions about our products and services? +

+

We're here to answer!

+
+
+ Novodraft will revolutionize your practice. +
+
+ Request a demo - let us show you how. +
+
+ Revolutionize your practice. +
+
Let us show you how.
+
+
+ + +
+
+
+
+ {showPromoModal ? ( + + ) : ( + <> + )} +
+ ); + + return isBusy ? ( + + ) : ( + homeContent + ); +}; + +export default HomePage;