@react-pakistan/util-functions 3.0.3 → 3.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
var g=Object.defineProperty;var
|
|
1
|
+
var g=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var U=Object.prototype.hasOwnProperty;var x=(t,r)=>{for(var i in r)g(t,i,{get:r[i],enumerable:!0})},J=(t,r,i,c)=>{if(r&&typeof r=="object"||typeof r=="function")for(let a of S(r))!U.call(t,a)&&a!==i&&g(t,a,{get:()=>r[a],enumerable:!(c=O(r,a))||c.enumerable});return t};var M=t=>J(g({},"__esModule",{value:!0}),t);var H={};x(H,{useModuleEntityV2:()=>B});module.exports=M(H);var d=require("react"),n=require("../constants/api-methods"),s=require("./use-fetch");const B=({byIdCallback:t,byIdDeps:r=[],byIdParams:i,deleteCallback:c,deleteDeps:a=[],deleteParams:m,listCallback:p,listDeps:E=[],listParams:u,listUrl:k,headers:l,searchQuery:T,unitByIdUrl:C,unitUrl:b,updateCallback:y,updateDeps:F=[],updateParams:N})=>{const o=(0,d.useRef)(null);(0,d.useEffect)(()=>()=>{o.current&&(globalThis.clearTimeout(o.current),o.current=null)},[]);const{error:P,fetchNow:f,loading:w}=(0,s.useFetch)(k,{method:n.API_METHODS.GET,params:u,headers:l,callback:p,credentials:!0},[T,u,...E]),h=(e=300)=>{o.current&&globalThis.clearTimeout(o.current),o.current=globalThis.setTimeout(()=>{try{f(void 0,{method:n.API_METHODS.GET,params:u,headers:l})}catch{}o.current=null},e)},{error:I,loading:L,fetchNow:v}=(0,s.useFetch)(b,{method:n.API_METHODS.PUT,body:JSON.stringify(N),headers:l,callback:e=>{if(y)try{y(e)}catch{}try{e&&e.ok&&h()}catch{}}},[...F]),{error:A,loading:V,fetchNow:D}=(0,s.useFetch)(C,{method:n.API_METHODS.GET,params:i,headers:l,callback:t},[...r]),{error:R,loading:j,fetchNow:G}=(0,s.useFetch)(b,{method:n.API_METHODS.DELETE,body:JSON.stringify(m),headers:l,callback:e=>{if(c)try{c(e)}catch{}try{e&&e.ok&&h()}catch{}}},[...a]);return{byIdError:A,byIdFetchNow:D,byIdLoading:V,deleteError:R,deleteFetchNow:G,deleteLoading:j,listError:P,listFetchNow:f,listLoading:w,updateError:I,updateFetchNow:v,updateLoading:L}};0&&(module.exports={useModuleEntityV2});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useRef as
|
|
1
|
+
import{useRef as j,useEffect as G}from"react";import{API_METHODS as a}from"../constants/api-methods";import{useFetch as o}from"./use-fetch";const J=({byIdCallback:u,byIdDeps:g=[],byIdParams:b,deleteCallback:n,deleteDeps:y=[],deleteParams:f,listCallback:h,listDeps:m=[],listParams:i,listUrl:p,headers:e,searchQuery:E,unitByIdUrl:k,unitUrl:c,updateCallback:l,updateDeps:T=[],updateParams:C})=>{const t=j(null);G(()=>()=>{t.current&&(globalThis.clearTimeout(t.current),t.current=null)},[]);const{error:F,fetchNow:s,loading:N}=o(p,{method:a.GET,params:i,headers:e,callback:h,credentials:!0},[E,i,...m]),d=(r=300)=>{t.current&&globalThis.clearTimeout(t.current),t.current=globalThis.setTimeout(()=>{try{s(void 0,{method:a.GET,params:i,headers:e})}catch{}t.current=null},r)},{error:P,loading:w,fetchNow:I}=o(c,{method:a.PUT,body:JSON.stringify(C),headers:e,callback:r=>{if(l)try{l(r)}catch{}try{r&&r.ok&&d()}catch{}}},[...T]),{error:L,loading:v,fetchNow:A}=o(k,{method:a.GET,params:b,headers:e,callback:u},[...g]),{error:V,loading:D,fetchNow:R}=o(c,{method:a.DELETE,body:JSON.stringify(f),headers:e,callback:r=>{if(n)try{n(r)}catch{}try{r&&r.ok&&d()}catch{}}},[...y]);return{byIdError:L,byIdFetchNow:A,byIdLoading:v,deleteError:V,deleteFetchNow:R,deleteLoading:D,listError:F,listFetchNow:s,listLoading:N,updateError:P,updateFetchNow:I,updateLoading:w}};export{J as useModuleEntityV2};
|