fixd larg lines in HomePage , add cookies rather than localStorage,make canvas background Login page

This commit is contained in:
hamzaobed7
2026-08-04 12:51:47 +03:00
parent 4ebb75ddd9
commit 7973c15e3f
51 changed files with 1460 additions and 2563 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,14 +0,0 @@
'use client';
import { motion } from 'framer-motion';
export default function Loading() {
return (
<div className="min-h-screen bg-gray-50 flex items-center justify-center">
<motion.div initial={{ opacity: 0 }} animate={{ opacity: 1 }} className="text-center">
<div className="w-14 h-14 border-4 border-amber-500 border-t-transparent rounded-full animate-spin mx-auto mb-4" />
<p className="text-gray-500 text-lg">جاري التحميل...</p>
</motion.div>
</div>
);
}

View File

@ -1,4 +1,4 @@
import PropertyDetail from './PropertyDetail';
import PropertyDetail from "./PropertyDetail";
// Server-side API fetch for metadata (runs at request time on server)
async function fetchPropertyForMeta(id) {
@ -10,7 +10,7 @@ async function fetchPropertyForMeta(id) {
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;
return items.find((p) => p.id == id) || items[0] || null;
} catch {
return null;
}
@ -19,26 +19,28 @@ async function fetchPropertyForMeta(id) {
function mapProperty(item) {
const info = item.propertyInformation || item.PropertyInformation || {};
let details = {};
if (typeof info.detailsJSON === 'object' && info.detailsJSON) {
if (typeof info.detailsJSON === "object" && info.detailsJSON) {
details = info.detailsJSON;
} else if (typeof info.DetailsJSON === 'object' && info.DetailsJSON) {
} else if (typeof info.DetailsJSON === "object" && info.DetailsJSON) {
details = info.DetailsJSON;
} else {
try { details = JSON.parse(info.detailsJSON || info.DetailsJSON || '{}'); } catch {}
try {
details = JSON.parse(info.detailsJSON || info.DetailsJSON || "{}");
} catch {}
}
const price = item.monthlyRent || item.MonthlyRent || item.dailyRent || item.DailyRent || 0;
const priceUnit = item.monthlyRent || item.MonthlyRent ? 'monthly' : 'daily';
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 address = info.address || info.Address || '';
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;
const area = info.space || info.Space || 0;
const desc = info.description || info.Description || '';
const desc = info.description || info.Description || "";
const images = info.images || info.Images || [];
const firstImage = Array.isArray(images) && images[0] ? images[0] : '';
const firstImage = Array.isArray(images) && images[0] ? images[0] : "";
return {
title: `${typeLabel} في ${address}`,
@ -60,21 +62,22 @@ export async function generateMetadata({ params }) {
if (!raw) {
return {
title: 'SweetHome - عقار',
description: 'اكتشف أفضل العقارات للإيجار',
title: "SweetHome - عقار",
description: "اكتشف أفضل العقارات للإيجار",
};
}
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 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 ogImages = propertyImage
? [{ url: propertyImage, width: 1200, height: 630 }, { url: logoUrl, width: 512, height: 512 }]
? [
{ url: propertyImage, width: 1200, height: 630 },
{ url: logoUrl, width: 512, height: 512 },
]
: [{ url: logoUrl, width: 512, height: 512 }];
return {
@ -85,14 +88,14 @@ export async function generateMetadata({ params }) {
description: p.description,
images: ogImages,
url: `http://45.93.137.91/property/${id}`,
type: 'website',
siteName: 'SweetHome',
type: "website",
siteName: "SweetHome",
},
twitter: {
card: 'summary_large_image',
card: "summary_large_image",
title: `${p.title} - ${priceStr}`,
description: p.description,
images: ogImages.map(i => i.url),
images: ogImages.map((i) => i.url),
},
};
}