@bikdotai/bik-component-library 0.0.454-beta.ppi-6 → 0.0.454-beta.ppi-7
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.
- package/dist/cjs/components/bik-layout/MockMenus.d.ts +0 -1
- package/dist/cjs/components/product-picker-v2/modal.js +1 -1
- package/dist/cjs/components/product-picker-v2/rearrangeScreen.js +1 -1
- package/dist/cjs/components/product-picker-v2/reducers.js +1 -1
- package/dist/cjs/components/product-picker-v2/searchScreen.js +1 -1
- package/dist/cjs/components/product-picker-v2/selectedScreen.js +1 -1
- package/dist/cjs/components/product-picker-v2/utility.d.ts +2 -1
- package/dist/cjs/components/product-picker-v2/utility.js +1 -1
- package/dist/esm/components/bik-layout/MockMenus.d.ts +0 -1
- package/dist/esm/components/product-picker-v2/modal.js +1 -1
- package/dist/esm/components/product-picker-v2/rearrangeScreen.js +1 -1
- package/dist/esm/components/product-picker-v2/reducers.js +1 -1
- package/dist/esm/components/product-picker-v2/searchScreen.js +1 -1
- package/dist/esm/components/product-picker-v2/selectedScreen.js +1 -1
- package/dist/esm/components/product-picker-v2/utility.d.ts +2 -1
- package/dist/esm/components/product-picker-v2/utility.js +1 -1
- package/package.json +1 -1
- package/dist/cjs/components/product-picker-v2/useFetchFbStatus copy.d.ts +0 -2
- package/dist/cjs/components/product-picker-v2/useFetchFbStatus.d.ts +0 -6
- package/dist/cjs/components/product-picker-v2/useFetchFbStatus.js +0 -1
- package/dist/esm/components/product-picker-v2/useFetchFbStatus copy.d.ts +0 -2
- package/dist/esm/components/product-picker-v2/useFetchFbStatus.d.ts +0 -6
- package/dist/esm/components/product-picker-v2/useFetchFbStatus.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react/jsx-runtime"),c=require("../../assets/icons/search.svg.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react/jsx-runtime"),c=require("../../assets/icons/search.svg.js"),o=require("react"),r=require("../../constants/Theme.js"),s=require("../button/Button.js"),n=require("../input/Input.js"),i=require("../modals/styledModal.js"),l=require("../spinner/Spinner.js"),a=require("../tag/Tag.js"),d=require("./collectionScreen.js"),u=require("./productInfoOverlay.js"),h=require("./productScreen.js"),p=require("./rearrangeScreen.js"),S=require("./reducers.js"),C=require("./searchScreen.js"),x=require("./selectedScreen.js"),g=require("./style.js"),j=require("./type.js");exports.ScreenName=void 0,(e=exports.ScreenName||(exports.ScreenName={})).Collections="collections",e.RearrangeProducts="rearrange",e.SelectedProducts="view",e.SearchProducts="searchProducts",e.Products="products";exports.ProductPickerModal=e=>{const{storeId:m,selectedItems:b,onClose:y,visible:f,zIndex:P,exactLimit:v,limit:I,hideCollectionCheckbox:k,hideProductCheckbox:F,outOfStockAction:O=j.OUT_OF_STOCK_ACTION.BLUR,hideVariantCheckbox:R,selectProductsFromCustomCollection:T,hideSelectionCount:q,title:D,width:E,renderWithoutModal:w,onClickSave:N,pickerType:A,hideProductVariants:B=!1,startupScreen:$=exports.ScreenName.Collections,rearrangeEnabled:M,selectSingleItem:V=!1,showProductDetailInfoIcon:L}=e,[_,z]=o.useReducer(S.collectionsReducer,{}),[G,H]=o.useState([exports.ScreenName.Collections,exports.ScreenName.RearrangeProducts].includes($)?$:exports.ScreenName.Collections),[W,K]=o.useState("grid"),[U,Y]=o.useState(""),[J,Q]=o.useState(""),[X,Z]=o.useState(0),[ee,te]=o.useState(!1),[ce,oe]=o.useState(0),[re,se]=o.useState(""),[ne,ie]=o.useState(!1),[le,ae]=o.useState(!1),[de,ue]=o.useReducer(S.searchReducer,{}),[he,pe]=o.useReducer(S.selectedColectionsReducer,Object.keys(b).length>0?b:{}),Se=o.useRef(null),[Ce,xe]=o.useState(!1),[ge,je]=o.useState();o.useEffect((()=>{te(!0),ae(!0),e.collectionFetcher(X,m).then((e=>{z({type:"fetched",data:(null==e?void 0:e.collections)||{}}),te(!1),Z((e=>e+1)),ae(!1)})).catch()}),[]),o.useEffect((()=>{let e=0;Object.keys(he||[]).forEach((t=>{var c;Object.keys((null===(c=he[t])||void 0===c?void 0:c.products)||[]).forEach((c=>{var o,r;Object.keys((null===(r=null===(o=he[t].products)||void 0===o?void 0:o[c])||void 0===r?void 0:r.variants)||[]).forEach((()=>{e+=1}))}))})),oe(e)})),o.useEffect((()=>{J&&(te(!0),e.productFetcher(J,m).then((e=>{Object.keys(e).length&&z({type:"productsFetched",data:{collectionId:J,products:e}}),te(!1)})).catch())}),[J]),o.useEffect((()=>{const t=setTimeout((()=>{"rearrange"!==G&&(re.length?(ie(!0),e.searchFetcher(m,re).then((e=>{ue({type:"set",data:e}),H("searchProducts"),te(!1),ie(!1)}))):H("collections"))}),800);return()=>clearTimeout(t)}),[re]),o.useEffect((()=>{N&&(e.onAdd(he,ce),me())}),[N]),o.useEffect((()=>{V&&Object.keys(he||{}).length&&ce&&(e.onAdd(he,ce),me())}),[V,he,ce]);const me=()=>{pe({type:"reset",data:{}})},be=t.jsxs(g.ContainerStyle,{children:[e.postHeader&&t.jsx("div",Object.assign({style:{padding:"0 24px"}},{children:e.postHeader})),!e.hideGlobalSearch&&t.jsx(t.Fragment,{children:("collections"===G||"searchProducts"===G)&&t.jsx("div",Object.assign({style:{padding:w?"8px 16px":"12px 24px",borderBottom:"1px solid #E0E0E0"}},{children:t.jsx(n.Input,{noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>ne?t.jsx(l.Spinner,{size:"small",color:r.COLORS.content.primary}):t.jsx(c.default,{})},id:"listInput",height:"24px",type:"text",value:re,onChangeText:e=>{e.length&&e.trim().length?se(e):se("")}})}))}),t.jsxs(g.ScrollContainerStyle,Object.assign({ref:Se},{children:["collections"===G&&t.jsx(d.CollectionsScreen,{customCollectionRestriction:e.customCollectionRestriction,dataLoading:le,collections:_,selectedCollectionsDispatch:pe,setCollectionId:Y,setSelectedCollectionId:Q,setScreen:H,selectedCollections:he,collectionFetcher:e.collectionFetcher,storeId:m,collectionsDispatch:z,setSaveDisabled:te,pagingControls:{curPage:X,setCurPage:Z},hideCollectionCheckbox:k,renderWithoutModal:w,pickerType:A}),"products"===G&&U&&t.jsx(S.CollectionIdContext.Provider,Object.assign({value:U},{children:t.jsx(h.ProductsScreen,{hideInCollectionSearch:e.hideInCollectionSearch,customCollectionRestriction:e.customCollectionRestriction,productFetcher:e.productFetcher,setScreen:H,storeId:m,data:_[U],collectionsDispatch:z,selectedCollectionsDispatch:pe,selectedData:he,setSaveDisabled:te,searchInCollectionFetcher:e.searchInCollectionFetcher,hideProductCheckbox:F,outOfStockAction:O,hideVariantCheckbox:R,selectProductsFromCustomCollection:T,renderWithoutModal:w,pickerType:A,hideProductVariants:B,fbStatusFetcher:e.fbStatusFetcher,onInfoIconClick:e=>{xe(!0),je(e)},showProductDetailInfoIcon:L})})),"view"===G&&t.jsx(x.SelectedScreen,{selectedCollections:he||{},selectedCollectionsDispatch:pe,setScreen:H,collections:_,outOfStockAction:O,storeId:m,fbStatusFetcher:e.fbStatusFetcher}),"rearrange"===G&&t.jsx(p.RearrangeScreen,{selectedCollections:he||{},selectedCollectionsDispatch:pe,setScreen:H,outOfStockAction:O,rearrangeViewType:"grid"===W?"list":"grid",scrollContainerRef:Se,storeId:m,fbStatusFetcher:e.fbStatusFetcher}),"searchProducts"===G&&t.jsx(C.SearchScreen,{customCollectionRestriction:e.customCollectionRestriction,selectedCollections:he||{},searchedCollections:de||{},searchedCollectionsDispatch:ue,selectedCollectionsDispatch:pe,setScreen:H,collections:_,onBackPress:()=>{se(""),ue({type:"set",data:{}})},pickerType:A,hideProductCheckbox:F,hideProductVariants:B,hideVariantCheckbox:R,storeId:m,fbStatusFetcher:e.fbStatusFetcher})]}))]});return t.jsx(t.Fragment,{children:w?be:t.jsxs(i.StyledModal,Object.assign({zIndex:P,open:f,onClose:()=>{null==y||y(),me()},headingTitle:D||("collections"===G||"products"===G?"Select Products":"view"===G?"Selected Products":"searchProducts"===G?"Searched Products":"rearrange"===G?"Rearrange Products":void 0),footerShadow:!0,centralContainerStyles:{width:E||"600px"},headerRightCustomElement:"rearrange"===G?(console.log("ignore:",K),t.jsx(t.Fragment,{})):t.jsx(t.Fragment,{}),primaryButton:{buttonText:ee?"Loading...":G===exports.ScreenName.RearrangeProducts?"Done":"Add",disabled:ee||ce<1||v&&ce<v||!v&&I&&ce>I||!1,onClick:()=>{e.onAdd(he,ce),me()}},footerLeftCustomElement:q?t.jsx(t.Fragment,{}):v&&ce>v?t.jsx(a.Tag,{tagText:`You can only select ${v} products`,type:"negative"}):I&&ce>I?t.jsx(a.Tag,{tagText:`You can only select ${I} products`,type:"negative"}):ce>0?t.jsx(s.Button,{onClick:()=>{H(M?exports.ScreenName.RearrangeProducts:exports.ScreenName.SelectedProducts)},buttonText:v?`${ce}/${v} products selected`:`${ce} products selected`,buttonType:["rearrange","view"].includes(G)?"tertiaryGray":"tertiary",disabled:["rearrange","view"].includes(G)}):t.jsx(s.Button,{disabled:!0,buttonText:v?`${ce}/${v} products selected`:`${ce} products selected`,buttonType:"tertiaryGray"}),hideCrossButton:Ce},{children:[be,Ce&&ge?t.jsx(u.ProductInfoOverlay,{productData:ge,outOfStockAction:O,onClose:()=>{xe(!1)}}):t.jsx(t.Fragment,{})]}))})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/arrow_left.svg.js"),r=require("react"),s=require("react-beautiful-dnd"),c=require("../../constants/Theme.js"),o=require("../icon-button/IconButton.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/arrow_left.svg.js"),r=require("react"),s=require("react-beautiful-dnd"),c=require("../../constants/Theme.js"),o=require("../icon-button/IconButton.js"),i=require("../TypographyStyle.js"),n=require("./emptyState.js"),a=require("./helpers/ProductHelper.js"),l=require("./style.js"),d=require("./utility.js"),u=require("./variantComponents.js");exports.RearrangeScreen=p=>{const{selectedCollections:j,selectedCollectionsDispatch:S,setScreen:h,rearrangeViewType:y,outOfStockAction:f,scrollContainerRef:x,storeId:q,fbStatusFetcher:C}=p,[O,g]=r.useState(a.parseSelectedVariantsToArray(j));r.useEffect((()=>{var e;null===(e=null==x?void 0:x.current)||void 0===e||e.scrollTo({top:0}),d.fetchFbStatusCollection(j,q,S,C,"update"),g(a.parseSelectedVariantsToArray(j))}),[j]);return e.jsxs(s.DragDropContext,Object.assign({onDragEnd:e=>{if(!e.destination)return;const t=O,[r]=t.splice(e.source.index,1);t.splice(e.destination.index,0,r),t.forEach(((e,t)=>{e.displayOrder=t})),g(t)}},{children:[e.jsxs(l.SelectedScreenHeader,{children:[e.jsx(o.IconButton,{Icon:t.default,width:16,height:16,color:c.COLORS.content.secondary,onClick:()=>{h("collections")}}),e.jsx(i.BodyCaption,Object.assign({color:c.COLORS.content.secondary},{children:"All Products"}))]}),Object.keys(j).length>0?"list"===y?e.jsx(u.VariantsList,{selectedVariants:O,setSelectedVariants:g,selectedCollectionsDispatch:S,outOfStockAction:f}):e.jsx(u.VariantsGrid,{selectedVariants:O,setSelectedVariants:g,selectedCollectionsDispatch:S}):e.jsx(n.EmptyState,{title:"No Products Selected",subtitle:"Selected products will appear here"})]}))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("lodash");const e=require("react").createContext("");exports.CollectionIdContext=e,exports.collectionsReducer=function(t,e){let a={};switch(e.type){case"fetched":return a=Object.assign({},e.data),a;case"productsFetched":return console.log("vj: productsFetched",{collections:t,action:e}),a=Object.assign({},t),a[e.data.collectionId].products=e.data.products,console.log("vj: collectionsCopy",{collectionsCopy:a}),a;case"paged":return console.log("vj: paged",{collections:t,action:e}),a=Object.assign(Object.assign({},t),e.data),a;case"productsPaged":return console.log("vj: pagedProducts",{collections:t,action:e}),a=Object.assign({},t),e.data.collectionId,a[e.data.collectionId].products=Object.assign(Object.assign({},a[e.data.collectionId].products),e.data.products),a;default:return{}}},exports.paginationReducer=function(t,e){let a={};switch(e.type){case"paginate":console.log("vj: paginate",e),a=Object.assign({},t);for(const t in e.data)if(Object.prototype.hasOwnProperty.call(e.data,t)){const o=e.data[t];if(Object.prototype.hasOwnProperty.call(a,t)){const e=a[t];a[t]=Object.assign(Object.assign({},e),{products:Object.assign(Object.assign({},e.products),o.products)})}else a[t]=o}return console.log("vj: collections copy",a),a;case"update":return console.log("vj: update",e),a=Object.assign({},t),console.log("vj: update collection",e),a;case"set":return a=Object.assign(Object.assign({},t),e.data),console.log("vj: update collection",e),a;case"filter":a={};for(const o in t)if(o in e.data){const c=Object.assign({},t[o]),s=e.data[o],d={};for(const t in c.products)if(t in s.products){const e=Object.assign({},c.products[t]),a=s.products[t],o={};for(const t in e.variants)t in a.variants&&(o[t]=Object.assign({},e.variants[t]));Object.keys(o).length>0&&(e.variants=o,d[t]=e)}Object.keys(d).length>0&&(c.products=d,a[o]=c)}return a;default:return t}},exports.searchReducer=function(t,e){return"set"===e.type?e.data:t},exports.selectedColectionsReducer=function(e,a){var o,c,s,d,n,l;let r={},i="",u="",p="";switch(a.type){case"selected":return console.log("vj: selectedColectionsReducer selected",a),r=t.cloneDeep(e),a.data.val.isSmartCollection&&(a.data.isRestricted&&(r={}),r.isCustom=!0),r[a.data.id]=a.data.val,r;case"unselected":return r=t.cloneDeep(e),(null==r?void 0:r.isCustom)&&(r.isCustom=!1),delete r[a.data.id],r;case"productUnselected":return r=t.cloneDeep(e),i=a.data.productId,u=a.data.collectionId,delete r[u].products[i],Object.keys(r[u].products).length||((null==r?void 0:r.isCustom)&&(r.isCustom=!1),delete r[u]),r;case"productSelected":return r=t.cloneDeep(e),i=a.data.productId,u=a.data.collectionId,(null===(o=a.data.catalogOnlyData)||void 0===o?void 0:o.isSmartCollection)&&(a.data.isRestricted&&(r={}),r.isCustom=!0),(null==r?void 0:r[u])||(r[u]=a.data.catalogOnlyData,r[u].products={}),r[u].products[i]=a.data.product,r;case"variantSelected":return r=t.cloneDeep(e),i=a.data.productId,u=a.data.collectionId,p=a.data.variantId,(null===(c=a.data.catalogOnlyData)||void 0===c?void 0:c.isSmartCollection)&&(a.data.isRestricted&&(r={}),r.isCustom=!0),(null==r?void 0:r[u])||(r[u]=a.data.catalogOnlyData,r[u].products={},r[u].products[i]=a.data.productOnlyData,r[u].products[i].variants={}),(null===(d=null===(s=null==r?void 0:r[u])||void 0===s?void 0:s.products)||void 0===d?void 0:d[i])||((null===(n=null==r?void 0:r[u])||void 0===n?void 0:n.products)||(r[u].products={}),r[u].products[i]=a.data.productOnlyData,r[u].products[i].variants={}),r[u].products[i].variants[p]=a.data.variant,r;case"variantUnselected":return r=t.cloneDeep(e),i=a.data.productId,u=a.data.collectionId,p=a.data.variantId,delete r[u].products[i].variants[p],Object.keys(r[u].products[i].variants).length||(delete r[u].products[i],Object.keys(r[u].products).length||((null===(l=r[u])||void 0===l?void 0:l.isSmartCollection)&&(r.isCustom=!1),delete r[u])),r;case"
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("lodash");const e=require("react").createContext("");exports.CollectionIdContext=e,exports.collectionsReducer=function(t,e){let a={};switch(e.type){case"fetched":return a=Object.assign({},e.data),a;case"productsFetched":return console.log("vj: productsFetched",{collections:t,action:e}),a=Object.assign({},t),a[e.data.collectionId].products=e.data.products,console.log("vj: collectionsCopy",{collectionsCopy:a}),a;case"paged":return console.log("vj: paged",{collections:t,action:e}),a=Object.assign(Object.assign({},t),e.data),a;case"productsPaged":return console.log("vj: pagedProducts",{collections:t,action:e}),a=Object.assign({},t),e.data.collectionId,a[e.data.collectionId].products=Object.assign(Object.assign({},a[e.data.collectionId].products),e.data.products),a;default:return{}}},exports.paginationReducer=function(t,e){let a={};switch(e.type){case"paginate":console.log("vj: paginate",e),a=Object.assign({},t);for(const t in e.data)if(Object.prototype.hasOwnProperty.call(e.data,t)){const o=e.data[t];if(Object.prototype.hasOwnProperty.call(a,t)){const e=a[t];a[t]=Object.assign(Object.assign({},e),{products:Object.assign(Object.assign({},e.products),o.products)})}else a[t]=o}return console.log("vj: collections copy",a),a;case"update":return console.log("vj: update",e),a=Object.assign({},t),console.log("vj: update collection",e),a;case"set":return a=Object.assign(Object.assign({},t),e.data),console.log("vj: update collection",e),a;case"filter":a={};for(const o in t)if(o in e.data){const c=Object.assign({},t[o]),s=e.data[o],d={};for(const t in c.products)if(t in s.products){const e=Object.assign({},c.products[t]),a=s.products[t],o={};for(const t in e.variants)t in a.variants&&(o[t]=Object.assign({},e.variants[t]));Object.keys(o).length>0&&(e.variants=o,d[t]=e)}Object.keys(d).length>0&&(c.products=d,a[o]=c)}return a;default:return t}},exports.searchReducer=function(t,e){return"set"===e.type?e.data:t},exports.selectedColectionsReducer=function(e,a){var o,c,s,d,n,l;let r={},i="",u="",p="";switch(a.type){case"selected":return console.log("vj: selectedColectionsReducer selected",a),r=t.cloneDeep(e),a.data.val.isSmartCollection&&(a.data.isRestricted&&(r={}),r.isCustom=!0),r[a.data.id]=a.data.val,r;case"unselected":return r=t.cloneDeep(e),(null==r?void 0:r.isCustom)&&(r.isCustom=!1),delete r[a.data.id],r;case"productUnselected":return r=t.cloneDeep(e),i=a.data.productId,u=a.data.collectionId,delete r[u].products[i],Object.keys(r[u].products).length||((null==r?void 0:r.isCustom)&&(r.isCustom=!1),delete r[u]),r;case"productSelected":return r=t.cloneDeep(e),i=a.data.productId,u=a.data.collectionId,(null===(o=a.data.catalogOnlyData)||void 0===o?void 0:o.isSmartCollection)&&(a.data.isRestricted&&(r={}),r.isCustom=!0),(null==r?void 0:r[u])||(r[u]=a.data.catalogOnlyData,r[u].products={}),r[u].products[i]=a.data.product,r;case"variantSelected":return r=t.cloneDeep(e),i=a.data.productId,u=a.data.collectionId,p=a.data.variantId,(null===(c=a.data.catalogOnlyData)||void 0===c?void 0:c.isSmartCollection)&&(a.data.isRestricted&&(r={}),r.isCustom=!0),(null==r?void 0:r[u])||(r[u]=a.data.catalogOnlyData,r[u].products={},r[u].products[i]=a.data.productOnlyData,r[u].products[i].variants={}),(null===(d=null===(s=null==r?void 0:r[u])||void 0===s?void 0:s.products)||void 0===d?void 0:d[i])||((null===(n=null==r?void 0:r[u])||void 0===n?void 0:n.products)||(r[u].products={}),r[u].products[i]=a.data.productOnlyData,r[u].products[i].variants={}),r[u].products[i].variants[p]=a.data.variant,r;case"variantUnselected":return r=t.cloneDeep(e),i=a.data.productId,u=a.data.collectionId,p=a.data.variantId,delete r[u].products[i].variants[p],Object.keys(r[u].products[i].variants).length||(delete r[u].products[i],Object.keys(r[u].products).length||((null===(l=r[u])||void 0===l?void 0:l.isSmartCollection)&&(r.isCustom=!1),delete r[u])),r;case"update":default:return e;case"reset":return{}}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/arrow_left.svg.js"),o=require("react"),i=require("../icon-button/IconButton.js"),r=require("../TypographyStyle.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/arrow_left.svg.js"),o=require("react"),i=require("../icon-button/IconButton.js"),r=require("../TypographyStyle.js"),c=require("./emptyState.js"),s=require("./productScreen.js"),l=require("./style.js"),d=require("./utility.js");exports.SearchScreen=n=>{const{customCollectionRestriction:u,selectedCollections:a,searchedCollections:v,searchedCollectionsDispatch:h,selectedCollectionsDispatch:p,setScreen:j,collections:y,onBackPress:b,hideVariantCheckbox:k,pickerType:x,hideProductVariants:C,hideProductCheckbox:f,storeId:S,fbStatusFetcher:P}=n;o.useEffect((()=>{d.fetchFbStatusCollection(v,S,h,P,"set")}),[v]);const q=(e,t)=>{var o,i,r,c,s,l,d,n,u;let v=0,h=0;return!!((null===(i=null===(o=null==a?void 0:a[e])||void 0===o?void 0:o.products)||void 0===i?void 0:i[t])&&(null===(l=Object.keys((null===(s=null===(c=null===(r=null==y?void 0:y[e])||void 0===r?void 0:r.products)||void 0===c?void 0:c[t])||void 0===s?void 0:s.variants)||[]))||void 0===l||l.forEach((()=>h++)),Object.keys((null===(u=null===(n=null===(d=null==a?void 0:a[e])||void 0===d?void 0:d.products)||void 0===n?void 0:n[t])||void 0===u?void 0:u.variants)||[]).forEach((()=>v++)),v>0&&h!==v))};return e.jsxs("div",{children:[e.jsxs(l.SelectedScreenHeader,{children:[e.jsx(i.IconButton,{Icon:t.default,onClick:()=>{j("collections"),b()}}),e.jsx(r.BodyCaption,{children:"Searched Products"})]}),e.jsx("div",{children:Object.keys(v).length?e.jsx(e.Fragment,{children:Object.keys(v).map((t=>{var o;return Object.keys((null===(o=null==v?void 0:v[t])||void 0===o?void 0:o.products)||[]).map((o=>{let i=!1;return(null==v?void 0:v.isCustom)&&(i=!0),e.jsx(s.ProductGroup,{collectionId:t,upliftAdditions:(e,o)=>((e,t,o)=>{const i=d.liftTheStateUp(o,v[e]);p({type:t,data:Object.assign(Object.assign({},i),{isRestricted:u})})})(t,e,o),productId:o,data:v[t].products[o],isProductPartiallyChecked:q(t,o),selectedData:a,selectedCollectionsDispatch:p,viewOnly:i,hideProductCheckbox:f,hideVariantCheckbox:k,hideProductVariants:C,pickerType:x},o)}))}))}):e.jsx(c.EmptyState,{title:"No search results found",subtitle:"We couldn’t find the product you were looking for."})})]})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/arrow_left.svg.js"),r=require("react"),o=require("../icon-button/IconButton.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/arrow_left.svg.js"),r=require("react"),o=require("../icon-button/IconButton.js"),c=require("../TypographyStyle.js"),s=require("./emptyState.js"),l=require("./productScreen.js"),n=require("./reducers.js"),i=require("./style.js"),u=require("./utility.js");exports.SelectedScreen=d=>{const{selectedCollections:a,selectedCollectionsDispatch:v,setScreen:p,collections:j,outOfStockAction:f,storeId:g,fbStatusFetcher:S}=d,y=r.useRef(0),h=r.useRef(null),[b,x]=r.useReducer(n.paginationReducer,{});r.useEffect((()=>{y.current=0;const e=u.paginateSelectedItems(a,10,0);x({type:"paginate",data:e}),u.fetchFbStatusCollection(e,g,x,S,"set"),y.current+=1}),[]),r.useEffect((()=>{x({type:"filter",data:a})}),[a]),r.useEffect((()=>{console.log("vj: observertarget",h.current);const e=new IntersectionObserver((e=>{if(console.log("vj: observertargetinside",e),e[0].isIntersecting&&(console.log("vj: nextPageRef",y.current),y.current>0)){const e=u.paginateSelectedItems(a,10,y.current);console.log("paginated inside observer target",{paginatedProducts:e,selectedCollections:a,curScreenData:b}),x({type:"paginate",data:e}),u.fetchFbStatusCollection(e,g,x,S,"update"),y.current+=1}}),{threshold:1});return h.current&&e.observe(h.current),()=>{h.current&&e.unobserve(h.current)}}),[h,a]);const q=(e,t)=>{var r,o,c,s,l,n,i,u,d;let v=0,p=0;return!!((null===(o=null===(r=null==a?void 0:a[e])||void 0===r?void 0:r.products)||void 0===o?void 0:o[t])&&(null===(n=Object.keys((null===(l=null===(s=null===(c=null==j?void 0:j[e])||void 0===c?void 0:c.products)||void 0===s?void 0:s[t])||void 0===l?void 0:l.variants)||[]))||void 0===n||n.forEach((()=>p++)),Object.keys((null===(d=null===(u=null===(i=null==a?void 0:a[e])||void 0===i?void 0:i.products)||void 0===u?void 0:u[t])||void 0===d?void 0:d.variants)||[]).forEach((()=>v++)),v>0&&p!==v))};return e.jsxs("div",{children:[e.jsxs(i.SelectedScreenHeader,{children:[e.jsx(o.IconButton,{Icon:t.default,onClick:()=>{p("collections")}}),e.jsx(c.BodyCaption,{children:"Selected Products"})]}),e.jsxs("div",{children:[Object.keys(b).length>0?e.jsx(e.Fragment,{children:Object.keys(b).map((t=>{var r;return Object.keys((null===(r=null==b?void 0:b[t])||void 0===r?void 0:r.products)||[]).map((r=>{let o=!1;return(null==b?void 0:b.isCustom)&&(o=!0),e.jsx(l.ProductGroup,{upliftAdditions:null,collectionId:t,productId:r,data:b[t].products[r],isProductPartiallyChecked:q(t,r),selectedData:a,selectedCollectionsDispatch:v,viewOnly:o,outOfStockAction:f},r)}))}))}):e.jsx(s.EmptyState,{title:"No Products Selected",subtitle:"Select products will appear here"}),e.jsx("div",{ref:h})]})]})};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Collection, SelectedItems } from './modal';
|
|
1
|
+
import { Collection, FbStatusFetcherReturn, SelectedItems } from './modal';
|
|
2
2
|
export declare const liftTheStateUp: (payload: any, data: any) => any;
|
|
3
3
|
export declare function paginateSelectedItems(selectedItems: SelectedItems, limit: number, offset: number): {
|
|
4
4
|
[key: string]: Collection;
|
|
5
5
|
};
|
|
6
|
+
export declare const fetchFbStatusCollection: (data: SelectedItems, storeId: string, dispatcher: any, fbStatusFetcher?: ((storeId: string, variantIds: string[]) => FbStatusFetcherReturn) | undefined, dispatchType?: string) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var o=require("lodash");function t(o,t,n){if(!o)return{};const l=Object.keys(o).slice(n,n+t),e={};return l.forEach((t=>{e[t]=o[t]})),e}const n=(o,t,n)=>{Object.keys(o).forEach((t=>{var n,l;const e=null!==(l=null===(n=o[t])||void 0===n?void 0:n.products)&&void 0!==l?l:{};Object.keys(e).forEach((n=>{var l,e,s,d;const i=null!==(d=null===(s=null===(e=null===(l=o[t])||void 0===l?void 0:l.products)||void 0===e?void 0:e[n])||void 0===s?void 0:s.variants)&&void 0!==d?d:{};Object.keys(i).forEach((l=>{var e,s,d,i;const c=null===(i=null===(d=null===(s=null===(e=o[t])||void 0===e?void 0:e.products)||void 0===s?void 0:s[n])||void 0===d?void 0:d.variants)||void 0===i?void 0:i[l];c&&!c.fbStatus&&(c.fbStatus="APPROVED")}))}))})),t({type:n,data:o})};exports.fetchFbStatusCollection=function(o,t,l,e){let s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"paged";e||n(o,l,s);const d=(o=>{const t=[];return Object.keys(o).forEach((n=>{var l,e;const s=null!==(e=null===(l=o[n])||void 0===l?void 0:l.products)&&void 0!==e?e:{};Object.keys(s).forEach((l=>{var e,s,d,i;const c=null!==(i=null===(d=null===(s=null===(e=o[n])||void 0===e?void 0:e.products)||void 0===s?void 0:s[l])||void 0===d?void 0:d.variants)&&void 0!==i?i:{};Object.keys(c).forEach((e=>{var s,d,i,c;const a=null===(c=null===(i=null===(d=null===(s=o[n])||void 0===s?void 0:s.products)||void 0===d?void 0:d[l])||void 0===i?void 0:i.variants)||void 0===c?void 0:c[e];(null==a?void 0:a.fbStatus)||t.push(e)}))}))})),t})(o);console.log("vj: variantids",d),d.length>0&&e&&e(t,d).then((t=>{const n=Object.assign({},o);Object.keys(n).forEach((o=>{var l,e;const s=null!==(e=null===(l=n[o])||void 0===l?void 0:l.products)&&void 0!==e?e:{};Object.keys(s).forEach((l=>{var e,s,d,i;const c=null!==(i=null===(d=null===(s=null===(e=n[o])||void 0===e?void 0:e.products)||void 0===s?void 0:s[l])||void 0===d?void 0:d.variants)&&void 0!==i?i:{};Object.keys(c).forEach((e=>{var s,d,i,c;const a=null===(c=null===(i=null===(d=null===(s=n[o])||void 0===s?void 0:s.products)||void 0===d?void 0:d[l])||void 0===i?void 0:i.variants)||void 0===c?void 0:c[e];a&&"REJECTED"===t[e]?a.fbStatus="REJECTED":a&&"APPROVED"===t[e]&&(a.fbStatus="APPROVED")}))}))})),console.log("updated data",n,s),l({type:s,data:n})})).catch((t=>{console.error("Error in fbStatusFetcher",t),n(o,l,s)}))},exports.liftTheStateUp=(t,n)=>{const l=o.cloneDeep(n);if(delete l.products,(t=Object.assign(Object.assign({},t),{catalogOnlyData:l})).productId&&n.products){const e=o.cloneDeep(n.products[t.productId]);(null==e?void 0:e.variants)&&delete e.variants,t=Object.assign(Object.assign({},t),{catalogOnlyData:l,productOnlyData:e})}return t},exports.paginateSelectedItems=function(o,n,l){var e;const s={};let d=0;console.log("paginated offset",l);for(const i in o)if(Object.prototype.hasOwnProperty.call(o,i)){const c=o[i],a=t(c.products,n,l-d);a&&Object.keys(a).length>0&&(s[i]=Object.assign(Object.assign({},c),{products:a})),d+=Object.keys(null!==(e=c.products)&&void 0!==e?e:{}).length}return s};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as t,Fragment as o}from"react/jsx-runtime";import c from"../../assets/icons/search.svg.js";import{useReducer as r,useState as s,useRef as n,useEffect as i}from"react";import{COLORS as l}from"../../constants/Theme.js";import{Button as d}from"../button/Button.js";import{Input as a}from"../input/Input.js";import{StyledModal as u}from"../modals/styledModal.js";import{Spinner as h}from"../spinner/Spinner.js";import{Tag as p}from"../tag/Tag.js";import{CollectionsScreen as m}from"./collectionScreen.js";import{ProductInfoOverlay as C}from"./productInfoOverlay.js";import{ProductsScreen as g}from"./productScreen.js";import{RearrangeScreen as f}from"./rearrangeScreen.js";import{collectionsReducer as b,searchReducer as S,selectedColectionsReducer as y,CollectionIdContext as P}from"./reducers.js";import{SearchScreen as v}from"./searchScreen.js";import{SelectedScreen as j}from"./selectedScreen.js";import{ContainerStyle as k,ScrollContainerStyle as x}from"./style.js";import{OUT_OF_STOCK_ACTION as I}from"./type.js";
|
|
1
|
+
import{jsxs as e,jsx as t,Fragment as o}from"react/jsx-runtime";import c from"../../assets/icons/search.svg.js";import{useReducer as r,useState as s,useRef as n,useEffect as i}from"react";import{COLORS as l}from"../../constants/Theme.js";import{Button as d}from"../button/Button.js";import{Input as a}from"../input/Input.js";import{StyledModal as u}from"../modals/styledModal.js";import{Spinner as h}from"../spinner/Spinner.js";import{Tag as p}from"../tag/Tag.js";import{CollectionsScreen as m}from"./collectionScreen.js";import{ProductInfoOverlay as C}from"./productInfoOverlay.js";import{ProductsScreen as g}from"./productScreen.js";import{RearrangeScreen as f}from"./rearrangeScreen.js";import{collectionsReducer as b,searchReducer as S,selectedColectionsReducer as y,CollectionIdContext as P}from"./reducers.js";import{SearchScreen as v}from"./searchScreen.js";import{SelectedScreen as j}from"./selectedScreen.js";import{ContainerStyle as k,ScrollContainerStyle as x}from"./style.js";import{OUT_OF_STOCK_ACTION as I}from"./type.js";var F;!function(e){e.Collections="collections",e.RearrangeProducts="rearrange",e.SelectedProducts="view",e.SearchProducts="searchProducts",e.Products="products"}(F||(F={}));const T=T=>{const{storeId:O,selectedItems:D,onClose:R,visible:w,zIndex:E,exactLimit:A,limit:$,hideCollectionCheckbox:V,hideProductCheckbox:B,outOfStockAction:L=I.BLUR,hideVariantCheckbox:M,selectProductsFromCustomCollection:z,hideSelectionCount:G,title:H,width:W,renderWithoutModal:Y,onClickSave:K,pickerType:U,hideProductVariants:q=!1,startupScreen:J=F.Collections,rearrangeEnabled:N,selectSingleItem:Q=!1,showProductDetailInfoIcon:X}=T,[Z,_]=r(b,{}),[ee,te]=s([F.Collections,F.RearrangeProducts].includes(J)?J:F.Collections),[oe,ce]=s("grid"),[re,se]=s(""),[ne,ie]=s(""),[le,de]=s(0),[ae,ue]=s(!1),[he,pe]=s(0),[me,Ce]=s(""),[ge,fe]=s(!1),[be,Se]=s(!1),[ye,Pe]=r(S,{}),[ve,je]=r(y,Object.keys(D).length>0?D:{}),ke=n(null),[xe,Ie]=s(!1),[Fe,Te]=s();i((()=>{ue(!0),Se(!0),T.collectionFetcher(le,O).then((e=>{_({type:"fetched",data:(null==e?void 0:e.collections)||{}}),ue(!1),de((e=>e+1)),Se(!1)})).catch()}),[]),i((()=>{let e=0;Object.keys(ve||[]).forEach((t=>{var o;Object.keys((null===(o=ve[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c,r;Object.keys((null===(r=null===(c=ve[t].products)||void 0===c?void 0:c[o])||void 0===r?void 0:r.variants)||[]).forEach((()=>{e+=1}))}))})),pe(e)})),i((()=>{ne&&(ue(!0),T.productFetcher(ne,O).then((e=>{Object.keys(e).length&&_({type:"productsFetched",data:{collectionId:ne,products:e}}),ue(!1)})).catch())}),[ne]),i((()=>{const e=setTimeout((()=>{"rearrange"!==ee&&(me.length?(fe(!0),T.searchFetcher(O,me).then((e=>{Pe({type:"set",data:e}),te("searchProducts"),ue(!1),fe(!1)}))):te("collections"))}),800);return()=>clearTimeout(e)}),[me]),i((()=>{K&&(T.onAdd(ve,he),Oe())}),[K]),i((()=>{Q&&Object.keys(ve||{}).length&&he&&(T.onAdd(ve,he),Oe())}),[Q,ve,he]);const Oe=()=>{je({type:"reset",data:{}})},De=e(k,{children:[T.postHeader&&t("div",Object.assign({style:{padding:"0 24px"}},{children:T.postHeader})),!T.hideGlobalSearch&&t(o,{children:("collections"===ee||"searchProducts"===ee)&&t("div",Object.assign({style:{padding:Y?"8px 16px":"12px 24px",borderBottom:"1px solid #E0E0E0"}},{children:t(a,{noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>ge?t(h,{size:"small",color:l.content.primary}):t(c,{})},id:"listInput",height:"24px",type:"text",value:me,onChangeText:e=>{e.length&&e.trim().length?Ce(e):Ce("")}})}))}),e(x,Object.assign({ref:ke},{children:["collections"===ee&&t(m,{customCollectionRestriction:T.customCollectionRestriction,dataLoading:be,collections:Z,selectedCollectionsDispatch:je,setCollectionId:se,setSelectedCollectionId:ie,setScreen:te,selectedCollections:ve,collectionFetcher:T.collectionFetcher,storeId:O,collectionsDispatch:_,setSaveDisabled:ue,pagingControls:{curPage:le,setCurPage:de},hideCollectionCheckbox:V,renderWithoutModal:Y,pickerType:U}),"products"===ee&&re&&t(P.Provider,Object.assign({value:re},{children:t(g,{hideInCollectionSearch:T.hideInCollectionSearch,customCollectionRestriction:T.customCollectionRestriction,productFetcher:T.productFetcher,setScreen:te,storeId:O,data:Z[re],collectionsDispatch:_,selectedCollectionsDispatch:je,selectedData:ve,setSaveDisabled:ue,searchInCollectionFetcher:T.searchInCollectionFetcher,hideProductCheckbox:B,outOfStockAction:L,hideVariantCheckbox:M,selectProductsFromCustomCollection:z,renderWithoutModal:Y,pickerType:U,hideProductVariants:q,fbStatusFetcher:T.fbStatusFetcher,onInfoIconClick:e=>{Ie(!0),Te(e)},showProductDetailInfoIcon:X})})),"view"===ee&&t(j,{selectedCollections:ve||{},selectedCollectionsDispatch:je,setScreen:te,collections:Z,outOfStockAction:L,storeId:O,fbStatusFetcher:T.fbStatusFetcher}),"rearrange"===ee&&t(f,{selectedCollections:ve||{},selectedCollectionsDispatch:je,setScreen:te,outOfStockAction:L,rearrangeViewType:"grid"===oe?"list":"grid",scrollContainerRef:ke,storeId:O,fbStatusFetcher:T.fbStatusFetcher}),"searchProducts"===ee&&t(v,{customCollectionRestriction:T.customCollectionRestriction,selectedCollections:ve||{},searchedCollections:ye||{},searchedCollectionsDispatch:Pe,selectedCollectionsDispatch:je,setScreen:te,collections:Z,onBackPress:()=>{Ce(""),Pe({type:"set",data:{}})},pickerType:U,hideProductCheckbox:B,hideProductVariants:q,hideVariantCheckbox:M,storeId:O,fbStatusFetcher:T.fbStatusFetcher})]}))]});return t(o,{children:Y?De:e(u,Object.assign({zIndex:E,open:w,onClose:()=>{null==R||R(),Oe()},headingTitle:H||("collections"===ee||"products"===ee?"Select Products":"view"===ee?"Selected Products":"searchProducts"===ee?"Searched Products":"rearrange"===ee?"Rearrange Products":void 0),footerShadow:!0,centralContainerStyles:{width:W||"600px"},headerRightCustomElement:"rearrange"===ee?(console.log("ignore:",ce),t(o,{})):t(o,{}),primaryButton:{buttonText:ae?"Loading...":ee===F.RearrangeProducts?"Done":"Add",disabled:ae||he<1||A&&he<A||!A&&$&&he>$||!1,onClick:()=>{T.onAdd(ve,he),Oe()}},footerLeftCustomElement:G?t(o,{}):A&&he>A?t(p,{tagText:`You can only select ${A} products`,type:"negative"}):$&&he>$?t(p,{tagText:`You can only select ${$} products`,type:"negative"}):t(d,he>0?{onClick:()=>{te(N?F.RearrangeProducts:F.SelectedProducts)},buttonText:A?`${he}/${A} products selected`:`${he} products selected`,buttonType:["rearrange","view"].includes(ee)?"tertiaryGray":"tertiary",disabled:["rearrange","view"].includes(ee)}:{disabled:!0,buttonText:A?`${he}/${A} products selected`:`${he} products selected`,buttonType:"tertiaryGray"}),hideCrossButton:xe},{children:[De,xe&&Fe?t(C,{productData:Fe,outOfStockAction:L,onClose:()=>{Ie(!1)}}):t(o,{})]}))})};export{T as ProductPickerModal,F as ScreenName};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as t,jsx as e}from"react/jsx-runtime";import o from"../../assets/icons/arrow_left.svg.js";import{useState as r,useEffect as s}from"react";import{DragDropContext as c}from"react-beautiful-dnd";import{COLORS as i}from"../../constants/Theme.js";import{IconButton as n}from"../icon-button/IconButton.js";import{BodyCaption as l}from"../TypographyStyle.js";import{EmptyState as a}from"./emptyState.js";import{parseSelectedVariantsToArray as d}from"./helpers/ProductHelper.js";import{SelectedScreenHeader as p}from"./style.js";import{fetchFbStatusCollection as m}from"./
|
|
1
|
+
import{jsxs as t,jsx as e}from"react/jsx-runtime";import o from"../../assets/icons/arrow_left.svg.js";import{useState as r,useEffect as s}from"react";import{DragDropContext as c}from"react-beautiful-dnd";import{COLORS as i}from"../../constants/Theme.js";import{IconButton as n}from"../icon-button/IconButton.js";import{BodyCaption as l}from"../TypographyStyle.js";import{EmptyState as a}from"./emptyState.js";import{parseSelectedVariantsToArray as d}from"./helpers/ProductHelper.js";import{SelectedScreenHeader as p}from"./style.js";import{fetchFbStatusCollection as m}from"./utility.js";import{VariantsList as u,VariantsGrid as f}from"./variantComponents.js";const h=h=>{const{selectedCollections:j,selectedCollectionsDispatch:y,setScreen:S,rearrangeViewType:g,outOfStockAction:b,scrollContainerRef:C,storeId:O,fbStatusFetcher:v}=h,[V,k]=r(d(j));s((()=>{var t;null===(t=null==C?void 0:C.current)||void 0===t||t.scrollTo({top:0}),m(j,O,y,v,"update"),k(d(j))}),[j]);return t(c,Object.assign({onDragEnd:t=>{if(!t.destination)return;const e=V,[o]=e.splice(t.source.index,1);e.splice(t.destination.index,0,o),e.forEach(((t,e)=>{t.displayOrder=e})),k(e)}},{children:[t(p,{children:[e(n,{Icon:o,width:16,height:16,color:i.content.secondary,onClick:()=>{S("collections")}}),e(l,Object.assign({color:i.content.secondary},{children:"All Products"}))]}),Object.keys(j).length>0?"list"===g?e(u,{selectedVariants:V,setSelectedVariants:k,selectedCollectionsDispatch:y,outOfStockAction:b}):e(f,{selectedVariants:V,setSelectedVariants:k,selectedCollectionsDispatch:y}):e(a,{title:"No Products Selected",subtitle:"Selected products will appear here"})]}))};export{h as RearrangeScreen};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{cloneDeep as t}from"lodash";import{createContext as a}from"react";function e(a,e){var o,c,s,d,n,l;let r={},i="",u="",p="";switch(e.type){case"selected":return console.log("vj: selectedColectionsReducer selected",e),r=t(a),e.data.val.isSmartCollection&&(e.data.isRestricted&&(r={}),r.isCustom=!0),r[e.data.id]=e.data.val,r;case"unselected":return r=t(a),(null==r?void 0:r.isCustom)&&(r.isCustom=!1),delete r[e.data.id],r;case"productUnselected":return r=t(a),i=e.data.productId,u=e.data.collectionId,delete r[u].products[i],Object.keys(r[u].products).length||((null==r?void 0:r.isCustom)&&(r.isCustom=!1),delete r[u]),r;case"productSelected":return r=t(a),i=e.data.productId,u=e.data.collectionId,(null===(o=e.data.catalogOnlyData)||void 0===o?void 0:o.isSmartCollection)&&(e.data.isRestricted&&(r={}),r.isCustom=!0),(null==r?void 0:r[u])||(r[u]=e.data.catalogOnlyData,r[u].products={}),r[u].products[i]=e.data.product,r;case"variantSelected":return r=t(a),i=e.data.productId,u=e.data.collectionId,p=e.data.variantId,(null===(c=e.data.catalogOnlyData)||void 0===c?void 0:c.isSmartCollection)&&(e.data.isRestricted&&(r={}),r.isCustom=!0),(null==r?void 0:r[u])||(r[u]=e.data.catalogOnlyData,r[u].products={},r[u].products[i]=e.data.productOnlyData,r[u].products[i].variants={}),(null===(d=null===(s=null==r?void 0:r[u])||void 0===s?void 0:s.products)||void 0===d?void 0:d[i])||((null===(n=null==r?void 0:r[u])||void 0===n?void 0:n.products)||(r[u].products={}),r[u].products[i]=e.data.productOnlyData,r[u].products[i].variants={}),r[u].products[i].variants[p]=e.data.variant,r;case"variantUnselected":return r=t(a),i=e.data.productId,u=e.data.collectionId,p=e.data.variantId,delete r[u].products[i].variants[p],Object.keys(r[u].products[i].variants).length||(delete r[u].products[i],Object.keys(r[u].products).length||((null===(l=r[u])||void 0===l?void 0:l.isSmartCollection)&&(r.isCustom=!1),delete r[u])),r;case"
|
|
1
|
+
import{cloneDeep as t}from"lodash";import{createContext as a}from"react";function e(a,e){var o,c,s,d,n,l;let r={},i="",u="",p="";switch(e.type){case"selected":return console.log("vj: selectedColectionsReducer selected",e),r=t(a),e.data.val.isSmartCollection&&(e.data.isRestricted&&(r={}),r.isCustom=!0),r[e.data.id]=e.data.val,r;case"unselected":return r=t(a),(null==r?void 0:r.isCustom)&&(r.isCustom=!1),delete r[e.data.id],r;case"productUnselected":return r=t(a),i=e.data.productId,u=e.data.collectionId,delete r[u].products[i],Object.keys(r[u].products).length||((null==r?void 0:r.isCustom)&&(r.isCustom=!1),delete r[u]),r;case"productSelected":return r=t(a),i=e.data.productId,u=e.data.collectionId,(null===(o=e.data.catalogOnlyData)||void 0===o?void 0:o.isSmartCollection)&&(e.data.isRestricted&&(r={}),r.isCustom=!0),(null==r?void 0:r[u])||(r[u]=e.data.catalogOnlyData,r[u].products={}),r[u].products[i]=e.data.product,r;case"variantSelected":return r=t(a),i=e.data.productId,u=e.data.collectionId,p=e.data.variantId,(null===(c=e.data.catalogOnlyData)||void 0===c?void 0:c.isSmartCollection)&&(e.data.isRestricted&&(r={}),r.isCustom=!0),(null==r?void 0:r[u])||(r[u]=e.data.catalogOnlyData,r[u].products={},r[u].products[i]=e.data.productOnlyData,r[u].products[i].variants={}),(null===(d=null===(s=null==r?void 0:r[u])||void 0===s?void 0:s.products)||void 0===d?void 0:d[i])||((null===(n=null==r?void 0:r[u])||void 0===n?void 0:n.products)||(r[u].products={}),r[u].products[i]=e.data.productOnlyData,r[u].products[i].variants={}),r[u].products[i].variants[p]=e.data.variant,r;case"variantUnselected":return r=t(a),i=e.data.productId,u=e.data.collectionId,p=e.data.variantId,delete r[u].products[i].variants[p],Object.keys(r[u].products[i].variants).length||(delete r[u].products[i],Object.keys(r[u].products).length||((null===(l=r[u])||void 0===l?void 0:l.isSmartCollection)&&(r.isCustom=!1),delete r[u])),r;case"update":default:return a;case"reset":return{}}}function o(t,a){let e={};switch(a.type){case"fetched":return e=Object.assign({},a.data),e;case"productsFetched":return console.log("vj: productsFetched",{collections:t,action:a}),e=Object.assign({},t),e[a.data.collectionId].products=a.data.products,console.log("vj: collectionsCopy",{collectionsCopy:e}),e;case"paged":return console.log("vj: paged",{collections:t,action:a}),e=Object.assign(Object.assign({},t),a.data),e;case"productsPaged":return console.log("vj: pagedProducts",{collections:t,action:a}),e=Object.assign({},t),a.data.collectionId,e[a.data.collectionId].products=Object.assign(Object.assign({},e[a.data.collectionId].products),a.data.products),e;default:return{}}}function c(t,a){let e={};switch(a.type){case"paginate":console.log("vj: paginate",a),e=Object.assign({},t);for(const t in a.data)if(Object.prototype.hasOwnProperty.call(a.data,t)){const o=a.data[t];if(Object.prototype.hasOwnProperty.call(e,t)){const a=e[t];e[t]=Object.assign(Object.assign({},a),{products:Object.assign(Object.assign({},a.products),o.products)})}else e[t]=o}return console.log("vj: collections copy",e),e;case"update":return console.log("vj: update",a),e=Object.assign({},t),console.log("vj: update collection",a),e;case"set":return e=Object.assign(Object.assign({},t),a.data),console.log("vj: update collection",a),e;case"filter":e={};for(const o in t)if(o in a.data){const c=Object.assign({},t[o]),s=a.data[o],d={};for(const t in c.products)if(t in s.products){const a=Object.assign({},c.products[t]),e=s.products[t],o={};for(const t in a.variants)t in e.variants&&(o[t]=Object.assign({},a.variants[t]));Object.keys(o).length>0&&(a.variants=o,d[t]=a)}Object.keys(d).length>0&&(c.products=d,e[o]=c)}return e;default:return t}}function s(t,a){return"set"===a.type?a.data:t}const d=a("");export{d as CollectionIdContext,o as collectionsReducer,c as paginationReducer,s as searchReducer,e as selectedColectionsReducer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as
|
|
1
|
+
import{jsxs as o,jsx as t,Fragment as e}from"react/jsx-runtime";import i from"../../assets/icons/arrow_left.svg.js";import{useEffect as r}from"react";import{IconButton as c}from"../icon-button/IconButton.js";import{BodyCaption as l}from"../TypographyStyle.js";import{EmptyState as s}from"./emptyState.js";import{ProductGroup as d}from"./productScreen.js";import{SelectedScreenHeader as n}from"./style.js";import{fetchFbStatusCollection as u,liftTheStateUp as a}from"./utility.js";const p=p=>{const{customCollectionRestriction:v,selectedCollections:h,searchedCollections:m,searchedCollectionsDispatch:f,selectedCollectionsDispatch:y,setScreen:j,collections:k,onBackPress:b,hideVariantCheckbox:C,pickerType:O,hideProductVariants:P,hideProductCheckbox:g,storeId:x,fbStatusFetcher:S}=p;r((()=>{u(m,x,f,S,"set")}),[m]);const I=(o,t)=>{var e,i,r,c,l,s,d,n,u;let a=0,p=0;return!!((null===(i=null===(e=null==h?void 0:h[o])||void 0===e?void 0:e.products)||void 0===i?void 0:i[t])&&(null===(s=Object.keys((null===(l=null===(c=null===(r=null==k?void 0:k[o])||void 0===r?void 0:r.products)||void 0===c?void 0:c[t])||void 0===l?void 0:l.variants)||[]))||void 0===s||s.forEach((()=>p++)),Object.keys((null===(u=null===(n=null===(d=null==h?void 0:h[o])||void 0===d?void 0:d.products)||void 0===n?void 0:n[t])||void 0===u?void 0:u.variants)||[]).forEach((()=>a++)),a>0&&p!==a))};return o("div",{children:[o(n,{children:[t(c,{Icon:i,onClick:()=>{j("collections"),b()}}),t(l,{children:"Searched Products"})]}),t("div",{children:Object.keys(m).length?t(e,{children:Object.keys(m).map((o=>{var e;return Object.keys((null===(e=null==m?void 0:m[o])||void 0===e?void 0:e.products)||[]).map((e=>{let i=!1;return(null==m?void 0:m.isCustom)&&(i=!0),t(d,{collectionId:o,upliftAdditions:(t,e)=>((o,t,e)=>{const i=a(e,m[o]);y({type:t,data:Object.assign(Object.assign({},i),{isRestricted:v})})})(o,t,e),productId:e,data:m[o].products[e],isProductPartiallyChecked:I(o,e),selectedData:h,selectedCollectionsDispatch:y,viewOnly:i,hideProductCheckbox:g,hideVariantCheckbox:C,hideProductVariants:P,pickerType:O},e)}))}))}):t(s,{title:"No search results found",subtitle:"We couldn’t find the product you were looking for."})})]})};export{p as SearchScreen};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as
|
|
1
|
+
import{jsxs as e,jsx as t,Fragment as o}from"react/jsx-runtime";import r from"../../assets/icons/arrow_left.svg.js";import{useRef as l,useReducer as n,useEffect as c}from"react";import{IconButton as i}from"../icon-button/IconButton.js";import{BodyCaption as s}from"../TypographyStyle.js";import{EmptyState as d}from"./emptyState.js";import{ProductGroup as u}from"./productScreen.js";import{paginationReducer as a}from"./reducers.js";import{SelectedScreenHeader as v}from"./style.js";import{paginateSelectedItems as p,fetchFbStatusCollection as m}from"./utility.js";const f=f=>{const{selectedCollections:j,selectedCollectionsDispatch:g,setScreen:h,collections:y,outOfStockAction:b,storeId:S,fbStatusFetcher:k}=f,O=l(0),C=l(null),[I,P]=n(a,{});c((()=>{O.current=0;const e=p(j,10,0);P({type:"paginate",data:e}),m(e,S,P,k,"set"),O.current+=1}),[]),c((()=>{P({type:"filter",data:j})}),[j]),c((()=>{console.log("vj: observertarget",C.current);const e=new IntersectionObserver((e=>{if(console.log("vj: observertargetinside",e),e[0].isIntersecting&&(console.log("vj: nextPageRef",O.current),O.current>0)){const e=p(j,10,O.current);console.log("paginated inside observer target",{paginatedProducts:e,selectedCollections:j,curScreenData:I}),P({type:"paginate",data:e}),m(e,S,P,k,"update"),O.current+=1}}),{threshold:1});return C.current&&e.observe(C.current),()=>{C.current&&e.unobserve(C.current)}}),[C,j]);const w=(e,t)=>{var o,r,l,n,c,i,s,d,u;let a=0,v=0;return!!((null===(r=null===(o=null==j?void 0:j[e])||void 0===o?void 0:o.products)||void 0===r?void 0:r[t])&&(null===(i=Object.keys((null===(c=null===(n=null===(l=null==y?void 0:y[e])||void 0===l?void 0:l.products)||void 0===n?void 0:n[t])||void 0===c?void 0:c.variants)||[]))||void 0===i||i.forEach((()=>v++)),Object.keys((null===(u=null===(d=null===(s=null==j?void 0:j[e])||void 0===s?void 0:s.products)||void 0===d?void 0:d[t])||void 0===u?void 0:u.variants)||[]).forEach((()=>a++)),a>0&&v!==a))};return e("div",{children:[e(v,{children:[t(i,{Icon:r,onClick:()=>{h("collections")}}),t(s,{children:"Selected Products"})]}),e("div",{children:[Object.keys(I).length>0?t(o,{children:Object.keys(I).map((e=>{var o;return Object.keys((null===(o=null==I?void 0:I[e])||void 0===o?void 0:o.products)||[]).map((o=>{let r=!1;return(null==I?void 0:I.isCustom)&&(r=!0),t(u,{upliftAdditions:null,collectionId:e,productId:o,data:I[e].products[o],isProductPartiallyChecked:w(e,o),selectedData:j,selectedCollectionsDispatch:g,viewOnly:r,outOfStockAction:b},o)}))}))}):t(d,{title:"No Products Selected",subtitle:"Select products will appear here"}),t("div",{ref:C})]})]})};export{f as SelectedScreen};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Collection, SelectedItems } from './modal';
|
|
1
|
+
import { Collection, FbStatusFetcherReturn, SelectedItems } from './modal';
|
|
2
2
|
export declare const liftTheStateUp: (payload: any, data: any) => any;
|
|
3
3
|
export declare function paginateSelectedItems(selectedItems: SelectedItems, limit: number, offset: number): {
|
|
4
4
|
[key: string]: Collection;
|
|
5
5
|
};
|
|
6
|
+
export declare const fetchFbStatusCollection: (data: SelectedItems, storeId: string, dispatcher: any, fbStatusFetcher?: ((storeId: string, variantIds: string[]) => FbStatusFetcherReturn) | undefined, dispatchType?: string) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{cloneDeep as
|
|
1
|
+
import{cloneDeep as o}from"lodash";const t=(t,n)=>{const l=o(n);if(delete l.products,(t=Object.assign(Object.assign({},t),{catalogOnlyData:l})).productId&&n.products){const d=o(n.products[t.productId]);(null==d?void 0:d.variants)&&delete d.variants,t=Object.assign(Object.assign({},t),{catalogOnlyData:l,productOnlyData:d})}return t};function n(o,t,n){var d;const i={};let s=0;console.log("paginated offset",n);for(const c in o)if(Object.prototype.hasOwnProperty.call(o,c)){const v=o[c],a=l(v.products,t,n-s);a&&Object.keys(a).length>0&&(i[c]=Object.assign(Object.assign({},v),{products:a})),s+=Object.keys(null!==(d=v.products)&&void 0!==d?d:{}).length}return i}function l(o,t,n){if(!o)return{};const l=Object.keys(o).slice(n,n+t),d={};return l.forEach((t=>{d[t]=o[t]})),d}const d=(o,t,n)=>{Object.keys(o).forEach((t=>{var n,l;const d=null!==(l=null===(n=o[t])||void 0===n?void 0:n.products)&&void 0!==l?l:{};Object.keys(d).forEach((n=>{var l,d,i,s;const c=null!==(s=null===(i=null===(d=null===(l=o[t])||void 0===l?void 0:l.products)||void 0===d?void 0:d[n])||void 0===i?void 0:i.variants)&&void 0!==s?s:{};Object.keys(c).forEach((l=>{var d,i,s,c;const v=null===(c=null===(s=null===(i=null===(d=o[t])||void 0===d?void 0:d.products)||void 0===i?void 0:i[n])||void 0===s?void 0:s.variants)||void 0===c?void 0:c[l];v&&!v.fbStatus&&(v.fbStatus="APPROVED")}))}))})),t({type:n,data:o})},i=function(o,t,n,l){let i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"paged";l||d(o,n,i);const s=(o=>{const t=[];return Object.keys(o).forEach((n=>{var l,d;const i=null!==(d=null===(l=o[n])||void 0===l?void 0:l.products)&&void 0!==d?d:{};Object.keys(i).forEach((l=>{var d,i,s,c;const v=null!==(c=null===(s=null===(i=null===(d=o[n])||void 0===d?void 0:d.products)||void 0===i?void 0:i[l])||void 0===s?void 0:s.variants)&&void 0!==c?c:{};Object.keys(v).forEach((d=>{var i,s,c,v;const a=null===(v=null===(c=null===(s=null===(i=o[n])||void 0===i?void 0:i.products)||void 0===s?void 0:s[l])||void 0===c?void 0:c.variants)||void 0===v?void 0:v[d];(null==a?void 0:a.fbStatus)||t.push(d)}))}))})),t})(o);console.log("vj: variantids",s),s.length>0&&l&&l(t,s).then((t=>{const l=Object.assign({},o);Object.keys(l).forEach((o=>{var n,d;const i=null!==(d=null===(n=l[o])||void 0===n?void 0:n.products)&&void 0!==d?d:{};Object.keys(i).forEach((n=>{var d,i,s,c;const v=null!==(c=null===(s=null===(i=null===(d=l[o])||void 0===d?void 0:d.products)||void 0===i?void 0:i[n])||void 0===s?void 0:s.variants)&&void 0!==c?c:{};Object.keys(v).forEach((d=>{var i,s,c,v;const a=null===(v=null===(c=null===(s=null===(i=l[o])||void 0===i?void 0:i.products)||void 0===s?void 0:s[n])||void 0===c?void 0:c.variants)||void 0===v?void 0:v[d];a&&"REJECTED"===t[d]?a.fbStatus="REJECTED":a&&"APPROVED"===t[d]&&(a.fbStatus="APPROVED")}))}))})),console.log("updated data",l,i),n({type:i,data:l})})).catch((t=>{console.error("Error in fbStatusFetcher",t),d(o,n,i)}))};export{i as fetchFbStatusCollection,t as liftTheStateUp,n as paginateSelectedItems};
|
package/package.json
CHANGED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { FbStatusFetcherReturn, SelectedItems } from './modal';
|
|
2
|
-
export declare const fetchFbStatus: (data: SelectedItems, storeId: string, dispatchCurScreenData: any, fbStatusFetcher?: ((storeId: string, variantIds: string[]) => FbStatusFetcherReturn) | undefined, set?: boolean) => void;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { FbStatusFetcherReturn, SelectedItems } from './modal';
|
|
2
|
-
import { SelectedCollectionsActions } from './reducers';
|
|
3
|
-
export declare const useFetchFbStatusForCollections: (data: SelectedItems, storeId: string, selectedCollectionsDispatch: React.Dispatch<SelectedCollectionsActions>, fbStatusFetcher?: ((storeId: string, variantIds: string[]) => FbStatusFetcherReturn) | undefined, autoFetch?: boolean, setSearchedCollections?: React.Dispatch<React.SetStateAction<SelectedItems | undefined>>) => {
|
|
4
|
-
fetchFbStatus: () => void;
|
|
5
|
-
};
|
|
6
|
-
export declare const fetchFbStatusCollection: (data: SelectedItems, storeId: string, dispatcher: any, fbStatusFetcher?: ((storeId: string, variantIds: string[]) => FbStatusFetcherReturn) | undefined, dispatchType?: string) => void;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const o=(o,v,d)=>{Object.keys(o).forEach((v=>{var d,l;const i=null!==(l=null===(d=o[v])||void 0===d?void 0:d.products)&&void 0!==l?l:{};Object.keys(i).forEach((d=>{var l,i,t,n;const s=null!==(n=null===(t=null===(i=null===(l=o[v])||void 0===l?void 0:l.products)||void 0===i?void 0:i[d])||void 0===t?void 0:t.variants)&&void 0!==n?n:{};Object.keys(s).forEach((l=>{var i,t,n,s;const u=null===(s=null===(n=null===(t=null===(i=o[v])||void 0===i?void 0:i.products)||void 0===t?void 0:t[d])||void 0===n?void 0:n.variants)||void 0===s?void 0:s[l];u&&!u.fbStatus&&(u.fbStatus="APPROVED")}))}))})),v({type:d,data:o})};exports.fetchFbStatusCollection=function(v,d,l,i){let t=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"paged";i||o(v,l,t);const n=(o=>{const v=[];return Object.keys(o).forEach((d=>{var l,i;const t=null!==(i=null===(l=o[d])||void 0===l?void 0:l.products)&&void 0!==i?i:{};Object.keys(t).forEach((l=>{var i,t,n,s;const u=null!==(s=null===(n=null===(t=null===(i=o[d])||void 0===i?void 0:i.products)||void 0===t?void 0:t[l])||void 0===n?void 0:n.variants)&&void 0!==s?s:{};Object.keys(u).forEach((i=>{var t,n,s,u;const c=null===(u=null===(s=null===(n=null===(t=o[d])||void 0===t?void 0:t.products)||void 0===n?void 0:n[l])||void 0===s?void 0:s.variants)||void 0===u?void 0:u[i];(null==c?void 0:c.fbStatus)||v.push(i)}))}))})),v})(v);console.log("vj: variantids",n),n.length>0&&i&&i(d,n).then((o=>{const d=Object.assign({},v);Object.keys(d).forEach((v=>{var l,i;const t=null!==(i=null===(l=d[v])||void 0===l?void 0:l.products)&&void 0!==i?i:{};Object.keys(t).forEach((l=>{var i,t,n,s;const u=null!==(s=null===(n=null===(t=null===(i=d[v])||void 0===i?void 0:i.products)||void 0===t?void 0:t[l])||void 0===n?void 0:n.variants)&&void 0!==s?s:{};Object.keys(u).forEach((i=>{var t,n,s,u;const c=null===(u=null===(s=null===(n=null===(t=d[v])||void 0===t?void 0:t.products)||void 0===n?void 0:n[l])||void 0===s?void 0:s.variants)||void 0===u?void 0:u[i];c&&"REJECTED"===o[i]?c.fbStatus="REJECTED":c&&"APPROVED"===o[i]&&(c.fbStatus="APPROVED")}))}))})),console.log("updated data",d),l({type:t,data:d})})).catch((d=>{console.error("Error in fbStatusFetcher",d),o(v,l,t)}))},exports.useFetchFbStatusForCollections=function(o,v,d,l){let i=arguments.length>5?arguments[5]:void 0;const t=()=>{if(!l){const v=Object.assign({},o);Object.keys(v).forEach((o=>{var d,l;const i=null!==(l=null===(d=v[o])||void 0===d?void 0:d.products)&&void 0!==l?l:{};Object.keys(i).forEach((d=>{var l,i,t,n;const s=null!==(n=null===(t=null===(i=null===(l=v[o])||void 0===l?void 0:l.products)||void 0===i?void 0:i[d])||void 0===t?void 0:t.variants)&&void 0!==n?n:{};Object.keys(s).forEach((l=>{var i,t,n,s;const u=null===(s=null===(n=null===(t=null===(i=v[o])||void 0===i?void 0:i.products)||void 0===t?void 0:t[d])||void 0===n?void 0:n.variants)||void 0===s?void 0:s[l];u&&(u.fbStatus="APPROVED")}))}))})),i?i(v):d({type:"paged",data:v})}const t=(()=>{const v=[];return Object.keys(o).forEach((d=>{var l,i;const t=null!==(i=null===(l=o[d])||void 0===l?void 0:l.products)&&void 0!==i?i:{};Object.keys(t).forEach((l=>{var i,t,n,s;const u=null!==(s=null===(n=null===(t=null===(i=o[d])||void 0===i?void 0:i.products)||void 0===t?void 0:t[l])||void 0===n?void 0:n.variants)&&void 0!==s?s:{};Object.keys(u).forEach((i=>{var t,n,s,u;const c=null===(u=null===(s=null===(n=null===(t=o[d])||void 0===t?void 0:t.products)||void 0===n?void 0:n[l])||void 0===s?void 0:s.variants)||void 0===u?void 0:u[i];(null==c?void 0:c.fbStatus)||v.push(i)}))}))})),v})();console.log("vj: variantids",t),t.length>0&&l&&l(v,t).then((v=>{const l=Object.assign({},o);Object.keys(l).forEach((o=>{var d,i;const t=null!==(i=null===(d=l[o])||void 0===d?void 0:d.products)&&void 0!==i?i:{};Object.keys(t).forEach((d=>{var i,t,n,s;const u=null!==(s=null===(n=null===(t=null===(i=l[o])||void 0===i?void 0:i.products)||void 0===t?void 0:t[d])||void 0===n?void 0:n.variants)&&void 0!==s?s:{};Object.keys(u).forEach((i=>{var t,n,s,u;const c=null===(u=null===(s=null===(n=null===(t=l[o])||void 0===t?void 0:t.products)||void 0===n?void 0:n[d])||void 0===s?void 0:s.variants)||void 0===u?void 0:u[i];c&&"REJECTED"===v[i]?c.fbStatus="REJECTED":c&&"APPROVED"===v[i]&&(c.fbStatus="APPROVED")}))}))})),console.log("variantids",l),i?i(l):d({type:"paged",data:l})})).catch((v=>{const l=Object.assign({},o);Object.keys(l).forEach((o=>{var v,d;const i=null!==(d=null===(v=l[o])||void 0===v?void 0:v.products)&&void 0!==d?d:{};Object.keys(i).forEach((v=>{var d,i,t,n;const s=null!==(n=null===(t=null===(i=null===(d=l[o])||void 0===d?void 0:d.products)||void 0===i?void 0:i[v])||void 0===t?void 0:t.variants)&&void 0!==n?n:{};Object.keys(s).forEach((d=>{var i,t,n,s;const u=null===(s=null===(n=null===(t=null===(i=l[o])||void 0===i?void 0:i.products)||void 0===t?void 0:t[v])||void 0===n?void 0:n.variants)||void 0===s?void 0:s[d];u&&(u.fbStatus="APPROVED")}))}))})),console.log("vj: variantids",l),i?i(l):d({type:"paged",data:l})}))};return(!(arguments.length>4&&void 0!==arguments[4])||arguments[4])&&t(),{fetchFbStatus:t}};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { FbStatusFetcherReturn, SelectedItems } from './modal';
|
|
2
|
-
export declare const fetchFbStatus: (data: SelectedItems, storeId: string, dispatchCurScreenData: any, fbStatusFetcher?: ((storeId: string, variantIds: string[]) => FbStatusFetcherReturn) | undefined, set?: boolean) => void;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { FbStatusFetcherReturn, SelectedItems } from './modal';
|
|
2
|
-
import { SelectedCollectionsActions } from './reducers';
|
|
3
|
-
export declare const useFetchFbStatusForCollections: (data: SelectedItems, storeId: string, selectedCollectionsDispatch: React.Dispatch<SelectedCollectionsActions>, fbStatusFetcher?: ((storeId: string, variantIds: string[]) => FbStatusFetcherReturn) | undefined, autoFetch?: boolean, setSearchedCollections?: React.Dispatch<React.SetStateAction<SelectedItems | undefined>>) => {
|
|
4
|
-
fetchFbStatus: () => void;
|
|
5
|
-
};
|
|
6
|
-
export declare const fetchFbStatusCollection: (data: SelectedItems, storeId: string, dispatcher: any, fbStatusFetcher?: ((storeId: string, variantIds: string[]) => FbStatusFetcherReturn) | undefined, dispatchType?: string) => void;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const o=function(o,v,d,l){let i=arguments.length>5?arguments[5]:void 0;const t=()=>{if(!l){const v=Object.assign({},o);Object.keys(v).forEach((o=>{var d,l;const i=null!==(l=null===(d=v[o])||void 0===d?void 0:d.products)&&void 0!==l?l:{};Object.keys(i).forEach((d=>{var l,i,t,n;const s=null!==(n=null===(t=null===(i=null===(l=v[o])||void 0===l?void 0:l.products)||void 0===i?void 0:i[d])||void 0===t?void 0:t.variants)&&void 0!==n?n:{};Object.keys(s).forEach((l=>{var i,t,n,s;const a=null===(s=null===(n=null===(t=null===(i=v[o])||void 0===i?void 0:i.products)||void 0===t?void 0:t[d])||void 0===n?void 0:n.variants)||void 0===s?void 0:s[l];a&&(a.fbStatus="APPROVED")}))}))})),i?i(v):d({type:"paged",data:v})}const t=(()=>{const v=[];return Object.keys(o).forEach((d=>{var l,i;const t=null!==(i=null===(l=o[d])||void 0===l?void 0:l.products)&&void 0!==i?i:{};Object.keys(t).forEach((l=>{var i,t,n,s;const a=null!==(s=null===(n=null===(t=null===(i=o[d])||void 0===i?void 0:i.products)||void 0===t?void 0:t[l])||void 0===n?void 0:n.variants)&&void 0!==s?s:{};Object.keys(a).forEach((i=>{var t,n,s,a;const u=null===(a=null===(s=null===(n=null===(t=o[d])||void 0===t?void 0:t.products)||void 0===n?void 0:n[l])||void 0===s?void 0:s.variants)||void 0===a?void 0:a[i];(null==u?void 0:u.fbStatus)||v.push(i)}))}))})),v})();console.log("vj: variantids",t),t.length>0&&l&&l(v,t).then((v=>{const l=Object.assign({},o);Object.keys(l).forEach((o=>{var d,i;const t=null!==(i=null===(d=l[o])||void 0===d?void 0:d.products)&&void 0!==i?i:{};Object.keys(t).forEach((d=>{var i,t,n,s;const a=null!==(s=null===(n=null===(t=null===(i=l[o])||void 0===i?void 0:i.products)||void 0===t?void 0:t[d])||void 0===n?void 0:n.variants)&&void 0!==s?s:{};Object.keys(a).forEach((i=>{var t,n,s,a;const u=null===(a=null===(s=null===(n=null===(t=l[o])||void 0===t?void 0:t.products)||void 0===n?void 0:n[d])||void 0===s?void 0:s.variants)||void 0===a?void 0:a[i];u&&"REJECTED"===v[i]?u.fbStatus="REJECTED":u&&"APPROVED"===v[i]&&(u.fbStatus="APPROVED")}))}))})),console.log("variantids",l),i?i(l):d({type:"paged",data:l})})).catch((v=>{const l=Object.assign({},o);Object.keys(l).forEach((o=>{var v,d;const i=null!==(d=null===(v=l[o])||void 0===v?void 0:v.products)&&void 0!==d?d:{};Object.keys(i).forEach((v=>{var d,i,t,n;const s=null!==(n=null===(t=null===(i=null===(d=l[o])||void 0===d?void 0:d.products)||void 0===i?void 0:i[v])||void 0===t?void 0:t.variants)&&void 0!==n?n:{};Object.keys(s).forEach((d=>{var i,t,n,s;const a=null===(s=null===(n=null===(t=null===(i=l[o])||void 0===i?void 0:i.products)||void 0===t?void 0:t[v])||void 0===n?void 0:n.variants)||void 0===s?void 0:s[d];a&&(a.fbStatus="APPROVED")}))}))})),console.log("vj: variantids",l),i?i(l):d({type:"paged",data:l})}))};return(!(arguments.length>4&&void 0!==arguments[4])||arguments[4])&&t(),{fetchFbStatus:t}},v=(o,v,d)=>{Object.keys(o).forEach((v=>{var d,l;const i=null!==(l=null===(d=o[v])||void 0===d?void 0:d.products)&&void 0!==l?l:{};Object.keys(i).forEach((d=>{var l,i,t,n;const s=null!==(n=null===(t=null===(i=null===(l=o[v])||void 0===l?void 0:l.products)||void 0===i?void 0:i[d])||void 0===t?void 0:t.variants)&&void 0!==n?n:{};Object.keys(s).forEach((l=>{var i,t,n,s;const a=null===(s=null===(n=null===(t=null===(i=o[v])||void 0===i?void 0:i.products)||void 0===t?void 0:t[d])||void 0===n?void 0:n.variants)||void 0===s?void 0:s[l];a&&!a.fbStatus&&(a.fbStatus="APPROVED")}))}))})),v({type:d,data:o})},d=function(o,d,l,i){let t=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"paged";i||v(o,l,t);const n=(o=>{const v=[];return Object.keys(o).forEach((d=>{var l,i;const t=null!==(i=null===(l=o[d])||void 0===l?void 0:l.products)&&void 0!==i?i:{};Object.keys(t).forEach((l=>{var i,t,n,s;const a=null!==(s=null===(n=null===(t=null===(i=o[d])||void 0===i?void 0:i.products)||void 0===t?void 0:t[l])||void 0===n?void 0:n.variants)&&void 0!==s?s:{};Object.keys(a).forEach((i=>{var t,n,s,a;const u=null===(a=null===(s=null===(n=null===(t=o[d])||void 0===t?void 0:t.products)||void 0===n?void 0:n[l])||void 0===s?void 0:s.variants)||void 0===a?void 0:a[i];(null==u?void 0:u.fbStatus)||v.push(i)}))}))})),v})(o);console.log("vj: variantids",n),n.length>0&&i&&i(d,n).then((v=>{const d=Object.assign({},o);Object.keys(d).forEach((o=>{var l,i;const t=null!==(i=null===(l=d[o])||void 0===l?void 0:l.products)&&void 0!==i?i:{};Object.keys(t).forEach((l=>{var i,t,n,s;const a=null!==(s=null===(n=null===(t=null===(i=d[o])||void 0===i?void 0:i.products)||void 0===t?void 0:t[l])||void 0===n?void 0:n.variants)&&void 0!==s?s:{};Object.keys(a).forEach((i=>{var t,n,s,a;const u=null===(a=null===(s=null===(n=null===(t=d[o])||void 0===t?void 0:t.products)||void 0===n?void 0:n[l])||void 0===s?void 0:s.variants)||void 0===a?void 0:a[i];u&&"REJECTED"===v[i]?u.fbStatus="REJECTED":u&&"APPROVED"===v[i]&&(u.fbStatus="APPROVED")}))}))})),console.log("updated data",d),l({type:t,data:d})})).catch((d=>{console.error("Error in fbStatusFetcher",d),v(o,l,t)}))};export{d as fetchFbStatusCollection,o as useFetchFbStatusForCollections};
|