@bikdotai/bik-component-library 0.0.453-beta.ppi-9 → 0.0.453
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/collectionScreen.d.ts +0 -1
- package/dist/cjs/components/product-picker-v2/collectionScreen.js +1 -1
- package/dist/cjs/components/product-picker-v2/helpers/ProductHelper.d.ts +0 -2
- package/dist/cjs/components/product-picker-v2/helpers/ProductHelper.js +1 -1
- package/dist/cjs/components/product-picker-v2/modal.d.ts +3 -12
- package/dist/cjs/components/product-picker-v2/modal.js +1 -1
- package/dist/cjs/components/product-picker-v2/productScreen.d.ts +3 -10
- package/dist/cjs/components/product-picker-v2/productScreen.js +1 -1
- package/dist/cjs/components/product-picker-v2/rearrangeScreen.d.ts +1 -3
- package/dist/cjs/components/product-picker-v2/rearrangeScreen.js +1 -1
- package/dist/cjs/components/product-picker-v2/reducers.d.ts +0 -1
- package/dist/cjs/components/product-picker-v2/reducers.js +1 -1
- package/dist/cjs/components/product-picker-v2/searchScreen.d.ts +1 -6
- package/dist/cjs/components/product-picker-v2/searchScreen.js +1 -1
- package/dist/cjs/components/product-picker-v2/selectedScreen.d.ts +1 -5
- package/dist/cjs/components/product-picker-v2/selectedScreen.js +1 -1
- package/dist/cjs/components/product-picker-v2/style.js +7 -12
- package/dist/cjs/components/product-picker-v2/utility.d.ts +0 -10
- package/dist/cjs/components/product-picker-v2/utility.js +1 -1
- package/dist/cjs/components/product-picker-v2/variant.js +1 -1
- package/dist/esm/components/product-picker-v2/collectionScreen.d.ts +0 -1
- package/dist/esm/components/product-picker-v2/collectionScreen.js +1 -1
- package/dist/esm/components/product-picker-v2/helpers/ProductHelper.d.ts +0 -2
- package/dist/esm/components/product-picker-v2/helpers/ProductHelper.js +1 -1
- package/dist/esm/components/product-picker-v2/modal.d.ts +3 -12
- package/dist/esm/components/product-picker-v2/modal.js +1 -1
- package/dist/esm/components/product-picker-v2/productScreen.d.ts +3 -10
- package/dist/esm/components/product-picker-v2/productScreen.js +1 -1
- package/dist/esm/components/product-picker-v2/rearrangeScreen.d.ts +1 -3
- package/dist/esm/components/product-picker-v2/rearrangeScreen.js +1 -1
- package/dist/esm/components/product-picker-v2/reducers.d.ts +0 -1
- package/dist/esm/components/product-picker-v2/reducers.js +1 -1
- package/dist/esm/components/product-picker-v2/searchScreen.d.ts +1 -6
- package/dist/esm/components/product-picker-v2/searchScreen.js +1 -1
- package/dist/esm/components/product-picker-v2/selectedScreen.d.ts +1 -5
- package/dist/esm/components/product-picker-v2/selectedScreen.js +1 -1
- package/dist/esm/components/product-picker-v2/style.js +9 -14
- package/dist/esm/components/product-picker-v2/utility.d.ts +0 -10
- package/dist/esm/components/product-picker-v2/utility.js +1 -1
- package/dist/esm/components/product-picker-v2/variant.js +1 -1
- package/package.json +1 -1
- package/dist/cjs/components/product-picker-v2/ProductPickerTag.d.ts +0 -8
- package/dist/cjs/components/product-picker-v2/ProductPickerTag.js +0 -1
- package/dist/cjs/components/product-picker-v2/productInfoOverlay.d.ts +0 -11
- package/dist/cjs/components/product-picker-v2/productInfoOverlay.js +0 -39
- package/dist/cjs/components/product-picker-v2/useFetchFbStatus copy.d.ts +0 -2
- package/dist/cjs/components/product-picker-v2/useFetchFbStatus copy.js +0 -1
- package/dist/cjs/components/product-picker-v2/useFetchFbStatus.d.ts +0 -5
- package/dist/cjs/components/product-picker-v2/useFetchFbStatus.js +0 -1
- package/dist/esm/components/product-picker-v2/ProductPickerTag.d.ts +0 -8
- package/dist/esm/components/product-picker-v2/ProductPickerTag.js +0 -1
- package/dist/esm/components/product-picker-v2/productInfoOverlay.d.ts +0 -11
- package/dist/esm/components/product-picker-v2/productInfoOverlay.js +0 -39
- package/dist/esm/components/product-picker-v2/useFetchFbStatus copy.d.ts +0 -2
- package/dist/esm/components/product-picker-v2/useFetchFbStatus copy.js +0 -1
- package/dist/esm/components/product-picker-v2/useFetchFbStatus.d.ts +0 -5
- package/dist/esm/components/product-picker-v2/useFetchFbStatus.js +0 -1
|
@@ -13,7 +13,6 @@ interface CollectionsScreenInterface {
|
|
|
13
13
|
storeId: string;
|
|
14
14
|
selectedCollectionsDispatch: React.Dispatch<SelectedCollectionsActions>;
|
|
15
15
|
setCollectionId: React.Dispatch<React.SetStateAction<string>>;
|
|
16
|
-
setSelectedCollectionId: React.Dispatch<React.SetStateAction<string>>;
|
|
17
16
|
setScreen: React.Dispatch<React.SetStateAction<string>>;
|
|
18
17
|
collectionsDispatch: React.Dispatch<CollectionsActions>;
|
|
19
18
|
setSaveDisabled: React.Dispatch<boolean>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/chevronRight.svg.js"),i=require("react"),s=require("../checkBox/CheckBox.js"),o=require("../icon-button/IconButton.js"),c=require("../shimmer/ShimmerComponent/BikShimmer.js"),l=require("../tag/Tag.js"),r=require("../tooltips/Tooltip.js"),n=require("../TypographyStyle.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/chevronRight.svg.js"),i=require("react"),s=require("../checkBox/CheckBox.js"),o=require("../icon-button/IconButton.js"),c=require("../shimmer/ShimmerComponent/BikShimmer.js"),l=require("../tag/Tag.js"),r=require("../tooltips/Tooltip.js"),n=require("../TypographyStyle.js"),a=require("./emptyState.js"),d=require("./style.js");const u=(e,t,i)=>{if(e.length<=t)return e;const s=e.slice(0,t-1);return(i?s.slice(0,s.lastIndexOf(" ")):s)+"..."},h=i=>{const{customCollectionRestriction:c,data:a,selectedCollectionsDispatch:h,setCollectionId:p,isPartiallyChecked:C,setScreen:j,id:x,isChecked:y,isDisabled:g,hideCollectionCheckbox:v,pickerType:m,selectedCollections:b}=i;return e.jsxs(d.CollectionCardStyle,Object.assign({isDisabled:g,onClick:e=>{if(!g){if("COLLECTION"===m)return e.stopPropagation(),h({type:"reset",data:{}}),h({type:"selected",data:{id:x,val:a,isRestricted:c}}),void p(x);p(x),j("products")}},isActive:!!b[x]},{children:[e.jsxs(d.CollectionCardInfoStyle,{children:[!v&&e.jsx(s.CheckBox,{isDisabled:g,isChecked:y,isPartiallyChecked:C,onValueChange:function(e,t,i){null==i||i.stopPropagation(),h(e?{type:"selected",data:{id:x,val:a,isRestricted:c}}:{type:"unselected",data:{id:x}}),p(e?x:"")}}),e.jsx(d.CollectionCardDetailStyle,{children:e.jsx(r.Tooltip,Object.assign({body:a.name,placement:"bottom",delay:400},{children:e.jsxs(d.CollectionNameHolder,{children:[e.jsx(n.TitleRegular,{children:u(a.name,40,!0)}),a.isSmartCollection?e.jsx("div",Object.assign({style:{display:"flex"}},{children:e.jsx(l.Tag,{tagText:"Smart Collection",type:"warning"})})):e.jsx(e.Fragment,{})]})}))})]}),"COLLECTION"!==m&&e.jsx(o.IconButton,{height:12,width:12,disabled:g,Icon:t.default})]}))};exports.CollectionsScreen=t=>{const{customCollectionRestriction:s,dataLoading:o,collections:l,selectedCollectionsDispatch:r,setCollectionId:n,selectedCollections:d,setScreen:u,collectionFetcher:p,collectionsDispatch:C,pagingControls:j,storeId:x,setSaveDisabled:y,hideCollectionCheckbox:g,renderWithoutModal:v,pickerType:m}=t,b=i.useRef(null),k=i.useRef(j.curPage),f=!!s&&(null==d?void 0:d.isCustom),[O,S]=i.useState(!1);i.useEffect((()=>{k.current=j.curPage}),[j.curPage]),i.useEffect((()=>{const e=new IntersectionObserver((e=>{e[0].isIntersecting&&k.current>0&&(y(!0),S(!0),p(k.current,x).then((e=>{C({type:"paged",data:(null==e?void 0:e.collections)||{}}),j.setCurPage(k.current+1),S(!1),y(!1)})).catch())}),{threshold:1});return b.current&&e.observe(b.current),()=>{b.current&&e.unobserve(b.current)}}),[b]);const E=e=>{var t,i;let s=0,o=0;if(d[e]){const c=null===(t=l[e])||void 0===t?void 0:t.products;c&&Object.keys(c).forEach((e=>{var t;const i=null===(t=c[e])||void 0===t?void 0:t.variants;i&&Object.keys(i).forEach((e=>s+=1))}));const r=null===(i=d[e])||void 0===i?void 0:i.products;return r&&Object.keys(r).forEach((e=>{var t;const i=null===(t=r[e])||void 0===t?void 0:t.variants;i&&Object.keys(i).forEach((e=>o+=1))})),!(s<=0&&o>0)&&(o>0&&s!==o)}return!1};return e.jsxs("div",{children:[Object.keys(l).length?Object.keys(l).map((t=>e.jsx(h,{customCollectionRestriction:s,data:l[t],isDisabled:f&&!(null==d?void 0:d[t]),isChecked:!!(null==d?void 0:d[t]),isPartiallyChecked:E(t),selectedCollectionsDispatch:r,setCollectionId:n,setScreen:u,id:t,hideCollectionCheckbox:g,selectedCollections:d,renderWithoutModal:v,pickerType:m},t))):o?[1,2,3,4,5,6,7,8,9,10].map(((t,i)=>e.jsx("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(c.BikShimmer,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),i))):e.jsx(a.EmptyState,{title:"No collections to show",subtitle:"We couldn’t find any collection."}),e.jsx("div",{ref:b}),O&&[1,2,3,4,5].map(((t,i)=>e.jsx("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(c.BikShimmer,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),i)))]})},exports.truncate=u;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { TagType } from "../../tag/model";
|
|
2
1
|
import { Product, ProductVariant, SelectedItems } from '../modal';
|
|
3
2
|
import { OUT_OF_STOCK_ACTION } from '../type';
|
|
4
3
|
import { ProductVariantForRearrange } from '../variant';
|
|
@@ -32,7 +31,6 @@ export declare class ProductHelper {
|
|
|
32
31
|
* @param outOfStockAction
|
|
33
32
|
*/
|
|
34
33
|
static getProductLabels(productVariant: Product | ProductVariant, outOfStockAction?: OUT_OF_STOCK_ACTION): string | null;
|
|
35
|
-
static getTagType: (tagText: string) => TagType;
|
|
36
34
|
}
|
|
37
35
|
/**
|
|
38
36
|
* Loops through each collection, each product, each variant.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("../type.js");const n={NORMAL:null,NOT_SYNCED:"Hidden",OUT_OF_STOCK:"Out of Stock"
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("../type.js");const n={NORMAL:null,NOT_SYNCED:"Hidden",OUT_OF_STOCK:"Out of Stock"};exports.ProductHelper=class{static getProductLabels(l){let i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t.OUT_OF_STOCK_ACTION.NORMAL,u="NORMAL";if(l.variants)return n[u];const d=l;return i===t.OUT_OF_STOCK_ACTION.HIDE&&(!d.skipSync||0!==(null==d?void 0:d.quantity)&&-2!==(null==d?void 0:d.quantity)||(u="NOT_SYNCED"),d.skipSync&&0!==(null==d?void 0:d.quantity)&&-2!==(null==d?void 0:d.quantity)&&(u="NOT_SYNCED"),d.skipSync||0!==(null==d?void 0:d.quantity)&&-2!==(null==d?void 0:d.quantity)||(u="NOT_SYNCED"),d.skipSync||0===(null==d?void 0:d.quantity)||-2===(null==d?void 0:d.quantity)||(u="NORMAL")),i===t.OUT_OF_STOCK_ACTION.BLUR&&(!d.skipSync||0!==(null==d?void 0:d.quantity)&&-2!==(null==d?void 0:d.quantity)||(u="NOT_SYNCED"),d.skipSync&&0!==(null==d?void 0:d.quantity)&&-2!==(null==d?void 0:d.quantity)&&(u="NOT_SYNCED"),d.skipSync||0!==(null==d?void 0:d.quantity)&&-2!==(null==d?void 0:d.quantity)||(u="OUT_OF_STOCK"),d.skipSync||0===(null==d?void 0:d.quantity)||-2===(null==d?void 0:d.quantity)||(u="NORMAL")),i===t.OUT_OF_STOCK_ACTION.NORMAL&&(!d.skipSync||0!==(null==d?void 0:d.quantity)&&-2!==(null==d?void 0:d.quantity)||(u="NOT_SYNCED"),d.skipSync&&0!==(null==d?void 0:d.quantity)&&-2!==(null==d?void 0:d.quantity)&&(u="NOT_SYNCED"),d.skipSync||0!==(null==d?void 0:d.quantity)&&-2!==(null==d?void 0:d.quantity)||(u="NORMAL"),d.skipSync||0===(null==d?void 0:d.quantity)||-2===(null==d?void 0:d.quantity)||(u="NORMAL")),n[u]}},exports.parseSelectedVariantsToArray=t=>{let n=[];Object.keys(t).forEach((l=>{var i;return Object.keys((null===(i=null==t?void 0:t[l])||void 0===i?void 0:i.products)||[]).forEach((i=>{var u,d;const a=null!==(u=t[l].products)&&void 0!==u?u:[],o=null!==(d=a[i].variants)&&void 0!==d?d:[];return Object.keys(o).map((t=>{const n=o[t];n.variantId=t,n.productId=i,n.collectionId=l,n.productName=a[i].name})),n=[...n,...Object.values(o)],n}))}));const l=n.sort(((t,n)=>null==t.displayOrder&&null==n.displayOrder?0:null==t.displayOrder?1:null==n.displayOrder?-1:t.displayOrder-n.displayOrder));return l.forEach(((t,n)=>{t.displayOrder=n})),l};
|
|
@@ -7,13 +7,10 @@ export interface ProductVariant {
|
|
|
7
7
|
quantity: number;
|
|
8
8
|
skipSync?: boolean;
|
|
9
9
|
displayOrder?: number | null;
|
|
10
|
-
fbStatus?: FbProductStatus;
|
|
11
|
-
description?: string;
|
|
12
10
|
}
|
|
13
11
|
export interface Product {
|
|
14
12
|
name: string;
|
|
15
13
|
image: string;
|
|
16
|
-
description?: string;
|
|
17
14
|
variants?: {
|
|
18
15
|
[key: string]: ProductVariant;
|
|
19
16
|
};
|
|
@@ -41,10 +38,6 @@ export type CollectionFetcherReturn = Promise<{
|
|
|
41
38
|
export type ProductFetcherReturn = Promise<{
|
|
42
39
|
[key: string]: Product;
|
|
43
40
|
}>;
|
|
44
|
-
export type FbStatusFetcherReturn = Promise<{
|
|
45
|
-
[key: string]: FbProductStatus;
|
|
46
|
-
}>;
|
|
47
|
-
export type FbProductStatus = 'APPROVED' | 'REJECTED';
|
|
48
41
|
export declare enum ScreenName {
|
|
49
42
|
Collections = "collections",
|
|
50
43
|
RearrangeProducts = "rearrange",
|
|
@@ -56,11 +49,10 @@ export type ProductPickerInterface = {
|
|
|
56
49
|
hideGlobalSearch?: boolean;
|
|
57
50
|
hideInCollectionSearch?: boolean;
|
|
58
51
|
customCollectionRestriction?: boolean;
|
|
59
|
-
searchInCollectionFetcher: (storeId: string, collectionId: string, query: string) =>
|
|
60
|
-
searchFetcher: (storeId: string, query: string
|
|
52
|
+
searchInCollectionFetcher: (storeId: string, collectionId: string, query: string) => Promise<string[]>;
|
|
53
|
+
searchFetcher: (storeId: string, query: string) => Promise<SelectedItems>;
|
|
61
54
|
collectionFetcher: (offset: number, storeId: string) => CollectionFetcherReturn;
|
|
62
|
-
productFetcher: (collectionId: string, storeId: string
|
|
63
|
-
fbStatusFetcher?: (storeId: string, variantIds: string[]) => FbStatusFetcherReturn;
|
|
55
|
+
productFetcher: (collectionId: string, storeId: string) => ProductFetcherReturn;
|
|
64
56
|
storeId: string;
|
|
65
57
|
selectedItems: SelectedItems;
|
|
66
58
|
onAdd: (items: SelectedItems, total: number) => void;
|
|
@@ -84,7 +76,6 @@ export type ProductPickerInterface = {
|
|
|
84
76
|
hideProductVariants?: boolean;
|
|
85
77
|
rearrangeEnabled?: boolean;
|
|
86
78
|
selectSingleItem?: boolean;
|
|
87
|
-
showProductDetailInfoIcon?: boolean;
|
|
88
79
|
} & ({
|
|
89
80
|
startupScreen: ScreenName.RearrangeProducts;
|
|
90
81
|
rearrangeEnabled: true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react/jsx-runtime"),r=require("../../assets/icons/search.svg.js"),c=require("react"),o=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("./productScreen.js"),h=require("./rearrangeScreen.js"),p=require("./reducers.js"),S=require("./searchScreen.js"),x=require("./selectedScreen.js"),g=require("./style.js"),C=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:j,selectedItems:m,onClose:y,visible:b,zIndex:v,exactLimit:P,limit:f,hideCollectionCheckbox:k,hideProductCheckbox:T,outOfStockAction:O=C.OUT_OF_STOCK_ACTION.BLUR,hideVariantCheckbox:R,selectProductsFromCustomCollection:I,hideSelectionCount:F,title:q,width:E,renderWithoutModal:D,onClickSave:N,pickerType:w,hideProductVariants:A=!1,startupScreen:$=exports.ScreenName.Collections,rearrangeEnabled:B,selectSingleItem:M=!1}=e,[V,L]=c.useReducer(p.collectionsReducer,{}),[_,z]=c.useState([exports.ScreenName.Collections,exports.ScreenName.RearrangeProducts].includes($)?$:exports.ScreenName.Collections),[G,H]=c.useState("grid"),[W,K]=c.useState(""),[U,Y]=c.useState(0),[J,Q]=c.useState(!1),[X,Z]=c.useState(0),[ee,te]=c.useState(""),[re,ce]=c.useState(!1),[oe,se]=c.useState(!1),[ne,ie]=c.useState(),[le,ae]=c.useReducer(p.selectedColectionsReducer,Object.keys(m).length>0?m:{}),de=c.useRef(null);c.useEffect((()=>{Q(!0),se(!0),e.collectionFetcher(U,j).then((e=>{L({type:"fetched",data:(null==e?void 0:e.collections)||{}}),Q(!1),Y((e=>e+1)),se(!1)})).catch()}),[]),c.useEffect((()=>{let e=0;Object.keys(le||[]).forEach((t=>{var r;Object.keys((null===(r=le[t])||void 0===r?void 0:r.products)||[]).forEach((r=>{var c,o;Object.keys((null===(o=null===(c=le[t].products)||void 0===c?void 0:c[r])||void 0===o?void 0:o.variants)||[]).forEach((()=>{e+=1}))}))})),Z(e)})),c.useEffect((()=>{var t;W&&!(null===(t=null==V?void 0:V[W])||void 0===t?void 0:t.products)&&(Q(!0),e.productFetcher(W,j).then((e=>{Object.keys(e).length&&L({type:"productsFetched",data:{collectionId:W,products:e}}),Q(!1)})).catch())}),[W]),c.useEffect((()=>{const t=setTimeout((()=>{"rearrange"!==_&&(ee.length?(ce(!0),e.searchFetcher(j,ee).then((e=>{ie(Object.assign({},e)),z("searchProducts"),Q(!1),ce(!1)}))):z("collections"))}),800);return()=>clearTimeout(t)}),[ee]),c.useEffect((()=>{N&&(e.onAdd(le,X),ue())}),[N]),c.useEffect((()=>{M&&Object.keys(le||{}).length&&X&&(e.onAdd(le,X),ue())}),[M,le,X]);const ue=()=>{ae({type:"reset",data:{}})},he=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"===_||"searchProducts"===_)&&t.jsx("div",Object.assign({style:{padding:D?"8px 16px":"12px 24px",borderBottom:"1px solid #E0E0E0"}},{children:t.jsx(n.Input,{noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>re?t.jsx(l.Spinner,{size:"small",color:o.COLORS.content.primary}):t.jsx(r.default,{})},id:"listInput",height:"24px",type:"text",value:ee,onChangeText:e=>{e.length&&e.trim().length?te(e):te("")}})}))}),t.jsxs(g.ScrollContainerStyle,Object.assign({ref:de},{children:["collections"===_&&t.jsx(d.CollectionsScreen,{customCollectionRestriction:e.customCollectionRestriction,dataLoading:oe,collections:V,selectedCollectionsDispatch:ae,setCollectionId:K,setScreen:z,selectedCollections:le,collectionFetcher:e.collectionFetcher,storeId:j,collectionsDispatch:L,setSaveDisabled:Q,pagingControls:{curPage:U,setCurPage:Y},hideCollectionCheckbox:k,renderWithoutModal:D,pickerType:w}),"products"===_&&W&&t.jsx(p.CollectionIdContext.Provider,Object.assign({value:W},{children:t.jsx(u.ProductsScreen,{hideInCollectionSearch:e.hideInCollectionSearch,customCollectionRestriction:e.customCollectionRestriction,productFetcher:e.productFetcher,setScreen:z,storeId:j,data:V[W],collectionsDispatch:L,selectedCollectionsDispatch:ae,selectedData:le,setSaveDisabled:Q,searchInCollectionFetcher:e.searchInCollectionFetcher,hideProductCheckbox:T,outOfStockAction:O,hideVariantCheckbox:R,selectProductsFromCustomCollection:I,renderWithoutModal:D,pickerType:w,hideProductVariants:A})})),"view"===_&&t.jsx(x.SelectedScreen,{selectedCollections:le||{},selectedCollectionsDispatch:ae,setScreen:z,collections:V}),"rearrange"===_&&t.jsx(h.RearrangeScreen,{selectedCollections:le||{},selectedCollectionsDispatch:ae,setScreen:z,outOfStockAction:O,rearrangeViewType:"grid"===G?"list":"grid",scrollContainerRef:de}),"searchProducts"===_&&t.jsx(S.SearchScreen,{customCollectionRestriction:e.customCollectionRestriction,selectedCollections:le||{},searchedCollections:ne||{},selectedCollectionsDispatch:ae,setScreen:z,collections:V,onBackPress:()=>{te(""),ie({})},pickerType:w,hideProductCheckbox:T,hideProductVariants:A,hideVariantCheckbox:R})]}))]});return t.jsx(t.Fragment,{children:D?he:t.jsx(i.StyledModal,Object.assign({zIndex:v,open:b,onClose:()=>{null==y||y(),ue()},headingTitle:q||("collections"===_||"products"===_?"Select Products":"view"===_?"Selected Products":"searchProducts"===_?"Searched Products":"rearrange"===_?"Rearrange Products":void 0),footerShadow:!0,centralContainerStyles:{width:E||"480px"},headerRightCustomElement:"rearrange"===_?(console.log("ignore:",H),t.jsx(t.Fragment,{})):t.jsx(t.Fragment,{}),primaryButton:{buttonText:J?"Loading...":_===exports.ScreenName.RearrangeProducts?"Done":"Add",disabled:J||X<1||P&&X<P||!P&&f&&X>f||!1,onClick:()=>{e.onAdd(le,X),ue()}},footerLeftCustomElement:F?t.jsx(t.Fragment,{}):P&&X>P?t.jsx(a.Tag,{tagText:`You can only select ${P} products`,type:"negative"}):f&&X>f?t.jsx(a.Tag,{tagText:`You can only select ${f} products`,type:"negative"}):X>0?t.jsx(s.Button,{onClick:()=>{z(B?exports.ScreenName.RearrangeProducts:exports.ScreenName.SelectedProducts)},buttonText:P?`${X}/${P} products selected`:`${X} products selected`,buttonType:["rearrange","view"].includes(_)?"tertiaryGray":"tertiary",disabled:["rearrange","view"].includes(_)}):t.jsx(s.Button,{disabled:!0,buttonText:P?`${X}/${P} products selected`:`${X} products selected`,buttonType:"tertiaryGray"})},{children:he}))})};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Collection,
|
|
2
|
+
import { Collection, Product, ProductFetcherReturn, ProductVariant, SelectedItems } from '.';
|
|
3
3
|
import { CollectionsActions, SelectedCollectionsActions } from './reducers';
|
|
4
4
|
import { OUT_OF_STOCK_ACTION } from './type';
|
|
5
5
|
interface ProductsScreenInterface {
|
|
@@ -9,8 +9,8 @@ interface ProductsScreenInterface {
|
|
|
9
9
|
collectionsDispatch: React.Dispatch<CollectionsActions>;
|
|
10
10
|
selectedData: SelectedItems;
|
|
11
11
|
selectedCollectionsDispatch: React.Dispatch<SelectedCollectionsActions>;
|
|
12
|
-
searchInCollectionFetcher: (storeId: string, collectionId: string, query: string) =>
|
|
13
|
-
productFetcher: (collectionId: string, storeId: string
|
|
12
|
+
searchInCollectionFetcher: (storeId: string, collectionId: string, query: string) => Promise<string[]>;
|
|
13
|
+
productFetcher: (collectionId: string, storeId: string) => ProductFetcherReturn;
|
|
14
14
|
storeId: string;
|
|
15
15
|
setScreen: React.Dispatch<React.SetStateAction<string>>;
|
|
16
16
|
setSaveDisabled: React.Dispatch<React.SetStateAction<boolean>>;
|
|
@@ -21,9 +21,6 @@ interface ProductsScreenInterface {
|
|
|
21
21
|
renderWithoutModal?: boolean;
|
|
22
22
|
pickerType?: 'COLLECTION' | 'PRODUCT';
|
|
23
23
|
hideProductVariants?: boolean;
|
|
24
|
-
showProductDetailInfoIcon?: boolean;
|
|
25
|
-
fbStatusFetcher?: (storeId: string, variantIds: string[]) => FbStatusFetcherReturn;
|
|
26
|
-
onInfoIconClick: (productData: Product | ProductVariant) => void;
|
|
27
24
|
}
|
|
28
25
|
export declare const ProductsScreen: (props: ProductsScreenInterface) => import("react/jsx-runtime").JSX.Element;
|
|
29
26
|
interface ProductGroupInterface {
|
|
@@ -39,9 +36,7 @@ interface ProductGroupInterface {
|
|
|
39
36
|
outOfStockAction?: OUT_OF_STOCK_ACTION;
|
|
40
37
|
hideVariantCheckbox?: boolean;
|
|
41
38
|
hideProductVariants?: boolean;
|
|
42
|
-
showProductDetailInfoIcon?: boolean;
|
|
43
39
|
pickerType?: 'COLLECTION' | 'PRODUCT';
|
|
44
|
-
onInfoIconClick?: (productData: Product | ProductVariant) => void;
|
|
45
40
|
}
|
|
46
41
|
export declare const ProductGroup: (props: ProductGroupInterface) => import("react/jsx-runtime").JSX.Element;
|
|
47
42
|
interface ProductCardInterface {
|
|
@@ -59,9 +54,7 @@ interface ProductCardInterface {
|
|
|
59
54
|
outOfStockAction?: OUT_OF_STOCK_ACTION;
|
|
60
55
|
hideVariantCheckbox?: boolean;
|
|
61
56
|
hideProductVariants?: boolean;
|
|
62
|
-
showProductDetailInfoIcon?: boolean;
|
|
63
57
|
pickerType?: 'COLLECTION' | 'PRODUCT';
|
|
64
|
-
onInfoIconClick?: (productData: Product | ProductVariant) => void;
|
|
65
58
|
}
|
|
66
59
|
export declare const ProductCard: (props: ProductCardInterface) => import("react/jsx-runtime").JSX.Element;
|
|
67
60
|
export {};
|
|
@@ -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"),i=require("../../assets/icons/search.svg.js"),n=require("lodash"),s=require("react"),c=require("../../constants/Theme.js"),l=require("../../assets/icons/info.svg.js"),r=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"),b=require("./ProductPickerTag.js"),f=require("./reducers.js"),y=require("./style.js"),O=require("./type.js"),k=require("./utility.js");const x=t=>{const{collectionId:o,productId:i,data:n,selectedData:s,selectedCollectionsDispatch:c,viewOnly:l,upliftAdditions:r,isProductPartiallyChecked:d,hideProductCheckbox:a,outOfStockAction:u,hideVariantCheckbox:v,hideProductVariants:h,pickerType:p,onInfoIconClick:j,showProductDetailInfoIcon:g}=t,b=e=>{var t,n,c,l,r,d;if(!(null===(n=null===(t=null==s?void 0:s[o])||void 0===t?void 0:t.products)||void 0===n?void 0:n[i]))return!1;return!!(null===(d=null===(r=null===(l=null===(c=null==s?void 0:s[o])||void 0===c?void 0:c.products)||void 0===l?void 0:l[i])||void 0===r?void 0:r.variants)||void 0===d?void 0:d[e])};return e.jsxs("div",{children:[e.jsx(I,{isVariant:!1,data:n,productId:i,collectionId:o,isSelected:!!(null===(y=null===(f=null==s?void 0:s[o])||void 0===f?void 0:f.products)||void 0===y?void 0:y[i]),isPartiallyChecked:d,selectedCollectionsDispatch:c,upliftAdditions:r,viewOnly:l,hideProductCheckbox:a,hideVariantCheckbox:v,hideProductVariants:h,pickerType:p,outOfStockAction:u,onInfoIconClick:j,showProductDetailInfoIcon:g},i),h?null:Object.keys(n.variants||[]).length>1&&Object.keys(n.variants||[]).map((t=>e.jsx(I,{isVariant:!0,hideVariantCheckbox:v,data:n.variants[t],variantId:t,productId:i,viewOnly:l,upliftAdditions:r,collectionId:o,isSelected:b(t),selectedCollectionsDispatch:c,outOfStockAction:u,onInfoIconClick:j,showProductDetailInfoIcon:g},t)))]});var f,y},I=t=>{const{isVariant:o,data:i,productId:n,collectionId:s,variantId:a,isSelected:u,selectedCollectionsDispatch:h,viewOnly:g,upliftAdditions:f,isPartiallyChecked:O,hideProductCheckbox:k,outOfStockAction:x,hideVariantCheckbox:I,hideProductVariants:C,pickerType:P,onInfoIconClick:m,showProductDetailInfoIcon:S}=t;return e.jsxs(y.ProductCardStyle,Object.assign({isVariant:o,onClick:e=>{"PRODUCT"===P&&C&&(e.stopPropagation(),h({type:"reset",data:{}}),f("variantSelected",{productId:n,variantId:a||Object.keys(i.variants)[0],collectionId:s,variant:i}))},isActive:u},{children:[o&&!g&&!I||!o&&!g&&!k?e.jsx(r.CheckBox,{isChecked:u,isPartiallyChecked:O||!1,onValueChange:function(e){o?e?f("variantSelected",{productId:n,variantId:a,collectionId:s,variant:i}):h({type:"variantUnselected",data:{productId:n,variantId:a,collectionId:s}}):e?f("productSelected",{productId:n,collectionId:s,product:i}):h({type:"productUnselected",data:{productId:n,collectionId:s}})}}):e.jsx(e.Fragment,{}),e.jsx("div",{children:e.jsx(v.ShimmerImage,{width:40,height:40,imageUrl:i.image,alt:"Item",borderRadius:4})}),e.jsx(p.Tooltip,Object.assign({variant:"light",body:i.name,placement:"bottom",delay:400},{children: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(j.BodyPrimary,Object.assign({numberOfLines:1},{children:i.name})),S&&e.jsx(d.IconButton,{onClick:()=>{null==m||m(i)},Icon:()=>e.jsx(l.default,{width:20,height:20,color:c.COLORS.content.placeholder})})]})),e.jsx(b.ProductPickerTag,{isVariant:o,data:i,outOfStockAction:x})]}))}))]}))};exports.ProductCard=I,exports.ProductGroup=x,exports.ProductsScreen=l=>{const{data:v,collectionsDispatch:p,selectedData:b,selectedCollectionsDispatch:I,productFetcher:C,storeId:P,setScreen:m,setSaveDisabled:S,hideInCollectionSearch:E,customCollectionRestriction:D,hideProductCheckbox:T,outOfStockAction:A=O.OUT_OF_STOCK_ACTION.BLUR,hideVariantCheckbox:V=!1,selectProductsFromCustomCollection:w=!1,pickerType:q,hideProductVariants:F,fbStatusFetcher:R,onInfoIconClick:B,showProductDetailInfoIcon:L}=l,U=s.useContext(f.CollectionIdContext),_=s.useRef(null),H=s.useRef(0),[J,K]=s.useState(!1),[M,N]=s.useState(""),[W,z]=s.useState(!1),[G,Q]=s.useState(v),X=s.useRef(!1);s.useEffect((()=>{const e=setTimeout((()=>{M.length?(z(!0),l.searchInCollectionFetcher(P,U,M).then((e=>{const t=n.cloneDeep(v);t.products=e,Q(t);const o=$(null!=e?e:{},!0);ee(o,null!=e?e:{},!0),S(!1),z(!1)}))):Q(v)}),800);return()=>clearTimeout(e)}),[M]),s.useEffect((()=>{var e,t,o,i,n,s,c,l;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 r=$(null!==(n=v.products)&&void 0!==n?n:{});ee(r,null!==(s=v.products)&&void 0!==s?s:{}),console.log("vj: collectionId change after",v,v.products,null===(l=Object.keys(null!==(c=v.products)&&void 0!==c?c:{}))||void 0===l?void 0:l.length,X)}),[U]);const Y=!!D&&v.isSmartCollection,Z=e=>{var t,o,i,n,s,c,l,r;let d=0,a=0;return!!((null===(o=null===(t=null==b?void 0:b[U])||void 0===t?void 0:t.products)||void 0===o?void 0:o[e])&&(null===(s=Object.keys((null===(n=null===(i=null==v?void 0:v.products)||void 0===i?void 0:i[e])||void 0===n?void 0:n.variants)||[]))||void 0===s||s.forEach((()=>a++)),Object.keys((null===(r=null===(l=null===(c=null==b?void 0:b[U])||void 0===c?void 0:c.products)||void 0===l?void 0:l[e])||void 0===r?void 0:r.variants)||[]).forEach((()=>d++)),d>0&&a!==d))};s.useEffect((()=>{(null==v?void 0:v.products)||te(10)}),[]);const $=(e,t)=>{const o=[];return console.log("vj: getVariantIdsForFbStatusFetch",e),Object.keys(null!=e?e:{}).forEach((i=>{var n,s;const c=null!==(s=null===(n=null==e?void 0:e[i])||void 0===n?void 0:n.variants)&&void 0!==s?s:{};Object.keys(c).forEach((n=>{var s,c,l,r,d;let a;a=t?null===(c=null===(s=null==e?void 0:e[i])||void 0===s?void 0:s.variants)||void 0===c?void 0:c[n]:null===(d=null===(r=null===(l=null==v?void 0:v.products)||void 0===l?void 0:l[i])||void 0===r?void 0:r.variants)||void 0===d?void 0:d[n],console.log("vj: variant fb status",{data:v,variant:a}),(null==a?void 0:a.fbStatus)||o.push(n)}))})),console.log("vj: getVariantIdsForFbStatusFetch returning",o),o},ee=(e,t,o)=>{if(console.log("fetchFbStatusAndDispatchProducts",{variantIdsToFetchFbStatus:e,fbStatusFetcher:R}),!R){const e=Object.assign({},t);if(Object.keys(t).forEach((o=>{var i,n,s;console.log("vj: response variants",null===(i=null==t?void 0:t[o])||void 0===i?void 0:i.variants),Object.keys(null!==(s=null===(n=null==t?void 0:t[o])||void 0===n?void 0:n.variants)&&void 0!==s?s:{}).forEach((i=>{var n,s;const c=null===(n=null==t?void 0:t[o].variants)||void 0===n?void 0:n[i];c&&(c.fbStatus="APPROVED");const l=null===(s=null==e?void 0:e[o])||void 0===s?void 0:s.variants;l&&l[i]&&(l[i]=c)}))})),console.log("vj: fetchFbStatusAndDispatchProducts updated Products",e),o){const t=Object.assign({},G);t.products=e,Q(t)}else p({type:"productsPaged",data:{collectionId:U,products:e}})}e.length>0&&R&&R(P,e).then((e=>{console.log("vj: response",{response:e,products:t});const i=Object.assign({},t);if(Object.keys(t).forEach((o=>{var n,s,c;console.log("vj: response variants",null===(n=null==t?void 0:t[o])||void 0===n?void 0:n.variants),Object.keys(null!==(c=null===(s=null==t?void 0:t[o])||void 0===s?void 0:s.variants)&&void 0!==c?c:{}).forEach((n=>{var s,c;const l=null===(s=null==t?void 0:t[o].variants)||void 0===s?void 0:s[n];console.log("vj: v",{v:l,vId:n,status:e[n],response:e}),l&&"REJECTED"===e[n]?l.fbStatus="REJECTED":l&&"APPROVED"===e[n]&&(l.fbStatus="APPROVED");const r=null===(c=null==i?void 0:i[o])||void 0===c?void 0:c.variants;r&&r[n]&&(r[n]=l)}))})),console.log("vj: updated Products",i),o){const e=Object.assign({},G);e.products=i,Q(e)}else p({type:"productsPaged",data:{collectionId:U,products:i}})})).catch((e=>{const i=Object.assign({},t);if(Object.keys(t).forEach((e=>{var o,n,s;console.log("vj: response variants",null===(o=null==t?void 0:t[e])||void 0===o?void 0:o.variants),Object.keys(null!==(s=null===(n=null==t?void 0:t[e])||void 0===n?void 0:n.variants)&&void 0!==s?s:{}).forEach((o=>{var n,s;const c=null===(n=null==t?void 0:t[e].variants)||void 0===n?void 0:n[o];c&&(c.fbStatus="APPROVED");const l=null===(s=null==i?void 0:i[e])||void 0===s?void 0:s.variants;l&&l[o]&&(l[o]=c)}))})),console.log("vj: fetchFbStatusAndDispatchProducts updated Products",i),o){const e=Object.assign({},G);e.products=i,Q(e)}else p({type:"productsPaged",data:{collectionId:U,products:i}})}))};s.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&&(S(!0),K(!0),C(U,P,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=$(e);ee(o,e),H.current+=1}K(!1),S(!1)})).catch()))}),{threshold:1});return _.current&&e.observe(_.current),()=>{_.current&&e.unobserve(_.current)}}),[_]);const te=e=>{console.log("vj: getProductsForCollection"),S(!0),z(!0),C(U,P,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=$(t);ee(e,t),H.current=1}console.log("vj: product data",{productData:t,limit:e,data:v}),e||I({type:"selected",data:{id:U,val:Object.assign(Object.assign({},v),{products:t})}}),S(!1),z(!1)})).catch()},oe=(e,t)=>{const o=k.liftTheStateUp(t,v);I({type:e,data:Object.assign(Object.assign({},o),{isRestricted:D})})};return e.jsxs("div",{children:[e.jsxs(y.ProductScreenHeader,{children:[e.jsx(d.IconButton,{Icon:t.default,height:16,onClick:()=>{m("collections")}}),e.jsx(j.BodyCaption,Object.assign({style:{color:c.COLORS.content.secondary}},{children:v.name}))]}),!E&&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:c.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(r.CheckBox,{isChecked:!!(null==b?void 0:b[U]),isPartiallyChecked:(e=>{var t;let o=0,i=0;if(b[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 s=null===(t=b[e])||void 0===t?void 0:t.products;return s&&Object.keys(s).forEach((e=>{var t;const o=null===(t=s[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?te():I({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(x,{outOfStockAction:A,collectionId:U,isProductPartiallyChecked:Z(t),productId:t,data:G.products[t],selectedData:b,selectedCollectionsDispatch:I,viewOnly:!w&&!!Y,upliftAdditions:oe,hideProductCheckbox:T,hideVariantCheckbox:V,hideProductVariants:F,pickerType:q,onInfoIconClick:B,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"),i=require("../../assets/icons/box.svg.js"),o=require("../../assets/icons/search.svg.js"),c=require("lodash"),r=require("react"),d=require("../tag/Tag.js"),s=require("../../constants/Theme.js"),l=require("../checkBox/CheckBox.js"),n=require("../icon-button/IconButton.js"),a=require("../input/Input.js"),u=require("../shimmer/ShimmerComponent/BikShimmer.js"),h=require("../shimmer-image/ShimmerImage.js"),p=require("../spinner/Spinner.js"),v=require("../tooltips/Tooltip.js"),j=require("../TypographyStyle.js"),x=require("./collectionScreen.js"),y=require("./emptyState.js"),g=require("./helpers/ProductHelper.js"),C=require("./reducers.js"),k=require("./style.js"),m=require("./type.js"),b=require("./utility.js");const O=t=>{const{collectionId:i,productId:o,data:c,selectedData:r,selectedCollectionsDispatch:d,viewOnly:s,upliftAdditions:l,isProductPartiallyChecked:n,hideProductCheckbox:a,outOfStockAction:u,hideVariantCheckbox:h,hideProductVariants:p,pickerType:v}=t,j=e=>{var t,c,d,s,l,n;if(!(null===(c=null===(t=null==r?void 0:r[i])||void 0===t?void 0:t.products)||void 0===c?void 0:c[o]))return!1;return!!(null===(n=null===(l=null===(s=null===(d=null==r?void 0:r[i])||void 0===d?void 0:d.products)||void 0===s?void 0:s[o])||void 0===l?void 0:l.variants)||void 0===n?void 0:n[e])};return e.jsxs("div",{children:[e.jsx(I,{isVariant:!1,data:c,productId:o,collectionId:i,isSelected:!!(null===(y=null===(x=null==r?void 0:r[i])||void 0===x?void 0:x.products)||void 0===y?void 0:y[o]),isPartiallyChecked:n,selectedCollectionsDispatch:d,upliftAdditions:l,viewOnly:s,hideProductCheckbox:a,hideVariantCheckbox:h,hideProductVariants:p,pickerType:v},o),p?null:Object.keys(c.variants||[]).map((t=>e.jsx(I,{isVariant:!0,hideVariantCheckbox:h,data:c.variants[t],variantId:t,productId:o,viewOnly:s,upliftAdditions:l,collectionId:i,isSelected:j(t),selectedCollectionsDispatch:d,outOfStockAction:u},t)))]});var x,y},I=t=>{const{isVariant:i,data:o,productId:c,collectionId:r,variantId:s,isSelected:n,selectedCollectionsDispatch:a,viewOnly:u,upliftAdditions:p,isPartiallyChecked:y,hideProductCheckbox:C,outOfStockAction:m,hideVariantCheckbox:b,hideProductVariants:O,pickerType:I}=t,S=g.ProductHelper.getProductLabels(o,m);return e.jsxs(k.ProductCardStyle,Object.assign({isVariant:i,onClick:e=>{"PRODUCT"===I&&O&&(e.stopPropagation(),a({type:"reset",data:{}}),p("variantSelected",{productId:c,variantId:s||Object.keys(o.variants)[0],collectionId:r,variant:o}))},isActive:n},{children:[i&&!u&&!b||!i&&!u&&!C?e.jsx(l.CheckBox,{isChecked:n,isPartiallyChecked:y||!1,onValueChange:function(e){i?e?p("variantSelected",{productId:c,variantId:s,collectionId:r,variant:o}):a({type:"variantUnselected",data:{productId:c,variantId:s,collectionId:r}}):e?p("productSelected",{productId:c,collectionId:r,product:o}):a({type:"productUnselected",data:{productId:c,collectionId:r}})}}):e.jsx(e.Fragment,{}),e.jsx("div",{children:e.jsx(h.ShimmerImage,{width:40,height:40,imageUrl:o.image,alt:"Item",borderRadius:4})}),e.jsx(v.Tooltip,Object.assign({body:o.name,placement:"bottom",delay:400},{children:e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column"}},{children:[e.jsx(j.TitleRegular,{children:x.truncate(o.name,40,!0)}),S?e.jsx("div",Object.assign({style:{width:90,display:"flex"}},{children:e.jsx(d.Tag,{tagText:S,type:"warning",theme:"light"})})):e.jsx(e.Fragment,{})]}))}))]}))};exports.ProductCard=I,exports.ProductGroup=O,exports.ProductsScreen=d=>{const h=r.useContext(C.CollectionIdContext),{data:v,collectionsDispatch:x,selectedData:g,selectedCollectionsDispatch:I,productFetcher:S,storeId:f,setScreen:P,setSaveDisabled:q,hideInCollectionSearch:T,customCollectionRestriction:V,hideProductCheckbox:E,outOfStockAction:D=m.OUT_OF_STOCK_ACTION.BLUR,hideVariantCheckbox:w=!1,selectProductsFromCustomCollection:A=!1,pickerType:B,hideProductVariants:R}=d,[F,U]=r.useState(""),[_,H]=r.useState(!1),[L,K]=r.useState(v);r.useEffect((()=>{const e=setTimeout((()=>{F.length?(H(!0),d.searchInCollectionFetcher(f,h,F).then((e=>{var t;const i=c.cloneDeep(v);i.products={};for(const o of e)(null===(t=null==v?void 0:v.products)||void 0===t?void 0:t[o])&&(i.products[o]=v.products[o]);K(i),q(!1),H(!1)}))):K(v)}),800);return()=>clearTimeout(e)}),[F]);const N=!!V&&v.isSmartCollection,W=e=>{var t,i,o,c,r,d,s,l;let n=0,a=0;return!!((null===(i=null===(t=null==g?void 0:g[h])||void 0===t?void 0:t.products)||void 0===i?void 0:i[e])&&(null===(r=Object.keys((null===(c=null===(o=null==v?void 0:v.products)||void 0===o?void 0:o[e])||void 0===c?void 0:c.variants)||[]))||void 0===r||r.forEach((()=>a++)),Object.keys((null===(l=null===(s=null===(d=null==g?void 0:g[h])||void 0===d?void 0:d.products)||void 0===s?void 0:s[e])||void 0===l?void 0:l.variants)||[]).forEach((()=>n++)),n>0&&a!==n))};r.useEffect((()=>{(null==v?void 0:v.products)||z()}),[]);const z=()=>{q(!0),H(!0),S(h,f).then((e=>{Object.keys(e).length&&(x({type:"productsFetched",data:{collectionId:h,products:e}}),K(Object.assign(Object.assign({},L),{products:e}))),q(!1),H(!1)})).catch()},G=(e,t)=>{const i=b.liftTheStateUp(t,v);I({type:e,data:Object.assign(Object.assign({},i),{isRestricted:V})})};return e.jsxs("div",{children:[e.jsxs(k.ProductScreenHeader,{children:[e.jsx(n.IconButton,{Icon:t.default,height:16,onClick:()=>{P("collections")}}),e.jsx(j.BodyCaption,Object.assign({style:{color:s.COLORS.content.secondary}},{children:v.name}))]}),!T&&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:()=>_&&F.length?e.jsx(p.Spinner,{size:"small",color:s.COLORS.content.primary}):e.jsx(o.default,{})},id:"listInput",height:"24px",type:"text",value:F,onChangeText:e=>{e.length&&e.trim().length?U(e):U("")},placeholder:"Search products in this collection..."})})),e.jsxs("div",{children:[Object.keys((null==L?void 0:L.products)||[]).length>0&&!N&&!F.length&&!E&&e.jsxs(k.ProductScreenCollectionCardStyle,{children:[e.jsx(l.CheckBox,{isChecked:!!(null==g?void 0:g[h]),isPartiallyChecked:(e=>{var t;let i=0,o=0;if(g[e]){const c=null==v?void 0:v.products;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((e=>i+=1))}));const r=null===(t=g[e])||void 0===t?void 0:t.products;return r&&Object.keys(r).forEach((e=>{var t;const i=null===(t=r[e])||void 0===t?void 0:t.variants;i&&Object.keys(i).forEach((()=>o+=1))})),o>0&&i!==o}return!1})(h),onValueChange:function(e){I(e?{type:"selected",data:{id:h,val:v}}:{type:"unselected",data:{id:h}})}}),e.jsx("div",Object.assign({style:{width:40,height:40}},{children:e.jsx(i.default,{})})),e.jsx(j.TitleRegular,{children:"All Products"})]}),Object.keys((null==L?void 0:L.products)||[]).length?Object.keys(L.products||[]).map((t=>e.jsx(O,{outOfStockAction:D,collectionId:h,isProductPartiallyChecked:W(t),productId:t,data:L.products[t],selectedData:g,selectedCollectionsDispatch:I,viewOnly:!A&&!!N,upliftAdditions:G,hideProductCheckbox:E,hideVariantCheckbox:w,hideProductVariants:R,pickerType:B},t))):_?[1,2,3,4,5,6,7,8,9,10].map(((t,i)=>e.jsx("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(u.BikShimmer,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),i))):e.jsx(y.EmptyState,{title:"No products to show",subtitle:F.length?"We couldn't find the product you were looking for":"We couldn’t find any product in this collection."})]})]})};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { SelectedItems } from '.';
|
|
3
3
|
import { SelectedCollectionsActions } from './reducers';
|
|
4
4
|
import { OUT_OF_STOCK_ACTION } from './type';
|
|
5
5
|
interface RearrangeScreenInterface {
|
|
@@ -9,8 +9,6 @@ interface RearrangeScreenInterface {
|
|
|
9
9
|
rearrangeViewType: 'grid' | 'list';
|
|
10
10
|
outOfStockAction?: OUT_OF_STOCK_ACTION;
|
|
11
11
|
scrollContainerRef: React.RefObject<HTMLDivElement>;
|
|
12
|
-
storeId: string;
|
|
13
|
-
fbStatusFetcher?: (storeId: string, variantIds: string[]) => FbStatusFetcherReturn;
|
|
14
12
|
}
|
|
15
13
|
/**
|
|
16
14
|
* Screen will be opened on two conditions -
|
|
@@ -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"),
|
|
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"),n=require("../../constants/Theme.js"),c=require("../icon-button/IconButton.js"),o=require("../TypographyStyle.js"),i=require("./emptyState.js"),a=require("./helpers/ProductHelper.js"),l=require("./style.js"),d=require("./variantComponents.js");exports.RearrangeScreen=u=>{const{selectedCollections:p,selectedCollectionsDispatch:j,setScreen:S,rearrangeViewType:h,outOfStockAction:y,scrollContainerRef:x}=u,[f,q]=r.useState(a.parseSelectedVariantsToArray(p));r.useEffect((()=>{var e;null===(e=null==x?void 0:x.current)||void 0===e||e.scrollTo({top:0}),q(a.parseSelectedVariantsToArray(p))}),[p]);return e.jsxs(s.DragDropContext,Object.assign({onDragEnd:e=>{if(!e.destination)return;const t=f,[r]=t.splice(e.source.index,1);t.splice(e.destination.index,0,r),t.forEach(((e,t)=>{e.displayOrder=t})),q(t)}},{children:[e.jsxs(l.SelectedScreenHeader,{children:[e.jsx(c.IconButton,{Icon:t.default,width:16,height:16,color:n.COLORS.content.secondary,onClick:()=>{S("collections")}}),e.jsx(o.BodyCaption,Object.assign({color:n.COLORS.content.secondary},{children:"All Products"}))]}),Object.keys(p).length>0?"list"===h?e.jsx(d.VariantsList,{selectedVariants:f,setSelectedVariants:q,selectedCollectionsDispatch:j,outOfStockAction:y}):e.jsx(d.VariantsGrid,{selectedVariants:f,setSelectedVariants:q,selectedCollectionsDispatch:j}):e.jsx(i.EmptyState,{title:"No Products Selected",subtitle:"Selected products will appear here"})]}))};
|
|
@@ -14,5 +14,4 @@ export interface CollectionsActions {
|
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
16
|
export declare function collectionsReducer(collections: Collection, action: CollectionsActions): any;
|
|
17
|
-
export declare function paginationReducer(collections: SelectedItems, action: SelectedCollectionsActions): SelectedItems;
|
|
18
17
|
export declare const CollectionIdContext: import("react").Context<string>;
|
|
@@ -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
|
|
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;default:return{}}},exports.selectedColectionsReducer=function(e,a){var d,o,c,s,l,r;let n={},u="",i="",p="";switch(a.type){case"selected":return n=t.cloneDeep(e),a.data.val.isSmartCollection&&(a.data.isRestricted&&(n={}),n.isCustom=!0),n[a.data.id]=a.data.val,n;case"unselected":return n=t.cloneDeep(e),(null==n?void 0:n.isCustom)&&(n.isCustom=!1),delete n[a.data.id],n;case"productUnselected":return n=t.cloneDeep(e),u=a.data.productId,i=a.data.collectionId,delete n[i].products[u],Object.keys(n[i].products).length||((null==n?void 0:n.isCustom)&&(n.isCustom=!1),delete n[i]),n;case"productSelected":return n=t.cloneDeep(e),u=a.data.productId,i=a.data.collectionId,(null===(d=a.data.catalogOnlyData)||void 0===d?void 0:d.isSmartCollection)&&(a.data.isRestricted&&(n={}),n.isCustom=!0),(null==n?void 0:n[i])||(n[i]=a.data.catalogOnlyData,n[i].products={}),n[i].products[u]=a.data.product,n;case"variantSelected":return n=t.cloneDeep(e),u=a.data.productId,i=a.data.collectionId,p=a.data.variantId,(null===(o=a.data.catalogOnlyData)||void 0===o?void 0:o.isSmartCollection)&&(a.data.isRestricted&&(n={}),n.isCustom=!0),(null==n?void 0:n[i])||(n[i]=a.data.catalogOnlyData,n[i].products={},n[i].products[u]=a.data.productOnlyData,n[i].products[u].variants={}),(null===(s=null===(c=null==n?void 0:n[i])||void 0===c?void 0:c.products)||void 0===s?void 0:s[u])||((null===(l=null==n?void 0:n[i])||void 0===l?void 0:l.products)||(n[i].products={}),n[i].products[u]=a.data.productOnlyData,n[i].products[u].variants={}),n[i].products[u].variants[p]=a.data.variant,n;case"variantUnselected":return n=t.cloneDeep(e),u=a.data.productId,i=a.data.collectionId,p=a.data.variantId,delete n[i].products[u].variants[p],Object.keys(n[i].products[u].variants).length||(delete n[i].products[u],Object.keys(n[i].products).length||((null===(r=n[i])||void 0===r?void 0:r.isSmartCollection)&&(n.isCustom=!1),delete n[i])),n;case"reset":return{};default:return e}};
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { Collection,
|
|
2
|
+
import { Collection, SelectedItems } from '.';
|
|
3
3
|
import { SelectedCollectionsActions } from './reducers';
|
|
4
4
|
interface SearchScreenInterface {
|
|
5
5
|
customCollectionRestriction?: boolean;
|
|
6
6
|
selectedCollections: SelectedItems;
|
|
7
7
|
searchedCollections: SelectedItems;
|
|
8
|
-
setSearchedCollections: React.Dispatch<React.SetStateAction<SelectedItems>>;
|
|
9
8
|
selectedCollectionsDispatch: React.Dispatch<SelectedCollectionsActions>;
|
|
10
9
|
setScreen: React.Dispatch<React.SetStateAction<string>>;
|
|
11
10
|
collections: {
|
|
@@ -16,10 +15,6 @@ interface SearchScreenInterface {
|
|
|
16
15
|
pickerType?: 'COLLECTION' | 'PRODUCT';
|
|
17
16
|
hideProductVariants?: boolean;
|
|
18
17
|
hideProductCheckbox?: boolean;
|
|
19
|
-
storeId: string;
|
|
20
|
-
fbStatusFetcher?: (storeId: string, variantIds: string[]) => FbStatusFetcherReturn;
|
|
21
|
-
searchFetcher: (storeId: string, query: string, limit?: number, offset?: number) => Promise<SelectedItems>;
|
|
22
|
-
searchText: string;
|
|
23
18
|
}
|
|
24
19
|
export declare const SearchScreen: (props: SearchScreenInterface) => import("react/jsx-runtime").JSX.Element;
|
|
25
20
|
export {};
|
|
@@ -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("../icon-button/IconButton.js"),i=require("../TypographyStyle.js"),r=require("./emptyState.js"),c=require("./productScreen.js"),s=require("./style.js"),l=require("./utility.js");exports.SearchScreen=d=>{const{customCollectionRestriction:n,selectedCollections:u,searchedCollections:a,selectedCollectionsDispatch:v,setScreen:h,collections:p,onBackPress:j,hideVariantCheckbox:y,pickerType:k,hideProductVariants:x,hideProductCheckbox:b}=d,C=(e,t)=>{var o,i,r,c,s,l,d,n,a;let v=0,h=0;return!!((null===(i=null===(o=null==u?void 0:u[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==p?void 0:p[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===(a=null===(n=null===(d=null==u?void 0:u[e])||void 0===d?void 0:d.products)||void 0===n?void 0:n[t])||void 0===a?void 0:a.variants)||[]).forEach((()=>v++)),v>0&&h!==v))};return e.jsxs("div",{children:[e.jsxs(s.SelectedScreenHeader,{children:[e.jsx(o.IconButton,{Icon:t.default,onClick:()=>{h("collections"),j()}}),e.jsx(i.BodyCaption,{children:"Searched Products"})]}),e.jsx("div",{children:Object.keys(a).length?e.jsx(e.Fragment,{children:Object.keys(a).map((t=>{var o;return Object.keys((null===(o=null==a?void 0:a[t])||void 0===o?void 0:o.products)||[]).map((o=>{let i=!1;return(null==a?void 0:a.isCustom)&&(i=!0),e.jsx(c.ProductGroup,{collectionId:t,upliftAdditions:(e,o)=>((e,t,o)=>{const i=l.liftTheStateUp(o,a[e]);v({type:t,data:Object.assign(Object.assign({},i),{isRestricted:n})})})(t,e,o),productId:o,data:a[t].products[o],isProductPartiallyChecked:C(t,o),selectedData:u,selectedCollectionsDispatch:v,viewOnly:i,hideProductCheckbox:b,hideVariantCheckbox:y,hideProductVariants:x,pickerType:k},o)}))}))}):e.jsx(r.EmptyState,{title:"No search results found",subtitle:"We couldn’t find the product you were looking for."})})]})};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { Collection,
|
|
2
|
+
import { Collection, SelectedItems } from '.';
|
|
3
3
|
import { SelectedCollectionsActions } from './reducers';
|
|
4
|
-
import { OUT_OF_STOCK_ACTION } from './type';
|
|
5
4
|
interface SelectedScreenInterface {
|
|
6
5
|
selectedCollections: SelectedItems;
|
|
7
6
|
selectedCollectionsDispatch: React.Dispatch<SelectedCollectionsActions>;
|
|
@@ -9,9 +8,6 @@ interface SelectedScreenInterface {
|
|
|
9
8
|
collections: {
|
|
10
9
|
[key: string]: Collection;
|
|
11
10
|
};
|
|
12
|
-
outOfStockAction?: OUT_OF_STOCK_ACTION;
|
|
13
|
-
storeId: string;
|
|
14
|
-
fbStatusFetcher?: (storeId: string, variantIds: string[]) => FbStatusFetcherReturn;
|
|
15
11
|
}
|
|
16
12
|
export declare const SelectedScreen: (props: SelectedScreenInterface) => import("react/jsx-runtime").JSX.Element;
|
|
17
13
|
export {};
|
|
@@ -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"),l=require("../icon-button/IconButton.js"),o=require("../TypographyStyle.js"),r=require("./emptyState.js"),i=require("./productScreen.js"),d=require("./style.js");exports.SelectedScreen=s=>{const{selectedCollections:c,selectedCollectionsDispatch:n,setScreen:u,collections:v}=s,a=(e,t)=>{var l,o,r,i,d,s,n,u,a;let p=0,j=0;return!!((null===(o=null===(l=null==c?void 0:c[e])||void 0===l?void 0:l.products)||void 0===o?void 0:o[t])&&(null===(s=Object.keys((null===(d=null===(i=null===(r=null==v?void 0:v[e])||void 0===r?void 0:r.products)||void 0===i?void 0:i[t])||void 0===d?void 0:d.variants)||[]))||void 0===s||s.forEach((()=>j++)),Object.keys((null===(a=null===(u=null===(n=null==c?void 0:c[e])||void 0===n?void 0:n.products)||void 0===u?void 0:u[t])||void 0===a?void 0:a.variants)||[]).forEach((()=>p++)),p>0&&j!==p))};return e.jsxs("div",{children:[e.jsxs(d.SelectedScreenHeader,{children:[e.jsx(l.IconButton,{Icon:t.default,onClick:()=>{u("collections")}}),e.jsx(o.BodyCaption,{children:"Selected Products"})]}),e.jsx("div",{children:Object.keys(c).length>0?e.jsx(e.Fragment,{children:Object.keys(c).map((t=>{var l;return Object.keys((null===(l=null==c?void 0:c[t])||void 0===l?void 0:l.products)||[]).map((l=>{let o=!1;return(null==c?void 0:c.isCustom)&&(o=!0),e.jsx(i.ProductGroup,{upliftAdditions:null,collectionId:t,productId:l,data:c[t].products[l],isProductPartiallyChecked:a(t,l),selectedData:c,selectedCollectionsDispatch:n,viewOnly:o},l)}))}))}):e.jsx(r.EmptyState,{title:"No Products Selected",subtitle:"Select products will appear here"})})]})};
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("styled-components"),t=require("../../constants/Theme.js");function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=i(e);const r=o.default.div`
|
|
2
2
|
display: flex;
|
|
3
3
|
background-color: white;
|
|
4
|
-
height: 600px;
|
|
4
|
+
max-height: 600px;
|
|
5
|
+
min-height: 600px;
|
|
5
6
|
flex-direction: column;
|
|
6
7
|
`,l=o.default.div`
|
|
7
8
|
overflow-y: scroll;
|
|
8
9
|
overflow-x: hidden;
|
|
9
|
-
`,
|
|
10
|
+
`,d=o.default.div`
|
|
10
11
|
height: 64px;
|
|
11
12
|
background-color: ${e=>e.isDisabled?"#F0F0F0":e.isActive?t.COLORS.background.positive.light:"white"};
|
|
12
13
|
border-bottom: 1px solid #e0e0e0;
|
|
@@ -20,7 +21,7 @@
|
|
|
20
21
|
cursor: pointer;
|
|
21
22
|
background-color: ${t.COLORS.surface.hovered};
|
|
22
23
|
}
|
|
23
|
-
`,
|
|
24
|
+
`,n=o.default.div`
|
|
24
25
|
display: flex;
|
|
25
26
|
flex-direction: row;
|
|
26
27
|
justify-content: center;
|
|
@@ -40,9 +41,6 @@
|
|
|
40
41
|
align-items: center;
|
|
41
42
|
padding: 8px 16px;
|
|
42
43
|
margin-top: 16px;
|
|
43
|
-
position: sticky;
|
|
44
|
-
top: 0;
|
|
45
|
-
z-index: 10;
|
|
46
44
|
`,c=o.default.div`
|
|
47
45
|
display: flex;
|
|
48
46
|
flex-direction: row;
|
|
@@ -51,7 +49,7 @@
|
|
|
51
49
|
border-bottom: 1px solid #e0e0e0;
|
|
52
50
|
align-items: center;
|
|
53
51
|
`,x=o.default.div`
|
|
54
|
-
|
|
52
|
+
height: 64px;
|
|
55
53
|
background-color: ${e=>e.isActive?t.COLORS.background.positive.light:"white"};
|
|
56
54
|
border-bottom: 1px solid #e0e0e0;
|
|
57
55
|
padding: 12px 16px;
|
|
@@ -74,14 +72,11 @@
|
|
|
74
72
|
justify-content: flex-start;
|
|
75
73
|
align-items: center;
|
|
76
74
|
padding: 8px 16px;
|
|
77
|
-
position: sticky;
|
|
78
|
-
top: 0;
|
|
79
|
-
z-index: 10;
|
|
80
75
|
`,f=o.default.div`
|
|
81
76
|
display: flex;
|
|
82
77
|
flex-direction: column;
|
|
83
78
|
`,u=o.default.div`
|
|
84
|
-
|
|
79
|
+
height: 72px;
|
|
85
80
|
background: white;
|
|
86
81
|
padding: 12px 16px;
|
|
87
82
|
display: flex;
|
|
@@ -112,4 +107,4 @@
|
|
|
112
107
|
align-items: center;
|
|
113
108
|
border: 1px solid ${t.COLORS.stroke.primary};
|
|
114
109
|
border-radius: 4px;
|
|
115
|
-
`,exports.CollectionCardDetailStyle=a,exports.CollectionCardInfoStyle=
|
|
110
|
+
`,exports.CollectionCardDetailStyle=a,exports.CollectionCardInfoStyle=n,exports.CollectionCardStyle=d,exports.CollectionNameHolder=f,exports.ContainerStyle=r,exports.ProductCardStyle=x,exports.ProductScreenCollectionCardStyle=c,exports.ProductScreenHeader=p,exports.ScrollContainerStyle=l,exports.SelectedScreenHeader=s,exports.VariantCardGridStyle=g,exports.VariantCardListStyle=u;
|
|
@@ -1,11 +1 @@
|
|
|
1
|
-
import { Collection, SelectedItems } from './modal';
|
|
2
1
|
export declare const liftTheStateUp: (payload: any, data: any) => any;
|
|
3
|
-
export declare function paginateArray(array: Array<any>, limit: number, pageNo: number): {
|
|
4
|
-
data: any[];
|
|
5
|
-
leftCursor: boolean;
|
|
6
|
-
rightCursor: boolean;
|
|
7
|
-
};
|
|
8
|
-
export declare function paginateSelectedItems(selectedItems: SelectedItems, limit: number, offset: number): {
|
|
9
|
-
[key: string]: Collection;
|
|
10
|
-
};
|
|
11
|
-
export declare function mergeProducts(curData: any, paginatedData: any): any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("lodash");exports.liftTheStateUp=(t,a)=>{const s=e.cloneDeep(a);if(delete s.products,(t=Object.assign(Object.assign({},t),{catalogOnlyData:s})).productId&&a.products){const c=e.cloneDeep(a.products[t.productId]);(null==c?void 0:c.variants)&&delete c.variants,t=Object.assign(Object.assign({},t),{catalogOnlyData:s,productOnlyData:c})}return t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/delete.svg.js"),r=require("../../assets/icons/drag_handle.svg.js"),i=require("../../constants/Theme.js"),a=require("../icon-button/IconButton.js"),s=require("../shimmer-image/ShimmerImage.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/delete.svg.js"),r=require("../../assets/icons/drag_handle.svg.js"),i=require("../../constants/Theme.js"),a=require("../icon-button/IconButton.js"),s=require("../shimmer-image/ShimmerImage.js"),l=require("../TypographyStyle.js"),n=require("./collectionScreen.js"),o=require("./helpers/ProductHelper.js"),d=require("./style.js"),c=require("../tooltips/Tooltip.js"),u=require("../tag/Tag.js");exports.VariantCardGridView=t=>{const{data:r}=t;return e.jsx(d.VariantCardGridStyle,{children:e.jsx(c.Tooltip,Object.assign({body:r.name,alwaysVisible:!1,variant:"dark",placement:"bottom"},{children:e.jsx(s.ShimmerImage,{width:72,height:72,imageUrl:r.image,alt:"Item",borderRadius:4})}))})},exports.VariantCardListView=h=>{const{data:m,selectedCollectionsDispatch:j,outOfStockAction:g}=h,p=o.ProductHelper.getProductLabels(m,g),x=e=>{let t;return t=m.name.includes(m.productName)?m.name:`${m.productName} ${m.name}`,e?n.truncate(t,34,!0):t};return e.jsxs(d.VariantCardListStyle,{children:[e.jsx(r.default,{width:24,height:24,color:i.COLORS.content.placeholder}),e.jsx("div",{children:e.jsx(s.ShimmerImage,{width:40,height:40,imageUrl:m.image,alt:"Item",borderRadius:4},m.variantId)}),e.jsxs("div",Object.assign({className:"tooltip-title-tag"},{children:[e.jsx(c.Tooltip,Object.assign({body:x(!1),placement:"bottom",delay:400},{children:e.jsx(l.TitleRegular,{children:x(!0)})})),p?e.jsx("div",Object.assign({style:{width:90,display:"flex"}},{children:e.jsx(u.Tag,{tagText:p,type:"warning",theme:"light"})})):e.jsx(e.Fragment,{})]})),e.jsx(a.IconButton,{Icon:()=>e.jsx(t.default,{width:24,height:24,color:i.COLORS.content.placeholder}),onClick:()=>{j&&j({type:"variantUnselected",data:{productId:m.productId,variantId:m.variantId,collectionId:m.collectionId}}),h.onDelete&&h.onDelete()}})]})};
|
|
@@ -13,7 +13,6 @@ interface CollectionsScreenInterface {
|
|
|
13
13
|
storeId: string;
|
|
14
14
|
selectedCollectionsDispatch: React.Dispatch<SelectedCollectionsActions>;
|
|
15
15
|
setCollectionId: React.Dispatch<React.SetStateAction<string>>;
|
|
16
|
-
setSelectedCollectionId: React.Dispatch<React.SetStateAction<string>>;
|
|
17
16
|
setScreen: React.Dispatch<React.SetStateAction<string>>;
|
|
18
17
|
collectionsDispatch: React.Dispatch<CollectionsActions>;
|
|
19
18
|
setSaveDisabled: React.Dispatch<boolean>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as t,Fragment as o}from"react/jsx-runtime";import i from"../../assets/icons/chevronRight.svg.js";import{useRef as c,useState as s,useEffect as
|
|
1
|
+
import{jsxs as e,jsx as t,Fragment as o}from"react/jsx-runtime";import i from"../../assets/icons/chevronRight.svg.js";import{useRef as c,useState as s,useEffect as r}from"react";import{CheckBox as l}from"../checkBox/CheckBox.js";import{IconButton as n}from"../icon-button/IconButton.js";import{BikShimmer as d}from"../shimmer/ShimmerComponent/BikShimmer.js";import{Tag as a}from"../tag/Tag.js";import{Tooltip as h}from"../tooltips/Tooltip.js";import{TitleRegular as p}from"../TypographyStyle.js";import{EmptyState as m}from"./emptyState.js";import{CollectionCardStyle as u,CollectionCardInfoStyle as C,CollectionCardDetailStyle as v,CollectionNameHolder as b}from"./style.js";const g=(e,t,o)=>{if(e.length<=t)return e;const i=e.slice(0,t-1);return(o?i.slice(0,i.lastIndexOf(" ")):i)+"..."},y=o=>{const{customCollectionRestriction:i,dataLoading:l,collections:n,selectedCollectionsDispatch:a,setCollectionId:h,selectedCollections:p,setScreen:u,collectionFetcher:C,collectionsDispatch:v,pagingControls:b,storeId:g,setSaveDisabled:y,hideCollectionCheckbox:k,renderWithoutModal:j,pickerType:x}=o,O=c(null),E=c(b.curPage),I=!!i&&(null==p?void 0:p.isCustom),[T,S]=s(!1);r((()=>{E.current=b.curPage}),[b.curPage]),r((()=>{const e=new IntersectionObserver((e=>{e[0].isIntersecting&&E.current>0&&(y(!0),S(!0),C(E.current,g).then((e=>{v({type:"paged",data:(null==e?void 0:e.collections)||{}}),b.setCurPage(E.current+1),S(!1),y(!1)})).catch())}),{threshold:1});return O.current&&e.observe(O.current),()=>{O.current&&e.unobserve(O.current)}}),[O]);const D=e=>{var t,o;let i=0,c=0;if(p[e]){const s=null===(t=n[e])||void 0===t?void 0:t.products;s&&Object.keys(s).forEach((e=>{var t;const o=null===(t=s[e])||void 0===t?void 0:t.variants;o&&Object.keys(o).forEach((e=>i+=1))}));const r=null===(o=p[e])||void 0===o?void 0:o.products;return r&&Object.keys(r).forEach((e=>{var t;const o=null===(t=r[e])||void 0===t?void 0:t.variants;o&&Object.keys(o).forEach((e=>c+=1))})),!(i<=0&&c>0)&&(c>0&&i!==c)}return!1};return e("div",{children:[Object.keys(n).length?Object.keys(n).map((e=>t(f,{customCollectionRestriction:i,data:n[e],isDisabled:I&&!(null==p?void 0:p[e]),isChecked:!!(null==p?void 0:p[e]),isPartiallyChecked:D(e),selectedCollectionsDispatch:a,setCollectionId:h,setScreen:u,id:e,hideCollectionCheckbox:k,selectedCollections:p,renderWithoutModal:j,pickerType:x},e))):l?[1,2,3,4,5,6,7,8,9,10].map(((e,o)=>t("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:t(d,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),o))):t(m,{title:"No collections to show",subtitle:"We couldn’t find any collection."}),t("div",{ref:O}),T&&[1,2,3,4,5].map(((e,o)=>t("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:t(d,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),o)))]})},f=c=>{const{customCollectionRestriction:s,data:r,selectedCollectionsDispatch:d,setCollectionId:m,isPartiallyChecked:y,setScreen:f,id:k,isChecked:j,isDisabled:x,hideCollectionCheckbox:O,pickerType:E,selectedCollections:I}=c;return e(u,Object.assign({isDisabled:x,onClick:e=>{if(!x){if("COLLECTION"===E)return e.stopPropagation(),d({type:"reset",data:{}}),d({type:"selected",data:{id:k,val:r,isRestricted:s}}),void m(k);m(k),f("products")}},isActive:!!I[k]},{children:[e(C,{children:[!O&&t(l,{isDisabled:x,isChecked:j,isPartiallyChecked:y,onValueChange:function(e,t,o){null==o||o.stopPropagation(),d(e?{type:"selected",data:{id:k,val:r,isRestricted:s}}:{type:"unselected",data:{id:k}}),m(e?k:"")}}),t(v,{children:t(h,Object.assign({body:r.name,placement:"bottom",delay:400},{children:e(b,{children:[t(p,{children:g(r.name,40,!0)}),r.isSmartCollection?t("div",Object.assign({style:{display:"flex"}},{children:t(a,{tagText:"Smart Collection",type:"warning"})})):t(o,{})]})}))})]}),"COLLECTION"!==E&&t(n,{height:12,width:12,disabled:x,Icon:i})]}))};export{y as CollectionsScreen,g as truncate};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { TagType } from "../../tag/model";
|
|
2
1
|
import { Product, ProductVariant, SelectedItems } from '../modal';
|
|
3
2
|
import { OUT_OF_STOCK_ACTION } from '../type';
|
|
4
3
|
import { ProductVariantForRearrange } from '../variant';
|
|
@@ -32,7 +31,6 @@ export declare class ProductHelper {
|
|
|
32
31
|
* @param outOfStockAction
|
|
33
32
|
*/
|
|
34
33
|
static getProductLabels(productVariant: Product | ProductVariant, outOfStockAction?: OUT_OF_STOCK_ACTION): string | null;
|
|
35
|
-
static getTagType: (tagText: string) => TagType;
|
|
36
34
|
}
|
|
37
35
|
/**
|
|
38
36
|
* Loops through each collection, each product, each variant.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{OUT_OF_STOCK_ACTION as n}from"../type.js";const t={NORMAL:null,NOT_SYNCED:"Hidden",OUT_OF_STOCK:"Out of Stock"
|
|
1
|
+
import{OUT_OF_STOCK_ACTION as n}from"../type.js";const t={NORMAL:null,NOT_SYNCED:"Hidden",OUT_OF_STOCK:"Out of Stock"};class i{static getProductLabels(i){let l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:n.NORMAL,u="NORMAL";if(i.variants)return t[u];const d=i;return l===n.HIDE&&(!d.skipSync||0!==(null==d?void 0:d.quantity)&&-2!==(null==d?void 0:d.quantity)||(u="NOT_SYNCED"),d.skipSync&&0!==(null==d?void 0:d.quantity)&&-2!==(null==d?void 0:d.quantity)&&(u="NOT_SYNCED"),d.skipSync||0!==(null==d?void 0:d.quantity)&&-2!==(null==d?void 0:d.quantity)||(u="NOT_SYNCED"),d.skipSync||0===(null==d?void 0:d.quantity)||-2===(null==d?void 0:d.quantity)||(u="NORMAL")),l===n.BLUR&&(!d.skipSync||0!==(null==d?void 0:d.quantity)&&-2!==(null==d?void 0:d.quantity)||(u="NOT_SYNCED"),d.skipSync&&0!==(null==d?void 0:d.quantity)&&-2!==(null==d?void 0:d.quantity)&&(u="NOT_SYNCED"),d.skipSync||0!==(null==d?void 0:d.quantity)&&-2!==(null==d?void 0:d.quantity)||(u="OUT_OF_STOCK"),d.skipSync||0===(null==d?void 0:d.quantity)||-2===(null==d?void 0:d.quantity)||(u="NORMAL")),l===n.NORMAL&&(!d.skipSync||0!==(null==d?void 0:d.quantity)&&-2!==(null==d?void 0:d.quantity)||(u="NOT_SYNCED"),d.skipSync&&0!==(null==d?void 0:d.quantity)&&-2!==(null==d?void 0:d.quantity)&&(u="NOT_SYNCED"),d.skipSync||0!==(null==d?void 0:d.quantity)&&-2!==(null==d?void 0:d.quantity)||(u="NORMAL"),d.skipSync||0===(null==d?void 0:d.quantity)||-2===(null==d?void 0:d.quantity)||(u="NORMAL")),t[u]}}const l=n=>{let t=[];Object.keys(n).forEach((i=>{var l;return Object.keys((null===(l=null==n?void 0:n[i])||void 0===l?void 0:l.products)||[]).forEach((l=>{var u,d;const o=null!==(u=n[i].products)&&void 0!==u?u:[],a=null!==(d=o[l].variants)&&void 0!==d?d:[];return Object.keys(a).map((n=>{const t=a[n];t.variantId=n,t.productId=l,t.collectionId=i,t.productName=o[l].name})),t=[...t,...Object.values(a)],t}))}));const i=t.sort(((n,t)=>null==n.displayOrder&&null==t.displayOrder?0:null==n.displayOrder?1:null==t.displayOrder?-1:n.displayOrder-t.displayOrder));return i.forEach(((n,t)=>{n.displayOrder=t})),i};export{i as ProductHelper,l as parseSelectedVariantsToArray};
|