hmmmammamam

This commit is contained in:
NotII
2025-03-24 00:08:32 +00:00
parent ce9f4e4d49
commit c65511aa5d
11 changed files with 229 additions and 123 deletions

View File

@@ -1,5 +1,18 @@
import { fetchData } from '@/lib/data-service';
import { normalizeApiUrl } from './api-utils';
/**
* Interface for shipping method data
*/
interface ShippingMethod {
name: string;
price: number;
_id?: string;
}
/**
* Fetches all shipping methods for the current store
*/
export const fetchShippingMethods = async (authToken: string) => {
try {
const res = await fetchData(
@@ -23,12 +36,9 @@ export const fetchShippingMethods = async (authToken: string) => {
}
};
interface ShippingMethod {
name: string;
price: number;
_id?: string;
}
/**
* Adds a new shipping method
*/
export const addShippingMethod = async (
authToken: string,
newShipping: Omit<ShippingMethod, "_id">
@@ -69,6 +79,9 @@ export const addShippingMethod = async (
}
};
/**
* Deletes a shipping method by ID
*/
export const deleteShippingMethod = async (authToken: string, id: string) => {
try {
const res = await fetchData(
@@ -88,10 +101,13 @@ export const deleteShippingMethod = async (authToken: string, id: string) => {
}
};
/**
* Updates an existing shipping method
*/
export const updateShippingMethod = async (
authToken: string,
id: string,
updatedShipping: any
updatedShipping: Partial<ShippingMethod>
) => {
try {
const res = await fetchData(