@licklist/design 0.44.488 → 0.44.490

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.
Files changed (68) hide show
  1. package/dist/customers/components/filter/CustomerFilter.d.ts +13 -0
  2. package/dist/customers/components/filter/CustomerFilter.d.ts.map +1 -0
  3. package/dist/customers/components/filter/CustomerFilter.js +1 -0
  4. package/dist/customers/components/filter/index.d.ts +3 -0
  5. package/dist/customers/components/filter/index.d.ts.map +1 -0
  6. package/dist/customers/components/index.d.ts +2 -0
  7. package/dist/customers/components/index.d.ts.map +1 -0
  8. package/dist/customers/index.d.ts +2 -0
  9. package/dist/customers/index.d.ts.map +1 -0
  10. package/dist/events/event-statistic-modal/EventStatisticModal.d.ts +1 -2
  11. package/dist/events/event-statistic-modal/EventStatisticModal.d.ts.map +1 -1
  12. package/dist/events/event-statistic-modal/EventStatisticModal.js +1 -1
  13. package/dist/events/event-statistic-modal/hooks/useTableData.d.ts +1 -1
  14. package/dist/events/event-statistic-modal/hooks/useTableData.d.ts.map +1 -1
  15. package/dist/events/event-statistic-modal/hooks/useTableData.js +1 -1
  16. package/dist/events/event-statistic-modal/utils/index.d.ts +1 -1
  17. package/dist/events/event-statistic-modal/utils/index.d.ts.map +1 -1
  18. package/dist/events/event-statistic-modal/utils/index.js +1 -1
  19. package/dist/iframe/payment/order-items-table/OrderItemsTable.js +1 -1
  20. package/dist/iframe/payment/payment-form/PaymentForm.js +1 -1
  21. package/dist/index.d.ts +1 -0
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +1 -1
  24. package/dist/sales/guest-profile/previous-bookings/PreviousBookings.d.ts +3 -2
  25. package/dist/sales/guest-profile/previous-bookings/PreviousBookings.d.ts.map +1 -1
  26. package/dist/sales/guest-profile/previous-bookings/PreviousBookings.js +1 -1
  27. package/dist/sales/notes/NotesTableRow.js +1 -1
  28. package/dist/setting/dashboard/snippets/card/SnippetCard.js +1 -1
  29. package/dist/styles/customers/Filter.scss +53 -0
  30. package/dist/styles/customers/_index.scss +1 -0
  31. package/dist/styles/packages.scss +1 -0
  32. package/dist/table/ReactTableHelperComponent.d.ts +12 -0
  33. package/dist/table/ReactTableHelperComponent.d.ts.map +1 -0
  34. package/dist/table/ReactTableHelperComponent.js +1 -0
  35. package/dist/table/TableHelperComponent.d.ts +2 -3
  36. package/dist/table/TableHelperComponent.d.ts.map +1 -1
  37. package/dist/table/hooks/useTableQueryOptions.d.ts +20 -0
  38. package/dist/table/hooks/useTableQueryOptions.d.ts.map +1 -0
  39. package/dist/table/hooks/useTableQueryOptions.js +1 -0
  40. package/dist/table/index.d.ts +1 -0
  41. package/dist/table/index.d.ts.map +1 -1
  42. package/dist/table/types.d.ts +41 -0
  43. package/dist/table/types.d.ts.map +1 -0
  44. package/dist/table/utils/index.d.ts +1 -0
  45. package/dist/table/utils/index.d.ts.map +1 -1
  46. package/dist/table/utils/index.js +1 -1
  47. package/package.json +2 -1
  48. package/src/customers/components/filter/CustomerFilter.stories.tsx +18 -0
  49. package/src/customers/components/filter/CustomerFilter.tsx +48 -0
  50. package/src/customers/components/filter/index.ts +2 -0
  51. package/src/customers/components/index.ts +1 -0
  52. package/src/customers/index.ts +1 -0
  53. package/src/events/event-statistic-modal/EventStatisticModal.tsx +1 -4
  54. package/src/events/event-statistic-modal/hooks/useTableData.tsx +4 -10
  55. package/src/events/event-statistic-modal/utils/index.ts +35 -38
  56. package/src/index.ts +1 -0
  57. package/src/sales/guest-profile/previous-bookings/PreviousBookings.stories.tsx +35 -5
  58. package/src/sales/guest-profile/previous-bookings/PreviousBookings.tsx +11 -3
  59. package/src/styles/customers/Filter.scss +53 -0
  60. package/src/styles/customers/_index.scss +1 -0
  61. package/src/styles/packages.scss +1 -0
  62. package/src/table/ReactTableHelperComponent.tsx +321 -0
  63. package/src/table/Table.stories.tsx +127 -1
  64. package/src/table/TableHelperComponent.tsx +3 -1
  65. package/src/table/hooks/useTableQueryOptions.ts +49 -0
  66. package/src/table/index.ts +1 -0
  67. package/src/table/types.ts +47 -0
  68. package/src/table/utils/index.ts +2 -0
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/table/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,yDAAyD,CAAC;AAWlF,eAAO,MAAM,qBAAqB,UACzB,eAAe,kBACN,QAAQ,WAAW,CAAC,OAC/B,MAAM,WAAW,oBAWvB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/table/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,yDAAyD,CAAC;AAGlF,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAUnD,eAAO,MAAM,qBAAqB,UACzB,eAAe,kBACN,QAAQ,WAAW,CAAC,OAC/B,MAAM,WAAW,oBAWvB,CAAC"}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=(e=require("@licklist/plugins/dist/services/Table/TableService"))&&"object"==typeof e&&"default"in e?e.default:e,r={page:t.DEFAULT_PAGE,perPage:t.DEFAULT_PER_PAGE,sortDirection:t.DEFAULT_SORT_DIRECTION,sortKey:t.DEFAULT_SORT_KEY,filter:""};exports.getFilterOptionsValue=function(e,t,i){return e.get(i)?e.get(i):t[i]?t[i]:r[i]};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=(e=require("@licklist/plugins/dist/services/Table/TableService"))&&"object"==typeof e&&"default"in e?e.default:e,r=require("@tanstack/react-table"),i={page:t.DEFAULT_PAGE,perPage:t.DEFAULT_PER_PAGE,sortDirection:t.DEFAULT_SORT_DIRECTION,sortKey:t.DEFAULT_SORT_KEY,filter:""};Object.defineProperty(exports,"flexRender",{enumerable:!0,get:function(){return r.flexRender}}),exports.getFilterOptionsValue=function(e,t,r){return e.get(r)?e.get(r):t[r]?t[r]:i[r]};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@licklist/design",
3
- "version": "0.44.488",
3
+ "version": "0.44.490",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+ssh://git@bitbucket.org/artelogicsoft/licklist_design.git"
@@ -71,6 +71,7 @@
71
71
  "@storybook/react": "6.3.12",
72
72
  "@svgr/rollup": "5.5.0",
73
73
  "@svgr/webpack": "5.5.0",
74
+ "@tanstack/react-table": "8.10.6",
74
75
  "@testing-library/jest-dom": "5.16.1",
75
76
  "@testing-library/react": "11.2.5",
76
77
  "@testing-library/react-hooks": "5.1.0",
@@ -0,0 +1,18 @@
1
+ import React, { useState } from "react";
2
+ import { Meta, Story } from "@storybook/react";
3
+ import { CustomerFilter, CustomerFilterProps } from "./CustomerFilter";
4
+
5
+ export default {
6
+ title: "Customers/Filter",
7
+ component: CustomerFilter,
8
+ } as Meta;
9
+
10
+ export const Default: Story<CustomerFilterProps> = () => {
11
+ const [values, setValues] = useState({
12
+ name: "",
13
+ email: "",
14
+ phone: "",
15
+ });
16
+
17
+ return <CustomerFilter values={values} onChange={setValues} />;
18
+ };
@@ -0,0 +1,48 @@
1
+ import React from "react";
2
+ import { useTranslation } from "react-i18next";
3
+ import clsx from "clsx";
4
+ import { TextField } from "../../../static/TextField";
5
+
6
+ type CustomerFilterValues = {
7
+ name: string;
8
+ email: string;
9
+ phone: string;
10
+ };
11
+
12
+ const FILTER_FIELDS = {
13
+ name: "name",
14
+ email: "email",
15
+ phone: "phone",
16
+ };
17
+
18
+ export interface CustomerFilterProps {
19
+ values: CustomerFilterValues;
20
+ onChange: (values: CustomerFilterValues) => void;
21
+ }
22
+
23
+ export const CustomerFilter = ({ values, onChange }: CustomerFilterProps) => {
24
+ const { t } = useTranslation(["Design"]);
25
+
26
+ return (
27
+ <div className="customers-filter d-flex">
28
+ <div className="d-flex customers-filter-items">
29
+ {Object.keys(FILTER_FIELDS).map((filterKeyName) => {
30
+ const label = t(FILTER_FIELDS[filterKeyName]);
31
+
32
+ return (
33
+ <TextField
34
+ key={filterKeyName}
35
+ className={clsx("mb-0", "col-4", "customer-filter")}
36
+ type="text"
37
+ label={label}
38
+ value={values[filterKeyName]}
39
+ onChange={(event) =>
40
+ onChange({ ...values, [filterKeyName]: event.target.value })
41
+ }
42
+ />
43
+ );
44
+ })}
45
+ </div>
46
+ </div>
47
+ );
48
+ };
@@ -0,0 +1,2 @@
1
+ export { CustomerFilter } from "./CustomerFilter";
2
+ export type { CustomerFilterProps } from "./CustomerFilter";
@@ -0,0 +1 @@
1
+ export * from "./filter";
@@ -0,0 +1 @@
1
+ export * from "./components";
@@ -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, date);
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, date).forEach(
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, date));
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
- const formattedDate = DateTime.fromISO(date)
32
- .toUTC()
33
- .toFormat(DATE_TIME_FULL_FORMAT);
28
+ Object.values(eventStatistic?.productCategorySummary)?.forEach(
29
+ (categories) => {
30
+ categories?.forEach(
31
+ ({ totalPerCategory, productsSummary = [], categoryName, eventId }) => {
32
+ let quantity = 0;
34
33
 
35
- eventStatistic?.productCategorySummary?.[formattedDate]?.forEach(
36
- ({ totalPerCategory, productsSummary = [], categoryName, eventId }) => {
37
- let quantity = 0;
34
+ totalAmount += totalPerCategory || 0;
38
35
 
39
- totalAmount += totalPerCategory || 0;
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
- tableDataArray.push({
42
- name: categoryName,
43
- key: `${eventId}.${categoryName}`,
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
- productsSummary?.forEach(
51
- ({ productsSold, name, totalQuantity, total }) => {
52
- quantity += productsSold;
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}.${name}`,
57
- quantity: totalQuantity
58
- ? `${productsSold} / ${totalQuantity}`
59
- : String(productsSold),
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
 
package/src/index.ts CHANGED
@@ -32,3 +32,4 @@ export * from "./typeahead-helper";
32
32
  export * from "./zone";
33
33
  export * from "./resource";
34
34
  export * from "./virtualized";
35
+ export * from "./customers";
@@ -1,5 +1,6 @@
1
1
  import React from "react";
2
2
  import { Meta } from "@storybook/react";
3
+ import { boolean } from "@storybook/addon-knobs";
3
4
  import { Event } from "@licklist/core/dist/DataMapper/Provider/EventDataMapper";
4
5
  import { User } from "@licklist/core/dist/DataMapper/User/UserDataMapper";
5
6
  import { Product } from "@licklist/core/dist/DataMapper/Product/ProductDataMapper";
@@ -10,11 +11,26 @@ export default {
10
11
  title: "Sales/Guest Profile/Previous Bookings",
11
12
  } as Meta;
12
13
 
13
- export const Default = (args) => (
14
- <div>
15
- <PreviousBookings {...args} />
16
- </div>
17
- );
14
+ export const Default = (args) => {
15
+ const useProviderLink = boolean("useProviderLink", true);
16
+
17
+ const renderOrderTitleLinkByProvider = (order: Order) => {
18
+ return (
19
+ <a href={`/some_href/${order.id}`}>{order[order.orderableType]?.name}</a>
20
+ );
21
+ };
22
+
23
+ return (
24
+ <div>
25
+ <PreviousBookings
26
+ {...args}
27
+ renderOrderTitleLinkByProvider={
28
+ useProviderLink ? renderOrderTitleLinkByProvider : undefined
29
+ }
30
+ />
31
+ </div>
32
+ );
33
+ };
18
34
 
19
35
  Default.args = {
20
36
  orders: [
@@ -43,6 +59,8 @@ Default.args = {
43
59
  updatedAt: "2022-05-20 18:28:56",
44
60
  status: "cart",
45
61
  tickets: [],
62
+ orderableType: "event",
63
+ orderableId: 1,
46
64
  event: {
47
65
  id: 1,
48
66
  name: "testEvent1",
@@ -79,6 +97,8 @@ Default.args = {
79
97
  updatedAt: "2022-05-20 18:28:56",
80
98
  status: "cart",
81
99
  tickets: [],
100
+ orderableType: "event",
101
+ orderableId: 2,
82
102
  event: {
83
103
  id: 2,
84
104
  name: "testEvent2",
@@ -128,6 +148,8 @@ Default.args = {
128
148
  updatedAt: "2022-05-20 18:28:56",
129
149
  status: "cart",
130
150
  tickets: [],
151
+ orderableType: "event",
152
+ orderableId: 3,
131
153
  event: {
132
154
  id: 3,
133
155
  name: "testEvent3",
@@ -156,6 +178,8 @@ Default.args = {
156
178
  updatedAt: "2022-05-20 18:28:56",
157
179
  status: "cart",
158
180
  tickets: [],
181
+ orderableType: "event",
182
+ orderableId: 3,
159
183
  event: {
160
184
  id: 3,
161
185
  name: "testEvent3",
@@ -184,6 +208,8 @@ Default.args = {
184
208
  updatedAt: "2022-05-20 18:28:56",
185
209
  status: "cart",
186
210
  tickets: [],
211
+ orderableType: "event",
212
+ orderableId: 3,
187
213
  event: {
188
214
  id: 3,
189
215
  name: "testEvent3",
@@ -212,6 +238,8 @@ Default.args = {
212
238
  updatedAt: "2022-05-20 18:28:56",
213
239
  status: "cart",
214
240
  tickets: [],
241
+ orderableType: "event",
242
+ orderableId: 3,
215
243
  event: {
216
244
  id: 3,
217
245
  name: "testEvent3",
@@ -239,6 +267,8 @@ Default.args = {
239
267
  updatedAt: "2022-05-20 18:28:56",
240
268
  status: "cart",
241
269
  tickets: [],
270
+ orderableType: "event",
271
+ orderableId: 3,
242
272
  event: {
243
273
  id: 3,
244
274
  name: "testEvent3",
@@ -1,4 +1,4 @@
1
- import React, { useState } from "react";
1
+ import React, { useState, ReactNode } from "react";
2
2
  import { useTranslation } from "react-i18next";
3
3
  import { DateTime } from "luxon";
4
4
  import { Button } from "react-bootstrap";
@@ -8,9 +8,13 @@ const MAX_ORDERS_COUNT = 6;
8
8
 
9
9
  export type PreviousBookingsProps = {
10
10
  orders: Order[];
11
+ renderOrderTitleLinkByProvider?: (order: Order) => ReactNode;
11
12
  };
12
13
 
13
- export const PreviousBookings = ({ orders }: PreviousBookingsProps) => {
14
+ export const PreviousBookings = ({
15
+ orders,
16
+ renderOrderTitleLinkByProvider,
17
+ }: PreviousBookingsProps) => {
14
18
  const { t } = useTranslation("Design");
15
19
  const [showOlderBookings, setShowOlderBookings] = useState(false);
16
20
 
@@ -36,13 +40,17 @@ export const PreviousBookings = ({ orders }: PreviousBookingsProps) => {
36
40
  {orders.length > 0 ? (
37
41
  <div className="events-wrapper">
38
42
  {orders.slice(0, endSlicedOrdersNumber).map((order) => {
43
+ const eventName = renderOrderTitleLinkByProvider
44
+ ? renderOrderTitleLinkByProvider(order)
45
+ : order[order.orderableType]?.name;
46
+
39
47
  return (
40
48
  <div
41
49
  className="event-info col-12 col-sm-6 col-md-6 col-lg-6 col-xl-6"
42
50
  key={order.id}
43
51
  >
44
52
  <div className="info-wrapper">
45
- <p className="label">{order.event?.name}</p>
53
+ <p className="label">{eventName}</p>
46
54
  {order.createdAt && (
47
55
  <p className="event-date">{formatDate(order.createdAt)}</p>
48
56
  )}
@@ -0,0 +1,53 @@
1
+ .customers-filter {
2
+ @include media-breakpoint-down(sm) {
3
+ label {
4
+ font-size: 0.8rem;
5
+ }
6
+ }
7
+
8
+ @include media-breakpoint-up(md) {
9
+ label {
10
+ font-size: 0.9rem;
11
+ }
12
+ }
13
+
14
+ @include media-breakpoint-up(lg) {
15
+ label {
16
+ font-size: 1rem;
17
+ }
18
+ }
19
+
20
+ @include media-breakpoint-down(lg) {
21
+ flex-direction: column;
22
+ }
23
+
24
+ .customers-filter-items {
25
+ width: 100%;
26
+
27
+ .customer-filter {
28
+ flex: 0 0 33.33%;
29
+ max-width: 33.33%;
30
+ }
31
+
32
+ @include media-breakpoint-down(xs) {
33
+ flex-direction: column;
34
+
35
+ .customer-filter {
36
+ flex: 1;
37
+ max-width: 100%;
38
+ }
39
+ }
40
+
41
+ @include media-breakpoint-up(sm) {
42
+ .customer-filter {
43
+ &:first-child {
44
+ padding-left: 0;
45
+ }
46
+
47
+ &:last-child {
48
+ padding-right: 0;
49
+ }
50
+ }
51
+ }
52
+ }
53
+ }
@@ -0,0 +1 @@
1
+ @import "./Filter.scss";
@@ -35,3 +35,4 @@
35
35
  @import "./skeleton";
36
36
  @import "./virtualized/";
37
37
  @import "./error";
38
+ @import "./customers/";