From a7f0dd1229118b10c77e5bbf6002d9c6c80a90fc Mon Sep 17 00:00:00 2001 From: hamzat Date: Wed, 11 Jan 2023 03:32:50 +0100 Subject: [PATCH] clean up pricing functionality --- .../src/components/spinner/Spinner.jsx | 6 +- .../pages/applications/components/Table.jsx | 1 + .../applications/components/rr_table.jsx | 3 + .../src/pages/paystack/paystack.jsx | 23 --- .../src/pages/pricing_plan/Pricing.jsx | 149 +----------------- .../pages/pricing_plan/components/Plans3.jsx | 76 ++++----- .../pages/pricing_plan/components/Plans4.jsx | 35 ++-- 7 files changed, 67 insertions(+), 226 deletions(-) diff --git a/Apply-For-Me-UI/src/components/spinner/Spinner.jsx b/Apply-For-Me-UI/src/components/spinner/Spinner.jsx index 19d70f21..7ed339df 100644 --- a/Apply-For-Me-UI/src/components/spinner/Spinner.jsx +++ b/Apply-For-Me-UI/src/components/spinner/Spinner.jsx @@ -1,16 +1,16 @@ /* eslint-disable no-unused-vars */ import React from "react"; import { useState } from "react"; -import PacmanLoader from "react-spinners/PacmanLoader"; +import ScaleLoader from "react-spinners/ScaleLoader"; import classes from "./Spinner.module.css"; const Spinner = () => { let [color] = useState("#2E3192"); return (
- diff --git a/Apply-For-Me-UI/src/pages/applications/components/Table.jsx b/Apply-For-Me-UI/src/pages/applications/components/Table.jsx index 6466dc53..26f0a5c6 100644 --- a/Apply-For-Me-UI/src/pages/applications/components/Table.jsx +++ b/Apply-For-Me-UI/src/pages/applications/components/Table.jsx @@ -36,6 +36,7 @@ const Table = () => { setPageCout(response.data?.totalPages); } catch (error) { toast.error(`${error}`); + console.log("thisis", JSON.stringify(error.response)) } }, [token, pagination.pageNo, pagination.pageSize]); diff --git a/Apply-For-Me-UI/src/pages/applications/components/rr_table.jsx b/Apply-For-Me-UI/src/pages/applications/components/rr_table.jsx index 98626aa2..6513d80a 100644 --- a/Apply-For-Me-UI/src/pages/applications/components/rr_table.jsx +++ b/Apply-For-Me-UI/src/pages/applications/components/rr_table.jsx @@ -30,6 +30,7 @@ const Table = () => { } ); setData(response.data?.content); + console.log(response.data?.content); setPageCout(response.data?.totalPages); setIsLoading(false); @@ -100,6 +101,7 @@ const Table = () => {
Name
+
Job Title
Salary
Type
Details
@@ -107,6 +109,7 @@ const Table = () => { {data?.map((application, index) => { return(
+
{application.professional.member.firstName}
{application.profileTitle}
{application.salaryRange}
{application.preferredJobLocationType}
diff --git a/Apply-For-Me-UI/src/pages/paystack/paystack.jsx b/Apply-For-Me-UI/src/pages/paystack/paystack.jsx index 1d480e29..0b25e15a 100644 --- a/Apply-For-Me-UI/src/pages/paystack/paystack.jsx +++ b/Apply-For-Me-UI/src/pages/paystack/paystack.jsx @@ -3,7 +3,6 @@ import jwt_decode from "jwt-decode"; import { useParams } from "react-router-dom"; import Spinner from "components/spinner/PulseLoader"; import { useState } from "react"; -// import { useCallback } from "react"; import axios from "axios"; import { toast, ToastContainer } from "react-toastify"; @@ -13,26 +12,7 @@ export const PaystackPage = () => { const { price, planName, paymentInterval } = useParams(); const channels = ["card", "bank"]; const currency = "NGN"; - - // const [convertedPrice, setConvertedPrice] = useState(); - // const exchangeBaseUrl = "https://api.apilayer.com/exchangerates_data"; const token = localStorage.getItem("tokenHngKey"); - // const convertToNaira = useCallback(async () => { - // try { - // const response = await axios.get( - // `${exchangeBaseUrl}/convert?to=NGN&from=USD&amount=${price}`, - // { - // headers: { - // "apikey": process.env.REACT_APP_EXCHANGE_RATE_API_KEY - // } - // } - // ); - // setConvertedPrice(response?.data?.result); - // setLoading(false); - // } catch (err) { - // toast.error(err?.response?.data?.message); - // } - // }, [price]); const createPlan = async(planName,paymentInterval)=>{ setLoading(true); @@ -91,9 +71,6 @@ export const PaystackPage = () => { setLoading(false); } } - // useEffect(() => { - // convertToNaira(); - // }, [convertToNaira]) const handleSubmit = (e)=>{ e.preventDefault(); diff --git a/Apply-For-Me-UI/src/pages/pricing_plan/Pricing.jsx b/Apply-For-Me-UI/src/pages/pricing_plan/Pricing.jsx index 4d7fc48f..cce1128a 100644 --- a/Apply-For-Me-UI/src/pages/pricing_plan/Pricing.jsx +++ b/Apply-For-Me-UI/src/pages/pricing_plan/Pricing.jsx @@ -34,16 +34,12 @@ const Pricing = ({ const [paymentInterval, setpaymentInterval] = useState(); const [seeMore, setSeeMore] = useState(false); - //const data = seeMore ? plans : plansFull; - useEffect(() => { toggle.yearly ? setpaymentInterval("yearly") : setpaymentInterval("monthly"); }, [toggle.yearly, paymentInterval]); - //const location = useLocation(); - - //const { user } = useSelector(state => state.user); + const navigate = useNavigate(); return ( @@ -114,149 +110,6 @@ const Pricing = ({ therefore prices are not included in the pricing plan but based on individual requests.

- {/*
- {data.map( - ( - { - planName, - price, - duration, - model, - btnText, - stamp - }, - index - ) => { - return ( -
-
-

- {stamp} -

-
- -

- {planName} Plan -

-

- $ {price} -

-

- {duration} -

- -
- {model.map( - ( - { icon, text, alt }, - index - ) => { - return ( -
- {alt} -

- {text} -

-
- ); - } - )} -
- {user ? ( - { - let isAuthorized; - user?.roles?.forEach( - role => { - if ( - role.includes( - "Professional" - ) - ) { - isAuthorized = true; - } - } - ); - if ( - isAuthorized && - price !== "0" - ) { - navigate( - `/checkout/${planName}/${paymentInterval}/${price}` - ); - } else if ( - isAuthorized && - price === "0" - ) { - return; - } else { - toast.error( - "Unauthorized" - ); - } - }} - /> - ) : ( - <> - - navigate("/wel2", { - state: { - from: location - } - }) - } - />{" "} - - )} -
- ); - } - )} -
*/} - - {/*
-

- See more plans -

-
*/} - {!seeMore && (
); diff --git a/Apply-For-Me-UI/src/pages/pricing_plan/components/Plans4.jsx b/Apply-For-Me-UI/src/pages/pricing_plan/components/Plans4.jsx index b99a306f..81142aa6 100644 --- a/Apply-For-Me-UI/src/pages/pricing_plan/components/Plans4.jsx +++ b/Apply-For-Me-UI/src/pages/pricing_plan/components/Plans4.jsx @@ -3,11 +3,13 @@ import BlueButton from "components/buttons/blue_background/BlueButton"; import { toast } from "react-toastify"; import { useSelector } from "react-redux"; import styles from "./plans4.module.css"; +import { useState } from "react"; const Plans3 = ({ paymentInterval, plans }) => { const location = useLocation(); const navigate = useNavigate(); const { user } = useSelector(state => state.user); + const [activeSubScription] = useState("Free") return (
{plans.map( @@ -46,32 +48,33 @@ const Plans3 = ({ paymentInterval, plans }) => { ); })}
- {user ? ( + {user && (user?.roles?.includes("Professional"))? ( + activeSubScription !== planName ? { - let isAuthorized; - user?.roles?.forEach(role => { - if (role.includes("Professional")) { - isAuthorized = true; - } - }); - if (isAuthorized && price !== "0") { + if (price !== "0") { navigate( `/checkout/${planName}/${paymentInterval}/${price}` ); - } else if ( - isAuthorized && - price === "0" - ) { - return; } else { - toast.error("Unauthorized"); + return; } }} /> - ) : ( + : + + ) : user && (!user?.roles?.includes("Professional"))? ( + toast("SubScriptions are meant for users alone")} + /> + ):( <>