From fc457e7dc9077be5c3d151e53669cf37285d20a6 Mon Sep 17 00:00:00 2001 From: Priyatham Sai Chand Date: Tue, 23 Mar 2021 23:31:06 +0530 Subject: [PATCH] pricing confirm --- client/src/components/Payment.js | 17 +++++++- client/src/components/PricingPlan.js | 59 +++++++++++++++++++++++----- server/routes/users.js | 1 + 3 files changed, 66 insertions(+), 11 deletions(-) diff --git a/client/src/components/Payment.js b/client/src/components/Payment.js index 199e538..fa50423 100644 --- a/client/src/components/Payment.js +++ b/client/src/components/Payment.js @@ -1,6 +1,21 @@ -import React from 'react'; +import React,{ useContext } from 'react'; import NavBar from './NavBar'; import Footer from './Footer'; +import UserContext from '../context/UserContext' +const Payment = (props) => { + const { userData, setUserData } = useContext(UserContext); + + return ( +
+ +

{userData.user.username}

+

{props.pricing}

+ +
+ + ); +} +export default Payment; diff --git a/client/src/components/PricingPlan.js b/client/src/components/PricingPlan.js index 9e4b232..16aea0b 100644 --- a/client/src/components/PricingPlan.js +++ b/client/src/components/PricingPlan.js @@ -1,8 +1,11 @@ -import React, { useState,Component,useContext } from 'react'; +import React, { useState,useContext } from 'react'; import NavBar from './NavBar'; import Footer from './Footer'; import styled,{css} from 'styled-components'; import UserContext from "../context/UserContext"; +import Payment from "./Payment"; +import { useHistory } from "react-router-dom"; +import Axios from 'axios'; const size = { mobileS: '320px', @@ -176,6 +179,7 @@ const Button = styled.a` letter-spacing: 0.02em; font-weight: bold; text-align: center; + cursor: pointer; &:hover { @@ -185,21 +189,46 @@ const Button = styled.a` } +`; + +const Heading = styled.h1` + color: #66bfbf; + margin-left: 20px; + margin-top: 100px; + + `; const PricingPlan = () => { -const { userData, setUserData } = useContext(UserContext); -const [pricing, setPricing] = useState(); + + const { userData, setUserData } = useContext(UserContext); +const [ purchased, setPurchased ] = useState(false); + const [ pricing, setPricing ] = useState(); + + const history = useHistory(); +const submit = async (props) => { + props.preventDefault(); + try { + const pricingRes = await Axios.put( + "http://localhost:5000/users/update", { + userData.user.email, + pricing + } + + ); + } catch (err) { + console.log(err); + + } +} return (
- -
-
-
-

Pricing Plan

- {pricing} + { !purchased ? ( + + + Pricing Plan setPricing(event.target.value)}> @@ -281,8 +310,18 @@ const [pricing, setPricing] = useState(); - + + + ): ( + + user name: {userData.user.username} +

Plan selected : {pricing}

+ + +
+ ) + }