@licklist/design 0.68.4 → 0.68.5-dev.0

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 (110) hide show
  1. package/dist/affiliate/form/AffiliateForm.d.ts.map +1 -1
  2. package/dist/auth/Login/LoginComponent.js +2 -1
  3. package/dist/calendar/components/CalendarButtons/CalendarButtons.d.ts.map +1 -1
  4. package/dist/calendar/components/CalendarButtons/CalendarButtons.js +35 -40
  5. package/dist/events/edit-event-modal/IntervalInput.d.ts.map +1 -1
  6. package/dist/events/edit-event-modal/IntervalInput.js +7 -1
  7. package/dist/events/edit-event-modal/component/EditEventForm/EditEventForm.d.ts.map +1 -1
  8. package/dist/events/edit-event-modal/component/EditEventForm/EditEventForm.js +0 -1
  9. package/dist/events/edit-event-modal/component/SelectEventProductSet/SelectEventProductSet.d.ts.map +1 -1
  10. package/dist/events/edit-event-modal/component/SelectEventProductSet/SelectEventProductSet.js +24 -23
  11. package/dist/events/edit-event-modal/utils/getDefaultProductSet.d.ts.map +1 -1
  12. package/dist/events/edit-event-modal/utils/getDefaultProductSet.js +0 -1
  13. package/dist/iframe/event/event-card/IframeEventCard.d.ts.map +1 -1
  14. package/dist/iframe/event/event-card/IframeEventCard.js +2 -2
  15. package/dist/iframe/order-process/components/CategoryProduct/components/ProductQuantityInput/ProductQuantityInput.d.ts.map +1 -1
  16. package/dist/iframe/order-process/components/CategoryProduct/components/ProductQuantityInput/ProductQuantityInput.js +2 -0
  17. package/dist/iframe/payment/order-items-table/utils/paymentSummary.d.ts.map +1 -1
  18. package/dist/index.js +1 -0
  19. package/dist/layout/DropDown.d.ts +2 -1
  20. package/dist/layout/DropDown.d.ts.map +1 -1
  21. package/dist/modals/confirmation/ConfirmModal.d.ts +3 -1
  22. package/dist/modals/confirmation/ConfirmModal.d.ts.map +1 -1
  23. package/dist/modals/confirmation/ConfirmModal.js +172 -8
  24. package/dist/product-set/card/ProductSetCard.d.ts +6 -2
  25. package/dist/product-set/card/ProductSetCard.d.ts.map +1 -1
  26. package/dist/product-set/card/ProductSetCard.js +30 -11
  27. package/dist/product-set/control/DateInput.d.ts.map +1 -1
  28. package/dist/product-set/control/DateInput.js +2 -2
  29. package/dist/product-set/form/ProductCategoriesControl.d.ts.map +1 -1
  30. package/dist/product-set/form/ProductCategoriesControl.js +48 -2
  31. package/dist/product-set/form/ProductSetForm.d.ts +4 -1
  32. package/dist/product-set/form/ProductSetForm.d.ts.map +1 -1
  33. package/dist/product-set/form/ProductSetForm.js +59 -1
  34. package/dist/product-set/form/ProductSetNameControl.d.ts +6 -0
  35. package/dist/product-set/form/ProductSetNameControl.d.ts.map +1 -0
  36. package/dist/product-set/form/ProductSetNameControl.js +35 -0
  37. package/dist/product-set/form/ProductZonesControl.d.ts.map +1 -1
  38. package/dist/product-set/form/ProductZonesControl.js +0 -2
  39. package/dist/product-set/form/SelectCategoryModal.d.ts +12 -0
  40. package/dist/product-set/form/SelectCategoryModal.d.ts.map +1 -1
  41. package/dist/product-set/form/SelectCategoryModal.js +1 -1
  42. package/dist/product-set/form/SubProductsControl.d.ts.map +1 -1
  43. package/dist/product-set/form/SubProductsControl.js +0 -3
  44. package/dist/product-set/form/VenueMapsControl.d.ts.map +1 -1
  45. package/dist/product-set/form/VenueMapsControl.js +0 -3
  46. package/dist/product-set/form/index.d.ts +1 -0
  47. package/dist/product-set/form/index.d.ts.map +1 -1
  48. package/dist/product-set/product/ProductControl.d.ts.map +1 -1
  49. package/dist/product-set/utils/index.d.ts +7 -0
  50. package/dist/product-set/utils/index.d.ts.map +1 -1
  51. package/dist/product-set/utils/index.js +10 -1
  52. package/dist/sales/booking/results/components/ResultCard.d.ts.map +1 -1
  53. package/dist/sales/booking/results/components/ResultCard.js +0 -2
  54. package/dist/snippet/snippet-template/preview/Preview.d.ts.map +1 -1
  55. package/dist/snippet/snippet-template/preview/Preview.js +6 -0
  56. package/dist/sortable-tree/SortableTreeItem.d.ts +2 -1
  57. package/dist/sortable-tree/SortableTreeItem.d.ts.map +1 -1
  58. package/dist/sortable-tree/SortableTreeItem.js +10 -4
  59. package/dist/styles/iframe-events/Calendar.scss +0 -1
  60. package/dist/styles/iframe-external-modal/IframeExternalModal.scss +2 -2
  61. package/dist/styles/product-set/ProductSetForm.scss +22 -0
  62. package/dist/styles/sales/BookingResults.scss +1 -1
  63. package/dist/tiptap-editor/TipTapMenu/extensions/constants.d.ts +2 -0
  64. package/dist/tiptap-editor/TipTapMenu/extensions/constants.d.ts.map +1 -0
  65. package/dist/tiptap-editor/TipTapMenu/extensions/constants.js +3 -0
  66. package/dist/tiptap-editor/TipTapMenu/extensions/utils.d.ts +1 -1
  67. package/dist/tiptap-editor/TipTapMenu/extensions/utils.d.ts.map +1 -1
  68. package/dist/tiptap-editor/TipTapMenu/extensions/utils.js +3 -1
  69. package/dist/typeahead/Typeahead.d.ts +5 -1
  70. package/dist/typeahead/Typeahead.d.ts.map +1 -1
  71. package/dist/typeahead/Typeahead.js +9 -2
  72. package/package.json +9 -7
  73. package/src/affiliate/form/AffiliateForm.tsx +1 -0
  74. package/src/auth/Login/LoginComponent.tsx +1 -1
  75. package/src/calendar/components/CalendarButtons/CalendarButtons.tsx +29 -28
  76. package/src/events/edit-event-modal/IntervalInput.tsx +8 -1
  77. package/src/events/edit-event-modal/component/EditEventForm/EditEventForm.tsx +0 -1
  78. package/src/events/edit-event-modal/component/SelectEventProductSet/SelectEventProductSet.tsx +82 -85
  79. package/src/events/edit-event-modal/utils/getDefaultProductSet.ts +0 -1
  80. package/src/iframe/event/event-card/IframeEventCard.tsx +30 -29
  81. package/src/iframe/order-process/components/CategoryProduct/components/ProductQuantityInput/ProductQuantityInput.tsx +1 -0
  82. package/src/iframe/payment/order-items-table/utils/paymentSummary.tsx +1 -0
  83. package/src/layout/DropDown.tsx +2 -1
  84. package/src/modals/confirmation/ConfirmModal.tsx +19 -3
  85. package/src/product-set/card/ProductSetCard.tsx +47 -8
  86. package/src/product-set/control/DateInput.tsx +2 -1
  87. package/src/product-set/form/ProductCategoriesControl.tsx +37 -1
  88. package/src/product-set/form/ProductSetForm.tsx +17 -2
  89. package/src/product-set/form/ProductSetNameControl.tsx +27 -0
  90. package/src/product-set/form/ProductZonesControl.tsx +1 -4
  91. package/src/product-set/form/SelectCategoryModal.tsx +2 -2
  92. package/src/product-set/form/SubProductsControl.tsx +0 -3
  93. package/src/product-set/form/VenueMapsControl.tsx +0 -3
  94. package/src/product-set/form/index.ts +1 -0
  95. package/src/product-set/product/ProductControl.tsx +0 -1
  96. package/src/product-set/product/advanced-options/AdvancedOptions.tsx +1 -1
  97. package/src/product-set/product-zone/ProductZoneControl.tsx +1 -1
  98. package/src/product-set/utils/index.ts +11 -0
  99. package/src/sales/booking/results/components/ResultCard.tsx +0 -2
  100. package/src/snippet/snippet-template/preview/Preview.tsx +6 -0
  101. package/src/sortable-tree/SortableTreeItem.tsx +6 -0
  102. package/src/styles/iframe-events/Calendar.scss +0 -1
  103. package/src/styles/iframe-external-modal/IframeExternalModal.scss +2 -2
  104. package/src/styles/product-set/ProductSetForm.scss +22 -0
  105. package/src/styles/sales/BookingResults.scss +1 -1
  106. package/src/tiptap-editor/TipTapMenu/extensions/constants.ts +1 -0
  107. package/src/tiptap-editor/TipTapMenu/extensions/utils.ts +4 -1
  108. package/src/typeahead/Typeahead.tsx +15 -1
  109. package/yarn.lock +40 -14
  110. package/dist/assets/iframe/selectArrow.svg.js +0 -17
@@ -5,9 +5,11 @@ import { useId } from '@react-aria/utils'
5
5
  import { Controller, useFormContext } from 'react-hook-form'
6
6
  import { HasPermissionProp } from '@licklist/plugins/dist/types/permission/Permission'
7
7
  import { ProductSet } from '@licklist/core/dist/DataMapper/Product/ProductSetDataMapper'
8
+ import { getTypeHeadItemsFromMenus } from '../../../../product-set/utils'
8
9
  import { ConfirmModal } from '../../../../modals/confirmation/ConfirmModal'
9
10
  import { EditEventFormValues } from '../EditEventForm/EditEventForm'
10
11
  import { EditEventProductSet } from './component/EditEventProductSet'
12
+ import { Typeahead } from '../../../../typeahead'
11
13
 
12
14
  interface SelectEventProductSetProps extends HasPermissionProp {
13
15
  productSets?: ProductSet[]
@@ -42,6 +44,21 @@ export const SelectEventProductSet = ({
42
44
  const productSetId = watch('productSetId')
43
45
  const editedProductSet = watch('editedProductSet')
44
46
 
47
+ const typeheadValues = getTypeHeadItemsFromMenus(
48
+ editedProductSet
49
+ ? productSets.map((productSet) => {
50
+ if (productSet.id === editedProductSet.id) {
51
+ return editedProductSet
52
+ }
53
+
54
+ return productSet
55
+ })
56
+ : productSets,
57
+ )
58
+ const selectedProductSetTypeheadValue = productSetId
59
+ ? typeheadValues?.find((typeheadValue) => typeheadValue.id === productSetId)
60
+ : undefined
61
+
45
62
  const onEditProductSet = useCallback(
46
63
  () => {
47
64
  setEditProductSetId(String(productSetId))
@@ -95,6 +112,7 @@ export const SelectEventProductSet = ({
95
112
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
96
113
  const onSubmit = (value: EditEventFormValues['editedProductSet']) => {
97
114
  setShowEditProductSet(false)
115
+ setValue('productSetId', value.id)
98
116
  setValue('editedProductSet', value)
99
117
  }
100
118
 
@@ -110,93 +128,72 @@ export const SelectEventProductSet = ({
110
128
  <Controller
111
129
  control={control}
112
130
  name="productSetId"
113
- render={({ field }) => {
114
- const fieldValue = String(field.value)
115
- return (
116
- <>
117
- <div className="d-flex align-items-center flex-row w-100">
118
- <ConfirmModal>
119
- {(confirm) => (
120
- <Form.Control
121
- as="select"
122
- onChange={(e) =>
123
- onChangeProductSet(Number(e.target.value), confirm)
124
- }
125
- isInvalid={Boolean(errors.productSetId)}
126
- value={fieldValue}
127
- >
128
- <option value="" hidden>
129
- {t('Design:chooseProductSet')}
130
- </option>
131
- {productSets?.map((productSet) => {
132
- const isCurrentEditedProductSet =
133
- editedProductSet &&
134
- editedProductSet?.id === productSet?.id
135
- return (
136
- <option key={productSet.id} value={productSet.id}>
137
- {isCurrentEditedProductSet ||
138
- productSet.isOverride
139
- ? `[${t('edited')}] ${
140
- isCurrentEditedProductSet
141
- ? editedProductSet?.name
142
- : productSet.name
143
- }`
144
- : productSet.name}
145
- </option>
146
- )
147
- })}
148
- </Form.Control>
149
- )}
150
- </ConfirmModal>
151
-
152
- <div className="buttons-container">
153
- {!showEditProductSet && !editedProductSet && (
154
- <Button
155
- variant=""
156
- className="btn product-set-button mr-4"
157
- onClick={handleCreateProductSet}
158
- >
159
- {t('addNewProductSet')}
160
- </Button>
161
- )}
162
- {showOverrideProductSet && (
163
- <Button
164
- variant=""
165
- className="btn product-set-button "
166
- onClick={onEditProductSet}
167
- >
168
- {isOverrideProductSet
169
- ? t('editOverrides')
170
- : t('editProductSet')}
171
- </Button>
172
- )}
173
- {showEditProductSet && (
174
- <Button
175
- variant=""
176
- className="btn product-set-button"
177
- onClick={revertEditProductSet}
178
- >
179
- {t('cancelAndRevert')}
180
- </Button>
181
- )}
182
- {!showEditProductSet && editedProductSet && (
183
- <Button
184
- variant=""
185
- className="btn product-set-button ml-4 text-danger"
186
- onClick={revertEditProductSet}
187
- >
188
- {t('undoChanges')}
189
- </Button>
190
- )}
191
- </div>
131
+ render={() => (
132
+ <>
133
+ <div className="d-flex align-items-center flex-row w-100">
134
+ <ConfirmModal>
135
+ {(confirm) => (
136
+ <Typeahead
137
+ name="productSetId"
138
+ value={selectedProductSetTypeheadValue}
139
+ containerStyles={{ width: '100%' }}
140
+ onChangeValue={(typeheadValue) => {
141
+ onChangeProductSet(Number(typeheadValue.id), confirm)
142
+ }}
143
+ options={typeheadValues}
144
+ placeholder={t('Design:choose')}
145
+ noOptionsMessage={t('Design:noAvailableProductSets')}
146
+ />
147
+ )}
148
+ </ConfirmModal>
149
+
150
+ <div className="buttons-container">
151
+ {!showEditProductSet && !editedProductSet && (
152
+ <Button
153
+ variant=""
154
+ className="btn product-set-button mr-4"
155
+ onClick={handleCreateProductSet}
156
+ >
157
+ {t('addNewProductSet')}
158
+ </Button>
159
+ )}
160
+ {showOverrideProductSet && (
161
+ <Button
162
+ variant=""
163
+ className="btn product-set-button "
164
+ onClick={onEditProductSet}
165
+ >
166
+ {isOverrideProductSet
167
+ ? t('editOverrides')
168
+ : t('editProductSet')}
169
+ </Button>
170
+ )}
171
+ {showEditProductSet && (
172
+ <Button
173
+ variant=""
174
+ className="btn product-set-button"
175
+ onClick={revertEditProductSet}
176
+ >
177
+ {t('cancelAndRevert')}
178
+ </Button>
179
+ )}
180
+ {!showEditProductSet && editedProductSet && (
181
+ <Button
182
+ variant=""
183
+ className="btn product-set-button ml-4 text-danger"
184
+ onClick={revertEditProductSet}
185
+ >
186
+ {t('undoChanges')}
187
+ </Button>
188
+ )}
192
189
  </div>
190
+ </div>
193
191
 
194
- <Form.Control.Feedback type="invalid">
195
- {errors?.productSetId?.message}
196
- </Form.Control.Feedback>
197
- </>
198
- )
199
- }}
192
+ <Form.Control.Feedback type="invalid">
193
+ {errors?.productSetId?.message}
194
+ </Form.Control.Feedback>
195
+ </>
196
+ )}
200
197
  />
201
198
  </Form.Group>
202
199
  </div>
@@ -37,7 +37,6 @@ export const getDefaultValues = (
37
37
  ...product,
38
38
  subProducts: subProducts?.map(({ ...subProducts }) => ({
39
39
  ...subProducts,
40
- originalProductId: null,
41
40
  productCategoryId: undefined,
42
41
  })),
43
42
  productCategoryId: undefined,
@@ -71,56 +71,56 @@ export function IframeEventCard({
71
71
  className,
72
72
  )}
73
73
  onClick={
74
- goToDetails || !snippetSetting.displayBookingButtonOnEventList
74
+ goToDetails || !snippetSetting?.displayBookingButtonOnEventList
75
75
  ? onClick
76
76
  : undefined
77
77
  }
78
78
  >
79
- {showMoreInfo && <div className="iframe-event-card__info-icon">i</div>}
79
+ {showMoreInfo && <div className='iframe-event-card__info-icon'>i</div>}
80
80
  {imageSrc && (
81
81
  <Card.Img
82
82
  className={imageClassName ?? 'card-image'}
83
- variant="top"
84
- as="div"
83
+ variant='top'
84
+ as='div'
85
85
  style={{ backgroundImage: `url("${imageSrc}")` }}
86
86
  />
87
87
  )}
88
88
  <Card.Body
89
89
  className={clsx('d-flex', 'flex-column', !imageSrc && 'no-image')}
90
90
  >
91
- <Card.Title className="iframe-event-card__title" id={titleId}>
91
+ <Card.Title className='iframe-event-card__title' id={titleId}>
92
92
  {title}
93
93
  </Card.Title>
94
94
 
95
- <div className="flex-grow-1 iframe-event-card__description">
96
- <Card.Text as="div">
97
- <div className="d-flex align-items-center mb-3">
98
- <div className="icon-wrapper">
95
+ <div className='flex-grow-1 iframe-event-card__description'>
96
+ <Card.Text as='div'>
97
+ <div className='d-flex align-items-center mb-3'>
98
+ <div className='icon-wrapper'>
99
99
  <CalendarSvg />
100
100
  </div>
101
- <p className="m-0 list-view-hided">{date}</p>
102
- <p className="m-0 grid-view-hided">{shortDate}</p>
101
+ <p className='m-0 list-view-hided'>{date}</p>
102
+ <p className='m-0 grid-view-hided'>{shortDate}</p>
103
103
  </div>
104
104
  </Card.Text>
105
105
 
106
106
  {type && (
107
- <Card.Text as="div" className="list-view-hided">
108
- <div className="d-flex align-items-center mb-3">
109
- <div className="icon-wrapper">
107
+ <Card.Text as='div' className='list-view-hided'>
108
+ <div className='d-flex align-items-center mb-3'>
109
+ <div className='icon-wrapper'>
110
110
  <ClockSvg />
111
111
  </div>
112
- <p className="m-0">{type}</p>
112
+ <p className='m-0'>{type}</p>
113
113
  </div>
114
114
  </Card.Text>
115
115
  )}
116
116
 
117
117
  {typeof cost === 'number' && (
118
- <Card.Text as="div">
119
- <div className="d-flex align-items-center mb-3">
120
- <div className="icon-wrapper">
118
+ <Card.Text as='div'>
119
+ <div className='d-flex align-items-center mb-3'>
120
+ <div className='icon-wrapper'>
121
121
  <TicketSvg />
122
122
  </div>
123
- <p className="m-0">
123
+ <p className='m-0'>
124
124
  {t('from')}{' '}
125
125
  {formatNumber(cost, { style: 'currency', currency: 'GBP' })}
126
126
  </p>
@@ -129,7 +129,7 @@ export function IframeEventCard({
129
129
  )}
130
130
 
131
131
  {description && (
132
- <Card.Text as="div" className="list-view-hided">
132
+ <Card.Text as='div' className='list-view-hided'>
133
133
  <TipTapEditor
134
134
  viewMode
135
135
  disabled
@@ -138,15 +138,16 @@ export function IframeEventCard({
138
138
  />
139
139
  </Card.Text>
140
140
  )}
141
- {!!snippetSetting.displayBookingButtonOnEventList && showMoreInfo && (
142
- <Button
143
- className="step-save-btn w-25 mt-4"
144
- type="button"
145
- onClick={onClick}
146
- >
147
- {t('book')}
148
- </Button>
149
- )}
141
+ {!!snippetSetting?.displayBookingButtonOnEventList &&
142
+ showMoreInfo && (
143
+ <Button
144
+ className='step-save-btn w-25 mt-4'
145
+ type='button'
146
+ onClick={onClick}
147
+ >
148
+ {t('book')}
149
+ </Button>
150
+ )}
150
151
  </div>
151
152
  </Card.Body>
152
153
  </Card>
@@ -51,6 +51,7 @@ export const ProductQuantityInput = ({
51
51
  hasDeposit: category.allowDeposits && product?.deposit < product.price,
52
52
  price: product.price,
53
53
  productCategoryId: category.id,
54
+ zoneId: category.zone?.id,
54
55
  quantity,
55
56
  capacity: product?.capacity,
56
57
  })
@@ -61,6 +61,7 @@ const processedPaymentSummary = ({
61
61
  const total = calculateTotalPrice(order, externalPaymentDetail)
62
62
 
63
63
  const totalDiscount = calculateTotalDiscount(order.payments)
64
+
64
65
  let summaryItems: SummaryItem[] = [
65
66
  {
66
67
  translateKey: AMOUNT_TOTAL,
@@ -1,4 +1,4 @@
1
- import { forwardRef } from 'react'
1
+ import React, { forwardRef } from 'react'
2
2
 
3
3
  interface Props {
4
4
  children?: React.ReactNode | React.ReactNode[]
@@ -24,4 +24,5 @@ const DropDown = forwardRef((props: Props, ref: any) => {
24
24
  })
25
25
 
26
26
  DropDown.displayName = 'DropDown'
27
+
27
28
  export default DropDown
@@ -20,6 +20,9 @@ export type ConfirmModalTypes =
20
20
  export interface ConfirmModalProps {
21
21
  type?: ConfirmModalTypes
22
22
  children?: (confirm: (action: ConfirmAction) => void) => ReactNode
23
+ // confirm function memoize the callback function. It's an alternative function
24
+ confirmationHandler?: () => Promise<boolean | undefined>
25
+ disabledButtons?: boolean
23
26
  title?: string
24
27
  content?: string | ReactNode
25
28
  onClose?: () => void
@@ -37,7 +40,9 @@ export function ConfirmModal({
37
40
  type = 'default',
38
41
  children,
39
42
  onClose,
43
+ confirmationHandler,
40
44
  title,
45
+ disabledButtons,
41
46
  content,
42
47
  hideButtons = false,
43
48
  }: ConfirmModalProps) {
@@ -52,10 +57,16 @@ export function ConfirmModal({
52
57
  setIsOpen(() => true)
53
58
  }
54
59
 
55
- const handleConfirmation = (e) => {
60
+ const handleConfirmation = async (e) => {
56
61
  e.stopPropagation()
57
- if (!actionRef.current) return
58
-
62
+ if (!actionRef.current && !confirmationHandler) return
63
+ if (confirmationHandler) {
64
+ const res = await confirmationHandler()
65
+ if (res) {
66
+ setIsOpen(() => false)
67
+ }
68
+ return
69
+ }
59
70
  actionRef.current()
60
71
  setIsOpen(() => false)
61
72
  }
@@ -88,6 +99,7 @@ export function ConfirmModal({
88
99
  <Button
89
100
  variant="danger"
90
101
  className="btn-sm rounded"
102
+ disabled={disabledButtons}
91
103
  onClick={handleClose}
92
104
  data-id={CONFIRM_MODAL_ACTION_DECLINE}
93
105
  >
@@ -105,12 +117,14 @@ export function ConfirmModal({
105
117
  variant="outline"
106
118
  className="cancel-button"
107
119
  onClick={handleClose}
120
+ disabled={disabledButtons}
108
121
  data-id={CONFIRM_MODAL_ACTION_DECLINE}
109
122
  >
110
123
  {t('cancel')}
111
124
  </Button>
112
125
  <Button
113
126
  variant="danger"
127
+ disabled={disabledButtons}
114
128
  onClick={handleConfirmation}
115
129
  data-id={CONFIRM_MODAL_ACTION_CONFIRM}
116
130
  >
@@ -121,6 +135,7 @@ export function ConfirmModal({
121
135
  <>
122
136
  <Button
123
137
  variant="danger"
138
+ disabled={disabledButtons}
124
139
  onClick={handleClose}
125
140
  data-id={CONFIRM_MODAL_ACTION_DECLINE}
126
141
  >
@@ -128,6 +143,7 @@ export function ConfirmModal({
128
143
  </Button>
129
144
  <Button
130
145
  variant="success"
146
+ disabled={disabledButtons}
131
147
  onClick={handleConfirmation}
132
148
  data-id={CONFIRM_MODAL_ACTION_CONFIRM}
133
149
  >
@@ -9,15 +9,20 @@ import RouteService from '@licklist/plugins/dist/services/Route/RouteService'
9
9
  import { FaEllipsisH, FaEye, FaTrashAlt } from 'react-icons/fa'
10
10
  import { ConfirmModal } from '../../modals'
11
11
  import { MenuButton } from '../../table/MenuButton'
12
+ import { ProductSetNameControl } from '../form/ProductSetNameControl'
12
13
 
13
14
  export interface ProductSetCardProps extends HasPermissionProp {
14
15
  name: string
15
16
  rrule?: string
16
17
  href: string
17
- onCopy: () => void
18
+ duplicateProductSetName: string
19
+ onChangeDuplicateProductSetName: (value: string) => void
20
+ onCopy: () => Promise<boolean | undefined>
18
21
  onRemove: () => void
22
+ isLoading?: boolean
19
23
  className?: string
20
24
  override?: number
25
+ duplicateProductSetError?: string
21
26
  }
22
27
 
23
28
  export function ProductSetCard({
@@ -26,6 +31,10 @@ export function ProductSetCard({
26
31
  href,
27
32
  onCopy,
28
33
  onRemove,
34
+ onChangeDuplicateProductSetName,
35
+ duplicateProductSetName,
36
+ duplicateProductSetError,
37
+ isLoading,
29
38
  className = '',
30
39
  hasPermission = true,
31
40
  override = 0,
@@ -35,19 +44,23 @@ export function ProductSetCard({
35
44
  const productSetCardClasses = `product-set-card ${className}`
36
45
  const [isOverlayVisibile, setIsOverlayVisible] = useState(false)
37
46
 
47
+ const onCardClick = () => {
48
+ RouteService.redirectTo(href)
49
+ }
38
50
  return (
51
+ // eslint-disable-next-line jsx-a11y/click-events-have-key-events
39
52
  <div
40
53
  role="button"
41
54
  tabIndex={0}
42
55
  className="border-0 product-set-card-wrapper w-100 pb-0"
43
- onClick={() => RouteService.redirectTo(href)}
44
- onKeyUp={() => RouteService.redirectTo(href)}
56
+ onClick={onCardClick}
45
57
  >
46
58
  <div className={productSetCardClasses}>
47
59
  <div className="product-set-card-link">
48
60
  <div className="d-flex flex-column">
49
61
  <div>
50
- {name} {rrule && `(${RRule.fromString(rrule).toText()})`}
62
+ {name}
63
+ {rrule && `(${RRule.fromString(rrule).toText()})`}
51
64
  </div>
52
65
  {!!override && (
53
66
  <div className="h6 bold ml-1">
@@ -79,14 +92,33 @@ export function ProductSetCard({
79
92
  >
80
93
  {hasPermission && (
81
94
  <>
82
- <ListGroup.Item action as="div">
95
+ <ListGroup.Item
96
+ action
97
+ as="div"
98
+ role="button"
99
+ tabIndex={0}
100
+ onClick={(e) => e.stopPropagation()}
101
+ >
83
102
  {Boolean(onCopy) && (
84
- <ConfirmModal>
103
+ <ConfirmModal
104
+ // confirm function memoize the callback function and it leads to bugs
105
+ confirmationHandler={onCopy}
106
+ disabledButtons={isLoading}
107
+ content={
108
+ <ProductSetNameControl
109
+ value={duplicateProductSetName}
110
+ onChange={onChangeDuplicateProductSetName}
111
+ error={duplicateProductSetError}
112
+ />
113
+ }
114
+ >
85
115
  {(confirm) => (
86
116
  <MenuButton
87
117
  onClick={() => {
88
118
  setIsOverlayVisible(false)
89
- confirm(onCopy)
119
+ onChangeDuplicateProductSetName(name)
120
+ // confirm function memoize the callback function and it leads to bugs
121
+ confirm(() => {})
90
122
  }}
91
123
  name={t('duplicate')}
92
124
  className="product-set-card-menu-item-text"
@@ -95,7 +127,14 @@ export function ProductSetCard({
95
127
  </ConfirmModal>
96
128
  )}
97
129
  </ListGroup.Item>
98
- <ListGroup.Item action className="text-danger" as="div">
130
+ <ListGroup.Item
131
+ action
132
+ className="text-danger"
133
+ as="div"
134
+ role="button"
135
+ tabIndex={0}
136
+ onClick={(e) => e.stopPropagation()}
137
+ >
99
138
  {Boolean(onRemove) && (
100
139
  <ConfirmModal>
101
140
  {(confirm) => (
@@ -247,7 +247,8 @@ export const DateInput = ({
247
247
  menuRecurrence={menuRecurrence}
248
248
  onEdit={() => handleOnEdit(menuRecurrence, index)}
249
249
  errorMessage={
250
- errors?.menuRecurrences?.[`${index}`]?.availableTimes?.message
250
+ errors?.menuRecurrences?.[`${index}`]?.availableTimes
251
+ ?.message || errors?.menuRecurrences?.[`${index}`]?.message
251
252
  }
252
253
  />
253
254
  ))}
@@ -8,6 +8,7 @@ import {
8
8
  useFormContext,
9
9
  useWatch,
10
10
  } from 'react-hook-form'
11
+ import { FaBars, FaBowlingBall, FaCalendar, FaTicketAlt } from 'react-icons/fa'
11
12
  import { useTranslation } from 'react-i18next'
12
13
  import { useSensor, MouseSensor } from '@dnd-kit/core'
13
14
  import {
@@ -25,7 +26,11 @@ import { ProductCategoryControl } from '../product-category'
25
26
  import { ProductCategory } from '../types'
26
27
  import { ProductsControl } from './ProductsControl'
27
28
  import { ProductSetFormValues, WithIsLoading } from './ProductSetForm'
28
- import { SelectCategoryModal } from './SelectCategoryModal'
29
+ import {
30
+ SelectCategoryModal,
31
+ CATEGORY_TYPES_NAMES,
32
+ CategoryConfig,
33
+ } from './SelectCategoryModal'
29
34
  import { ProductSetLoadingContext } from './context'
30
35
  import { VenueMapSetModal } from './VenueMapSetModal'
31
36
  import { moveArrayElements, sortArrayByIndex } from '../utils'
@@ -33,6 +38,29 @@ import { useSortableTreeFunctions } from '../hooks/useSortableTreeFunctions'
33
38
  // @TODO not for first release
34
39
  // import Popover from "./ProductSetFormPopover";
35
40
 
41
+ const CATEGORIES_TYPE: Partial<Record<CategoryType, CategoryConfig>> = {
42
+ [CATEGORY_TYPES_NAMES.tickets]: {
43
+ label: 'tickets',
44
+ icon: <FaTicketAlt color="#0e8ce2" size={10} />,
45
+ },
46
+ [CATEGORY_TYPES_NAMES.bookings]: {
47
+ label: 'bookings',
48
+ icon: <FaCalendar color="#0e8ce2" size={10} />,
49
+ },
50
+ [CATEGORY_TYPES_NAMES.menuItems]: {
51
+ label: 'menuItems',
52
+ icon: <FaBars color="#0e8ce2" size={10} />,
53
+ },
54
+ [CATEGORY_TYPES_NAMES.game]: {
55
+ label: 'game',
56
+ icon: <FaBowlingBall color="#0e8ce2" size={10} />,
57
+ },
58
+ [CATEGORY_TYPES_NAMES.fixedDuration]: {
59
+ label: 'fixedDuration',
60
+ icon: <FaCalendar color="#0e8ce2" size={10} />,
61
+ },
62
+ }
63
+
36
64
  interface ProductCategoriesControlProps extends WithIsLoading {
37
65
  stepIndex: number
38
66
  isOverrides?: boolean
@@ -228,6 +256,8 @@ export function ProductCategoriesControl({
228
256
  setIsExpanded(productCategoryId)
229
257
  }
230
258
 
259
+ const categoryType = CATEGORIES_TYPE[productCategory.type]
260
+
231
261
  return (
232
262
  <Controller
233
263
  key={`product-category-${productCategory._id}`}
@@ -272,6 +302,12 @@ export function ProductCategoriesControl({
272
302
  )}
273
303
  modalClass={ProductSetModalClasses.category}
274
304
  isNewAdded={showCategoryModal}
305
+ itemButton={
306
+ <div className="btn-outline-primary item-icon sm border border-primary rounded-sm">
307
+ {categoryType.icon}
308
+ <span className="ml-2">{t(categoryType.label)}</span>
309
+ </div>
310
+ }
275
311
  body={
276
312
  <ProductCategoryControl
277
313
  isLoading={isLoading}