From 793762fec9a20a76ca40de91929c8cdf503aa0d9 Mon Sep 17 00:00:00 2001 From: mohammedsalah7 Date: Wed, 3 Nov 2021 14:33:24 +0200 Subject: [PATCH] get all data from api and display it in profile #55 --- client/package.json | 2 + .../components/Agent/EstateAgent/index.jsx | 179 ++++++++++-------- client/src/components/Agent/Favroit/index.jsx | 2 +- client/src/components/Agent/Info/index.jsx | 23 ++- .../components/Agent/PenddingEstate/index.jsx | 2 +- client/src/components/tab/index.jsx | 8 +- client/src/pages/Profile/index.jsx | 63 ++++-- 7 files changed, 170 insertions(+), 109 deletions(-) diff --git a/client/package.json b/client/package.json index b900884..f8568bf 100644 --- a/client/package.json +++ b/client/package.json @@ -6,12 +6,14 @@ "dependencies": { "@emotion/react": "^11.5.0", "@emotion/styled": "^11.3.0", + "@mui/icons-material": "^5.0.5", "@mui/material": "^5.0.4", "@testing-library/jest-dom": "^5.14.1", "@testing-library/react": "^11.2.7", "@testing-library/user-event": "^12.8.3", "axios": "^0.23.0", "eslint-config-react-app": "^6.0.0", + "prop-types": "^15.7.2", "react": "^17.0.2", "react-dom": "^17.0.2", "react-router-dom": "^5.3.0", diff --git a/client/src/components/Agent/EstateAgent/index.jsx b/client/src/components/Agent/EstateAgent/index.jsx index 08ad579..a40d9cd 100644 --- a/client/src/components/Agent/EstateAgent/index.jsx +++ b/client/src/components/Agent/EstateAgent/index.jsx @@ -1,3 +1,5 @@ +/* eslint-disable no-console */ +/* eslint-disable react/prop-types */ /* eslint-disable import/no-extraneous-dependencies */ import { Container, @@ -8,101 +10,112 @@ import CardContent from '@mui/material/CardContent'; import DeleteIcon from '@mui/icons-material/Delete'; import Button from '@mui/material/Button'; import Typography from '@mui/material/Typography'; -import House from '../../../asstes/house.jpeg'; +import House from '../../../assetes/house.jpeg'; import './style.css'; -const AgenteEstate = () => ( - - - - { + console.log('AgenteEstate', data); + return ( + - publish house + > + + {data.length ? data.map((datas) => ( + + + - Rhoncus sed vestibulum - {' '} - - - - massa volutpat convallis morbi odio odio elementum eu interdum eu tincidunt in - - - - House - {' '} - - + {datas.title} + + + + + {datas.title} + {' '} + + + + {datas.description} + + + + {datas.category} + {' '} + + + + + {datas.type} + {' '} + + + + + - - Buy - {' '} - + - - - - - - - + + )) : ' You are still not published any estate' } - -); + + ); +}; export default AgenteEstate; diff --git a/client/src/components/Agent/Favroit/index.jsx b/client/src/components/Agent/Favroit/index.jsx index bccd4d9..11d58e3 100644 --- a/client/src/components/Agent/Favroit/index.jsx +++ b/client/src/components/Agent/Favroit/index.jsx @@ -13,7 +13,7 @@ import Divider from '@mui/material/Divider'; import ListItemText from '@mui/material/ListItemText'; import ListItemAvatar from '@mui/material/ListItemAvatar'; import Avatar from '@mui/material/Avatar'; -import House from '../../../asstes/house.jpeg'; +import House from '../../../assetes/house.jpeg'; const AgenteFavariot = () => ( ( +const AgentInfo = ({ + name, email, phone, avater, +}) => ( ( }} > ( > - Mohammed M. Salah + {name} {' '} - 0597777777 + {phone} @@ -72,7 +75,7 @@ const AgentInfo = () => ( - moh2020@gmail.com + {email} @@ -97,5 +100,11 @@ const AgentInfo = () => ( ); +AgentInfo.propTypes = { + name: PropTypes.string.isRequired, + email: PropTypes.string.isRequired, + phone: PropTypes.string.isRequired, + avater: PropTypes.string.isRequired, +}; export default AgentInfo; diff --git a/client/src/components/Agent/PenddingEstate/index.jsx b/client/src/components/Agent/PenddingEstate/index.jsx index e38d32e..73184d5 100644 --- a/client/src/components/Agent/PenddingEstate/index.jsx +++ b/client/src/components/Agent/PenddingEstate/index.jsx @@ -5,7 +5,7 @@ import { import Card from '@mui/material/Card'; import CardContent from '@mui/material/CardContent'; import Typography from '@mui/material/Typography'; -import House from '../../../asstes/house.jpeg'; +import House from '../../../assetes/house.jpeg'; const PenddingEstate = () => ( { @@ -69,7 +69,7 @@ export default function ProfileTabs() { - + diff --git a/client/src/pages/Profile/index.jsx b/client/src/pages/Profile/index.jsx index 676d427..4e26929 100644 --- a/client/src/pages/Profile/index.jsx +++ b/client/src/pages/Profile/index.jsx @@ -1,3 +1,8 @@ +/* eslint-disable no-unused-vars */ +/* eslint-disable no-console */ +import { useState, useEffect } from 'react'; +import axios from 'axios'; + import { Container, Box, } from '@mui/material'; @@ -6,22 +11,54 @@ import AgenteFavariot from '../../components/Agent/Favroit'; import ProfileTabs from '../../components/tab'; -const AgentProfile = () => ( +const AgentProfile = () => { + const [error, setError] = useState(''); + const [data, setData] = useState([]); + const [userId, setUserId] = useState(1); + + useEffect(() => { + const getData = async () => { + await axios.get(`/api/v1/users/${userId}/estates`) + .then((res) => { + setData(res.data.data); + }) + .catch((err) => { + setError(err); + }); + }; + getData(); + }, [userId]); + + console.log('ssss', data); + console.log(error); + return ( - - - - - - + + { + data.length + ? ( + + ) + : 'loading' + } + + + + - {' '} + {' '} - + -); + ); +}; export default AgentProfile;