diff --git a/app/blocked/page.js b/app/blocked/page.js index f2ac960..300318f 100644 --- a/app/blocked/page.js +++ b/app/blocked/page.js @@ -80,7 +80,7 @@ export default function BlockedPage() { @@ -220,45 +210,49 @@ const PropertyCard = ({ property, viewMode = 'grid', onLoginRequired }) => { {getPropertyTypeIcon(property.type)} {getPropertyTypeLabel(property.type)} - - {property.status === 'available' ? t('available', 'متاح') : t('booked', 'محجوز')} + + {property.status === "available" ? t("available", "متاح") : t("booked", "محجوز")}

{property.title}

- {t('city.' + property.location.city, property.location.city)}، {property.location.district} + {t("city." + property.location.city, property.location.city)}، {property.location.district}
{formatCurrency(property.price)}
-
/{property.priceUnit === 'daily' ? t('day', 'يوم') : t('month', 'شهر')}
+
/{property.priceUnit === "daily" ? t("day", "يوم") : t("month", "شهر")}
- {property.bedrooms} {t('rooms', 'غرف')} + + {property.bedrooms} {t("rooms", "غرف")} +
- {property.bathrooms} {t('bathrooms', 'حمامات')} + + {property.bathrooms} {t("bathrooms", "حمامات")} +
- {property.area} {t('sqm', 'م²')} + + {property.area} {t("sqm", "م²")} +

{property.description}

- - {t('viewDetails', 'عرض التفاصيل')} + // + + {t("viewDetails", "عرض التفاصيل")}
@@ -302,19 +291,19 @@ const PropertyCard = ({ property, viewMode = 'grid', onLoginRequired }) => { {getPropertyTypeIcon(property.type)} {getPropertyTypeLabel(property.type)}
- {property.status === 'available' && ( - {t('available', 'متاح')} - )} + {property.status === "available" && {t("available", "متاح")}}

{property.title}

- {t('city.' + property.location.city, property.location.city)}، {property.location.district} + + {t("city." + property.location.city, property.location.city)}، {property.location.district} +
{formatCurrency(property.price)}
-
/{property.priceUnit === 'daily' ? t('day', 'يوم') : t('month', 'شهر')}
+
/{property.priceUnit === "daily" ? t("day", "يوم") : t("month", "شهر")}
@@ -330,7 +319,10 @@ const PropertyCard = ({ property, viewMode = 'grid', onLoginRequired }) => {
- {property.area}{t('sqm', 'م²')} + + {property.area} + {t("sqm", "م²")} +
{property.rating > 0 && ( @@ -341,11 +333,8 @@ const PropertyCard = ({ property, viewMode = 'grid', onLoginRequired }) => { )} - - {t('viewDetails', 'عرض التفاصيل')} + + {t("viewDetails", "عرض التفاصيل")} @@ -357,57 +346,57 @@ const FilterBar = ({ filters, onFilterChange }) => { const [showFilters, setShowFilters] = useState(false); const propertyTypes = [ - { id: 'all', label: t('all', 'الكل') }, - { id: 'residential', label: t('propertyType.residential', 'سكني') }, - { id: 'commercial', label: t('propertyType.commercial', 'تجاري') }, - { id: 'agricultural', label: t('propertyType.agricultural', 'زراعي') }, + { id: "all", label: t("all", "الكل") }, + { id: "residential", label: t("propertyType.residential", "سكني") }, + { id: "commercial", label: t("propertyType.commercial", "تجاري") }, + { id: "agricultural", label: t("propertyType.agricultural", "زراعي") }, ]; const buildingTypes = [ - { id: 'all', label: t('all', 'الكل') }, - { id: 'apartment', label: t('buildingType.apartment', 'شقة'), icon: Building2 }, - { id: 'villa', label: t('buildingType.villa', 'فيلا'), icon: Home }, - { id: 'sweet', label: t('buildingType.sweet', 'جناح'), icon: Home }, - { id: 'room', label: t('buildingType.room', 'غرفة'), icon: Home }, - { id: 'studio', label: t('buildingType.studio', 'ستوديو'), icon: Building2 }, - { id: 'office', label: t('buildingType.office', 'مكتب'), icon: Building2 }, - { id: 'farms', label: t('buildingType.farms', 'مزرعة'), icon: Home }, - { id: 'shop', label: t('buildingType.shop', 'محل تجاري'), icon: Building2 }, - { id: 'warehouse', label: t('buildingType.warehouse', 'مستودع'), icon: Building2 } + { id: "all", label: t("all", "الكل") }, + { id: "apartment", label: t("buildingType.apartment", "شقة"), icon: Building2 }, + { id: "villa", label: t("buildingType.villa", "فيلا"), icon: Home }, + { id: "sweet", label: t("buildingType.sweet", "جناح"), icon: Home }, + { id: "room", label: t("buildingType.room", "غرفة"), icon: Home }, + { id: "studio", label: t("buildingType.studio", "ستوديو"), icon: Building2 }, + { id: "office", label: t("buildingType.office", "مكتب"), icon: Building2 }, + { id: "farms", label: t("buildingType.farms", "مزرعة"), icon: Home }, + { id: "shop", label: t("buildingType.shop", "محل تجاري"), icon: Building2 }, + { id: "warehouse", label: t("buildingType.warehouse", "مستودع"), icon: Building2 }, ]; const priceRanges = [ - { id: 'all', label: t('allPrices', 'جميع الأسعار') }, - { id: '0-500000', label: t('price-range-less-than-500k', 'أقل من 500 ألف') }, - { id: '500000-1000000', label: t('price-range-500k-to-1m', '500 ألف - 1 مليون') }, - { id: '1000000-2000000', label: t('price-range-1m-to-2m', '1 مليون - 2 مليون') }, - { id: '2000000-5000000', label: t('price-range-2m-to-5m', '2 مليون - 5 مليون') }, - { id: '5000000+', label: t('price-range-more-than-5m', 'أكثر من 5 مليون') } + { id: "all", label: t("allPrices", "جميع الأسعار") }, + { id: "0-500000", label: t("price-range-less-than-500k", "أقل من 500 ألف") }, + { id: "500000-1000000", label: t("price-range-500k-to-1m", "500 ألف - 1 مليون") }, + { id: "1000000-2000000", label: t("price-range-1m-to-2m", "1 مليون - 2 مليون") }, + { id: "2000000-5000000", label: t("price-range-2m-to-5m", "2 مليون - 5 مليون") }, + { id: "5000000+", label: t("price-range-more-than-5m", "أكثر من 5 مليون") }, ]; const cities = [ - { id: 'all', label: t('allCities', 'جميع المدن') }, - { id: 'damascus', label: t('city.damascus', 'دمشق') }, - { id: 'aleppo', label: t('city.aleppo', 'حلب') }, - { id: 'homs', label: t('city.homs', 'حمص') }, - { id: 'latakia', label: t('city.latakia', 'اللاذقية') }, - { id: 'daraa', label: t('city.daraa', 'درعا') }, - { id: 'tartous', label: t('city.tartous', 'طرطوس') }, - { id: 'suweida', label: t('city.suweida', 'السويداء') }, - { id: 'deirEzzor', label: t('city.deirEzzor', 'دير الزور') }, - { id: 'raqqa', label: t('city.raqqa', 'الرقة') }, - { id: 'idlib', label: t('city.idlib', 'إدلب') }, - { id: 'hasakah', label: t('city.hasakah', 'الحسكة') }, - { id: 'qamishli', label: t('city.qamishli', 'القامشلي') }, - { id: 'ruralDamascus', label: t('city.ruralDamascus', 'ريف دمشق') } + { id: "all", label: t("allCities", "جميع المدن") }, + { id: "damascus", label: t("city.damascus", "دمشق") }, + { id: "aleppo", label: t("city.aleppo", "حلب") }, + { id: "homs", label: t("city.homs", "حمص") }, + { id: "latakia", label: t("city.latakia", "اللاذقية") }, + { id: "daraa", label: t("city.daraa", "درعا") }, + { id: "tartous", label: t("city.tartous", "طرطوس") }, + { id: "suweida", label: t("city.suweida", "السويداء") }, + { id: "deirEzzor", label: t("city.deirEzzor", "دير الزور") }, + { id: "raqqa", label: t("city.raqqa", "الرقة") }, + { id: "idlib", label: t("city.idlib", "إدلب") }, + { id: "hasakah", label: t("city.hasakah", "الحسكة") }, + { id: "qamishli", label: t("city.qamishli", "القامشلي") }, + { id: "ruralDamascus", label: t("city.ruralDamascus", "ريف دمشق") }, ]; const certificates = [ - { id: 'all', label: t('allCertificates', 'جميع السندات') }, - { id: 'realEstateTitle', label: t('certificate.realEstateTitle', 'طابو أخضر') }, - { id: 'courtRuling', label: t('certificate.courtRuling', 'حكم محكمة') }, - { id: 'notary', label: t('certificate.notary', 'كاتب عدل') }, - { id: 'shares', label: t('certificate.shares', 'أسهم عقارية') } + { id: "all", label: t("allCertificates", "جميع السندات") }, + { id: "realEstateTitle", label: t("certificate.realEstateTitle", "طابو أخضر") }, + { id: "courtRuling", label: t("certificate.courtRuling", "حكم محكمة") }, + { id: "notary", label: t("certificate.notary", "كاتب عدل") }, + { id: "shares", label: t("certificate.shares", "أسهم عقارية") }, ]; return ( @@ -417,91 +406,91 @@ const FilterBar = ({ filters, onFilterChange }) => { onFilterChange({ ...filters, search: e.target.value })} /> - {showFilters && ( - +
- +
- +
- +
- +
- + onFilterChange({ ...filters, bathrooms: e.target.value })} - className="w-full px-4 py-2 border border-gray-200 rounded-xl focus:ring-2 focus:ring-gray-300 focus:border-gray-300 text-sm" + className="w-full px-4 py-2 border bg-[#1e293b] border-gray-200 rounded-xl focus:ring-2 focus:ring-gray-300 focus:border-gray-300 text-sm" > - + @@ -526,31 +515,33 @@ const FilterBar = ({ filters, onFilterChange }) => {
- +
- +
onFilterChange({ ...filters, minArea: e.target.value })} /> onFilterChange({ ...filters, maxArea: e.target.value })} @@ -561,28 +552,27 @@ const FilterBar = ({ filters, onFilterChange }) => {
-
@@ -594,24 +584,24 @@ const FilterBar = ({ filters, onFilterChange }) => { export default function PropertiesPage() { const { t, i18n } = useTranslation(); - const [purposeTab, setPurposeTab] = useState('rent'); - const [viewMode, setViewMode] = useState('grid'); - const [sortBy, setSortBy] = useState('newest'); + const [purposeTab, setPurposeTab] = useState("rent"); + const [viewMode, setViewMode] = useState("grid"); + const [sortBy, setSortBy] = useState("newest"); const [properties, setProperties] = useState([]); const [loading, setLoading] = useState(true); const [showLoginDialog, setShowLoginDialog] = useState(false); const [filters, setFilters] = useState({ - search: '', - propertyType: 'all', - buildingType: 'all', - city: 'all', - priceRange: 'all', - bedrooms: 'all', - bathrooms: 'all', - certificate: 'all', - minArea: '', - maxArea: '', - features: [] + search: "", + propertyType: "all", + buildingType: "all", + city: "all", + priceRange: "all", + bedrooms: "all", + bathrooms: "all", + certificate: "all", + minArea: "", + maxArea: "", + features: [], }); useEffect(() => { @@ -620,80 +610,79 @@ export default function PropertiesPage() { try { const queryParams = new URLSearchParams(); - if (filters.bedrooms !== 'all') { - queryParams.append('numberOfBedRooms', filters.bedrooms); + if (filters.bedrooms !== "all") { + queryParams.append("numberOfBedRooms", filters.bedrooms); } - if (filters.bathrooms !== 'all') { - queryParams.append('numberOfBathRooms', filters.bathrooms); + if (filters.bathrooms !== "all") { + queryParams.append("numberOfBathRooms", filters.bathrooms); } if (filters.minArea) { - queryParams.append('space', filters.minArea); + queryParams.append("space", filters.minArea); } - const buildingTypeReverseMap = { - 'apartment': 'Apartment', - 'villa': 'Villa', - 'sweet': 'Sweet', - 'room': 'Room', - 'studio': 'Studio', - 'office': 'Office', - 'farms': 'Farms', - 'shop': 'Shop', - 'warehouse': 'Warehouse' + const buildingTypeReverseMap = { + apartment: "Apartment", + villa: "Villa", + sweet: "Sweet", + room: "Room", + studio: "Studio", + office: "Office", + farms: "Farms", + shop: "Shop", + warehouse: "Warehouse", }; - if (filters.buildingType !== 'all' && buildingTypeReverseMap[filters.buildingType] !== undefined) { - queryParams.append('buildingType', buildingTypeReverseMap[filters.buildingType]); + if (filters.buildingType !== "all" && buildingTypeReverseMap[filters.buildingType] !== undefined) { + queryParams.append("buildingType", buildingTypeReverseMap[filters.buildingType]); } const propertyTypeReverseMap = { - 'residential': 'Residential', - 'commercial': 'Commercial', - 'agricultural': 'Agricultural' + residential: "Residential", + commercial: "Commercial", + agricultural: "Agricultural", }; - if (filters.propertyType !== 'all' && propertyTypeReverseMap[filters.propertyType] !== undefined) { - queryParams.append('propertyType', propertyTypeReverseMap[filters.propertyType]); + if (filters.propertyType !== "all" && propertyTypeReverseMap[filters.propertyType] !== undefined) { + queryParams.append("propertyType", propertyTypeReverseMap[filters.propertyType]); } const certificateReverseMap = { - 'realEstateTitle': 'RealEstateTitle', - 'courtRuling': 'CourtRuling', - 'notary': 'Notary', - 'shares': 'Shares' + realEstateTitle: "RealEstateTitle", + courtRuling: "CourtRuling", + notary: "Notary", + shares: "Shares", }; - if (filters.certificate !== 'all' && certificateReverseMap[filters.certificate] !== undefined) { - queryParams.append('certificate', certificateReverseMap[filters.certificate]); + if (filters.certificate !== "all" && certificateReverseMap[filters.certificate] !== undefined) { + queryParams.append("certificate", certificateReverseMap[filters.certificate]); } - if (filters.city !== 'all') { + if (filters.city !== "all") { const cityFormatted = filters.city.charAt(0).toUpperCase() + filters.city.slice(1); - queryParams.append('city', cityFormatted); + queryParams.append("city", cityFormatted); } - const baseUrl = process.env.NEXT_PUBLIC_API_URL || 'http://45.93.137.91/api'; + const baseUrl = process.env.NEXT_PUBLIC_API_URL || "http://45.93.137.91/api"; const rentEndpoint = `${baseUrl}/RentProperties/FilterRentProperties?${queryParams.toString()}`; const [rentRes, saleData] = await Promise.all([ fetch(rentEndpoint, { headers: { - 'Accept': 'application/json', - } - }).then(res => res.json()).catch(() => ({ data: [], isSuccess: false })), + Accept: "application/json", + }, + }) + .then((res) => res.json()) + .catch(() => ({ data: [], isSuccess: false })), getSaleProperties().catch(() => []), ]); const rentList = rentRes.isSuccess && Array.isArray(rentRes.data) ? rentRes.data : []; const saleList = Array.isArray(saleData) ? saleData : []; - const mapped = [ - ...rentList.map((p, i) => ({ ...mapApiProperty(t, p, i), purpose: 'rent' })), - ...saleList.map((p, i) => ({ ...mapApiProperty(t, p, rentList.length + i), purpose: 'sale' })), - ]; + const mapped = [...rentList.map((p, i) => ({ ...mapApiProperty(t, p, i), purpose: "rent" })), ...saleList.map((p, i) => ({ ...mapApiProperty(t, p, rentList.length + i), purpose: "sale" }))]; setProperties(mapped); } catch (err) { - console.error('[Properties] Failed to fetch properties:', err); + console.error("[Properties] Failed to fetch properties:", err); } finally { setLoading(false); } @@ -703,17 +692,17 @@ export default function PropertiesPage() { }, [filters, t]); const filteredProperties = properties - .filter(p => p.purpose === purposeTab) - .filter(property => { + .filter((p) => p.purpose === purposeTab) + .filter((property) => { if (filters.search && !property.title.includes(filters.search) && !property.description.includes(filters.search)) { return false; } - if (filters.priceRange !== 'all') { - const [min, max] = filters.priceRange.split('-'); + if (filters.priceRange !== "all") { + const [min, max] = filters.priceRange.split("-"); if (max) { if (property.price < parseInt(min) || property.price > parseInt(max)) return false; - } else if (filters.priceRange.endsWith('+')) { - const minVal = parseInt(filters.priceRange.replace('+', '')); + } else if (filters.priceRange.endsWith("+")) { + const minVal = parseInt(filters.priceRange.replace("+", "")); if (property.price < minVal) return false; } } @@ -721,33 +710,37 @@ export default function PropertiesPage() { }) .sort((a, b) => { switch (sortBy) { - case 'price_asc': return a.price - b.price; - case 'price_desc': return b.price - a.price; - case 'rating': return b.rating - a.rating; - default: return 0; + case "price_asc": + return a.price - b.price; + case "price_desc": + return b.price - a.price; + case "rating": + return b.rating - a.rating; + default: + return 0; } }); return ( -
+
- -

{purposeTab === 'rent' ? t('properties-for-rent', 'عقارات للإيجار') : t('properties-for-sale', 'عقارات للبيع')}

-

{t('best-properties-in-syria', 'أفضل العقارات المتاحة في سوريا مباشرة وبسهولة')}

+ +

{purposeTab === "rent" ? t("properties-for-rent", "عقارات للإيجار") : t("properties-for-sale", "عقارات للبيع")}

+

{t("best-properties-in-syria", "أفضل العقارات المتاحة في سوريا مباشرة وبسهولة")}

- -
@@ -762,29 +755,29 @@ export default function PropertiesPage() {
- {filteredProperties.length} {t('property-available', 'عقار متاح')} + {filteredProperties.length} {t("property-available", "عقار متاح")}
@@ -792,26 +785,19 @@ export default function PropertiesPage() {
-
+
{filteredProperties.map((property) => ( - setShowLoginDialog(true)} /> + setShowLoginDialog(true)} /> ))}
{!loading && filteredProperties.length === 0 && ( - +
-

{t('no-properties', 'لا يوجد نتائج تطابق بحثك')}

-

{t('try-changing-search-criteria', 'يرجى تجربة تعديل خيارات الفلترة والبحث')}

+

{t("no-properties", "لا يوجد نتائج تطابق بحثك")}

+

{t("try-changing-search-criteria", "يرجى تجربة تعديل خيارات الفلترة والبحث")}

)}
@@ -827,20 +813,14 @@ export default function PropertiesPage() {
-

{t('login-required-title', 'تسجيل الدخول مطلوب')}

-

{t('login-required-favorites-desc', 'يجب تسجيل الدخول لتتمكن من إضافة العقار للمفضلة')}

+

{t("login-required-title", "تسجيل الدخول مطلوب")}

+

{t("login-required-favorites-desc", "يجب تسجيل الدخول لتتمكن من إضافة العقار للمفضلة")}

- - - {t('login', 'دخول')} + + {t("login", "دخول")}
@@ -848,4 +828,4 @@ export default function PropertiesPage() { )}
); -} \ No newline at end of file +} diff --git a/app/property/[id]/PropertyDetail.js b/app/property/[id]/PropertyDetail.js index badc68e..b16d46b 100644 --- a/app/property/[id]/PropertyDetail.js +++ b/app/property/[id]/PropertyDetail.js @@ -5,7 +5,7 @@ import { useTranslation } from "react-i18next"; import { motion, AnimatePresence } from "framer-motion"; import toast, { Toaster } from "react-hot-toast"; import Link from "next/link"; -import { useParams, useRouter } from "next/navigation"; +import { useParams, useRouter, useSearchParams } from "next/navigation"; import { MapPin, Bed, @@ -244,9 +244,10 @@ function mapApiDetail(item) { }; } -export default function PropertyDetailsPage() { +export default function PropertyDetailsPage({type}) { const { t, i18n } = useTranslation(); const params = useParams(); + const router = useRouter(); const { isFavorite, addFavorite, removeFavorite } = useFavorites(); @@ -271,6 +272,7 @@ export default function PropertyDetailsPage() { useEffect(() => { const id = params.id; + if (!id) return; setLoading(true); @@ -278,7 +280,7 @@ export default function PropertyDetailsPage() { try { let data = null; try { - data = await getRentProperty(id); + data = type==="rent"?await getRentProperty(id):(await getSalePropertyById(id)) || (await getSaleProperty(id)); } catch {} if (!data) { try { diff --git a/app/property/[id]/page.js b/app/property/[id]/page.js index 6f20726..e1a76e3 100644 --- a/app/property/[id]/page.js +++ b/app/property/[id]/page.js @@ -1,15 +1,20 @@ import PropertyDetail from "./PropertyDetail"; -// Server-side API fetch for metadata (runs at request time on server) -async function fetchPropertyForMeta(id) { +async function fetchPropertyForMeta(id, type) { try { - const res = await fetch(`http://45.93.137.91/api/RentProperties/GetRentProperties`, { + const endpoint = type === "sale" ? "http://45.93.137.91/api/SaleProperties/GetSaleProperties" : "http://45.93.137.91/api/RentProperties/GetRentProperties"; + + const res = await fetch(endpoint, { next: { revalidate: 60 }, }); + if (!res.ok) return null; + const text = await res.text(); const json = JSON.parse(text); + const items = Array.isArray(json?.data) ? json.data : Array.isArray(json) ? json : []; + return items.find((p) => p.id == id) || items[0] || null; } catch { return null; @@ -18,7 +23,9 @@ async function fetchPropertyForMeta(id) { function mapProperty(item) { const info = item.propertyInformation || item.PropertyInformation || {}; + let details = {}; + if (typeof info.detailsJSON === "object" && info.detailsJSON) { details = info.detailsJSON; } else if (typeof info.DetailsJSON === "object" && info.DetailsJSON) { @@ -30,10 +37,25 @@ function mapProperty(item) { } const price = item.monthlyRent || item.MonthlyRent || item.dailyRent || item.DailyRent || 0; + const priceUnit = item.monthlyRent || item.MonthlyRent ? "monthly" : "daily"; + const buildingType = info.buildingType ?? info.BuildingType ?? 0; - const type = { 0: "apartment", 1: "villa", 2: "house" }[buildingType] || "apartment"; - const typeLabel = { 0: "apartment", 1: "villa", 2: "house" }[buildingType] || "apartment"; + + const type = + { + 0: "apartment", + 1: "villa", + 2: "house", + }[buildingType] || "apartment"; + + const typeLabel = + { + 0: "apartment", + 1: "villa", + 2: "house", + }[buildingType] || "apartment"; + const address = info.address || info.Address || ""; const bedrooms = info.numberOfBedRooms || info.NumberOfBedRooms || 0; const bathrooms = info.numberOfBathRooms || info.NumberOfBathRooms || 0; @@ -56,9 +78,13 @@ function mapProperty(item) { }; } -export async function generateMetadata({ params }) { +export async function generateMetadata({ params, searchParams }) { const { id } = await params; - const raw = await fetchPropertyForMeta(id); + const { type } = await searchParams; + + console.log("Property type:", type); + + const raw = await fetchPropertyForMeta(id, type); if (!raw) { return { @@ -68,11 +94,13 @@ export async function generateMetadata({ params }) { } const p = mapProperty(raw); - const priceStr = `${p.price.toLocaleString()} ل.س / ${p.priceUnit === "daily" ? "يوم" : "شهر"}`; - const propertyImage = p.image ? (p.image.startsWith("http") ? p.image : `http://45.93.137.91${p.image}`) : ""; - const logoUrl = `http://45.93.137.91/logo.png`; - // Use property image if available, otherwise logo + const priceStr = `${p.price.toLocaleString()} ل.س / ${p.priceUnit === "daily" ? "يوم" : "شهر"}`; + + const propertyImage = p.image ? (p.image.startsWith("http") ? p.image : `http://45.93.137.91${p.image}`) : ""; + + const logoUrl = "http://45.93.137.91/logo.png"; + const ogImages = propertyImage ? [ { url: propertyImage, width: 1200, height: 630 }, @@ -83,14 +111,16 @@ export async function generateMetadata({ params }) { return { title: `${p.title} - ${priceStr}`, description: p.description, + openGraph: { title: `${p.title} - ${priceStr}`, description: p.description, images: ogImages, - url: `http://45.93.137.91/property/${id}`, + url: `http://45.93.137.91/property/${id}?type=${type}`, type: "website", siteName: "SweetHome", }, + twitter: { card: "summary_large_image", title: `${p.title} - ${priceStr}`, @@ -100,6 +130,8 @@ export async function generateMetadata({ params }) { }; } -export default function PropertyPage({ params }) { - return ; +export default async function PropertyPage({ params, searchParams }) { + const { type } = await searchParams; + + return ; } diff --git a/app/utils/api.js b/app/utils/api.js index d27c44d..4a554ea 100644 --- a/app/utils/api.js +++ b/app/utils/api.js @@ -192,7 +192,7 @@ export async function getSaleProperties() { } export async function getSaleProperty(id) { - const items = await apiFetch("/SaleProperties/GetSaleProperties"); + const items = await apiFetch(`/SaleProperties/GetSalePropertyById/${id}`); if (!Array.isArray(items)) return items; return items.find((p) => p.id == id) || items[0]; } diff --git a/middleware.js b/middleware.js index 595504b..4af3cba 100644 --- a/middleware.js +++ b/middleware.js @@ -40,6 +40,7 @@ export function middleware(request) { return NextResponse.redirect(new URL("/", request.url)); } + if (isOwnerRoute && !isOwner) { return NextResponse.redirect(new URL("/", request.url)); }