From f79f07fc66439b415d171aa50195a9c5249dd1fd Mon Sep 17 00:00:00 2001 From: Eduard Tudorache Date: Fri, 11 Nov 2022 15:42:35 +0100 Subject: [PATCH 1/2] work done on profile page --- .../sidescreen/dashboard/Dashboard.jsx | 2 +- .../dashboard/sidescreen/user/User.jsx | 45 ++++++++++++++++++- .../dashboard/sidescreen/user/User.scss | 28 ++++++++++++ 3 files changed, 73 insertions(+), 2 deletions(-) create mode 100644 src/screens/dashboard/sidescreen/user/User.scss diff --git a/src/screens/dashboard/sidescreen/dashboard/Dashboard.jsx b/src/screens/dashboard/sidescreen/dashboard/Dashboard.jsx index 9a7f73a..16c5639 100644 --- a/src/screens/dashboard/sidescreen/dashboard/Dashboard.jsx +++ b/src/screens/dashboard/sidescreen/dashboard/Dashboard.jsx @@ -10,7 +10,7 @@ import { ProgressBar } from 'react-loader-spinner'; import { getTickets } from '../../../../services/TicketService'; const Dashboard = () => { - const toMonthName= (monthNumber) => { + const toMonthName = (monthNumber) => { const date = new Date(); date.setMonth(monthNumber - 1); diff --git a/src/screens/dashboard/sidescreen/user/User.jsx b/src/screens/dashboard/sidescreen/user/User.jsx index 7200e80..6c784fd 100644 --- a/src/screens/dashboard/sidescreen/user/User.jsx +++ b/src/screens/dashboard/sidescreen/user/User.jsx @@ -1,20 +1,63 @@ import React, { useEffect, useState } from 'react'; +import { Link } from 'react-router-dom'; +import { getContracts } from '../../../../services/ContractService'; import { getCurrentUser } from '../../../../services/UserService'; +import "./User.scss" const User = () => { const [ user, setUser ] = useState({}) + const [ contracts, setContracts] = useState([]) + + const toMonthName = (monthNumber) => { + const date = new Date(); + date.setMonth(monthNumber - 1); + + return date.toLocaleString('en-US', { + month: 'short', + }); + } useEffect(() => { getCurrentUser() .then(user => { setUser(user) + getContracts(user) + .then(contracts => { + setContracts(contracts) + console.log(contracts); + }) + .catch(err => (console.log(err))) }) + .catch(err => console.log(err)) }, []) return ( +
+
+

Bienvenido {user.firstName}

+
-

{user.firstName}

+ {contracts.map((contract) => { + return ( + +
+

{contract.location.city}

+

+ {toMonthName(contract.createdAt.split('-').slice(1,-1).toString())} + {" "} + {contract.createdAt.split('-').slice(0, 1)} +

+

{contract.location.street}{" "}{contract.location.streetNumber}

+

{contract.price} €/kwh

+ {contract.solarPanels ?

Solar panels: {contract.solarPanels}

: ''} + {contract.solarPanels ?

Power generated per solar panel: {contract.powerPerPanel}

: ''} +
+ + ) + }) + }
+
); }; diff --git a/src/screens/dashboard/sidescreen/user/User.scss b/src/screens/dashboard/sidescreen/user/User.scss new file mode 100644 index 0000000..5ab0d80 --- /dev/null +++ b/src/screens/dashboard/sidescreen/user/User.scss @@ -0,0 +1,28 @@ +.contract-container { + background-color: white; + border-radius: 6px; + display: flex; + justify-content: space-between; + padding: 20px; + text-decoration: none; + box-shadow: 0px 10px 15px -3px rgba(0,0,0,0.1); + transition: .2s ease-in-out; + margin-bottom: 20px; + max-width: 400px; + &:visited { + color: #3d3d3d + } + &:hover { + color: #3d3d3d; + box-shadow: 0px 10px 15px 0px rgba(0,0,0,0.1); + background-color: rgb(223, 237, 255); + } + &:active { + color: #3d3d3d + } +} + +.contract-container-container { + display: flex; + flex-wrap: wrap; +} \ No newline at end of file From 2ef9b4e4f15b23733c04c91d7cd6214c1717ce78 Mon Sep 17 00:00:00 2001 From: Eduard Tudorache Date: Fri, 11 Nov 2022 16:07:22 +0100 Subject: [PATCH 2/2] profile finished, may need retouch --- src/components/misc/contract-select/ContractSelect.jsx | 9 +++++---- src/screens/dashboard/sidescreen/user/User.jsx | 6 ++++-- src/screens/dashboard/sidescreen/user/User.scss | 2 ++ 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/components/misc/contract-select/ContractSelect.jsx b/src/components/misc/contract-select/ContractSelect.jsx index 608eb47..c593e0a 100644 --- a/src/components/misc/contract-select/ContractSelect.jsx +++ b/src/components/misc/contract-select/ContractSelect.jsx @@ -2,16 +2,17 @@ import React from 'react'; import './ContractSelect.scss' const ContractSelect = ({contracts, contractSelected, setContractSelected}) => { + const handleChange = event => { setContractSelected(event.target.value); }; return (