diff --git a/app/components/BottomNav.js b/app/components/BottomNav.js index fbb16aa..f16abe0 100644 --- a/app/components/BottomNav.js +++ b/app/components/BottomNav.js @@ -5,8 +5,6 @@ import { usePathname } from "next/navigation"; import { Home, Building2, Building, CalendarCheck, CalendarDays, ClipboardList, CreditCard, BookOpenCheck } from "lucide-react"; import React, { useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; -import { label } from "framer-motion/client"; - export default function BottomNav({ isOwner, isOwnerOrAgent }) { const { t } = useTranslation(); const pathname = usePathname(); @@ -52,7 +50,13 @@ export default function BottomNav({ isOwner, isOwnerOrAgent }) { pointer-events-auto " > -
+
{items.map((it) => { const Icon = it.icon; const active = isActive(it.href); diff --git a/app/components/LoginComponent/OtpComponent.js b/app/components/LoginComponent/OtpComponent.js index e233033..67e13ba 100644 --- a/app/components/LoginComponent/OtpComponent.js +++ b/app/components/LoginComponent/OtpComponent.js @@ -28,8 +28,6 @@ export default function OtpComponent({ isLoading, setIsLoading, isSuccess, setIs if (result?.ok) { try { await AuthService.cacheCurrentUser(getOwnerByUserId, getCustomerByUserId); - console.log("Decoded:", AuthService.decodeToken()); - console.log("User:", AuthService.getUser()); } catch (err) { console.warn("Failed to cache user", err); } diff --git a/app/i18n/config.js b/app/i18n/config.js index 240ebb0..d274666 100644 --- a/app/i18n/config.js +++ b/app/i18n/config.js @@ -6,7 +6,6 @@ const resources = { en: { translation: { /*Block*/ - subject: "Subject", "blocked.fillAllFields": "Please fill in all required fields", "blocked.reportSent": "Message sent successfully", @@ -1661,13 +1660,15 @@ const resources = { "calendar.mockTenant2": "Sara Ahmed", "calendar.mockTenant3": "Mohammed Ali", "loading":"Loading", - "neaebymosque":"Distance to nearest mosque (km)" + "neaebymosque":"Distance to nearest mosque (km)", + "commission":"Commission", }, }, ar: { translation: { "loading":"جار التحميل", "neaebymosque":"المسافة الى اقرب جامع", + "commission":"كمسيون", /* Block*/ "blocked.fillAllFields": "يرجى تعبئة جميع الحقول المطلوبة", "blocked.reportSent": "تم إرسال الرسالة بنجاح", diff --git a/app/loading.js b/app/loading.js index 4a0348a..4f31915 100644 --- a/app/loading.js +++ b/app/loading.js @@ -6,8 +6,8 @@ import { useTranslation } from "react-i18next"; export default function Loading() { const { t } = useTranslation(); return ( -
- +
+ - +
- Sweet Home + Sweet Home

- ... {t("loading")} + {t("loading")}

diff --git a/app/owner/properties/add/page.js b/app/owner/properties/add/page.js index 93852ec..d059f9c 100644 --- a/app/owner/properties/add/page.js +++ b/app/owner/properties/add/page.js @@ -123,6 +123,7 @@ export default function AddPropertyPage() { dailyPrice: "", monthlyPrice: "", deposit: "", + commission: "", allowedPaymentPeriod: "", city: Governorate.DAMASCUS, @@ -562,6 +563,7 @@ export default function AddPropertyPage() { } else if (formData.offerType === "both") { if (!formData.dailyPrice) newErrors.dailyPrice = t("addProperty.dailyPriceRequired"); if (!formData.monthlyPrice) newErrors.monthlyPrice = t("addProperty.monthlyPriceRequired"); + } } break; @@ -681,6 +683,7 @@ export default function AddPropertyPage() { const isRent = purpose === "rent"; const details = { description: formData.description || "", + commission: parseFloat(formData.commission) || 0, services: selectedServices, serviceDetails: selectedServices.reduce((acc, s) => ({ ...acc, [s]: formData.serviceDetails[s] || "in general" }), {}), propertyCondition: formData.furnished ? "WithFurniture" : "WithoutFurniture", @@ -753,9 +756,9 @@ export default function AddPropertyPage() { price: parseFloat(formData.salePrice), deposit: parseFloat(formData.deposit) || 0, }; - console.log("ff", payload); + const res = await addSaleProperty(payload); - console.log(res); + toast.success(t("toast.salePropertySuccess")); } else { const rentTypeMap = { daily: RentType.DAILY, monthly: RentType.MONTHLY, both: RentType.MONTHLY }; @@ -773,7 +776,9 @@ export default function AddPropertyPage() { type: formData.furnished ? RentPropertyType.FURNISHED : RentPropertyType.UNFURNISHED, allowedPaymentPeriod: formData.allowedPaymentPeriod || "1.00:00:00", }); + const res = await addRentProperty(payload); + toast.success(t("toast.rentPropertySuccess")); } setTimeout(() => { @@ -1221,7 +1226,7 @@ export default function AddPropertyPage() { {step === 3 && purpose === "sale" && (
-
+

{t("addProperty.salePriceTitle")}

@@ -1251,6 +1256,33 @@ export default function AddPropertyPage() { placeholder={t("addProperty.salePricePlaceholder")} />
+ +
+ +
+ {currencySymbol} + { + const val = e.target.value; + + if (val === "" || parseFloat(val) >= 0) { + setFormData({ ...formData, commission: val }); + } + (formData.commission); + }} + onKeyDown={(e) => { + if (["-", "e", "E", "+"].includes(e.key)) e.preventDefault(); + }} + className="w-full pr-12 pl-4 py-3 border border-gray-300 rounded-xl focus:outline-none focus:ring-2 focus:ring-amber-500" + placeholder={t("addProperty.depositPlaceholder")} + /> +
+
{errors.salePrice &&

{errors.salePrice}

}
@@ -1378,6 +1410,33 @@ export default function AddPropertyPage() { placeholder={t("addProperty.depositPlaceholder")} />
+ + {/* كمسيون */} +
+ +
+ {currencySymbol} + { + const val = e.target.value; + if (val === "" || parseFloat(val) >= 0) { + setFormData({ ...formData, commission: val }); + } + + }} + onKeyDown={(e) => { + if (["-", "e", "E", "+"].includes(e.key)) e.preventDefault(); + }} + className="w-full pr-12 pl-4 py-3 border border-gray-300 rounded-xl focus:outline-none focus:ring-2 focus:ring-amber-500" + placeholder={t("addProperty.depositPlaceholder")} + /> +
+
)} @@ -1433,6 +1492,30 @@ export default function AddPropertyPage() { />
+
+ +
+ {currencySymbol} + { + const val = e.target.value; + if (val === "" || parseFloat(val) >= 0) { + setFormData({ ...formData, commission: val }); + } + }} + onKeyDown={(e) => { + if (["-", "e", "E", "+"].includes(e.key)) e.preventDefault(); + }} + className="w-full pr-12 pl-4 py-3 border border-gray-300 rounded-xl focus:outline-none focus:ring-2 focus:ring-amber-500" + placeholder={t("addProperty.depositPlaceholder")} + /> +
+
)} @@ -1512,6 +1595,30 @@ export default function AddPropertyPage() { /> +
+ +
+ {currencySymbol} + { + const val = e.target.value; + if (val === "" || parseFloat(val) >= 0) { + setFormData({ ...formData, commission: val }); + } + }} + onKeyDown={(e) => { + if (["-", "e", "E", "+"].includes(e.key)) e.preventDefault(); + }} + className="w-full pr-12 pl-4 py-3 border border-gray-300 rounded-xl focus:outline-none focus:ring-2 focus:ring-amber-500" + placeholder={t("addProperty.depositPlaceholder")} + /> +
+
)} diff --git a/app/properties/page.js b/app/properties/page.js index 385be80..4a7f9fa 100644 --- a/app/properties/page.js +++ b/app/properties/page.js @@ -111,7 +111,6 @@ const PropertyCard = ({ property, viewMode = "grid", onLoginRequired, type = "re const [favLoading, setFavLoading] = useState(false); const [currentImage, setCurrentImage] = useState(0); const isFav = checkFavorite(property.id); - const toggleFavorite = async (e) => { e.preventDefault(); e.stopPropagation(); diff --git a/app/property/[id]/PropertyDetail.js b/app/property/[id]/PropertyDetail.js index b16d46b..484d222 100644 --- a/app/property/[id]/PropertyDetail.js +++ b/app/property/[id]/PropertyDetail.js @@ -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}) { )}
- {t("propertyStatus." + property.statusLabel)} - {t("buildingType." + property.typeLabel)} + {t("propertyStatus." + property.statusLabel)} + {t("buildingType." + property.typeLabel)}
{currentImage + 1} / {property.images.length || 1} @@ -607,13 +609,27 @@ export default function PropertyDetailsPage({type}) { {t("depositLabel")} {formatCurrency(property.deposit)} {t("syp")}
)} + + {property.details.commission > 0 && ( +
+ {t("commission")} {formatCurrency(property.details.commission)} {t("syp")} +
+ )} + ) : ( -
- {formatCurrency(property.price)} - {t("syp")} - {t("forSale")} -
+ <> +
+ {formatCurrency(property.price)} + {t("syp")} + {t("forSale")} +
+
+ {formatCurrency(property.details.commission)} + {t("syp")} + {t("commission")} +
+ )} @@ -865,7 +881,7 @@ export default function PropertyDetailsPage({type}) { {key === "University" && } {key === "Park" && } {key === "Mall" && } - {!["School", "Hospital", "Restaurant", "University", "Park", "Mall","Mosque"].includes(key) && } + {!["School", "Hospital", "Restaurant", "University", "Park", "Mall", "Mosque"].includes(key) && }
{t(proxKey(key))}
@@ -1049,7 +1065,6 @@ export default function PropertyDetailsPage({type}) { )} )} -
diff --git a/app/property/[id]/page.js b/app/property/[id]/page.js index e1a76e3..351a3a3 100644 --- a/app/property/[id]/page.js +++ b/app/property/[id]/page.js @@ -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); diff --git a/app/register/tenant/page.js b/app/register/tenant/page.js index 57fe530..f4bdfd6 100644 --- a/app/register/tenant/page.js +++ b/app/register/tenant/page.js @@ -68,7 +68,6 @@ export default function TenantRegisterPage() { }; try { const res = await addCustomer(payload, null, null); - console.log(res); if (res.status === 200 || res.ok) { const apiMessage = res.message || res.data?.message || res.data[0]?.message; toast.success(apiMessage || t("register.accountCreated"), { duration: 4000 });