@licklist/design 0.78.5-dev.16 → 0.78.5-dev.2

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 (36) hide show
  1. package/dist/auth/Layout/UserNavDropDownToggle.js +0 -3
  2. package/dist/events/edit-recurrent-event-modal/EditRecurrentEventModal.d.ts.map +1 -1
  3. package/dist/events/event-statistic-modal/EventStatisticModal.d.ts.map +1 -1
  4. package/dist/iframe/payment/order-items-table/hooks/useTableData.d.ts.map +1 -1
  5. package/dist/iframe/payment/order-items-table/hooks/useTableData.js +80 -81
  6. package/dist/modals/dialog/Dialog.d.ts.map +1 -1
  7. package/dist/modals/dialog/Dialog.js +41 -39
  8. package/dist/notification/email-template/card/EmailTemplateCard.d.ts.map +1 -1
  9. package/dist/notification/email-template/control/EmailTemplateControl.d.ts +0 -1
  10. package/dist/notification/email-template/control/EmailTemplateControl.d.ts.map +1 -1
  11. package/dist/notification/email-template/control/EmailTemplateControl.js +4 -4
  12. package/dist/notification/email-template/form/EmailTemplateForm.d.ts +1 -2
  13. package/dist/notification/email-template/form/EmailTemplateForm.d.ts.map +1 -1
  14. package/dist/notification/email-template/form/EmailTemplateForm.js +1 -2
  15. package/dist/product-set/product/advanced-options/AdvancedOptions.js +1 -1
  16. package/dist/recurrence-input/RecurrenceInput.d.ts.map +1 -1
  17. package/dist/recurrence-input/RecurrenceInput.js +1 -1
  18. package/dist/setting/dashboard/payments/payments-modal/PaymentsModal.d.ts.map +1 -1
  19. package/dist/snippet/snippet-template/preview/Preview.d.ts.map +1 -1
  20. package/dist/snippet/snippet-template/preview/Preview.js +20 -14
  21. package/package.json +6 -6
  22. package/src/auth/Layout/UserNavDropDownToggle.tsx +1 -1
  23. package/src/events/edit-recurrent-event-modal/EditRecurrentEventModal.tsx +0 -1
  24. package/src/events/event-statistic-modal/EventStatisticModal.tsx +0 -1
  25. package/src/iframe/payment/order-items-table/hooks/useTableData.tsx +109 -103
  26. package/src/modals/dialog/Dialog.tsx +36 -35
  27. package/src/notification/email-template/card/EmailTemplateCard.tsx +2 -0
  28. package/src/notification/email-template/control/EmailTemplateControl.tsx +5 -7
  29. package/src/notification/email-template/form/EmailTemplateForm.tsx +0 -3
  30. package/src/recurrence-input/RecurrenceInput.tsx +3 -4
  31. package/src/setting/dashboard/payments/payments-modal/PaymentsModal.tsx +0 -1
  32. package/src/snippet/snippet-template/preview/Preview.tsx +9 -6
  33. package/yarn.lock +479 -473
  34. package/dist/CustomDatePicker/CustomDatePicker.d.ts +0 -10
  35. package/dist/CustomDatePicker/CustomDatePicker.d.ts.map +0 -1
  36. package/src/CustomDatePicker/CustomDatePicker.tsx +0 -252
@@ -13,7 +13,7 @@ function UserNavDropDownToggle(props: UserNavDropDownToggleProps) {
13
13
  return (
14
14
  <>
15
15
  <span className='header-user-name mr-2 d-none d-lg-inline text-gray-600 small'>
16
- <Trans t={t} i18nKey='userPromo' values={{ name: user?.first_name }}>
16
+ <Trans t={t} i18nKey='userPromo'>
17
17
  Hi, {{ name: user?.first_name }}
18
18
  </Trans>
19
19
  </span>
@@ -86,7 +86,6 @@ export const EditRecurrentEventModal = ({
86
86
  contentClassName='rounded'
87
87
  >
88
88
  <Form onSubmit={handleSubmit(onSubmit)} noValidate>
89
- {/* @ts-ignore */}
90
89
  <Modal.Header className='border-0'>
91
90
  <Modal.Title as='h6'>{title}</Modal.Title>
92
91
  <Button
@@ -39,7 +39,6 @@ export const EventStatisticModal = ({
39
39
  contentClassName='rounded'
40
40
  className='event-statistic-modal'
41
41
  >
42
- {/* @ts-ignore */}
43
42
  <Modal.Header>
44
43
  <Modal.Title as='h6'>{title ?? t('eventStatistic')}</Modal.Title>
45
44
  <Button
@@ -1,22 +1,24 @@
1
1
  import { useMemo } from 'react'
2
- import { uniqueId, flatMap, flatten } from 'lodash'
2
+ import { uniqueId, flatMap, flatten, map } from 'lodash'
3
3
  import { useIntl } from 'react-intl'
4
4
  import { useTranslation } from 'react-i18next'
5
5
  import { Product } from '@licklist/core/dist/DataMapper/Product/ProductDataMapper'
6
6
  import { OrderModifier } from '@licklist/core/dist/DataMapper/Order/OrderModifierDataMapper'
7
- import { OrderProduct } from '@licklist/core/dist/DataMapper/Order/OrderProductDataMapper'
8
7
  import {
9
8
  PAYMENT_TYPE_VAT,
10
9
  PAYMENT_TYPE_FEE,
11
10
  PAYMENT_TYPE_NET_PROFIT,
12
11
  } from '@licklist/core/dist/DataMapper/Order/PaymentDataMapper'
13
12
  import { StaticTableData } from '../../../../table'
14
- import { getTotalSumByCategory } from '../utils'
13
+ import { getProductQuantityAndPrice, getTotalSumByCategory } from '../utils'
15
14
  import { OrderItemsTableProps, SummaryItem } from '../types'
16
15
  import { getOrderSummaryItems } from '../utils/paymentSummary'
16
+ import { Order } from '@licklist/core/dist/DataMapper'
17
+ import { OrderPayment } from '@licklist/core/dist/DataMapper/Order/OrderPaymentDataMapper'
18
+ import { OrderProduct } from '@licklist/core/dist/DataMapper/Order/OrderProductDataMapper'
19
+ import { OrderModifierByProduct } from '@licklist/core/dist/DataMapper/Order/OrderModifiierByProduct'
17
20
 
18
21
  const CURRENCY_DEFAULT = 'GBP'
19
-
20
22
  export const PAYMENT_TYPE_TRANSLATE_KEYS = {
21
23
  [PAYMENT_TYPE_NET_PROFIT]: 'netAmount',
22
24
  [PAYMENT_TYPE_FEE]: 'bookeditFee',
@@ -39,62 +41,43 @@ export const useTableData = ({
39
41
  })
40
42
 
41
43
  const wrapLabelContent = (string: string) => (
42
- <div className="label">{string}</div>
44
+ <div className='label'>{string}</div>
43
45
  )
44
46
 
45
47
  const renderCategoryItem = (products: Product[]) => ({
46
48
  key: uniqueId('category-id-'),
47
- name: wrapLabelContent(products[0]?.productCategory?.name ?? ''),
49
+ name: wrapLabelContent(products[0].productCategory?.name ?? ''),
48
50
  quantity: '',
49
51
  price: wrapLabelContent(
50
52
  `${t('total')}: ${formatPrice(
51
- getTotalSumByCategory(order.orderProducts ?? [], products),
53
+ getTotalSumByCategory(order.orderProducts, products),
52
54
  )}`,
53
55
  ),
54
56
  })
55
57
 
56
- const reworkProductStructure = (order: OrderProduct) => {
57
- if (!order) return []
58
-
59
- const groups: any[] = (order as any)?.orderProductModifiersGroups ?? []
60
- if (!Array.isArray(groups) || !groups.length) return [order]
61
-
62
- return groups.flatMap((modGroup, idx) => ({
63
- deletedAt: order.deletedAt ?? null,
64
- id: `${order.id}-${idx + 1}`,
65
- orderId: order.orderId ?? null,
66
- price: order.price ?? 0,
67
- productId: order.productId ?? '',
68
- quantity: modGroup?.productQuantity ?? 1,
69
- deposit: order.deposit ?? 0,
70
- orderProductModifiers:
71
- (modGroup?.modifiers ?? []).map((mod: any) => ({
72
- modifierId: mod?.modifierId ?? '',
73
- price: mod?.price ?? 0,
74
- productId: mod?.productId ?? '',
75
- quantity: mod?.quantity ?? 1,
76
- modifierSetId: mod?.modifierSetId ?? '',
77
- modifier: mod?.modifier ?? null,
78
- })) ?? [],
79
- }))
80
- }
81
-
82
- const renderModifierItem = (orderModifier: OrderModifier) => {
83
- if (!orderModifier || orderModifier.quantity === 0) return null
84
- const { quantity, modifier, modifierId, price } = orderModifier
85
-
86
- return {
87
- key: modifierId,
88
- name: ` - ${modifier?.name || ''}`,
89
- quantity: (
90
- <div className="quantity">
91
- <div className="multiplier">x</div>
92
- {quantity}
93
- </div>
94
- ),
95
- price: formatPrice(price ?? 0),
96
- }
97
- }
58
+ const reworkProductStructure = (order: OrderProduct) =>
59
+ order
60
+ ? flatMap(order, (item) => {
61
+ if (!item || !Array.isArray(item)) return []
62
+ return item.map((modGroup, idx) => ({
63
+ deletedAt: order.deletedAt ?? null,
64
+ id: `${order.id}-${idx + 1}`, // Ensuring uniqueness with string concatenation
65
+ orderId: order.orderId ?? null,
66
+ price: order.price ?? 0,
67
+ productId: order.productId ?? '',
68
+ quantity: modGroup.productQuantity ?? 1,
69
+ deposit: order.deposit ?? 0,
70
+ orderProductModifiers: modGroup.modifiers.map((mod) => ({
71
+ modifierId: mod.modifierId ?? '',
72
+ price: mod.price ?? 0,
73
+ productId: mod.productId ?? '',
74
+ quantity: mod.quantity ?? 1,
75
+ modifierSetId: mod.modifierSetId ?? '',
76
+ modifier: mod.modifier ?? null,
77
+ })),
78
+ }))
79
+ })
80
+ : []
98
81
 
99
82
  const renderProductItem = ({
100
83
  product,
@@ -103,26 +86,43 @@ export const useTableData = ({
103
86
  product: OrderProduct
104
87
  productsForCategory: Product[]
105
88
  }) => {
106
- if (!product || product.quantity === 0) return null
107
-
89
+ if (product.quantity === 0) {
90
+ return null
91
+ }
92
+
108
93
  const name =
109
- productsForCategory.find((item) => item.id === product.productId)?.name ||
110
- ''
94
+ productsForCategory.find((item) => item.id === product.productId)?.name || ''
111
95
 
112
96
  return {
113
97
  key: product.id,
114
98
  name,
115
99
  quantity: (
116
- <div className="quantity">
117
- <div className="multiplier">x</div>
100
+ <div className='quantity'>
101
+ <div className='multiplier'>x</div>
118
102
  {product.quantity}
119
103
  </div>
120
104
  ),
121
- price: formatPrice(product.price ?? 0),
122
- modifier:
123
- (product?.orderProductModifiers?.map(renderModifierItem) ?? []).filter(
124
- Boolean,
125
- ),
105
+ price: formatPrice(product.price),
106
+ modifier: product?.orderProductModifiers?.map(renderModifierItem) || [],
107
+ }
108
+ }
109
+
110
+ const renderModifierItem = (orderModifier: OrderModifier) => {
111
+ const { quantity, modifier, modifierId, price } = orderModifier
112
+ if (quantity === 0) {
113
+ return null
114
+ }
115
+
116
+ return {
117
+ key: modifierId,
118
+ name: ` - ${modifier?.name || ''}`,
119
+ quantity: (
120
+ <div className='quantity'>
121
+ <div className='multiplier'>x</div>
122
+ {quantity}
123
+ </div>
124
+ ),
125
+ price: formatPrice(price),
126
126
  }
127
127
  }
128
128
 
@@ -132,40 +132,41 @@ export const useTableData = ({
132
132
  ]
133
133
 
134
134
  return productCategories.reduce(
135
- (acc: StaticTableData[], categoryId) => {
136
- const productsForCategory =
137
- order?.products.filter((p) => p.productCategoryId === categoryId) ?? []
138
-
139
- const products =
140
- order?.orderProducts?.filter((el) =>
141
- productsForCategory.map((p) => p.id).includes(el.productId),
142
- ) ?? []
143
-
144
- if (!products.length) return acc
145
-
135
+ (previousValues: StaticTableData[], categoryId) => {
136
+ const productsForCategory = order?.products.filter(
137
+ (product) => product.productCategoryId === categoryId,
138
+ )
139
+
140
+ const products = order.orderProducts.filter((el) =>
141
+ productsForCategory
142
+ .map((product) => product.id)
143
+ .includes(el.productId),
144
+ )
145
+
146
+ if (!products.length) {
147
+ return previousValues
148
+ }
146
149
  const productsWithReworkedModifier = products.map((product) => {
147
- if (!product?.orderProductModifiers?.length) return product
150
+ if (!product.orderProductModifiers.length) return product
148
151
  return reworkProductStructure(product)
149
152
  })
150
153
 
151
- const filteredProducts = flatten(productsWithReworkedModifier)
152
- .map((p) =>
153
- renderProductItem({
154
- product: p as OrderProduct,
155
- productsForCategory,
156
- }),
157
- )
158
- .filter((row): row is NonNullable<typeof row> => Boolean(row))
159
-
160
- if (!filteredProducts.length) return acc
161
-
162
- const productWithModifier = flatMap(filteredProducts, (row) => [
163
- row,
164
- ...(row.modifier ?? []),
154
+ const filteredProducts = flatten(productsWithReworkedModifier).map(
155
+ (product) =>
156
+ renderProductItem({ product , productsForCategory }),
157
+ )
158
+
159
+ const productWithModifier = flatMap(filteredProducts, (item) => [
160
+ item,
161
+ ...item.modifier,
165
162
  ])
166
163
 
164
+ if (!filteredProducts.length) {
165
+ return previousValues
166
+ }
167
+
167
168
  return [
168
- ...acc,
169
+ ...previousValues,
169
170
  renderCategoryItem(productsForCategory),
170
171
  ...productWithModifier,
171
172
  ]
@@ -182,21 +183,26 @@ export const useTableData = ({
182
183
  price: wrapLabelContent(formatPrice(price)),
183
184
  }))
184
185
 
185
- const data = useMemo(() => {
186
- if (!order) return []
187
-
188
- return [
189
- ...renderProductsContent(),
190
- ...renderSummaryItems(
191
- getOrderSummaryItems({
192
- order,
193
- paymentDetail,
194
- isPaymentProcessed,
195
- externalDiscount,
196
- }),
197
- ),
198
- ]
199
- }, [order, externalDiscount, isPaymentProcessed, paymentDetail])
200
-
186
+ const data = useMemo(
187
+ () => {
188
+ if (!order) {
189
+ return []
190
+ }
191
+
192
+ return [
193
+ ...renderProductsContent(),
194
+ ...renderSummaryItems(
195
+ getOrderSummaryItems({
196
+ order,
197
+ paymentDetail,
198
+ isPaymentProcessed,
199
+ externalDiscount,
200
+ }),
201
+ ),
202
+ ]
203
+ },
204
+ // eslint-disable-next-line react-hooks/exhaustive-deps
205
+ [order, externalDiscount, isPaymentProcessed],
206
+ )
201
207
  return data
202
208
  }
@@ -32,41 +32,42 @@ export const Dialog = ({
32
32
  }
33
33
 
34
34
  return (
35
- <Modal
36
- show={isActive}
37
- onHide={onDecline}
38
- animation={false}
39
- size='sm'
40
- centered
41
- className='text-center justify-content-center rounded'
42
- >
43
- {/* @ts-ignore */}
44
- <Modal.Header className='justify-content-center border-0'>
45
- {title && <Modal.Title as='h6'>{title}</Modal.Title>}
46
- </Modal.Header>
47
- {content && (
48
- <Modal.Body className='justify-content-center'>{content}</Modal.Body>
49
- )}
50
- <Modal.Footer className='border-0 justify-content-center'>
51
- {customButtons || (
52
- <>
53
- <Button
54
- variant='secondary'
55
- className='modal-buttons'
56
- onClick={declineHandler}
57
- >
58
- {t('cancel')}
59
- </Button>
60
- <Button
61
- variant='primary'
62
- className='modal-buttons'
63
- onClick={approveHandler}
64
- >
65
- {t('Design:confirm')}
66
- </Button>
67
- </>
35
+ <>
36
+ <Modal
37
+ show={isActive}
38
+ onHide={onDecline}
39
+ animation={false}
40
+ size='sm'
41
+ centered
42
+ className='text-center justify-content-center rounded'
43
+ >
44
+ <Modal.Header className='justify-content-center border-0'>
45
+ {title && <Modal.Title as='h6'>{title}</Modal.Title>}
46
+ </Modal.Header>
47
+ {content && (
48
+ <Modal.Body className='justify-content-center'>{content}</Modal.Body>
68
49
  )}
69
- </Modal.Footer>
70
- </Modal>
50
+ <Modal.Footer className='border-0 justify-content-center'>
51
+ {customButtons || (
52
+ <>
53
+ <Button
54
+ variant='secondary'
55
+ className='modal-buttons'
56
+ onClick={declineHandler}
57
+ >
58
+ {t('cancel')}
59
+ </Button>
60
+ <Button
61
+ variant='primary'
62
+ className='modal-buttons'
63
+ onClick={approveHandler}
64
+ >
65
+ {t('Design:confirm')}
66
+ </Button>
67
+ </>
68
+ )}
69
+ </Modal.Footer>
70
+ </Modal>
71
+ </>
71
72
  )
72
73
  }
@@ -35,6 +35,8 @@ export function EmailTemplateCard({
35
35
  return (
36
36
  <div className='snippet-template-card'>
37
37
  <div className='snippet-template-card-header'>
38
+ {/* TODO fix issue react router types
39
+ @ts-expect-error */}
38
40
  <Link to={href}>{name}</Link>
39
41
  {hasPermission && Boolean(onRemove) && (
40
42
  <ConfirmModal
@@ -27,7 +27,6 @@ export interface EmailTemplateControlProps {
27
27
  meta: string
28
28
  defaultAttachments?: Attachment[]
29
29
  notificationTypes?: NotificationType[]
30
- waiverType?: boolean
31
30
  getDefaultTemplateMetaByType?: (type?: NotificationType | null) => string
32
31
  }
33
32
 
@@ -39,7 +38,6 @@ export const EmailTemplateControl = forwardRef(
39
38
  options = [],
40
39
  defaultAttachments = [],
41
40
  notificationTypes = [],
42
- waiverType = false,
43
41
  getDefaultTemplateMetaByType,
44
42
  }: EmailTemplateControlProps,
45
43
  ref: any,
@@ -198,7 +196,7 @@ export const EmailTemplateControl = forwardRef(
198
196
  })
199
197
  })
200
198
  }
201
-
199
+
202
200
  return (
203
201
  <>
204
202
  <Row>
@@ -286,7 +284,7 @@ export const EmailTemplateControl = forwardRef(
286
284
  </Form.Group>
287
285
  </Row>
288
286
 
289
- { !waiverType && (<Row>
287
+ <Row>
290
288
  <Form.Group as={Col}>
291
289
  <Form.Check
292
290
  {...register('isActive')}
@@ -303,7 +301,7 @@ export const EmailTemplateControl = forwardRef(
303
301
  custom
304
302
  />
305
303
  </Form.Group>
306
- </Row>)}
304
+ </Row>
307
305
  <Row className='mb-4'>
308
306
  <Form.Group as={Col}>
309
307
  <Form.Label>{t('Design:emailBody')}</Form.Label>
@@ -376,7 +374,7 @@ export const EmailTemplateControl = forwardRef(
376
374
  }
377
375
  // should show dropdown only if user want to include PDF file
378
376
  if (option.type === OPTION_TYPE.files_selector) {
379
- const fileSelectors = option?.defaultValue ? JSON.parse(option.defaultValue) : ''
377
+ const fileSelectors = JSON.parse(option.defaultValue)
380
378
  const fileNames = Object.values(fileSelectors)
381
379
  const fileKeys = Object.keys(fileSelectors)
382
380
 
@@ -425,7 +423,7 @@ export const EmailTemplateControl = forwardRef(
425
423
  )
426
424
  }
427
425
 
428
- if (option.type === OPTION_TYPE.days_reminder || option.type === OPTION_TYPE.waiver_reminder ) {
426
+ if (option.type === OPTION_TYPE.days_reminder) {
429
427
  return (
430
428
  <>
431
429
  <Form.Label className='mt-4'>
@@ -41,7 +41,6 @@ export interface EmailTemplateProps extends HasPermissionProp {
41
41
  placeholders?: NotificationPlaceholder[]
42
42
  options?: TemplateOption[]
43
43
  serverErrors?: ServerError
44
- waiverType?: boolean
45
44
  notificationTypes?: NotificationType[]
46
45
  getDefaultTemplateMetaByType?: (type?: NotificationType | null) => string
47
46
  onTypeChange?: (type?: NotificationType | null) => void
@@ -55,7 +54,6 @@ export const EmailTemplateForm = ({
55
54
  placeholders = [],
56
55
  options = [],
57
56
  serverErrors,
58
- waiverType,
59
57
  notificationTypes = [],
60
58
  getDefaultTemplateMetaByType,
61
59
  onTypeChange,
@@ -95,7 +93,6 @@ export const EmailTemplateForm = ({
95
93
  >
96
94
  <EmailTemplateControl
97
95
  ref={emailEditorRef}
98
- waiverType={waiverType}
99
96
  setIsLoading={setIsLoading}
100
97
  meta={defaultValues?.meta || null}
101
98
  defaultAttachments={defaultValues?.attachments || []}
@@ -1,7 +1,7 @@
1
1
  /* eslint-disable prefer-destructuring */
2
2
  /* eslint-disable react-hooks/exhaustive-deps */
3
3
  import { DateTime } from 'luxon'
4
- import { useEffect, useReducer } from 'react'
4
+ import { useEffect, useReducer, useState } from 'react'
5
5
  import RRule, { Frequency, Weekday } from 'rrule'
6
6
  import RecurrenceEndInput, { defaultOccurrences } from './RecurrenceEndInput'
7
7
  import RecurrenceIntervalAndFrequencyInput from './RecurrenceIntervalAndFrequencyInput'
@@ -37,7 +37,7 @@ export function RecurrenceInput({
37
37
 
38
38
  useEffect(
39
39
  // TODO: unhardcode timezone
40
- () => {
40
+ () =>
41
41
  onChange(
42
42
  RRule.optionsToString({
43
43
  freq: state.freq,
@@ -47,8 +47,7 @@ export function RecurrenceInput({
47
47
  tzid: 'Europe/London',
48
48
  ...state,
49
49
  }).replace('RRULE:', ''),
50
- )
51
- },
50
+ ),
52
51
  [state],
53
52
  )
54
53
 
@@ -25,7 +25,6 @@ export function PaymentsModal({
25
25
 
26
26
  return (
27
27
  <Modal show={isVisible} onHide={onHide} centered>
28
- {/* @ts-ignore */}
29
28
  <Modal.Header closeButton>
30
29
  <Modal.Title>{t('Design:setEmail')}</Modal.Title>
31
30
  </Modal.Header>
@@ -1,5 +1,6 @@
1
1
  import { useContext, useState } from 'react'
2
2
  import { useTranslation } from 'react-i18next'
3
+ import { MemoryRouter } from 'react-router-dom'
3
4
  import { Button } from 'react-bootstrap'
4
5
  import {
5
6
  SNIPPET_TEMPLATE_TYPE_VENUE_MAP,
@@ -78,12 +79,14 @@ export function Preview({
78
79
  <div className='mt-5 pt-5 external-header'>
79
80
  <PageHeader showCloseButton showBackButton>
80
81
  <Timer timer={600} />
81
- <NavigationSteps
82
- steps={[
83
- { pathname: '/step1', key: '/step1', name: 'Burger' },
84
- { pathname: '/step2', key: '/step2', name: 'Cheese' },
85
- ]}
86
- />
82
+ <MemoryRouter initialEntries={['/step1', '/step2']}>
83
+ <NavigationSteps
84
+ steps={[
85
+ { pathname: '/step1', key: '/step1', name: 'Burger' },
86
+ { pathname: '/step2', key: '/step2', name: 'Cheese' },
87
+ ]}
88
+ />
89
+ </MemoryRouter>
87
90
  </PageHeader>
88
91
  </div>
89
92
  </div>