From 2ff8ab53f29a3ffd404eeeab331df147d8fd57cc Mon Sep 17 00:00:00 2001 From: Bunthai Deng Date: Thu, 8 Feb 2024 09:22:53 -0600 Subject: [PATCH] prop --- frontend/src/pages/AddProperty.js | 55 ++-- frontend/src/pages/PropertyDetail.js | 11 +- frontend/src/pages/UpdateProperty.js | 416 +++++++++++++++++++++++++++ frontend/src/routes/Router.js | 2 + 4 files changed, 455 insertions(+), 29 deletions(-) create mode 100644 frontend/src/pages/UpdateProperty.js diff --git a/frontend/src/pages/AddProperty.js b/frontend/src/pages/AddProperty.js index c308c78..8be1d82 100644 --- a/frontend/src/pages/AddProperty.js +++ b/frontend/src/pages/AddProperty.js @@ -22,10 +22,29 @@ import { FaLocationDot } from "react-icons/fa6"; import { useNavigate } from "react-router-dom"; export const CATEGORY = ["House", "Apartment", "Condo","Land"]; -const LAND_TYPES = ["Residential", "Commercial", "Agricultural"]; -const HOUSE_TYPES = ["Single Family", "Multi Family", "Townhouse"]; -const APARTMENT_TYPES = ["Studio", "Loft", "Duplex"]; -const CONDO_TYPES = ["High Rise", "Low Rise", "Mid Rise"]; +export const LAND_TYPES = ["Residential", "Commercial", "Agricultural"]; +export const HOUSE_TYPES = ["Single Family", "Multi Family", "Townhouse"]; +export const APARTMENT_TYPES = ["Studio", "Loft", "Duplex"]; +export const CONDO_TYPES = ["High Rise", "Low Rise", "Mid Rise"]; +export const handleChangePropertyType = (type, setPropertyType) => { + switch (type) { + case "House": + setPropertyType(HOUSE_TYPES); + break; + case "Apartment": + setPropertyType(APARTMENT_TYPES); + break; + case "Condo": + setPropertyType(CONDO_TYPES); + break; + case "Land": + setPropertyType(LAND_TYPES); + break; + default: + setPropertyType(HOUSE_TYPES); + break; + } +}; const AddProperty = () => { const [propertyType, setPropertyType] = React.useState(HOUSE_TYPES); @@ -34,25 +53,7 @@ const AddProperty = () => { const [imageKeys, setImageKeys] = React.useState([]); const [latLong, setLatLong] = React.useState(null); const navigate = useNavigate(); - const handleChangePropertyType = (type) => { - switch (type) { - case "House": - setPropertyType(HOUSE_TYPES); - break; - case "Apartment": - setPropertyType(APARTMENT_TYPES); - break; - case "Condo": - setPropertyType(CONDO_TYPES); - break; - case "Land": - setPropertyType(LAND_TYPES); - break; - default: - setPropertyType(HOUSE_TYPES); - break; - } - }; + const PropertySchema = z.object({ type: z.string(), title: z.string().min(3).max(150), @@ -226,7 +227,7 @@ const AddProperty = () => { category + + + + + + Title + + handleChangeProperty(e) + } + /> + + {errors.title?.message} + + + + Number of Rooms + + handleChangeProperty(e) + } + /> + + {errors.numberOfRoom?.message} + + + + + Price + + + handleChangeProperty(e) + } + /> + + + {type === "Rent" + ? "$ / month" + : "$"} + + + + {errors.price?.message} + + + + + + Description + + + {errors.description?.message} + + + + + + + + category + + + {errors.category?.message} + + + + + + {category} Type + + + {errors.subCategory?.message} + + + + + + + location + + + {errors.location?.message} + + + + Image + + handleUploadImage(e.target.files) + } + /> + + + {imageArr?.map((img, index) => { + return ( + + +

{img.name}

+ + + ); + })} +
+ + + {/* */} + + +
+ + + + + + ); +} + +export default UpdateProperty; diff --git a/frontend/src/routes/Router.js b/frontend/src/routes/Router.js index 3cf4724..048b768 100644 --- a/frontend/src/routes/Router.js +++ b/frontend/src/routes/Router.js @@ -20,6 +20,7 @@ import MyOffer from "../pages/MyOffer"; import Contact from "../pages/Contact"; import About from "../pages/About"; import PricacyPilicy from "../pages/PricacyPilicy"; +import UpdateProperty from "../pages/UpdateProperty"; const Router = () => { return ( @@ -29,6 +30,7 @@ const Router = () => { } /> } /> } /> + } /> } /> } /> } />