From 222ee70f8770fde9b7bbb415992b4bb51a3fbd45 Mon Sep 17 00:00:00 2001 From: M M Date: Sun, 9 Jun 2024 23:37:47 -0700 Subject: [PATCH 1/6] Implemented the integrations page. --- Client/package-lock.json | 18 -------- Client/src/Components/Integrations/index.jsx | 4 +- Client/src/Pages/Integrations/index.jsx | 43 +++++++++++++++++--- 3 files changed, 39 insertions(+), 26 deletions(-) diff --git a/Client/package-lock.json b/Client/package-lock.json index 26b303991..c33093918 100644 --- a/Client/package-lock.json +++ b/Client/package-lock.json @@ -1424,15 +1424,9 @@ } }, "node_modules/@mui/x-charts": { -<<<<<<< HEAD "version": "7.6.1", "resolved": "https://registry.npmjs.org/@mui/x-charts/-/x-charts-7.6.1.tgz", "integrity": "sha512-LuAVQX4lzhmsqk2NRdWCP+aQZ8kRwG7KOy8ulf8hR5NI5J1VsiOtH41J+qgV3uAC6hDMWL7fTgffrRDFTMci/g==", -======= - "version": "7.6.2", - "resolved": "https://registry.npmjs.org/@mui/x-charts/-/x-charts-7.6.2.tgz", - "integrity": "sha512-oG22NRno1+HSLV/9jVLThnHAKN4g+MXOO6GqaQxN9LM0hjt1tgRsrNAlfcJndmj/dVwqFtynkFB5qWnTEBZs7Q==", ->>>>>>> 3f41db916efdd46069589e91f5886a4a01d11896 "dependencies": { "@babel/runtime": "^7.24.6", "@mui/base": "^5.0.0-beta.40", @@ -2436,15 +2430,9 @@ } }, "node_modules/caniuse-lite": { -<<<<<<< HEAD "version": "1.0.30001628", "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001628.tgz", "integrity": "sha512-S3BnR4Kh26TBxbi5t5kpbcUlLJb9lhtDXISDPwOfI+JoC+ik0QksvkZtUVyikw3hjnkgkMPSJ8oIM9yMm9vflA==", -======= - "version": "1.0.30001629", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001629.tgz", - "integrity": "sha512-c3dl911slnQhmxUIT4HhYzT7wnBK/XYpGnYLOj4nJBaRiw52Ibe7YxlDaAeRECvA786zCuExhxIUJ2K7nHMrBw==", ->>>>>>> 3f41db916efdd46069589e91f5886a4a01d11896 "dev": true, "funding": [ { @@ -2848,15 +2836,9 @@ } }, "node_modules/electron-to-chromium": { -<<<<<<< HEAD "version": "1.4.790", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.790.tgz", "integrity": "sha512-eVGeQxpaBYbomDBa/Mehrs28MdvCXfJmEFzaMFsv8jH/MJDLIylJN81eTJ5kvx7B7p18OiPK0BkC06lydEy63A==", -======= - "version": "1.4.792", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.792.tgz", - "integrity": "sha512-rkg5/N3L+Y844JyfgPUyuKK0Hk0efo3JNxUDKvz3HgP6EmN4rNGhr2D8boLsfTV/hGo7ZGAL8djw+jlg99zQyA==", ->>>>>>> 3f41db916efdd46069589e91f5886a4a01d11896 "dev": true }, "node_modules/error-ex": { diff --git a/Client/src/Components/Integrations/index.jsx b/Client/src/Components/Integrations/index.jsx index b0e00bdfe..7d7ae96c4 100644 --- a/Client/src/Components/Integrations/index.jsx +++ b/Client/src/Components/Integrations/index.jsx @@ -5,7 +5,7 @@ import Button from '../Button'; * Integrations component * @returns {JSX.Element} */ -const Integrations = () => { +const IntegrationsComponent = () => { const theme = useTheme(); return ( @@ -53,4 +53,4 @@ const Integrations = () => { ); }; -export default Integrations; +export default IntegrationsComponent; diff --git a/Client/src/Pages/Integrations/index.jsx b/Client/src/Pages/Integrations/index.jsx index 1df87ee52..ca90e79ef 100644 --- a/Client/src/Pages/Integrations/index.jsx +++ b/Client/src/Pages/Integrations/index.jsx @@ -1,9 +1,40 @@ -import React from 'react' +import IntegrationsComponent from '../../Components/Integrations'; +import { Box, Typography, useTheme } from '@mui/material'; +/** + * Integrations Page Component + * @returns {JSX.Element} + */ const Integrations = () => { + const theme = useTheme(); + return ( -
Integrations
- ) -} - -export default Integrations \ No newline at end of file + + + Integrations + + + Connect Uptime Genie to your favorite service + + + + + + + + ); + }; + + export default Integrations; From 91891b1a90d850dba7ec6e41fbdee8a7012e1a45 Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Mon, 10 Jun 2024 10:38:00 -0700 Subject: [PATCH 2/6] Added async thunk --- Client/src/Features/Auth/authSlice.js | 4 ++ Client/src/Pages/Login/index.jsx | 53 ++++++++++++++++++++++----- Client/src/Validation/validation.js | 18 ++++++++- 3 files changed, 65 insertions(+), 10 deletions(-) diff --git a/Client/src/Features/Auth/authSlice.js b/Client/src/Features/Auth/authSlice.js index f8bc106e5..d361ffa05 100644 --- a/Client/src/Features/Auth/authSlice.js +++ b/Client/src/Features/Auth/authSlice.js @@ -22,6 +22,10 @@ export const register = createAsyncThunk( } ); +export const login = createAsyncThunk("auth/login", async (form, thunkApi) => { + console.log(form); +}); + const authSlice = createSlice({ name: "auth", initialState, diff --git a/Client/src/Pages/Login/index.jsx b/Client/src/Pages/Login/index.jsx index 19edcf6f0..3732e52c8 100644 --- a/Client/src/Pages/Login/index.jsx +++ b/Client/src/Pages/Login/index.jsx @@ -1,4 +1,4 @@ -import { useState } from "react"; +import { useState, useEffect } from "react"; import "./index.css"; import BackgroundPattern from "../../Components/BackgroundPattern/BackgroundPattern"; import Logomark from "../../assets/Images/Logomark.png"; @@ -8,23 +8,51 @@ import Button from "../../Components/Button"; import Google from "../../assets/Images/Google.png"; import PasswordTextField from "../../Components/TextFields/Password/PasswordTextField"; +import { loginValidation } from "../../Validation/validation"; +import { login } from "../../Features/Auth/authSlice"; +import { useDispatch } from "react-redux"; + const Login = () => { + const dispatch = useDispatch(); + const idMap = { "login-email-input": "email", "login-password-input": "password", }; + const [errors, setErrors] = useState({}); + const [form, setForm] = useState({ email: "", password: "", }); - const handleInput = (e) => { - const fieldName = idMap[e.target.id]; - setForm({ - ...form, - [fieldName]: e.target.value, + useEffect(() => { + const { error } = loginValidation.validate(form, { + abortEarly: false, }); + + if (error) { + // Creates an error object in the format { field: message } + const validationErrors = error.details.reduce((acc, err) => { + return { ...acc, [err.path[0]]: err.message }; + }, {}); + setErrors(validationErrors); + } + }, []); + + const handleSubmit = async () => { + try { + await loginValidation.validateAsync(form, { abortEarly: false }); + dispatch(login(form)); + } catch (error) { + console.log(error); + } + }; + + const handleInput = (e) => { + const newForm = { ...form, [idMap[e.target.id]]: e.target.value }; + setForm(newForm); }; return ( @@ -44,14 +72,16 @@ const Login = () => {
@@ -63,7 +93,12 @@ const Login = () => {
-