@licklist/design 0.44.543 → 0.44.545

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.
@@ -2,6 +2,33 @@ import { EventStatistic } from "@licklist/core/dist/DataMapper/Provider/EventSta
2
2
  export declare function formatContent(content: any, maxSymbols: any): any;
3
3
  export declare const formatContentWithoutTags: (content: any, maxLength?: number) => any;
4
4
  export declare const EVENT_DESCRIPTION_SIZE = 300;
5
+ /**
6
+ * Calculate the total number of views from the given dates and event statistic.
7
+ *
8
+ * @param {string[]} dates - An array of dates.
9
+ * @param {EventStatistic} eventStatistic - The event statistic object.
10
+ * @returns {number} - The total number of views.
11
+ */
12
+ export declare const calculateTotalViews: (dates: string[], eventStatistic: EventStatistic) => number;
13
+ /**
14
+ * Calculates the total number of products sold and the total amount sold
15
+ * based on the provided dates and event statistics.
16
+ *
17
+ * @param {string[]} dates - An array of dates.
18
+ * @param {EventStatistic} eventStatistic - Object containing event statistics.
19
+ * @returns {number[]} An array representing the total number of products sold and total amount sold.
20
+ */
21
+ export declare const calculateTotalSoldAndAmount: (dates: string[], eventStatistic: EventStatistic) => [number, number];
22
+ /**
23
+ * Get statistic information for a given event and date.
24
+ * @param {EventStatistic | null} eventStatistic - The event statistic object.
25
+ * @param {string} date - The date in ISO format.
26
+ * @returns {{
27
+ * totalViews: number;
28
+ * totalSold: number;
29
+ * totalAmount: number;
30
+ * }} The statistic information object.
31
+ */
5
32
  export declare const getStatisticInfo: (eventStatistic: EventStatistic | null, date: string) => {
6
33
  totalViews: number;
7
34
  totalSold: number;
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/events/event-card/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,kEAAkE,CAAC;AAGlG,wBAAgB,aAAa,CAAC,OAAO,KAAA,EAAE,UAAU,KAAA,OAIhD;AAED,eAAO,MAAM,wBAAwB,2CAepC,CAAC;AAEF,eAAO,MAAM,sBAAsB,MAAM,CAAC;AAE1C,eAAO,MAAM,gBAAgB,mBACX,cAAc,GAAG,IAAI,QAC/B,MAAM;;;;CA6Bb,CAAC"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/events/event-card/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,kEAAkE,CAAC;AAGlG,wBAAgB,aAAa,CAAC,OAAO,KAAA,EAAE,UAAU,KAAA,OAIhD;AAED,eAAO,MAAM,wBAAwB,2CAepC,CAAC;AAEF,eAAO,MAAM,sBAAsB,MAAM,CAAC;AAE1C;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,UACvB,MAAM,EAAE,kBACC,cAAc,KAC7B,MAUF,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,2BAA2B,UAC/B,MAAM,EAAE,kBACC,cAAc,KAC7B,CAAC,MAAM,EAAE,MAAM,CAejB,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,gBAAgB,mBACX,cAAc,GAAG,IAAI,QAC/B,MAAM;gBAEA,MAAM;eACP,MAAM;iBACJ,MAAM;CAmBpB,CAAC"}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@licklist/core/dist/Config"),o=require("luxon");var r=300;exports.EVENT_DESCRIPTION_SIZE=r,exports.formatContent=function(t,o){return t?t.length>o?"".concat(t.slice(0,o),"..."):t:""},exports.formatContentWithoutTags=function(t,o){if(void 0===o&&(o=r),!t)return"";if(t<o)return t;var e=t.replace(/<[^>]*>/g,"").trim().replace(/&nbsp;|[^a-zA-Z0-9\s]/g,"").replace(/\s\s+/g," ").slice(0,o).split(" "),i=String(t).indexOf(e[e.length-2]);return t.slice(0,i).concat("...")},exports.getStatisticInfo=function(r,e){var i,n,a,l,u=0,s=0;if(!r)return{totalViews:0,totalSold:0,totalAmount:0};var c=o.DateTime.fromISO(e).toUTC().toFormat(t.DATE_FORMAT);l=(null===(i=r.views[c])||void 0===i?void 0:i.pageViews)||0;var d=o.DateTime.fromISO(e).toUTC().toFormat(t.DATE_TIME_FULL_FORMAT);return null===(a=null===(n=null==r?void 0:r.productCategorySummary)||void 0===n?void 0:n[d])||void 0===a||a.forEach((function(t){var o=t.totalPerCategory,r=t.productsSummary,e=void 0===r?[]:r;s+=o||0,null==e||e.forEach((function(t){var o=t.productsSold;u+=o}))})),{totalViews:l,totalSold:u,totalAmount:s}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("tslib"),e=require("@licklist/core/dist/Config"),r=require("luxon");var o=300,n=function(t,e){return t.reduce((function(t,r){var o;return t+Object.values(null!==(o=e.views[r])&&void 0!==o?o:{}).reduce((function(t,e){return t+(e.pageViews||0)}),0)}),0)},u=function(t,e){var r=0,o=0;return t.forEach((function(t){var n;return Object.values(null!==(n=e.productCategorySummary[t])&&void 0!==n?n:{}).forEach((function(t){var e,n=t.totalPerCategory,u=t.productsSummary;o+=n||0,r+=null!==(e=null==u?void 0:u.reduce((function(t,e){return t+e.productsSold}),0))&&void 0!==e?e:0}))})),[r,o]};exports.EVENT_DESCRIPTION_SIZE=o,exports.calculateTotalSoldAndAmount=u,exports.calculateTotalViews=n,exports.formatContent=function(t,e){return t?t.length>e?"".concat(t.slice(0,e),"..."):t:""},exports.formatContentWithoutTags=function(t,e){if(void 0===e&&(e=o),!t)return"";if(t<e)return t;var r=t.replace(/<[^>]*>/g,"").trim().replace(/&nbsp;|[^a-zA-Z0-9\s]/g,"").replace(/\s\s+/g," ").slice(0,e).split(" "),n=String(t).indexOf(r[r.length-2]);return t.slice(0,n).concat("...")},exports.getStatisticInfo=function(o,a){if(!o)return{totalViews:0,totalSold:0,totalAmount:0};var i=r.DateTime.fromISO(a).toUTC().toFormat(e.DATE_FORMAT),l=r.DateTime.fromISO(a).toUTC().toFormat(e.DATE_TIME_FULL_FORMAT),c=n([i],o),s=t.__read(u([l],o),2);return{totalViews:c,totalSold:s[0],totalAmount:s[1]}};
@@ -1,10 +1,12 @@
1
1
  /// <reference types="react" />
2
2
  import { EventStatistic } from "@licklist/core/dist/DataMapper/Provider/EventStatisticDataMapper";
3
+ import { Event } from "@licklist/core/dist/DataMapper/Provider/EventDataMapper";
3
4
  export type EventStatisticModalProps = {
4
5
  isOpen: boolean;
5
6
  setIsOpen: (value: boolean) => void;
7
+ date?: Event["startAt"] | null;
6
8
  eventStatistic?: EventStatistic | null;
7
9
  title?: string;
8
10
  };
9
- export declare const EventStatisticModal: ({ isOpen, setIsOpen, eventStatistic, title, }: EventStatisticModalProps) => JSX.Element;
11
+ export declare const EventStatisticModal: ({ isOpen, setIsOpen, date, eventStatistic, title, }: EventStatisticModalProps) => JSX.Element;
10
12
  //# 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,MAAM,MAAM,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
+ {"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;AAClG,OAAO,EAAE,KAAK,EAAE,MAAM,yDAAyD,CAAC;AAKhF,MAAM,MAAM,wBAAwB,GAAG;IACrC,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IACpC,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC;IAC/B,cAAc,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;IACvC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,eAAO,MAAM,mBAAmB,wDAM7B,wBAAwB,gBAiD1B,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"),require("../../table/ReactTableHelperComponent.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:"striped-static-table"})):a.createElement("div",{className:"no-statistic"},a.createElement("h5",null,m("noStatisticsForSelectedEvent")))))};
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"),require("../../table/ReactTableHelperComponent.js");var i=require("./hooks/useTableData.js");exports.EventStatisticModal=function(e){var t=e.isOpen,o=e.setIsOpen,c=e.date,u=e.eventStatistic,m=e.title,d=l.useTranslation("Design").t,b=i.useTableData(c,u),p=function(){o(!1)};return a.createElement(n.Modal,{show:t,onHide:p,animation:!1,centered:!0,contentClassName:"rounded",className:"event-statistic-modal"},a.createElement(n.Modal.Header,null,a.createElement(n.Modal.Title,{as:"h6"},null!=m?m:d("eventStatistic")),a.createElement(n.Button,{variant:"danger",className:"btn-sm rounded",onClick:p},a.createElement(r.default,{type:"times",height:"1rem"}))),a.createElement(n.Modal.Body,null,b.length?a.createElement(a.Fragment,null,a.createElement("h5",{className:"mb-5"},d("statistics")),a.createElement(s.StaticTable,{columns:[{key:"name",label:""},{key:"quantity",label:""},{key:"total",label:""}],data:b,className:"striped-static-table"})):a.createElement("div",{className:"no-statistic"},a.createElement("h5",null,d("noStatisticsForSelectedEvent")))))};
@@ -1,4 +1,5 @@
1
1
  import { EventStatistic } from "@licklist/core/dist/DataMapper/Provider/EventStatisticDataMapper";
2
+ import { Event } from "@licklist/core/dist/DataMapper/Provider/EventDataMapper";
2
3
  import { StaticTableData } from "../../../table";
3
- export declare const useTableData: (eventStatistic: EventStatistic | null) => StaticTableData[];
4
+ export declare const useTableData: (date: Event["startAt"] | null, eventStatistic: EventStatistic | null) => StaticTableData[];
4
5
  //# 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,mBAAoB,cAAc,GAAG,IAAI,sBA2EjE,CAAC"}
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;AAClG,OAAO,EAAE,KAAK,EAAE,MAAM,yDAAyD,CAAC;AAEhF,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD,eAAO,MAAM,YAAY,SACjB,KAAK,CAAC,SAAS,CAAC,GAAG,IAAI,kBACb,cAAc,GAAG,IAAI,sBA+EtC,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){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};
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,s){var l=i.useTranslation("Design").t,f=c.useIntl().formatNumber,d=t.__read(r.useState([]),2),y=d[0],T=d[1],b=function(e,t){return void 0===t&&(t=!1),n.createElement("div",{className:a("bold",t&&"header-row")},e)},q=function(e){var t=String(e);return Object.keys(o.TRANSLATION_KEYS).includes(t)?l(t):t};return r.useEffect((function(){T(function(e,t){if(!t)return[];var r=[];return o.convertEventStatisticToTableData(e,t).forEach((function(e){var t=e.name,n=e.quantity,i=e.total,a=e.isBold,c=e.isHeader,s=e.key,l=Object.keys(o.TRANSLATION_KEYS).includes(String(i))?i:f(Number(i),{style:"currency",currency:u.Currency.GBP}),d=q(t),y=q(n);a?r.push({name:b(d,c),quantity:b(y,c),total:b(t===o.TRANSLATION_KEYS.total?"Total: ".concat(l):l,c),key:s}):r.push({name:d,quantity:y,total:l,key:s})})),r}(e,s))}),[e,s]),y};
@@ -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: (date: string, 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;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
+ {"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;AAIlG,eAAO,MAAM,gBAAgB;;;;CAI5B,CAAC;AAEF,eAAO,MAAM,gCAAgC,SACrC,MAAM,kBACI,cAAc;UAUtB,MAAM;SACP,MAAM;eACA,OAAO;aACT,OAAO;cACN,MAAM,GAAG,MAAM;WAClB,MAAM,GAAG,MAAM;GA4DzB,CAAC"}
@@ -1 +1 @@
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
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@licklist/core/dist/Config"),o=require("luxon"),a={shortQuantity:"shortQuantity",total:"total",totalPerCategory:"totalPerCategory"};exports.TRANSLATION_KEYS=a,exports.convertEventStatisticToTableData=function(e,r){var n,c,l=0,i=0;if(!r)return[];var u=[],s=o.DateTime.fromISO(e).toUTC().toFormat(t.DATE_TIME_FULL_FORMAT);return null===(c=Object.values(null!==(n=null==r?void 0:r.productCategorySummary[s])&&void 0!==n?n:{}))||void 0===c||c.forEach((function(t){var o=t.totalPerCategory,e=t.productsSummary,r=void 0===e?[]:e,n=t.categoryName,c=t.eventId,s=0;l+=o||0,u.push({name:n,key:"".concat(c,".").concat(n),isBold:!0,isHeader:!0,quantity:a.shortQuantity,total:a.total}),null==r||r.forEach((function(t){var o=t.productsSold,a=t.name,e=t.totalQuantity,r=t.total;s+=o,u.push({name:a,key:"".concat(c,".").concat(n,".").concat(a),quantity:e?"".concat(o," / ").concat(e):String(o),total:String(r)})})),u.push({name:a.totalPerCategory,key:"".concat(c,".").concat(n,".").concat(a.totalPerCategory),quantity:s,total:o,isBold:!0}),i+=s})),u.push({name:a.total,key:"".concat(a.total,".").concat(l),quantity:i,total:l,isBold:!0}),u};
@@ -1 +1 @@
1
- {"version":3,"file":"DateAndRecurrenceInput.d.ts","sourceRoot":"","sources":["../../../src/product-set/control/DateAndRecurrenceInput.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAO1C,OAAO,EAAE,QAAQ,EAAE,MAAM,4DAA4D,CAAC;AACtF,OAAO,EAAE,oBAAoB,EAAE,MAAM,uEAAuE,CAAC;AAuB7G,MAAM,WAAW,4BAA4B;IAC3C,eAAe,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC,EAAE,CAAC;CACnD;AAED,UAAU,2BAA2B;IACnC,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAC;IACvB,4BAA4B,EAAE,OAAO,CAAC;IACtC,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,eAAO,MAAM,sBAAsB,mFAKhC,2BAA2B,gBA4Q7B,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAC5C,WAAW,EACX,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAsBxB,CAAC"}
1
+ {"version":3,"file":"DateAndRecurrenceInput.d.ts","sourceRoot":"","sources":["../../../src/product-set/control/DateAndRecurrenceInput.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAO1C,OAAO,EAAE,QAAQ,EAAE,MAAM,4DAA4D,CAAC;AACtF,OAAO,EAAE,oBAAoB,EAAE,MAAM,uEAAuE,CAAC;AAuB7G,MAAM,WAAW,4BAA4B;IAC3C,eAAe,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC,EAAE,CAAC;CACnD;AAED,UAAU,2BAA2B;IACnC,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAC;IACvB,4BAA4B,EAAE,OAAO,CAAC;IACtC,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,eAAO,MAAM,sBAAsB,mFAKhC,2BAA2B,gBA8Q7B,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAC5C,WAAW,EACX,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAsBxB,CAAC"}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,r=require("tslib"),t=require("react"),n=(e=t)&&"object"==typeof e&&"default"in e?e.default:e,i=require("react-i18next"),a=require("react-bootstrap"),o=require("../../static/Icon.js"),u=require("react-hook-form"),l=require("@react-aria/utils"),s=require("react-use"),d=require("luxon");require("../../static/index.js");var c=require("@dnd-kit/core"),m=require("@dnd-kit/modifiers"),v=require("@dnd-kit/sortable"),f=require("../../modals/confirmation/ConfirmModal.js"),g=require("@licklist/core/dist/Config/Date"),p=require("../../recurring-date-picker-input/RecurringDatePickerInput.js"),T=require("./ProductSetRecurrenceControl.js"),b=require("../../zone/form/components/AvailableTimesControl.js"),x={name:"sameWidth",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:function(e){var r=e.state,t={width:"".concat(r.rects.reference.width+4,"px"),marginLeft:"-2px",maxWidth:"unset"};Object.assign(r.styles.popper,t)},effect:function(e){var r=e.state,t=r.elements.reference.getBoundingClientRect().width,n={width:"".concat(t,"px"),maxWidth:"unset"};Object.assign(r.elements.popper.style,n)}};exports.DateAndRecurrenceInput=function(e){var E,_,R,h,q,D=e.isEventEditProductSet,S=e.providerHasBookingManagement,C=e.workHours,y=e.isLoading,k=u.useFormContext(),I=k.control,M=k.register,w=k.formState.errors,A=k.getValues,O=k.setValue,F=k.clearErrors,N=r.__read(t.useState([]),2),j=N[0],P=N[1],V=t.useRef(),L=u.useFieldArray({name:"menuRecurrences",control:I,keyName:"_id"}),W=L.fields,B=L.append,H=L.update,z=L.move,G=r.__read(t.useState(!1),2),K=G[0],J=G[1],Q=r.__read(t.useState({index:null,values:null}),2),U=Q[0],X=Q[1],Y=function(){return X({index:null,values:null})},Z=t.useRef();s.useClickAway(Z,(function(e){var r,t,n;f.CONFIRM_MODAL_ACTIONS.includes(null===(n=null===(t=null===(r=e.target)||void 0===r?void 0:r.attributes)||void 0===t?void 0:t.getNamedItem("data-id"))||void 0===n?void 0:n.value)||(J(!1),Y())}));var $=l.useId(),ee=i.useTranslation("Design").t,re=function(){Y(),J((function(e){return!e}))};return t.useEffect((function(){W.length&&F("menuRecurrences")}),[W,F]),n.createElement(a.Form.Group,null,n.createElement(a.Form.Label,null,ee(D?"whenOverridesAvailable":"productSetAvailable")),n.createElement(a.OverlayTrigger,{show:K,overlay:n.createElement(a.Popover,{id:$,className:"rounded"},n.createElement(a.Popover.Content,{className:"shadow-lg rounded",ref:Z},n.createElement(p.RecurringDatePickerInput,{defaultValues:U.values,onChange:function(e){return r.__awaiter(void 0,void 0,void 0,(function(){var t,n,i,a,o,u,l,s,c;return r.__generator(this,(function(m){switch(m.label){case 0:return[4,null===(u=V.current)||void 0===u?void 0:u.trigger()];case 1:return t=m.sent(),(null==e?void 0:e.startTime)&&(null==e?void 0:e.endTime)&&t&&(n=d.DateTime.fromISO(e.startTime),i=d.DateTime.fromISO(e.endTime),a=V.current.getValues().availableTimes,!a.every((function(e){var r=d.DateTime.fromFormat(e,g.TIME_FORMAT);return r.diff(n,"minutes").minutes>=0&&r.diff(i,"minutes").minutes<=0})))?(V.current.setError("availableTimes",{message:ee("Validation:fieldTimeBetween",{attribute:ee("Design:startTimesSmall"),min:n.toFormat(g.TIME_FORMAT),max:i.toFormat(g.TIME_FORMAT)})}),[2]):(o=r.__assign({rrule:e.rrule,startDate:e.startDate,endDate:e.endDate,startTime:e.startTime,endTime:e.endTime},null===(l=null==V?void 0:V.current)||void 0===l?void 0:l.getValues()),(null===(s=U.values)||void 0===s?void 0:s.id)&&(o.id=null===(c=U.values)||void 0===c?void 0:c.id),null!==U.index?H(U.index,o):B(o),J((function(){return!1})),Y(),[2])}}))}))},onDelete:function(){var e=U.index;J(!1),Y(),setTimeout((function(){var r=A().menuRecurrences;O("menuRecurrences",(void 0===r?[]:r).filter((function(r,t){return t!==e})))}),100)}},S&&n.createElement(b.AvailableTimesControl,{workHours:C,isLoading:y,defaultValues:j,ref:V,errorMessage:null===(R=null===(_=null===(E=null==w?void 0:w.menuRecurrences)||void 0===E?void 0:E["".concat(null==U?void 0:U.index)])||void 0===_?void 0:_.availableTimes)||void 0===R?void 0:R.message,clearErrorMessage:function(){return F("menuRecurrences.".concat(null==U?void 0:U.index,".availableTimes"))}})))),trigger:"click",placement:"bottom",popperConfig:{modifiers:[x]}},n.createElement("div",{className:"product-set-recurrences"},n.createElement(c.DndContext,{onDragEnd:function(e){var r=e.over,t=e.active;if(r.id!==t.id){var n=W.findIndex((function(e){return String(e._id)===t.id})),i=W.findIndex((function(e){return String(e._id)===r.id}));z(n,i)}},modifiers:[m.restrictToVerticalAxis]},n.createElement(v.SortableContext,{items:null!==(h=null==W?void 0:W.map((function(e){return String(e._id)})))&&void 0!==h?h:[],strategy:v.verticalListSortingStrategy},W.map((function(e,r){var t,i,a;return n.createElement(T.ProductSetRecurrenceControl,{key:e._id,menuRecurrence:e,onEdit:function(){return function(e,r){Y(),setTimeout((function(){X({index:r,values:e}),P(e.availableTimes||[]),J((function(){return!0}))}),100)}(e,r)},errorMessage:null===(a=null===(i=null===(t=null==w?void 0:w.menuRecurrences)||void 0===t?void 0:t["".concat(r)])||void 0===i?void 0:i.availableTimes)||void 0===a?void 0:a.message})})))),(!D||(null==W?void 0:W.length)<1)&&n.createElement("div",{className:"product-set-recurrence-icon-wrapper",role:"button",tabIndex:0,onClick:re,onKeyDown:re},n.createElement(o.default,{type:"plus-circle",height:"1rem",className:"product-set-recurrence-icon-add mr-2"}),ee("addDates")),n.createElement(a.Form.Control,r.__assign({type:"hidden"},M("menuRecurrences",{required:{value:!0,message:ee("Validation:fieldMinNumber",{attribute:ee("dates"),min:1})}}))),n.createElement("div",{className:"manual-form-error"},null===(q=w.menuRecurrences)||void 0===q?void 0:q.message))))},exports.sameWidthPopperModifier=x;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,r=require("tslib"),t=require("react"),n=(e=t)&&"object"==typeof e&&"default"in e?e.default:e,i=require("react-i18next"),a=require("react-bootstrap"),o=require("../../static/Icon.js"),u=require("react-hook-form"),l=require("@react-aria/utils"),s=require("react-use"),d=require("luxon");require("../../static/index.js");var c=require("@dnd-kit/core"),m=require("@dnd-kit/modifiers"),v=require("@dnd-kit/sortable"),f=require("../../modals/confirmation/ConfirmModal.js"),g=require("@licklist/core/dist/Config/Date"),p=require("../../recurring-date-picker-input/RecurringDatePickerInput.js"),T=require("./ProductSetRecurrenceControl.js"),b=require("../../zone/form/components/AvailableTimesControl.js"),x={name:"sameWidth",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:function(e){var r=e.state,t={width:"".concat(r.rects.reference.width+4,"px"),marginLeft:"-2px",maxWidth:"unset"};Object.assign(r.styles.popper,t)},effect:function(e){var r=e.state,t=r.elements.reference.getBoundingClientRect().width,n={width:"".concat(t,"px"),maxWidth:"unset"};Object.assign(r.elements.popper.style,n)}};exports.DateAndRecurrenceInput=function(e){var E,_,R,h,q,D=e.isEventEditProductSet,S=e.providerHasBookingManagement,C=e.workHours,y=e.isLoading,k=u.useFormContext(),I=k.control,M=k.register,w=k.formState.errors,A=k.getValues,O=k.setValue,F=k.clearErrors,N=r.__read(t.useState([]),2),j=N[0],P=N[1],V=t.useRef(),L=u.useFieldArray({name:"menuRecurrences",control:I,keyName:"_id"}),W=L.fields,B=L.append,H=L.update,z=L.move,G=r.__read(t.useState(!1),2),K=G[0],J=G[1],Q=r.__read(t.useState({index:null,values:null}),2),U=Q[0],X=Q[1],Y=function(){return X({index:null,values:null})},Z=t.useRef();s.useClickAway(Z,(function(e){var r,t,n;f.CONFIRM_MODAL_ACTIONS.includes(null===(n=null===(t=null===(r=e.target)||void 0===r?void 0:r.attributes)||void 0===t?void 0:t.getNamedItem("data-id"))||void 0===n?void 0:n.value)||(J(!1),Y())}));var $=l.useId(),ee=i.useTranslation("Design").t,re=function(){Y(),J((function(e){return!e}))};return t.useEffect((function(){W.length&&F("menuRecurrences")}),[W,F]),n.createElement(a.Form.Group,null,n.createElement(a.Form.Label,null,ee(D?"whenOverridesAvailable":"productSetAvailable")),n.createElement(a.OverlayTrigger,{show:K,overlay:n.createElement(a.Popover,{id:$,className:"rounded"},n.createElement(a.Popover.Content,{className:"shadow-lg rounded",ref:Z},n.createElement(p.RecurringDatePickerInput,{defaultValues:U.values,onChange:function(e){return r.__awaiter(void 0,void 0,void 0,(function(){var t,n,i,a,o,u,l,s,c,m,v;return r.__generator(this,(function(r){switch(r.label){case 0:return[4,null===(l=V.current)||void 0===l?void 0:l.trigger()];case 1:return t=r.sent(),(null==e?void 0:e.startTime)&&(null==e?void 0:e.endTime)&&t&&(n=d.DateTime.fromISO(e.startTime),i=d.DateTime.fromISO(e.endTime),a=V.current.getValues().availableTimes,!a.every((function(e){var r=d.DateTime.fromFormat(e,g.TIME_FORMAT);return r.diff(n,"minutes").minutes>=0&&r.diff(i,"minutes").minutes<=0})))?(V.current.setError("availableTimes",{message:ee("Validation:fieldTimeBetween",{attribute:ee("Design:startTimesSmall"),min:n.toFormat(g.TIME_FORMAT),max:i.toFormat(g.TIME_FORMAT)})}),[2]):(o=(null===(c=null===(s=null==V?void 0:V.current)||void 0===s?void 0:s.getValues())||void 0===c?void 0:c.availableTimes)||null,u={rrule:e.rrule,startDate:e.startDate,endDate:e.endDate,startTime:e.startTime,endTime:e.endTime,availableTimes:o},(null===(m=U.values)||void 0===m?void 0:m.id)&&(u.id=null===(v=U.values)||void 0===v?void 0:v.id),null!==U.index?H(U.index,u):B(u),J((function(){return!1})),Y(),[2])}}))}))},onDelete:function(){var e=U.index;J(!1),Y(),setTimeout((function(){var r=A().menuRecurrences;O("menuRecurrences",(void 0===r?[]:r).filter((function(r,t){return t!==e})))}),100)}},S&&n.createElement(b.AvailableTimesControl,{workHours:C,isLoading:y,defaultValues:j,ref:V,errorMessage:null===(R=null===(_=null===(E=null==w?void 0:w.menuRecurrences)||void 0===E?void 0:E["".concat(null==U?void 0:U.index)])||void 0===_?void 0:_.availableTimes)||void 0===R?void 0:R.message,clearErrorMessage:function(){return F("menuRecurrences.".concat(null==U?void 0:U.index,".availableTimes"))}})))),trigger:"click",placement:"bottom",popperConfig:{modifiers:[x]}},n.createElement("div",{className:"product-set-recurrences"},n.createElement(c.DndContext,{onDragEnd:function(e){var r=e.over,t=e.active;if(r.id!==t.id){var n=W.findIndex((function(e){return String(e._id)===t.id})),i=W.findIndex((function(e){return String(e._id)===r.id}));z(n,i)}},modifiers:[m.restrictToVerticalAxis]},n.createElement(v.SortableContext,{items:null!==(h=null==W?void 0:W.map((function(e){return String(e._id)})))&&void 0!==h?h:[],strategy:v.verticalListSortingStrategy},W.map((function(e,r){var t,i,a;return n.createElement(T.ProductSetRecurrenceControl,{key:e._id,menuRecurrence:e,onEdit:function(){return function(e,r){Y(),setTimeout((function(){X({index:r,values:e}),P(e.availableTimes||[]),J((function(){return!0}))}),100)}(e,r)},errorMessage:null===(a=null===(i=null===(t=null==w?void 0:w.menuRecurrences)||void 0===t?void 0:t["".concat(r)])||void 0===i?void 0:i.availableTimes)||void 0===a?void 0:a.message})})))),(!D||(null==W?void 0:W.length)<1)&&n.createElement("div",{className:"product-set-recurrence-icon-wrapper",role:"button",tabIndex:0,onClick:re,onKeyDown:re},n.createElement(o.default,{type:"plus-circle",height:"1rem",className:"product-set-recurrence-icon-add mr-2"}),ee("addDates")),n.createElement(a.Form.Control,r.__assign({type:"hidden"},M("menuRecurrences",{required:{value:!0,message:ee("Validation:fieldMinNumber",{attribute:ee("dates"),min:1})}}))),n.createElement("div",{className:"manual-form-error"},null===(q=w.menuRecurrences)||void 0===q?void 0:q.message))))},exports.sameWidthPopperModifier=x;
@@ -7,9 +7,14 @@
7
7
  overflow: auto;
8
8
  }
9
9
 
10
+
10
11
  .modal-form-content {
11
12
  max-height: 21rem;
12
13
  overflow-x: hidden;
14
+
15
+ .error-content {
16
+ min-width: 25rem;
17
+ }
13
18
  }
14
19
 
15
20
  .reccurrence-interval-container {
@@ -71,6 +76,7 @@
71
76
  display: flex;
72
77
  flex-direction: column;
73
78
  gap: 1rem;
79
+
74
80
  }
75
81
 
76
82
  .custom-checkbox {
@@ -137,6 +143,10 @@
137
143
  }
138
144
  }
139
145
 
146
+ .footer-with-short-notes {
147
+ min-width: 18rem;
148
+ }
149
+
140
150
  footer {
141
151
  display: flex;
142
152
  gap: 1.25rem;
@@ -153,3 +163,4 @@
153
163
  }
154
164
  }
155
165
  }
166
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@licklist/design",
3
- "version": "0.44.543",
3
+ "version": "0.44.545",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+ssh://git@bitbucket.org/artelogicsoft/licklist_design.git"
@@ -27,34 +27,88 @@ export const formatContentWithoutTags = (
27
27
 
28
28
  export const EVENT_DESCRIPTION_SIZE = 300;
29
29
 
30
- export const getStatisticInfo = (
31
- eventStatistic: EventStatistic | null,
32
- date: string
33
- ) => {
34
- let totalViews = 0;
30
+ /**
31
+ * Calculate the total number of views from the given dates and event statistic.
32
+ *
33
+ * @param {string[]} dates - An array of dates.
34
+ * @param {EventStatistic} eventStatistic - The event statistic object.
35
+ * @returns {number} - The total number of views.
36
+ */
37
+ export const calculateTotalViews = (
38
+ dates: string[],
39
+ eventStatistic: EventStatistic
40
+ ): number => {
41
+ return dates.reduce(
42
+ (rootAcc, date) =>
43
+ rootAcc +
44
+ Object.values(eventStatistic.views[date] ?? {}).reduce(
45
+ (acc, view) => acc + (view.pageViews || 0),
46
+ 0
47
+ ),
48
+ 0
49
+ );
50
+ };
51
+
52
+ /**
53
+ * Calculates the total number of products sold and the total amount sold
54
+ * based on the provided dates and event statistics.
55
+ *
56
+ * @param {string[]} dates - An array of dates.
57
+ * @param {EventStatistic} eventStatistic - Object containing event statistics.
58
+ * @returns {number[]} An array representing the total number of products sold and total amount sold.
59
+ */
60
+ export const calculateTotalSoldAndAmount = (
61
+ dates: string[],
62
+ eventStatistic: EventStatistic
63
+ ): [number, number] => {
35
64
  let totalSold = 0;
36
65
  let totalAmount = 0;
66
+ dates.forEach((date) =>
67
+ Object.values(eventStatistic.productCategorySummary[date] ?? {}).forEach(
68
+ ({ totalPerCategory, productsSummary }) => {
69
+ totalAmount += totalPerCategory || 0;
70
+ totalSold +=
71
+ productsSummary?.reduce((acc, curr) => acc + curr.productsSold, 0) ??
72
+ 0;
73
+ }
74
+ )
75
+ );
37
76
 
38
- if (!eventStatistic) return { totalViews: 0, totalSold: 0, totalAmount: 0 };
77
+ return [totalSold, totalAmount];
78
+ };
79
+
80
+ /**
81
+ * Get statistic information for a given event and date.
82
+ * @param {EventStatistic | null} eventStatistic - The event statistic object.
83
+ * @param {string} date - The date in ISO format.
84
+ * @returns {{
85
+ * totalViews: number;
86
+ * totalSold: number;
87
+ * totalAmount: number;
88
+ * }} The statistic information object.
89
+ */
90
+ export const getStatisticInfo = (
91
+ eventStatistic: EventStatistic | null,
92
+ date: string
93
+ ): {
94
+ totalViews: number;
95
+ totalSold: number;
96
+ totalAmount: number;
97
+ } => {
98
+ const defaultValues = { totalViews: 0, totalSold: 0, totalAmount: 0 };
99
+ if (!eventStatistic) return defaultValues;
39
100
 
40
101
  const viewsFormattedDate = DateTime.fromISO(date)
41
102
  .toUTC()
42
103
  .toFormat(DATE_FORMAT);
43
-
44
- totalViews = eventStatistic.views[viewsFormattedDate]?.pageViews || 0;
45
-
46
104
  const summaryFormattedDate = DateTime.fromISO(date)
47
105
  .toUTC()
48
106
  .toFormat(DATE_TIME_FULL_FORMAT);
49
107
 
50
- eventStatistic?.productCategorySummary?.[summaryFormattedDate]?.forEach(
51
- ({ totalPerCategory, productsSummary = [] }) => {
52
- totalAmount += totalPerCategory || 0;
53
-
54
- productsSummary?.forEach(({ productsSold }) => {
55
- totalSold += productsSold;
56
- });
57
- }
108
+ const totalViews = calculateTotalViews([viewsFormattedDate], eventStatistic);
109
+ const [totalSold, totalAmount] = calculateTotalSoldAndAmount(
110
+ [summaryFormattedDate],
111
+ eventStatistic
58
112
  );
59
113
 
60
114
  return { totalViews, totalSold, totalAmount };
@@ -2,6 +2,7 @@ import React from "react";
2
2
  import { Modal, Button } from "react-bootstrap";
3
3
  import { useTranslation } from "react-i18next";
4
4
  import { EventStatistic } from "@licklist/core/dist/DataMapper/Provider/EventStatisticDataMapper";
5
+ import { Event } from "@licklist/core/dist/DataMapper/Provider/EventDataMapper";
5
6
  import Icon from "../../static/Icon";
6
7
  import { StaticTable } from "../../table";
7
8
  import { useTableData } from "./hooks/useTableData";
@@ -9,6 +10,7 @@ import { useTableData } from "./hooks/useTableData";
9
10
  export type EventStatisticModalProps = {
10
11
  isOpen: boolean;
11
12
  setIsOpen: (value: boolean) => void;
13
+ date?: Event["startAt"] | null;
12
14
  eventStatistic?: EventStatistic | null;
13
15
  title?: string;
14
16
  };
@@ -16,11 +18,13 @@ export type EventStatisticModalProps = {
16
18
  export const EventStatisticModal = ({
17
19
  isOpen,
18
20
  setIsOpen,
21
+ date,
19
22
  eventStatistic,
20
23
  title,
21
24
  }: EventStatisticModalProps) => {
22
25
  const { t } = useTranslation("Design");
23
- const data = useTableData(eventStatistic);
26
+
27
+ const data = useTableData(date, eventStatistic);
24
28
  const handleClose = () => {
25
29
  setIsOpen(false);
26
30
  };
@@ -4,10 +4,14 @@ import { useIntl } from "react-intl";
4
4
  import { useTranslation } from "react-i18next";
5
5
  import * as Config from "@licklist/core/dist/Config";
6
6
  import { EventStatistic } from "@licklist/core/dist/DataMapper/Provider/EventStatisticDataMapper";
7
+ import { Event } from "@licklist/core/dist/DataMapper/Provider/EventDataMapper";
7
8
  import { convertEventStatisticToTableData, TRANSLATION_KEYS } from "../utils";
8
9
  import { StaticTableData } from "../../../table";
9
10
 
10
- export const useTableData = (eventStatistic: EventStatistic | null) => {
11
+ export const useTableData = (
12
+ date: Event["startAt"] | null,
13
+ eventStatistic: EventStatistic | null
14
+ ) => {
11
15
  const { t } = useTranslation("Design");
12
16
  const { formatNumber } = useIntl();
13
17
  const [tableRows, setTableRows] = useState<StaticTableData[]>([]);
@@ -28,14 +32,17 @@ export const useTableData = (eventStatistic: EventStatistic | null) => {
28
32
  return t(key);
29
33
  };
30
34
 
31
- const transformStatisticToTableRows = (statistic: EventStatistic | null) => {
35
+ const transformStatisticToTableRows = (
36
+ date: Event["startAt"],
37
+ statistic: EventStatistic | null
38
+ ) => {
32
39
  if (!statistic) {
33
40
  return [];
34
41
  }
35
42
 
36
43
  const tableDataRows: StaticTableData[] = [];
37
44
 
38
- convertEventStatisticToTableData(statistic).forEach(
45
+ convertEventStatisticToTableData(date, statistic).forEach(
39
46
  ({ name, quantity, total, isBold, isHeader, key }) => {
40
47
  const formattedTotal = !Object.keys(TRANSLATION_KEYS).includes(
41
48
  String(total)
@@ -77,9 +84,9 @@ export const useTableData = (eventStatistic: EventStatistic | null) => {
77
84
  };
78
85
 
79
86
  useEffect(() => {
80
- setTableRows(transformStatisticToTableRows(eventStatistic));
87
+ setTableRows(transformStatisticToTableRows(date, eventStatistic));
81
88
  // eslint-disable-next-line react-hooks/exhaustive-deps
82
- }, [eventStatistic]);
89
+ }, [date, eventStatistic]);
83
90
 
84
91
  return tableRows;
85
92
  };
@@ -1,4 +1,6 @@
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";
2
4
 
3
5
  export const TRANSLATION_KEYS = {
4
6
  shortQuantity: "shortQuantity",
@@ -7,6 +9,7 @@ export const TRANSLATION_KEYS = {
7
9
  };
8
10
 
9
11
  export const convertEventStatisticToTableData = (
12
+ date: string,
10
13
  eventStatistic: EventStatistic
11
14
  ) => {
12
15
  let totalAmount = 0;
@@ -25,49 +28,51 @@ export const convertEventStatisticToTableData = (
25
28
  total: string | number;
26
29
  }[] = [];
27
30
 
28
- Object.values(eventStatistic?.productCategorySummary)?.forEach(
29
- (categories) => {
30
- categories?.forEach(
31
- ({ totalPerCategory, productsSummary = [], categoryName, eventId }) => {
32
- let quantity = 0;
31
+ const summaryFormattedDate = DateTime.fromISO(date)
32
+ .toUTC()
33
+ .toFormat(DATE_TIME_FULL_FORMAT);
33
34
 
34
- totalAmount += totalPerCategory || 0;
35
+ Object.values(
36
+ eventStatistic?.productCategorySummary[summaryFormattedDate] ?? {}
37
+ )?.forEach(
38
+ ({ totalPerCategory, productsSummary = [], categoryName, eventId }) => {
39
+ let quantity = 0;
35
40
 
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
- });
41
+ totalAmount += totalPerCategory || 0;
44
42
 
45
- productsSummary?.forEach(
46
- ({ productsSold, name, totalQuantity, total }) => {
47
- quantity += productsSold;
43
+ tableDataArray.push({
44
+ name: categoryName,
45
+ key: `${eventId}.${categoryName}`,
46
+ isBold: true,
47
+ isHeader: true,
48
+ quantity: TRANSLATION_KEYS.shortQuantity,
49
+ total: TRANSLATION_KEYS.total,
50
+ });
48
51
 
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
- );
52
+ productsSummary?.forEach(
53
+ ({ productsSold, name, totalQuantity, total }) => {
54
+ quantity += productsSold;
59
55
 
60
56
  tableDataArray.push({
61
- name: TRANSLATION_KEYS.totalPerCategory,
62
- key: `${eventId}.${categoryName}.${TRANSLATION_KEYS.totalPerCategory}`,
63
- quantity,
64
- total: totalPerCategory,
65
- isBold: true,
57
+ name,
58
+ key: `${eventId}.${categoryName}.${name}`,
59
+ quantity: totalQuantity
60
+ ? `${productsSold} / ${totalQuantity}`
61
+ : String(productsSold),
62
+ total: String(total),
66
63
  });
67
-
68
- totalQuantity += quantity;
69
64
  }
70
65
  );
66
+
67
+ tableDataArray.push({
68
+ name: TRANSLATION_KEYS.totalPerCategory,
69
+ key: `${eventId}.${categoryName}.${TRANSLATION_KEYS.totalPerCategory}`,
70
+ quantity,
71
+ total: totalPerCategory,
72
+ isBold: true,
73
+ });
74
+
75
+ totalQuantity += quantity;
71
76
  }
72
77
  );
73
78
 
@@ -126,13 +126,15 @@ export const DateAndRecurrenceInput = ({
126
126
  }
127
127
  }
128
128
 
129
+ const availableTime = availableTimesFormRef?.current?.getValues()?.availableTimes || null;
130
+
129
131
  const values = {
130
132
  rrule: next.rrule,
131
133
  startDate: next.startDate,
132
134
  endDate: next.endDate,
133
135
  startTime: next.startTime,
134
136
  endTime: next.endTime,
135
- ...availableTimesFormRef?.current?.getValues(),
137
+ availableTimes: availableTime,
136
138
  } as Partial<ProductSetRecurrence>;
137
139
 
138
140
  if (editState.values?.id) {
@@ -7,9 +7,14 @@
7
7
  overflow: auto;
8
8
  }
9
9
 
10
+
10
11
  .modal-form-content {
11
12
  max-height: 21rem;
12
13
  overflow-x: hidden;
14
+
15
+ .error-content {
16
+ min-width: 25rem;
17
+ }
13
18
  }
14
19
 
15
20
  .reccurrence-interval-container {
@@ -71,6 +76,7 @@
71
76
  display: flex;
72
77
  flex-direction: column;
73
78
  gap: 1rem;
79
+
74
80
  }
75
81
 
76
82
  .custom-checkbox {
@@ -137,6 +143,10 @@
137
143
  }
138
144
  }
139
145
 
146
+ .footer-with-short-notes {
147
+ min-width: 18rem;
148
+ }
149
+
140
150
  footer {
141
151
  display: flex;
142
152
  gap: 1.25rem;
@@ -153,3 +163,4 @@
153
163
  }
154
164
  }
155
165
  }
166
+