update,
This commit is contained in:
15
tsc1877/task1/project/admin/src/api/cancelOrder.js
Normal file
15
tsc1877/task1/project/admin/src/api/cancelOrder.js
Normal file
@@ -0,0 +1,15 @@
|
||||
import axios from 'axios';
|
||||
import { API_PREF } from './common';
|
||||
|
||||
const CancelOrder = ({ custom_id }) => {
|
||||
return axios
|
||||
.post(`/api/order/cancel-order`, { custom_id })
|
||||
.then(response => {
|
||||
return response['data']['state'];
|
||||
})
|
||||
.catch(error => {
|
||||
console.error(error);
|
||||
});
|
||||
};
|
||||
|
||||
export default CancelOrder;
|
10
tsc1877/task1/project/admin/src/api/checkSession.js
Normal file
10
tsc1877/task1/project/admin/src/api/checkSession.js
Normal file
@@ -0,0 +1,10 @@
|
||||
import axios from 'axios';
|
||||
|
||||
const CheckSession = ({ session }) => {
|
||||
return axios
|
||||
.get(`/api/auth/check_session`, { headers: { session } })
|
||||
.then(res => res['data'])
|
||||
.catch(err => console.error(err));
|
||||
};
|
||||
|
||||
export default CheckSession;
|
15
tsc1877/task1/project/admin/src/api/checkoutCart.js
Normal file
15
tsc1877/task1/project/admin/src/api/checkoutCart.js
Normal file
@@ -0,0 +1,15 @@
|
||||
import axios from 'axios';
|
||||
import { API_PREF } from './common';
|
||||
|
||||
const checkoutCart = items_to_checkout => {
|
||||
return axios
|
||||
.post(`/api/inventory/check_out`, items_to_checkout)
|
||||
.then(response => {
|
||||
return response;
|
||||
})
|
||||
.catch(error => {
|
||||
console.error(error);
|
||||
});
|
||||
};
|
||||
|
||||
export default checkoutCart;
|
3
tsc1877/task1/project/admin/src/api/common.js
Normal file
3
tsc1877/task1/project/admin/src/api/common.js
Normal file
@@ -0,0 +1,3 @@
|
||||
const API_PREF = process.env.NEXT_PUBLIC_API_PREF;
|
||||
|
||||
export { API_PREF };
|
22
tsc1877/task1/project/admin/src/api/fetchAllOrders.js
Normal file
22
tsc1877/task1/project/admin/src/api/fetchAllOrders.js
Normal file
@@ -0,0 +1,22 @@
|
||||
import axios from 'axios';
|
||||
import { API_PREF } from './common';
|
||||
|
||||
const fetchAllOrders = ({ session }) => {
|
||||
console.log({ session });
|
||||
|
||||
return axios
|
||||
.get(`/api/order/list`, { headers: { session } })
|
||||
.then(function (response) {
|
||||
let { data } = response;
|
||||
|
||||
let { orders } = data;
|
||||
|
||||
return orders;
|
||||
})
|
||||
.catch(function (error) {
|
||||
// handle error
|
||||
console.log(error);
|
||||
});
|
||||
};
|
||||
|
||||
export default fetchAllOrders;
|
21
tsc1877/task1/project/admin/src/api/fetchCategories.js
Normal file
21
tsc1877/task1/project/admin/src/api/fetchCategories.js
Normal file
@@ -0,0 +1,21 @@
|
||||
import axios from 'axios';
|
||||
import { API_PREF } from './common';
|
||||
|
||||
const fetchCategories = () => {
|
||||
return axios
|
||||
.get(`/api/categories/list`)
|
||||
.then(function (response) {
|
||||
let { data } = response;
|
||||
let { categories } = data;
|
||||
return categories;
|
||||
})
|
||||
.catch(function (error) {
|
||||
// handle error
|
||||
console.log(error);
|
||||
})
|
||||
.finally(function () {
|
||||
// always executed
|
||||
});
|
||||
};
|
||||
|
||||
export default fetchCategories;
|
10
tsc1877/task1/project/admin/src/api/fetchCategory.js
Normal file
10
tsc1877/task1/project/admin/src/api/fetchCategory.js
Normal file
@@ -0,0 +1,10 @@
|
||||
import axios from 'axios';
|
||||
|
||||
const fetchCategory = async ({ cid }) => {
|
||||
return axios
|
||||
.get(`/api/categories/view?cid=${cid}`)
|
||||
.then(res => res)
|
||||
.catch(err => console.error(err));
|
||||
};
|
||||
|
||||
export default fetchCategory;
|
18
tsc1877/task1/project/admin/src/api/fetchCustomerOrders.js
Normal file
18
tsc1877/task1/project/admin/src/api/fetchCustomerOrders.js
Normal file
@@ -0,0 +1,18 @@
|
||||
import axios from 'axios';
|
||||
import { API_PREF } from './common';
|
||||
|
||||
const fetchCustomerOrders = ({ session }) => {
|
||||
return axios
|
||||
.get(`/api/order/listByCustomer`, { headers: { session } })
|
||||
.then(function (response) {
|
||||
let { data } = response;
|
||||
let { orders } = data;
|
||||
return orders;
|
||||
})
|
||||
.catch(function (error) {
|
||||
// handle error
|
||||
console.log(error);
|
||||
});
|
||||
};
|
||||
|
||||
export default fetchCustomerOrders;
|
10
tsc1877/task1/project/admin/src/api/fetchListByCategory.js
Normal file
10
tsc1877/task1/project/admin/src/api/fetchListByCategory.js
Normal file
@@ -0,0 +1,10 @@
|
||||
import axios from 'axios';
|
||||
|
||||
const fetchListByCategory = ({ cid }) => {
|
||||
return axios
|
||||
.get(`/api/products/listByCategory?cid=${cid}`)
|
||||
.then(res => res)
|
||||
.catch(err => console.error(err));
|
||||
};
|
||||
|
||||
export default fetchListByCategory;
|
@@ -0,0 +1,16 @@
|
||||
import axios from 'axios';
|
||||
import { API_PREF } from './common';
|
||||
|
||||
const fetchListByCategoryUnsold = ({ cid }) => {
|
||||
return axios
|
||||
.get(`/api/products/listByCategoryUnsold?cid=${cid}`)
|
||||
.then(res => {
|
||||
let {
|
||||
data: { products },
|
||||
} = res;
|
||||
return products;
|
||||
})
|
||||
.catch(err => console.error(err));
|
||||
};
|
||||
|
||||
export default fetchListByCategoryUnsold;
|
13
tsc1877/task1/project/admin/src/api/fetchProduct.js
Normal file
13
tsc1877/task1/project/admin/src/api/fetchProduct.js
Normal file
@@ -0,0 +1,13 @@
|
||||
import axios from 'axios';
|
||||
import { API_PREF } from './common';
|
||||
|
||||
const fetchProduct = ({ pid }) => {
|
||||
return axios
|
||||
.get(`/api/products/view?pid=${pid}`)
|
||||
.then(res => {
|
||||
return res;
|
||||
})
|
||||
.catch(err => console.error(err));
|
||||
};
|
||||
|
||||
export default fetchProduct;
|
19
tsc1877/task1/project/admin/src/api/fetchProducts.js
Normal file
19
tsc1877/task1/project/admin/src/api/fetchProducts.js
Normal file
@@ -0,0 +1,19 @@
|
||||
import axios from 'axios';
|
||||
import { API_PREF } from './common';
|
||||
|
||||
const fetchProducts = () => {
|
||||
return axios
|
||||
.get(`/api/products/list`)
|
||||
.then(function (response) {
|
||||
let { data } = response;
|
||||
let { products } = data;
|
||||
|
||||
return products;
|
||||
})
|
||||
.catch(function (error) {
|
||||
// handle error
|
||||
console.log(error);
|
||||
});
|
||||
};
|
||||
|
||||
export default fetchProducts;
|
18
tsc1877/task1/project/admin/src/api/getOrderDetails.js
Normal file
18
tsc1877/task1/project/admin/src/api/getOrderDetails.js
Normal file
@@ -0,0 +1,18 @@
|
||||
import axios from 'axios';
|
||||
import { API_PREF } from './common';
|
||||
|
||||
const GetOrderDetails = ({ cart, currency_code }) => {
|
||||
let session_raw = localStorage.getItem('session');
|
||||
let { session } = JSON.parse(session_raw);
|
||||
|
||||
return axios
|
||||
.post(`/api/order/get-order-details`, { cart, currency_code }, { headers: { session } })
|
||||
.then(response => {
|
||||
return response['data'];
|
||||
})
|
||||
.catch(error => {
|
||||
console.error(error);
|
||||
});
|
||||
};
|
||||
|
||||
export default GetOrderDetails;
|
16
tsc1877/task1/project/admin/src/api/saveOrder.js
Normal file
16
tsc1877/task1/project/admin/src/api/saveOrder.js
Normal file
@@ -0,0 +1,16 @@
|
||||
import axios from 'axios';
|
||||
import { API_PREF } from './common';
|
||||
import { csrf } from 'src/lib/csrf';
|
||||
|
||||
const SaveOrder = ({ custom_id }) => {
|
||||
return axios
|
||||
.post(`/api/order/save-order`, { custom_id })
|
||||
.then(response => {
|
||||
return response['data']['state'];
|
||||
})
|
||||
.catch(error => {
|
||||
console.error(error);
|
||||
});
|
||||
};
|
||||
|
||||
export default SaveOrder;
|
Reference in New Issue
Block a user