Fix registration 415: send multipart form data with ID images
All checks were successful
Build frontend / build (push) Successful in 1m10s

- addCustomer/addOwner now use FormData with multipart upload
- Front and back ID images appended as FrontIdCarImage/RearIdCarImage
- Registration pages pass idImages.front and idImages.back to API
- Field names mapped to PascalCase for .NET API (FullName, Email, etc.)
This commit is contained in:
Claw AI
2026-03-28 15:15:09 +00:00
parent c2235cf575
commit 2424da2d45
4 changed files with 96 additions and 31 deletions

View File

@ -184,24 +184,45 @@ export default function ClientLayout({ children }) {
<div
className={`flex items-center space-x-1 ${currentLanguage === "ar" ? "flex-row-reverse space-x-reverse" : ""}`}
>
<Link
href="/files/SweetHome.apk"
className="group flex items-center gap-2 text-gray-700 hover:text-green-600 transition-colors"
>
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
fill="currentColor"
className="bi bi-android"
viewBox="0 0 16 16"
>
<path d="M2.76 3.061a.5.5 0 0 1 .679.2l1.283 2.352A8.9 8.9 0 0 1 8 5a8.9 8.9 0 0 1 3.278.613l1.283-2.352a.5.5 0 1 1 .878.478l-1.252 2.295C14.475 7.266 16 9.477 16 12H0c0-2.523 1.525-4.734 3.813-5.966L2.56 3.74a.5.5 0 0 1 .2-.678ZM5 10a1 1 0 1 0 0-2 1 1 0 0 0 0 2m6 0a1 1 0 1 0 0-2 1 1 0 0 0 0 2" />
</svg>
<span className="text-green-600 text-sm font-semibold opacity-0 max-w-0 overflow-hidden whitespace-nowrap group-hover:opacity-100 group-hover:max-w-xs transition-all duration-300">
حمل التطببيق الان
</span>
</Link>
{/* Download App Dropdown */}
<div className="relative group">
<button className="flex items-center gap-2 px-3 py-2 text-gray-700 hover:text-amber-600 hover:bg-amber-50 rounded-lg transition-all">
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor" viewBox="0 0 16 16">
<path d="M11 2a3 3 0 0 0-3 3v6.5a.5.5 0 0 0 1 0V5a2 2 0 1 1 4 0v6.5a.5.5 0 0 0 1 0V5a3 3 0 0 0-3-3z"/>
<path d="M1.5 12.5A1.5 1.5 0 0 0 3 14h10a1.5 1.5 0 0 0 0-3H3a1.5 1.5 0 0 0-1.5 1.5z"/>
</svg>
<span className="text-sm font-semibold">تحميل التطبيق</span>
<svg className="w-4 h-4 transition-transform group-hover:rotate-180" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M19 9l-7 7-7-7"/></svg>
</button>
<div className="absolute right-0 mt-2 w-64 bg-white rounded-xl shadow-xl border border-gray-200 overflow-hidden z-50 opacity-0 invisible group-hover:opacity-100 group-hover:visible transition-all duration-200 translate-y-2 group-hover:translate-y-0">
<div className="p-2">
<a href="/files/SweetHome.apk" download
className="flex items-center gap-3 px-4 py-3 rounded-lg hover:bg-green-50 transition-colors">
<div className="w-10 h-10 bg-green-100 rounded-lg flex items-center justify-center">
<svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" fill="#16a34a" viewBox="0 0 16 16">
<path d="M2.76 3.061a.5.5 0 0 1 .679.2l1.283 2.352A8.9 8.9 0 0 1 8 5a8.9 8.9 0 0 1 3.278.613l1.283-2.352a.5.5 0 1 1 .878.478l-1.252 2.295C14.475 7.266 16 9.477 16 12H0c0-2.523 1.525-4.734 3.813-5.966L2.56 3.74a.5.5 0 0 1 .2-.678ZM5 10a1 1 0 1 0 0-2 1 1 0 0 0 0 2m6 0a1 1 0 1 0 0-2 1 1 0 0 0 0 2"/>
</svg>
</div>
<div>
<p className="font-semibold text-gray-900 text-sm">Android</p>
<p className="text-xs text-green-600">تحميل APK</p>
</div>
</a>
<div className="flex items-center gap-3 px-4 py-3 rounded-lg opacity-50 cursor-not-allowed">
<div className="w-10 h-10 bg-gray-100 rounded-lg flex items-center justify-center">
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="#6b7280" viewBox="0 0 16 16">
<path d="M11.182.008C11.148-.03 9.923.023 8.857 1.18c-1.066 1.156-.902 2.482-.878 2.516.024.034 1.52.087 2.475-1.258.955-1.345.762-2.391.728-2.43Zm3.314 11.733c-.048-.096-2.325-1.234-2.113-3.422.212-2.189 1.675-2.789 1.698-2.854.023-.065-.597-.79-1.254-1.157a3.692 3.692 0 0 0-1.563-.434c-.108-.003-.483-.095-1.254.116-.508.139-1.653.589-1.968.607-.316.018-1.256-.522-2.267-.665-.647-.125-1.333.131-1.824.328-.49.196-1.422.754-2.074 2.237-.652 1.482-.311 3.83-.067 4.56.244.729.625 1.924 1.273 2.796.576.984 1.34 1.667 1.659 1.899.319.232 1.219.385 1.843.067.502-.308 1.408-.485 1.766-.472.357.013 1.061.154 1.782.539.571.197 1.111.115 1.652-.105.541-.221 1.324-1.059 2.238-2.758.347-.79.505-1.217.473-1.282Z"/>
</svg>
</div>
<div>
<p className="font-semibold text-gray-400 text-sm">iOS</p>
<p className="text-xs text-gray-400">قريباً</p>
</div>
</div>
</div>
</div>
</div>
<NavLink href="/">الرئيسية</NavLink>
<NavLink href="/properties">عقاراتنا</NavLink>

View File

@ -132,7 +132,7 @@ export default function OwnerRegisterPage() {
};
try {
const res = await addOwner(payload);
const res = await addOwner(payload, idImages.front, idImages.back);
console.log('[OwnerRegister] addOwner response:', res);
if (res.status === 200 || res.ok) {

View File

@ -128,7 +128,7 @@ export default function TenantRegisterPage() {
};
try {
const res = await addCustomer(payload);
const res = await addCustomer(payload, idImages.front, idImages.back);
console.log('[CustomerRegister] addCustomer response:', res);
if (res.status === 200 || res.ok) {

View File

@ -160,19 +160,63 @@ export async function getTerms() {
* @param {Object} data — { name, email, phoneNumber, whatsAppNumber, password, ownerType }
* @returns {Promise<{status, data, ok, message}>}
*/
export async function addOwner(data) {
console.log('[Auth] Registering owner:', data.email);
return authFetch('/Owner/Add', data);
// Multipart form-data fetch for file uploads
async function multipartAuthFetch(endpoint, formData) {
console.log('[Auth] Multipart request:', `${API_BASE}${endpoint}`);
const res = await fetch(`${API_BASE}${endpoint}`, {
method: 'POST',
// Don't set Content-Type — browser sets it with boundary
body: formData,
});
console.log('[Auth] Response status:', res.status, endpoint);
const text = await res.text();
let data = null;
try {
data = text ? JSON.parse(text) : null;
if (data && typeof data === 'object' && 'data' in data) {
data = data.data;
}
} catch {
data = text;
}
return { status: res.status, data, ok: res.ok || res.status === 206, message: data?.message };
}
/**
* Register a new customer/tenant
* @param {Object} data — { name, email, phoneNumber, password, customerType }
* @returns {Promise<{status, data, ok, message}>}
*/
export async function addCustomer(data) {
console.log('[Auth] Registering customer:', data.email);
return authFetch('/Customer/Add', data);
export async function addOwner(data, frontImage = null, backImage = null) {
console.log('[Auth] Registering owner (multipart):', data.email);
const formData = new FormData();
formData.append('FullName', data.name || data.FullName || '');
formData.append('Email', data.email || '');
formData.append('PhoneNumber', data.phoneNumber || '');
formData.append('WhatsAppNumber', data.whatsAppNumber || '');
formData.append('Password', data.password || '');
formData.append('Type', String(data.ownerType ?? data.Type ?? 0));
if (frontImage) formData.append('FrontIdCarImage', frontImage);
if (backImage) formData.append('RearIdCarImage', backImage);
return multipartAuthFetch('/Owner/Add', formData);
}
export async function addCustomer(data, frontImage = null, backImage = null) {
console.log('[Auth] Registering customer (multipart):', data.email);
const formData = new FormData();
formData.append('FullName', data.name || data.FullName || '');
formData.append('Email', data.email || '');
formData.append('PhoneNumber', data.phoneNumber || '');
formData.append('Password', data.password || '');
formData.append('Type', String(data.customerType ?? data.Type ?? 0));
if (frontImage) formData.append('FrontIdCarImage', frontImage);
if (backImage) formData.append('RearIdCarImage', backImage);
return multipartAuthFetch('/Customer/Add', formData);
}
// ─── Auth: Login ───