ok
This commit is contained in:
@@ -165,12 +165,19 @@ export async function updateItemAvalilability(itemId, isAvailable) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
export async function createItemType(shopId, name, selectedImage) {
|
||||
export async function createItemType(shopId, name, selectedImage, previewUrl) {
|
||||
try {
|
||||
const formData = new FormData();
|
||||
formData.append("name", name);
|
||||
formData.append("image", selectedImage);
|
||||
|
||||
// Check if selectedImage is provided
|
||||
if (selectedImage) {
|
||||
formData.append("image", selectedImage);
|
||||
} else if (previewUrl) {
|
||||
// Remove the API_BASE_URL and any leading slashes from previewUrl
|
||||
const processedPreviewUrl = previewUrl.replace(API_BASE_URL, "").replace(/^\/+/, "");
|
||||
formData.append("sampleImage", processedPreviewUrl);
|
||||
}
|
||||
|
||||
const response = await fetch(`${API_BASE_URL}/item/createType/${shopId}`, {
|
||||
method: "POST",
|
||||
@@ -192,6 +199,7 @@ export async function createItemType(shopId, name, selectedImage) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
export async function updateItemType(
|
||||
shopId,
|
||||
itemTypeId,
|
||||
|
||||
@@ -193,12 +193,12 @@ export const getAllCafeOwner = async (formData) => {
|
||||
}
|
||||
};
|
||||
|
||||
export const createCafeOwner = async (shopId, email, username, password) => {
|
||||
export const createCafeOwner = async (email, username, password) => {
|
||||
const token = getLocalStorage("auth");
|
||||
if (token) {
|
||||
try {
|
||||
const response = await fetch(
|
||||
API_BASE_URL + "/user/create-clerk/" + shopId,
|
||||
API_BASE_URL + "/user/create-admin/" ,
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
@@ -276,6 +276,7 @@ export const createClerks = async (shopId, email, username, password) => {
|
||||
throw new Error(`HTTP error! status: ${response.status}`);
|
||||
}
|
||||
const data = await response.json();
|
||||
console.log(data)
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.error("Error getting clerk:", error);
|
||||
|
||||
Reference in New Issue
Block a user