diff --git a/client/public/index.html b/client/public/index.html
index 4ad4ede..60a0c29 100644
--- a/client/public/index.html
+++ b/client/public/index.html
@@ -36,7 +36,7 @@
Learn how to configure a non-root public URL by running `npm run build`.
-->
- refine - Build your React-based CRUD applications, without constraints.
+ Dashboard
diff --git a/client/src/components/agent/AgentCard.tsx b/client/src/components/agent/AgentCard.tsx
index 0cf27e5..2c5bf0c 100644
--- a/client/src/components/agent/AgentCard.tsx
+++ b/client/src/components/agent/AgentCard.tsx
@@ -1,8 +1,75 @@
-import React from 'react'
+import { EmailOutlined,LocationCity,Phone,Place } from '@mui/icons-material'
+import { useGetIdentity } from '@pankod/refine-core'
+import {Box,Stack, Typography} from '@pankod/refine-mui'
+import { AgentCardProp,InfoBarProps } from 'interfaces/agent'
+import { Link } from "react-router-dom";
+const InfoBar=({icon,name}:InfoBarProps) =>(
+
+ {icon}
+ {name}
+
+);
+
+const AgentCard = ({id,name,email,avatar,noOfProperties}:AgentCardProp) => {
+ const {data:currentUser}=useGetIdentity();
+ const generateLink=()=>{
+ if(currentUser.email===email) return '/my-profile'
+ return `/agent/show/${id}`;
+ }
+
-const AgentCard = () => {
return (
- AgentCard
+
+
+
+
+ {name}
+ Real-Estate Agent
+
+
+ }
+ name={email}
+ />
+ }
+ name="London"
+ />
+ }
+ name="+744-2234-4455"
+ />
+ }
+ name={`${noOfProperties} Properties`}
+ />
+
+
+
)
}
diff --git a/client/src/components/common/Profile.tsx b/client/src/components/common/Profile.tsx
index f52d50d..5d5afcb 100644
--- a/client/src/components/common/Profile.tsx
+++ b/client/src/components/common/Profile.tsx
@@ -1,9 +1,197 @@
-import React from 'react'
+import { Email, Phone, Place } from "@mui/icons-material";
+import { Box, Stack, Typography } from "@mui/material";
-const Profile = () => {
- return (
- Profile
- )
+import { ProfileProps, PropertyProps } from "interfaces/common";
+import PropertyCard from "./PropertyCard";
+
+function checkImage(url: any) {
+ const img = new Image();
+ img.src = url;
+ return img.width !== 0 && img.height !== 0;
}
-export default Profile
\ No newline at end of file
+const Profile = ({ type, name, avatar, email, properties }: ProfileProps) => (
+
+
+ {type} Profile
+
+
+
+
+
+
+
+
+
+
+
+
+ {name}
+
+
+ Realestate Agent
+
+
+
+
+
+
+ Address
+
+
+
+
+ 4517 Washington Ave. Manchaster,
+ Kentucky 39495
+
+
+
+
+
+
+
+ Phone Number
+
+
+
+
+ +0123 456 7890
+
+
+
+
+
+
+ Email
+
+
+
+
+ {email}
+
+
+
+
+
+
+
+
+
+
+
+ {properties.length > 0 && (
+
+
+ {type} Properties
+
+
+
+ {properties?.map((property: PropertyProps) => (
+
+ ))}
+
+
+ )}
+
+);
+
+export default Profile;
\ No newline at end of file
diff --git a/client/src/pages/agent-profile.tsx b/client/src/pages/agent-profile.tsx
index 002052b..b55a16f 100644
--- a/client/src/pages/agent-profile.tsx
+++ b/client/src/pages/agent-profile.tsx
@@ -1,9 +1,32 @@
-import React from 'react'
+import { useOne } from "@pankod/refine-core";
+import { useParams } from "react-router-dom";
-const agentProfile = () => {
- return (
- agent-profile
- )
-}
+import { Profile } from "components";
-export default agentProfile
\ No newline at end of file
+const AgentProfile = () => {
+ const { id } = useParams();
+
+ const { data, isLoading, isError } = useOne({
+ resource: "users",
+ id: id as string,
+ });
+
+ console.log(data);
+
+ const myProfile = data?.data ?? [];
+
+ if (isLoading) return loading...
;
+ if (isError) return error...
;
+
+ return (
+
+ );
+};
+
+export default AgentProfile;
\ No newline at end of file
diff --git a/client/src/pages/agent.tsx b/client/src/pages/agent.tsx
index 4c7aec6..0d451fc 100644
--- a/client/src/pages/agent.tsx
+++ b/client/src/pages/agent.tsx
@@ -1,9 +1,40 @@
-import React from 'react'
-
-const agent = () => {
+import {useList} from '@pankod/refine-core'
+import {Box,Typography} from '@pankod/refine-mui'
+ import { AgentCard } from 'components'
+const Agents = () => {
+ const{data, isLoading,isError} =useList({
+ resource:'users' ,
+ });
+ const allAgents= data?.data??[];
+ if(isLoading) return Loading...
+ if(isError) return Error
return (
- agent
+
+
+ Agents List
+
+
+ {allAgents.map((agent)=>(
+
+ ))}
+
+
)
}
-export default agent
\ No newline at end of file
+export default Agents
\ No newline at end of file
diff --git a/client/src/pages/home.tsx b/client/src/pages/home.tsx
index c8fc1dd..c8b4248 100644
--- a/client/src/pages/home.tsx
+++ b/client/src/pages/home.tsx
@@ -11,6 +11,17 @@ import {
const Home = () => {
+ const {data,isLoading,isError} = useList({
+ resource:'properties',
+ config:{
+ pagination:{
+ pageSize:5
+ }
+ }
+ })
+ const latestProperties=data?.data??[];
+ if (isLoading) return loading..
+ if (isError) return Error
return (
@@ -47,7 +58,33 @@ const Home = () => {
+
+
+ Latest Properties
+
+
+ {latestProperties.map((property) =>(
+
+ ))}
+
+
)
}
diff --git a/client/src/pages/my-profile.tsx b/client/src/pages/my-profile.tsx
index 7ed4f6e..fd587e0 100644
--- a/client/src/pages/my-profile.tsx
+++ b/client/src/pages/my-profile.tsx
@@ -1,9 +1,27 @@
-import React from 'react'
+import { useGetIdentity,useOne } from "@pankod/refine-core"
+import {Profile} from 'components'
-const myProfile = () => {
+
+
+const MyProfile = () => {
+ const {data:user} =useGetIdentity();
+ const {data,isLoading,isError} = useOne({
+ resource:'users',
+ id:user?.userid,
+ })
+ const MyProfile=data?.data??[];
+ if(isLoading) return Loading..
+ if(isError) return Error
+
return (
- my-profile
+
)
}
-export default myProfile
\ No newline at end of file
+export default MyProfile
\ No newline at end of file
diff --git a/server/controllers/property.controller.js b/server/controllers/property.controller.js
index e10301e..704a843 100644
--- a/server/controllers/property.controller.js
+++ b/server/controllers/property.controller.js
@@ -123,8 +123,7 @@ const deleteProperty=async(req,res)=>{
if (!propertyToDelete) throw new Error("Property not found");
const session = await mongoose.startSession();
session.startTransaction();
-
- propertyToDelete.remove({ session });
+ await propertyToDelete.deleteOne({ session });
propertyToDelete.creator.allProperties.pull(propertyToDelete);
await propertyToDelete.creator.save({ session });
await session.commitTransaction();
diff --git a/server/controllers/user.controller.js b/server/controllers/user.controller.js
index 6298da8..49837dd 100644
--- a/server/controllers/user.controller.js
+++ b/server/controllers/user.controller.js
@@ -1,5 +1,12 @@
import User from '../mongodb/models/user.js'
-const getAllUsers=async(req,res) =>{};
+const getAllUsers=async(req,res) =>{
+ try {
+ const users =await User.find({}).limit(req.query._end);
+ res.status(200).json(users);
+ } catch (error) {
+ res.status(500).json({message:error.message})
+ }
+};
const createUser=async(req,res) =>{
try {
const{name,email,avatar}=req.body;
@@ -15,8 +22,13 @@ const createUser=async(req,res) =>{
res.status(500).json({message:error.message})
}
};
-const getUserInfoByID=async(req,res) =>{};
-
+const getUserInfoByID=async(req,res) =>{
+ const {id} =req.params;
+ const user=await User.findOne({_id:id}).populate('allProperties');
+ if (user){res.status(200).json(user);} else
+ {
+ res.status(404).json({message:'User not found'});}
+ }
export{
getAllUsers,
createUser,