This commit is contained in:
@ -159,6 +159,7 @@ function mapApiDetail(item) {
|
||||
const dailyPrice = item.dailyRent || 0;
|
||||
const monthlyPrice = item.monthlyRent || 0;
|
||||
const salePrice = item.price || 0;
|
||||
const commission = item.commission || 0;
|
||||
const price = isRent ? monthlyPrice || dailyPrice : salePrice;
|
||||
const priceUnit = isRent ? (monthlyPrice ? "monthly" : "daily") : "sale";
|
||||
|
||||
@ -244,7 +245,7 @@ function mapApiDetail(item) {
|
||||
};
|
||||
}
|
||||
|
||||
export default function PropertyDetailsPage({type}) {
|
||||
export default function PropertyDetailsPage({ type }) {
|
||||
const { t, i18n } = useTranslation();
|
||||
const params = useParams();
|
||||
|
||||
@ -272,7 +273,7 @@ export default function PropertyDetailsPage({type}) {
|
||||
|
||||
useEffect(() => {
|
||||
const id = params.id;
|
||||
|
||||
|
||||
if (!id) return;
|
||||
setLoading(true);
|
||||
|
||||
@ -280,7 +281,7 @@ export default function PropertyDetailsPage({type}) {
|
||||
try {
|
||||
let data = null;
|
||||
try {
|
||||
data = type==="rent"?await getRentProperty(id):(await getSalePropertyById(id)) || (await getSaleProperty(id));
|
||||
data = type === "rent" ? await getRentProperty(id) : (await getSalePropertyById(id)) || (await getSaleProperty(id));
|
||||
} catch {}
|
||||
if (!data) {
|
||||
try {
|
||||
@ -427,6 +428,7 @@ export default function PropertyDetailsPage({type}) {
|
||||
}
|
||||
setBookingLoading(true);
|
||||
setBookingError(null);
|
||||
|
||||
try {
|
||||
const propInfoId = property._raw?.propertyInformationId || property.id;
|
||||
const startDate = new Date(selectedStart + "T00:00:00.000").toISOString();
|
||||
@ -528,8 +530,8 @@ export default function PropertyDetailsPage({type}) {
|
||||
)}
|
||||
|
||||
<div className="absolute bottom-4 right-4 flex gap-2 z-10">
|
||||
<span className="bg-black/70 text-white px-3 py-1 rounded-full text-sm font-medium backdrop-blur-sm">{t("propertyStatus." + property.statusLabel)}</span>
|
||||
<span className="bg-black/70 text-white px-3 py-1 rounded-full text-sm font-medium backdrop-blur-sm">{t("buildingType." + property.typeLabel)}</span>
|
||||
<span className="bg-gray-100 text-black px-3 py-1 rounded-full text-sm font-medium backdrop-blur-sm">{t("propertyStatus." + property.statusLabel)}</span>
|
||||
<span className="bg-gray-100 text-black px-3 py-1 rounded-full text-sm font-medium backdrop-blur-sm">{t("buildingType." + property.typeLabel)}</span>
|
||||
</div>
|
||||
<div className="absolute bottom-4 left-4 bg-black/70 text-white px-3 py-1 rounded-full text-xs backdrop-blur-sm z-10">
|
||||
{currentImage + 1} / {property.images.length || 1}
|
||||
@ -607,13 +609,27 @@ export default function PropertyDetailsPage({type}) {
|
||||
<span className="font-medium">{t("depositLabel")}</span> {formatCurrency(property.deposit)} {t("syp")}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{property.details.commission > 0 && (
|
||||
<div className="text-sm text-gray-500">
|
||||
<span className="font-medium">{t("commission")}</span> {formatCurrency(property.details.commission)} {t("syp")}
|
||||
</div>
|
||||
)}
|
||||
|
||||
</div>
|
||||
) : (
|
||||
<div>
|
||||
<span className="text-2xl font-bold text-blue-600">{formatCurrency(property.price)}</span>
|
||||
<span className="text-gray-500 mr-1">{t("syp")}</span>
|
||||
<span className="text-sm text-gray-400 mr-2">{t("forSale")}</span>
|
||||
</div>
|
||||
<>
|
||||
<div>
|
||||
<span className="text-2xl font-bold text-blue-600">{formatCurrency(property.price)}</span>
|
||||
<span className="text-gray-500 mr-1">{t("syp")}</span>
|
||||
<span className="text-sm text-gray-400 mr-2">{t("forSale")}</span>
|
||||
</div>
|
||||
<div>
|
||||
<span className="text-2xl font-bold text-blue-600">{formatCurrency(property.details.commission)}</span>
|
||||
<span className="text-gray-500 mr-1">{t("syp")}</span>
|
||||
<span className="text-sm text-gray-400 mr-2">{t("commission")}</span>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@ -865,7 +881,7 @@ export default function PropertyDetailsPage({type}) {
|
||||
{key === "University" && <GraduationCap className="w-3.5 h-3.5 text-amber-500 flex-shrink-0" />}
|
||||
{key === "Park" && <TreePine className="w-3.5 h-3.5 text-amber-500 flex-shrink-0" />}
|
||||
{key === "Mall" && <Building className="w-3.5 h-3.5 text-amber-500 flex-shrink-0" />}
|
||||
{!["School", "Hospital", "Restaurant", "University", "Park", "Mall","Mosque"].includes(key) && <MapPin className="w-3.5 h-3.5 text-amber-500 flex-shrink-0" />}
|
||||
{!["School", "Hospital", "Restaurant", "University", "Park", "Mall", "Mosque"].includes(key) && <MapPin className="w-3.5 h-3.5 text-amber-500 flex-shrink-0" />}
|
||||
<div>
|
||||
<div className="text-xs font-medium text-gray-900">{t(proxKey(key))}</div>
|
||||
<div className="text-[10px] text-gray-500">
|
||||
@ -1049,7 +1065,6 @@ export default function PropertyDetailsPage({type}) {
|
||||
)}
|
||||
</motion.div>
|
||||
)}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -82,7 +82,7 @@ export async function generateMetadata({ params, searchParams }) {
|
||||
const { id } = await params;
|
||||
const { type } = await searchParams;
|
||||
|
||||
console.log("Property type:", type);
|
||||
|
||||
|
||||
const raw = await fetchPropertyForMeta(id, type);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user