@licklist/design 0.44.486-dev.70 → 0.44.486-dev.72

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.
@@ -1,9 +1,10 @@
1
1
  /// <reference types="react" />
2
+ import { ZoneResourcesAvailability } from "@licklist/core/dist/DataMapper/Order/ZoneResourcesAvailabilityDataMapper";
2
3
  type AvailabilityIndicatorProps = {
3
- booked: number;
4
- total: number;
5
- notAvailable?: boolean;
4
+ resources: ZoneResourcesAvailability;
5
+ isUnavailable?: boolean;
6
+ isSoldOut?: boolean;
6
7
  };
7
- export declare const AvailabilityIndicator: ({ booked, total, notAvailable, }: AvailabilityIndicatorProps) => JSX.Element;
8
+ export declare const AvailabilityIndicator: ({ resources, isUnavailable, isSoldOut, }: AvailabilityIndicatorProps) => JSX.Element;
8
9
  export {};
9
10
  //# sourceMappingURL=AvailabilityIndicator.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AvailabilityIndicator.d.ts","sourceRoot":"","sources":["../../src/availability-indicator/AvailabilityIndicator.tsx"],"names":[],"mappings":";AA6BA,KAAK,0BAA0B,GAAG;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF,eAAO,MAAM,qBAAqB,qCAI/B,0BAA0B,gBAmB5B,CAAC"}
1
+ {"version":3,"file":"AvailabilityIndicator.d.ts","sourceRoot":"","sources":["../../src/availability-indicator/AvailabilityIndicator.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,yBAAyB,EAAE,MAAM,0EAA0E,CAAC;AAiCrH,KAAK,0BAA0B,GAAG;IAChC,SAAS,EAAE,yBAAyB,CAAC;IACrC,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,eAAO,MAAM,qBAAqB,6CAI/B,0BAA0B,gBAc5B,CAAC"}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,a=require("react"),t=(e=a)&&"object"==typeof e&&"default"in e?e.default:e,l=require("react-i18next"),i=require("../assets/iframe/available.svg.js"),o=require("../assets/iframe/limited.svg.js"),n=require("../assets/iframe/soldOut.svg.js");exports.AvailabilityIndicator=function(e){var a=e.booked,s=e.total,r=e.notAvailable,c=l.useTranslation("Design").t,m=function(e,a){return e===a?{label:"soldOut",icon:t.createElement(n.ReactComponent,{className:"logo"})}:e/a<=.2?{label:"lotsOfSpace",icon:t.createElement(i.ReactComponent,{className:"logo"})}:e/a>=.8?{label:"limited",icon:t.createElement(o.ReactComponent,{className:"logo"})}:{label:"available",icon:t.createElement(i.ReactComponent,{className:"logo"})}}(a,s),u=m.icon,v=m.label;return r?t.createElement("div",{className:"availability-indicator"},t.createElement(n.ReactComponent,{className:"logo"}),t.createElement("div",null,c("notAvailable"))):t.createElement("div",{className:"availability-indicator"},u,t.createElement("div",null,c(v)))};
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"),i=require("../assets/iframe/available.svg.js"),n=require("../assets/iframe/limited.svg.js"),r=require("../assets/iframe/soldOut.svg.js"),o=function(e){var t=e.icon,l=e.label;return a.createElement("div",{className:"availability-indicator"},t,a.createElement("div",null,l))};exports.AvailabilityIndicator=function(e){var t=e.resources,s=e.isUnavailable,c=e.isSoldOut,u=l.useTranslation("Design").t;if(s)return a.createElement(o,{icon:r.ReactComponent,label:u("notAvailable")});if(c)return a.createElement(o,{icon:r.ReactComponent,label:u("soldOut")});var b=function(e){var t=e.bookedResources,a=e.totalResources;return t===a?{label:"soldOut",icon:r.ReactComponent}:t/a<=.2?{label:"lotsOfSpace",icon:i.ReactComponent}:t/a>=.8?{label:"limited",icon:n.ReactComponent}:{label:"available",icon:i.ReactComponent}}(t),m=b.icon,v=b.label;return a.createElement(o,{icon:m,label:u(v)})};
@@ -1,5 +1,6 @@
1
1
  import { Dispatch, ReactElement, SetStateAction } from "react";
2
2
  import { DateTime } from "luxon";
3
+ import { ZoneResourcesAvailability } from "@licklist/core/dist/DataMapper/Order/ZoneResourcesAvailabilityDataMapper";
3
4
  export declare const defaultStartDay: DateTime;
4
5
  export type CalendarProps = {
5
6
  currentDate: DateTime;
@@ -11,10 +12,7 @@ export type CalendarProps = {
11
12
  fromPrice?: string | ReactElement | null;
12
13
  isLoading?: boolean;
13
14
  initialDate?: DateTime;
14
- getAvailability?: (date: DateTime) => {
15
- booked: number;
16
- total: number;
17
- } | undefined;
15
+ getAvailability?: (date: DateTime) => ZoneResourcesAvailability | null;
18
16
  includeAvailability?: boolean;
19
17
  };
20
18
  export declare const Calendar: ({ disabledDates, initialDate, ...props }: CalendarProps) => JSX.Element;
@@ -1 +1 @@
1
- {"version":3,"file":"Calendar.d.ts","sourceRoot":"","sources":["../../src/calendar/Calendar.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,QAAQ,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AACtE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAIjC,eAAO,MAAM,eAAe,UAK1B,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG;IAC1B,WAAW,EAAE,QAAQ,CAAC;IACtB,cAAc,EAAE,QAAQ,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC;IACnD,aAAa,EAAE,QAAQ,EAAE,CAAC;IAC1B,aAAa,CAAC,EAAE,QAAQ,EAAE,CAAC;IAC3B,YAAY,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC9B,eAAe,EAAE,QAAQ,CAAC,cAAc,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC,CAAC;IAC3D,SAAS,CAAC,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI,CAAC;IACzC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,QAAQ,CAAC;IACvB,eAAe,CAAC,EAAE,CAChB,IAAI,EAAE,QAAQ,KACX;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,CAAC;IACnD,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B,CAAC;AAEF,eAAO,MAAM,QAAQ,6CAIlB,aAAa,gBAaf,CAAC"}
1
+ {"version":3,"file":"Calendar.d.ts","sourceRoot":"","sources":["../../src/calendar/Calendar.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,QAAQ,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AACtE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,yBAAyB,EAAE,MAAM,0EAA0E,CAAC;AAIrH,eAAO,MAAM,eAAe,UAK1B,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG;IAC1B,WAAW,EAAE,QAAQ,CAAC;IACtB,cAAc,EAAE,QAAQ,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC;IACnD,aAAa,EAAE,QAAQ,EAAE,CAAC;IAC1B,aAAa,CAAC,EAAE,QAAQ,EAAE,CAAC;IAC3B,YAAY,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC9B,eAAe,EAAE,QAAQ,CAAC,cAAc,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC,CAAC;IAC3D,SAAS,CAAC,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI,CAAC;IACzC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,QAAQ,CAAC;IACvB,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,yBAAyB,GAAG,IAAI,CAAC;IACvE,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B,CAAC;AAEF,eAAO,MAAM,QAAQ,6CAIlB,aAAa,gBAaf,CAAC"}
@@ -1,18 +1,17 @@
1
1
  import { ReactElement } from "react";
2
2
  import { DateTime } from "luxon";
3
+ import { ZoneResourcesAvailability } from "@licklist/core/dist/DataMapper/Order/ZoneResourcesAvailabilityDataMapper";
3
4
  export type DateTimeButtonProps<T = DateTime | string> = {
4
5
  date: T;
5
6
  isSelected?: boolean;
6
7
  isDisabled?: boolean;
8
+ isSoldOut?: boolean;
7
9
  onSelect: (date: T) => void;
8
10
  isOnlyTimeContainer?: boolean;
9
11
  price?: string | number | ReactElement | null;
10
- resources?: {
11
- booked: number;
12
- total: number;
13
- };
12
+ resources?: ZoneResourcesAvailability | null;
14
13
  calendarView?: boolean;
15
14
  showResources?: boolean;
16
15
  };
17
- export declare const DateTimeButton: <T extends string | DateTime>({ date, isDisabled: _isDisabled, isSelected, onSelect, isOnlyTimeContainer, price, resources, calendarView, showResources, }: DateTimeButtonProps<T>) => JSX.Element;
16
+ export declare const DateTimeButton: <T extends string | DateTime>({ date, isDisabled: _isDisabled, isSelected, isSoldOut, onSelect, isOnlyTimeContainer, price, resources, calendarView, showResources, }: DateTimeButtonProps<T>) => JSX.Element;
18
17
  //# sourceMappingURL=DateTimeButton.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DateTimeButton.d.ts","sourceRoot":"","sources":["../../src/date-time-button/DateTimeButton.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAIjC,MAAM,MAAM,mBAAmB,CAAC,CAAC,GAAG,QAAQ,GAAG,MAAM,IAAI;IACvD,IAAI,EAAE,CAAC,CAAC;IACR,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,CAAC;IAC5B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,YAAY,GAAG,IAAI,CAAC;IAC9C,SAAS,CAAC,EAAE;QACV,MAAM,EAAE,MAAM,CAAC;QACf,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;IACF,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF,eAAO,MAAM,cAAc,oMAgD1B,CAAC"}
1
+ {"version":3,"file":"DateTimeButton.d.ts","sourceRoot":"","sources":["../../src/date-time-button/DateTimeButton.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,yBAAyB,EAAE,MAAM,0EAA0E,CAAC;AAIrH,MAAM,MAAM,mBAAmB,CAAC,CAAC,GAAG,QAAQ,GAAG,MAAM,IAAI;IACvD,IAAI,EAAE,CAAC,CAAC;IACR,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,CAAC;IAC5B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,YAAY,GAAG,IAAI,CAAC;IAC9C,SAAS,CAAC,EAAE,yBAAyB,GAAG,IAAI,CAAC;IAC7C,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF,eAAO,MAAM,cAAc,+MAsD1B,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"),i=e(require("react")),a=e(require("clsx")),r=require("../availability-indicator/AvailabilityIndicator.js"),n=require("./DateContent.js");exports.DateTimeButton=function(e){var l=e.date,o=e.isDisabled,s=e.isSelected,c=e.onSelect,d=e.isOnlyTimeContainer,u=e.price,b=e.resources,m=e.calendarView,y=e.showResources,v="string"==typeof l,f=o||b&&b.booked===b.total;return i.createElement("button",{type:"button",onClick:function(){return c(l)},disabled:f,className:a("date-time-button",f&&"disabled",s&&"selected",v&&"time-button",d&&"only-time-container",!v&&"today",m&&"calendar-view")},v?l:i.createElement(n.DateContent,{date:l,isDisabled:f,isSelected:s}),u&&!f&&i.createElement("div",{className:"price"},u),y&&b&&i.createElement(r.AvailabilityIndicator,t.__assign({},b,{notAvailable:o})))};
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=e(require("react")),i=e(require("clsx")),a=require("../availability-indicator/AvailabilityIndicator.js"),r=require("./DateContent.js");exports.DateTimeButton=function(e){var n=e.date,o=e.isDisabled,s=e.isSelected,l=e.isSoldOut,c=e.onSelect,u=e.isOnlyTimeContainer,d=e.price,b=e.resources,m=e.calendarView,y=e.showResources,v="string"==typeof n,f=o||b&&b.bookedResources===b.totalResources;return t.createElement("button",{type:"button",onClick:function(){return c(n)},disabled:f,className:i("date-time-button",f&&"disabled",s&&"selected",v&&"time-button",u&&"only-time-container",!v&&"today",m&&"calendar-view")},v?n:t.createElement(r.DateContent,{date:n,isDisabled:f,isSelected:s}),d&&!f&&t.createElement("div",{className:"price"},d),y&&b&&t.createElement(a.AvailabilityIndicator,{resources:b,isUnavailable:o,isSoldOut:l}))};
@@ -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"),a=require("react"),n=e(a),r=require("@licklist/core/dist/Config"),l=require("react-i18next"),c=require("react-bootstrap"),i=require("../../static/Icon.js"),s=e(require("clsx")),m=require("react-intl"),o=require("../../tiptap-editor/TipTapEditor.js"),u=require("./utils.js"),d=require("../../assets/dashboard/chartBar.svg.js");exports.EventCard=function(e){var E=e.name,v=e.description,p=e.date,y=e.imageUrl,f=e.sales,b=e.onPreview,N=e.onEdit,C=e.onCopy,k=e.onRemove,g=e.hasPermission,x=void 0===g||g,q=e.onStatistic,w=e.eventStatistic,h=e.titleId,T=e.descriptionId,j=l.useTranslation("Design").t,I=m.useIntl(),P=I.formatNumber,_=I.formatDate,B=u.getStatisticInfo(w),S=B.totalViews,D=t.__rest(B,["totalViews"]),M=a.useMemo((function(){return u.formatContentWithoutTags(v,u.EVENT_DESCRIPTION_SIZE)}),[v]);return n.createElement(c.Card,{className:"d-flex flex-column event-card h-100"},n.createElement("div",{className:s("event-card-image-container",!y&&"no-image")},y&&n.createElement(c.Card.Img,{variant:"top",src:y}),n.createElement(c.Badge,{className:"event-card-date",as:"time",dateTime:p,variant:"primary"},_(new Date(p),{weekday:"short",day:"numeric",month:"short",year:"numeric",hour:"numeric",minute:"numeric"}))),n.createElement(c.Card.Body,null,n.createElement(c.Card.Title,{id:h},E),n.createElement("div",{className:"flex-grow-1"},n.createElement(o.TipTapEditor,{viewMode:!0,disabled:!0,className:s("event-description",!y&&"no-image"),content:M,id:T}),n.createElement("div",{className:"mt-2 ml-2"},Object.keys(D).map((function(e){return n.createElement("div",{className:"event-card-sale",key:e},n.createElement("span",{className:"event-card-sale-name"},j(e),":"," ","totalAmount"===e?P(D[e],{style:"currency",currency:r.Currency.GBP}):D[e]))}))),f&&f.map((function(e){return n.createElement("div",{className:"event-card-sale",key:e.id},n.createElement("div",{className:"event-card-sale-text"},n.createElement("span",{className:"event-card-sale-name"},e.name)," ",n.createElement("span",{className:"event-card-sale-quantity"},[e.current,e.max].map((function(e){return P(e)})).join(" / "))),n.createElement(c.ProgressBar,{now:e.current,max:e.max}))})))),n.createElement(c.Card.Footer,null,n.createElement("div",{className:"d-flex w-100 justify-content-between"},n.createElement("div",{className:"d-flex"},n.createElement("button",{type:"button",className:"event-card-link-button ml-3 mr-4",onClick:q},n.createElement(d.ReactComponent,null)),n.createElement("div",{className:"event-card-views"},n.createElement(i.default,{type:"eye"}),n.createElement("span",null,P(S)))),n.createElement("div",null,n.createElement("button",{type:"button",className:"event-card-link-button",onClick:b},n.createElement(i.default,{type:"external-link-alt"})),x&&n.createElement(n.Fragment,null,n.createElement("button",{type:"button",className:"event-card-link-button",onClick:N},n.createElement(i.default,{type:"edit"})),n.createElement("button",{type:"button",className:"event-card-link-button",onClick:C},n.createElement(i.default,{type:"copy"})),n.createElement("button",{type:"button",className:"event-card-link-button",onClick:k},n.createElement(i.default,{type:"trash-alt"})))))))};
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"),a=require("react"),n=e(a),r=require("@licklist/core/dist/Config"),l=require("react-i18next"),c=require("react-bootstrap"),i=require("../../static/Icon.js"),s=e(require("clsx")),m=require("react-intl"),o=require("../../tiptap-editor/TipTapEditor.js"),u=require("./utils.js"),d=require("../../assets/dashboard/chartBar.svg.js");exports.EventCard=function(e){var E=e.name,v=e.description,p=e.date,y=e.imageUrl,f=e.sales,b=e.onPreview,N=e.onEdit,C=e.onCopy,k=e.onRemove,g=e.hasPermission,x=void 0===g||g,q=e.onStatistic,w=e.eventStatistic,h=e.titleId,T=e.descriptionId,j=l.useTranslation("Design").t,I=m.useIntl(),P=I.formatNumber,_=I.formatDate,B=u.getStatisticInfo(w,p),S=B.totalViews,D=t.__rest(B,["totalViews"]),M=a.useMemo((function(){return u.formatContentWithoutTags(v,u.EVENT_DESCRIPTION_SIZE)}),[v]);return n.createElement(c.Card,{className:"d-flex flex-column event-card h-100"},n.createElement("div",{className:s("event-card-image-container",!y&&"no-image")},y&&n.createElement(c.Card.Img,{variant:"top",src:y}),n.createElement(c.Badge,{className:"event-card-date",as:"time",dateTime:p,variant:"primary"},_(new Date(p),{weekday:"short",day:"numeric",month:"short",year:"numeric",hour:"numeric",minute:"numeric"}))),n.createElement(c.Card.Body,null,n.createElement(c.Card.Title,{id:h},E),n.createElement("div",{className:"flex-grow-1"},n.createElement(o.TipTapEditor,{viewMode:!0,disabled:!0,className:s("event-description",!y&&"no-image"),content:M,id:T}),n.createElement("div",{className:"mt-2 ml-2"},Object.keys(D).map((function(e){return n.createElement("div",{className:"event-card-sale",key:e},n.createElement("span",{className:"event-card-sale-name"},j(e),":"," ","totalAmount"===e?P(D[e],{style:"currency",currency:r.Currency.GBP}):D[e]))}))),f&&f.map((function(e){return n.createElement("div",{className:"event-card-sale",key:e.id},n.createElement("div",{className:"event-card-sale-text"},n.createElement("span",{className:"event-card-sale-name"},e.name)," ",n.createElement("span",{className:"event-card-sale-quantity"},[e.current,e.max].map((function(e){return P(e)})).join(" / "))),n.createElement(c.ProgressBar,{now:e.current,max:e.max}))})))),n.createElement(c.Card.Footer,null,n.createElement("div",{className:"d-flex w-100 justify-content-between"},n.createElement("div",{className:"d-flex"},n.createElement("button",{type:"button",className:"event-card-link-button ml-3 mr-4",onClick:q},n.createElement(d.ReactComponent,null)),n.createElement("div",{className:"event-card-views"},n.createElement(i.default,{type:"eye"}),n.createElement("span",null,P(S)))),n.createElement("div",null,n.createElement("button",{type:"button",className:"event-card-link-button",onClick:b},n.createElement(i.default,{type:"external-link-alt"})),x&&n.createElement(n.Fragment,null,n.createElement("button",{type:"button",className:"event-card-link-button",onClick:N},n.createElement(i.default,{type:"edit"})),n.createElement("button",{type:"button",className:"event-card-link-button",onClick:C},n.createElement(i.default,{type:"copy"})),n.createElement("button",{type:"button",className:"event-card-link-button",onClick:k},n.createElement(i.default,{type:"trash-alt"})))))))};
@@ -2,7 +2,34 @@ 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
- export declare const getStatisticInfo: (eventStatistic: EventStatistic | null) => {
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
+ */
32
+ export declare const getStatisticInfo: (eventStatistic: EventStatistic | null, date: string) => {
6
33
  totalViews: number;
7
34
  totalSold: number;
8
35
  totalAmount: number;
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/events/event-card/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kEAAkE,CAAC;AAElG,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,mBAAoB,cAAc,GAAG,IAAI;;;;CAwBrE,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;CAuBpB,CAAC"}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=300;exports.EVENT_DESCRIPTION_SIZE=t,exports.formatContent=function(t,e){return t?t.length>e?"".concat(t.slice(0,e),"..."):t:""},exports.formatContentWithoutTags=function(e,r){if(void 0===r&&(r=t),!e)return"";if(e<r)return e;var o=e.replace(/<[^>]*>/g,"").trim().replace(/&nbsp;|[^a-zA-Z0-9\s]/g,"").replace(/\s\s+/g," ").slice(0,r).split(" "),n=String(e).indexOf(o[o.length-2]);return e.slice(0,n).concat("...")},exports.getStatisticInfo=function(t){var e,r=0,o=0;return t?(e=Object.values(t.views).reduce((function(t,e){return t+(e.pageViews||0)}),0),Object.values(t.productCategorySummary).forEach((function(t){return t.forEach((function(t){var e=t.totalPerCategory,n=t.productsSummary,a=void 0===n?[]:n;o+=e||0,null==a||a.forEach((function(t){var e=t.productsSold;r+=e}))}))})),{totalViews:e,totalSold:r,totalAmount:o}):{totalViews:0,totalSold:0,totalAmount:0}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("tslib"),r=require("@licklist/core/dist/Config"),e=require("luxon");var o=300,a=function(t,r){return t.reduce((function(t,e){var o;return t+Object.values(null!==(o=r.views[e])&&void 0!==o?o:{}).reduce((function(t,r){return t+(r.pageViews||0)}),0)}),0)},n=function(t,r){var e=0,o=0;return t.forEach((function(t){var a;return Object.values(null!==(a=r.productCategorySummary[t])&&void 0!==a?a:{}).forEach((function(t){var r,a=t.totalPerCategory,n=t.productsSummary;o+=a||0,e+=null!==(r=null==n?void 0:n.reduce((function(t,r){return t+r.productsSold}),0))&&void 0!==r?r:0}))})),[e,o]};exports.EVENT_DESCRIPTION_SIZE=o,exports.calculateTotalSoldAndAmount=n,exports.calculateTotalViews=a,exports.formatContent=function(t,r){return t?t.length>r?"".concat(t.slice(0,r),"..."):t:""},exports.formatContentWithoutTags=function(t,r){if(void 0===r&&(r=o),!t)return"";if(t<r)return t;var e=t.replace(/<[^>]*>/g,"").trim().replace(/&nbsp;|[^a-zA-Z0-9\s]/g,"").replace(/\s\s+/g," ").slice(0,r).split(" "),a=String(t).indexOf(e[e.length-2]);return t.slice(0,a).concat("...")},exports.getStatisticInfo=function(o,u){var i;if(!o)return{totalViews:0,totalSold:0,totalAmount:0};var l=e.DateTime.fromISO(u).toUTC().toFormat(r.DATE_FORMAT),c=e.DateTime.fromISO(u).toUTC().toFormat(r.DATE_TIME_FULL_FORMAT),s=Object.values(null!==(i=o.relativeDays)&&void 0!==i?i:{}),d=a(t.__spreadArray([l],t.__read(s),!1),o),f=t.__read(n(t.__spreadArray([c],t.__read(s),!1),o),2);return{totalViews:d,totalSold:f[0],totalAmount:f[1]}};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@licklist/design",
3
- "version": "0.44.486-dev.70",
3
+ "version": "0.44.486-dev.72",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+ssh://git@bitbucket.org/artelogicsoft/licklist_design.git"
@@ -1,5 +1,6 @@
1
- import React, { ReactElement } from "react";
1
+ import React, { FunctionComponent, SVGProps } from "react";
2
2
  import { useTranslation } from "react-i18next";
3
+ import { ZoneResourcesAvailability } from "@licklist/core/dist/DataMapper/Order/ZoneResourcesAvailabilityDataMapper";
3
4
  import { ReactComponent as AvailableIcon } from "../assets/iframe/available.svg";
4
5
  import { ReactComponent as LimitedIcon } from "../assets/iframe/limited.svg";
5
6
  import { ReactComponent as SoldOutIcon } from "../assets/iframe/soldOut.svg";
@@ -7,53 +8,60 @@ import { ReactComponent as SoldOutIcon } from "../assets/iframe/soldOut.svg";
7
8
  const LOTS_OF_SPACE_LIMIT = 0.2;
8
9
  const LIMITED_LIMIT = 0.8;
9
10
 
10
- const getIconsAndLabels = (
11
- booked: number,
12
- total: number
13
- ): { label: string; icon: ReactElement } => {
14
- if (booked === total) {
15
- return { label: "soldOut", icon: <SoldOutIcon className="logo" /> };
11
+ type Config = {
12
+ label: string;
13
+ icon: FunctionComponent<SVGProps<SVGSVGElement>>;
14
+ };
15
+
16
+ const getIconsAndLabels = ({
17
+ bookedResources,
18
+ totalResources,
19
+ }: ZoneResourcesAvailability): Config => {
20
+ if (bookedResources === totalResources) {
21
+ return { label: "soldOut", icon: SoldOutIcon };
16
22
  }
17
23
 
18
24
  // lots of space if less than 80% booked
19
- if (booked / total <= LOTS_OF_SPACE_LIMIT) {
20
- return { label: "lotsOfSpace", icon: <AvailableIcon className="logo" /> };
25
+ if (bookedResources / totalResources <= LOTS_OF_SPACE_LIMIT) {
26
+ return { label: "lotsOfSpace", icon: AvailableIcon };
21
27
  }
22
28
 
23
- if (booked / total >= LIMITED_LIMIT) {
24
- return { label: "limited", icon: <LimitedIcon className="logo" /> };
29
+ if (bookedResources / totalResources >= LIMITED_LIMIT) {
30
+ return { label: "limited", icon: LimitedIcon };
25
31
  }
26
32
 
27
- return { label: "available", icon: <AvailableIcon className="logo" /> };
33
+ return { label: "available", icon: AvailableIcon };
28
34
  };
29
35
 
30
36
  type AvailabilityIndicatorProps = {
31
- booked: number;
32
- total: number;
33
- notAvailable?: boolean;
37
+ resources: ZoneResourcesAvailability;
38
+ isUnavailable?: boolean;
39
+ isSoldOut?: boolean;
34
40
  };
35
41
 
36
42
  export const AvailabilityIndicator = ({
37
- booked,
38
- total,
39
- notAvailable,
43
+ resources,
44
+ isUnavailable,
45
+ isSoldOut,
40
46
  }: AvailabilityIndicatorProps) => {
41
47
  const { t } = useTranslation("Design");
42
- const { icon, label } = getIconsAndLabels(booked, total);
43
-
44
- if (notAvailable) {
45
- return (
46
- <div className="availability-indicator">
47
- <SoldOutIcon className="logo" />
48
- <div>{t("notAvailable")}</div>
49
- </div>
50
- );
48
+
49
+ if (isUnavailable) {
50
+ return <Indicator icon={SoldOutIcon} label={t("notAvailable")} />;
51
51
  }
52
52
 
53
- return (
54
- <div className="availability-indicator">
55
- {icon}
56
- <div>{t(label)}</div>
57
- </div>
58
- );
53
+ if (isSoldOut) {
54
+ return <Indicator icon={SoldOutIcon} label={t("soldOut")} />;
55
+ }
56
+
57
+ const { icon, label } = getIconsAndLabels(resources);
58
+
59
+ return <Indicator icon={icon} label={t(label)} />;
59
60
  };
61
+
62
+ const Indicator = ({ icon, label }: Config) => (
63
+ <div className="availability-indicator">
64
+ {icon}
65
+ <div>{label}</div>
66
+ </div>
67
+ );
@@ -1,5 +1,6 @@
1
1
  import React, { Dispatch, ReactElement, SetStateAction } from "react";
2
2
  import { DateTime } from "luxon";
3
+ import { ZoneResourcesAvailability } from "@licklist/core/dist/DataMapper/Order/ZoneResourcesAvailabilityDataMapper";
3
4
  import { CalendarButtons } from "./components/CalendarButtons";
4
5
  import { CalendarDates } from "./components/CalendarDates";
5
6
 
@@ -20,9 +21,7 @@ export type CalendarProps = {
20
21
  fromPrice?: string | ReactElement | null;
21
22
  isLoading?: boolean;
22
23
  initialDate?: DateTime;
23
- getAvailability?: (
24
- date: DateTime
25
- ) => { booked: number; total: number } | undefined;
24
+ getAvailability?: (date: DateTime) => ZoneResourcesAvailability | null;
26
25
  includeAvailability?: boolean;
27
26
  };
28
27
 
@@ -1,6 +1,7 @@
1
1
  import React, { ReactElement } from "react";
2
2
  import clsx from "clsx";
3
3
  import { DateTime } from "luxon";
4
+ import { ZoneResourcesAvailability } from "@licklist/core/dist/DataMapper/Order/ZoneResourcesAvailabilityDataMapper";
4
5
  import { AvailabilityIndicator } from "../availability-indicator";
5
6
  import { DateContent } from "./DateContent";
6
7
 
@@ -8,13 +9,11 @@ export type DateTimeButtonProps<T = DateTime | string> = {
8
9
  date: T;
9
10
  isSelected?: boolean;
10
11
  isDisabled?: boolean;
12
+ isSoldOut?: boolean;
11
13
  onSelect: (date: T) => void;
12
14
  isOnlyTimeContainer?: boolean;
13
15
  price?: string | number | ReactElement | null;
14
- resources?: {
15
- booked: number;
16
- total: number;
17
- };
16
+ resources?: ZoneResourcesAvailability | null;
18
17
  calendarView?: boolean;
19
18
  showResources?: boolean;
20
19
  };
@@ -23,6 +22,7 @@ export const DateTimeButton = <T extends DateTime | string>({
23
22
  date,
24
23
  isDisabled: _isDisabled,
25
24
  isSelected,
25
+ isSoldOut,
26
26
  onSelect,
27
27
  isOnlyTimeContainer,
28
28
  price,
@@ -33,7 +33,8 @@ export const DateTimeButton = <T extends DateTime | string>({
33
33
  const isTimeVariant = typeof date === "string";
34
34
 
35
35
  const isDisabled =
36
- _isDisabled || (resources && resources.booked === resources.total);
36
+ _isDisabled ||
37
+ (resources && resources.bookedResources === resources.totalResources);
37
38
 
38
39
  return (
39
40
  <button
@@ -63,7 +64,11 @@ export const DateTimeButton = <T extends DateTime | string>({
63
64
  {price && !isDisabled && <div className="price">{price}</div>}
64
65
 
65
66
  {showResources && resources && (
66
- <AvailabilityIndicator {...resources} notAvailable={_isDisabled} />
67
+ <AvailabilityIndicator
68
+ resources={resources}
69
+ isUnavailable={_isDisabled}
70
+ isSoldOut={isSoldOut}
71
+ />
67
72
  )}
68
73
  </button>
69
74
  );
@@ -50,7 +50,7 @@ export function EventCard({
50
50
  }: EventCardProps) {
51
51
  const { t } = useTranslation("Design");
52
52
  const { formatNumber, formatDate } = useIntl();
53
- const { totalViews, ...statistics } = getStatisticInfo(eventStatistic);
53
+ const { totalViews, ...statistics } = getStatisticInfo(eventStatistic, date);
54
54
  const memoedContent = useMemo(
55
55
  () => formatContentWithoutTags(description, EVENT_DESCRIPTION_SIZE),
56
56
  [description]
@@ -1,4 +1,6 @@
1
+ import { DATE_FORMAT, DATE_TIME_FULL_FORMAT } from "@licklist/core/dist/Config";
1
2
  import { EventStatistic } from "@licklist/core/dist/DataMapper/Provider/EventStatisticDataMapper";
3
+ import { DateTime } from "luxon";
2
4
 
3
5
  export function formatContent(content, maxSymbols) {
4
6
  if (!content) return "";
@@ -25,27 +27,92 @@ export const formatContentWithoutTags = (
25
27
 
26
28
  export const EVENT_DESCRIPTION_SIZE = 300;
27
29
 
28
- export const getStatisticInfo = (eventStatistic: EventStatistic | null) => {
29
- 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] => {
30
64
  let totalSold = 0;
31
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
+ );
32
76
 
33
- if (!eventStatistic) return { totalViews: 0, totalSold: 0, totalAmount: 0 };
77
+ return [totalSold, totalAmount];
78
+ };
34
79
 
35
- totalViews = Object.values(eventStatistic.views).reduce(
36
- (accumulator, currentValue) => {
37
- return accumulator + (currentValue.pageViews || 0);
38
- },
39
- 0
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;
100
+
101
+ const viewsFormattedDate = DateTime.fromISO(date)
102
+ .toUTC()
103
+ .toFormat(DATE_FORMAT);
104
+ const summaryFormattedDate = DateTime.fromISO(date)
105
+ .toUTC()
106
+ .toFormat(DATE_TIME_FULL_FORMAT);
107
+ const relatedDays = Object.values(eventStatistic.relativeDays ?? {});
108
+
109
+ const totalViews = calculateTotalViews(
110
+ [viewsFormattedDate, ...relatedDays],
111
+ eventStatistic
40
112
  );
41
- Object.values(eventStatistic.productCategorySummary).forEach((summaries) =>
42
- summaries.forEach(({ totalPerCategory, productsSummary = [] }) => {
43
- totalAmount += totalPerCategory || 0;
44
-
45
- productsSummary?.forEach(({ productsSold }) => {
46
- totalSold += productsSold;
47
- });
48
- })
113
+ const [totalSold, totalAmount] = calculateTotalSoldAndAmount(
114
+ [summaryFormattedDate, ...relatedDays],
115
+ eventStatistic
49
116
  );
50
117
 
51
118
  return { totalViews, totalSold, totalAmount };