diff --git a/src/.DS_Store b/src/.DS_Store index 14f8fed..fc1de4d 100644 Binary files a/src/.DS_Store and b/src/.DS_Store differ diff --git a/src/Components/SignupPage/SignupPage.js b/src/Components/SignupPage/SignupPage.js index b4002ab..8990db0 100644 --- a/src/Components/SignupPage/SignupPage.js +++ b/src/Components/SignupPage/SignupPage.js @@ -1,4 +1,4 @@ -import React, { useState, useEffect } from "react"; +import React, { useState } from "react"; import Col from "react-bootstrap/Col"; import Form from "react-bootstrap/Form"; import Row from "react-bootstrap/Row"; @@ -10,7 +10,6 @@ import TextInput from "../../pageElements/TextInput"; import { v4 as uuidv4 } from "uuid"; import { collection, setDoc, doc } from "firebase/firestore"; import { splitEvery } from "../../Utils/Array"; -import PaymentModal from "../Modals/PaymentModal"; import { getFormDataDefaults, getValidatedFormData, @@ -19,26 +18,17 @@ import { } from "../../Utils/Form"; import { objectMap } from "../../Utils/Object"; import { signupfields } from "../../Constants/Fields/Signupfields"; -import { paymentfields } from "../../Constants/Fields/PaymentFields"; import "../../styles/signup.scss"; const SignupPage = () => { const navigate = useNavigate(); const [notice, setNotice] = useState(""); - const [isMobile, setIsMobile] = useState(window.innerWidth < 440); - useEffect(() => { - setIsMobile(window.innerWidth < 440); - }); + const fieldsChunkSize = 2; + const [isBusy, setIsBusy] = useState(false); const [data, setData] = useState(getFormDataDefaults(signupfields)); - const [paymentdata, setPaymentdata] = useState( - getFormDataDefaults(paymentfields) - ); - - const [showPaymentModal, setShowPaymentModal] = useState(false); - const handleChangeInput = (e, name) => { const newData = handleFormDataChange(e, name, data, signupfields); if (newData !== null) { @@ -46,13 +36,6 @@ const SignupPage = () => { } }; - const handleChangePaymentInput = (e, name) => { - const newData = handleFormDataChange(e, name, data, paymentfields); - if (newData !== null) { - setPaymentdata(newData); - } - }; - const validateData = () => { const newData = getValidatedFormData(data, signupfields); const hasErrors = isFormDataHasErrors(newData); @@ -60,13 +43,6 @@ const SignupPage = () => { return hasErrors ? null : objectMap(({ value }) => value, newData); }; - const validatePaymentData = () => { - const newData = getValidatedFormData(data, signupfields); - const hasErrors = isFormDataHasErrors(newData); - setPaymentdata(newData); - return hasErrors ? null : objectMap(({ value }) => value, newData); - }; - async function saveUserData(authId, dataValues) { const appUserId = uuidv4(); const firmId = uuidv4(); @@ -110,115 +86,31 @@ const SignupPage = () => { } } - async function handleStripePaymentAuthorization(paymentDataValues) { - console.log(paymentDataValues); - // Stripe API calls, etc - } - const handleSignup = async (e) => { e.preventDefault(); - const paymentDataValues = validatePaymentData(); - if (paymentDataValues === null) { + if (isBusy) { return; } - /* - const paymentSuccess = handleStripePaymentAuthorization(paymentDataValues); - - if (paymentSuccess) { - if (isBusy) { - return; - } - - setIsBusy(true); - try { - const userCredential = await createUserWithEmailAndPassword( - auth, - dataValues.email, - dataValues.password - ); - const user = userCredential.user; - await saveUserData(user.uid, dataValues); - navigate("/"); - } catch (error) { - setIsBusy(false); - setNotice( - error.message || "Sorry, something went wrong. Please try again." - ); - } - } - */ - }; - - const handleProceedToPayment = () => { - /* const dataValues = validateData(); if (dataValues === null) { return; } -*/ - setShowPaymentModal(true); - }; - - const handleCancel = () => { - setShowPaymentModal(false); - }; - - const MobileForm = () => { - return splitEvery( - Object.keys(signupfields).slice(0, -2), - fieldsChunkSize - ).map((names, j) => ( -