diff --git a/src/App.js b/src/App.js index a9ffc32..a3d8d6a 100644 --- a/src/App.js +++ b/src/App.js @@ -47,7 +47,10 @@ function App() { } /> } /> - } /> + } + /> } /> { }; const handleConfirmUpgrade = () => { - console.log("handle confirm upgrade"); + const isUpgrade = true; + const currentPlan = group?.subscriptionPlan; + navigate(`/signup/${isUpgrade}/${currentPlan}`); }; + const handleSuccess = () => { setIsLoading(true); setShowUploadModal(false); diff --git a/src/Components/SignupPage/SignupPage.js b/src/Components/SignupPage/SignupPage.js index 30a4ca6..ead6b0f 100644 --- a/src/Components/SignupPage/SignupPage.js +++ b/src/Components/SignupPage/SignupPage.js @@ -3,6 +3,7 @@ import Col from "react-bootstrap/Col"; import Form from "react-bootstrap/Form"; import Row from "react-bootstrap/Row"; import Button from "../../pageElements/Button"; +import { useParams } from "react-router-dom"; import { db, auth } from "../../firebase"; import { createUserWithEmailAndPassword } from "firebase/auth"; import { useNavigate } from "react-router-dom"; @@ -30,8 +31,8 @@ import "../../styles/signup.scss"; import Stripe from "stripe"; import { stripeApiKey } from "../../secrets"; -const SignupPage = (props) => { - const { isUpgrade } = props; +const SignupPage = () => { + const { isUpgrade, currentPlan } = useParams(); const navigate = useNavigate(); const [notice, setNotice] = useState(""); const fieldsChunkSize = 2; @@ -41,7 +42,9 @@ const SignupPage = (props) => { getFormDataDefaults(paymentfields) ); const [showPaymentModal, setShowPaymentModal] = useState(false); - const [showSelectPlan, setShowSelectPlan] = useState(false); + const [showSelectPlan, setShowSelectPlan] = useState( + isUpgrade ? true : false + ); const [activeRadioOption, setActiveRadioOption] = useState("partner"); const [selectedPlan, setSelectedPlan] = useState([signupRadioFields[1]]); const [isAnnual, setIsAnnual] = useState(1); @@ -201,6 +204,7 @@ const SignupPage = (props) => { email, customerId: customerId, subscriptionId: subscriptionId, + subscriptionPlan: plan, }; try { @@ -379,97 +383,101 @@ const SignupPage = (props) => { selectedPlan[0].value === "seniorPartner" || selectedPlan[0].value === "partner"; + const signupForm = ( +
+
+

Create a Novodraft account

+
+
+ {splitEvery( + Object.keys(signupFields).slice(0, -2), + fieldsChunkSize + ).map((names, j) => ( + + {names.map((name, i) => ( + + handleChangeInput(e, name)} + error={data[name].error} + message={data[name].message} + label={ + data[name].value.length === 0 + ? signupFields[name].label + : "" + } + type={signupFields[name].type} + values={signupFields[name].values} + disabled={isBusy} + /> + + ))} + + ))} + + + handleChangeInput(e, "password")} + disabled={isBusy} + /> + + + + + handleChangeInput(e, "confirmPassword")} + disabled={isBusy} + /> + + +
+
+
+ {showNoticeOnPage ? ( + <> +

+
+ {notice} +
+ + ) : ( + <> + )} +
+ ); + const magicIndex = currentPlan === "associate" ? 1 : 2; return (
-
-
-

Create a Novodraft account

-
-
- {splitEvery( - Object.keys(signupFields).slice(0, -2), - fieldsChunkSize - ).map((names, j) => ( - - {names.map((name, i) => ( - - handleChangeInput(e, name)} - error={data[name].error} - message={data[name].message} - label={ - data[name].value.length === 0 - ? signupFields[name].label - : "" - } - type={signupFields[name].type} - values={signupFields[name].values} - disabled={isBusy} - /> - - ))} - - ))} - - - handleChangeInput(e, "password")} - disabled={isBusy} - /> - - - - - handleChangeInput(e, "confirmPassword")} - disabled={isBusy} - /> - - -
-
-
- {showNoticeOnPage ? ( - <> -

-
- {notice} -
- - ) : ( - <> - )} -
+ {!isUpgrade ? signupForm : <>} {showSelectPlan ? (
@@ -488,7 +496,7 @@ const SignupPage = (props) => {
- {signupRadioFields?.map((option, i) => ( + {signupRadioFields?.map((option, index) => (
{ activeRadioOption={activeRadioOption} price={option.pricing} isAnnual={isAnnual} + isUpgrade={index < magicIndex ? true : false} + disabled={index < magicIndex ? true : false} + currentPlan={currentPlan} />
))} diff --git a/src/pageElements/Radio.js b/src/pageElements/Radio.js index 687b0dc..6898216 100644 --- a/src/pageElements/Radio.js +++ b/src/pageElements/Radio.js @@ -13,22 +13,26 @@ const Radio = (props) => { activeRadioOption, details, isAnnual, + isUpgrade, + currentPlan, } = props; const classCheckbox = "checkbox"; const classOption = "option"; const index = isAnnual === 1 ? Number("1") : Number("0"); + const upgradeClass = isUpgrade ? "upgrade" : "not-upgrade"; + return (
<> -
+
!disabled && onClick && onClick(value)} > - {value == activeRadioOption ? ( + {value == activeRadioOption && !isUpgrade ? (
@@ -48,7 +52,7 @@ const Radio = (props) => {
{description.map((item, i) => { const el = - item == "First month free!" ? ( + item == "First month free!" && !isUpgrade ? (

{item}

diff --git a/src/styles/radio.scss b/src/styles/radio.scss index 75b9076..ae5039b 100644 --- a/src/styles/radio.scss +++ b/src/styles/radio.scss @@ -1,7 +1,12 @@ .radio-circle-container { display: flex; flex-direction: column; - background-color: #fff; + &.upgrade { + background-color: rgb(149, 149, 149); + } + &.not-upgrade { + background-color: #fff; + } height: 290px; margin: 10px 8px 0px 8px; border-radius: 5px;