feat: create new order
This commit is contained in:
@@ -3,7 +3,7 @@ import {ofetch} from "ofetch";
|
||||
const BASE_URL = '/';
|
||||
|
||||
export const apiFetch = ofetch.create({
|
||||
onRequest({ request, options }) {
|
||||
onRequest({request, options}) {
|
||||
const initData = window.Telegram?.WebApp?.initData
|
||||
|
||||
if (initData) {
|
||||
@@ -15,7 +15,7 @@ export const apiFetch = ofetch.create({
|
||||
},
|
||||
});
|
||||
|
||||
export default async function (action, query = null, json = null) {
|
||||
async function ftch(action, query = null, json = null) {
|
||||
const options = {
|
||||
method: json ? 'POST' : 'GET',
|
||||
}
|
||||
@@ -23,4 +23,39 @@ export default async function (action, query = null, json = null) {
|
||||
if (json) options.body = json;
|
||||
|
||||
return await apiFetch(`${BASE_URL}index.php?route=extension/tgshop/handle&api_action=${action}`, options);
|
||||
};
|
||||
}
|
||||
|
||||
export async function storeOrder(data) {
|
||||
return await apiFetch(`${BASE_URL}index.php?route=extension/tgshop/handle&api_action=storeOrder`, {
|
||||
method: 'POST',
|
||||
body: data,
|
||||
});
|
||||
}
|
||||
|
||||
export async function getCart() {
|
||||
return await ftch('getCart');
|
||||
}
|
||||
|
||||
export async function addToCart(data) {
|
||||
return await apiFetch(`${BASE_URL}index.php?route=checkout/cart/add`, {
|
||||
method: 'POST',
|
||||
body: data,
|
||||
});
|
||||
}
|
||||
|
||||
export async function cartRemoveItem(data) {
|
||||
return await apiFetch(`${BASE_URL}index.php?route=checkout/cart/remove`, {
|
||||
method: 'POST',
|
||||
body: data,
|
||||
});
|
||||
}
|
||||
|
||||
export async function cartEditItem(data) {
|
||||
return await apiFetch(`${BASE_URL}index.php?route=checkout/cart/edit`, {
|
||||
redirect: 'manual',
|
||||
method: 'POST',
|
||||
body: data,
|
||||
});
|
||||
}
|
||||
|
||||
export default ftch;
|
||||
|
||||
Reference in New Issue
Block a user