Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import store from "../redux/store";
- import make_request from "./utils";
- import {endLoading, startLoading} from "../redux/globalLoading/globalLoadingSlice";
- import config from "react-global-configuration";
- let controller = new AbortController();
- const URL_PREFIX = config.get('URL_PREFIX', '')
- export class api{
- static async get_brands(){
- controller.abort();
- return make_request(
- '/api/product_v2/brand'
- )
- }
- static async get_products(values){
- controller.abort();
- store.dispatch(startLoading())
- return make_request(
- '/api/product_v2/product', values
- ).finally(()=>store.dispatch(endLoading()))
- }
- static async get_product_packages(_id){
- let {signal} = controller;
- if (signal.aborted) {
- controller = new AbortController();
- signal = controller.signal;
- }
- return make_request(
- `/api/product_v2/product/${_id}/package`,
- null, {signal: signal}
- )
- }
- static async get_inquiry(brand, cat_no){
- let {signal} = controller;
- if (signal.aborted) {
- controller = new AbortController();
- signal = controller.signal;
- }
- return make_request(
- `/api/product_v2/inquiry/${brand}/${cat_no}/`,
- null,
- {signal: signal}
- )
- }
- static async get_alter_storage(cat_no){
- let {signal} = controller;
- if (signal.aborted) {
- controller = new AbortController();
- signal = controller.signal;
- }
- if(!cat_no){return async ()=>[]}
- return make_request(
- `/api/product_v2/alter_storage/${cat_no}`, null, {signal: signal}
- )
- }
- static async get_all_coa(cat_no){
- if(!cat_no){return async ()=>[]}
- return make_request(
- '/api/product_v2/coa', {cat_no: cat_no,}
- )
- }
- static async get_po_plan(cat_no){
- if(!cat_no){return async ()=>[]}
- return make_request(
- '/api/product_v2/po_plan', {cat_no: cat_no}
- )
- }
- static async get_so_detail(cat_no){
- if (!cat_no){return async ()=>[]}
- return make_request(
- `/api/sales_order/${cat_no}/`, null
- )
- }
- static async get_stock(cat_no){
- if(!cat_no){return async ()=>[]}
- let {signal} = controller;
- if (signal.aborted) {
- controller = new AbortController();
- signal = controller.signal;
- }
- return make_request(
- '/api/product_v2/storage', {cat_no: cat_no,}, {signal: signal}
- )
- }
- static get_msds_url(brand, cat_no){
- if(brand!=='cato'){
- return null
- }
- return `http://192.168.5.246:8805/api/jchemhost/product/export_msds/?brand=${encodeURIComponent(brand)}&cat_no=${encodeURIComponent(cat_no)}`
- }
- }
Advertisement
Advertisement