fixed owner and customer register make reuseable component and completed it

This commit is contained in:
hamzaobed7
2026-08-05 23:27:34 +03:00
parent 7973c15e3f
commit 7da4bf9f2b
35 changed files with 1815 additions and 1510 deletions

View File

@ -1,6 +1,4 @@
import { Toast } from "flowbite-react";
import AuthService from "../services/AuthService";
const API_BASE = process.env.NEXT_PUBLIC_API_URL || "https://45.93.137.91.nip.io/api";
const REPORT_API_BASE = process.env.NEXT_PUBLIC_REPORT_API_URL || "http://45.93.137.91/api";
@ -82,7 +80,6 @@ async function apiFetch(endpoint, options = {}) {
}
} catch (error) {
if (error instanceof TypeError && error.message === "Failed to fetch") {
throw new Error(`تعذر الاتصال بالخادم. تحقق من اتصالك بالإنترنت أو حاول مرة أخرى لاحقاً. (${API_BASE}${endpoint})`);
}
throw error;
@ -419,7 +416,6 @@ export async function uploadPicture(file) {
async function multipartAuthFetch(endpoint, formData) {
const token = AuthService.getToken();
const res = await fetch(`${API_BASE}${endpoint}`, {
method: "POST",
headers: {
@ -450,7 +446,7 @@ async function multipartAuthFetch(endpoint, formData) {
};
}
export async function addOwner(data, frontImage = null, backImage = null, licenseImage = null) {
export async function addOwner(data, frontImage = null, backImage = null) {
const formData = new FormData();
formData.append("FirstName", data.firstName || data.FirstName || "");
@ -471,8 +467,6 @@ export async function addOwner(data, frontImage = null, backImage = null, licens
if (frontImage) formData.append("FrontIdCarImagePath", frontImage);
if (backImage) formData.append("RearIdCarImagePath", backImage);
if (licenseImage) formData.append("LicenseImagePath", licenseImage);
return multipartAuthFetch("/Owner/Add", formData);
}