From 47e3b0301cf7202a226ddf4f9261bdc5cd5d399c Mon Sep 17 00:00:00 2001 From: Emanuel Date: Fri, 22 Dec 2023 00:08:39 +0100 Subject: [PATCH] adding pricing page & some test changes for login page --- frontend/src/pages/Login.jsx | 131 ++++++++++++++------------- frontend/src/pages/Pricing.jsx | 110 ++++++++++++++++++++-- frontend/src/pages/Register.jsx | 156 +++++++++++++++++--------------- 3 files changed, 255 insertions(+), 142 deletions(-) diff --git a/frontend/src/pages/Login.jsx b/frontend/src/pages/Login.jsx index 89050cc..4da6936 100644 --- a/frontend/src/pages/Login.jsx +++ b/frontend/src/pages/Login.jsx @@ -1,14 +1,16 @@ import React, { useState } from 'react'; import axios from 'axios'; import qs from 'qs'; -import { Box, Button, Container, TextField, Typography } from '@mui/material'; +import { Box, Button, Checkbox, Container, FormControlLabel, TextField, Typography } from '@mui/material'; +import LockOutlinedIcon from '@mui/icons-material/LockOutlined'; import { useAuth } from '../contexts/AuthContext'; import { useNavigate } from 'react-router-dom'; import { API_URL } from '../utils/constants'; function LoginPage({ onLogin }) { - const [username, setUsername] = useState(''); + const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); + const [rememberMe, setRememberMe] = useState(false); const navigate = useNavigate(); const { updateAuth } = useAuth(); @@ -17,7 +19,7 @@ function LoginPage({ onLogin }) { try { const response = await axios.post(`${API_URL}token/`, qs.stringify ({ - username, + username: email, password }), { headers: { @@ -25,16 +27,12 @@ function LoginPage({ onLogin }) { } }); - // Assuming the backend sets the cookie automatically - // If login is successful, navigate to root if (response.status === 200) { - // Here you might want to do additional checks or set state updateAuth(true); navigate('/dashboards'); } } catch (error) { console.error('Login error:', error); - // Handle login error (e.g., show an error message) } }; @@ -44,61 +42,70 @@ function LoginPage({ onLogin }) { return ( - - - Login - - - setUsername(e.target.value)} - /> - setPassword(e.target.value)} - /> - - - - + + + + Sign in + + + setEmail(e.target.value)} + /> + setPassword(e.target.value)} + /> + } + label="Remember me" + checked={rememberMe} + onChange={(e) => setRememberMe(e.target.checked)} + /> + + + + + + + + Copyright © Your Website 2023. + + ); } diff --git a/frontend/src/pages/Pricing.jsx b/frontend/src/pages/Pricing.jsx index c17ac1c..5df6e71 100644 --- a/frontend/src/pages/Pricing.jsx +++ b/frontend/src/pages/Pricing.jsx @@ -1,8 +1,106 @@ -import React from "react"; -// import { Box, Container, Typography } from "@mui/material"; +import * as React from 'react'; +import { + Container, + Grid, + Typography, + Card, + CardContent, + CardActions, + Button, + Box +} from '@mui/material'; -const PricingPage = () => { -
-}; +function PricingPage() { + // Define the pricing tiers + const tiers = [ + { + title: 'Starter', + price: '190', + description: ['1 User', '1 App', 'Integrations'], + buttonText: 'Learn more', + buttonVariant: 'outlined', + }, + { + title: 'Pro', + price: '390', + description: [ + 'All in Starter plan', + 'Google Ads', + 'SSO via Google', + 'API access', + ], + buttonText: 'Learn more', + buttonVariant: 'contained', // Change to contained for the middle button + }, + { + title: 'Enterprise', + price: '690', + description: [ + 'All features', + 'Email support', + 'Google Ads', + 'SSO via Google', + 'API access', + 'Facebook Ads', + ], + buttonText: 'Learn more', + buttonVariant: 'outlined', + }, + ]; -export default PricingPage \ No newline at end of file + // Function to set the background color for the 'Pro' tier button + const getButtonStyle = (title) => { + return title === 'Pro' ? { bgcolor: 'primary.main', color: 'common.white' } : {}; + }; + + return ( + + + + Flexible pricing options + + + We are founded by a leading academic and researcher in the field of Industrial Systems Engineering. + For entrepreneurs, startups and freelancers. If you didn’t find what you needed, these could help! + + + {tiers.map((tier) => ( + + + + + {tier.title} + + + ${tier.price} + + /yr + + +
    + {tier.description.map((line) => ( + + {line} + + ))} +
+
+ + + +
+
+ ))} +
+
+
+ ); +} + +export default PricingPage; diff --git a/frontend/src/pages/Register.jsx b/frontend/src/pages/Register.jsx index b05921d..c9e83a9 100644 --- a/frontend/src/pages/Register.jsx +++ b/frontend/src/pages/Register.jsx @@ -1,13 +1,15 @@ import React, { useState } from 'react'; import axios from 'axios'; import { useNavigate } from 'react-router-dom'; -import { Box, Button, Container, TextField, Typography } from '@mui/material'; +import { Box, Button, Checkbox, Container, FormControlLabel, TextField, Typography } from '@mui/material'; +import LockOutlinedIcon from '@mui/icons-material/LockOutlined'; import { API_URL } from '../utils/constants'; function RegisterPage({ onRegister }) { const [username, setUsername] = useState(''); const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); + const [subscribe, setSubscribe] = useState(false); const navigate = useNavigate(); const handleSubmit = async (event) => { @@ -17,90 +19,96 @@ function RegisterPage({ onRegister }) { const response = await axios.post(`${API_URL}register/`, { username, email, - password + password, + // You can add subscribe or any additional fields if required by your API }); - // Assuming the backend sets the cookie automatically - // If registration is successful, navigate to the login page if (response.status === 200) { - navigate('/login'); + navigate('/login'); } } catch (error) { - console.error('Login error:', error); - // Handle login error (e.g., show an error message) + console.error('Registration error:', error); + // Handle registration error (e.g., show an error message) } }; return ( - - - Register - - - setUsername(e.target.value)} - /> - setEmail(e.target.value)} - /> - setPassword(e.target.value)} - /> - - - - + + + + Sign up + + + setUsername(e.target.value)} + /> + setEmail(e.target.value)} + /> + setPassword(e.target.value)} + /> + } + label="I want to receive inspiration, marketing promotions and updates via email." + checked={subscribe} + onChange={(e) => setSubscribe(e.target.checked)} + /> + + + Already have an account? + + + + + Copyright © Your Website 2023. + + ); } -export default RegisterPage; \ No newline at end of file +export default RegisterPage;