@bikdotai/bik-component-library 0.0.455-beta.ppi-29 → 0.0.455-beta.ppi-31
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/product-picker-v2/productScreen.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/esm/components/product-picker-v2/productScreen.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/package.json +1 -1
|
@@ -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("../../assets/icons/box.svg.js"),c=require("../../assets/icons/search.svg.js"),i=require("lodash"),n=require("react"),s=require("../../constants/Theme.js"),r=require("../../assets/icons/info.svg.js"),l=require("../checkBox/CheckBox.js"),d=require("../icon-button/IconButton.js"),a=require("../input/Input.js"),u=require("../shimmer/ShimmerComponent/BikShimmer.js"),h=require("../shimmer-image/ShimmerImage.js"),v=require("../spinner/Spinner.js"),p=require("../tooltips/Tooltip.js"),j=require("../TypographyStyle.js"),g=require("./emptyState.js"),b=require("./ProductPickerTag.js"),f=require("./reducers.js"),x=require("./style.js"),y=require("./type.js"),I=require("./utility.js");const k=t=>{const{collectionId:o,productId:c,data:i,selectedData:n,selectedCollectionsDispatch:s,viewOnly:r,upliftAdditions:l,isProductPartiallyChecked:d,hideProductCheckbox:a,outOfStockAction:u,hideVariantCheckbox:h,hideProductVariants:v,pickerType:p,onInfoIconClick:j,showProductDetailInfoIcon:g}=t,b=e=>{var t,i,s,r,l,d;if(!(null===(i=null===(t=null==n?void 0:n[o])||void 0===t?void 0:t.products)||void 0===i?void 0:i[c]))return!1;return!!(null===(d=null===(l=null===(r=null===(s=null==n?void 0:n[o])||void 0===s?void 0:s.products)||void 0===r?void 0:r[c])||void 0===l?void 0:l.variants)||void 0===d?void 0:d[e])};return e.jsxs("div",{children:[e.jsx(O,{isVariant:!1,data:i,productId:c,collectionId:o,isSelected:!!(null===(x=null===(f=null==n?void 0:n[o])||void 0===f?void 0:f.products)||void 0===x?void 0:x[c]),isPartiallyChecked:d,selectedCollectionsDispatch:s,upliftAdditions:l,viewOnly:r,hideProductCheckbox:a,hideVariantCheckbox:h,hideProductVariants:v,pickerType:p,outOfStockAction:u,onInfoIconClick:j,showProductDetailInfoIcon:g},c),v?null:(()=>{const e=Object.keys(i.variants||[]);let t=!1;return!(e.length<=1)||(e.forEach((e=>{var o,c;t=null!==(c=null===(o=i.variants)||void 0===o?void 0:o[e].name.includes(i.name))&&void 0!==c&&c})),!t)})()&&Object.keys(i.variants||[]).map((t=>e.jsx(O,{isVariant:!0,hideVariantCheckbox:h,data:i.variants[t],variantId:t,productId:c,viewOnly:r,upliftAdditions:l,collectionId:o,isSelected:b(t),selectedCollectionsDispatch:s,outOfStockAction:u,onInfoIconClick:j,showProductDetailInfoIcon:g},t)))]});var f,x},O=t=>{const{isVariant:o,data:c,productId:i,collectionId:n,variantId:a,isSelected:u,selectedCollectionsDispatch:v,viewOnly:g,upliftAdditions:f,isPartiallyChecked:y,hideProductCheckbox:I,outOfStockAction:k,hideVariantCheckbox:O,hideProductVariants:C,pickerType:m,onInfoIconClick:P,showProductDetailInfoIcon:S}=t;return e.jsxs(x.ProductCardStyle,Object.assign({isVariant:o,onClick:e=>{"PRODUCT"===m&&C&&(e.stopPropagation(),v({type:"reset",data:{}}),f("variantSelected",{productId:i,variantId:a||Object.keys(c.variants)[0],collectionId:n,variant:c}))},isActive:u},{children:[o&&!g&&!O||!o&&!g&&!I?e.jsx(l.CheckBox,{isChecked:u,isPartiallyChecked:y||!1,onValueChange:function(e){o?e?f("variantSelected",{productId:i,variantId:a,collectionId:n,variant:c}):v({type:"variantUnselected",data:{productId:i,variantId:a,collectionId:n}}):e?f("productSelected",{productId:i,collectionId:n,product:c}):v({type:"productUnselected",data:{productId:i,collectionId:n}})}}):e.jsx(e.Fragment,{}),e.jsx("div",{children:e.jsx(h.ShimmerImage,{width:40,height:40,imageUrl:c.image,alt:"Item",borderRadius:4})}),e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",flex:1}},{children:[e.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"space-between"}},{children:[e.jsx(p.Tooltip,Object.assign({variant:"light",body:c.name,placement:"bottom",delay:400},{children:e.jsx(j.BodyPrimary,Object.assign({numberOfLines:1},{children:c.name}))})),S&&e.jsx(d.IconButton,{onClick:()=>{null==P||P(c)},Icon:()=>e.jsx(r.default,{width:20,height:20,color:s.COLORS.content.placeholder})})]})),e.jsx(b.ProductPickerTag,{isVariant:o,data:c,outOfStockAction:k})]}))]}))};exports.ProductCard=O,exports.ProductGroup=k,exports.ProductsScreen=r=>{const{data:h,collectionsDispatch:p,selectedData:b,selectedCollectionsDispatch:O,productFetcher:C,storeId:m,setScreen:P,setSaveDisabled:S,hideInCollectionSearch:A,customCollectionRestriction:E,hideProductCheckbox:T,outOfStockAction:V=y.OUT_OF_STOCK_ACTION.BLUR,hideVariantCheckbox:D=!1,selectProductsFromCustomCollection:w=!1,pickerType:q,hideProductVariants:R,fbStatusFetcher:B,onInfoIconClick:F,showProductDetailInfoIcon:L}=r,U=n.useContext(f.CollectionIdContext),_=n.useRef(null),H=n.useRef(0),[J,K]=n.useState(!1),[M,N]=n.useState(""),[W,z]=n.useState(!1),[G,Q]=n.useState(h),X=n.useRef(!1);n.useEffect((()=>{const e=setTimeout((()=>{M.length?(z(!0),r.searchInCollectionFetcher(m,U,M).then((e=>{const t=i.cloneDeep(h);t.products=e,Q(t);const o=I.getVariantIdsToFetchAtProductLevel(null!=e?e:{});$(o,null!=e?e:{},!0),S(!1),z(!1)}))):Q(h)}),800);return()=>clearTimeout(e)}),[M]),n.useEffect((()=>{var e,t,o,c,i,n,s,r;console.log("vj: collectionId change before",h,h.products,null===(t=Object.keys(null!==(e=h.products)&&void 0!==e?e:{}))||void 0===t?void 0:t.length,X),X.current=!1,H.current=Math.floor((null===(c=Object.keys(null!==(o=h.products)&&void 0!==o?o:{}))||void 0===c?void 0:c.length)/10);const l=I.getVariantIdsToFetchAtProductLevel(null!==(i=h.products)&&void 0!==i?i:{});$(l,null!==(n=h.products)&&void 0!==n?n:{}),console.log("vj: collectionId change after",h,h.products,null===(r=Object.keys(null!==(s=h.products)&&void 0!==s?s:{}))||void 0===r?void 0:r.length,X)}),[U]);const Y=!!E&&h.isSmartCollection,Z=e=>{var t,o,c,i,n,s,r,l;let d=0,a=0;return!!((null===(o=null===(t=null==h?void 0:h[U])||void 0===t?void 0:t.products)||void 0===o?void 0:o[e])&&(null===(n=Object.keys((null===(i=null===(c=null==h?void 0:h.products)||void 0===c?void 0:c[e])||void 0===i?void 0:i.variants)||[]))||void 0===n||n.forEach((()=>a++)),Object.keys((null===(l=null===(r=null===(s=null==b?void 0:b[U])||void 0===s?void 0:s.products)||void 0===r?void 0:r[e])||void 0===l?void 0:l.variants)||[]).forEach((()=>d++)),d>0&&a!==d))};n.useEffect((()=>{(null==h?void 0:h.products)||ee(10)}),[]);const $=(e,t,o)=>{console.log("fetchFbStatusAndDispatchProducts",{variantIdsToFetchFbStatus:e,fbStatusFetcher:B}),B||(o?I.markVariantsAsApprovedProductsLevel(t,p,U,G,Q):I.markVariantsAsApprovedProductsLevel(t,p,U)),e.length>0&&B&&B(m,e).then((e=>{const c=Object.assign({},t);Object.keys(t).forEach((o=>{var i,n;Object.keys(null!==(n=null===(i=null==t?void 0:t[o])||void 0===i?void 0:i.variants)&&void 0!==n?n:{}).forEach((i=>{var n,s;const r=null===(n=null==t?void 0:t[o].variants)||void 0===n?void 0:n[i];r&&"REJECTED"===e[i]?r.fbStatus="REJECTED":r&&"APPROVED"===e[i]&&(r.fbStatus="APPROVED");const l=null===(s=null==c?void 0:c[o])||void 0===s?void 0:s.variants;l&&l[i]&&(l[i]=r)}))})),o?(Q((e=>{const t=Object.assign({},e);return t.products=c,t})),p({type:"productsPaged",data:{collectionId:U,products:c}})):p({type:"productsPaged",data:{collectionId:U,products:c}})})).catch((e=>{o?I.markVariantsAsApprovedProductsLevel(t,p,U,G,Q):I.markVariantsAsApprovedProductsLevel(t,p,U)}))};n.useEffect((()=>{console.log("vj: observertarget",_.current);const e=new IntersectionObserver((e=>{console.log("vj: observertargetinside",e),e[0].isIntersecting&&(console.log("vj: nextPageRef",H.current,X),H.current>=0&&!X.current&&!M&&(S(!0),K(!0),C(U,m,10,H.current).then((e=>{if(console.log("vj: fetched products",e,X,Object.keys(e).length),Object.keys(e).length||(console.log("vj: setHasAllCollectionLoaded ",!0),X.current=!0),Object.keys(e).length){const t=G;t.products=Object.assign(Object.assign({},G.products),e),Q(t);const o=I.getVariantIdsToFetchAtProductLevel(e);$(o,e),H.current+=1}K(!1),S(!1)})).catch()))}),{threshold:1});return _.current&&e.observe(_.current),()=>{_.current&&e.unobserve(_.current)}}),[_,M]);const ee=e=>{console.log("vj: getProductsForCollection"),S(!0),z(!0),C(U,m,e,0).then((t=>{if(Object.keys(t).length||(console.log("vj: setHasAllCollectionLoaded ",!0),X.current=!0),Object.keys(t).length){Q(Object.assign(Object.assign({},G),{products:t})),console.log("vj: next page when products loaded",H.current);const e=I.getVariantIdsToFetchAtProductLevel(t);$(e,t),H.current=1}console.log("vj: product data",{productData:t,limit:e,data:h}),e||O({type:"selected",data:{id:U,val:Object.assign(Object.assign({},h),{products:t})}}),S(!1),z(!1)})).catch()},te=(e,t)=>{const o=I.liftTheStateUp(t,h);O({type:e,data:Object.assign(Object.assign({},o),{isRestricted:E})})};return e.jsxs("div",{children:[e.jsxs(x.ProductScreenHeader,{children:[e.jsx(d.IconButton,{Icon:t.default,height:16,onClick:()=>{P("collections")}}),e.jsx(j.BodyCaption,Object.assign({style:{color:s.COLORS.content.secondary}},{children:h.name}))]}),!A&&e.jsx("div",Object.assign({style:{padding:16,height:"76px",borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(a.Input,{noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>W&&M.length?e.jsx(v.Spinner,{size:"small",color:s.COLORS.content.primary}):e.jsx(c.default,{})},id:"listInput",height:"24px",type:"text",value:M,onChangeText:e=>{e.length&&e.trim().length?N(e):N("")},placeholder:"Search products in this collection..."})})),e.jsxs("div",{children:[Object.keys((null==G?void 0:G.products)||[]).length>0&&!Y&&!M.length&&!T&&"-1"!==U&&e.jsxs(x.ProductScreenCollectionCardStyle,{children:[e.jsx(l.CheckBox,{isChecked:!!(null==b?void 0:b[U]),isPartiallyChecked:(e=>{var t;let o=0,c=0;if(b[e]){const i=null==h?void 0:h.products;i&&Object.keys(i).forEach((e=>{var t;const c=null===(t=i[e])||void 0===t?void 0:t.variants;c&&Object.keys(c).forEach((e=>o+=1))}));const n=null===(t=b[e])||void 0===t?void 0:t.products;return n&&Object.keys(n).forEach((e=>{var t;const o=null===(t=n[e])||void 0===t?void 0:t.variants;o&&Object.keys(o).forEach((()=>c+=1))})),c>0&&o!==c}return!1})(U),onValueChange:function(e){e?ee():O({type:"unselected",data:{id:U}})}}),e.jsx("div",Object.assign({style:{width:40,height:40}},{children:e.jsx(o.default,{})})),e.jsx(j.TitleRegular,{children:"All Products"})]}),Object.keys((null==G?void 0:G.products)||[]).length?Object.keys(G.products||[]).map((t=>e.jsx(k,{outOfStockAction:V,collectionId:U,isProductPartiallyChecked:Z(t),productId:t,data:G.products[t],selectedData:b,selectedCollectionsDispatch:O,viewOnly:!w&&!!Y,upliftAdditions:te,hideProductCheckbox:T,hideVariantCheckbox:D,hideProductVariants:R,pickerType:q,onInfoIconClick:F,showProductDetailInfoIcon:L},t))):W?[1,2,3,4,5,6,7,8,9,10].map(((t,o)=>e.jsx("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(u.BikShimmer,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),o))):e.jsx(g.EmptyState,{title:"No products to show",subtitle:M.length?"We couldn't find the product you were looking for":"We couldn’t find any product in this collection."}),e.jsx("div",{ref:_})]}),J&&[1,2,3,4,5].map(((t,o)=>e.jsx("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(u.BikShimmer,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),o)))]})};
|
|
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("../../assets/icons/box.svg.js"),i=require("../../assets/icons/search.svg.js"),n=require("lodash"),c=require("react"),s=require("../../constants/Theme.js"),r=require("../../assets/icons/info.svg.js"),l=require("../checkBox/CheckBox.js"),d=require("../icon-button/IconButton.js"),a=require("../input/Input.js"),u=require("../shimmer/ShimmerComponent/BikShimmer.js"),v=require("../shimmer-image/ShimmerImage.js"),h=require("../spinner/Spinner.js"),p=require("../tooltips/Tooltip.js"),j=require("../TypographyStyle.js"),g=require("./emptyState.js"),f=require("./ProductPickerTag.js"),b=require("./reducers.js"),y=require("./style.js"),x=require("./type.js"),I=require("./utility.js");const k=t=>{const{collectionId:o,productId:i,data:n,selectedData:c,selectedCollectionsDispatch:s,viewOnly:r,upliftAdditions:l,isProductPartiallyChecked:d,hideProductCheckbox:a,outOfStockAction:u,hideVariantCheckbox:v,hideProductVariants:h,pickerType:p,onInfoIconClick:j,showProductDetailInfoIcon:g}=t,f=e=>{var t,n,s,r,l,d;if(!(null===(n=null===(t=null==c?void 0:c[o])||void 0===t?void 0:t.products)||void 0===n?void 0:n[i]))return!1;return!!(null===(d=null===(l=null===(r=null===(s=null==c?void 0:c[o])||void 0===s?void 0:s.products)||void 0===r?void 0:r[i])||void 0===l?void 0:l.variants)||void 0===d?void 0:d[e])};return e.jsxs("div",{children:[e.jsx(O,{isVariant:!1,data:n,productId:i,collectionId:o,isSelected:!!(null===(y=null===(b=null==c?void 0:c[o])||void 0===b?void 0:b.products)||void 0===y?void 0:y[i]),isPartiallyChecked:d,selectedCollectionsDispatch:s,upliftAdditions:l,viewOnly:r,hideProductCheckbox:a,hideVariantCheckbox:v,hideProductVariants:h,pickerType:p,outOfStockAction:u,onInfoIconClick:j,showProductDetailInfoIcon:g},i),h?null:(()=>{const e=Object.keys(n.variants||[]);let t=!1;return!(e.length<=1)||(e.forEach((e=>{var o,i;t=null!==(i=null===(o=n.variants)||void 0===o?void 0:o[e].name.includes(n.name))&&void 0!==i&&i})),!t)})()&&Object.keys(n.variants||[]).map((t=>e.jsx(O,{isVariant:!0,hideVariantCheckbox:v,data:n.variants[t],variantId:t,productId:i,viewOnly:r,upliftAdditions:l,collectionId:o,isSelected:f(t),selectedCollectionsDispatch:s,outOfStockAction:u,onInfoIconClick:j,showProductDetailInfoIcon:g},t)))]});var b,y},O=t=>{const{isVariant:o,data:i,productId:n,collectionId:c,variantId:a,isSelected:u,selectedCollectionsDispatch:h,viewOnly:g,upliftAdditions:b,isPartiallyChecked:x,hideProductCheckbox:I,outOfStockAction:k,hideVariantCheckbox:O,hideProductVariants:C,pickerType:m,onInfoIconClick:P,showProductDetailInfoIcon:S}=t;return e.jsxs(y.ProductCardStyle,Object.assign({isVariant:o,onClick:e=>{"PRODUCT"===m&&C&&(e.stopPropagation(),h({type:"reset",data:{}}),b("variantSelected",{productId:n,variantId:a||Object.keys(i.variants)[0],collectionId:c,variant:i}))},isActive:u},{children:[o&&!g&&!O||!o&&!g&&!I?e.jsx(l.CheckBox,{isChecked:u,isPartiallyChecked:x||!1,onValueChange:function(e){o?e?b("variantSelected",{productId:n,variantId:a,collectionId:c,variant:i}):h({type:"variantUnselected",data:{productId:n,variantId:a,collectionId:c}}):e?b("productSelected",{productId:n,collectionId:c,product:i}):h({type:"productUnselected",data:{productId:n,collectionId:c}})}}):e.jsx(e.Fragment,{}),e.jsx("div",{children:e.jsx(v.ShimmerImage,{width:40,height:40,imageUrl:i.image,alt:"Item",borderRadius:4})}),e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",flex:1}},{children:[e.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"space-between"}},{children:[e.jsx(p.Tooltip,Object.assign({variant:"light",body:i.name,placement:"bottom",delay:400},{children:e.jsx(j.BodyPrimary,Object.assign({numberOfLines:1},{children:i.name}))})),S&&e.jsx(d.IconButton,{onClick:()=>{null==P||P(i)},Icon:()=>e.jsx(r.default,{width:20,height:20,color:s.COLORS.content.placeholder})})]})),e.jsx(f.ProductPickerTag,{isVariant:o,data:i,outOfStockAction:k})]}))]}))};exports.ProductCard=O,exports.ProductGroup=k,exports.ProductsScreen=r=>{const{data:v,collectionsDispatch:p,selectedData:f,selectedCollectionsDispatch:O,productFetcher:C,storeId:m,setScreen:P,setSaveDisabled:S,hideInCollectionSearch:A,customCollectionRestriction:E,hideProductCheckbox:T,outOfStockAction:V=x.OUT_OF_STOCK_ACTION.BLUR,hideVariantCheckbox:D=!1,selectProductsFromCustomCollection:w=!1,pickerType:q,hideProductVariants:R,fbStatusFetcher:B,onInfoIconClick:F,showProductDetailInfoIcon:L}=r,U=c.useContext(b.CollectionIdContext),_=c.useRef(null),H=c.useRef(0),[J,K]=c.useState(!1),[M,N]=c.useState(""),[W,z]=c.useState(!1),[G,Q]=c.useState(v),X=c.useRef(!1);c.useEffect((()=>{const e=setTimeout((()=>{M.length?(z(!0),r.searchInCollectionFetcher(m,U,M).then((e=>{const t=n.cloneDeep(v);t.products=e,Q(t);const o=I.getVariantIdsToFetchAtProductLevel(null!=e?e:{});$(o,null!=e?e:{},!0),S(!1),z(!1)}))):Q(v)}),800);return()=>clearTimeout(e)}),[M]),c.useEffect((()=>{var e,t,o,i,n,c,s,r;console.log("vj: collectionId change before",v,v.products,null===(t=Object.keys(null!==(e=v.products)&&void 0!==e?e:{}))||void 0===t?void 0:t.length,X),X.current=!1,H.current=Math.floor((null===(i=Object.keys(null!==(o=v.products)&&void 0!==o?o:{}))||void 0===i?void 0:i.length)/10);const l=I.getVariantIdsToFetchAtProductLevel(null!==(n=v.products)&&void 0!==n?n:{});$(l,null!==(c=v.products)&&void 0!==c?c:{}),console.log("vj: collectionId change after",v,v.products,null===(r=Object.keys(null!==(s=v.products)&&void 0!==s?s:{}))||void 0===r?void 0:r.length,X)}),[U]);const Y=!!E&&v.isSmartCollection,Z=e=>{var t,o,i,n,c,s,r,l,d,a,u,v,h,p,j,g,b,y,x;let I=0,k=0;if(null===(o=null===(t=null==f?void 0:f[U])||void 0===t?void 0:t.products)||void 0===o?void 0:o[e]){const t=(null===(c=null===(n=null===(i=null==f?void 0:f[U])||void 0===i?void 0:i.products)||void 0===n?void 0:n[e])||void 0===c?void 0:c.variants)||[];if(1===Object.keys(t).length)for(const o in t){const t=null===(r=null===(s=null==f?void 0:f[U])||void 0===s?void 0:s.products)||void 0===r?void 0:r[e],i=null===(u=null===(a=null===(d=null===(l=null==f?void 0:f[U])||void 0===l?void 0:l.products)||void 0===d?void 0:d[e])||void 0===a?void 0:a.variants)||void 0===u?void 0:u[o];if(null===(v=null==i?void 0:i.name)||void 0===v?void 0:v.includes(null!==(h=null==t?void 0:t.name)&&void 0!==h?h:""))return!1}if(null===(g=Object.keys((null===(j=null===(p=null==G?void 0:G.products)||void 0===p?void 0:p[e])||void 0===j?void 0:j.variants)||[]))||void 0===g||g.forEach((()=>k++)),Object.keys((null===(x=null===(y=null===(b=null==f?void 0:f[U])||void 0===b?void 0:b.products)||void 0===y?void 0:y[e])||void 0===x?void 0:x.variants)||[]).forEach((()=>I++)),I>0&&k!==I)return!0}return!1};c.useEffect((()=>{(null==v?void 0:v.products)||ee(10)}),[]);const $=(e,t,o)=>{console.log("fetchFbStatusAndDispatchProducts",{variantIdsToFetchFbStatus:e,fbStatusFetcher:B}),B||(o?I.markVariantsAsApprovedProductsLevel(t,p,U,G,Q):I.markVariantsAsApprovedProductsLevel(t,p,U)),e.length>0&&B&&B(m,e).then((e=>{const i=Object.assign({},t);Object.keys(t).forEach((o=>{var n,c;Object.keys(null!==(c=null===(n=null==t?void 0:t[o])||void 0===n?void 0:n.variants)&&void 0!==c?c:{}).forEach((n=>{var c,s;const r=null===(c=null==t?void 0:t[o].variants)||void 0===c?void 0:c[n];r&&"REJECTED"===e[n]?r.fbStatus="REJECTED":r&&"APPROVED"===e[n]&&(r.fbStatus="APPROVED");const l=null===(s=null==i?void 0:i[o])||void 0===s?void 0:s.variants;l&&l[n]&&(l[n]=r)}))})),o?(Q((e=>{const t=Object.assign({},e);return t.products=i,t})),p({type:"productsPaged",data:{collectionId:U,products:i}})):p({type:"productsPaged",data:{collectionId:U,products:i}})})).catch((e=>{o?I.markVariantsAsApprovedProductsLevel(t,p,U,G,Q):I.markVariantsAsApprovedProductsLevel(t,p,U)}))};c.useEffect((()=>{console.log("vj: observertarget",_.current);const e=new IntersectionObserver((e=>{console.log("vj: observertargetinside",e),e[0].isIntersecting&&(console.log("vj: nextPageRef",H.current,X),H.current>=0&&!X.current&&!M&&(S(!0),K(!0),C(U,m,10,H.current).then((e=>{if(console.log("vj: fetched products",e,X,Object.keys(e).length),Object.keys(e).length||(console.log("vj: setHasAllCollectionLoaded ",!0),X.current=!0),Object.keys(e).length){const t=G;t.products=Object.assign(Object.assign({},G.products),e),Q(t);const o=I.getVariantIdsToFetchAtProductLevel(e);$(o,e),H.current+=1}K(!1),S(!1)})).catch()))}),{threshold:1});return _.current&&e.observe(_.current),()=>{_.current&&e.unobserve(_.current)}}),[_,M]);const ee=e=>{console.log("vj: getProductsForCollection"),S(!0),z(!0),C(U,m,e,0).then((t=>{if(Object.keys(t).length||(console.log("vj: setHasAllCollectionLoaded ",!0),X.current=!0),Object.keys(t).length){Q(Object.assign(Object.assign({},G),{products:t})),console.log("vj: next page when products loaded",H.current);const e=I.getVariantIdsToFetchAtProductLevel(t);$(e,t),H.current=1}console.log("vj: product data",{productData:t,limit:e,data:v}),e||O({type:"selected",data:{id:U,val:Object.assign(Object.assign({},v),{products:t})}}),S(!1),z(!1)})).catch()},te=(e,t)=>{const o=I.liftTheStateUp(t,v);O({type:e,data:Object.assign(Object.assign({},o),{isRestricted:E})})};return e.jsxs("div",{children:[e.jsxs(y.ProductScreenHeader,{children:[e.jsx(d.IconButton,{Icon:t.default,height:16,onClick:()=>{P("collections")}}),e.jsx(j.BodyCaption,Object.assign({style:{color:s.COLORS.content.secondary}},{children:v.name}))]}),!A&&e.jsx("div",Object.assign({style:{padding:16,height:"76px",borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(a.Input,{noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>W&&M.length?e.jsx(h.Spinner,{size:"small",color:s.COLORS.content.primary}):e.jsx(i.default,{})},id:"listInput",height:"24px",type:"text",value:M,onChangeText:e=>{e.length&&e.trim().length?N(e):N("")},placeholder:"Search products in this collection..."})})),e.jsxs("div",{children:[Object.keys((null==G?void 0:G.products)||[]).length>0&&!Y&&!M.length&&!T&&"-1"!==U&&e.jsxs(y.ProductScreenCollectionCardStyle,{children:[e.jsx(l.CheckBox,{isChecked:!!(null==f?void 0:f[U]),isPartiallyChecked:(e=>{var t;let o=0,i=0;if(f[e]){const n=null==v?void 0:v.products;n&&Object.keys(n).forEach((e=>{var t;const i=null===(t=n[e])||void 0===t?void 0:t.variants;i&&Object.keys(i).forEach((e=>o+=1))}));const c=null===(t=f[e])||void 0===t?void 0:t.products;return c&&Object.keys(c).forEach((e=>{var t;const o=null===(t=c[e])||void 0===t?void 0:t.variants;o&&Object.keys(o).forEach((()=>i+=1))})),i>0&&o!==i}return!1})(U),onValueChange:function(e){e?ee():O({type:"unselected",data:{id:U}})}}),e.jsx("div",Object.assign({style:{width:40,height:40}},{children:e.jsx(o.default,{})})),e.jsx(j.TitleRegular,{children:"All Products"})]}),Object.keys((null==G?void 0:G.products)||[]).length?Object.keys(G.products||[]).map((t=>e.jsx(k,{outOfStockAction:V,collectionId:U,isProductPartiallyChecked:Z(t),productId:t,data:G.products[t],selectedData:f,selectedCollectionsDispatch:O,viewOnly:!w&&!!Y,upliftAdditions:te,hideProductCheckbox:T,hideVariantCheckbox:D,hideProductVariants:R,pickerType:q,onInfoIconClick:F,showProductDetailInfoIcon:L},t))):W?[1,2,3,4,5,6,7,8,9,10].map(((t,o)=>e.jsx("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(u.BikShimmer,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),o))):e.jsx(g.EmptyState,{title:"No products to show",subtitle:M.length?"We couldn't find the product you were looking for":"We couldn’t find any product in this collection."}),e.jsx("div",{ref:_})]}),J&&[1,2,3,4,5].map(((t,o)=>e.jsx("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(u.BikShimmer,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),o)))]})};
|
|
@@ -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 a=Object.assign({},t),a[e.data.collectionId].products=e.data.products,a;case"paged":return a=Object.assign(Object.assign({},t),e.data),a;case"productsPaged":return a=Object.assign({},t),a[e.data.collectionId].products=Object.assign(Object.assign({},a[e.data.collectionId].products),e.data.products),a;case"searched":a=Object.assign({},t);for(const t in e.data)t in a||(a[t]=e.data[t]);return 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 s=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),s.products)})}else a[t]=s}return a;case"update":return a=Object.assign({},t),a;case"set":return a=Object.assign(Object.assign({},t),e.data),a;case"filter":a={};for(const s in t)if(s in e.data){const c=Object.assign({},t[s]),
|
|
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 a=Object.assign({},t),a[e.data.collectionId].products=e.data.products,a;case"paged":return a=Object.assign(Object.assign({},t),e.data),a;case"productsPaged":return a=Object.assign({},t),a[e.data.collectionId].products=Object.assign(Object.assign({},a[e.data.collectionId].products),e.data.products),a;case"searched":a=Object.assign({},t);for(const t in e.data)t in a||(a[t]=e.data[t]);return 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 s=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),s.products)})}else a[t]=s}return a;case"update":return a=Object.assign({},t),a;case"set":return a=Object.assign(Object.assign({},t),e.data),a;case"filter":a={};for(const s in t)if(s in e.data){const c=Object.assign({},t[s]),d=e.data[s],o={};for(const t in c.products)if(t in d.products){const e=Object.assign({},c.products[t]),a=d.products[t],s={};for(const t in e.variants)t in a.variants&&(s[t]=Object.assign({},e.variants[t]));Object.keys(s).length>0&&(e.variants=s,o[t]=e)}Object.keys(o).length>0&&(c.products=o,a[s]=c)}return a;default:return t}},exports.searchReducer=function(t,e){let a={collections:{},products:{}};switch(e.type){case"set":return e.data;case"setProducts":return a=Object.assign({},t),a.products=e.data,a;default:return t}},exports.selectedColectionsReducer=function(e,a){var s,c,d,o,r,n;let i={},l="",u="",p="";switch(a.type){case"selected":return i=t.cloneDeep(e),a.data.val.isSmartCollection&&(a.data.isRestricted&&(i={}),i.isCustom=!0),i[a.data.id]=a.data.val,i;case"unselected":return i=t.cloneDeep(e),(null==i?void 0:i.isCustom)&&(i.isCustom=!1),delete i[a.data.id],i;case"productUnselected":return i=t.cloneDeep(e),l=a.data.productId,u=a.data.collectionId,delete i[u].products[l],Object.keys(i[u].products).length||((null==i?void 0:i.isCustom)&&(i.isCustom=!1),delete i[u]),i;case"productSelected":return i=t.cloneDeep(e),l=a.data.productId,u=a.data.collectionId,(null===(s=a.data.catalogOnlyData)||void 0===s?void 0:s.isSmartCollection)&&(a.data.isRestricted&&(i={}),i.isCustom=!0),(null==i?void 0:i[u])||(i[u]=a.data.catalogOnlyData,i[u].products={}),i[u].products[l]=a.data.product,i;case"variantSelected":return i=t.cloneDeep(e),l=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&&(i={}),i.isCustom=!0),(null==i?void 0:i[u])||(i[u]=a.data.catalogOnlyData,i[u].products={},i[u].products[l]=a.data.productOnlyData,i[u].products[l].variants={}),(null===(o=null===(d=null==i?void 0:i[u])||void 0===d?void 0:d.products)||void 0===o?void 0:o[l])||((null===(r=null==i?void 0:i[u])||void 0===r?void 0:r.products)||(i[u].products={}),i[u].products[l]=a.data.productOnlyData,i[u].products[l].variants={}),i[u].products[l].variants[p]=a.data.variant,i;case"variantUnselected":return i=t.cloneDeep(e),l=a.data.productId,u=a.data.collectionId,p=a.data.variantId,delete i[u].products[l].variants[p],Object.keys(i[u].products[l].variants).length||(delete i[u].products[l],Object.keys(i[u].products).length||((null===(n=i[u])||void 0===n?void 0:n.isSmartCollection)&&(i.isCustom=!1),delete i[u])),i;case"update":return i=Object.assign({},e),i;case"reset":return{};default:return e}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),o=require("../../assets/icons/arrow_left.svg.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),o=require("../../assets/icons/arrow_left.svg.js"),l=require("react"),t=require("../icon-button/IconButton.js"),i=require("../TypographyStyle.js"),d=require("./collectionScreen.js"),c=require("./emptyState.js"),n=require("./productScreen.js"),s=require("./style.js"),r=require("./utility.js");exports.SearchScreen=u=>{const{customCollectionRestriction:v,selectedCollections:a,searchedCollections:h,searchedCollectionsDispatch:p,selectedCollectionsDispatch:j,setScreen:C,collections:y,onBackPress:k,hideVariantCheckbox:b,pickerType:f,hideProductVariants:x,hideProductCheckbox:S,storeId:O,fbStatusFetcher:m,setCollectionId:P,setSelectedCollectionId:g,hideCollectionCheckbox:I,renderWithoutModal:q}=u;l.useEffect((()=>{var e;r.fetchFbStatusCollection(null!==(e=h.products)&&void 0!==e?e:{},O,p,m,"setProducts")}),[null==h?void 0:h.products]);const E=!!v&&(null==a?void 0:a.isCustom),D=e=>{var o,l;let t=0,i=0;if(a[e]){const d=null===(o=y[e])||void 0===o?void 0:o.products;d&&Object.keys(d).forEach((e=>{var o;const l=null===(o=d[e])||void 0===o?void 0:o.variants;l&&Object.keys(l).forEach((e=>t+=1))}));const c=null===(l=a[e])||void 0===l?void 0:l.products;return c&&Object.keys(c).forEach((e=>{var o;const l=null===(o=c[e])||void 0===o?void 0:o.variants;l&&Object.keys(l).forEach((e=>i+=1))})),!(t<=0&&i>0)&&(i>0&&t!==i)}return!1},F=(e,o)=>{var l,t,i,d,c,n,s,r,u,v,p,j,C,y,k,b,f,x,S,O,m;let P=0,g=0;if(null===(t=null===(l=null==a?void 0:a[e])||void 0===l?void 0:l.products)||void 0===t?void 0:t[o]){const l=(null===(c=null===(d=null===(i=null==a?void 0:a[e])||void 0===i?void 0:i.products)||void 0===d?void 0:d[o])||void 0===c?void 0:c.variants)||[];if(1===Object.keys(l).length)for(const t in l){const l=null===(s=null===(n=null==a?void 0:a[e])||void 0===n?void 0:n.products)||void 0===s?void 0:s[o],i=null===(p=null===(v=null===(u=null===(r=null==a?void 0:a[e])||void 0===r?void 0:r.products)||void 0===u?void 0:u[o])||void 0===v?void 0:v.variants)||void 0===p?void 0:p[t];if(null===(j=null==i?void 0:i.name)||void 0===j?void 0:j.includes(null!==(C=null==l?void 0:l.name)&&void 0!==C?C:""))return!1}if(null===(x=Object.keys((null===(f=null===(b=null===(k=null===(y=h.products)||void 0===y?void 0:y[e])||void 0===k?void 0:k.products)||void 0===b?void 0:b[o])||void 0===f?void 0:f.variants)||[]))||void 0===x||x.forEach((()=>g++)),Object.keys((null===(m=null===(O=null===(S=null==a?void 0:a[e])||void 0===S?void 0:S.products)||void 0===O?void 0:O[o])||void 0===m?void 0:m.variants)||[]).forEach((()=>P++)),P>0&&g!==P)return!0}return!1};return e.jsxs("div",{children:[e.jsxs(s.SelectedScreenHeader,{children:[e.jsx(t.IconButton,{Icon:o.default,onClick:()=>{C("collections"),k()}}),e.jsx(i.BodyCaption,{children:"Searched Products"})]}),e.jsx("div",{children:Object.keys(null==h?void 0:h.products).length||Object.keys(null==h?void 0:h.collections).length?e.jsxs(e.Fragment,{children:[e.jsx(e.Fragment,{children:Object.keys(null==h?void 0:h.collections).map((o=>e.jsx(d.CollectionCard,{customCollectionRestriction:v,data:null==y?void 0:y[o],isDisabled:E&&!(null==a?void 0:a[o]),isChecked:!!(null==a?void 0:a[o]),isPartiallyChecked:D(o),selectedCollectionsDispatch:j,setCollectionId:P,setSelectedCollectionId:g,setScreen:C,id:o,hideCollectionCheckbox:I||"-1"===o,selectedCollections:a,renderWithoutModal:q,pickerType:f,usedInSearch:!0},o)))}),e.jsx(e.Fragment,{children:Object.keys(null==h?void 0:h.products).map((o=>{var l,t;return Object.keys((null===(t=null===(l=null==h?void 0:h.products)||void 0===l?void 0:l[o])||void 0===t?void 0:t.products)||[]).map((l=>{var t,i;let d=!1;return(null===(t=null==h?void 0:h.products)||void 0===t?void 0:t.isCustom)&&(d=!0),e.jsx(n.ProductGroup,{collectionId:o,upliftAdditions:(e,l)=>((e,o,l)=>{var t;const i=r.liftTheStateUp(l,null===(t=null==h?void 0:h.products)||void 0===t?void 0:t[e]);j({type:o,data:Object.assign(Object.assign({},i),{isRestricted:v})})})(o,e,l),productId:l,data:(null===(i=null==h?void 0:h.products)||void 0===i?void 0:i[o].products)[l],isProductPartiallyChecked:F(o,l),selectedData:a,selectedCollectionsDispatch:j,viewOnly:d,hideProductCheckbox:S,hideVariantCheckbox:b,hideProductVariants:x,pickerType:f},l)}))}))})]}):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"),
|
|
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"),r=require("../icon-button/IconButton.js"),l=require("../TypographyStyle.js"),i=require("./emptyState.js"),n=require("./productScreen.js"),s=require("./reducers.js"),c=require("./style.js"),d=require("./utility.js");exports.SelectedScreen=u=>{const{selectedCollections:v,selectedCollectionsDispatch:a,setScreen:p,collections:f,outOfStockAction:j,storeId:g,fbStatusFetcher:y}=u,S=o.useRef(0),h=o.useRef(null),[b,x]=o.useReducer(s.paginationReducer,{});o.useEffect((()=>{S.current=0;const e=d.paginateSelectedItems(v,10,0);x({type:"paginate",data:e}),d.fetchFbStatusCollection(e,g,x,y,"set"),S.current+=1}),[]),o.useEffect((()=>{x({type:"filter",data:v})}),[v]),o.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",S.current),S.current>0)){const e=d.paginateSelectedItems(v,10,S.current);console.log("paginated inside observer target",{paginatedProducts:e,selectedCollections:v,curScreenData:b}),x({type:"paginate",data:e}),d.fetchFbStatusCollection(e,g,x,y,"update"),S.current+=1}}),{threshold:1});return h.current&&e.observe(h.current),()=>{h.current&&e.unobserve(h.current)}}),[h,v]);const m=(e,t)=>{var o,r,l,i,n,s,c,d,u,a,p,j,g,y,S,h,b,x,m,O;let k=0,q=0;if(null===(r=null===(o=null==v?void 0:v[e])||void 0===o?void 0:o.products)||void 0===r?void 0:r[t]){const o=(null===(n=null===(i=null===(l=null==v?void 0:v[e])||void 0===l?void 0:l.products)||void 0===i?void 0:i[t])||void 0===n?void 0:n.variants)||[];if(1===Object.keys(o).length)for(const r in o){const o=null===(c=null===(s=null==v?void 0:v[e])||void 0===s?void 0:s.products)||void 0===c?void 0:c[t],l=null===(p=null===(a=null===(u=null===(d=null==v?void 0:v[e])||void 0===d?void 0:d.products)||void 0===u?void 0:u[t])||void 0===a?void 0:a.variants)||void 0===p?void 0:p[r];if(null===(j=null==l?void 0:l.name)||void 0===j?void 0:j.includes(null!==(g=null==o?void 0:o.name)&&void 0!==g?g:""))return!1}if(null===(b=Object.keys((null===(h=null===(S=null===(y=null==f?void 0:f[e])||void 0===y?void 0:y.products)||void 0===S?void 0:S[t])||void 0===h?void 0:h.variants)||[]))||void 0===b||b.forEach((()=>q++)),Object.keys((null===(O=null===(m=null===(x=null==v?void 0:v[e])||void 0===x?void 0:x.products)||void 0===m?void 0:m[t])||void 0===O?void 0:O.variants)||[]).forEach((()=>k++)),k>0&&q!==k)return!0}return!1};return e.jsxs("div",{children:[e.jsxs(c.SelectedScreenHeader,{children:[e.jsx(r.IconButton,{Icon:t.default,onClick:()=>{p("collections")}}),e.jsx(l.BodyCaption,{children:"Selected Products"})]}),e.jsxs("div",{children:[Object.keys(b).length>0?e.jsx(e.Fragment,{children:Object.keys(b).map((t=>{var o;return Object.keys((null===(o=null==b?void 0:b[t])||void 0===o?void 0:o.products)||[]).map((o=>{let r=!1;return(null==v?void 0:v.isCustom)&&(r=!0),e.jsx(n.ProductGroup,{upliftAdditions:null,collectionId:t,productId:o,data:b[t].products[o],isProductPartiallyChecked:m(t,o),selectedData:v,selectedCollectionsDispatch:a,viewOnly:r,outOfStockAction:j},o)}))}))}):e.jsx(i.EmptyState,{title:"No Products Selected",subtitle:"Select products will appear here"}),e.jsx("div",{ref:h})]})]})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as t,jsx as o,Fragment as e}from"react/jsx-runtime";import i from"../../assets/icons/arrow_left.svg.js";import c from"../../assets/icons/box.svg.js";import n from"../../assets/icons/search.svg.js";import{cloneDeep as l}from"lodash";import{useContext as r,useRef as s,useState as d,useEffect as a}from"react";import{COLORS as u}from"../../constants/Theme.js";import h from"../../assets/icons/info.svg.js";import{CheckBox as v}from"../checkBox/CheckBox.js";import{IconButton as p}from"../icon-button/IconButton.js";import{Input as m}from"../input/Input.js";import{BikShimmer as g}from"../shimmer/ShimmerComponent/BikShimmer.js";import{ShimmerImage as f}from"../shimmer-image/ShimmerImage.js";import{Spinner as b}from"../spinner/Spinner.js";import{Tooltip as j}from"../tooltips/Tooltip.js";import{BodyCaption as y,TitleRegular as I,BodyPrimary as k}from"../TypographyStyle.js";import{EmptyState as O}from"./emptyState.js";import{ProductPickerTag as C}from"./ProductPickerTag.js";import{CollectionIdContext as P}from"./reducers.js";import{ProductScreenHeader as x,ProductScreenCollectionCardStyle as S,ProductCardStyle as E}from"./style.js";import{OUT_OF_STOCK_ACTION as D}from"./type.js";import{getVariantIdsToFetchAtProductLevel as w,markVariantsAsApprovedProductsLevel as V,liftTheStateUp as A}from"./utility.js";const T=e=>{const{data:h,collectionsDispatch:f,selectedData:j,selectedCollectionsDispatch:k,productFetcher:C,storeId:E,setScreen:T,setSaveDisabled:F,hideInCollectionSearch:B,customCollectionRestriction:U,hideProductCheckbox:L,outOfStockAction:H=D.BLUR,hideVariantCheckbox:J=!1,selectProductsFromCustomCollection:W=!1,pickerType:z,hideProductVariants:K,fbStatusFetcher:M,onInfoIconClick:N,showProductDetailInfoIcon:_}=e,q=r(P),G=s(null),Q=s(0),[X,Y]=d(!1),[Z,$]=d(""),[tt,ot]=d(!1),[et,it]=d(h),ct=s(!1);a((()=>{const t=setTimeout((()=>{Z.length?(ot(!0),e.searchInCollectionFetcher(E,q,Z).then((t=>{const o=l(h);o.products=t,it(o);const e=w(null!=t?t:{});rt(e,null!=t?t:{},!0),F(!1),ot(!1)}))):it(h)}),800);return()=>clearTimeout(t)}),[Z]),a((()=>{var t,o,e,i,c,n,l,r;console.log("vj: collectionId change before",h,h.products,null===(o=Object.keys(null!==(t=h.products)&&void 0!==t?t:{}))||void 0===o?void 0:o.length,ct),ct.current=!1,Q.current=Math.floor((null===(i=Object.keys(null!==(e=h.products)&&void 0!==e?e:{}))||void 0===i?void 0:i.length)/10);const s=w(null!==(c=h.products)&&void 0!==c?c:{});rt(s,null!==(n=h.products)&&void 0!==n?n:{}),console.log("vj: collectionId change after",h,h.products,null===(r=Object.keys(null!==(l=h.products)&&void 0!==l?l:{}))||void 0===r?void 0:r.length,ct)}),[q]);const nt=!!U&&h.isSmartCollection,lt=t=>{var o,e,i,c,n,l,r,s;let d=0,a=0;return!!((null===(e=null===(o=null==h?void 0:h[q])||void 0===o?void 0:o.products)||void 0===e?void 0:e[t])&&(null===(n=Object.keys((null===(c=null===(i=null==h?void 0:h.products)||void 0===i?void 0:i[t])||void 0===c?void 0:c.variants)||[]))||void 0===n||n.forEach((()=>a++)),Object.keys((null===(s=null===(r=null===(l=null==j?void 0:j[q])||void 0===l?void 0:l.products)||void 0===r?void 0:r[t])||void 0===s?void 0:s.variants)||[]).forEach((()=>d++)),d>0&&a!==d))};a((()=>{(null==h?void 0:h.products)||st(10)}),[]);const rt=(t,o,e)=>{console.log("fetchFbStatusAndDispatchProducts",{variantIdsToFetchFbStatus:t,fbStatusFetcher:M}),M||(e?V(o,f,q,et,it):V(o,f,q)),t.length>0&&M&&M(E,t).then((t=>{const i=Object.assign({},o);Object.keys(o).forEach((e=>{var c,n;Object.keys(null!==(n=null===(c=null==o?void 0:o[e])||void 0===c?void 0:c.variants)&&void 0!==n?n:{}).forEach((c=>{var n,l;const r=null===(n=null==o?void 0:o[e].variants)||void 0===n?void 0:n[c];r&&"REJECTED"===t[c]?r.fbStatus="REJECTED":r&&"APPROVED"===t[c]&&(r.fbStatus="APPROVED");const s=null===(l=null==i?void 0:i[e])||void 0===l?void 0:l.variants;s&&s[c]&&(s[c]=r)}))})),e?(it((t=>{const o=Object.assign({},t);return o.products=i,o})),f({type:"productsPaged",data:{collectionId:q,products:i}})):f({type:"productsPaged",data:{collectionId:q,products:i}})})).catch((t=>{e?V(o,f,q,et,it):V(o,f,q)}))};a((()=>{console.log("vj: observertarget",G.current);const t=new IntersectionObserver((t=>{console.log("vj: observertargetinside",t),t[0].isIntersecting&&(console.log("vj: nextPageRef",Q.current,ct),Q.current>=0&&!ct.current&&!Z&&(F(!0),Y(!0),C(q,E,10,Q.current).then((t=>{if(console.log("vj: fetched products",t,ct,Object.keys(t).length),Object.keys(t).length||(console.log("vj: setHasAllCollectionLoaded ",!0),ct.current=!0),Object.keys(t).length){const o=et;o.products=Object.assign(Object.assign({},et.products),t),it(o);const e=w(t);rt(e,t),Q.current+=1}Y(!1),F(!1)})).catch()))}),{threshold:1});return G.current&&t.observe(G.current),()=>{G.current&&t.unobserve(G.current)}}),[G,Z]);const st=t=>{console.log("vj: getProductsForCollection"),F(!0),ot(!0),C(q,E,t,0).then((o=>{if(Object.keys(o).length||(console.log("vj: setHasAllCollectionLoaded ",!0),ct.current=!0),Object.keys(o).length){it(Object.assign(Object.assign({},et),{products:o})),console.log("vj: next page when products loaded",Q.current);const t=w(o);rt(t,o),Q.current=1}console.log("vj: product data",{productData:o,limit:t,data:h}),t||k({type:"selected",data:{id:q,val:Object.assign(Object.assign({},h),{products:o})}}),F(!1),ot(!1)})).catch()},dt=(t,o)=>{const e=A(o,h);k({type:t,data:Object.assign(Object.assign({},e),{isRestricted:U})})};return t("div",{children:[t(x,{children:[o(p,{Icon:i,height:16,onClick:()=>{T("collections")}}),o(y,Object.assign({style:{color:u.content.secondary}},{children:h.name}))]}),!B&&o("div",Object.assign({style:{padding:16,height:"76px",borderBottom:"1px solid #E0E0E0"}},{children:o(m,{noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>tt&&Z.length?o(b,{size:"small",color:u.content.primary}):o(n,{})},id:"listInput",height:"24px",type:"text",value:Z,onChangeText:t=>{t.length&&t.trim().length?$(t):$("")},placeholder:"Search products in this collection..."})})),t("div",{children:[Object.keys((null==et?void 0:et.products)||[]).length>0&&!nt&&!Z.length&&!L&&"-1"!==q&&t(S,{children:[o(v,{isChecked:!!(null==j?void 0:j[q]),isPartiallyChecked:(t=>{var o;let e=0,i=0;if(j[t]){const c=null==h?void 0:h.products;c&&Object.keys(c).forEach((t=>{var o;const i=null===(o=c[t])||void 0===o?void 0:o.variants;i&&Object.keys(i).forEach((t=>e+=1))}));const n=null===(o=j[t])||void 0===o?void 0:o.products;return n&&Object.keys(n).forEach((t=>{var o;const e=null===(o=n[t])||void 0===o?void 0:o.variants;e&&Object.keys(e).forEach((()=>i+=1))})),i>0&&e!==i}return!1})(q),onValueChange:function(t){t?st():k({type:"unselected",data:{id:q}})}}),o("div",Object.assign({style:{width:40,height:40}},{children:o(c,{})})),o(I,{children:"All Products"})]}),Object.keys((null==et?void 0:et.products)||[]).length?Object.keys(et.products||[]).map((t=>o(R,{outOfStockAction:H,collectionId:q,isProductPartiallyChecked:lt(t),productId:t,data:et.products[t],selectedData:j,selectedCollectionsDispatch:k,viewOnly:!W&&!!nt,upliftAdditions:dt,hideProductCheckbox:L,hideVariantCheckbox:J,hideProductVariants:K,pickerType:z,onInfoIconClick:N,showProductDetailInfoIcon:_},t))):tt?[1,2,3,4,5,6,7,8,9,10].map(((t,e)=>o("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:o(g,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),e))):o(O,{title:"No products to show",subtitle:Z.length?"We couldn't find the product you were looking for":"We couldn’t find any product in this collection."}),o("div",{ref:G})]}),X&&[1,2,3,4,5].map(((t,e)=>o("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:o(g,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),e)))]})},R=e=>{const{collectionId:i,productId:c,data:n,selectedData:l,selectedCollectionsDispatch:r,viewOnly:s,upliftAdditions:d,isProductPartiallyChecked:a,hideProductCheckbox:u,outOfStockAction:h,hideVariantCheckbox:v,hideProductVariants:p,pickerType:m,onInfoIconClick:g,showProductDetailInfoIcon:f}=e,b=t=>{var o,e,n,r,s,d;if(!(null===(e=null===(o=null==l?void 0:l[i])||void 0===o?void 0:o.products)||void 0===e?void 0:e[c]))return!1;return!!(null===(d=null===(s=null===(r=null===(n=null==l?void 0:l[i])||void 0===n?void 0:n.products)||void 0===r?void 0:r[c])||void 0===s?void 0:s.variants)||void 0===d?void 0:d[t])};return t("div",{children:[o(F,{isVariant:!1,data:n,productId:c,collectionId:i,isSelected:!!(null===(y=null===(j=null==l?void 0:l[i])||void 0===j?void 0:j.products)||void 0===y?void 0:y[c]),isPartiallyChecked:a,selectedCollectionsDispatch:r,upliftAdditions:d,viewOnly:s,hideProductCheckbox:u,hideVariantCheckbox:v,hideProductVariants:p,pickerType:m,outOfStockAction:h,onInfoIconClick:g,showProductDetailInfoIcon:f},c),p?null:(()=>{const t=Object.keys(n.variants||[]);let o=!1;return!(t.length<=1)||(t.forEach((t=>{var e,i;o=null!==(i=null===(e=n.variants)||void 0===e?void 0:e[t].name.includes(n.name))&&void 0!==i&&i})),!o)})()&&Object.keys(n.variants||[]).map((t=>o(F,{isVariant:!0,hideVariantCheckbox:v,data:n.variants[t],variantId:t,productId:c,viewOnly:s,upliftAdditions:d,collectionId:i,isSelected:b(t),selectedCollectionsDispatch:r,outOfStockAction:h,onInfoIconClick:g,showProductDetailInfoIcon:f},t)))]});var j,y},F=i=>{const{isVariant:c,data:n,productId:l,collectionId:r,variantId:s,isSelected:d,selectedCollectionsDispatch:a,viewOnly:m,upliftAdditions:g,isPartiallyChecked:b,hideProductCheckbox:y,outOfStockAction:I,hideVariantCheckbox:O,hideProductVariants:P,pickerType:x,onInfoIconClick:S,showProductDetailInfoIcon:D}=i;return t(E,Object.assign({isVariant:c,onClick:t=>{"PRODUCT"===x&&P&&(t.stopPropagation(),a({type:"reset",data:{}}),g("variantSelected",{productId:l,variantId:s||Object.keys(n.variants)[0],collectionId:r,variant:n}))},isActive:d},{children:[c&&!m&&!O||!c&&!m&&!y?o(v,{isChecked:d,isPartiallyChecked:b||!1,onValueChange:function(t){c?t?g("variantSelected",{productId:l,variantId:s,collectionId:r,variant:n}):a({type:"variantUnselected",data:{productId:l,variantId:s,collectionId:r}}):t?g("productSelected",{productId:l,collectionId:r,product:n}):a({type:"productUnselected",data:{productId:l,collectionId:r}})}}):o(e,{}),o("div",{children:o(f,{width:40,height:40,imageUrl:n.image,alt:"Item",borderRadius:4})}),t("div",Object.assign({style:{display:"flex",flexDirection:"column",flex:1}},{children:[t("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"space-between"}},{children:[o(j,Object.assign({variant:"light",body:n.name,placement:"bottom",delay:400},{children:o(k,Object.assign({numberOfLines:1},{children:n.name}))})),D&&o(p,{onClick:()=>{null==S||S(n)},Icon:()=>o(h,{width:20,height:20,color:u.content.placeholder})})]})),o(C,{isVariant:c,data:n,outOfStockAction:I})]}))]}))};export{F as ProductCard,R as ProductGroup,T as ProductsScreen};
|
|
1
|
+
import{jsxs as t,jsx as o,Fragment as e}from"react/jsx-runtime";import i from"../../assets/icons/arrow_left.svg.js";import n from"../../assets/icons/box.svg.js";import c from"../../assets/icons/search.svg.js";import{cloneDeep as l}from"lodash";import{useContext as r,useRef as d,useState as s,useEffect as a}from"react";import{COLORS as u}from"../../constants/Theme.js";import v from"../../assets/icons/info.svg.js";import{CheckBox as h}from"../checkBox/CheckBox.js";import{IconButton as p}from"../icon-button/IconButton.js";import{Input as m}from"../input/Input.js";import{BikShimmer as g}from"../shimmer/ShimmerComponent/BikShimmer.js";import{ShimmerImage as f}from"../shimmer-image/ShimmerImage.js";import{Spinner as b}from"../spinner/Spinner.js";import{Tooltip as j}from"../tooltips/Tooltip.js";import{BodyCaption as y,TitleRegular as k,BodyPrimary as I}from"../TypographyStyle.js";import{EmptyState as O}from"./emptyState.js";import{ProductPickerTag as C}from"./ProductPickerTag.js";import{CollectionIdContext as P}from"./reducers.js";import{ProductScreenHeader as x,ProductScreenCollectionCardStyle as S,ProductCardStyle as E}from"./style.js";import{OUT_OF_STOCK_ACTION as D}from"./type.js";import{getVariantIdsToFetchAtProductLevel as w,markVariantsAsApprovedProductsLevel as V,liftTheStateUp as A}from"./utility.js";const T=e=>{const{data:v,collectionsDispatch:f,selectedData:j,selectedCollectionsDispatch:I,productFetcher:C,storeId:E,setScreen:T,setSaveDisabled:F,hideInCollectionSearch:B,customCollectionRestriction:U,hideProductCheckbox:L,outOfStockAction:H=D.BLUR,hideVariantCheckbox:J=!1,selectProductsFromCustomCollection:W=!1,pickerType:z,hideProductVariants:K,fbStatusFetcher:M,onInfoIconClick:N,showProductDetailInfoIcon:_}=e,q=r(P),G=d(null),Q=d(0),[X,Y]=s(!1),[Z,$]=s(""),[tt,ot]=s(!1),[et,it]=s(v),nt=d(!1);a((()=>{const t=setTimeout((()=>{Z.length?(ot(!0),e.searchInCollectionFetcher(E,q,Z).then((t=>{const o=l(v);o.products=t,it(o);const e=w(null!=t?t:{});rt(e,null!=t?t:{},!0),F(!1),ot(!1)}))):it(v)}),800);return()=>clearTimeout(t)}),[Z]),a((()=>{var t,o,e,i,n,c,l,r;console.log("vj: collectionId change before",v,v.products,null===(o=Object.keys(null!==(t=v.products)&&void 0!==t?t:{}))||void 0===o?void 0:o.length,nt),nt.current=!1,Q.current=Math.floor((null===(i=Object.keys(null!==(e=v.products)&&void 0!==e?e:{}))||void 0===i?void 0:i.length)/10);const d=w(null!==(n=v.products)&&void 0!==n?n:{});rt(d,null!==(c=v.products)&&void 0!==c?c:{}),console.log("vj: collectionId change after",v,v.products,null===(r=Object.keys(null!==(l=v.products)&&void 0!==l?l:{}))||void 0===r?void 0:r.length,nt)}),[q]);const ct=!!U&&v.isSmartCollection,lt=t=>{var o,e,i,n,c,l,r,d,s,a,u,v,h,p,m,g,f,b,y;let k=0,I=0;if(null===(e=null===(o=null==j?void 0:j[q])||void 0===o?void 0:o.products)||void 0===e?void 0:e[t]){const o=(null===(c=null===(n=null===(i=null==j?void 0:j[q])||void 0===i?void 0:i.products)||void 0===n?void 0:n[t])||void 0===c?void 0:c.variants)||[];if(1===Object.keys(o).length)for(const e in o){const o=null===(r=null===(l=null==j?void 0:j[q])||void 0===l?void 0:l.products)||void 0===r?void 0:r[t],i=null===(u=null===(a=null===(s=null===(d=null==j?void 0:j[q])||void 0===d?void 0:d.products)||void 0===s?void 0:s[t])||void 0===a?void 0:a.variants)||void 0===u?void 0:u[e];if(null===(v=null==i?void 0:i.name)||void 0===v?void 0:v.includes(null!==(h=null==o?void 0:o.name)&&void 0!==h?h:""))return!1}if(null===(g=Object.keys((null===(m=null===(p=null==et?void 0:et.products)||void 0===p?void 0:p[t])||void 0===m?void 0:m.variants)||[]))||void 0===g||g.forEach((()=>I++)),Object.keys((null===(y=null===(b=null===(f=null==j?void 0:j[q])||void 0===f?void 0:f.products)||void 0===b?void 0:b[t])||void 0===y?void 0:y.variants)||[]).forEach((()=>k++)),k>0&&I!==k)return!0}return!1};a((()=>{(null==v?void 0:v.products)||dt(10)}),[]);const rt=(t,o,e)=>{console.log("fetchFbStatusAndDispatchProducts",{variantIdsToFetchFbStatus:t,fbStatusFetcher:M}),M||(e?V(o,f,q,et,it):V(o,f,q)),t.length>0&&M&&M(E,t).then((t=>{const i=Object.assign({},o);Object.keys(o).forEach((e=>{var n,c;Object.keys(null!==(c=null===(n=null==o?void 0:o[e])||void 0===n?void 0:n.variants)&&void 0!==c?c:{}).forEach((n=>{var c,l;const r=null===(c=null==o?void 0:o[e].variants)||void 0===c?void 0:c[n];r&&"REJECTED"===t[n]?r.fbStatus="REJECTED":r&&"APPROVED"===t[n]&&(r.fbStatus="APPROVED");const d=null===(l=null==i?void 0:i[e])||void 0===l?void 0:l.variants;d&&d[n]&&(d[n]=r)}))})),e?(it((t=>{const o=Object.assign({},t);return o.products=i,o})),f({type:"productsPaged",data:{collectionId:q,products:i}})):f({type:"productsPaged",data:{collectionId:q,products:i}})})).catch((t=>{e?V(o,f,q,et,it):V(o,f,q)}))};a((()=>{console.log("vj: observertarget",G.current);const t=new IntersectionObserver((t=>{console.log("vj: observertargetinside",t),t[0].isIntersecting&&(console.log("vj: nextPageRef",Q.current,nt),Q.current>=0&&!nt.current&&!Z&&(F(!0),Y(!0),C(q,E,10,Q.current).then((t=>{if(console.log("vj: fetched products",t,nt,Object.keys(t).length),Object.keys(t).length||(console.log("vj: setHasAllCollectionLoaded ",!0),nt.current=!0),Object.keys(t).length){const o=et;o.products=Object.assign(Object.assign({},et.products),t),it(o);const e=w(t);rt(e,t),Q.current+=1}Y(!1),F(!1)})).catch()))}),{threshold:1});return G.current&&t.observe(G.current),()=>{G.current&&t.unobserve(G.current)}}),[G,Z]);const dt=t=>{console.log("vj: getProductsForCollection"),F(!0),ot(!0),C(q,E,t,0).then((o=>{if(Object.keys(o).length||(console.log("vj: setHasAllCollectionLoaded ",!0),nt.current=!0),Object.keys(o).length){it(Object.assign(Object.assign({},et),{products:o})),console.log("vj: next page when products loaded",Q.current);const t=w(o);rt(t,o),Q.current=1}console.log("vj: product data",{productData:o,limit:t,data:v}),t||I({type:"selected",data:{id:q,val:Object.assign(Object.assign({},v),{products:o})}}),F(!1),ot(!1)})).catch()},st=(t,o)=>{const e=A(o,v);I({type:t,data:Object.assign(Object.assign({},e),{isRestricted:U})})};return t("div",{children:[t(x,{children:[o(p,{Icon:i,height:16,onClick:()=>{T("collections")}}),o(y,Object.assign({style:{color:u.content.secondary}},{children:v.name}))]}),!B&&o("div",Object.assign({style:{padding:16,height:"76px",borderBottom:"1px solid #E0E0E0"}},{children:o(m,{noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>tt&&Z.length?o(b,{size:"small",color:u.content.primary}):o(c,{})},id:"listInput",height:"24px",type:"text",value:Z,onChangeText:t=>{t.length&&t.trim().length?$(t):$("")},placeholder:"Search products in this collection..."})})),t("div",{children:[Object.keys((null==et?void 0:et.products)||[]).length>0&&!ct&&!Z.length&&!L&&"-1"!==q&&t(S,{children:[o(h,{isChecked:!!(null==j?void 0:j[q]),isPartiallyChecked:(t=>{var o;let e=0,i=0;if(j[t]){const n=null==v?void 0:v.products;n&&Object.keys(n).forEach((t=>{var o;const i=null===(o=n[t])||void 0===o?void 0:o.variants;i&&Object.keys(i).forEach((t=>e+=1))}));const c=null===(o=j[t])||void 0===o?void 0:o.products;return c&&Object.keys(c).forEach((t=>{var o;const e=null===(o=c[t])||void 0===o?void 0:o.variants;e&&Object.keys(e).forEach((()=>i+=1))})),i>0&&e!==i}return!1})(q),onValueChange:function(t){t?dt():I({type:"unselected",data:{id:q}})}}),o("div",Object.assign({style:{width:40,height:40}},{children:o(n,{})})),o(k,{children:"All Products"})]}),Object.keys((null==et?void 0:et.products)||[]).length?Object.keys(et.products||[]).map((t=>o(R,{outOfStockAction:H,collectionId:q,isProductPartiallyChecked:lt(t),productId:t,data:et.products[t],selectedData:j,selectedCollectionsDispatch:I,viewOnly:!W&&!!ct,upliftAdditions:st,hideProductCheckbox:L,hideVariantCheckbox:J,hideProductVariants:K,pickerType:z,onInfoIconClick:N,showProductDetailInfoIcon:_},t))):tt?[1,2,3,4,5,6,7,8,9,10].map(((t,e)=>o("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:o(g,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),e))):o(O,{title:"No products to show",subtitle:Z.length?"We couldn't find the product you were looking for":"We couldn’t find any product in this collection."}),o("div",{ref:G})]}),X&&[1,2,3,4,5].map(((t,e)=>o("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:o(g,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),e)))]})},R=e=>{const{collectionId:i,productId:n,data:c,selectedData:l,selectedCollectionsDispatch:r,viewOnly:d,upliftAdditions:s,isProductPartiallyChecked:a,hideProductCheckbox:u,outOfStockAction:v,hideVariantCheckbox:h,hideProductVariants:p,pickerType:m,onInfoIconClick:g,showProductDetailInfoIcon:f}=e,b=t=>{var o,e,c,r,d,s;if(!(null===(e=null===(o=null==l?void 0:l[i])||void 0===o?void 0:o.products)||void 0===e?void 0:e[n]))return!1;return!!(null===(s=null===(d=null===(r=null===(c=null==l?void 0:l[i])||void 0===c?void 0:c.products)||void 0===r?void 0:r[n])||void 0===d?void 0:d.variants)||void 0===s?void 0:s[t])};return t("div",{children:[o(F,{isVariant:!1,data:c,productId:n,collectionId:i,isSelected:!!(null===(y=null===(j=null==l?void 0:l[i])||void 0===j?void 0:j.products)||void 0===y?void 0:y[n]),isPartiallyChecked:a,selectedCollectionsDispatch:r,upliftAdditions:s,viewOnly:d,hideProductCheckbox:u,hideVariantCheckbox:h,hideProductVariants:p,pickerType:m,outOfStockAction:v,onInfoIconClick:g,showProductDetailInfoIcon:f},n),p?null:(()=>{const t=Object.keys(c.variants||[]);let o=!1;return!(t.length<=1)||(t.forEach((t=>{var e,i;o=null!==(i=null===(e=c.variants)||void 0===e?void 0:e[t].name.includes(c.name))&&void 0!==i&&i})),!o)})()&&Object.keys(c.variants||[]).map((t=>o(F,{isVariant:!0,hideVariantCheckbox:h,data:c.variants[t],variantId:t,productId:n,viewOnly:d,upliftAdditions:s,collectionId:i,isSelected:b(t),selectedCollectionsDispatch:r,outOfStockAction:v,onInfoIconClick:g,showProductDetailInfoIcon:f},t)))]});var j,y},F=i=>{const{isVariant:n,data:c,productId:l,collectionId:r,variantId:d,isSelected:s,selectedCollectionsDispatch:a,viewOnly:m,upliftAdditions:g,isPartiallyChecked:b,hideProductCheckbox:y,outOfStockAction:k,hideVariantCheckbox:O,hideProductVariants:P,pickerType:x,onInfoIconClick:S,showProductDetailInfoIcon:D}=i;return t(E,Object.assign({isVariant:n,onClick:t=>{"PRODUCT"===x&&P&&(t.stopPropagation(),a({type:"reset",data:{}}),g("variantSelected",{productId:l,variantId:d||Object.keys(c.variants)[0],collectionId:r,variant:c}))},isActive:s},{children:[n&&!m&&!O||!n&&!m&&!y?o(h,{isChecked:s,isPartiallyChecked:b||!1,onValueChange:function(t){n?t?g("variantSelected",{productId:l,variantId:d,collectionId:r,variant:c}):a({type:"variantUnselected",data:{productId:l,variantId:d,collectionId:r}}):t?g("productSelected",{productId:l,collectionId:r,product:c}):a({type:"productUnselected",data:{productId:l,collectionId:r}})}}):o(e,{}),o("div",{children:o(f,{width:40,height:40,imageUrl:c.image,alt:"Item",borderRadius:4})}),t("div",Object.assign({style:{display:"flex",flexDirection:"column",flex:1}},{children:[t("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"space-between"}},{children:[o(j,Object.assign({variant:"light",body:c.name,placement:"bottom",delay:400},{children:o(I,Object.assign({numberOfLines:1},{children:c.name}))})),D&&o(p,{onClick:()=>{null==S||S(c)},Icon:()=>o(v,{width:20,height:20,color:u.content.placeholder})})]})),o(C,{isVariant:n,data:c,outOfStockAction:k})]}))]}))};export{F as ProductCard,R as ProductGroup,T as ProductsScreen};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{cloneDeep as t}from"lodash";import{createContext as a}from"react";function e(a,e){var s,c,d,o,n
|
|
1
|
+
import{cloneDeep as t}from"lodash";import{createContext as a}from"react";function e(a,e){var s,c,d,o,r,n;let i={},u="",l="",p="";switch(e.type){case"selected":return i=t(a),e.data.val.isSmartCollection&&(e.data.isRestricted&&(i={}),i.isCustom=!0),i[e.data.id]=e.data.val,i;case"unselected":return i=t(a),(null==i?void 0:i.isCustom)&&(i.isCustom=!1),delete i[e.data.id],i;case"productUnselected":return i=t(a),u=e.data.productId,l=e.data.collectionId,delete i[l].products[u],Object.keys(i[l].products).length||((null==i?void 0:i.isCustom)&&(i.isCustom=!1),delete i[l]),i;case"productSelected":return i=t(a),u=e.data.productId,l=e.data.collectionId,(null===(s=e.data.catalogOnlyData)||void 0===s?void 0:s.isSmartCollection)&&(e.data.isRestricted&&(i={}),i.isCustom=!0),(null==i?void 0:i[l])||(i[l]=e.data.catalogOnlyData,i[l].products={}),i[l].products[u]=e.data.product,i;case"variantSelected":return i=t(a),u=e.data.productId,l=e.data.collectionId,p=e.data.variantId,(null===(c=e.data.catalogOnlyData)||void 0===c?void 0:c.isSmartCollection)&&(e.data.isRestricted&&(i={}),i.isCustom=!0),(null==i?void 0:i[l])||(i[l]=e.data.catalogOnlyData,i[l].products={},i[l].products[u]=e.data.productOnlyData,i[l].products[u].variants={}),(null===(o=null===(d=null==i?void 0:i[l])||void 0===d?void 0:d.products)||void 0===o?void 0:o[u])||((null===(r=null==i?void 0:i[l])||void 0===r?void 0:r.products)||(i[l].products={}),i[l].products[u]=e.data.productOnlyData,i[l].products[u].variants={}),i[l].products[u].variants[p]=e.data.variant,i;case"variantUnselected":return i=t(a),u=e.data.productId,l=e.data.collectionId,p=e.data.variantId,delete i[l].products[u].variants[p],Object.keys(i[l].products[u].variants).length||(delete i[l].products[u],Object.keys(i[l].products).length||((null===(n=i[l])||void 0===n?void 0:n.isSmartCollection)&&(i.isCustom=!1),delete i[l])),i;case"update":return i=Object.assign({},a),i;case"reset":return{};default:return a}}function s(t,a){let e={};switch(a.type){case"fetched":return e=Object.assign({},a.data),e;case"productsFetched":return e=Object.assign({},t),e[a.data.collectionId].products=a.data.products,e;case"paged":return e=Object.assign(Object.assign({},t),a.data),e;case"productsPaged":return e=Object.assign({},t),e[a.data.collectionId].products=Object.assign(Object.assign({},e[a.data.collectionId].products),a.data.products),e;case"searched":e=Object.assign({},t);for(const t in a.data)t in e||(e[t]=a.data[t]);return 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 s=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),s.products)})}else e[t]=s}return e;case"update":return e=Object.assign({},t),e;case"set":return e=Object.assign(Object.assign({},t),a.data),e;case"filter":e={};for(const s in t)if(s in a.data){const c=Object.assign({},t[s]),d=a.data[s],o={};for(const t in c.products)if(t in d.products){const a=Object.assign({},c.products[t]),e=d.products[t],s={};for(const t in a.variants)t in e.variants&&(s[t]=Object.assign({},a.variants[t]));Object.keys(s).length>0&&(a.variants=s,o[t]=a)}Object.keys(o).length>0&&(c.products=o,e[s]=c)}return e;default:return t}}function d(t,a){let e={collections:{},products:{}};switch(a.type){case"set":return a.data;case"setProducts":return e=Object.assign({},t),e.products=a.data,e;default:return t}}const o=a("");export{o as CollectionIdContext,s as collectionsReducer,c as paginationReducer,d as searchReducer,e as selectedColectionsReducer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as o,jsx as
|
|
1
|
+
import{jsxs as o,jsx as i,Fragment as l}from"react/jsx-runtime";import t from"../../assets/icons/arrow_left.svg.js";import{useEffect as e}from"react";import{IconButton as d}from"../icon-button/IconButton.js";import{BodyCaption as c}from"../TypographyStyle.js";import{CollectionCard as n}from"./collectionScreen.js";import{EmptyState as r}from"./emptyState.js";import{ProductGroup as s}from"./productScreen.js";import{SelectedScreenHeader as u}from"./style.js";import{fetchFbStatusCollection as v,liftTheStateUp as a}from"./utility.js";const p=p=>{const{customCollectionRestriction:h,selectedCollections:m,searchedCollections:f,searchedCollectionsDispatch:k,selectedCollectionsDispatch:C,setScreen:y,collections:b,onBackPress:j,hideVariantCheckbox:O,pickerType:S,hideProductVariants:I,hideProductCheckbox:P,storeId:g,fbStatusFetcher:x,setCollectionId:D,setSelectedCollectionId:E,hideCollectionCheckbox:T,renderWithoutModal:V}=p;e((()=>{var o;v(null!==(o=f.products)&&void 0!==o?o:{},g,k,x,"setProducts")}),[null==f?void 0:f.products]);const w=!!h&&(null==m?void 0:m.isCustom),R=o=>{var i,l;let t=0,e=0;if(m[o]){const d=null===(i=b[o])||void 0===i?void 0:i.products;d&&Object.keys(d).forEach((o=>{var i;const l=null===(i=d[o])||void 0===i?void 0:i.variants;l&&Object.keys(l).forEach((o=>t+=1))}));const c=null===(l=m[o])||void 0===l?void 0:l.products;return c&&Object.keys(c).forEach((o=>{var i;const l=null===(i=c[o])||void 0===i?void 0:i.variants;l&&Object.keys(l).forEach((o=>e+=1))})),!(t<=0&&e>0)&&(e>0&&t!==e)}return!1},W=(o,i)=>{var l,t,e,d,c,n,r,s,u,v,a,p,h,k,C,y,b,j,O,S,I;let P=0,g=0;if(null===(t=null===(l=null==m?void 0:m[o])||void 0===l?void 0:l.products)||void 0===t?void 0:t[i]){const l=(null===(c=null===(d=null===(e=null==m?void 0:m[o])||void 0===e?void 0:e.products)||void 0===d?void 0:d[i])||void 0===c?void 0:c.variants)||[];if(1===Object.keys(l).length)for(const t in l){const l=null===(r=null===(n=null==m?void 0:m[o])||void 0===n?void 0:n.products)||void 0===r?void 0:r[i],e=null===(a=null===(v=null===(u=null===(s=null==m?void 0:m[o])||void 0===s?void 0:s.products)||void 0===u?void 0:u[i])||void 0===v?void 0:v.variants)||void 0===a?void 0:a[t];if(null===(p=null==e?void 0:e.name)||void 0===p?void 0:p.includes(null!==(h=null==l?void 0:l.name)&&void 0!==h?h:""))return!1}if(null===(j=Object.keys((null===(b=null===(y=null===(C=null===(k=f.products)||void 0===k?void 0:k[o])||void 0===C?void 0:C.products)||void 0===y?void 0:y[i])||void 0===b?void 0:b.variants)||[]))||void 0===j||j.forEach((()=>g++)),Object.keys((null===(I=null===(S=null===(O=null==m?void 0:m[o])||void 0===O?void 0:O.products)||void 0===S?void 0:S[i])||void 0===I?void 0:I.variants)||[]).forEach((()=>P++)),P>0&&g!==P)return!0}return!1};return o("div",{children:[o(u,{children:[i(d,{Icon:t,onClick:()=>{y("collections"),j()}}),i(c,{children:"Searched Products"})]}),i("div",{children:Object.keys(null==f?void 0:f.products).length||Object.keys(null==f?void 0:f.collections).length?o(l,{children:[i(l,{children:Object.keys(null==f?void 0:f.collections).map((o=>i(n,{customCollectionRestriction:h,data:null==b?void 0:b[o],isDisabled:w&&!(null==m?void 0:m[o]),isChecked:!!(null==m?void 0:m[o]),isPartiallyChecked:R(o),selectedCollectionsDispatch:C,setCollectionId:D,setSelectedCollectionId:E,setScreen:y,id:o,hideCollectionCheckbox:T||"-1"===o,selectedCollections:m,renderWithoutModal:V,pickerType:S,usedInSearch:!0},o)))}),i(l,{children:Object.keys(null==f?void 0:f.products).map((o=>{var l,t;return Object.keys((null===(t=null===(l=null==f?void 0:f.products)||void 0===l?void 0:l[o])||void 0===t?void 0:t.products)||[]).map((l=>{var t,e;let d=!1;return(null===(t=null==f?void 0:f.products)||void 0===t?void 0:t.isCustom)&&(d=!0),i(s,{collectionId:o,upliftAdditions:(i,l)=>((o,i,l)=>{var t;const e=a(l,null===(t=null==f?void 0:f.products)||void 0===t?void 0:t[o]);C({type:i,data:Object.assign(Object.assign({},e),{isRestricted:h})})})(o,i,l),productId:l,data:(null===(e=null==f?void 0:f.products)||void 0===e?void 0:e[o].products)[l],isProductPartiallyChecked:W(o,l),selectedData:m,selectedCollectionsDispatch:C,viewOnly:d,hideProductCheckbox:P,hideVariantCheckbox:O,hideProductVariants:I,pickerType:S},l)}))}))})]}):i(r,{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 o,jsx as t,Fragment as e}from"react/jsx-runtime";import l from"../../assets/icons/arrow_left.svg.js";import{useRef as r,useReducer as i,useEffect as n}from"react";import{IconButton as d}from"../icon-button/IconButton.js";import{BodyCaption as c}from"../TypographyStyle.js";import{EmptyState as s}from"./emptyState.js";import{ProductGroup as u}from"./productScreen.js";import{paginationReducer as v}from"./reducers.js";import{SelectedScreenHeader as a}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=r(0),C=r(null),[I,P]=i(v,{});n((()=>{O.current=0;const o=p(j,10,0);P({type:"paginate",data:o}),m(o,S,P,k,"set"),O.current+=1}),[]),n((()=>{P({type:"filter",data:j})}),[j]),n((()=>{console.log("vj: observertarget",C.current);const o=new IntersectionObserver((o=>{if(console.log("vj: observertargetinside",o),o[0].isIntersecting&&(console.log("vj: nextPageRef",O.current),O.current>0)){const o=p(j,10,O.current);console.log("paginated inside observer target",{paginatedProducts:o,selectedCollections:j,curScreenData:I}),P({type:"paginate",data:o}),m(o,S,P,k,"update"),O.current+=1}}),{threshold:1});return C.current&&o.observe(C.current),()=>{C.current&&o.unobserve(C.current)}}),[C,j]);const w=(o,t)=>{var e,l,r,i,n,d,c,s,u,v,a,p,m,f,g,h,b,S,k,O;let C=0,I=0;if(null===(l=null===(e=null==j?void 0:j[o])||void 0===e?void 0:e.products)||void 0===l?void 0:l[t]){const e=(null===(n=null===(i=null===(r=null==j?void 0:j[o])||void 0===r?void 0:r.products)||void 0===i?void 0:i[t])||void 0===n?void 0:n.variants)||[];if(1===Object.keys(e).length)for(const l in e){const e=null===(c=null===(d=null==j?void 0:j[o])||void 0===d?void 0:d.products)||void 0===c?void 0:c[t],r=null===(a=null===(v=null===(u=null===(s=null==j?void 0:j[o])||void 0===s?void 0:s.products)||void 0===u?void 0:u[t])||void 0===v?void 0:v.variants)||void 0===a?void 0:a[l];if(null===(p=null==r?void 0:r.name)||void 0===p?void 0:p.includes(null!==(m=null==e?void 0:e.name)&&void 0!==m?m:""))return!1}if(null===(b=Object.keys((null===(h=null===(g=null===(f=null==y?void 0:y[o])||void 0===f?void 0:f.products)||void 0===g?void 0:g[t])||void 0===h?void 0:h.variants)||[]))||void 0===b||b.forEach((()=>I++)),Object.keys((null===(O=null===(k=null===(S=null==j?void 0:j[o])||void 0===S?void 0:S.products)||void 0===k?void 0:k[t])||void 0===O?void 0:O.variants)||[]).forEach((()=>C++)),C>0&&I!==C)return!0}return!1};return o("div",{children:[o(a,{children:[t(d,{Icon:l,onClick:()=>{h("collections")}}),t(c,{children:"Selected Products"})]}),o("div",{children:[Object.keys(I).length>0?t(e,{children:Object.keys(I).map((o=>{var e;return Object.keys((null===(e=null==I?void 0:I[o])||void 0===e?void 0:e.products)||[]).map((e=>{let l=!1;return(null==j?void 0:j.isCustom)&&(l=!0),t(u,{upliftAdditions:null,collectionId:o,productId:e,data:I[o].products[e],isProductPartiallyChecked:w(o,e),selectedData:j,selectedCollectionsDispatch:g,viewOnly:l,outOfStockAction:b},e)}))}))}):t(s,{title:"No Products Selected",subtitle:"Select products will appear here"}),t("div",{ref:C})]})]})};export{f as SelectedScreen};
|