@licklist/design 0.71.18-dev.18 → 0.71.18-dev.3

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 (135) hide show
  1. package/dist/events/edit-event-modal/IntervalInput.d.ts +1 -3
  2. package/dist/events/edit-event-modal/IntervalInput.d.ts.map +1 -1
  3. package/dist/events/edit-event-modal/IntervalInput.js +4 -11
  4. package/dist/events/edit-event-modal/component/EditEventForm/EditEventForm.d.ts +1 -3
  5. package/dist/events/edit-event-modal/component/EditEventForm/EditEventForm.d.ts.map +1 -1
  6. package/dist/events/edit-event-modal/component/EditEventForm/EditEventForm.js +3 -14
  7. package/dist/events/edit-event-modal/component/SelectEventProductSet/component/EditEventProductSet.js +0 -1
  8. package/dist/events/edit-recurrent-event-modal/EditRecurrentEventModal.d.ts +1 -5
  9. package/dist/events/edit-recurrent-event-modal/EditRecurrentEventModal.d.ts.map +1 -1
  10. package/dist/events/edit-recurrent-event-modal/EditRecurrentEventModal.js +3 -5
  11. package/dist/events/event-statistic-modal/utils/index.js +3 -3
  12. package/dist/iframe/event/ticket-description/TicketDescription.d.ts +1 -3
  13. package/dist/iframe/event/ticket-description/TicketDescription.d.ts.map +1 -1
  14. package/dist/iframe/event/ticket-description/TicketDescription.js +7 -10
  15. package/dist/iframe/order-process/components/BookingSummary/BookingSummary.d.ts +1 -1
  16. package/dist/iframe/order-process/components/BookingSummary/BookingSummary.d.ts.map +1 -1
  17. package/dist/iframe/order-process/components/BookingSummary/BookingSummary.js +1 -2
  18. package/dist/iframe/order-process/components/BookingSummary/components/ProductSummary/ProductSummary.d.ts +1 -5
  19. package/dist/iframe/order-process/components/BookingSummary/components/ProductSummary/ProductSummary.d.ts.map +1 -1
  20. package/dist/iframe/order-process/components/BookingSummary/components/ProductSummary/ProductSummary.js +1 -12
  21. package/dist/iframe/order-process/components/BookingSummary/types/index.d.ts +0 -1
  22. package/dist/iframe/order-process/components/BookingSummary/types/index.d.ts.map +1 -1
  23. package/dist/iframe/order-process/components/BookingSummary/utils/index.d.ts +0 -4
  24. package/dist/iframe/order-process/components/BookingSummary/utils/index.d.ts.map +1 -1
  25. package/dist/iframe/order-process/components/BookingSummary/utils/index.js +2 -29
  26. package/dist/iframe/order-process/components/CategoryProduct/CategoryProduct.d.ts.map +1 -1
  27. package/dist/iframe/order-process/components/CategoryProduct/CategoryProduct.js +2 -106
  28. package/dist/iframe/order-process/components/CategoryProduct/components/ProductQuantityInput/ProductQuantityInput.d.ts +1 -3
  29. package/dist/iframe/order-process/components/CategoryProduct/components/ProductQuantityInput/ProductQuantityInput.d.ts.map +1 -1
  30. package/dist/iframe/order-process/components/CategoryProduct/components/ProductQuantityInput/ProductQuantityInput.js +1 -95
  31. package/dist/iframe/payment/order-items-table/hooks/useTableData.d.ts.map +1 -1
  32. package/dist/iframe/payment/order-items-table/hooks/useTableData.js +10 -83
  33. package/dist/iframe/payment/order-items-table/utils/index.d.ts.map +1 -1
  34. package/dist/iframe/payment/order-items-table/utils/index.js +0 -15
  35. package/dist/iframe/payment/order-items-table/utils/paymentSummary.js +2 -2
  36. package/dist/iframe/payment/payment-page/PaymentPage.d.ts.map +1 -1
  37. package/dist/iframe/payment/payment-page/PaymentPage.js +1 -4
  38. package/dist/index.js +1 -1
  39. package/dist/product-set/form/ProductSetForm.d.ts +1 -3
  40. package/dist/product-set/form/ProductSetForm.d.ts.map +1 -1
  41. package/dist/product-set/form/ProductSetForm.js +4 -6
  42. package/dist/product-set/form/ProductsControl.d.ts.map +1 -1
  43. package/dist/product-set/form/ProductsControl.js +5 -24
  44. package/dist/product-set/form/context.d.ts +1 -3
  45. package/dist/product-set/form/context.d.ts.map +1 -1
  46. package/dist/product-set/form/context.js +1 -2
  47. package/dist/product-set/product/ProductControl.d.ts +0 -8
  48. package/dist/product-set/product/ProductControl.d.ts.map +1 -1
  49. package/dist/product-set/product/ProductControl.js +1 -25
  50. package/dist/product-set/utils/index.d.ts +0 -88
  51. package/dist/product-set/utils/index.d.ts.map +1 -1
  52. package/dist/product-set/utils/index.js +1 -19
  53. package/dist/recurrence-input/RecurrenceInput.d.ts.map +1 -1
  54. package/dist/sales/coupon/utils/index.d.ts +1 -2
  55. package/dist/sales/coupon/utils/index.d.ts.map +1 -1
  56. package/dist/styles/date-time-button/DateTimeButton.scss +0 -7
  57. package/dist/styles/events/EditEventModal.scss +0 -2
  58. package/dist/styles/iframe-page/Page.scss +0 -16
  59. package/dist/styles/iframe-page/PageBody.scss +0 -4
  60. package/dist/styles/modals/Modals.scss +0 -16
  61. package/dist/styles/product-set/EditProductSetElement.scss +0 -1
  62. package/dist/styles/product-set/ProductSetForm.scss +0 -11
  63. package/dist/styles/sales/ManualBooking.scss +0 -6
  64. package/dist/styles/themes/bookedit/index.scss +0 -19
  65. package/package.json +6 -6
  66. package/src/events/edit-event-modal/IntervalInput.tsx +3 -13
  67. package/src/events/edit-event-modal/component/EditEventForm/EditEventForm.tsx +1 -16
  68. package/src/events/edit-recurrent-event-modal/EditRecurrentEventModal.tsx +1 -9
  69. package/src/events/event-statistic-modal/utils/index.ts +4 -4
  70. package/src/iframe/event/ticket-description/TicketDescription.tsx +4 -11
  71. package/src/iframe/order-process/components/BookingSummary/BookingSummary.tsx +0 -2
  72. package/src/iframe/order-process/components/BookingSummary/components/ProductSummary/ProductSummary.tsx +2 -24
  73. package/src/iframe/order-process/components/BookingSummary/types/index.ts +0 -1
  74. package/src/iframe/order-process/components/BookingSummary/utils/index.ts +1 -42
  75. package/src/iframe/order-process/components/CategoryProduct/CategoryProduct.tsx +75 -155
  76. package/src/iframe/order-process/components/CategoryProduct/components/ProductQuantityInput/ProductQuantityInput.tsx +1 -58
  77. package/src/iframe/payment/order-items-table/hooks/useTableData.tsx +14 -84
  78. package/src/iframe/payment/order-items-table/utils/index.ts +0 -23
  79. package/src/iframe/payment/order-items-table/utils/paymentSummary.tsx +2 -2
  80. package/src/iframe/payment/payment-page/PaymentPage.tsx +10 -8
  81. package/src/product-set/form/ProductSetForm.tsx +3 -11
  82. package/src/product-set/form/ProductsControl.tsx +15 -33
  83. package/src/product-set/form/context.tsx +0 -5
  84. package/src/product-set/product/ProductControl.tsx +1 -37
  85. package/src/product-set/utils/index.ts +0 -19
  86. package/src/recurrence-input/RecurrenceInput.tsx +5 -3
  87. package/src/sales/coupon/utils/index.ts +3 -5
  88. package/src/styles/date-time-button/DateTimeButton.scss +0 -7
  89. package/src/styles/events/EditEventModal.scss +0 -2
  90. package/src/styles/iframe-page/Page.scss +0 -16
  91. package/src/styles/iframe-page/PageBody.scss +0 -4
  92. package/src/styles/modals/Modals.scss +0 -16
  93. package/src/styles/product-set/EditProductSetElement.scss +0 -1
  94. package/src/styles/product-set/ProductSetForm.scss +0 -11
  95. package/src/styles/sales/ManualBooking.scss +0 -6
  96. package/src/styles/themes/bookedit/index.scss +0 -19
  97. package/yarn.lock +376 -377
  98. package/dist/iframe/ProductWithModifierModal/ModifierSetModal/ProductWithModifierSetForm.d.ts +0 -18
  99. package/dist/iframe/ProductWithModifierModal/ModifierSetModal/ProductWithModifierSetForm.d.ts.map +0 -1
  100. package/dist/iframe/ProductWithModifierModal/ModifierSetModal/ProductWithModifierSetForm.js +0 -295
  101. package/dist/iframe/ProductWithModifierModal/ModifierSetModal/ProductWithModifierSetModal.d.ts +0 -15
  102. package/dist/iframe/ProductWithModifierModal/ModifierSetModal/ProductWithModifierSetModal.d.ts.map +0 -1
  103. package/dist/iframe/ProductWithModifierModal/ModifierSetModal/ProductWithModifierSetModal.js +0 -90
  104. package/dist/iframe/ProductWithModifierModal/ModifierSetModal/controll/ModifierSetControll.d.ts +0 -14
  105. package/dist/iframe/ProductWithModifierModal/ModifierSetModal/controll/ModifierSetControll.d.ts.map +0 -1
  106. package/dist/iframe/ProductWithModifierModal/ModifierSetModal/controll/ModifierSetControll.js +0 -404
  107. package/dist/iframe/ProductWithModifierModal/ModifierSetModal/controll/ProductControll.d.ts +0 -10
  108. package/dist/iframe/ProductWithModifierModal/ModifierSetModal/controll/ProductControll.d.ts.map +0 -1
  109. package/dist/iframe/ProductWithModifierModal/ModifierSetModal/controll/ProductControll.js +0 -87
  110. package/dist/iframe/ProductWithModifierModal/ModifierSetModal/index.d.ts +0 -2
  111. package/dist/iframe/ProductWithModifierModal/ModifierSetModal/index.d.ts.map +0 -1
  112. package/dist/iframe/ProductWithModifierModal/index.d.ts +0 -2
  113. package/dist/iframe/ProductWithModifierModal/index.d.ts.map +0 -1
  114. package/dist/iframe/ProductWithModifierModal/utils.d.ts +0 -5
  115. package/dist/iframe/ProductWithModifierModal/utils.d.ts.map +0 -1
  116. package/dist/iframe/ProductWithModifierModal/utils.js +0 -21
  117. package/dist/iframe/order-process/components/CategoryProduct/components/ProductWithModifier/ProductWithModifier.d.ts +0 -23
  118. package/dist/iframe/order-process/components/CategoryProduct/components/ProductWithModifier/ProductWithModifier.d.ts.map +0 -1
  119. package/dist/iframe/order-process/components/CategoryProduct/components/ProductWithModifier/ProductWithModifier.js +0 -62
  120. package/dist/iframe/order-process/components/CategoryProduct/constants.d.ts +0 -2
  121. package/dist/iframe/order-process/components/CategoryProduct/constants.d.ts.map +0 -1
  122. package/dist/iframe/order-process/components/CategoryProduct/constants.js +0 -4
  123. package/dist/iframe/order-process/components/utils/useOnWindowUnmount.d.ts +0 -6
  124. package/dist/iframe/order-process/components/utils/useOnWindowUnmount.d.ts.map +0 -1
  125. package/dist/iframe/order-process/components/utils/useOnWindowUnmount.js +0 -18
  126. package/src/iframe/ProductWithModifierModal/ModifierSetModal/ProductWithModifierSetForm.tsx +0 -212
  127. package/src/iframe/ProductWithModifierModal/ModifierSetModal/ProductWithModifierSetModal.tsx +0 -76
  128. package/src/iframe/ProductWithModifierModal/ModifierSetModal/controll/ModifierSetControll.tsx +0 -393
  129. package/src/iframe/ProductWithModifierModal/ModifierSetModal/controll/ProductControll.tsx +0 -98
  130. package/src/iframe/ProductWithModifierModal/ModifierSetModal/index.ts +0 -1
  131. package/src/iframe/ProductWithModifierModal/index.ts +0 -1
  132. package/src/iframe/ProductWithModifierModal/utils.ts +0 -29
  133. package/src/iframe/order-process/components/CategoryProduct/components/ProductWithModifier/ProductWithModifier.tsx +0 -86
  134. package/src/iframe/order-process/components/CategoryProduct/constants.ts +0 -1
  135. package/src/iframe/order-process/components/utils/useOnWindowUnmount.ts +0 -25
@@ -65,8 +65,6 @@ export interface EditEventFormProps extends HasPermissionProp {
65
65
  timeZone: string
66
66
  eventProductSet?: ProductSet
67
67
  overrideNameError?: string
68
- disabledRecurrent?: boolean
69
- isCopyCreate?: boolean
70
68
  }
71
69
 
72
70
  const eventImageTypes = {
@@ -89,8 +87,6 @@ export const EditEventForm = ({
89
87
  timeZone,
90
88
  eventProductSet,
91
89
  overrideNameError,
92
- disabledRecurrent = false,
93
- isCopyCreate = false,
94
90
  }: EditEventFormProps) => {
95
91
  const { t } = useTranslation(['Design', 'Validation'])
96
92
 
@@ -130,7 +126,7 @@ export const EditEventForm = ({
130
126
  const visible = watch('visible')
131
127
  const editedProductSet = watch('editedProductSet')
132
128
  const productSetId = watch('productSetId')
133
- const rrule = watch('rrule')
129
+
134
130
  const {
135
131
  images,
136
132
  handleImageRemove,
@@ -183,15 +179,6 @@ export const EditEventForm = ({
183
179
  // eslint-disable-next-line react-hooks/exhaustive-deps
184
180
  }, [])
185
181
 
186
- const defaultExDate = defaultEventValues?.rrule?.includes('EXDATE')
187
- ? defaultEventValues?.rrule?.split(';EXDATE=')[1]
188
- : ''
189
-
190
- useEffect(() => {
191
- if (!defaultExDate || rrule?.includes('EXDATE')) return
192
- rrule && setValue('rrule', rrule?.concat(`;EXDATE=${defaultExDate}`))
193
- }, [defaultExDate, rrule])
194
-
195
182
  return (
196
183
  <>
197
184
  <Dialog
@@ -286,9 +273,7 @@ export const EditEventForm = ({
286
273
  disabled={disabled}
287
274
  productSetId={productSetId}
288
275
  productSets={productSets}
289
- disabledRecurrent={disabledRecurrent}
290
276
  editedProductSet={editedProductSet}
291
- isCopyCreate={isCopyCreate}
292
277
  />
293
278
  {categories.length !== 0 && (
294
279
  <Form.Group>
@@ -21,10 +21,6 @@ export const RECURRENT_MODE_TYPES_LIST = {
21
21
  [MODE_ALL_EVENTS]: 3,
22
22
  }
23
23
 
24
- export const RECURRENT_MODE_TYPES_WITHOUT_ALL = {
25
- [MODE_THIS_EVENT]: 1,
26
- }
27
-
28
24
  export type RecurrentEventMode = (typeof MODES)[number]
29
25
 
30
26
  export type EditRecurrentEventModalValues = {
@@ -37,7 +33,6 @@ export type EditRecurrentEventModalProps = {
37
33
  onHide: () => void
38
34
  title: string
39
35
  onSubmit: (values: EditRecurrentEventModalValues) => void
40
- isDateWasChanged?: boolean
41
36
  }
42
37
 
43
38
  export const EditRecurrentEventModal = ({
@@ -46,7 +41,6 @@ export const EditRecurrentEventModal = ({
46
41
  onHide,
47
42
  title,
48
43
  onSubmit,
49
- isDateWasChanged = false
50
44
  }: EditRecurrentEventModalProps) => {
51
45
  const { t } = useTranslation('Design')
52
46
 
@@ -56,8 +50,6 @@ export const EditRecurrentEventModal = ({
56
50
  },
57
51
  })
58
52
 
59
- const recurrentListMode = isDateWasChanged? RECURRENT_MODE_TYPES_WITHOUT_ALL : RECURRENT_MODE_TYPES_LIST
60
-
61
53
  return (
62
54
  <Modal
63
55
  show={isOpen}
@@ -83,7 +75,7 @@ export const EditRecurrentEventModal = ({
83
75
  <Controller
84
76
  render={({ field: { value, onChange } }) => (
85
77
  <>
86
- {Object.keys(recurrentListMode).map((option) => (
78
+ {Object.keys(RECURRENT_MODE_TYPES_LIST).map((option) => (
87
79
  <Form.Check
88
80
  type='radio'
89
81
  id={option}
@@ -33,15 +33,15 @@ export const convertEventStatisticToTableData = (
33
33
  return []
34
34
  }
35
35
 
36
- const summaryFormattedDate = DateTime.fromISO(date).toFormat(
37
- DATE_TIME_FULL_FORMAT,
38
- )
36
+ const summaryFormattedDate = DateTime.fromISO(date)
37
+ .toUTC()
38
+ .toFormat(DATE_FORMAT)
39
39
 
40
40
  const summaryDays =
41
41
  Object.keys(eventStatistic?.productCategorySummary)?.filter(
42
42
  (date) =>
43
43
  DateTime.fromFormat(date, DATE_TIME_FULL_FORMAT).toFormat(
44
- DATE_TIME_FULL_FORMAT,
44
+ DATE_FORMAT,
45
45
  ) === summaryFormattedDate,
46
46
  ) ?? []
47
47
 
@@ -12,12 +12,10 @@ interface TicketDescriptionProps {
12
12
  title: string
13
13
  description: string
14
14
  className?: string
15
- classNameProductModal?: string
16
15
  images: Image[] | null
17
16
  price?: ReactNode
18
17
  isRequired?: boolean
19
18
  canExpand?: boolean
20
- isModal?: boolean
21
19
  }
22
20
 
23
21
  const DESCRIPTION_MAX_LENGTH = 120
@@ -26,12 +24,10 @@ export function TicketDescription({
26
24
  title,
27
25
  description,
28
26
  className = '',
29
- classNameProductModal = '',
30
27
  images,
31
28
  price,
32
29
  isRequired = false,
33
30
  canExpand = true,
34
- isModal= false
35
31
  }: TicketDescriptionProps) {
36
32
  const [isDescriptionExpanded, setIsDescriptionExpanded] = useState(false)
37
33
 
@@ -51,10 +47,10 @@ export function TicketDescription({
51
47
  className='ticket-description__wrapper'
52
48
  style={descriptionWrapperStyle}
53
49
  >
54
- <div className={clsx('ticket-description__wrapper-children', classNameProductModal)}>
50
+ <div className='ticket-description__wrapper-children'>
55
51
  {imageSrc && (
56
- <div className={clsx('image-wrapper', classNameProductModal && 'w-100 h-25')}>
57
- <img className={clsx(classNameProductModal && 'w-100')} src={imageSrc} alt={title} />
52
+ <div className='image-wrapper'>
53
+ <img src={imageSrc} alt={title} />
58
54
  </div>
59
55
  )}
60
56
  {canExpand && description.length > DESCRIPTION_MAX_LENGTH ? (
@@ -67,7 +63,6 @@ export function TicketDescription({
67
63
  title={title}
68
64
  isRequired={isRequired}
69
65
  description={description}
70
- isModal={isModal}
71
66
  />
72
67
  </TextExpand>
73
68
  ) : (
@@ -75,7 +70,6 @@ export function TicketDescription({
75
70
  title={title}
76
71
  isRequired={isRequired}
77
72
  description={description}
78
- isModal={isModal}
79
73
  />
80
74
  )}
81
75
  </div>
@@ -89,9 +83,8 @@ const Description = ({
89
83
  title,
90
84
  isRequired,
91
85
  description,
92
- isModal
93
86
  }: Pick<TicketDescriptionProps, 'title' | 'isRequired' | 'description'>) => (
94
- <div className={clsx('description-content', isModal && 'ml-4 mt-2' )}>
87
+ <div className='description-content'>
95
88
  <div className='d-flex flex-column'>
96
89
  <div className='product-title'>
97
90
  {title} {isRequired && <span>*</span>}
@@ -17,7 +17,6 @@ export const BookingSummary = ({
17
17
  formValues = {},
18
18
  shouldHidePeopleAmount,
19
19
  eventName,
20
- headerTitle,
21
20
  transactionFee = 0,
22
21
  productsWithErrors = [],
23
22
  isLoading,
@@ -44,7 +43,6 @@ export const BookingSummary = ({
44
43
  <BookingSummaryAccordion
45
44
  isPaymentPage={isPaymentPage}
46
45
  hasPeopleInput={hasPeopleInput}
47
- title={headerTitle}
48
46
  headerComponent={headerComponent}
49
47
  >
50
48
  <div className='event-info'>
@@ -2,19 +2,11 @@ import { useTranslation } from 'react-i18next'
2
2
  import { useIntl } from 'react-intl'
3
3
  import * as Config from '@licklist/core/dist/Config'
4
4
  import { OrderItem } from '@licklist/plugins/dist/types/context/Iframe/orderItems'
5
- import { OrderModifierByProduct } from '@licklist/core/dist/DataMapper/Order/OrderModifiierByProduct'
6
- import { calculateTotalModifiersPrice } from '../../utils'
7
- import { ProductWithModifier } from '../../../CategoryProduct/components/ProductWithModifier/ProductWithModifier'
8
-
9
-
10
- interface IOrderProduct extends OrderItem {
11
- orderProductModifiers?: OrderModifierByProduct[] | null;
12
- }
13
5
 
14
6
  type ProductSummaryProps = {
15
7
  name?: string
16
8
  productQuantityError?: string
17
- orderProduct: IOrderProduct
9
+ orderProduct: OrderItem
18
10
  }
19
11
 
20
12
  export const ProductSummary = ({
@@ -24,9 +16,8 @@ export const ProductSummary = ({
24
16
  }: ProductSummaryProps) => {
25
17
  const { t } = useTranslation('Design')
26
18
  const { formatNumber } = useIntl()
27
- const priceForOneProduct = orderProduct?.price
28
19
 
29
- const modifiersSets = orderProduct?.orderModifiersSets || orderProduct?.orderProductModifiers
20
+ const priceForOneProduct = orderProduct?.price
30
21
 
31
22
  const fullPrice = formatNumber(priceForOneProduct * orderProduct?.quantity, {
32
23
  style: 'currency',
@@ -44,19 +35,6 @@ export const ProductSummary = ({
44
35
  <p className='price'>{fullPrice}</p>
45
36
  </div>
46
37
 
47
- {!!modifiersSets.length && (
48
- <>
49
- {modifiersSets.map((modifier, index) => (
50
- <ProductWithModifier
51
- key={modifier.productQuantity.toString()}
52
- modifier={modifier}
53
- modifierKey={index}
54
- isSummary
55
- />
56
- ))}
57
- </>
58
- )}
59
-
60
38
  {productQuantityError && (
61
39
  <p className='iframe-event__message-error'>{productQuantityError}</p>
62
40
  )}
@@ -24,5 +24,4 @@ export type BookingSummaryProps = {
24
24
  isPaymentPage?: boolean
25
25
  headerComponent?: ReactElement
26
26
  footer?: ReactElement
27
- headerTitle?: string
28
27
  }
@@ -1,7 +1,3 @@
1
- import { OrderModifier } from '@licklist/core/dist/DataMapper/Order/OrderModifierDataMapper'
2
- import {
3
- OrderModifierByProduct
4
- } from '@licklist/core/dist/DataMapper/Order/OrderModifiierByProduct'
5
1
  import { QuantityCheckProductInfo } from '@licklist/plugins/dist/types/Api/verifyStock'
6
2
  import { OrderItem } from '@licklist/plugins/dist/types/context/Iframe/orderItems'
7
3
 
@@ -17,9 +13,6 @@ export const cartSumByOrderProducts = ({
17
13
  }
18
14
  return orderProducts.reduce((prevSumValue: number, product) => {
19
15
  if (!product) return 0
20
- const modifiersPrice = calculateTotalModifiersPrice(
21
- product?.orderModifiersSets,
22
- )
23
16
 
24
17
  const price = isTotalSum
25
18
  ? product?.price
@@ -27,44 +20,10 @@ export const cartSumByOrderProducts = ({
27
20
  ? product?.deposit
28
21
  : product?.price
29
22
 
30
- return prevSumValue + price * product.quantity + modifiersPrice
23
+ return prevSumValue + price * product.quantity
31
24
  }, 0)
32
25
  }
33
26
 
34
- export const getModifierName = (
35
- modifier: OrderModifierByProduct,
36
- ) => {
37
- const modifierName = (orderModifier: OrderModifier) => orderModifier?.modifier?.name ?? orderModifier?.name
38
- return `${modifier.modifiers.map((item) => (
39
- item?.quantity > 1 ? `${item?.quantity}x - ${modifierName(item)}` : modifierName(item))).join(', ')}`
40
- }
41
-
42
- export const calculateTotalModifiersPrice = (
43
- orderModifiersSets: OrderModifierByProduct[],
44
- ) =>
45
- orderModifiersSets
46
- ?.map((set) =>
47
- set.modifiers.reduce(
48
- (sum, modifier) =>
49
- sum + modifier.price * modifier.quantity * set.productQuantity,
50
- 0,
51
- ),
52
- )
53
- .reduce((total, setTotal) => total + setTotal, 0)
54
-
55
- export const getOrderProductModifiersPrice = (
56
- modifierFromProduct: OrderModifierByProduct,
57
- ) => {
58
- const { modifiers, productQuantity } = modifierFromProduct
59
- const modifiersPrices = modifiers.reduce(
60
- (prevSumModifier: number, modifier: OrderModifier) =>
61
- prevSumModifier + modifier.price * modifier.quantity,
62
- 0,
63
- )
64
-
65
- return modifiersPrices * productQuantity
66
- }
67
-
68
27
  export const getProductError = (
69
28
  productsWithErrors: QuantityCheckProductInfo[],
70
29
  productId: OrderItem['id'],
@@ -1,4 +1,4 @@
1
- import { useEffect, useMemo, useState } from 'react'
1
+ import { useEffect, useMemo } from 'react'
2
2
  import { useFormContext, Controller } from 'react-hook-form'
3
3
  import clsx from 'clsx'
4
4
  import { useTranslation } from 'react-i18next'
@@ -10,14 +10,8 @@ import {
10
10
  Product,
11
11
  ProductCategory,
12
12
  } from '@licklist/plugins/dist/types/context/sale/menuSteps'
13
- import { Button } from 'react-bootstrap'
14
- import { FaTrashAlt } from 'react-icons/fa'
15
- import { ProductWithModifierSetModal } from 'src/iframe/ProductWithModifierModal'
16
- import { OrderModifierByProduct } from '@licklist/core/dist/DataMapper/Order/OrderModifiierByProduct'
17
13
  import { TicketDescription } from '../../../event/ticket-description'
18
14
  import { ProductQuantityInput } from './components/ProductQuantityInput'
19
- import { FormOrderItem } from './components/ProductQuantityInput/ProductQuantityInput'
20
- import { ProductWithModifier } from './components/ProductWithModifier/ProductWithModifier'
21
15
 
22
16
  interface CategoryProductProps {
23
17
  product: Product
@@ -37,9 +31,7 @@ export const CategoryProduct = ({
37
31
  const { formatNumber } = useIntl()
38
32
  const { t } = useTranslation(['Design', 'Validation'])
39
33
  const { control, clearErrors, setError } = useFormContext()
40
- const [editOrderModifierIndex, setEditOrderModifierIndex] =
41
- useState<OrderModifierByProduct>(undefined)
42
- const [modifierIndex, setModifierIndex] = useState<number>(undefined)
34
+
43
35
  const hasDeposits = category.allowDeposits && product?.deposit < product.price
44
36
 
45
37
  const productQuantityError = useMemo(() => {
@@ -126,155 +118,83 @@ export const CategoryProduct = ({
126
118
  render={({
127
119
  field: { onChange, value: productInfo = {}, ref },
128
120
  fieldState: { invalid, error },
129
- }) => {
130
- const deleteOrderModifier = (orderModifierIndex: number) => {
131
- const removedOrderModifierIndex = (
132
- productInfo as FormOrderItem
133
- ).orderModifiersSets?.filter(
134
- (_, index) => index !== orderModifierIndex,
135
- )
136
- const productInfoWithRemove = {
137
- ...productInfo,
138
- orderModifiersSets: removedOrderModifierIndex,
139
- quantity: removedOrderModifierIndex.reduce(
140
- (acc, product) => product.productQuantity + acc,
141
- 0,
142
- ),
143
- }
144
- onChange(productInfoWithRemove)
145
- }
146
-
147
- const editOrderModifierSet = (orderModifierIndex: number) => {
148
- const editOrderModifierIndex = (
149
- productInfo as FormOrderItem
150
- ).orderModifiersSets.find((_, index) => {
151
- setModifierIndex(index)
152
- return index === orderModifierIndex
153
- })
154
- setEditOrderModifierIndex(editOrderModifierIndex)
155
- }
156
-
157
- const onChangeWithModifierSets = (value: FormOrderItem) => {
158
- const editedOrderModifiersSets = (
159
- productInfo as FormOrderItem
160
- ).orderModifiersSets
161
- ?.filter((_, index) => index !== modifierIndex)
162
- .concat(value.orderModifiersSets)
163
-
164
- onChange({
165
- ...value,
166
- orderModifiersSets: editedOrderModifiersSets,
167
- quantity: editedOrderModifiersSets.reduce(
168
- (acc, product) => product.productQuantity + acc,
169
- 0,
170
- ),
171
- })
172
- setEditOrderModifierIndex(undefined)
173
- }
174
-
175
- return (
176
- <div
177
- id={String(product.id)}
178
- className='iframe-event__category-product'
179
- >
180
- <div className={clsx('iframe-event__product', invalid && 'error')}>
181
- <TicketDescription
182
- title={product.name}
183
- description={product.description}
184
- className={clsx('iframe-event__product-description')}
185
- images={product.images}
186
- isRequired={product.isRequired}
187
- canExpand={canExpandDescription}
188
- />
121
+ }) => (
122
+ <div id={String(product.id)} className='iframe-event__category-product'>
123
+ <div className={clsx('iframe-event__product', invalid && 'error')}>
124
+ <TicketDescription
125
+ title={product.name}
126
+ description={product.description}
127
+ className={clsx('iframe-event__product-description')}
128
+ images={product.images}
129
+ isRequired={product.isRequired}
130
+ canExpand={canExpandDescription}
131
+ />
132
+ </div>
133
+ <div className='iframe-event__product-price-wrapper'>
134
+ <span className='product-price'>
135
+ {formatNumber(product.price, {
136
+ style: 'currency',
137
+ currency: Config.Currency.GBP,
138
+ })}
139
+ </span>
140
+ <ProductQuantityInput
141
+ onChange={onChange}
142
+ productInfo={productInfo}
143
+ refCallback={ref}
144
+ clearErrors={clearErrors}
145
+ product={{
146
+ ...product,
147
+ isSoldOut: product?.isSoldOut || checkIfSoldOutProduct(),
148
+ }}
149
+ category={category}
150
+ invalid={invalid}
151
+ />
152
+ </div>
153
+ {hasDeposits && !category?.remainderExpireAfter && (
154
+ <div className='mt-4'>
155
+ {t('Design:payNowAndUponArrival', {
156
+ deposit: formatNumber(product?.deposit, {
157
+ style: 'currency',
158
+ currency: Config.Currency.GBP,
159
+ }),
160
+ remainder: formatNumber(product.price - product?.deposit, {
161
+ style: 'currency',
162
+ currency: Config.Currency.GBP,
163
+ }),
164
+ })}
189
165
  </div>
190
- <div className='iframe-event__product-price-wrapper'>
191
- <span className='product-price'>
192
- {formatNumber(product.price, {
166
+ )}
167
+
168
+ {hasDeposits && category?.remainderExpireAfter > 0 && (
169
+ <div className='mt-4'>
170
+ {t('Design:payNowAndReminderDays', {
171
+ deposit: formatNumber(product?.deposit, {
172
+ style: 'currency',
173
+ currency: Config.Currency.GBP,
174
+ }),
175
+ remainder: formatNumber(product.price - product?.deposit, {
193
176
  style: 'currency',
194
177
  currency: Config.Currency.GBP,
195
- })}
196
- </span>
197
- <ProductQuantityInput
198
- onChange={onChange}
199
- productInfo={productInfo}
200
- refCallback={ref}
201
- clearErrors={clearErrors}
202
- product={{
203
- ...product,
204
- isSoldOut: product?.isSoldOut || checkIfSoldOutProduct(),
205
- }}
206
- category={category}
207
- invalid={invalid}
208
- />
178
+ }),
179
+ days: category?.remainderExpireAfter,
180
+ })}
209
181
  </div>
210
- {hasDeposits && !category?.remainderExpireAfter && (
211
- <div className='mt-4'>
212
- {t('Design:payNowAndUponArrival', {
213
- deposit: formatNumber(product?.deposit, {
214
- style: 'currency',
215
- currency: Config.Currency.GBP,
216
- }),
217
- remainder: formatNumber(product.price - product?.deposit, {
218
- style: 'currency',
219
- currency: Config.Currency.GBP,
220
- }),
221
- })}
222
- </div>
223
- )}
224
- {(productInfo as FormOrderItem).orderModifiersSets?.length > 0 && (
225
- <>
226
- {(productInfo as FormOrderItem).orderModifiersSets.map(
227
- (modifier, index) => (
228
- <ProductWithModifier
229
- key={modifier.productQuantity.toString()}
230
- modifier={modifier}
231
- modifierKey={index}
232
- editOrderModifierSet={editOrderModifierSet}
233
- deleteOrderModifier={deleteOrderModifier}
234
- />
235
- ),
236
- )}
237
- </>
238
- )}
239
- {hasDeposits && category?.remainderExpireAfter > 0 && (
240
- <div className='mt-4'>
241
- {t('Design:payNowAndReminderDays', {
242
- deposit: formatNumber(product?.deposit, {
243
- style: 'currency',
244
- currency: Config.Currency.GBP,
245
- }),
246
- remainder: formatNumber(product.price - product?.deposit, {
247
- style: 'currency',
248
- currency: Config.Currency.GBP,
249
- }),
250
- days: category?.remainderExpireAfter,
251
- })}
252
- </div>
253
- )}
254
- {invalid && (
255
- <div className='d-flex mt-3 w-100'>
256
- <p className='iframe-event__message-error'>
257
- {HookFormService.hasError(error, 'required') &&
258
- t('Design:pleaseSelectAtLeastFrom', {
259
- min: 1,
260
- type: 'item',
261
- from: 'this category',
262
- })}
263
- {HookFormService.hasError(error, 'validate') && error.message}
264
- </p>
265
- </div>
266
- )}
267
- <ProductWithModifierSetModal
268
- show={!!editOrderModifierIndex}
269
- onHide={() => setEditOrderModifierIndex(undefined)}
270
- editOrderModifier={editOrderModifierIndex}
271
- onChange={onChangeWithModifierSets}
272
- product={product}
273
- category={category}
274
- />
275
- </div>
276
- )
277
- }}
182
+ )}
183
+ {invalid && (
184
+ <div className='d-flex mt-3 w-100'>
185
+ <p className='iframe-event__message-error'>
186
+ {HookFormService.hasError(error, 'required') &&
187
+ t('Design:pleaseSelectAtLeastFrom', {
188
+ min: 1,
189
+ type: 'item',
190
+ from: 'this category',
191
+ })}
192
+ {HookFormService.hasError(error, 'validate') && error.message}
193
+ </p>
194
+ </div>
195
+ )}
196
+ </div>
197
+ )}
278
198
  />
279
199
  )
280
200
  }