fixed owner and customer register make reuseable component and completed it
This commit is contained in:
@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user