@bikdotai/bik-component-library 0.0.455-beta.13 → 0.0.455-beta.ppi-1
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/analytics-chips-and-dropdowns/AnalyticsTrend.js +1 -1
- package/dist/cjs/components/product-picker-v2/ProductPickerTag.d.ts +8 -0
- package/dist/cjs/components/product-picker-v2/ProductPickerTag.js +1 -0
- package/dist/cjs/components/product-picker-v2/collectionScreen.d.ts +19 -0
- package/dist/cjs/components/product-picker-v2/collectionScreen.js +1 -1
- package/dist/cjs/components/product-picker-v2/helpers/ProductHelper.d.ts +2 -0
- package/dist/cjs/components/product-picker-v2/helpers/ProductHelper.js +1 -1
- package/dist/cjs/components/product-picker-v2/modal.d.ts +16 -3
- package/dist/cjs/components/product-picker-v2/modal.js +1 -1
- package/dist/cjs/components/product-picker-v2/productInfoOverlay.d.ts +11 -0
- package/dist/cjs/components/product-picker-v2/productInfoOverlay.js +39 -0
- package/dist/cjs/components/product-picker-v2/productScreen.d.ts +10 -3
- package/dist/cjs/components/product-picker-v2/productScreen.js +1 -1
- package/dist/cjs/components/product-picker-v2/rearrangeScreen.d.ts +3 -1
- package/dist/cjs/components/product-picker-v2/rearrangeScreen.js +1 -1
- package/dist/cjs/components/product-picker-v2/reducers.d.ts +7 -1
- package/dist/cjs/components/product-picker-v2/reducers.js +1 -1
- package/dist/cjs/components/product-picker-v2/searchScreen.d.ts +10 -3
- package/dist/cjs/components/product-picker-v2/searchScreen.js +1 -1
- package/dist/cjs/components/product-picker-v2/selectedScreen.d.ts +5 -1
- package/dist/cjs/components/product-picker-v2/selectedScreen.js +1 -1
- package/dist/cjs/components/product-picker-v2/style.d.ts +1 -0
- package/dist/cjs/components/product-picker-v2/style.js +13 -8
- package/dist/cjs/components/product-picker-v2/utility.d.ts +12 -0
- package/dist/cjs/components/product-picker-v2/utility.js +1 -1
- package/dist/cjs/components/product-picker-v2/variant.js +1 -1
- package/dist/cjs/components/template-context-mapper/utils/getFormattedMonthDate.js +1 -0
- package/dist/esm/components/analytics-chips-and-dropdowns/AnalyticsTrend.js +1 -1
- package/dist/esm/components/product-picker-v2/ProductPickerTag.d.ts +8 -0
- package/dist/esm/components/product-picker-v2/ProductPickerTag.js +1 -0
- package/dist/esm/components/product-picker-v2/collectionScreen.d.ts +19 -0
- package/dist/esm/components/product-picker-v2/collectionScreen.js +1 -1
- package/dist/esm/components/product-picker-v2/helpers/ProductHelper.d.ts +2 -0
- package/dist/esm/components/product-picker-v2/helpers/ProductHelper.js +1 -1
- package/dist/esm/components/product-picker-v2/modal.d.ts +16 -3
- package/dist/esm/components/product-picker-v2/modal.js +1 -1
- package/dist/esm/components/product-picker-v2/productInfoOverlay.d.ts +11 -0
- package/dist/esm/components/product-picker-v2/productInfoOverlay.js +39 -0
- package/dist/esm/components/product-picker-v2/productScreen.d.ts +10 -3
- package/dist/esm/components/product-picker-v2/productScreen.js +1 -1
- package/dist/esm/components/product-picker-v2/rearrangeScreen.d.ts +3 -1
- package/dist/esm/components/product-picker-v2/rearrangeScreen.js +1 -1
- package/dist/esm/components/product-picker-v2/reducers.d.ts +7 -1
- package/dist/esm/components/product-picker-v2/reducers.js +1 -1
- package/dist/esm/components/product-picker-v2/searchScreen.d.ts +10 -3
- package/dist/esm/components/product-picker-v2/searchScreen.js +1 -1
- package/dist/esm/components/product-picker-v2/selectedScreen.d.ts +5 -1
- package/dist/esm/components/product-picker-v2/selectedScreen.js +1 -1
- package/dist/esm/components/product-picker-v2/style.d.ts +1 -0
- package/dist/esm/components/product-picker-v2/style.js +13 -8
- package/dist/esm/components/product-picker-v2/utility.d.ts +12 -0
- package/dist/esm/components/product-picker-v2/utility.js +1 -1
- package/dist/esm/components/product-picker-v2/variant.js +1 -1
- package/dist/esm/components/template-context-mapper/utils/getFormattedMonthDate.js +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),i=require("../../constants/Theme.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),i=require("../../constants/Theme.js"),s=require("../../assets/icons/arrow_down.svg.js"),n=require("../../assets/icons/arrow_up.svg.js"),r=require("../../assets/icons/info.svg.js"),o=require("../tag/Tag.js"),a=require("../template-context-mapper/utils/getFormattedMonthDate.js"),l=require("../tooltips/Tooltip.js"),c=require("../TypographyStyle.js"),d=require("./CommonStyles.js");function g(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var h=g(t);const y=t=>{let{percent:r,direction:o,timeline:l,customRange:d}=t;const g="negative"===o?s.default:n.default,h="negative"===o?i.COLORS.background.negative.vibrant:"positive"===o?i.COLORS.background.positive.vibrant:i.COLORS.content.placeholder,y="today"===l?"vs yesterday":"yesterday"===l?"vs 1 day before":"7 days"===l?"vs last 7 days":"30 days"===l?"vs last 30 days":"custom"===l&&d?`vs ${a.getFormattedMonthDate(d[0])} - ${a.getFormattedMonthDate(d[1])}`:"";return e.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",flexDirection:"row"}},{children:["number"==typeof r&&e.jsx(g,{color:h,height:20,width:20,style:{marginRight:2}}),"number"==typeof r&&o&&e.jsxs(c.TitleSmall,Object.assign({style:{color:h}},{children:["neutral"===o?0:r,"%"]})),l&&e.jsx(c.Caption,Object.assign({style:{marginLeft:4,color:i.COLORS.content.placeholder}},{children:y}))]}))};exports.AnalyticsTrend=t=>{let{title:s,value:n,trendPercent:a,type:g="horizontal",timeline:p,customRange:u,tooltip:j,card:m=!0,rightSeparator:b=!1,size:v="big",share:x=!1,formatVal:O,prefixSymbol:f,trailingIcon:R,onTrailIconClick:C,iconTooltipBody:S}=t;const T="big"===v?c.TitleLarge:c.TitleMedium,w=void 0!==a?a<0?"negative":0===a?"neutral":"positive":void 0,L=void 0!==a?x?Math.round(a):Math.abs(Math.round(a)):void 0;return e.jsx(d.AnalyticsTrendContainer,Object.assign({card:m},{children:e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:4,borderRightWidth:b?1:0,borderRightColor:i.COLORS.stroke.primary,borderRightStyle:"solid",paddingLeft:m?0:24,paddingRight:m?0:24,height:"100%",justifyContent:"space-between",alignItems:"center"}},{children:[e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:4,height:"100%"}},{children:[e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:4,alignItems:"center"}},{children:[e.jsx(c.BodySecondary,Object.assign({style:{color:i.COLORS.content.secondary}},{children:s})),j&&e.jsx(l.Tooltip,Object.assign({body:j,placement:"right",width:300},{children:e.jsx("div",Object.assign({style:{display:"flex",alignItems:"center",cursor:"pointer"}},{children:e.jsx(r.default,{color:i.COLORS.content.inactive,height:16,width:16})}))}))]})),e.jsxs("div",Object.assign({style:Object.assign({display:"flex",flexDirection:"row",gap:12,alignItems:"center"},x?{justifyContent:"space-between"}:{})},{children:[e.jsx(T,Object.assign({style:{color:i.COLORS.content.primary}},{children:void 0===n?"--":"number"==typeof n&&O?`${null!=f?f:""}${new Intl.NumberFormat("en-IN",{}).format(n)}`:`${null!=f?f:""}${n}`})),"horizontal"===g&&!x&&e.jsx(y,{timeline:p,customRange:u,percent:L,direction:w}),x&&void 0!==L&&e.jsx(o.Tag,{tagText:`${L} %`,theme:"light",type:"neutral"})]})),"vertical"===g&&!x&&e.jsx("div",Object.assign({style:{marginTop:12}},{children:e.jsx(y,{timeline:p,customRange:u,percent:L,direction:w})}))]})),S&&e.jsx(l.Tooltip,Object.assign({body:S,placement:"right"},{children:R&&e.jsx("div",Object.assign({className:"icon--holder",onClick:C},{children:h.default.createElement(R,{height:20,width:20,color:i.COLORS.content.secondary})}))}))]}))}))};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Product, ProductVariant } from './modal';
|
|
2
|
+
import { OUT_OF_STOCK_ACTION } from './type';
|
|
3
|
+
export type ProductPickerTagType = {
|
|
4
|
+
isVariant: boolean;
|
|
5
|
+
data: Product | ProductVariant;
|
|
6
|
+
outOfStockAction?: OUT_OF_STOCK_ACTION;
|
|
7
|
+
};
|
|
8
|
+
export declare const ProductPickerTag: (props: ProductPickerTagType) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../shimmer/ShimmerComponent/BikShimmer.js"),r=require("../tag/Tag.js"),i=require("./helpers/ProductHelper.js");exports.ProductPickerTag=s=>{var l,a;const{isVariant:n,data:o,outOfStockAction:u}=s;let d=o,c=n;1===Object.keys(null!==(l=null==o?void 0:o.variants)&&void 0!==l?l:{}).length&&(d=Object.values(null!==(a=null==o?void 0:o.variants)&&void 0!==a?a:{})[0],c=!0);const p=i.ProductHelper.getProductLabels(d,u),g=i.ProductHelper.getTagType(null!=p?p:"");return e.jsx("div",Object.assign({style:{display:"flex"}},{children:!(null==d?void 0:d.fbStatus)&&c?e.jsx(t.BikShimmer,{boxes:[{height:"24px",width:"100px",marginTop:"0px"}]}):p?e.jsx("div",Object.assign({style:{display:"flex"}},{children:e.jsx(r.Tag,{tagText:p,type:g,theme:"light"})})):e.jsx(e.Fragment,{})}))};
|
|
@@ -13,6 +13,7 @@ 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>>;
|
|
16
17
|
setScreen: React.Dispatch<React.SetStateAction<string>>;
|
|
17
18
|
collectionsDispatch: React.Dispatch<CollectionsActions>;
|
|
18
19
|
setSaveDisabled: React.Dispatch<boolean>;
|
|
@@ -25,4 +26,22 @@ interface CollectionsScreenInterface {
|
|
|
25
26
|
pickerType?: 'COLLECTION' | 'PRODUCT';
|
|
26
27
|
}
|
|
27
28
|
export declare const CollectionsScreen: (props: CollectionsScreenInterface) => import("react/jsx-runtime").JSX.Element;
|
|
29
|
+
export interface CollectionCardInterface {
|
|
30
|
+
customCollectionRestriction?: boolean;
|
|
31
|
+
data: Collection;
|
|
32
|
+
selectedCollectionsDispatch: React.Dispatch<SelectedCollectionsActions>;
|
|
33
|
+
setCollectionId: React.Dispatch<React.SetStateAction<string>>;
|
|
34
|
+
setSelectedCollectionId: React.Dispatch<React.SetStateAction<string>>;
|
|
35
|
+
setScreen: React.Dispatch<React.SetStateAction<string>>;
|
|
36
|
+
id: string;
|
|
37
|
+
isChecked: boolean;
|
|
38
|
+
isDisabled: boolean;
|
|
39
|
+
isPartiallyChecked: boolean;
|
|
40
|
+
hideCollectionCheckbox?: boolean;
|
|
41
|
+
renderWithoutModal?: boolean;
|
|
42
|
+
pickerType?: 'COLLECTION' | 'PRODUCT';
|
|
43
|
+
selectedCollections: SelectedItems;
|
|
44
|
+
usedInSearch?: boolean;
|
|
45
|
+
}
|
|
46
|
+
export declare const CollectionCard: (props: CollectionCardInterface) => import("react/jsx-runtime").JSX.Element;
|
|
28
47
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/chevronRight.svg.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/chevronRight.svg.js"),s=require("react"),i=require("../checkBox/CheckBox.js"),o=require("../icon-button/IconButton.js"),l=require("../shimmer/ShimmerComponent/BikShimmer.js"),c=require("../tag/Tag.js"),r=require("../tooltips/Tooltip.js"),n=require("../TypographyStyle.js"),d=require("./emptyState.js"),a=require("./style.js");const u=(e,t,s)=>{if(e.length<=t)return e;const i=e.slice(0,t-1);return(s?i.slice(0,i.lastIndexOf(" ")):i)+"..."},h=s=>{const{customCollectionRestriction:l,data:d,selectedCollectionsDispatch:h,setCollectionId:p,setSelectedCollectionId:C,isPartiallyChecked:j,setScreen:x,id:y,isChecked:g,isDisabled:m,hideCollectionCheckbox:v,pickerType:b,selectedCollections:k,usedInSearch:f}=s;console.log("collection card props",{id:y,props:s});return e.jsxs(a.CollectionCardStyle,Object.assign({isDisabled:m,onClick:e=>{if(!m){if("COLLECTION"===b)return e.stopPropagation(),h({type:"reset",data:{}}),h({type:"selected",data:{id:y,val:d,isRestricted:l}}),void p(y);p(y),x("products")}},isActive:!!k[y],usedInSearch:null!=f&&f},{children:[e.jsxs(a.CollectionCardInfoStyle,{children:[!v&&e.jsx(i.CheckBox,{isDisabled:m,isChecked:g,isPartiallyChecked:j,onValueChange:function(e,t,s){null==s||s.stopPropagation(),h(e?{type:"selected",data:{id:y,val:d,isRestricted:l}}:{type:"unselected",data:{id:y}}),C(e?y:"")}}),e.jsx(a.CollectionCardDetailStyle,{children:e.jsx(r.Tooltip,Object.assign({body:d.name,placement:"bottom",delay:400},{children:e.jsxs(a.CollectionNameHolder,{children:[f?e.jsx(n.BodyPrimary,{children:u(d.name,40,!0)}):e.jsx(n.TitleRegular,{children:u(d.name,40,!0)}),d.isSmartCollection?e.jsx("div",Object.assign({style:{display:"flex"}},{children:e.jsx(c.Tag,{tagText:"Smart Collection",type:"warning"})})):e.jsx(e.Fragment,{})]})}))})]}),"COLLECTION"!==b&&e.jsx(o.IconButton,{height:12,width:12,disabled:m,Icon:t.default})]}))};exports.CollectionCard=h,exports.CollectionsScreen=t=>{const{customCollectionRestriction:i,dataLoading:o,collections:c,selectedCollectionsDispatch:r,setCollectionId:n,setSelectedCollectionId:a,selectedCollections:u,setScreen:p,collectionFetcher:C,collectionsDispatch:j,pagingControls:x,storeId:y,setSaveDisabled:g,hideCollectionCheckbox:m,renderWithoutModal:v,pickerType:b}=t,k=s.useRef(null),f=s.useRef(x.curPage),S=!!i&&(null==u?void 0:u.isCustom),[O,I]=s.useState(!1),E=s.useRef(!1);s.useEffect((()=>{f.current=x.curPage}),[x.curPage]),s.useEffect((()=>{const e=new IntersectionObserver((e=>{e[0].isIntersecting&&f.current>0&&!E.current&&(g(!0),I(!0),C(f.current,y).then((e=>{j({type:"paged",data:(null==e?void 0:e.collections)||{}}),x.setCurPage(f.current+1),I(!1),g(!1),Object.keys(e).length||(E.current=!0)})).catch())}),{threshold:1});return k.current&&e.observe(k.current),()=>{k.current&&e.unobserve(k.current)}}),[k]);const T=e=>{var t,s;let i=0,o=0;if(u[e]){const l=null===(t=c[e])||void 0===t?void 0:t.products;l&&Object.keys(l).forEach((e=>{var t;const s=null===(t=l[e])||void 0===t?void 0:t.variants;s&&Object.keys(s).forEach((e=>i+=1))}));const r=null===(s=u[e])||void 0===s?void 0:s.products;return r&&Object.keys(r).forEach((e=>{var t;const s=null===(t=r[e])||void 0===t?void 0:t.variants;s&&Object.keys(s).forEach((e=>o+=1))})),!(i<=0&&o>0)&&(o>0&&i!==o)}return!1};return e.jsxs("div",{children:[Object.keys(c).length?Object.keys(c).map((t=>e.jsx(h,{customCollectionRestriction:i,data:c[t],isDisabled:S&&!(null==u?void 0:u[t]),isChecked:!!(null==u?void 0:u[t]),isPartiallyChecked:T(t),selectedCollectionsDispatch:r,setCollectionId:n,setSelectedCollectionId:a,setScreen:p,id:t,hideCollectionCheckbox:m||"-1"===t,selectedCollections:u,renderWithoutModal:v,pickerType:b},t))):o?[1,2,3,4,5,6,7,8,9,10].map(((t,s)=>e.jsx("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(l.BikShimmer,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),s))):e.jsx(d.EmptyState,{title:"No collections to show",subtitle:"We couldn’t find any collection."}),e.jsx("div",{ref:k}),O&&[1,2,3,4,5].map(((t,s)=>e.jsx("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(l.BikShimmer,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),s)))]})},exports.truncate=u;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { TagType } from "../../tag/model";
|
|
1
2
|
import { Product, ProductVariant, SelectedItems } from '../modal';
|
|
2
3
|
import { OUT_OF_STOCK_ACTION } from '../type';
|
|
3
4
|
import { ProductVariantForRearrange } from '../variant';
|
|
@@ -31,6 +32,7 @@ export declare class ProductHelper {
|
|
|
31
32
|
* @param outOfStockAction
|
|
32
33
|
*/
|
|
33
34
|
static getProductLabels(productVariant: Product | ProductVariant, outOfStockAction?: OUT_OF_STOCK_ACTION): string | null;
|
|
35
|
+
static getTagType: (tagText: string) => TagType;
|
|
34
36
|
}
|
|
35
37
|
/**
|
|
36
38
|
* 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",FB_REJECTED:"Rejected on FB catalog"};class l{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 e=l;return"REJECTED"===(null==e?void 0:e.fbStatus)?n.FB_REJECTED:(i===t.OUT_OF_STOCK_ACTION.HIDE&&(!e.skipSync||0!==(null==e?void 0:e.quantity)&&-2!==(null==e?void 0:e.quantity)||(u="NOT_SYNCED"),e.skipSync&&0!==(null==e?void 0:e.quantity)&&-2!==(null==e?void 0:e.quantity)&&(u="NOT_SYNCED"),e.skipSync||0!==(null==e?void 0:e.quantity)&&-2!==(null==e?void 0:e.quantity)||(u="NOT_SYNCED"),e.skipSync||0===(null==e?void 0:e.quantity)||-2===(null==e?void 0:e.quantity)||(u="NORMAL")),i===t.OUT_OF_STOCK_ACTION.BLUR&&(!e.skipSync||0!==(null==e?void 0:e.quantity)&&-2!==(null==e?void 0:e.quantity)||(u="NOT_SYNCED"),e.skipSync&&0!==(null==e?void 0:e.quantity)&&-2!==(null==e?void 0:e.quantity)&&(u="NOT_SYNCED"),e.skipSync||0!==(null==e?void 0:e.quantity)&&-2!==(null==e?void 0:e.quantity)||(u="OUT_OF_STOCK"),e.skipSync||0===(null==e?void 0:e.quantity)||-2===(null==e?void 0:e.quantity)||(u="NORMAL")),i===t.OUT_OF_STOCK_ACTION.NORMAL&&(!e.skipSync||0!==(null==e?void 0:e.quantity)&&-2!==(null==e?void 0:e.quantity)||(u="NOT_SYNCED"),e.skipSync&&0!==(null==e?void 0:e.quantity)&&-2!==(null==e?void 0:e.quantity)&&(u="NOT_SYNCED"),e.skipSync||0!==(null==e?void 0:e.quantity)&&-2!==(null==e?void 0:e.quantity)||(u="NORMAL"),e.skipSync||0===(null==e?void 0:e.quantity)||-2===(null==e?void 0:e.quantity)||(u="NORMAL")),n[u])}}Object.defineProperty(l,"getTagType",{enumerable:!0,configurable:!0,writable:!0,value:t=>n.FB_REJECTED===t?"negative":"warning"});exports.ProductHelper=l,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,e;const a=null!==(u=t[l].products)&&void 0!==u?u:[],d=null!==(e=a[i].variants)&&void 0!==e?e:[];return Object.keys(d).map((t=>{const n=d[t];n.variantId=t,n.productId=i,n.collectionId=l,n.productName=a[i].name})),n=[...n,...Object.values(d)],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,10 +7,13 @@ export interface ProductVariant {
|
|
|
7
7
|
quantity: number;
|
|
8
8
|
skipSync?: boolean;
|
|
9
9
|
displayOrder?: number | null;
|
|
10
|
+
fbStatus?: FbProductStatus;
|
|
11
|
+
description?: string;
|
|
10
12
|
}
|
|
11
13
|
export interface Product {
|
|
12
14
|
name: string;
|
|
13
15
|
image: string;
|
|
16
|
+
description?: string;
|
|
14
17
|
variants?: {
|
|
15
18
|
[key: string]: ProductVariant;
|
|
16
19
|
};
|
|
@@ -26,6 +29,10 @@ export interface Collection {
|
|
|
26
29
|
export type SelectedItems = {
|
|
27
30
|
[key: string]: Collection;
|
|
28
31
|
};
|
|
32
|
+
export type SearchedItems = {
|
|
33
|
+
collections: SelectedItems;
|
|
34
|
+
products: SelectedItems;
|
|
35
|
+
};
|
|
29
36
|
export type CollectionFetcherReturn = Promise<{
|
|
30
37
|
collections: {
|
|
31
38
|
[key: string]: {
|
|
@@ -38,6 +45,10 @@ export type CollectionFetcherReturn = Promise<{
|
|
|
38
45
|
export type ProductFetcherReturn = Promise<{
|
|
39
46
|
[key: string]: Product;
|
|
40
47
|
}>;
|
|
48
|
+
export type FbStatusFetcherReturn = Promise<{
|
|
49
|
+
[key: string]: FbProductStatus;
|
|
50
|
+
}>;
|
|
51
|
+
export type FbProductStatus = 'APPROVED' | 'REJECTED';
|
|
41
52
|
export declare enum ScreenName {
|
|
42
53
|
Collections = "collections",
|
|
43
54
|
RearrangeProducts = "rearrange",
|
|
@@ -49,10 +60,11 @@ export type ProductPickerInterface = {
|
|
|
49
60
|
hideGlobalSearch?: boolean;
|
|
50
61
|
hideInCollectionSearch?: boolean;
|
|
51
62
|
customCollectionRestriction?: boolean;
|
|
52
|
-
searchInCollectionFetcher: (storeId: string, collectionId: string, query: string) =>
|
|
53
|
-
searchFetcher: (storeId: string, query: string) => Promise<SelectedItems>;
|
|
63
|
+
searchInCollectionFetcher: (storeId: string, collectionId: string, query: string) => ProductFetcherReturn;
|
|
64
|
+
searchFetcher: (storeId: string, query: string) => Promise<SearchedItems | SelectedItems>;
|
|
54
65
|
collectionFetcher: (offset: number, storeId: string) => CollectionFetcherReturn;
|
|
55
|
-
productFetcher: (collectionId: string, storeId: string) => ProductFetcherReturn;
|
|
66
|
+
productFetcher: (collectionId: string, storeId: string, limit?: number, offset?: number) => ProductFetcherReturn;
|
|
67
|
+
fbStatusFetcher?: (storeId: string, variantIds: string[]) => FbStatusFetcherReturn;
|
|
56
68
|
storeId: string;
|
|
57
69
|
selectedItems: SelectedItems;
|
|
58
70
|
onAdd: (items: SelectedItems, total: number) => void;
|
|
@@ -77,6 +89,7 @@ export type ProductPickerInterface = {
|
|
|
77
89
|
rearrangeEnabled?: boolean;
|
|
78
90
|
selectSingleItem?: boolean;
|
|
79
91
|
stickyFooter?: boolean;
|
|
92
|
+
showProductDetailInfoIcon?: boolean;
|
|
80
93
|
} & ({
|
|
81
94
|
startupScreen: ScreenName.RearrangeProducts;
|
|
82
95
|
rearrangeEnabled: true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react/jsx-runtime"),o=require("../../assets/icons/search.svg.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react/jsx-runtime"),o=require("../../assets/icons/search.svg.js"),c=require("react"),r=require("../../constants/Theme.js"),s=require("../button/Button.js"),n=require("../input/Input.js"),i=require("../modals/styledModal.js"),l=require("../spinner/Spinner.js"),a=require("../tag/Tag.js"),d=require("./collectionScreen.js"),u=require("./productInfoOverlay.js"),h=require("./productScreen.js"),p=require("./rearrangeScreen.js"),S=require("./reducers.js"),C=require("./searchScreen.js"),x=require("./selectedScreen.js"),g=require("./style.js"),j=require("./type.js");exports.ScreenName=void 0,(e=exports.ScreenName||(exports.ScreenName={})).Collections="collections",e.RearrangeProducts="rearrange",e.SelectedProducts="view",e.SearchProducts="searchProducts",e.Products="products";exports.ProductPickerModal=e=>{const{storeId:y,selectedItems:b,onClose:f,visible:m,zIndex:v,exactLimit:P,limit:I,hideCollectionCheckbox:k,hideProductCheckbox:F,outOfStockAction:O=j.OUT_OF_STOCK_ACTION.BLUR,hideVariantCheckbox:R,selectProductsFromCustomCollection:T,hideSelectionCount:q,title:D,width:E,renderWithoutModal:w,onClickSave:N,pickerType:A,hideProductVariants:B=!1,startupScreen:M=exports.ScreenName.Collections,rearrangeEnabled:$,selectSingleItem:L=!1,showProductDetailInfoIcon:V}=e,[_,z]=c.useReducer(S.collectionsReducer,{}),[W,G]=c.useState([exports.ScreenName.Collections,exports.ScreenName.RearrangeProducts].includes(M)?M:exports.ScreenName.Collections),[H,K]=c.useState("grid"),[U,Y]=c.useState(""),[J,Q]=c.useState(""),[X,Z]=c.useState(0),[ee,te]=c.useState(!1),[oe,ce]=c.useState(0),[re,se]=c.useState(""),[ne,ie]=c.useState(!1),[le,ae]=c.useState(!1),[de,ue]=c.useReducer(S.searchReducer,{collections:{},products:{}}),[he,pe]=c.useReducer(S.selectedColectionsReducer,Object.keys(b).length>0?b:{}),Se=c.useRef(null),[Ce,xe]=c.useState(!1),[ge,je]=c.useState();c.useEffect((()=>{te(!0),ae(!0),e.collectionFetcher(X,y).then((e=>{z({type:"fetched",data:(null==e?void 0:e.collections)||{}}),te(!1),Z((e=>e+1)),ae(!1)})).catch()}),[]),c.useEffect((()=>{let e=0;Object.keys(he||[]).forEach((t=>{var o;Object.keys((null===(o=he[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c,r;Object.keys((null===(r=null===(c=he[t].products)||void 0===c?void 0:c[o])||void 0===r?void 0:r.variants)||[]).forEach((()=>{e+=1}))}))})),ce(e)})),c.useEffect((()=>{J&&(te(!0),e.productFetcher(J,y).then((e=>{Object.keys(e).length&&z({type:"productsFetched",data:{collectionId:J,products:e}}),te(!1)})).catch())}),[J]),c.useEffect((()=>{const t=setTimeout((()=>{"rearrange"!==W&&(re.length?(ie(!0),e.searchFetcher(y,re).then((e=>{ue("collections"in e&&"products"in e?{type:"set",data:e}:{type:"set",data:{collections:{},products:e}}),G("searchProducts"),te(!1),ie(!1)}))):G("collections"))}),800);return()=>clearTimeout(t)}),[re]),c.useEffect((()=>{N&&(e.onAdd(he,oe),ye())}),[N]),c.useEffect((()=>{L&&Object.keys(he||{}).length&&oe&&(e.onAdd(he,oe),ye())}),[L,he,oe]);const ye=()=>{pe({type:"reset",data:{}})},be=t.jsxs(g.ContainerStyle,{children:[e.postHeader&&t.jsx("div",Object.assign({style:{padding:"0 24px"}},{children:e.postHeader})),!e.hideGlobalSearch&&t.jsx(t.Fragment,{children:("collections"===W||"searchProducts"===W)&&t.jsx("div",Object.assign({style:{padding:w?"8px 16px":"12px 24px",borderBottom:"1px solid #E0E0E0"}},{children:t.jsx(n.Input,{noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>ne?t.jsx(l.Spinner,{size:"small",color:r.COLORS.content.primary}):t.jsx(o.default,{})},id:"listInput",height:"24px",type:"text",value:re,onChangeText:e=>{e.length&&e.trim().length?se(e):se("")}})}))}),t.jsxs(g.ScrollContainerStyle,Object.assign({ref:Se},{children:["collections"===W&&t.jsx(d.CollectionsScreen,{customCollectionRestriction:e.customCollectionRestriction,dataLoading:le,collections:_,selectedCollectionsDispatch:pe,setCollectionId:Y,setSelectedCollectionId:Q,setScreen:G,selectedCollections:he,collectionFetcher:e.collectionFetcher,storeId:y,collectionsDispatch:z,setSaveDisabled:te,pagingControls:{curPage:X,setCurPage:Z},hideCollectionCheckbox:k,renderWithoutModal:w,pickerType:A}),"products"===W&&U&&t.jsx(S.CollectionIdContext.Provider,Object.assign({value:U},{children:t.jsx(h.ProductsScreen,{hideInCollectionSearch:e.hideInCollectionSearch,customCollectionRestriction:e.customCollectionRestriction,productFetcher:e.productFetcher,setScreen:G,storeId:y,data:_[U],collectionsDispatch:z,selectedCollectionsDispatch:pe,selectedData:he,setSaveDisabled:te,searchInCollectionFetcher:e.searchInCollectionFetcher,hideProductCheckbox:F,outOfStockAction:O,hideVariantCheckbox:R,selectProductsFromCustomCollection:T,renderWithoutModal:w,pickerType:A,hideProductVariants:B,fbStatusFetcher:e.fbStatusFetcher,onInfoIconClick:e=>{xe(!0),je(e)},showProductDetailInfoIcon:V})})),"view"===W&&t.jsx(x.SelectedScreen,{selectedCollections:he||{},selectedCollectionsDispatch:pe,setScreen:G,collections:_,outOfStockAction:O,storeId:y,fbStatusFetcher:e.fbStatusFetcher}),"rearrange"===W&&t.jsx(p.RearrangeScreen,{selectedCollections:he||{},selectedCollectionsDispatch:pe,setScreen:G,outOfStockAction:O,rearrangeViewType:"grid"===H?"list":"grid",scrollContainerRef:Se,storeId:y,fbStatusFetcher:e.fbStatusFetcher}),"searchProducts"===W&&t.jsx(C.SearchScreen,{customCollectionRestriction:e.customCollectionRestriction,selectedCollections:he||{},searchedCollections:de||{},searchedCollectionsDispatch:ue,selectedCollectionsDispatch:pe,setScreen:G,collections:_,onBackPress:()=>{se(""),ue({type:"set",data:{collections:{},products:{}}})},pickerType:A,hideProductCheckbox:F,hideProductVariants:B,hideVariantCheckbox:R,storeId:y,fbStatusFetcher:e.fbStatusFetcher,setCollectionId:Y,setSelectedCollectionId:Q,renderWithoutModal:w,hideCollectionCheckbox:k})]}))]});return t.jsx(t.Fragment,{children:w?be:t.jsxs(i.StyledModal,Object.assign({zIndex:v,open:m,onClose:()=>{null==f||f(),ye()},headingTitle:D||("collections"===W||"products"===W?"Select Products":"view"===W?"Selected Products":"searchProducts"===W?"Searched Products":"rearrange"===W?"Rearrange Products":void 0),footerShadow:!0,centralContainerStyles:{width:E||"600px"},headerRightCustomElement:"rearrange"===W?(console.log("ignore:",K),t.jsx(t.Fragment,{})):t.jsx(t.Fragment,{}),footerContainerStyle:e.stickyFooter?{position:"absolute",bottom:0,left:0,width:"100%",zIndex:9,background:r.COLORS.surface.standard}:void 0,primaryButton:{buttonText:ee?"Loading...":W===exports.ScreenName.RearrangeProducts?"Done":"Add",disabled:ee||oe<1||P&&oe<P||!P&&I&&oe>I||!1,onClick:()=>{e.onAdd(he,oe),ye()}},wrapperStyle:e.stickyFooter?{height:"calc(100vh - 168px)"}:void 0,footerLeftCustomElement:q?t.jsx(t.Fragment,{}):P&&oe>P?t.jsx(a.Tag,{tagText:`You can only select ${P} products`,type:"negative"}):I&&oe>I?t.jsx(a.Tag,{tagText:`You can only select ${I} products`,type:"negative"}):oe>0?t.jsx(s.Button,{onClick:()=>{G($?exports.ScreenName.RearrangeProducts:exports.ScreenName.SelectedProducts)},buttonText:P?`${oe}/${P} products selected`:`${oe} products selected`,buttonType:["rearrange","view"].includes(W)?"tertiaryGray":"tertiary",disabled:["rearrange","view"].includes(W)}):t.jsx(s.Button,{disabled:!0,buttonText:P?`${oe}/${P} products selected`:`${oe} products selected`,buttonType:"tertiaryGray"}),hideCrossButton:Ce},{children:[be,Ce&&ge?t.jsx(u.ProductInfoOverlay,{productData:ge,outOfStockAction:O,onClose:()=>{xe(!1)}}):t.jsx(t.Fragment,{})]}))})};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Product, ProductVariant } from './modal';
|
|
2
|
+
import { OUT_OF_STOCK_ACTION } from './type';
|
|
3
|
+
export declare const ProductInfoOverlay: (props: {
|
|
4
|
+
productData: Product | ProductVariant;
|
|
5
|
+
onClose: () => void;
|
|
6
|
+
outOfStockAction?: OUT_OF_STOCK_ACTION;
|
|
7
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export declare const ProductInfoCard: (props: {
|
|
9
|
+
productData: Product | ProductVariant;
|
|
10
|
+
outOfStockAction?: OUT_OF_STOCK_ACTION;
|
|
11
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("styled-components"),o=require("../../constants/Theme.js"),r=require("../../assets/icons/cross.svg.js"),i=require("../icon-button/IconButton.js"),a=require("../shimmer-image/ShimmerImage.js"),s=require("../TypographyStyle.js"),d=require("./ProductPickerTag.js");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var l=n(t);const c=t=>{var o;console.log("vj: product data",t);const r=void 0===t.productData.variants;return e.jsxs(f,{children:[e.jsx(g,{children:e.jsx(a.ShimmerImage,{imageUrl:t.productData.image,width:"200px",height:200,borderRadius:4})}),e.jsxs(h,{children:[e.jsx(s.TitleSmall,Object.assign({style:{display:"flex"}},{children:t.productData.name})),e.jsx(s.BodyCaption,{style:{display:"flex",flexDirection:"column"},dangerouslySetInnerHTML:{__html:null!==(o=t.productData.description)&&void 0!==o?o:""}}),e.jsx(d.ProductPickerTag,{isVariant:r,data:t.productData,outOfStockAction:t.outOfStockAction})]})]})},u=l.default.div`
|
|
2
|
+
display: flex;
|
|
3
|
+
flex: 1;
|
|
4
|
+
background: rgba(0, 0, 0, 0.5);
|
|
5
|
+
flex-direction: column;
|
|
6
|
+
width: 100%;
|
|
7
|
+
height: 100%;
|
|
8
|
+
position: absolute;
|
|
9
|
+
bottom: 0;
|
|
10
|
+
z-index: 10;
|
|
11
|
+
`,p=l.default.div`
|
|
12
|
+
display: flex;
|
|
13
|
+
flex: 1;
|
|
14
|
+
background: rgba(0, 0, 0, 0.5);
|
|
15
|
+
`,x=l.default.div`
|
|
16
|
+
position: relative;
|
|
17
|
+
|
|
18
|
+
.close-button {
|
|
19
|
+
position: absolute;
|
|
20
|
+
top: -50px;
|
|
21
|
+
right: 0px;
|
|
22
|
+
margin: 10px;
|
|
23
|
+
background: ${o.COLORS.surface.standard};
|
|
24
|
+
border-radius: 50%;
|
|
25
|
+
}
|
|
26
|
+
`,f=l.default.div`
|
|
27
|
+
display: flex;
|
|
28
|
+
background: white;
|
|
29
|
+
padding: 24px;
|
|
30
|
+
gap: 24px;
|
|
31
|
+
border-radius: 8px 8px 0px 0px;
|
|
32
|
+
`,g=l.default.div`
|
|
33
|
+
display: flex;
|
|
34
|
+
`,h=l.default.div`
|
|
35
|
+
display: flex;
|
|
36
|
+
flex: 1;
|
|
37
|
+
flex-direction: column;
|
|
38
|
+
gap: 10px;
|
|
39
|
+
`;exports.ProductInfoCard=c,exports.ProductInfoOverlay=t=>e.jsxs(u,{children:[e.jsx(p,{}),e.jsx(x,{children:e.jsx(i.IconButton,{className:"close-button",onClick:t.onClose,Icon:r.default,width:20,height:20})}),e.jsx(c,{productData:t.productData,outOfStockAction:t.outOfStockAction})]});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Collection, Product, ProductFetcherReturn, ProductVariant, SelectedItems } from '.';
|
|
2
|
+
import { Collection, FbStatusFetcherReturn, 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) => ProductFetcherReturn;
|
|
12
|
+
searchInCollectionFetcher: (storeId: string, collectionId: string, query: string) => ProductFetcherReturn;
|
|
13
|
+
productFetcher: (collectionId: string, storeId: string, limit?: number, offset?: number) => ProductFetcherReturn;
|
|
14
14
|
storeId: string;
|
|
15
15
|
setScreen: React.Dispatch<React.SetStateAction<string>>;
|
|
16
16
|
setSaveDisabled: React.Dispatch<React.SetStateAction<boolean>>;
|
|
@@ -21,6 +21,9 @@ 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;
|
|
24
27
|
}
|
|
25
28
|
export declare const ProductsScreen: (props: ProductsScreenInterface) => import("react/jsx-runtime").JSX.Element;
|
|
26
29
|
interface ProductGroupInterface {
|
|
@@ -36,7 +39,9 @@ interface ProductGroupInterface {
|
|
|
36
39
|
outOfStockAction?: OUT_OF_STOCK_ACTION;
|
|
37
40
|
hideVariantCheckbox?: boolean;
|
|
38
41
|
hideProductVariants?: boolean;
|
|
42
|
+
showProductDetailInfoIcon?: boolean;
|
|
39
43
|
pickerType?: 'COLLECTION' | 'PRODUCT';
|
|
44
|
+
onInfoIconClick?: (productData: Product | ProductVariant) => void;
|
|
40
45
|
}
|
|
41
46
|
export declare const ProductGroup: (props: ProductGroupInterface) => import("react/jsx-runtime").JSX.Element;
|
|
42
47
|
interface ProductCardInterface {
|
|
@@ -54,7 +59,9 @@ interface ProductCardInterface {
|
|
|
54
59
|
outOfStockAction?: OUT_OF_STOCK_ACTION;
|
|
55
60
|
hideVariantCheckbox?: boolean;
|
|
56
61
|
hideProductVariants?: boolean;
|
|
62
|
+
showProductDetailInfoIcon?: boolean;
|
|
57
63
|
pickerType?: 'COLLECTION' | 'PRODUCT';
|
|
64
|
+
onInfoIconClick?: (productData: Product | ProductVariant) => void;
|
|
58
65
|
}
|
|
59
66
|
export declare const ProductCard: (props: ProductCardInterface) => import("react/jsx-runtime").JSX.Element;
|
|
60
67
|
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"),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
|
+
"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"),c=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"),I=require("./type.js"),y=require("./utility.js");const k=t=>{const{collectionId:o,productId:i,data:c,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,c,s,r,l,d;if(!(null===(c=null===(t=null==n?void 0:n[o])||void 0===t?void 0:t.products)||void 0===c?void 0:c[i]))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[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:c,productId:i,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[i]),isPartiallyChecked:d,selectedCollectionsDispatch:s,upliftAdditions:l,viewOnly:r,hideProductCheckbox:a,hideVariantCheckbox:h,hideProductVariants:v,pickerType:p,outOfStockAction:u,onInfoIconClick:j,showProductDetailInfoIcon:g},i),v?null:Object.keys(c.variants||[]).length>1&&Object.keys(c.variants||[]).map((t=>e.jsx(O,{isVariant:!0,hideVariantCheckbox:h,data:c.variants[t],variantId:t,productId:i,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:i,productId:c,collectionId:n,variantId:a,isSelected:u,selectedCollectionsDispatch:v,viewOnly:g,upliftAdditions:f,isPartiallyChecked:I,hideProductCheckbox:y,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:c,variantId:a||Object.keys(i.variants)[0],collectionId:n,variant:i}))},isActive:u},{children:[o&&!g&&!O||!o&&!g&&!y?e.jsx(l.CheckBox,{isChecked:u,isPartiallyChecked:I||!1,onValueChange:function(e){o?e?f("variantSelected",{productId:c,variantId:a,collectionId:n,variant:i}):v({type:"variantUnselected",data:{productId:c,variantId:a,collectionId:n}}):e?f("productSelected",{productId:c,collectionId:n,product:i}):v({type:"productUnselected",data:{productId:c,collectionId:n}})}}):e.jsx(e.Fragment,{}),e.jsx("div",{children:e.jsx(h.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==P||P(i)},Icon:()=>e.jsx(r.default,{width:20,height:20,color:s.COLORS.content.placeholder})})]})),e.jsx(b.ProductPickerTag,{isVariant:o,data:i,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=I.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=c.cloneDeep(h);t.products=e,Q(t);const o=y.getVariantIdsToFetchAtProductLevel(null!=e?e:{},h);$(o,null!=e?e:{},!0),S(!1),z(!1)}))):Q(h)}),800);return()=>clearTimeout(e)}),[M]),n.useEffect((()=>{var e,t,o,i,c,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===(i=Object.keys(null!==(o=h.products)&&void 0!==o?o:{}))||void 0===i?void 0:i.length)/10);const l=y.getVariantIdsToFetchAtProductLevel(null!==(c=h.products)&&void 0!==c?c:{});$(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,i,c,n,s,r,l;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===(n=Object.keys((null===(c=null===(i=null==h?void 0:h.products)||void 0===i?void 0:i[e])||void 0===c?void 0:c.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?y.markVariantsAsApprovedProductsLevel(t,p,U,G,Q):y.markVariantsAsApprovedProductsLevel(t,p,U)),e.length>0&&B&&B(m,e).then((e=>{const i=Object.assign({},t);if(Object.keys(t).forEach((o=>{var c,n,s;console.log("vj: response variants",null===(c=null==t?void 0:t[o])||void 0===c?void 0:c.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((c=>{var n,s;const r=null===(n=null==t?void 0:t[o].variants)||void 0===n?void 0:n[c];console.log("vj: v",{v:r,vId:c,status:e[c],response:e}),r&&"REJECTED"===e[c]?r.fbStatus="REJECTED":r&&"APPROVED"===e[c]&&(r.fbStatus="APPROVED");const l=null===(s=null==i?void 0:i[o])||void 0===s?void 0:s.variants;l&&l[c]&&(l[c]=r)}))})),o){const e=Object.assign({},G);e.products=i,Q(e)}else p({type:"productsPaged",data:{collectionId:U,products:i}})})).catch((e=>{o?y.markVariantsAsApprovedProductsLevel(t,p,U,G,Q):y.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=y.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=y.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=y.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(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(x.ProductScreenCollectionCardStyle,{children:[e.jsx(l.CheckBox,{isChecked:!!(null==b?void 0:b[U]),isPartiallyChecked:(e=>{var t;let o=0,i=0;if(b[e]){const c=null==h?void 0:h.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=>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((()=>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: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,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { SelectedItems } from '.';
|
|
2
|
+
import { FbStatusFetcherReturn, SelectedItems } from '.';
|
|
3
3
|
import { SelectedCollectionsActions } from './reducers';
|
|
4
4
|
import { OUT_OF_STOCK_ACTION } from './type';
|
|
5
5
|
interface RearrangeScreenInterface {
|
|
@@ -9,6 +9,8 @@ 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;
|
|
12
14
|
}
|
|
13
15
|
/**
|
|
14
16
|
* 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"),c=require("../../constants/Theme.js"),o=require("../icon-button/IconButton.js"),i=require("../TypographyStyle.js"),n=require("./emptyState.js"),a=require("./helpers/ProductHelper.js"),l=require("./style.js"),d=require("./utility.js"),u=require("./variantComponents.js");exports.RearrangeScreen=p=>{const{selectedCollections:j,selectedCollectionsDispatch:S,setScreen:h,rearrangeViewType:y,outOfStockAction:f,scrollContainerRef:x,storeId:q,fbStatusFetcher:C}=p,[O,g]=r.useState(a.parseSelectedVariantsToArray(j));r.useEffect((()=>{var e;null===(e=null==x?void 0:x.current)||void 0===e||e.scrollTo({top:0}),d.fetchFbStatusCollection(j,q,S,C,"update"),g(a.parseSelectedVariantsToArray(j))}),[j]);return e.jsxs(s.DragDropContext,Object.assign({onDragEnd:e=>{if(!e.destination)return;const t=O,[r]=t.splice(e.source.index,1);t.splice(e.destination.index,0,r),t.forEach(((e,t)=>{e.displayOrder=t})),g(t)}},{children:[e.jsxs(l.SelectedScreenHeader,{children:[e.jsx(o.IconButton,{Icon:t.default,width:16,height:16,color:c.COLORS.content.secondary,onClick:()=>{h("collections")}}),e.jsx(i.BodyCaption,Object.assign({color:c.COLORS.content.secondary},{children:"All Products"}))]}),Object.keys(j).length>0?"list"===y?e.jsx(u.VariantsList,{selectedVariants:O,setSelectedVariants:g,selectedCollectionsDispatch:S,outOfStockAction:f}):e.jsx(u.VariantsGrid,{selectedVariants:O,setSelectedVariants:g,selectedCollectionsDispatch:S}):e.jsx(n.EmptyState,{title:"No Products Selected",subtitle:"Selected products will appear here"})]}))};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { Collection, SelectedItems } from '.';
|
|
2
|
+
import { Collection, SearchedItems, SelectedItems } from '.';
|
|
3
3
|
export interface SelectedCollectionsActions {
|
|
4
4
|
type: string;
|
|
5
5
|
data: {
|
|
@@ -14,4 +14,10 @@ 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
|
+
export interface SearchReducerActions {
|
|
19
|
+
type: string;
|
|
20
|
+
data: SearchedItems;
|
|
21
|
+
}
|
|
22
|
+
export declare function searchReducer(searchedItems: SearchedItems, action: SearchReducerActions): SearchedItems;
|
|
17
23
|
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 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.
|
|
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;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,12 +1,15 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { Collection, SelectedItems } from '.';
|
|
3
|
-
import { SelectedCollectionsActions } from './reducers';
|
|
2
|
+
import { Collection, FbStatusFetcherReturn, SearchedItems, SelectedItems } from '.';
|
|
3
|
+
import { SearchReducerActions, SelectedCollectionsActions } from './reducers';
|
|
4
4
|
interface SearchScreenInterface {
|
|
5
5
|
customCollectionRestriction?: boolean;
|
|
6
6
|
selectedCollections: SelectedItems;
|
|
7
|
-
searchedCollections:
|
|
7
|
+
searchedCollections: SearchedItems;
|
|
8
|
+
searchedCollectionsDispatch: React.Dispatch<SearchReducerActions>;
|
|
8
9
|
selectedCollectionsDispatch: React.Dispatch<SelectedCollectionsActions>;
|
|
9
10
|
setScreen: React.Dispatch<React.SetStateAction<string>>;
|
|
11
|
+
setCollectionId: React.Dispatch<React.SetStateAction<string>>;
|
|
12
|
+
setSelectedCollectionId: React.Dispatch<React.SetStateAction<string>>;
|
|
10
13
|
collections: {
|
|
11
14
|
[key: string]: Collection;
|
|
12
15
|
};
|
|
@@ -15,6 +18,10 @@ interface SearchScreenInterface {
|
|
|
15
18
|
pickerType?: 'COLLECTION' | 'PRODUCT';
|
|
16
19
|
hideProductVariants?: boolean;
|
|
17
20
|
hideProductCheckbox?: boolean;
|
|
21
|
+
storeId: string;
|
|
22
|
+
fbStatusFetcher?: (storeId: string, variantIds: string[]) => FbStatusFetcherReturn;
|
|
23
|
+
hideCollectionCheckbox?: boolean;
|
|
24
|
+
renderWithoutModal?: boolean;
|
|
18
25
|
}
|
|
19
26
|
export declare const SearchScreen: (props: SearchScreenInterface) => import("react/jsx-runtime").JSX.Element;
|
|
20
27
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),o=require("../../assets/icons/arrow_left.svg.js"),t=require("react"),l=require("../icon-button/IconButton.js"),i=require("../TypographyStyle.js"),c=require("./collectionScreen.js"),d=require("./emptyState.js"),r=require("./productScreen.js"),s=require("./style.js"),n=require("./utility.js");exports.SearchScreen=u=>{const{customCollectionRestriction:a,selectedCollections:v,searchedCollections:h,searchedCollectionsDispatch:p,selectedCollectionsDispatch:j,setScreen:C,collections:y,onBackPress:k,hideVariantCheckbox:b,pickerType:x,hideProductVariants:f,hideProductCheckbox:S,storeId:O,fbStatusFetcher:m,setCollectionId:P,setSelectedCollectionId:I,hideCollectionCheckbox:g,renderWithoutModal:q}=u;t.useEffect((()=>{var e;n.fetchFbStatusCollection(null!==(e=h.products)&&void 0!==e?e:{},O,p,m,"setProducts")}),[null==h?void 0:h.products]);const E=!!a&&(null==v?void 0:v.isCustom),D=e=>{var o,t;let l=0,i=0;if(v[e]){const c=null===(o=y[e])||void 0===o?void 0:o.products;c&&Object.keys(c).forEach((e=>{var o;const t=null===(o=c[e])||void 0===o?void 0:o.variants;t&&Object.keys(t).forEach((e=>l+=1))}));const d=null===(t=v[e])||void 0===t?void 0:t.products;return d&&Object.keys(d).forEach((e=>{var o;const t=null===(o=d[e])||void 0===o?void 0:o.variants;t&&Object.keys(t).forEach((e=>i+=1))})),!(l<=0&&i>0)&&(i>0&&l!==i)}return!1},F=(e,o)=>{var t,l,i,c,d,r,s,n,u;let a=0,h=0;return!!((null===(l=null===(t=null==v?void 0:v[e])||void 0===t?void 0:t.products)||void 0===l?void 0:l[o])&&(null===(r=Object.keys((null===(d=null===(c=null===(i=null==y?void 0:y[e])||void 0===i?void 0:i.products)||void 0===c?void 0:c[o])||void 0===d?void 0:d.variants)||[]))||void 0===r||r.forEach((()=>h++)),Object.keys((null===(u=null===(n=null===(s=null==v?void 0:v[e])||void 0===s?void 0:s.products)||void 0===n?void 0:n[o])||void 0===u?void 0:u.variants)||[]).forEach((()=>a++)),a>0&&h!==a))};return e.jsxs("div",{children:[e.jsxs(s.SelectedScreenHeader,{children:[e.jsx(l.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=>{var t;return e.jsx(c.CollectionCard,{customCollectionRestriction:a,data:null===(t=null==h?void 0:h.collections)||void 0===t?void 0:t[o],isDisabled:E&&!(null==v?void 0:v[o]),isChecked:!!(null==v?void 0:v[o]),isPartiallyChecked:D(o),selectedCollectionsDispatch:j,setCollectionId:P,setSelectedCollectionId:I,setScreen:C,id:o,hideCollectionCheckbox:g||"-1"===o,selectedCollections:v,renderWithoutModal:q,pickerType:x,usedInSearch:!0},o)}))}),e.jsx(e.Fragment,{children:Object.keys(null==h?void 0:h.products).map((o=>{var t,l;return Object.keys((null===(l=null===(t=null==h?void 0:h.products)||void 0===t?void 0:t[o])||void 0===l?void 0:l.products)||[]).map((t=>{var l,i;let c=!1;return(null===(l=null==h?void 0:h.products)||void 0===l?void 0:l.isCustom)&&(c=!0),e.jsx(r.ProductGroup,{collectionId:o,upliftAdditions:(e,t)=>((e,o,t)=>{var l;const i=n.liftTheStateUp(t,null===(l=null==h?void 0:h.products)||void 0===l?void 0:l[e]);j({type:o,data:Object.assign(Object.assign({},i),{isRestricted:a})})})(o,e,t),productId:t,data:(null===(i=null==h?void 0:h.products)||void 0===i?void 0:i[o].products)[t],isProductPartiallyChecked:F(o,t),selectedData:v,selectedCollectionsDispatch:j,viewOnly:c,hideProductCheckbox:S,hideVariantCheckbox:b,hideProductVariants:f,pickerType:x},t)}))}))})]}):e.jsx(d.EmptyState,{title:"No search results found",subtitle:"We couldn’t find the product you were looking for."})})]})};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { Collection, SelectedItems } from '.';
|
|
2
|
+
import { Collection, FbStatusFetcherReturn, SelectedItems } from '.';
|
|
3
3
|
import { SelectedCollectionsActions } from './reducers';
|
|
4
|
+
import { OUT_OF_STOCK_ACTION } from './type';
|
|
4
5
|
interface SelectedScreenInterface {
|
|
5
6
|
selectedCollections: SelectedItems;
|
|
6
7
|
selectedCollectionsDispatch: React.Dispatch<SelectedCollectionsActions>;
|
|
@@ -8,6 +9,9 @@ interface SelectedScreenInterface {
|
|
|
8
9
|
collections: {
|
|
9
10
|
[key: string]: Collection;
|
|
10
11
|
};
|
|
12
|
+
outOfStockAction?: OUT_OF_STOCK_ACTION;
|
|
13
|
+
storeId: string;
|
|
14
|
+
fbStatusFetcher?: (storeId: string, variantIds: string[]) => FbStatusFetcherReturn;
|
|
11
15
|
}
|
|
12
16
|
export declare const SelectedScreen: (props: SelectedScreenInterface) => import("react/jsx-runtime").JSX.Element;
|
|
13
17
|
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"),r=require("react"),o=require("../icon-button/IconButton.js"),c=require("../TypographyStyle.js"),s=require("./emptyState.js"),l=require("./productScreen.js"),n=require("./reducers.js"),i=require("./style.js"),u=require("./utility.js");exports.SelectedScreen=d=>{const{selectedCollections:a,selectedCollectionsDispatch:v,setScreen:p,collections:j,outOfStockAction:f,storeId:g,fbStatusFetcher:S}=d,y=r.useRef(0),h=r.useRef(null),[b,x]=r.useReducer(n.paginationReducer,{});r.useEffect((()=>{y.current=0;const e=u.paginateSelectedItems(a,10,0);x({type:"paginate",data:e}),u.fetchFbStatusCollection(e,g,x,S,"set"),y.current+=1}),[]),r.useEffect((()=>{x({type:"filter",data:a})}),[a]),r.useEffect((()=>{console.log("vj: observertarget",h.current);const e=new IntersectionObserver((e=>{if(console.log("vj: observertargetinside",e),e[0].isIntersecting&&(console.log("vj: nextPageRef",y.current),y.current>0)){const e=u.paginateSelectedItems(a,10,y.current);console.log("paginated inside observer target",{paginatedProducts:e,selectedCollections:a,curScreenData:b}),x({type:"paginate",data:e}),u.fetchFbStatusCollection(e,g,x,S,"update"),y.current+=1}}),{threshold:1});return h.current&&e.observe(h.current),()=>{h.current&&e.unobserve(h.current)}}),[h,a]);const q=(e,t)=>{var r,o,c,s,l,n,i,u,d;let v=0,p=0;return!!((null===(o=null===(r=null==a?void 0:a[e])||void 0===r?void 0:r.products)||void 0===o?void 0:o[t])&&(null===(n=Object.keys((null===(l=null===(s=null===(c=null==j?void 0:j[e])||void 0===c?void 0:c.products)||void 0===s?void 0:s[t])||void 0===l?void 0:l.variants)||[]))||void 0===n||n.forEach((()=>p++)),Object.keys((null===(d=null===(u=null===(i=null==a?void 0:a[e])||void 0===i?void 0:i.products)||void 0===u?void 0:u[t])||void 0===d?void 0:d.variants)||[]).forEach((()=>v++)),v>0&&p!==v))};return e.jsxs("div",{children:[e.jsxs(i.SelectedScreenHeader,{children:[e.jsx(o.IconButton,{Icon:t.default,onClick:()=>{p("collections")}}),e.jsx(c.BodyCaption,{children:"Selected Products"})]}),e.jsxs("div",{children:[Object.keys(b).length>0?e.jsx(e.Fragment,{children:Object.keys(b).map((t=>{var r;return Object.keys((null===(r=null==b?void 0:b[t])||void 0===r?void 0:r.products)||[]).map((r=>{let o=!1;return(null==b?void 0:b.isCustom)&&(o=!0),e.jsx(l.ProductGroup,{upliftAdditions:null,collectionId:t,productId:r,data:b[t].products[r],isProductPartiallyChecked:q(t,r),selectedData:a,selectedCollectionsDispatch:v,viewOnly:o,outOfStockAction:f},r)}))}))}):e.jsx(s.EmptyState,{title:"No Products Selected",subtitle:"Select products will appear here"}),e.jsx("div",{ref:h})]})]})};
|
|
@@ -3,6 +3,7 @@ export declare const ScrollContainerStyle: import("styled-components").StyledCom
|
|
|
3
3
|
export declare const CollectionCardStyle: import("styled-components").StyledComponent<"div", any, {
|
|
4
4
|
isDisabled: boolean;
|
|
5
5
|
isActive: boolean;
|
|
6
|
+
usedInSearch: boolean;
|
|
6
7
|
}, never>;
|
|
7
8
|
export declare const CollectionCardInfoStyle: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
8
9
|
export declare const CollectionCardDetailStyle: import("styled-components").StyledComponent<"div", any, {}, never>;
|