@bikdotai/bik-component-library 0.0.456-0 → 0.0.456-beta.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/product-picker-v2/ProductPickerShimmer.d.ts +3 -0
- package/dist/cjs/components/product-picker-v2/ProductPickerShimmer.js +1 -0
- package/dist/cjs/components/product-picker-v2/ProductPickerTag.d.ts +19 -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 +5 -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/product.d.ts +43 -0
- package/dist/cjs/components/product-picker-v2/product.js +1 -0
- package/dist/cjs/components/product-picker-v2/productInfoOverlay.d.ts +17 -0
- package/dist/cjs/components/product-picker-v2/productInfoOverlay.js +39 -0
- package/dist/cjs/components/product-picker-v2/productScreen.d.ts +6 -37
- 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 +25 -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 -2
- 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 +32 -12
- package/dist/cjs/components/product-picker-v2/utility.d.ts +37 -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/modalElements/EditWhatsAppCarouselTemplateV2.js +1 -1
- package/dist/cjs/components/template-context-mapper/modalElements/ProductBox.d.ts +1 -0
- package/dist/cjs/components/template-context-mapper/modalElements/ProductBox.js +2 -2
- package/dist/esm/components/product-picker-v2/ProductPickerShimmer.d.ts +3 -0
- package/dist/esm/components/product-picker-v2/ProductPickerShimmer.js +1 -0
- package/dist/esm/components/product-picker-v2/ProductPickerTag.d.ts +19 -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 +5 -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/product.d.ts +43 -0
- package/dist/esm/components/product-picker-v2/product.js +1 -0
- package/dist/esm/components/product-picker-v2/productInfoOverlay.d.ts +17 -0
- package/dist/esm/components/product-picker-v2/productInfoOverlay.js +39 -0
- package/dist/esm/components/product-picker-v2/productScreen.d.ts +6 -37
- 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 +25 -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 -2
- 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 +32 -12
- package/dist/esm/components/product-picker-v2/utility.d.ts +37 -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/modalElements/EditWhatsAppCarouselTemplateV2.js +1 -1
- package/dist/esm/components/template-context-mapper/modalElements/ProductBox.d.ts +1 -0
- package/dist/esm/components/template-context-mapper/modalElements/ProductBox.js +2 -2
- package/package.json +1 -1
- package/dist/cjs/components/product-picker-v2/helpers/AllProductHelper.d.ts +0 -4
- package/dist/cjs/components/product-picker-v2/helpers/AllProductHelper.js +0 -1
- package/dist/esm/components/product-picker-v2/helpers/AllProductHelper.d.ts +0 -4
- package/dist/esm/components/product-picker-v2/helpers/AllProductHelper.js +0 -1
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Product, ProductVariant } from './modal';
|
|
2
|
+
import { OUT_OF_STOCK_ACTION } from './type';
|
|
3
|
+
/**
|
|
4
|
+
* When user presses i icon on a product, we show the overlay.
|
|
5
|
+
* In case of a product, contains products image, product name & description
|
|
6
|
+
* In case of a variant, contains variant image, variant name,
|
|
7
|
+
* description as product name, variant tag
|
|
8
|
+
*/
|
|
9
|
+
export declare const ProductInfoOverlay: (props: {
|
|
10
|
+
productData: Product | ProductVariant;
|
|
11
|
+
onClose: () => void;
|
|
12
|
+
outOfStockAction?: OUT_OF_STOCK_ACTION;
|
|
13
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export declare const ProductInfoCard: (props: {
|
|
15
|
+
productData: Product | ProductVariant;
|
|
16
|
+
outOfStockAction?: OUT_OF_STOCK_ACTION;
|
|
17
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import{jsxs as o,jsx as t}from"react/jsx-runtime";import i from"styled-components";import{COLORS as r}from"../../constants/Theme.js";import e from"../../assets/icons/cross.svg.js";import{IconButton as a}from"../icon-button/IconButton.js";import{ShimmerImage as n}from"../shimmer-image/ShimmerImage.js";import{TitleSmall as d,BodyCaption as s}from"../TypographyStyle.js";import{ProductPickerTag as c}from"./ProductPickerTag.js";const l=i=>o(m,{children:[t(u,{}),t(x,{children:t(a,{className:"close-button",onClick:i.onClose,Icon:e,width:20,height:20})}),t(p,{productData:i.productData,outOfStockAction:i.outOfStockAction})]}),p=i=>{var r;const e=void 0===i.productData.variants;return o(f,{children:[t(g,{children:t(n,{imageUrl:i.productData.image,width:"200px",height:200,borderRadius:4})}),o(h,{children:[t(d,Object.assign({style:{display:"flex"}},{children:i.productData.name})),t(s,{style:{display:"flex",flexDirection:"column"},dangerouslySetInnerHTML:{__html:null!==(r=i.productData.description)&&void 0!==r?r:""}}),t(c,{isVariant:e,data:i.productData,outOfStockAction:i.outOfStockAction})]})]})},m=i.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
|
+
`,u=i.div`
|
|
12
|
+
display: flex;
|
|
13
|
+
flex: 1;
|
|
14
|
+
background: rgba(0, 0, 0, 0.5);
|
|
15
|
+
`,x=i.div`
|
|
16
|
+
position: relative;
|
|
17
|
+
|
|
18
|
+
.close-button {
|
|
19
|
+
position: absolute;
|
|
20
|
+
top: -50px;
|
|
21
|
+
right: 0px;
|
|
22
|
+
margin: 10px;
|
|
23
|
+
background: ${r.surface.standard};
|
|
24
|
+
border-radius: 50%;
|
|
25
|
+
}
|
|
26
|
+
`,f=i.div`
|
|
27
|
+
display: flex;
|
|
28
|
+
background: white;
|
|
29
|
+
padding: 24px;
|
|
30
|
+
gap: 24px;
|
|
31
|
+
border-radius: 8px 8px 0px 0px;
|
|
32
|
+
`,g=i.div`
|
|
33
|
+
display: flex;
|
|
34
|
+
`,h=i.div`
|
|
35
|
+
display: flex;
|
|
36
|
+
flex: 1;
|
|
37
|
+
flex-direction: column;
|
|
38
|
+
gap: 10px;
|
|
39
|
+
`;export{p as ProductInfoCard,l as ProductInfoOverlay};
|
|
@@ -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,40 +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
|
+
onProductDetailClick: (productData: Product | ProductVariant) => void;
|
|
24
27
|
}
|
|
25
28
|
export declare const ProductsScreen: (props: ProductsScreenInterface) => import("react/jsx-runtime").JSX.Element;
|
|
26
|
-
interface ProductGroupInterface {
|
|
27
|
-
collectionId: string;
|
|
28
|
-
productId: string;
|
|
29
|
-
data: Product;
|
|
30
|
-
selectedData: SelectedItems;
|
|
31
|
-
selectedCollectionsDispatch: React.Dispatch<SelectedCollectionsActions>;
|
|
32
|
-
viewOnly: boolean;
|
|
33
|
-
isProductPartiallyChecked?: boolean;
|
|
34
|
-
upliftAdditions: any;
|
|
35
|
-
hideProductCheckbox?: boolean;
|
|
36
|
-
outOfStockAction?: OUT_OF_STOCK_ACTION;
|
|
37
|
-
hideVariantCheckbox?: boolean;
|
|
38
|
-
hideProductVariants?: boolean;
|
|
39
|
-
pickerType?: 'COLLECTION' | 'PRODUCT';
|
|
40
|
-
}
|
|
41
|
-
export declare const ProductGroup: (props: ProductGroupInterface) => import("react/jsx-runtime").JSX.Element;
|
|
42
|
-
interface ProductCardInterface {
|
|
43
|
-
isVariant: boolean;
|
|
44
|
-
data: Product | ProductVariant;
|
|
45
|
-
productId: string;
|
|
46
|
-
collectionId: string;
|
|
47
|
-
variantId?: string;
|
|
48
|
-
isSelected: boolean;
|
|
49
|
-
selectedCollectionsDispatch: React.Dispatch<SelectedCollectionsActions>;
|
|
50
|
-
viewOnly: boolean;
|
|
51
|
-
isPartiallyChecked?: boolean;
|
|
52
|
-
upliftAdditions: any;
|
|
53
|
-
hideProductCheckbox?: boolean;
|
|
54
|
-
outOfStockAction?: OUT_OF_STOCK_ACTION;
|
|
55
|
-
hideVariantCheckbox?: boolean;
|
|
56
|
-
hideProductVariants?: boolean;
|
|
57
|
-
pickerType?: 'COLLECTION' | 'PRODUCT';
|
|
58
|
-
}
|
|
59
|
-
export declare const ProductCard: (props: ProductCardInterface) => import("react/jsx-runtime").JSX.Element;
|
|
60
29
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as t,jsx as e
|
|
1
|
+
import{jsxs as t,jsx as e}from"react/jsx-runtime";import o from"../../assets/icons/arrow_left.svg.js";import c from"../../assets/icons/box.svg.js";import r from"../../assets/icons/search.svg.js";import{cloneDeep as n}from"lodash";import{useContext as s,useRef as i,useState as l,useEffect as d}from"react";import{COLORS as a}from"../../constants/Theme.js";import{CheckBox as u}from"../checkBox/CheckBox.js";import{IconButton as h}from"../icon-button/IconButton.js";import{Input as p}from"../input/Input.js";import{Spinner as m}from"../spinner/Spinner.js";import{BodyCaption as g,TitleRegular as j}from"../TypographyStyle.js";import{EmptyState as v}from"./emptyState.js";import{ProductGroup as b}from"./product.js";import{ProductPickerShimmer as f}from"./ProductPickerShimmer.js";import{CollectionIdContext as y}from"./reducers.js";import{ProductScreenHeader as O,ProductScreenCollectionCardStyle as k}from"./style.js";import{OUT_OF_STOCK_ACTION as C}from"./type.js";import{getVariantIdsToFetchAtProductLevel as P,markVariantsAsApprovedProductsLevel as I,isCollectionPartiallyChecked as D,isProductPartiallyChecked as x,liftTheStateUp as E}from"./utility.js";const S=S=>{const{data:w,collectionsDispatch:T,selectedData:R,selectedCollectionsDispatch:V,productFetcher:A,storeId:B,setScreen:F,setSaveDisabled:J,hideInCollectionSearch:W,customCollectionRestriction:z,hideProductCheckbox:H,outOfStockAction:K=C.BLUR,hideVariantCheckbox:L=!1,selectProductsFromCustomCollection:M=!1,pickerType:N,hideProductVariants:U,fbStatusFetcher:_,onProductDetailClick:q,showProductDetailInfoIcon:G}=S,Q=s(y),X=i(null),Y=i(0),[Z,$]=l(!1),[tt,et]=l(""),[ot,ct]=l(!1),[rt,nt]=l(w),st=i(!1);d((()=>{const t=setTimeout((()=>{tt.length?(ct(!0),S.searchInCollectionFetcher(B,Q,tt).then((t=>{const e=n(w);e.products=t,nt(e);const o=P(null!=t?t:{});lt(o,null!=t?t:{},!0),J(!1),ct(!1)}))):nt(w)}),800);return()=>clearTimeout(t)}),[tt]),d((()=>{var t,e,o,c;st.current=!1,Y.current=Math.floor((null===(e=Object.keys(null!==(t=w.products)&&void 0!==t?t:{}))||void 0===e?void 0:e.length)/10);const r=P(null!==(o=w.products)&&void 0!==o?o:{});lt(r,null!==(c=w.products)&&void 0!==c?c:{})}),[Q]);const it=!!z&&w.isSmartCollection;d((()=>{(null==w?void 0:w.products)||dt(10)}),[]);const lt=(t,e,o)=>{_||(o?I(e,T,Q,rt,nt):I(e,T,Q)),t.length>0&&_&&_(B,t).then((t=>{const c=Object.assign({},e);Object.keys(e).forEach((o=>{var r,n;Object.keys(null!==(n=null===(r=null==e?void 0:e[o])||void 0===r?void 0:r.variants)&&void 0!==n?n:{}).forEach((r=>{var n,s;const i=null===(n=null==e?void 0:e[o].variants)||void 0===n?void 0:n[r];i&&"REJECTED"===t[r]?i.fbStatus="REJECTED":i&&"APPROVED"===t[r]&&(i.fbStatus="APPROVED");const l=null===(s=null==c?void 0:c[o])||void 0===s?void 0:s.variants;l&&l[r]&&(l[r]=i)}))})),o?(nt((t=>{const e=Object.assign({},t);return e.products=c,e})),T({type:"productsPaged",data:{collectionId:Q,products:c}})):T({type:"productsPaged",data:{collectionId:Q,products:c}})})).catch((t=>{o?I(e,T,Q,rt,nt):I(e,T,Q)}))};d((()=>{const t=new IntersectionObserver((t=>{t[0].isIntersecting&&Y.current>=0&&!st.current&&!tt&&(J(!0),$(!0),A(Q,B,10,Y.current).then((t=>{if(Object.keys(t).length||(st.current=!0),Object.keys(t).length){const e=rt;e.products=Object.assign(Object.assign({},rt.products),t),nt(e);const o=P(t);lt(o,t),Y.current+=1}$(!1),J(!1)})).catch())}),{threshold:1});return X.current&&t.observe(X.current),()=>{X.current&&t.unobserve(X.current)}}),[X,tt]);const dt=t=>{J(!0),ct(!0),A(Q,B,t,0).then((e=>{if(Object.keys(e).length||(st.current=!0),Object.keys(e).length){nt(Object.assign(Object.assign({},rt),{products:e}));const t=P(e);lt(t,e),Y.current=1}t||V({type:"selected",data:{id:Q,val:Object.assign(Object.assign({},w),{products:e})}}),J(!1),ct(!1)})).catch()},at=(t,e)=>{const o=E(e,w);V({type:t,data:Object.assign(Object.assign({},o),{isRestricted:z})})};return t("div",{children:[t(O,{children:[e(h,{Icon:o,height:16,onClick:()=>{F("collections")}}),e(g,Object.assign({style:{color:a.content.secondary}},{children:w.name}))]}),!W&&e("div",Object.assign({style:{padding:16,height:"76px",borderBottom:"1px solid #E0E0E0"}},{children:e(p,{noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>ot&&tt.length?e(m,{size:"small",color:a.content.primary}):e(r,{})},id:"listInput",height:"24px",type:"text",value:tt,onChangeText:t=>{t.length&&t.trim().length?et(t):et("")},placeholder:"Search products in this collection..."})})),t("div",{children:[Object.keys((null==rt?void 0:rt.products)||[]).length>0&&!it&&!tt.length&&!H&&"-1"!==Q&&t(k,{children:[e(u,{isChecked:!!(null==R?void 0:R[Q]),isPartiallyChecked:D(Q,w,R),onValueChange:function(t){t?dt():V({type:"unselected",data:{id:Q}})}}),e("div",Object.assign({style:{width:40,height:40}},{children:e(c,{})})),e(j,{children:"All Products"})]}),Object.keys((null==rt?void 0:rt.products)||[]).length?Object.keys(rt.products||[]).map((t=>e(b,{outOfStockAction:K,collectionId:Q,isProductPartiallyChecked:x(Q,t,R,rt),productId:t,data:rt.products[t],selectedData:R,selectedCollectionsDispatch:V,viewOnly:!M&&!!it,upliftAdditions:at,hideProductCheckbox:H,hideVariantCheckbox:L,hideProductVariants:U,pickerType:N,onProductDetailClick:q,showProductDetailInfoIcon:G},t))):ot?e(f,{limit:10}):e(v,{title:"No products to show",subtitle:tt.length?"We couldn't find the product you were looking for":"We couldn’t find any product in this collection."}),e("div",{ref:X})]}),Z&&e(f,{})]})};export{S as ProductsScreen};
|
|
@@ -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
|
-
import{jsxs as
|
|
1
|
+
import{jsxs as t,jsx as e}from"react/jsx-runtime";import o from"../../assets/icons/arrow_left.svg.js";import{useState as r,useEffect as s}from"react";import{DragDropContext as c}from"react-beautiful-dnd";import{COLORS as i}from"../../constants/Theme.js";import{IconButton as n}from"../icon-button/IconButton.js";import{BodyCaption as l}from"../TypographyStyle.js";import{EmptyState as a}from"./emptyState.js";import{parseSelectedVariantsToArray as d}from"./helpers/ProductHelper.js";import{SelectedScreenHeader as p}from"./style.js";import{fetchFbStatusCollection as m}from"./utility.js";import{VariantsList as u,VariantsGrid as f}from"./variantComponents.js";const h=h=>{const{selectedCollections:j,selectedCollectionsDispatch:y,setScreen:S,rearrangeViewType:g,outOfStockAction:b,scrollContainerRef:C,storeId:O,fbStatusFetcher:v}=h,[V,k]=r(d(j));s((()=>{k(d(j))}),[j]),s((()=>{var t;null===(t=null==C?void 0:C.current)||void 0===t||t.scrollTo({top:0}),m(j,O,y,v,"update")}),[]);return t(c,Object.assign({onDragEnd:t=>{if(!t.destination)return;const e=V,[o]=e.splice(t.source.index,1);e.splice(t.destination.index,0,o),e.forEach(((t,e)=>{t.displayOrder=e})),k(e)}},{children:[t(p,{children:[e(n,{Icon:o,width:16,height:16,color:i.content.secondary,onClick:()=>{S("collections")}}),e(l,Object.assign({color:i.content.secondary},{children:"All Products"}))]}),Object.keys(j).length>0?"list"===g?e(u,{selectedVariants:V,setSelectedVariants:k,selectedCollectionsDispatch:y,outOfStockAction:b}):e(f,{selectedVariants:V,setSelectedVariants:k,selectedCollectionsDispatch:y}):e(a,{title:"No Products Selected",subtitle:"Selected products will appear here"})]}))};export{h as RearrangeScreen};
|
|
@@ -1,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,28 @@ export interface CollectionsActions {
|
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
16
|
export declare function collectionsReducer(collections: Collection, action: CollectionsActions): any;
|
|
17
|
+
/**
|
|
18
|
+
* Pagination reducer used in selected screen.
|
|
19
|
+
* Used for local pagination.
|
|
20
|
+
*
|
|
21
|
+
* Actions used:
|
|
22
|
+
* paginate -> Checks if the products of the collection is already displayed, if yes addes the products, if no adds the entire collection
|
|
23
|
+
* update -> triggers a re-render.
|
|
24
|
+
* set -> adds the data to existing collections.
|
|
25
|
+
* filter -> When user unselects a product in selected screen, we filter out the selected data and show only unselected data.
|
|
26
|
+
*/
|
|
27
|
+
export declare function paginationReducer(collections: SelectedItems, action: SelectedCollectionsActions): SelectedItems;
|
|
28
|
+
export interface SearchReducerActions {
|
|
29
|
+
type: string;
|
|
30
|
+
data: SearchedItems;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Data used in search screen.
|
|
34
|
+
* To display both collections and products.
|
|
35
|
+
*
|
|
36
|
+
* Actions:
|
|
37
|
+
* set -> no change and sets the data.
|
|
38
|
+
* setProducts -> keeps the collection from search as-is and sets only products
|
|
39
|
+
*/
|
|
40
|
+
export declare function searchReducer(searchedItems: SearchedItems, action: SearchReducerActions): SearchedItems;
|
|
17
41
|
export declare const CollectionIdContext: import("react").Context<string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{cloneDeep as t}from"lodash";import{createContext as a}from"react";function
|
|
1
|
+
import{cloneDeep as t}from"lodash";import{createContext as a}from"react";function e(a,e){var s,c,d,r,o,n;let i={},u="",l="",p="";switch(e.type){case"selected":return i=t(a),e.data.val.isSmartCollection&&(e.data.isRestricted&&(i={}),i.isCustom=!0),i[e.data.id]=e.data.val,i;case"unselected":return i=t(a),(null==i?void 0:i.isCustom)&&(i.isCustom=!1),delete i[e.data.id],i;case"productUnselected":return i=t(a),u=e.data.productId,l=e.data.collectionId,delete i[l].products[u],Object.keys(i[l].products).length||((null==i?void 0:i.isCustom)&&(i.isCustom=!1),delete i[l]),i;case"productSelected":return i=t(a),u=e.data.productId,l=e.data.collectionId,(null===(s=e.data.catalogOnlyData)||void 0===s?void 0:s.isSmartCollection)&&(e.data.isRestricted&&(i={}),i.isCustom=!0),(null==i?void 0:i[l])||(i[l]=e.data.catalogOnlyData,i[l].products={}),i[l].products[u]=e.data.product,i;case"variantSelected":return i=t(a),u=e.data.productId,l=e.data.collectionId,p=e.data.variantId,(null===(c=e.data.catalogOnlyData)||void 0===c?void 0:c.isSmartCollection)&&(e.data.isRestricted&&(i={}),i.isCustom=!0),(null==i?void 0:i[l])||(i[l]=e.data.catalogOnlyData,i[l].products={},i[l].products[u]=e.data.productOnlyData,i[l].products[u].variants={}),(null===(r=null===(d=null==i?void 0:i[l])||void 0===d?void 0:d.products)||void 0===r?void 0:r[u])||((null===(o=null==i?void 0:i[l])||void 0===o?void 0:o.products)||(i[l].products={}),i[l].products[u]=e.data.productOnlyData,i[l].products[u].variants={}),i[l].products[u].variants[p]=e.data.variant,i;case"variantUnselected":return i=t(a),u=e.data.productId,l=e.data.collectionId,p=e.data.variantId,delete i[l].products[u].variants[p],Object.keys(i[l].products[u].variants).length||(delete i[l].products[u],Object.keys(i[l].products).length||((null===(n=i[l])||void 0===n?void 0:n.isSmartCollection)&&(i.isCustom=!1),delete i[l])),i;case"update":return i=Object.assign({},a),i;case"reset":return{};default:return a}}function s(t,a){let e={};switch(a.type){case"fetched":return e=Object.assign({},a.data),e;case"productsFetched":return e=Object.assign({},t),e[a.data.collectionId].products=a.data.products,e;case"paged":return e=Object.assign(Object.assign({},t),a.data),e;case"productsPaged":return e=Object.assign({},t),e[a.data.collectionId].products=Object.assign(Object.assign({},e[a.data.collectionId].products),a.data.products),e;case"searched":e=Object.assign({},t);for(const t in a.data)t in e||(e[t]=a.data[t]);return e;default:return{}}}function c(t,a){let e={};switch(a.type){case"paginate":e=Object.assign({},t);for(const t in a.data)if(Object.prototype.hasOwnProperty.call(a.data,t)){const s=a.data[t];if(Object.prototype.hasOwnProperty.call(e,t)){const a=e[t];e[t]=Object.assign(Object.assign({},a),{products:Object.assign(Object.assign({},a.products),s.products)})}else e[t]=s}return e;case"update":return e=Object.assign({},t),e;case"set":return e=Object.assign(Object.assign({},t),a.data),e;case"filter":e={};for(const s in t)if(s in a.data){const c=Object.assign({},t[s]),d=a.data[s],r={};for(const t in c.products)if(t in d.products){const a=Object.assign({},c.products[t]),e=d.products[t],s={};for(const t in a.variants)t in e.variants&&(s[t]=Object.assign({},a.variants[t]));Object.keys(s).length>0&&(a.variants=s,r[t]=a)}Object.keys(r).length>0&&(c.products=r,e[s]=c)}return e;default:return t}}function d(t,a){let e={collections:{},products:{}};switch(a.type){case"set":return a.data;case"setProducts":return e=Object.assign({},t),e.products=a.data,e;default:return t}}const r=a("");export{r as CollectionIdContext,s as collectionsReducer,c as paginationReducer,d as searchReducer,e as selectedColectionsReducer};
|
|
@@ -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
|
-
import{jsxs as
|
|
1
|
+
import{jsxs as e,jsx as o,Fragment as t}from"react/jsx-runtime";import l from"../../assets/icons/arrow_left.svg.js";import{useEffect as i}from"react";import{IconButton as c}from"../icon-button/IconButton.js";import{BodyCaption as d}from"../TypographyStyle.js";import{CollectionCard as s}from"./collectionScreen.js";import{EmptyState as r}from"./emptyState.js";import{ProductGroup as n}from"./product.js";import{SelectedScreenHeader as u}from"./style.js";import{fetchFbStatusCollection as a,isCollectionPartiallyChecked as p,isProductPartiallyChecked as h,liftTheStateUp as v}from"./utility.js";const m=m=>{const{customCollectionRestriction:C,selectedCollections:k,searchedCollections:y,searchedCollectionsDispatch:b,selectedCollectionsDispatch:f,setScreen:j,collections:I,onBackPress:P,hideVariantCheckbox:S,pickerType:x,hideProductVariants:O,hideProductCheckbox:g,storeId:D,fbStatusFetcher:T,setCollectionId:V,setSelectedCollectionId:w,hideCollectionCheckbox:R,renderWithoutModal:W}=m;i((()=>{var e;a(null!==(e=y.products)&&void 0!==e?e:{},D,b,T,"setProducts")}),[null==y?void 0:y.products]);const B=!!C&&(null==k?void 0:k.isCustom);return e("div",{children:[e(u,{children:[o(c,{Icon:l,onClick:()=>{j("collections"),P()}}),o(d,{children:"Searched Products"})]}),o("div",{children:Object.keys(null==y?void 0:y.products).length||Object.keys(null==y?void 0:y.collections).length?e(t,{children:[o(t,{children:Object.keys(null==y?void 0:y.collections).map((e=>o(s,{customCollectionRestriction:C,data:null==I?void 0:I[e],isDisabled:B&&!(null==k?void 0:k[e]),isChecked:!!(null==k?void 0:k[e]),isPartiallyChecked:p(e,null==I?void 0:I[e],k),selectedCollectionsDispatch:f,setCollectionId:V,setSelectedCollectionId:w,setScreen:j,id:e,hideCollectionCheckbox:R||"-1"===e,selectedCollections:k,renderWithoutModal:W,pickerType:x,usedInSearch:!0},e)))}),o(t,{children:Object.keys(null==y?void 0:y.products).map((e=>{var t,l;return Object.keys((null===(l=null===(t=null==y?void 0:y.products)||void 0===t?void 0:t[e])||void 0===l?void 0:l.products)||[]).map((t=>{var l,i,c;let d=!1;return(null===(l=null==y?void 0:y.products)||void 0===l?void 0:l.isCustom)&&(d=!0),o(n,{collectionId:e,upliftAdditions:(o,t)=>((e,o,t)=>{var l;const i=v(t,null===(l=null==y?void 0:y.products)||void 0===l?void 0:l[e]);f({type:o,data:Object.assign(Object.assign({},i),{isRestricted:C})})})(e,o,t),productId:t,data:(null===(i=null==y?void 0:y.products)||void 0===i?void 0:i[e].products)[t],isProductPartiallyChecked:h(e,t,k,null===(c=y.products)||void 0===c?void 0:c[e]),selectedData:k,selectedCollectionsDispatch:f,viewOnly:d,hideProductCheckbox:g,hideVariantCheckbox:S,hideProductVariants:O,pickerType:x},t)}))}))})]}):o(r,{title:"No search results found",subtitle:"We couldn’t find the product you were looking for."})})]})};export{m as SearchScreen};
|
|
@@ -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,7 +9,9 @@ interface SelectedScreenInterface {
|
|
|
8
9
|
collections: {
|
|
9
10
|
[key: string]: Collection;
|
|
10
11
|
};
|
|
11
|
-
|
|
12
|
+
outOfStockAction?: OUT_OF_STOCK_ACTION;
|
|
13
|
+
storeId: string;
|
|
14
|
+
fbStatusFetcher?: (storeId: string, variantIds: string[]) => FbStatusFetcherReturn;
|
|
12
15
|
}
|
|
13
16
|
export declare const SelectedScreen: (props: SelectedScreenInterface) => import("react/jsx-runtime").JSX.Element;
|
|
14
17
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as
|
|
1
|
+
import{jsxs as t,jsx as e,Fragment as r}from"react/jsx-runtime";import o from"../../assets/icons/arrow_left.svg.js";import{useRef as c,useReducer as n,useEffect as i}from"react";import{IconButton as s}from"../icon-button/IconButton.js";import{BodyCaption as l}from"../TypographyStyle.js";import{EmptyState as d}from"./emptyState.js";import{ProductGroup as u}from"./product.js";import{paginationReducer as p}from"./reducers.js";import{SelectedScreenHeader as a}from"./style.js";import{paginateSelectedItems as m,fetchFbStatusCollection as f,isProductPartiallyChecked as h}from"./utility.js";const v=v=>{const{selectedCollections:y,selectedCollectionsDispatch:j,setScreen:b,collections:S,outOfStockAction:k,storeId:I,fbStatusFetcher:O}=v,g=c(0),C=c(null),[w,P]=n(p,{});return i((()=>{g.current=0;const t=m(y,10,0);P({type:"paginate",data:t}),f(t,I,P,O,"set"),g.current+=1}),[]),i((()=>{P({type:"filter",data:y})}),[y]),i((()=>{const t=new IntersectionObserver((t=>{if(t[0].isIntersecting&&g.current>0){const t=m(y,10,g.current);P({type:"paginate",data:t}),f(t,I,P,O,"update"),g.current+=1}}),{threshold:1});return C.current&&t.observe(C.current),()=>{C.current&&t.unobserve(C.current)}}),[C,y]),t("div",{children:[t(a,{children:[e(s,{Icon:o,onClick:()=>{b("collections")}}),e(l,{children:"Selected Products"})]}),t("div",{children:[Object.keys(w).length>0?e(r,{children:Object.keys(w).map((t=>{var r;return Object.keys((null===(r=null==w?void 0:w[t])||void 0===r?void 0:r.products)||[]).map((r=>{let o=!1;return(null==y?void 0:y.isCustom)&&(o=!0),e(u,{upliftAdditions:null,collectionId:t,productId:r,data:w[t].products[r],isProductPartiallyChecked:h(t,r,y,null==S?void 0:S[t]),selectedData:y,selectedCollectionsDispatch:j,viewOnly:o,outOfStockAction:k},r)}))}))}):e(d,{title:"No Products Selected",subtitle:"Select products will appear here"}),e("div",{ref:C})]})]})};export{v as SelectedScreen};
|
|
@@ -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>;
|
|
@@ -1,17 +1,26 @@
|
|
|
1
1
|
import e from"styled-components";import{COLORS as i}from"../../constants/Theme.js";const t=e.div`
|
|
2
2
|
display: flex;
|
|
3
3
|
background-color: white;
|
|
4
|
-
|
|
5
|
-
min-height: 600px;
|
|
4
|
+
height: 600px;
|
|
6
5
|
flex-direction: column;
|
|
7
6
|
`,o=e.div`
|
|
8
7
|
overflow-y: scroll;
|
|
9
8
|
overflow-x: hidden;
|
|
9
|
+
|
|
10
|
+
::-webkit-scrollbar {
|
|
11
|
+
display: block;
|
|
12
|
+
width: 8px;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
::-webkit-scrollbar-thumb {
|
|
16
|
+
background-color: #888;
|
|
17
|
+
border-radius: 8px;
|
|
18
|
+
}
|
|
10
19
|
`,n=e.div`
|
|
11
20
|
height: 64px;
|
|
12
21
|
background-color: ${e=>e.isDisabled?"#F0F0F0":e.isActive?i.background.positive.light:"white"};
|
|
13
22
|
border-bottom: 1px solid #e0e0e0;
|
|
14
|
-
padding: 12px 24px;
|
|
23
|
+
padding: ${e=>e.usedInSearch?"12px 16px":"12px 24px"};
|
|
15
24
|
display: flex;
|
|
16
25
|
flex-direction: row;
|
|
17
26
|
column-gap: 16px;
|
|
@@ -31,7 +40,7 @@ import e from"styled-components";import{COLORS as i}from"../../constants/Theme.j
|
|
|
31
40
|
display: flex;
|
|
32
41
|
flex-direction: column;
|
|
33
42
|
justify-content: center;
|
|
34
|
-
`,
|
|
43
|
+
`,p=e.div`
|
|
35
44
|
display: flex;
|
|
36
45
|
flex-direction: row;
|
|
37
46
|
max-height: 32px;
|
|
@@ -41,15 +50,18 @@ import e from"styled-components";import{COLORS as i}from"../../constants/Theme.j
|
|
|
41
50
|
align-items: center;
|
|
42
51
|
padding: 8px 16px;
|
|
43
52
|
margin-top: 16px;
|
|
44
|
-
|
|
53
|
+
position: sticky;
|
|
54
|
+
top: 0;
|
|
55
|
+
z-index: 10;
|
|
56
|
+
`,l=e.div`
|
|
45
57
|
display: flex;
|
|
46
58
|
flex-direction: row;
|
|
47
59
|
column-gap: 16px;
|
|
48
60
|
padding: 12px 16px;
|
|
49
61
|
border-bottom: 1px solid #e0e0e0;
|
|
50
62
|
align-items: center;
|
|
51
|
-
`,
|
|
52
|
-
height: 64px;
|
|
63
|
+
`,c=e.div`
|
|
64
|
+
min-height: 64px;
|
|
53
65
|
background-color: ${e=>e.isActive?i.background.positive.light:"white"};
|
|
54
66
|
border-bottom: 1px solid #e0e0e0;
|
|
55
67
|
padding: 12px 16px;
|
|
@@ -63,7 +75,7 @@ import e from"styled-components";import{COLORS as i}from"../../constants/Theme.j
|
|
|
63
75
|
cursor: pointer;
|
|
64
76
|
background-color: ${i.surface.hovered};
|
|
65
77
|
}
|
|
66
|
-
`,
|
|
78
|
+
`,x=e.div`
|
|
67
79
|
display: flex;
|
|
68
80
|
flex-direction: row;
|
|
69
81
|
max-height: 32px;
|
|
@@ -72,18 +84,26 @@ import e from"styled-components";import{COLORS as i}from"../../constants/Theme.j
|
|
|
72
84
|
justify-content: flex-start;
|
|
73
85
|
align-items: center;
|
|
74
86
|
padding: 8px 16px;
|
|
87
|
+
position: sticky;
|
|
88
|
+
top: 0;
|
|
89
|
+
z-index: 10;
|
|
75
90
|
`,a=e.div`
|
|
76
91
|
display: flex;
|
|
77
92
|
flex-direction: column;
|
|
78
93
|
`,s=e.div`
|
|
79
|
-
height: 72px;
|
|
94
|
+
min-height: 72px;
|
|
80
95
|
background: white;
|
|
81
96
|
padding: 12px 16px;
|
|
82
97
|
display: flex;
|
|
83
98
|
flex-direction: row;
|
|
84
|
-
gap: 16px;
|
|
85
99
|
align-items: center;
|
|
86
|
-
justify-content:
|
|
100
|
+
justify-content: space-between;
|
|
101
|
+
|
|
102
|
+
.text-container {
|
|
103
|
+
display: flex;
|
|
104
|
+
justify-content: space-between;
|
|
105
|
+
gap: 16px;
|
|
106
|
+
}
|
|
87
107
|
|
|
88
108
|
.tooltip-title-tag {
|
|
89
109
|
display: flex;
|
|
@@ -107,4 +127,4 @@ import e from"styled-components";import{COLORS as i}from"../../constants/Theme.j
|
|
|
107
127
|
align-items: center;
|
|
108
128
|
border: 1px solid ${i.stroke.primary};
|
|
109
129
|
border-radius: 4px;
|
|
110
|
-
`;export{d as CollectionCardDetailStyle,r as CollectionCardInfoStyle,n as CollectionCardStyle,a as CollectionNameHolder,t as ContainerStyle,
|
|
130
|
+
`;export{d as CollectionCardDetailStyle,r as CollectionCardInfoStyle,n as CollectionCardStyle,a as CollectionNameHolder,t as ContainerStyle,c as ProductCardStyle,l as ProductScreenCollectionCardStyle,p as ProductScreenHeader,o as ScrollContainerStyle,x as SelectedScreenHeader,g as VariantCardGridStyle,s as VariantCardListStyle};
|
|
@@ -1 +1,38 @@
|
|
|
1
|
+
import { Collection, FbStatusFetcherReturn, Product, SelectedItems } from './modal';
|
|
2
|
+
import { CollectionsActions } from './reducers';
|
|
1
3
|
export declare const liftTheStateUp: (payload: any, data: any) => any;
|
|
4
|
+
export declare function paginateSelectedItems(selectedItems: SelectedItems, limit: number, offset: number): {
|
|
5
|
+
[key: string]: Collection;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* 3 scenarios.
|
|
9
|
+
* 1. If no api is provided -> marks everything as approved.
|
|
10
|
+
* 2. If api is success -> sets the status
|
|
11
|
+
* 3. If api is failure -> marks everything as approved.
|
|
12
|
+
*
|
|
13
|
+
* We first get the variant ids to fetch and only if we have variant ids, we call api.
|
|
14
|
+
*/
|
|
15
|
+
export declare const fetchFbStatusCollection: (data: SelectedItems, storeId: string, dispatcher: any, fbStatusFetcher?: ((storeId: string, variantIds: string[]) => FbStatusFetcherReturn) | undefined, dispatchType?: string) => void;
|
|
16
|
+
/**
|
|
17
|
+
* Instead of collection level, we do it product level.
|
|
18
|
+
*
|
|
19
|
+
* For more info refer @function getVariantIdsToFetch
|
|
20
|
+
*/
|
|
21
|
+
export declare const getVariantIdsToFetchAtProductLevel: (products: {
|
|
22
|
+
[key: string]: Product;
|
|
23
|
+
}, globalData?: Collection) => string[];
|
|
24
|
+
/**
|
|
25
|
+
* Instead of collection level, we do it product level.
|
|
26
|
+
*
|
|
27
|
+
* For more info refer @function markVariantsAsApproved
|
|
28
|
+
*/
|
|
29
|
+
export declare const markVariantsAsApprovedProductsLevel: (products: {
|
|
30
|
+
[key: string]: Product;
|
|
31
|
+
}, dispatcher: React.Dispatch<CollectionsActions>, collectionId: string, curScreenData?: Collection, setCurScreenData?: React.Dispatch<React.SetStateAction<Collection>>) => void;
|
|
32
|
+
/**
|
|
33
|
+
* If product has only one variant and variant name has product name, returns false.
|
|
34
|
+
* Other cases returns true.
|
|
35
|
+
*/
|
|
36
|
+
export declare const shouldShowVariant: (data: Product) => boolean;
|
|
37
|
+
export declare const isProductPartiallyChecked: (collectionId: string, productId: string, selectedData: SelectedItems, currentCollection: Collection) => boolean;
|
|
38
|
+
export declare const isCollectionPartiallyChecked: (collectionId: string, collection: Collection, selectedCollections: SelectedItems) => boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{cloneDeep as
|
|
1
|
+
import{cloneDeep as o}from"lodash";const l=(l,i)=>{const n=o(i);if(delete n.products,(l=Object.assign(Object.assign({},l),{catalogOnlyData:n})).productId&&i.products){const t=o(i.products[l.productId]);(null==t?void 0:t.variants)&&delete t.variants,l=Object.assign(Object.assign({},l),{catalogOnlyData:n,productOnlyData:t})}return l};function i(o,l,i){var t;const d={};let v=0;for(const s in o)if(Object.prototype.hasOwnProperty.call(o,s)){const u=o[s],c=n(u.products,l,i-v);c&&Object.keys(c).length>0&&(d[s]=Object.assign(Object.assign({},u),{products:c})),v+=Object.keys(null!==(t=u.products)&&void 0!==t?t:{}).length}return d}function n(o,l,i){if(!o)return{};const n=Object.keys(o).slice(i,i+l),t={};return n.forEach((l=>{t[l]=o[l]})),t}const t=(o,l,i)=>{Object.keys(o).forEach((l=>{var i,n;const t=null!==(n=null===(i=o[l])||void 0===i?void 0:i.products)&&void 0!==n?n:{};Object.keys(t).forEach((i=>{var n,t,d,v;const s=null!==(v=null===(d=null===(t=null===(n=o[l])||void 0===n?void 0:n.products)||void 0===t?void 0:t[i])||void 0===d?void 0:d.variants)&&void 0!==v?v:{};Object.keys(s).forEach((n=>{var t,d,v,s;const u=null===(s=null===(v=null===(d=null===(t=o[l])||void 0===t?void 0:t.products)||void 0===d?void 0:d[i])||void 0===v?void 0:v.variants)||void 0===s?void 0:s[n];u&&!u.fbStatus&&(u.fbStatus="APPROVED")}))}))})),l({type:i,data:o})},d=function(o,l,i,n){let d=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"paged";n||t(o,i,d);const v=(o=>{const l=[];return Object.keys(o).forEach((i=>{var n,t;const d=null!==(t=null===(n=o[i])||void 0===n?void 0:n.products)&&void 0!==t?t:{};Object.keys(d).forEach((n=>{var t,d,v,s;const u=null!==(s=null===(v=null===(d=null===(t=o[i])||void 0===t?void 0:t.products)||void 0===d?void 0:d[n])||void 0===v?void 0:v.variants)&&void 0!==s?s:{};Object.keys(u).forEach((t=>{var d,v,s,u;const c=null===(u=null===(s=null===(v=null===(d=o[i])||void 0===d?void 0:d.products)||void 0===v?void 0:v[n])||void 0===s?void 0:s.variants)||void 0===u?void 0:u[t];(null==c?void 0:c.fbStatus)||l.push(t)}))}))})),l})(o);v.length>0&&n&&n(l,v).then((l=>{const n=Object.assign({},o);Object.keys(n).forEach((o=>{var i,t;const d=null!==(t=null===(i=n[o])||void 0===i?void 0:i.products)&&void 0!==t?t:{};Object.keys(d).forEach((i=>{var t,d,v,s;const u=null!==(s=null===(v=null===(d=null===(t=n[o])||void 0===t?void 0:t.products)||void 0===d?void 0:d[i])||void 0===v?void 0:v.variants)&&void 0!==s?s:{};Object.keys(u).forEach((t=>{var d,v,s,u;const c=null===(u=null===(s=null===(v=null===(d=n[o])||void 0===d?void 0:d.products)||void 0===v?void 0:v[i])||void 0===s?void 0:s.variants)||void 0===u?void 0:u[t];c&&"REJECTED"===l[t]?c.fbStatus="REJECTED":c&&"APPROVED"===l[t]&&(c.fbStatus="APPROVED")}))}))})),i({type:d,data:n})})).catch((l=>{console.error("Error in fbStatusFetcher",l),t(o,i,d)}))},v=(o,l)=>{const i=[];return Object.keys(null!=o?o:{}).forEach((n=>{var t,d;const v=null!==(d=null===(t=null==o?void 0:o[n])||void 0===t?void 0:t.variants)&&void 0!==d?d:{};Object.keys(v).forEach((t=>{var d,v,s,u,c;let r;r=l?null===(s=null===(v=null===(d=null==l?void 0:l.products)||void 0===d?void 0:d[n])||void 0===v?void 0:v.variants)||void 0===s?void 0:s[t]:null===(c=null===(u=null==o?void 0:o[n])||void 0===u?void 0:u.variants)||void 0===c?void 0:c[t],(null==r?void 0:r.fbStatus)||i.push(t)}))})),i},s=(o,l,i,n,t)=>{const d=Object.assign({},o);if(Object.keys(o).forEach((l=>{var i,n;Object.keys(null!==(n=null===(i=null==o?void 0:o[l])||void 0===i?void 0:i.variants)&&void 0!==n?n:{}).forEach((i=>{var n,t;const v=null===(n=null==o?void 0:o[l].variants)||void 0===n?void 0:n[i];v&&(v.fbStatus="APPROVED");const s=null===(t=null==d?void 0:d[l])||void 0===t?void 0:t.variants;s&&s[i]&&(s[i]=v)}))})),n&&t){const o=Object.assign({},n);o.products=d,t(o),l({type:"productsPaged",data:{collectionId:i,products:d}})}else l({type:"productsPaged",data:{collectionId:i,products:d}})},u=o=>{const l=Object.keys(o.variants||[]);let i=!1;return!(l.length<=1)||(l.forEach((l=>{var n,t;i=null!==(t=null===(n=o.variants)||void 0===n?void 0:n[l].name.includes(o.name))&&void 0!==t&&t})),!i)},c=(o,l,i,n)=>{var t,d,v,s,u,c,r,a,e,f,p,b,O,h,j,y,E,k,g;let P=0,D=0;if(null===(d=null===(t=null==i?void 0:i[o])||void 0===t?void 0:t.products)||void 0===d?void 0:d[l]){const t=(null===(u=null===(s=null===(v=null==i?void 0:i[o])||void 0===v?void 0:v.products)||void 0===s?void 0:s[l])||void 0===u?void 0:u.variants)||[];if(1===Object.keys(t).length)for(const n in t){const t=null===(r=null===(c=null==i?void 0:i[o])||void 0===c?void 0:c.products)||void 0===r?void 0:r[l],d=null===(p=null===(f=null===(e=null===(a=null==i?void 0:i[o])||void 0===a?void 0:a.products)||void 0===e?void 0:e[l])||void 0===f?void 0:f.variants)||void 0===p?void 0:p[n];if(null===(b=null==d?void 0:d.name)||void 0===b?void 0:b.includes(null!==(O=null==t?void 0:t.name)&&void 0!==O?O:""))return!1}if(null===(y=Object.keys((null===(j=null===(h=null==n?void 0:n.products)||void 0===h?void 0:h[l])||void 0===j?void 0:j.variants)||[]))||void 0===y||y.forEach((()=>D++)),Object.keys((null===(g=null===(k=null===(E=null==i?void 0:i[o])||void 0===E?void 0:E.products)||void 0===k?void 0:k[l])||void 0===g?void 0:g.variants)||[]).forEach((()=>P++)),P>0&&D!==P)return!0}return!1},r=(o,l,i)=>{var n;let t=0,d=0;if(i[o]){const v=null==l?void 0:l.products;v&&Object.keys(v).forEach((o=>{var l;const i=null===(l=v[o])||void 0===l?void 0:l.variants;i&&Object.keys(i).forEach((o=>t+=1))}));const s=null===(n=i[o])||void 0===n?void 0:n.products;return s&&Object.keys(s).forEach((o=>{var l;const i=null===(l=s[o])||void 0===l?void 0:l.variants;i&&Object.keys(i).forEach((o=>d+=1))})),!(t<=0&&d>0)&&(d>0&&t!==d)}return!1};export{d as fetchFbStatusCollection,v as getVariantIdsToFetchAtProductLevel,r as isCollectionPartiallyChecked,c as isProductPartiallyChecked,l as liftTheStateUp,s as markVariantsAsApprovedProductsLevel,i as paginateSelectedItems,u as shouldShowVariant};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as t,jsx as e
|
|
1
|
+
import{jsxs as t,jsx as e}from"react/jsx-runtime";import o from"../../assets/icons/delete.svg.js";import i from"../../assets/icons/drag_handle.svg.js";import{COLORS as r}from"../../constants/Theme.js";import{IconButton as a}from"../icon-button/IconButton.js";import{ShimmerImage as n}from"../shimmer-image/ShimmerImage.js";import{TitleRegular as c}from"../TypographyStyle.js";import{truncate as s}from"./collectionScreen.js";import{ProductPickerTag as l}from"./ProductPickerTag.js";import{VariantCardListStyle as m,VariantCardGridStyle as d}from"./style.js";import{Tooltip as h}from"../tooltips/Tooltip.js";const p=d=>{const{data:p,selectedCollectionsDispatch:g,outOfStockAction:u}=d,j=t=>{let e;return e=p.name.includes(p.productName)?p.name:`${p.productName} ${p.name}`,t?s(e,34,!0):e};return t(m,{children:[t("div",Object.assign({className:"text-container"},{children:[e(i,{width:24,height:24,color:r.content.placeholder}),e("div",{children:e(n,{width:40,height:40,imageUrl:p.image,alt:"Item",borderRadius:4},p.variantId)}),t("div",Object.assign({className:"tooltip-title-tag"},{children:[e(h,Object.assign({body:j(!1),placement:"bottom",delay:400,variant:"light"},{children:e(c,{children:j(!0)})})),e(l,{isVariant:!0,data:p,outOfStockAction:u})]}))]})),e(a,{Icon:()=>e(o,{width:24,height:24,color:r.content.placeholder}),onClick:()=>{g&&g({type:"variantUnselected",data:{productId:p.productId,variantId:p.variantId,collectionId:p.collectionId}}),d.onDelete&&d.onDelete()}})]})},g=t=>{const{data:o}=t;return e(d,{children:e(h,Object.assign({body:o.name,alwaysVisible:!1,variant:"dark",placement:"bottom"},{children:e(n,{width:72,height:72,imageUrl:o.image,alt:"Item",borderRadius:4})}))})};export{g as VariantCardGridView,p as VariantCardListView};
|
package/dist/esm/components/template-context-mapper/modalElements/EditWhatsAppCarouselTemplateV2.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as t,Fragment as o}from"react/jsx-runtime";import i from"../../../assets/icons/PlusIcon.js";import{cloneDeep as
|
|
1
|
+
import{jsxs as e,jsx as t,Fragment as o}from"react/jsx-runtime";import i from"../../../assets/icons/PlusIcon.js";import{cloneDeep as l}from"lodash";import{useState as a,useEffect as r}from"react";import{AddVariableV2SideModal as n}from"../../add-variableV2/AddVariableV2SideModal.js";import"../../../_virtual/_tslib.js";import"../../add-variableV2/AddVariableV2.styled.js";import{Button as s}from"../../button/Button.js";import"../../icon-button/IconButton.js";import"../../input/Input.js";import"../../tooltips/Tooltip.js";import{COLORS as d}from"../../../constants/Theme.js";import"../../modals/modal.styled.js";import"../../switch/Switch.js";import{TitleMedium as c,TitleRegular as m,BodySecondary as p,BodyCaption as u}from"../../TypographyStyle.js";import{ProductPickerModal as h}from"../../product-picker-v2/modal.js";import{useTemplateModalContext as g}from"../context/templateModalContext.js";import v from"./EditWhatsAppTemplateV2.js";import{ProductBox as f}from"./ProductBox.js";import"../../template-preview/TemplatePreview.js";import"../../template-preview/WhatsApp/WhatsAppLikePreview.js";import"../../template-preview/WhatsApp/WhatsAppLikePreviewV2.js";import"../../curtain/CurtainHelper.js";import"../../template-preview/models/TemplateMeta.js";import{POD as b}from"../../template-preview/models/WhatsAppTemplate.js";const y=y=>{let{template:j,whatsappSpecificPickerMeta:C,showVariableModal:I,variableList:x,variableListForImage:w,discountCode:O,setDiscountCode:T}=y;var P,k;const{selectedCarouselIndex:S,setTemplate:V,pickerConf:L,isProductCarouselType:A,pod:E,cardCount:B,carouselProducts:M,setCarouselProducts:F,isError:W,cardImages:D,disableEditVariable:R,onDeleteSelectedProducts:q}=g(),[z,N]=a(-1==S?"First Message (Step 1/2)":"Carousel Cards (Step 2/2)"),[$,_]=a(!1),[G,H]=a(!1),[J,K]=a(!1);r((()=>{N(-1==S?"First Message (Step 1/2)":"Carousel Cards (Step 2/2)")}),[S]);return e("div",{children:[t(c,Object.assign({style:{marginLeft:10,marginBottom:10}},{children:z})),A&&(null!==(P=null==M?void 0:M.length)&&void 0!==P?P:0)>0&&null!=S&&S>=0&&e("div",Object.assign({style:{display:"flex",rowGap:16,marginBottom:16,marginLeft:10,marginRight:10,flexDirection:"column"}},{children:[t(f,{editItem:()=>{1===(null==M?void 0:M.length)&&"variable"===M[0].name?K(!0):_(!$)},cardBody:1===(null==M?void 0:M.length)&&"variable"===M[0].name?`${M[0].productName}`:`${null==M?void 0:M.length} Products Selected`,hideIcon:1===(null==M?void 0:M.length)&&"variable"===M[0].name,deleteItem:()=>{if(1===(null==M?void 0:M.length)&&"variable"===M[0].name)return void(null==F||F([]));const e=l(Object.assign({},j));e&&(null==D||D.forEach(((t,o)=>{var i;e.components[1].cards[o].components[0].example.header_handle=[null!==(i=D[o])&&void 0!==i?i:""]})),null==V||V(e)),null==F||F([]),null==q||q()}}),M&&(null==M?void 0:M.length)>0&&"variable"!=M[0].name&&t(s,{disabled:(null!==(k=null==M?void 0:M.length)&&void 0!==k?k:0)<=1,style:{alignSelf:"flex-end",background:d.surface.subdued},onClick:()=>{H(!0),_(!0)},buttonText:"Rearrange Products",buttonType:"tertiary"})]})),!R&&A&&0===(null==M?void 0:M.length)&&null!=S&&S>=0&&e(o,{children:[e("div",Object.assign({style:{marginLeft:12}},{children:[t(m,{children:"Product(s)"}),t(p,{children:`Select ${null!=B?B:1} products`})]})),e("div",Object.assign({style:{marginTop:16,marginBottom:16,marginLeft:12,marginRight:12,flexDirection:"column",display:"flex",alignItems:"center"}},{children:[t(s,{matchParentWidth:!0,style:{flex:1,display:"flex",width:"100%",marginBottom:12,border:W?`2px dashed ${d.content.negative}`:void 0},size:"medium",buttonText:"Add Product(s)",buttonType:W?"tertiaryGray":"dashBold",LeadingIcon:i,onClick:e=>{_(!0)}}),E===b.CHATBOT&&e(o,{children:[e("div",Object.assign({style:{display:"flex",flex:1,alignItems:"center",justifyContent:"space-between",flexDirection:"row",width:"100%"}},{children:[t("div",{style:{width:"100%",height:1,backgroundColor:"#E0E0E0",marginRight:8}}),t(u,Object.assign({style:{color:"#616161",overflow:"unset"}},{children:"OR"})),t("div",{style:{width:"100%",height:1,backgroundColor:"#E0E0E0",marginLeft:8}})]})),t(s,{matchParentWidth:!0,style:{flex:1,display:"flex",marginTop:12,width:"100%"},size:"medium",buttonText:"Add Product(s) Variable",buttonType:"dashBold",LeadingIcon:i,onClick:e=>{K(!0)}})]})]}))]}),t(v,{whatsappSpecificPickerMeta:C,template:j,onTemplateChange:e=>{null==V||V(e)},showVariableModal:I,variableList:x,variableListForImage:w,discountCode:O,setDiscountCode:T}),$&&L&&t(h,{zIndex:200,rearrangeEnabled:G,storeId:L.storeId,selectedItems:(e=>{if(e.length>0){const t={};for(const o of e){const e=null==o?void 0:o.collectionId,i=o.productId,l=o.variantId;e in t||(t[e]={products:{},name:"",image:"",isSmartCollection:!1}),i in t[e].products||(t[e].products[i]={variants:{},name:(null==o?void 0:o.productName)||"",image:(null==o?void 0:o.productImage)||""}),t[e].products[i].variants[l]={name:(null==o?void 0:o.name)||"",price:"",image:(null==o?void 0:o.image)||"",quantity:o.quantity||0,displayOrder:o.displayOrder}}return t}return{}})(null!=M?M:[]),collectionFetcher:L.fetchCollections,productFetcher:L.fetchProducts,onAdd:(e,t)=>{H(!1);const o=[];delete e.isCustom;for(const t of Object.keys(e)){const i=e[t].products;if(void 0!==i&&Object.keys(i).length)for(const e of Object.keys(i)){const l=i[e].variants;if(void 0!==l&&Object.keys(l).length)for(const a of Object.keys(l)){const{name:r,image:n,quantity:s,displayOrder:d}=l[a],c={name:r,image:n,quantity:s,variantId:a,productId:e,displayOrder:d,collectionId:t,productName:i[e].name,productImage:i[e].image};o.push(c)}}}const i=o.sort(((e,t)=>e.displayOrder-t.displayOrder)),a=o.map((e=>e.image)),r=l(Object.assign({},j));r&&(a.forEach(((e,t)=>{var o;r.components[1].cards[t].components[0].example.header_handle=e?[e]:[null!==(o=null==D?void 0:D[t])&&void 0!==o?o:""]})),null==V||V(r)),null==F||F(i),_(!1)},searchInCollectionFetcher:L.searchInCollection,searchFetcher:L.searchProducts,visible:$,onClose:()=>{_(!1)},exactLimit:null!=B?B:1}),J&&t(n,{zIndex:2e3,data:null!=x?x:[],showVariable:J,setShowVariable:K,placeholder:"Add a variable",customTrigger:e=>{null==F||F([{name:"variable",productName:e.actualValue}])}})]})};export{y as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{jsxs as t,jsx as e}from"react/jsx-runtime";import o from"../../../assets/icons/box.svg.js";import i from"../../../assets/icons/delete.svg.js";import n from"../../../assets/icons/edit.svg.js";import s from"styled-components";import{IconButton as r}from"../../icon-button/IconButton.js";import{
|
|
1
|
+
import{jsxs as t,jsx as e}from"react/jsx-runtime";import o from"../../../assets/icons/box.svg.js";import i from"../../../assets/icons/delete.svg.js";import n from"../../../assets/icons/edit.svg.js";import s from"styled-components";import{IconButton as r}from"../../icon-button/IconButton.js";import{TitleSmall as l}from"../../TypographyStyle.js";const c=s.div`
|
|
2
2
|
width: ${t=>t.width};
|
|
3
3
|
padding: 12px;
|
|
4
4
|
display: flex;
|
|
@@ -44,4 +44,4 @@ import{jsxs as t,jsx as e}from"react/jsx-runtime";import o from"../../../assets/
|
|
|
44
44
|
color: #000000;
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
`,d=s=>{const{cardBody:d,deleteItem:f,editItem:a}=s;return t(c,Object.assign({width:"100%"},{children:[e("div",Object.assign({style:{width:36,height:36}},{children:e(o,{})})),e("div",Object.assign({className:"card-body"},{children:e(l,{children:d})})),t("div",Object.assign({style:{display:"flex",alignItems:"center"}},{children:[a&&e(r,{style:{display:"flex"},Icon:n,onClick:t=>{a(),t.stopPropagation()}}),e(r,{style:{display:"flex",color:"#919191"},Icon:i,onClick:t=>{f(),t.stopPropagation()}})]}))]}))};export{d as ProductBox};
|
|
47
|
+
`,d=s=>{const{cardBody:d,deleteItem:f,editItem:a,hideIcon:p}=s;return t(c,Object.assign({width:"100%"},{children:[!p&&e("div",Object.assign({style:{width:36,height:36}},{children:e(o,{})})),e("div",Object.assign({className:"card-body"},{children:e(l,{children:d})})),t("div",Object.assign({style:{display:"flex",alignItems:"center"}},{children:[a&&e(r,{style:{display:"flex"},Icon:n,onClick:t=>{a(),t.stopPropagation()}}),e(r,{style:{display:"flex",color:"#919191"},Icon:i,onClick:t=>{f(),t.stopPropagation()}})]}))]}))};export{d as ProductBox};
|