@licklist/design 0.44.487 → 0.44.489
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/events/event-statistic-modal/EventStatisticModal.d.ts +1 -2
- package/dist/events/event-statistic-modal/EventStatisticModal.d.ts.map +1 -1
- package/dist/events/event-statistic-modal/EventStatisticModal.js +1 -1
- package/dist/events/event-statistic-modal/hooks/useTableData.d.ts +1 -1
- package/dist/events/event-statistic-modal/hooks/useTableData.d.ts.map +1 -1
- package/dist/events/event-statistic-modal/hooks/useTableData.js +1 -1
- package/dist/events/event-statistic-modal/utils/index.d.ts +1 -1
- package/dist/events/event-statistic-modal/utils/index.d.ts.map +1 -1
- package/dist/events/event-statistic-modal/utils/index.js +1 -1
- package/dist/product-set/form/ProductCategoriesControl.d.ts.map +1 -1
- package/dist/product-set/form/ProductCategoriesControl.js +1 -1
- package/package.json +1 -1
- package/src/events/event-statistic-modal/EventStatisticModal.tsx +1 -4
- package/src/events/event-statistic-modal/hooks/useTableData.tsx +4 -10
- package/src/events/event-statistic-modal/utils/index.ts +35 -38
- package/src/product-set/form/ProductCategoriesControl.tsx +7 -3
|
@@ -5,7 +5,6 @@ export declare type EventStatisticModalProps = {
|
|
|
5
5
|
setIsOpen: (value: boolean) => void;
|
|
6
6
|
eventStatistic?: EventStatistic | null;
|
|
7
7
|
title?: string;
|
|
8
|
-
date?: string;
|
|
9
8
|
};
|
|
10
|
-
export declare const EventStatisticModal: ({ isOpen, setIsOpen, eventStatistic, title,
|
|
9
|
+
export declare const EventStatisticModal: ({ isOpen, setIsOpen, eventStatistic, title, }: EventStatisticModalProps) => JSX.Element;
|
|
11
10
|
//# sourceMappingURL=EventStatisticModal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EventStatisticModal.d.ts","sourceRoot":"","sources":["../../../src/events/event-statistic-modal/EventStatisticModal.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,kEAAkE,CAAC;AAKlG,oBAAY,wBAAwB,GAAG;IACrC,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IACpC,cAAc,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;IACvC,KAAK,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"EventStatisticModal.d.ts","sourceRoot":"","sources":["../../../src/events/event-statistic-modal/EventStatisticModal.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,kEAAkE,CAAC;AAKlG,oBAAY,wBAAwB,GAAG;IACrC,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IACpC,cAAc,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;IACvC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,eAAO,MAAM,mBAAmB,kDAK7B,wBAAwB,gBAgD1B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react"),a=(e=t)&&"object"==typeof e&&"default"in e?e.default:e,l=require("react-i18next"),n=require("react-bootstrap"),r=require("../../static/Icon.js");require("../../table/MenuButton.js"),require("../../table/FilterHelperComponent.js"),require("../../table/PaginationHelperComponent.js"),require("../../table/PerPageHelperComponent.js");var s=require("../../table/StaticTable.js");require("../../table/TableHelperComponent.js");var i=require("./hooks/useTableData.js");exports.EventStatisticModal=function(e){var t=e.isOpen,o=e.setIsOpen,c=e.eventStatistic,u=e.title,m=
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react"),a=(e=t)&&"object"==typeof e&&"default"in e?e.default:e,l=require("react-i18next"),n=require("react-bootstrap"),r=require("../../static/Icon.js");require("../../table/MenuButton.js"),require("../../table/FilterHelperComponent.js"),require("../../table/PaginationHelperComponent.js"),require("../../table/PerPageHelperComponent.js");var s=require("../../table/StaticTable.js");require("../../table/TableHelperComponent.js");var i=require("./hooks/useTableData.js");exports.EventStatisticModal=function(e){var t=e.isOpen,o=e.setIsOpen,c=e.eventStatistic,u=e.title,m=l.useTranslation("Design").t,d=i.useTableData(c),b=function(){o(!1)};return a.createElement(n.Modal,{show:t,onHide:b,animation:!1,centered:!0,contentClassName:"rounded",className:"event-statistic-modal"},a.createElement(n.Modal.Header,null,a.createElement(n.Modal.Title,{as:"h6"},null!=u?u:m("eventStatistic")),a.createElement(n.Button,{variant:"danger",className:"btn-sm rounded",onClick:b},a.createElement(r.default,{type:"times",height:"1rem"}))),a.createElement(n.Modal.Body,null,d.length?a.createElement(a.Fragment,null,a.createElement("h5",{className:"mb-5"},m("statistics")),a.createElement(s.StaticTable,{columns:[{key:"name",label:""},{key:"quantity",label:""},{key:"total",label:""}],data:d,className:"event-statistic-table"})):a.createElement("div",{className:"no-statistic"},a.createElement("h5",null,m("noStatisticsForSelectedEvent")))))};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { EventStatistic } from "@licklist/core/dist/DataMapper/Provider/EventStatisticDataMapper";
|
|
2
2
|
import { StaticTableData } from "../../../table";
|
|
3
|
-
export declare const useTableData: (eventStatistic: EventStatistic | null
|
|
3
|
+
export declare const useTableData: (eventStatistic: EventStatistic | null) => StaticTableData[];
|
|
4
4
|
//# sourceMappingURL=useTableData.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTableData.d.ts","sourceRoot":"","sources":["../../../../src/events/event-statistic-modal/hooks/useTableData.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,MAAM,kEAAkE,CAAC;AAElG,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD,eAAO,MAAM,YAAY,
|
|
1
|
+
{"version":3,"file":"useTableData.d.ts","sourceRoot":"","sources":["../../../../src/events/event-statistic-modal/hooks/useTableData.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,MAAM,kEAAkE,CAAC;AAElG,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD,eAAO,MAAM,YAAY,mBAAoB,cAAc,GAAG,IAAI,sBA2EjE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("tslib"),r=require("react"),n=e(r),u=require("@licklist/core/dist/Config"),i=require("react-i18next"),a=e(require("clsx")),c=require("react-intl"),o=require("../utils/index.js");exports.useTableData=function(e
|
|
1
|
+
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("tslib"),r=require("react"),n=e(r),u=require("@licklist/core/dist/Config"),i=require("react-i18next"),a=e(require("clsx")),c=require("react-intl"),o=require("../utils/index.js");exports.useTableData=function(e){var s=i.useTranslation("Design").t,l=c.useIntl().formatNumber,f=t.__read(r.useState([]),2),d=f[0],y=f[1],T=function(e,t){return void 0===t&&(t=!1),n.createElement("div",{className:a("bold",t&&"header-row")},e)},b=function(e){var t=String(e);return Object.keys(o.TRANSLATION_KEYS).includes(t)?s(t):t};return r.useEffect((function(){y(function(e){if(!e)return[];var t=[];return o.convertEventStatisticToTableData(e).forEach((function(e){var r=e.name,n=e.quantity,i=e.total,a=e.isBold,c=e.isHeader,s=e.key,f=Object.keys(o.TRANSLATION_KEYS).includes(String(i))?i:l(Number(i),{style:"currency",currency:u.Currency.GBP}),d=b(r),y=b(n);a?t.push({name:T(d,c),quantity:T(y,c),total:T(r===o.TRANSLATION_KEYS.total?"Total: ".concat(f):f,c),key:s}):t.push({name:d,quantity:y,total:f,key:s})})),t}(e))}),[e]),d};
|
|
@@ -4,7 +4,7 @@ export declare const TRANSLATION_KEYS: {
|
|
|
4
4
|
total: string;
|
|
5
5
|
totalPerCategory: string;
|
|
6
6
|
};
|
|
7
|
-
export declare const convertEventStatisticToTableData: (eventStatistic: EventStatistic
|
|
7
|
+
export declare const convertEventStatisticToTableData: (eventStatistic: EventStatistic) => {
|
|
8
8
|
name: string;
|
|
9
9
|
key: string;
|
|
10
10
|
isHeader?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/events/event-statistic-modal/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kEAAkE,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/events/event-statistic-modal/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kEAAkE,CAAC;AAElG,eAAO,MAAM,gBAAgB;;;;CAI5B,CAAC;AAEF,eAAO,MAAM,gCAAgC,mBAC3B,cAAc;UAUtB,MAAM;SACP,MAAM;eACA,OAAO;aACT,OAAO;cACN,MAAM,GAAG,MAAM;WAClB,MAAM,GAAG,MAAM;GA0DzB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t={shortQuantity:"shortQuantity",total:"total",totalPerCategory:"totalPerCategory"};exports.TRANSLATION_KEYS=t,exports.convertEventStatisticToTableData=function(a){var o,n=0,e=0;if(!a)return[];var r=[];return null===(o=Object.values(null==a?void 0:a.productCategorySummary))||void 0===o||o.forEach((function(a){null==a||a.forEach((function(a){var o=a.totalPerCategory,c=a.productsSummary,l=void 0===c?[]:c,u=a.categoryName,i=a.eventId,y=0;n+=o||0,r.push({name:u,key:"".concat(i,".").concat(u),isBold:!0,isHeader:!0,quantity:t.shortQuantity,total:t.total}),null==l||l.forEach((function(t){var a=t.productsSold,o=t.name,n=t.totalQuantity,e=t.total;y+=a,r.push({name:o,key:"".concat(i,".").concat(u,".").concat(o),quantity:n?"".concat(a," / ").concat(n):String(a),total:String(e)})})),r.push({name:t.totalPerCategory,key:"".concat(i,".").concat(u,".").concat(t.totalPerCategory),quantity:y,total:o,isBold:!0}),e+=y}))})),r.push({name:t.total,key:"".concat(t.total,".").concat(n),quantity:e,total:n,isBold:!0}),r};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProductCategoriesControl.d.ts","sourceRoot":"","sources":["../../../src/product-set/form/ProductCategoriesControl.tsx"],"names":[],"mappings":";AAYA,OAAO,EAKL,YAAY,EACb,MAAM,kEAAkE,CAAC;AAQ1E,OAAO,EAAwB,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAQvE,UAAU,6BAA8B,SAAQ,aAAa;IAC3D,SAAS,EAAE,MAAM,CAAC;CACnB;AA4BD,wBAAgB,wBAAwB,CAAC,EACvC,SAAS,EACT,SAAS,GACV,EAAE,6BAA6B,
|
|
1
|
+
{"version":3,"file":"ProductCategoriesControl.d.ts","sourceRoot":"","sources":["../../../src/product-set/form/ProductCategoriesControl.tsx"],"names":[],"mappings":";AAYA,OAAO,EAKL,YAAY,EACb,MAAM,kEAAkE,CAAC;AAQ1E,OAAO,EAAwB,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAQvE,UAAU,6BAA8B,SAAQ,aAAa;IAC3D,SAAS,EAAE,MAAM,CAAC;CACnB;AA4BD,wBAAgB,wBAAwB,CAAC,EACvC,SAAS,EACT,SAAS,GACV,EAAE,6BAA6B,eAyR/B;AAED,eAAO,MAAM,cAAc,iBACX,YAAY,SACnB,MAAM;WACH,MAAM;eAAa,MAAM;CAcpC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("tslib"),r=require("react"),n=e(r),o=require("react-i18next"),i=require("react-bootstrap"),a=require("react-hook-form"),u=e(require("@licklist/plugins/dist/services/Form/HookFormService")),d=e(require("clsx")),l=require("@dnd-kit/core"),s=require("lodash"),c=require("../../sortable-tree/SortableTreeItem.js"),m=require("../../sortable-tree/SortableTree.js"),p=require("../item/CreateProductSetItem.js"),
|
|
1
|
+
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("tslib"),r=require("react"),n=e(r),o=require("react-i18next"),i=require("react-bootstrap"),a=require("react-hook-form"),u=e(require("@licklist/plugins/dist/services/Form/HookFormService")),d=e(require("clsx")),l=require("@dnd-kit/core"),s=require("lodash"),c=require("../../sortable-tree/SortableTreeItem.js"),m=require("../../sortable-tree/SortableTree.js"),p=require("../item/CreateProductSetItem.js"),g=require("./context.js"),v=require("@licklist/core/dist/DataMapper/Product/ProductCategoryDataMapper"),f=require("../product-category/ProductCategoryControl.js"),y=require("./ProductsControl.js"),C=require("./SelectCategoryModal.js"),E=require("./VenueMapSetModal.js"),_=require("../utils/index.js");var b=function(e,t){return e===v.CATEGORY_TYPE_GAME?{className:"game-badge",label:t}:e===v.CATEGORY_TYPE_FIXED_DURATION?{className:"fixed-duration-badge",label:t}:null};exports.ProductCategoriesControl=function(e){var I,S,q,T,x,P,N=e.isLoading,M=e.stepIndex,A=o.useTranslation("Design").t,h=r.useContext(g.ProductSetLoadingContext),k=h.providerHasMap,j=h.expandedProductCategories,D=h.setExpandedProductCategories,R=a.useFormContext(),V=t.__read(r.useState(!1),2),Y=V[0],F=V[1],O=t.__read(r.useState(!1),2),B=O[0],L=O[1],w=t.__read(r.useState(!1),2),G=w[0],H=w[1],U=R.control,Q=R.formState.errors,K=R.clearErrors,z=R.watch,W=R.trigger,X=R.getValues,J=R.setValue,Z=z("steps.".concat(M,".hasMap"))||!1,$="steps.".concat(M,".productCategories"),ee=a.useFieldArray({name:$,control:U,keyName:"_id"}),te=ee.fields,re=ee.append,ne=ee.remove,oe=t.__read(r.useState([]),2),ie=oe[0],ae=oe[1],ue=a.useWatch({control:U,name:$}),de=null===(S=null===(I=null==Q?void 0:Q.steps)||void 0===I?void 0:I[M])||void 0===S?void 0:S.productCategories,le=null===(T=null===(q=null==Q?void 0:Q.steps)||void 0===q?void 0:q[M])||void 0===T?void 0:T.venueMapSetId,se=null===(P=null===(x=null==Q?void 0:Q.steps)||void 0===x?void 0:x[M])||void 0===P?void 0:P.pointProducts,ce=Boolean(le||se),me=l.useSensor(l.MouseSensor,{activationConstraint:{distance:10}});return r.useEffect((function(){ue&&ue.length&&ue.forEach((function(e){var r,n,o=null===(r=e.products)||void 0===r?void 0:r.reduce((function(e,t){return e+Number(t.price)*Number(t.totalQuantity)}),0),i=null===(n=e.products)||void 0===n?void 0:n.reduce((function(e,t){return e+(t.isUnlimited?0:Number(t.totalQuantity))}),0);ae((function(r){var n;return t.__assign(t.__assign({},r),((n={})[(null==e?void 0:e.id)||e.uniqueId]={price:o,quantity:i},n))}))}))}),[ue]),r.useEffect((function(){1===te.length&&D((function(e){var r,n,o;return t.__assign(t.__assign({},e),((r={})[String((null===(n=te[0])||void 0===n?void 0:n.id)||(null===(o=te[0])||void 0===o?void 0:o.uniqueId))]=!0,r))}))}),[te]),n.createElement(n.Fragment,null,n.createElement(m.SortableTree,{sensors:[me],items:te.map((function(e){return String(e._id)})),onDragEnd:function(e){var t=e.active,r=e.over;if(t&&r&&(null==t?void 0:t.id)&&(null==r?void 0:r.id)){var n=te.findIndex((function(e){return e._id===t.id})),o=te.findIndex((function(e){return e._id===r.id}));if(n!==o){var i=X($);if(i){var a=_.sortArrayByIndex(_.moveArrayElements(i,n,o));J($,a)}}}}},te.map((function(e,r){var o=(null==e?void 0:e.id)?String(e.id):e.uniqueId,u=function(){!function(e){D((function(r){var n;return t.__assign(t.__assign({},r),((n={})[e]=!r[e],n))}))}(o)};return n.createElement(a.Controller,{key:"product-category-".concat(e._id),name:"".concat($,".").concat(r,".name"),control:U,rules:{required:A("Validation:fieldRequired",{attribute:A("name")})},render:function(t){var a,d,l,s=t.field,p=s.value,g=s.onChange;return n.createElement(m.SortableTree.Item,{id:e._id,title:p,isExpanded:j[o],setIsExpanded:u,isInvalid:!!de,badge:n.createElement(i.Badge,{className:"category-badge"},A("productCategory")),isIconInHeader:!1,subTitle:n.createElement("div",{className:"product-set-badges-container"},n.createElement("div",{className:"product-set-subtitle-dot product-set-subtitle-category-dot"}),n.createElement("span",null,null!==(l=null===(d=ie[null!==(a=null==e?void 0:e.id)&&void 0!==a?a:e.uniqueId])||void 0===d?void 0:d.quantity)&&void 0!==l?l:"N/A"," ",A("products"))),treeLineIconColor:"#1A93AA",modalLabel:A("addNewCategory"),secondaryBadge:b(e.type,A(e.type)),modalClass:c.ProductSetModalClasses.category,isNewAdded:G,body:n.createElement(f.ProductCategoryControl,{isLoading:N,onCategoryNameChange:g,categoryName:p,stepIndex:M,productCategoryIndex:r}),onDelete:function(){return ne(r)},validate:function(){return W("steps.".concat(M,".productCategories.").concat(r))},sortableItems:e.products?e.products.filter((function(e){return e.id})).map((function(e){var t=e.id;return String(t)})):[]},n.createElement(y.ProductsControl,{isLoading:N,quantityType:e.quantityType,hasTicket:null==e?void 0:e.hasTicket,stepIndex:M,productCategoryIndex:r,categoryType:e.type}))}})}))),n.createElement(p.CreateProductSetItem,{title:A("addCategory"),onClick:function(){F(!0)}}),n.createElement(C.SelectCategoryModal,{isVisible:Y,onHide:function(){return F(!1)},onCategorySelect:function(e){re(function(e,t){return{id:null,uniqueId:s.uniqueId("product-category"),name:"",minSubItems:null,maxSubItems:null,quantityType:v.QUANTITY_TYPE_STANDARD,type:e,isRelyOnPeople:e===v.CATEGORY_TYPE_TICKETS,isTimeRelated:!1,collectUserInfo:!1,hasTicket:e===v.CATEGORY_TYPE_TICKETS,allowDeposits:!1,remainderExpireAfter:void 0,hasBookingManagement:!1,weight:0,isReusable:!1,hasSubEvents:!1,products:[],zoneId:null,sort:t}}(e,te.length)),H(!0),(null==de?void 0:de.type)===u.manualErrorType&&K($)}}),k&&Z&&n.createElement(n.Fragment,null,n.createElement(p.CreateProductSetItem,{title:A("editMap"),onClick:function(){L(!0)},className:d("mt-3",ce&&"mb-3",ce&&"is-invalid")}),ce&&n.createElement("div",{className:"manual-form-error"},le&&A("Validation:fieldRequired",{attribute:A("Design:venueMapSet")}),se&&A("Validation:fieldMinNumber",{attribute:A("pointProduct"),min:1})),n.createElement(E.VenueMapSetModal,{isVisible:B,setIsVisible:L,stepIndex:M})),n.createElement("div",{className:"manual-form-error"},de&&de.message))},exports.getBadgeConfig=b;
|
package/package.json
CHANGED
|
@@ -11,7 +11,6 @@ export type EventStatisticModalProps = {
|
|
|
11
11
|
setIsOpen: (value: boolean) => void;
|
|
12
12
|
eventStatistic?: EventStatistic | null;
|
|
13
13
|
title?: string;
|
|
14
|
-
date?: string;
|
|
15
14
|
};
|
|
16
15
|
|
|
17
16
|
export const EventStatisticModal = ({
|
|
@@ -19,11 +18,9 @@ export const EventStatisticModal = ({
|
|
|
19
18
|
setIsOpen,
|
|
20
19
|
eventStatistic,
|
|
21
20
|
title,
|
|
22
|
-
date,
|
|
23
21
|
}: EventStatisticModalProps) => {
|
|
24
22
|
const { t } = useTranslation("Design");
|
|
25
|
-
const data = useTableData(eventStatistic
|
|
26
|
-
|
|
23
|
+
const data = useTableData(eventStatistic);
|
|
27
24
|
const handleClose = () => {
|
|
28
25
|
setIsOpen(false);
|
|
29
26
|
};
|
|
@@ -7,10 +7,7 @@ import { EventStatistic } from "@licklist/core/dist/DataMapper/Provider/EventSta
|
|
|
7
7
|
import { convertEventStatisticToTableData, TRANSLATION_KEYS } from "../utils";
|
|
8
8
|
import { StaticTableData } from "../../../table";
|
|
9
9
|
|
|
10
|
-
export const useTableData = (
|
|
11
|
-
eventStatistic: EventStatistic | null,
|
|
12
|
-
date: string
|
|
13
|
-
) => {
|
|
10
|
+
export const useTableData = (eventStatistic: EventStatistic | null) => {
|
|
14
11
|
const { t } = useTranslation("Design");
|
|
15
12
|
const { formatNumber } = useIntl();
|
|
16
13
|
const [tableRows, setTableRows] = useState<StaticTableData[]>([]);
|
|
@@ -31,17 +28,14 @@ export const useTableData = (
|
|
|
31
28
|
return t(key);
|
|
32
29
|
};
|
|
33
30
|
|
|
34
|
-
const transformStatisticToTableRows = (
|
|
35
|
-
statistic: EventStatistic | null,
|
|
36
|
-
date: string
|
|
37
|
-
) => {
|
|
31
|
+
const transformStatisticToTableRows = (statistic: EventStatistic | null) => {
|
|
38
32
|
if (!statistic) {
|
|
39
33
|
return [];
|
|
40
34
|
}
|
|
41
35
|
|
|
42
36
|
const tableDataRows: StaticTableData[] = [];
|
|
43
37
|
|
|
44
|
-
convertEventStatisticToTableData(statistic
|
|
38
|
+
convertEventStatisticToTableData(statistic).forEach(
|
|
45
39
|
({ name, quantity, total, isBold, isHeader, key }) => {
|
|
46
40
|
const formattedTotal = !Object.keys(TRANSLATION_KEYS).includes(
|
|
47
41
|
String(total)
|
|
@@ -83,7 +77,7 @@ export const useTableData = (
|
|
|
83
77
|
};
|
|
84
78
|
|
|
85
79
|
useEffect(() => {
|
|
86
|
-
setTableRows(transformStatisticToTableRows(eventStatistic
|
|
80
|
+
setTableRows(transformStatisticToTableRows(eventStatistic));
|
|
87
81
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
88
82
|
}, [eventStatistic]);
|
|
89
83
|
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { EventStatistic } from "@licklist/core/dist/DataMapper/Provider/EventStatisticDataMapper";
|
|
2
|
-
import { DateTime } from "luxon";
|
|
3
|
-
import { DATE_TIME_FULL_FORMAT } from "@licklist/core/dist/Config";
|
|
4
2
|
|
|
5
3
|
export const TRANSLATION_KEYS = {
|
|
6
4
|
shortQuantity: "shortQuantity",
|
|
@@ -9,8 +7,7 @@ export const TRANSLATION_KEYS = {
|
|
|
9
7
|
};
|
|
10
8
|
|
|
11
9
|
export const convertEventStatisticToTableData = (
|
|
12
|
-
eventStatistic: EventStatistic
|
|
13
|
-
date: string
|
|
10
|
+
eventStatistic: EventStatistic
|
|
14
11
|
) => {
|
|
15
12
|
let totalAmount = 0;
|
|
16
13
|
let totalQuantity = 0;
|
|
@@ -28,49 +25,49 @@ export const convertEventStatisticToTableData = (
|
|
|
28
25
|
total: string | number;
|
|
29
26
|
}[] = [];
|
|
30
27
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
Object.values(eventStatistic?.productCategorySummary)?.forEach(
|
|
29
|
+
(categories) => {
|
|
30
|
+
categories?.forEach(
|
|
31
|
+
({ totalPerCategory, productsSummary = [], categoryName, eventId }) => {
|
|
32
|
+
let quantity = 0;
|
|
34
33
|
|
|
35
|
-
|
|
36
|
-
({ totalPerCategory, productsSummary = [], categoryName, eventId }) => {
|
|
37
|
-
let quantity = 0;
|
|
34
|
+
totalAmount += totalPerCategory || 0;
|
|
38
35
|
|
|
39
|
-
|
|
36
|
+
tableDataArray.push({
|
|
37
|
+
name: categoryName,
|
|
38
|
+
key: `${eventId}.${categoryName}`,
|
|
39
|
+
isBold: true,
|
|
40
|
+
isHeader: true,
|
|
41
|
+
quantity: TRANSLATION_KEYS.shortQuantity,
|
|
42
|
+
total: TRANSLATION_KEYS.total,
|
|
43
|
+
});
|
|
40
44
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
isBold: true,
|
|
45
|
-
isHeader: true,
|
|
46
|
-
quantity: TRANSLATION_KEYS.shortQuantity,
|
|
47
|
-
total: TRANSLATION_KEYS.total,
|
|
48
|
-
});
|
|
45
|
+
productsSummary?.forEach(
|
|
46
|
+
({ productsSold, name, totalQuantity, total }) => {
|
|
47
|
+
quantity += productsSold;
|
|
49
48
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
tableDataArray.push({
|
|
50
|
+
name,
|
|
51
|
+
key: `${eventId}.${categoryName}.${name}`,
|
|
52
|
+
quantity: totalQuantity
|
|
53
|
+
? `${productsSold} / ${totalQuantity}`
|
|
54
|
+
: String(productsSold),
|
|
55
|
+
total: String(total),
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
);
|
|
53
59
|
|
|
54
60
|
tableDataArray.push({
|
|
55
|
-
name,
|
|
56
|
-
key: `${eventId}.${categoryName}.${
|
|
57
|
-
quantity
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
total: String(total),
|
|
61
|
+
name: TRANSLATION_KEYS.totalPerCategory,
|
|
62
|
+
key: `${eventId}.${categoryName}.${TRANSLATION_KEYS.totalPerCategory}`,
|
|
63
|
+
quantity,
|
|
64
|
+
total: totalPerCategory,
|
|
65
|
+
isBold: true,
|
|
61
66
|
});
|
|
67
|
+
|
|
68
|
+
totalQuantity += quantity;
|
|
62
69
|
}
|
|
63
70
|
);
|
|
64
|
-
|
|
65
|
-
tableDataArray.push({
|
|
66
|
-
name: TRANSLATION_KEYS.totalPerCategory,
|
|
67
|
-
key: `${eventId}.${categoryName}.${TRANSLATION_KEYS.totalPerCategory}`,
|
|
68
|
-
quantity,
|
|
69
|
-
total: totalPerCategory,
|
|
70
|
-
isBold: true,
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
totalQuantity += quantity;
|
|
74
71
|
}
|
|
75
72
|
);
|
|
76
73
|
|
|
@@ -165,17 +165,21 @@ export function ProductCategoriesControl({
|
|
|
165
165
|
return sum + Number(product.price) * Number(product.totalQuantity);
|
|
166
166
|
}, 0);
|
|
167
167
|
const quantity = productCategory.products?.reduce((sum, product) => {
|
|
168
|
-
|
|
168
|
+
const productQuantity = !product.isUnlimited
|
|
169
|
+
? Number(product.totalQuantity)
|
|
170
|
+
: 0;
|
|
171
|
+
return sum + productQuantity;
|
|
169
172
|
}, 0);
|
|
170
173
|
|
|
171
|
-
setProductCategoryState({
|
|
174
|
+
setProductCategoryState((prevState) => ({
|
|
175
|
+
...prevState,
|
|
172
176
|
// New added categories will have uniqueId
|
|
173
177
|
// but existing have already assigned Id.
|
|
174
178
|
[productCategory?.id || productCategory.uniqueId]: {
|
|
175
179
|
price,
|
|
176
180
|
quantity,
|
|
177
181
|
},
|
|
178
|
-
});
|
|
182
|
+
}));
|
|
179
183
|
});
|
|
180
184
|
}, [productCategories]);
|
|
181
185
|
|