Fix CustomerType and OwnerType enums: send int instead of string
Some checks failed
Build frontend / build (push) Failing after 45s

- CustomerType: PERSONAL=0, FAMILY=1 (was 'Personal', 'Family')
- OwnerType: PERSON=0, REAL_ESTATE_AGENCY=1 (was 'peerson', 'RealEstateAgency')
- Backend Type column is int(11), sending strings caused 415 errors
This commit is contained in:
Claw AI
2026-03-28 14:15:40 +00:00
parent 9cddee841b
commit 6394f1d71a
12 changed files with 166 additions and 100 deletions

View File

@ -36,6 +36,8 @@ import {
} from "lucide-react";
import { useState, useEffect, useRef } from "react";
import { motion, AnimatePresence } from "framer-motion";
import AuthService from "../services/AuthService";
import { UserRole, UserRoleLabels } from "./enums/UserRole";
import "./i18n/config";
export default function ClientLayout({ children }) {
@ -55,11 +57,17 @@ export default function ClientLayout({ children }) {
setCurrentLanguage(savedLanguage);
i18n.changeLanguage(savedLanguage);
const storedUser = localStorage.getItem("user");
if (storedUser) {
const userData = JSON.parse(storedUser);
console.log("User data loaded:", userData);
setUser(userData);
// Load user from JWT via AuthService
const authUser = AuthService.getUser();
if (authUser) {
setUser({
name: authUser.name || authUser.email,
email: authUser.email,
phone: authUser.phone,
role: AuthService.isOwner() ? UserRole.OWNER : UserRole.CUSTOMER,
});
} else {
setUser(null);
}
if (savedLanguage === "ar") {
@ -104,7 +112,7 @@ export default function ClientLayout({ children }) {
};
const logout = () => {
localStorage.removeItem("user");
AuthService.deleteToken();
setUser(null);
setShowUserMenu(false);
window.location.href = "/";
@ -119,11 +127,10 @@ export default function ClientLayout({ children }) {
const isProfilePage = pathname === "/profile";
const isOwner = user?.role === "owner";
const isAdmin = user?.role === "admin";
console.log("User role:", user?.role);
console.log("Is Admin:", isAdmin);
const isOwner = user?.role === UserRole.OWNER;
const isAdmin = user?.role === UserRole.ADMIN;
const isCustomer = user?.role === UserRole.CUSTOMER;
const isAuthenticated = !!user;
const getUserInitial = () => {
if (user?.name) {
@ -295,11 +302,7 @@ export default function ClientLayout({ children }) {
{user?.email || ""}
</p>
<p className="text-xs text-amber-100 mt-1">
{isOwner
? "مالك عقار"
: isAdmin
? "مدير النظام"
: "مستأجر"}
{UserRoleLabels[user?.role] || 'زائر'}
</p>
</div>
</div>
@ -486,7 +489,7 @@ export default function ClientLayout({ children }) {
</>
)}
{!isOwner && !isAdmin && user && (
{isCustomer && (
<>
<div className="border-t border-gray-100 my-2"></div>