From e61927ca2722de4215cef5b3e7d7d23071efcb30 Mon Sep 17 00:00:00 2001 From: panshak Date: Sun, 6 Feb 2022 14:56:41 +0100 Subject: [PATCH] add and autofill payment info/notes --- client/src/actions/auth.js | 8 +-- client/src/components/Invoice/Invoice.js | 13 +++-- .../InvoiceDetails/InvoiceDetails.js | 4 +- .../InvoiceDetails/InvoiceDetails.module.css | 7 ++- client/src/components/Login/Google.js | 2 +- client/src/components/Login/Login.js | 19 ++++--- client/src/components/Login/Login.module.css | 19 +++++++ client/src/components/Settings/Form/Form.js | 28 +++++----- client/src/components/Settings/Form/Input.js | 4 +- .../src/components/Settings/Form/Profile.js | 52 +++++++++++++++++++ client/src/components/Settings/Form/styles.js | 4 +- .../components/Settings/Settings.module.css | 4 +- server/index.js | 1 - server/models/ProfileModel.js | 3 +- 14 files changed, 128 insertions(+), 40 deletions(-) create mode 100644 client/src/components/Settings/Form/Profile.js diff --git a/client/src/actions/auth.js b/client/src/actions/auth.js index 0914ff69..1cd468bb 100644 --- a/client/src/actions/auth.js +++ b/client/src/actions/auth.js @@ -2,14 +2,14 @@ import * as api from '../api/index' import { AUTH, CREATE_PROFILE } from './constants' -export const signin =(formData, openSnackbar) => async(dispatch) => { +export const signin =(formData, openSnackbar, setLoading) => async(dispatch) => { try { //login the user const { data } = await api.signIn(formData) dispatch({ type: AUTH, data}) - + // setLoading(false) openSnackbar("Signin successfull") // history.push('/dashboard') window.location.href="/dashboard" @@ -17,10 +17,11 @@ export const signin =(formData, openSnackbar) => async(dispatch) => { } catch (error) { // console.log(error?.response?.data?.message) openSnackbar(error?.response?.data?.message) + setLoading(false) } } -export const signup =(formData, openSnackbar) => async(dispatch) => { +export const signup =(formData, openSnackbar, setLoading) => async(dispatch) => { try { //Sign up the user @@ -35,6 +36,7 @@ export const signup =(formData, openSnackbar) => async(dispatch) => { } catch (error) { console.log(error) openSnackbar(error?.response?.data?.message) + setLoading(false) } } diff --git a/client/src/components/Invoice/Invoice.js b/client/src/components/Invoice/Invoice.js index 0dad1879..1c918e05 100644 --- a/client/src/components/Invoice/Invoice.js +++ b/client/src/components/Invoice/Invoice.js @@ -37,6 +37,7 @@ import AddClient from './AddClient'; import InvoiceType from './InvoiceType'; import axios from 'axios' import { useLocation } from 'react-router-dom' +import { getProfilesByUser } from '../../actions/profile' // import SelectType from './SelectType' const useStyles = makeStyles((theme) => ({ @@ -82,13 +83,18 @@ const Invoice = () => { const dispatch = useDispatch() const history = useHistory() const user = JSON.parse(localStorage.getItem('profile')) + const { profiles } = useSelector((state) => state.profiles) + useEffect(() => { getTotalCount() + dispatch(getProfilesByUser({ search: user?.result?._id || user?.result.googleId})) + // setInvoiceData({...invoiceData, notes: profiles?.paymentDetails}) // eslint-disable-next-line },[location]) +console.log(profiles.paymentDetails) const getTotalCount = async() => { try { @@ -155,7 +161,7 @@ const Invoice = () => { setInvoiceData((prevState) => ({...prevState, tax: e.target.value})) } - // console.log(invoiceData) + console.log(invoiceData) // Change handler for dynamically added input field const handleChange =(index, e) => { const values = [...invoiceData.items] @@ -472,11 +478,12 @@ const Invoice = () => {
-

Notes/Terms

+

Note/Payment Details