@eventlook/sdk 1.4.46-beta.6 → 1.4.46

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 (228) hide show
  1. package/.claude/settings.local.json +9 -0
  2. package/dist/cjs/components/Image.js +29 -14
  3. package/dist/cjs/components/Image.js.map +1 -1
  4. package/dist/cjs/components/hook-form/FormProvider.js +2 -2
  5. package/dist/cjs/components/hook-form/FormProvider.js.map +1 -1
  6. package/dist/cjs/form/ChildEventDialog.js +3 -3
  7. package/dist/cjs/form/ChildEventDialog.js.map +1 -1
  8. package/dist/cjs/form/ContactPerson.js +1 -1
  9. package/dist/cjs/form/ContactPerson.js.map +1 -1
  10. package/dist/cjs/form/Payment.js +2 -2
  11. package/dist/cjs/form/Payment.js.map +1 -1
  12. package/dist/cjs/form/PaymentOverviewBox.js +23 -15
  13. package/dist/cjs/form/PaymentOverviewBox.js.map +1 -1
  14. package/dist/cjs/form/PaymentPending.js +4 -1
  15. package/dist/cjs/form/PaymentPending.js.map +1 -1
  16. package/dist/cjs/form/ReleaseWithMerchandise.js +48 -57
  17. package/dist/cjs/form/ReleaseWithMerchandise.js.map +1 -1
  18. package/dist/cjs/form/TicketForm.js +18 -36
  19. package/dist/cjs/form/TicketForm.js.map +1 -1
  20. package/dist/cjs/form/TicketSelection.js +6 -5
  21. package/dist/cjs/form/TicketSelection.js.map +1 -1
  22. package/dist/cjs/form/TicketWithMerchandiseSelection.js +5 -3
  23. package/dist/cjs/form/TicketWithMerchandiseSelection.js.map +1 -1
  24. package/dist/cjs/form/index.js +1 -1
  25. package/dist/cjs/form/index.js.map +1 -1
  26. package/dist/cjs/form/payment/FeeBox.js +4 -1
  27. package/dist/cjs/form/payment/FeeBox.js.map +1 -1
  28. package/dist/cjs/form/payment/PaymentOverviewCheckbox.js +27 -17
  29. package/dist/cjs/form/payment/PaymentOverviewCheckbox.js.map +1 -1
  30. package/dist/cjs/form/product/ProductCard.js +34 -49
  31. package/dist/cjs/form/product/ProductCard.js.map +1 -1
  32. package/dist/cjs/form/product/ProductVariantsDialog.js +94 -118
  33. package/dist/cjs/form/product/ProductVariantsDialog.js.map +1 -1
  34. package/dist/cjs/locales/cs.js +1 -16
  35. package/dist/cjs/locales/cs.js.map +1 -1
  36. package/dist/cjs/locales/en.js +1 -16
  37. package/dist/cjs/locales/en.js.map +1 -1
  38. package/dist/cjs/locales/es.js +0 -15
  39. package/dist/cjs/locales/es.js.map +1 -1
  40. package/dist/cjs/locales/pl.js +0 -15
  41. package/dist/cjs/locales/pl.js.map +1 -1
  42. package/dist/cjs/locales/sk.js +0 -15
  43. package/dist/cjs/locales/sk.js.map +1 -1
  44. package/dist/cjs/locales/uk.js +0 -15
  45. package/dist/cjs/locales/uk.js.map +1 -1
  46. package/dist/cjs/utils/data/global.js +0 -2
  47. package/dist/cjs/utils/data/global.js.map +1 -1
  48. package/dist/esm/components/Image.js +30 -15
  49. package/dist/esm/components/Image.js.map +1 -1
  50. package/dist/esm/components/hook-form/FormProvider.js +2 -2
  51. package/dist/esm/components/hook-form/FormProvider.js.map +1 -1
  52. package/dist/esm/form/ChildEventDialog.js +3 -3
  53. package/dist/esm/form/ChildEventDialog.js.map +1 -1
  54. package/dist/esm/form/ContactPerson.js +1 -1
  55. package/dist/esm/form/ContactPerson.js.map +1 -1
  56. package/dist/esm/form/Payment.js +2 -2
  57. package/dist/esm/form/Payment.js.map +1 -1
  58. package/dist/esm/form/PaymentOverviewBox.js +23 -15
  59. package/dist/esm/form/PaymentOverviewBox.js.map +1 -1
  60. package/dist/esm/form/PaymentPending.js +4 -1
  61. package/dist/esm/form/PaymentPending.js.map +1 -1
  62. package/dist/esm/form/ReleaseWithMerchandise.js +49 -58
  63. package/dist/esm/form/ReleaseWithMerchandise.js.map +1 -1
  64. package/dist/esm/form/TicketForm.js +20 -38
  65. package/dist/esm/form/TicketForm.js.map +1 -1
  66. package/dist/esm/form/TicketSelection.js +6 -5
  67. package/dist/esm/form/TicketSelection.js.map +1 -1
  68. package/dist/esm/form/TicketWithMerchandiseSelection.js +6 -4
  69. package/dist/esm/form/TicketWithMerchandiseSelection.js.map +1 -1
  70. package/dist/esm/form/index.js +1 -1
  71. package/dist/esm/form/index.js.map +1 -1
  72. package/dist/esm/form/payment/FeeBox.js +4 -1
  73. package/dist/esm/form/payment/FeeBox.js.map +1 -1
  74. package/dist/esm/form/payment/PaymentOverviewCheckbox.js +29 -19
  75. package/dist/esm/form/payment/PaymentOverviewCheckbox.js.map +1 -1
  76. package/dist/esm/form/product/ProductCard.js +35 -50
  77. package/dist/esm/form/product/ProductCard.js.map +1 -1
  78. package/dist/esm/form/product/ProductVariantsDialog.js +95 -119
  79. package/dist/esm/form/product/ProductVariantsDialog.js.map +1 -1
  80. package/dist/esm/locales/cs.js +1 -16
  81. package/dist/esm/locales/cs.js.map +1 -1
  82. package/dist/esm/locales/en.js +1 -16
  83. package/dist/esm/locales/en.js.map +1 -1
  84. package/dist/esm/locales/es.js +0 -15
  85. package/dist/esm/locales/es.js.map +1 -1
  86. package/dist/esm/locales/pl.js +0 -15
  87. package/dist/esm/locales/pl.js.map +1 -1
  88. package/dist/esm/locales/sk.js +0 -15
  89. package/dist/esm/locales/sk.js.map +1 -1
  90. package/dist/esm/locales/uk.js +0 -15
  91. package/dist/esm/locales/uk.js.map +1 -1
  92. package/dist/esm/utils/data/global.js +1 -2
  93. package/dist/esm/utils/data/global.js.map +1 -1
  94. package/dist/types/components/Image.d.ts +4 -4
  95. package/dist/types/form/style.d.ts +1 -1
  96. package/package.json +2 -8
  97. package/rollup.config.mjs +0 -2
  98. package/src/components/Image.tsx +48 -27
  99. package/src/components/hook-form/FormProvider.tsx +2 -5
  100. package/src/form/ChildEventDialog.tsx +3 -3
  101. package/src/form/ContactPerson.tsx +1 -1
  102. package/src/form/MerchandiseSelection.tsx +29 -0
  103. package/src/form/Payment.tsx +2 -2
  104. package/src/form/PaymentOverviewBox.tsx +72 -40
  105. package/src/form/PaymentPending.tsx +1 -1
  106. package/src/form/ReleaseWithMerchandise.tsx +230 -0
  107. package/src/form/TicketForm.tsx +18 -56
  108. package/src/form/{tickets/TicketSelection.tsx → TicketSelection.tsx} +109 -17
  109. package/src/form/{tickets/TicketSelectionMap.tsx → TicketSelectionMap.tsx} +1 -9
  110. package/src/form/{tickets/TicketWithMerchandiseSelection.tsx → TicketWithMerchandiseSelection.tsx} +7 -3
  111. package/src/form/index.tsx +1 -3
  112. package/src/form/payment/FeeBox.tsx +10 -0
  113. package/src/form/payment/PaymentOverviewCheckbox.tsx +56 -33
  114. package/src/form/product/ProductCard.tsx +52 -67
  115. package/src/form/product/ProductVariantsDialog.tsx +137 -195
  116. package/src/locales/cs.tsx +1 -16
  117. package/src/locales/en.tsx +1 -16
  118. package/src/locales/es.tsx +0 -15
  119. package/src/locales/pl.tsx +0 -15
  120. package/src/locales/sk.tsx +0 -15
  121. package/src/locales/uk.tsx +0 -15
  122. package/src/utils/data/global.ts +0 -1
  123. package/tsconfig.json +1 -2
  124. package/.env.example +0 -1
  125. package/dist/cjs/_virtual/_commonjsHelpers.js +0 -8
  126. package/dist/cjs/_virtual/_commonjsHelpers.js.map +0 -1
  127. package/dist/cjs/_virtual/index.js +0 -6
  128. package/dist/cjs/_virtual/index.js.map +0 -1
  129. package/dist/cjs/_virtual/index2.js +0 -6
  130. package/dist/cjs/_virtual/index2.js.map +0 -1
  131. package/dist/cjs/_virtual/index3.js +0 -6
  132. package/dist/cjs/_virtual/index3.js.map +0 -1
  133. package/dist/cjs/_virtual/react-is.development.js +0 -6
  134. package/dist/cjs/_virtual/react-is.development.js.map +0 -1
  135. package/dist/cjs/_virtual/react-is.development2.js +0 -6
  136. package/dist/cjs/_virtual/react-is.development2.js.map +0 -1
  137. package/dist/cjs/_virtual/react-is.production.js +0 -6
  138. package/dist/cjs/_virtual/react-is.production.js.map +0 -1
  139. package/dist/cjs/_virtual/react-is.production.min.js +0 -6
  140. package/dist/cjs/_virtual/react-is.production.min.js.map +0 -1
  141. package/dist/cjs/form/PaymentOverviewDrawer.js +0 -114
  142. package/dist/cjs/form/PaymentOverviewDrawer.js.map +0 -1
  143. package/dist/cjs/form/TicketQuantityControl.js +0 -51
  144. package/dist/cjs/form/TicketQuantityControl.js.map +0 -1
  145. package/dist/cjs/form/TicketSelectionMobile.js +0 -98
  146. package/dist/cjs/form/TicketSelectionMobile.js.map +0 -1
  147. package/dist/cjs/form/merchandise/MerchandiseSelection.js +0 -14
  148. package/dist/cjs/form/merchandise/MerchandiseSelection.js.map +0 -1
  149. package/dist/cjs/form/merchandise/MerchandiseSlider.js +0 -39
  150. package/dist/cjs/form/merchandise/MerchandiseSlider.js.map +0 -1
  151. package/dist/cjs/form/merchendise/MerchandiseSelection.js +0 -19
  152. package/dist/cjs/form/merchendise/MerchandiseSelection.js.map +0 -1
  153. package/dist/cjs/form/merchendise/MerchandiseSlider.js +0 -75
  154. package/dist/cjs/form/merchendise/MerchandiseSlider.js.map +0 -1
  155. package/dist/cjs/form/services/index.js +0 -131
  156. package/dist/cjs/form/services/index.js.map +0 -1
  157. package/dist/cjs/form/tickets/ReleaseDescription.js +0 -23
  158. package/dist/cjs/form/tickets/ReleaseDescription.js.map +0 -1
  159. package/dist/cjs/form/tickets/ReleaseWithMerchandise.js +0 -139
  160. package/dist/cjs/form/tickets/ReleaseWithMerchandise.js.map +0 -1
  161. package/dist/cjs/form/tickets/TicketQuantityControl.js +0 -52
  162. package/dist/cjs/form/tickets/TicketQuantityControl.js.map +0 -1
  163. package/dist/cjs/form/tickets/TicketSelection.js +0 -134
  164. package/dist/cjs/form/tickets/TicketSelection.js.map +0 -1
  165. package/dist/cjs/form/tickets/TicketSelectionMap.js +0 -73
  166. package/dist/cjs/form/tickets/TicketSelectionMap.js.map +0 -1
  167. package/dist/cjs/form/tickets/TicketSelectionMobile.js +0 -88
  168. package/dist/cjs/form/tickets/TicketSelectionMobile.js.map +0 -1
  169. package/dist/cjs/form/tickets/TicketWithMerchandiseSelection.js +0 -117
  170. package/dist/cjs/form/tickets/TicketWithMerchandiseSelection.js.map +0 -1
  171. package/dist/esm/_virtual/_commonjsHelpers.js +0 -6
  172. package/dist/esm/_virtual/_commonjsHelpers.js.map +0 -1
  173. package/dist/esm/_virtual/index.js +0 -4
  174. package/dist/esm/_virtual/index.js.map +0 -1
  175. package/dist/esm/_virtual/index2.js +0 -4
  176. package/dist/esm/_virtual/index2.js.map +0 -1
  177. package/dist/esm/_virtual/index3.js +0 -4
  178. package/dist/esm/_virtual/index3.js.map +0 -1
  179. package/dist/esm/_virtual/react-is.development.js +0 -4
  180. package/dist/esm/_virtual/react-is.development.js.map +0 -1
  181. package/dist/esm/_virtual/react-is.development2.js +0 -4
  182. package/dist/esm/_virtual/react-is.development2.js.map +0 -1
  183. package/dist/esm/_virtual/react-is.production.js +0 -4
  184. package/dist/esm/_virtual/react-is.production.js.map +0 -1
  185. package/dist/esm/_virtual/react-is.production.min.js +0 -4
  186. package/dist/esm/_virtual/react-is.production.min.js.map +0 -1
  187. package/dist/esm/form/PaymentOverviewDrawer.js +0 -110
  188. package/dist/esm/form/PaymentOverviewDrawer.js.map +0 -1
  189. package/dist/esm/form/TicketQuantityControl.js +0 -47
  190. package/dist/esm/form/TicketQuantityControl.js.map +0 -1
  191. package/dist/esm/form/TicketSelectionMobile.js +0 -94
  192. package/dist/esm/form/TicketSelectionMobile.js.map +0 -1
  193. package/dist/esm/form/merchandise/MerchandiseSelection.js +0 -10
  194. package/dist/esm/form/merchandise/MerchandiseSelection.js.map +0 -1
  195. package/dist/esm/form/merchandise/MerchandiseSlider.js +0 -35
  196. package/dist/esm/form/merchandise/MerchandiseSlider.js.map +0 -1
  197. package/dist/esm/form/merchendise/MerchandiseSelection.js +0 -15
  198. package/dist/esm/form/merchendise/MerchandiseSelection.js.map +0 -1
  199. package/dist/esm/form/merchendise/MerchandiseSlider.js +0 -71
  200. package/dist/esm/form/merchendise/MerchandiseSlider.js.map +0 -1
  201. package/dist/esm/form/services/index.js +0 -127
  202. package/dist/esm/form/services/index.js.map +0 -1
  203. package/dist/esm/form/tickets/ReleaseDescription.js +0 -19
  204. package/dist/esm/form/tickets/ReleaseDescription.js.map +0 -1
  205. package/dist/esm/form/tickets/ReleaseWithMerchandise.js +0 -135
  206. package/dist/esm/form/tickets/ReleaseWithMerchandise.js.map +0 -1
  207. package/dist/esm/form/tickets/TicketQuantityControl.js +0 -48
  208. package/dist/esm/form/tickets/TicketQuantityControl.js.map +0 -1
  209. package/dist/esm/form/tickets/TicketSelection.js +0 -130
  210. package/dist/esm/form/tickets/TicketSelection.js.map +0 -1
  211. package/dist/esm/form/tickets/TicketSelectionMap.js +0 -69
  212. package/dist/esm/form/tickets/TicketSelectionMap.js.map +0 -1
  213. package/dist/esm/form/tickets/TicketSelectionMobile.js +0 -84
  214. package/dist/esm/form/tickets/TicketSelectionMobile.js.map +0 -1
  215. package/dist/esm/form/tickets/TicketWithMerchandiseSelection.js +0 -113
  216. package/dist/esm/form/tickets/TicketWithMerchandiseSelection.js.map +0 -1
  217. package/dist/types/form/PaymentOverviewDrawer.d.ts +0 -8
  218. package/dist/types/form/merchendise/MerchandiseSelection.d.ts +0 -9
  219. package/dist/types/form/merchendise/MerchandiseSlider.d.ts +0 -10
  220. package/dist/types/form/merchendise/MerchendiseSlider.d.ts +0 -0
  221. package/src/form/PaymentOverviewDrawer.tsx +0 -180
  222. package/src/form/merchandise/MerchandiseSelection.tsx +0 -24
  223. package/src/form/merchandise/MerchandiseSlider.tsx +0 -61
  224. package/src/form/services/index.tsx +0 -260
  225. package/src/form/tickets/ReleaseDescription.tsx +0 -46
  226. package/src/form/tickets/ReleaseWithMerchandise.tsx +0 -237
  227. package/src/form/tickets/TicketQuantityControl.tsx +0 -94
  228. package/src/form/tickets/TicketSelectionMobile.tsx +0 -175
@@ -1 +1 @@
1
- {"version":3,"file":"TicketWithMerchandiseSelection.js","sources":["../../../src/form/TicketWithMerchandiseSelection.tsx"],"sourcesContent":["import React, { useEffect, useRef } from 'react';\nimport { useFormContext, useWatch } from 'react-hook-form';\nimport { Box, Divider, Skeleton, Stack, Typography } from '@mui/material';\nimport { ITicketForm, ITicketFormTicket } from '@utils/types/ticket.type';\nimport useEventActiveReleases from '@hooks/data/useEventActiveReleases';\nimport { groupBy } from '@utils/global';\nimport { IReleaseShort } from '@utils/types/release.type';\nimport FeeBox from '@form/payment/FeeBox';\nimport { IEvent } from '@utils/types/event.type';\nimport useResponsive from '@hooks/useResponsive';\nimport ReleaseWithMerchandise from '@form/ReleaseWithMerchandise';\nimport { EventType } from '@utils/data/event';\nimport useGlobal from '@hooks/useGlobal.ts';\n\ninterface Props {\n event: IEvent;\n}\n\nconst TicketWithMerchandiseSelection: React.FC<Props> = ({ event }) => {\n const { t } = useGlobal();\n const isMobile = useResponsive('down', 'md');\n const { setValue, watch } = useFormContext<ITicketForm>();\n const tickets: ITicketFormTicket[] = useWatch({ name: `tickets.${event.id}`, defaultValue: [] });\n const eventTimeslotId = watch('eventTimeslotId');\n const isProcessingRef = useRef(false);\n const { data: activeReleases, mutate } = useEventActiveReleases(\n event.id,\n false,\n event.type === EventType.RECURRING ? eventTimeslotId : undefined\n );\n\n useEffect(() => {\n if (!isProcessingRef.current) selectedTickets();\n }, [tickets, activeReleases]);\n\n const countReleaseCategories = (): number => {\n const grouped = groupBy(activeReleases || [], 'releaseCategoryName');\n return Object.keys(grouped).length;\n };\n\n const selectedReleaseIsSoldOut = (releases: IReleaseShort[] | undefined) => {\n const lockedSelectedReleases: boolean[] | undefined = releases?.map((item, index) => {\n const nextRelease = releases?.find(\n (item2) =>\n item2.releaseCategoryName === item.releaseCategoryName && item2.order === item.order + 1\n );\n const selected = tickets.find((ticket) => ticket.releaseId === item.id);\n return !!nextRelease && item.locked && !!selected && index + 1 == tickets.length;\n });\n return lockedSelectedReleases && lockedSelectedReleases.includes(true);\n };\n\n const countUnlockedReleases = () => activeReleases?.filter((item) => !item.locked).length || 0;\n\n const isReleaseSelected = (id: number) => !!tickets.find((ticket) => ticket.releaseId === id);\n\n const selectedTickets = async () => {\n const releases = await mutate();\n const allFilled = tickets.filter((item) => !item.releaseId || !item.quantity);\n\n const soldOutReleaseCategories = activeReleases?.filter((release) =>\n tickets.find(\n (ticket) =>\n release.id === ticket.releaseId &&\n ticket.quantity === release.availableTickets &&\n release.availableTickets !== 10\n )\n );\n\n // Unlock next releases when current release is sold out\n if (soldOutReleaseCategories?.length && activeReleases) {\n let hasChanges = false;\n const updatedReleases = activeReleases.map((release) => {\n // For each sold-out release, find and unlock the next one\n const soldOutRelease = soldOutReleaseCategories.find(\n (soldOut) =>\n soldOut.releaseCategoryName === release.releaseCategoryName &&\n soldOut.order === release.order - 1 &&\n release.locked\n );\n if (soldOutRelease) {\n hasChanges = true;\n return { ...release, locked: false };\n }\n return release;\n });\n\n if (hasChanges) {\n await mutate(updatedReleases, false);\n }\n }\n\n const hasSelectableRelease = activeReleases?.some(\n (release) => !isReleaseSelected(release.id) && !release.locked\n );\n\n const shouldAddRow =\n (soldOutReleaseCategories &&\n selectedReleaseIsSoldOut(releases) &&\n tickets.length < soldOutReleaseCategories.length + countUnlockedReleases() &&\n !allFilled.length) ||\n (activeReleases &&\n soldOutReleaseCategories?.length &&\n activeReleases?.length > tickets.length &&\n tickets.length < soldOutReleaseCategories.length + countUnlockedReleases() &&\n !allFilled.length) ||\n (tickets.length < countReleaseCategories() && !allFilled.length);\n\n const shouldRemoveEmptyRows =\n allFilled.length > 0 &&\n tickets.length > 1 &&\n !hasSelectableRelease &&\n (!soldOutReleaseCategories?.length || !selectedReleaseIsSoldOut(releases));\n\n if (shouldAddRow) {\n isProcessingRef.current = true;\n setValue(`tickets.${event.id}`, [\n ...tickets,\n {\n releaseId: '',\n quantity: '',\n itemName: '',\n price: 0,\n products: [],\n extraFields: [],\n },\n ]);\n setTimeout(() => (isProcessingRef.current = false), 0);\n } else if (shouldRemoveEmptyRows) {\n // Only remove completely empty rows (no releaseId), keep rows where user started selecting\n const nonEmptyTickets = tickets.filter((item) => item.releaseId);\n if (nonEmptyTickets.length < tickets.length) {\n isProcessingRef.current = true;\n setValue(`tickets.${event.id}`, nonEmptyTickets);\n setTimeout(() => (isProcessingRef.current = false), 0);\n }\n }\n };\n\n return (\n <Stack spacing={3} direction=\"column\">\n {!activeReleases && event.type !== EventType.RECURRING ? (\n <Skeleton\n variant=\"rounded\"\n sx={{\n width: '100%',\n height: (theme) => theme.spacing(7.5),\n }}\n />\n ) : (\n activeReleases?.map((release, index) => (\n <ReleaseWithMerchandise\n key={release.id}\n eventId={event.id}\n release={release}\n activeReleases={activeReleases}\n currency={event.currency}\n index={index}\n />\n ))\n )}\n {!activeReleases && event.type === EventType.RECURRING && (\n <Typography variant=\"h5\">{t('event.tickets.stepper.1.select_timeslot')}</Typography>\n )}\n {!!activeReleases && !activeReleases.length && (\n <Typography variant=\"h5\">{t('event.tickets.stepper.1.no_tickets')}</Typography>\n )}\n <Box>\n <Typography variant=\"caption\" component=\"div\" fontStyle=\"italic\" mb={2}>\n *{t('event.tickets.stepper.1.max_ticket_quantity')}\n </Typography>\n </Box>\n </Stack>\n );\n};\n\nexport default TicketWithMerchandiseSelection;\n"],"names":[],"mappings":";;;;;;;;;;AAkBA,MAAM,8BAA8B,GAAoB,CAAC,EAAE,KAAK,EAAE,KAAI;AACpE,IAAA,MAAM,EAAE,CAAC,EAAE,GAAG,SAAS,EAAE;IACR,aAAa,CAAC,MAAM,EAAE,IAAI;IAC3C,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,cAAc,EAAe;AACzD,IAAA,MAAM,OAAO,GAAwB,QAAQ,CAAC,EAAE,IAAI,EAAE,CAAA,QAAA,EAAW,KAAK,CAAC,EAAE,EAAE,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC;AAChG,IAAA,MAAM,eAAe,GAAG,KAAK,CAAC,iBAAiB,CAAC;AAChD,IAAA,MAAM,eAAe,GAAG,MAAM,CAAC,KAAK,CAAC;AACrC,IAAA,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,EA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,oBAAC,UAAU,EAAA,EAAC,OAAO,EAAC,IAAI,EAAA,EAAE,CAAC,CAAC,yCAAyC,CAAC,CAAc,CACrF;QACA,CAAC,CAAC,cAAc,IAAI,CAAC,cAAc,CAAC,MAAM,KACzC,KAAA,CAAA,aAAA,CAAC,UAAU,EAAA,EAAC,OAAO,EAAC,IAAI,EAAA,EAAE,CAAC,CAAC,oCAAoC,CAAC,CAAc,CAChF;AACD,QAAA,KAAA,CAAA,aAAA,CAAC,GAAG,EAAA,IAAA;AACF,YAAA,KAAA,CAAA,aAAA,CAAC,UAAU,EAAA,EAAC,OAAO,EAAC,SAAS,EAAC,SAAS,EAAC,KAAK,EAAC,SAAS,EAAC,QAAQ,EAAC,EAAE,EAAE,CAAC,EAAA;;AAClE,gBAAA,CAAC,CAAC,6CAA6C,CAAC,CACvC,CACT,CACA;AAEZ;;;;"}
1
+ {"version":3,"file":"TicketWithMerchandiseSelection.js","sources":["../../../src/form/TicketWithMerchandiseSelection.tsx"],"sourcesContent":["import React, { useEffect, useRef } from 'react';\nimport { useFormContext, useWatch } from 'react-hook-form';\nimport { Box, Divider, Skeleton, Stack, Typography } from '@mui/material';\nimport { ITicketForm, ITicketFormTicket } from '@utils/types/ticket.type';\nimport useEventActiveReleases from '@hooks/data/useEventActiveReleases';\nimport { groupBy } from '@utils/global';\nimport { IReleaseShort } from '@utils/types/release.type';\nimport FeeBox from '@form/payment/FeeBox';\nimport { IEvent } from '@utils/types/event.type';\nimport useResponsive from '@hooks/useResponsive';\nimport ReleaseWithMerchandise from '@form/ReleaseWithMerchandise';\nimport { EventType } from '@utils/data/event';\nimport useGlobal from '@hooks/useGlobal.ts';\n\ninterface Props {\n event: IEvent;\n}\n\nconst TicketWithMerchandiseSelection: React.FC<Props> = ({ event }) => {\n const { t } = useGlobal();\n const isMobile = useResponsive('down', 'md');\n const { setValue, watch } = useFormContext<ITicketForm>();\n const tickets: ITicketFormTicket[] = useWatch({ name: `tickets.${event.id}`, defaultValue: [] });\n const eventTimeslotId = watch('eventTimeslotId');\n const isProcessingRef = useRef(false);\n const { data: activeReleases, mutate } = useEventActiveReleases(\n event.id,\n false,\n event.type === EventType.RECURRING ? eventTimeslotId : undefined\n );\n\n useEffect(() => {\n if (!isProcessingRef.current) selectedTickets();\n }, [tickets, activeReleases]);\n\n const countReleaseCategories = (): number => {\n const grouped = groupBy(activeReleases || [], 'releaseCategoryName');\n return Object.keys(grouped).length;\n };\n\n const selectedReleaseIsSoldOut = (releases: IReleaseShort[] | undefined) => {\n const lockedSelectedReleases: boolean[] | undefined = releases?.map((item, index) => {\n const nextRelease = releases?.find(\n (item2) =>\n item2.releaseCategoryName === item.releaseCategoryName && item2.order === item.order + 1\n );\n const selected = tickets.find((ticket) => ticket.releaseId === item.id);\n return !!nextRelease && item.locked && !!selected && index + 1 == tickets.length;\n });\n return lockedSelectedReleases && lockedSelectedReleases.includes(true);\n };\n\n const countUnlockedReleases = () => activeReleases?.filter((item) => !item.locked).length || 0;\n\n const isReleaseSelected = (id: number) => !!tickets.find((ticket) => ticket.releaseId === id);\n\n const selectedTickets = async () => {\n const releases = await mutate();\n const allFilled = tickets.filter((item) => !item.releaseId || !item.quantity);\n\n const soldOutReleaseCategories = activeReleases?.filter((release) =>\n tickets.find(\n (ticket) =>\n release.id === ticket.releaseId &&\n ticket.quantity === release.availableTickets &&\n release.availableTickets !== 10\n )\n );\n\n // Unlock next releases when current release is sold out\n if (soldOutReleaseCategories?.length && activeReleases) {\n let hasChanges = false;\n const updatedReleases = activeReleases.map((release) => {\n // For each sold-out release, find and unlock the next one\n const soldOutRelease = soldOutReleaseCategories.find(\n (soldOut) =>\n soldOut.releaseCategoryName === release.releaseCategoryName &&\n soldOut.order === release.order - 1 &&\n release.locked\n );\n if (soldOutRelease) {\n hasChanges = true;\n return { ...release, locked: false };\n }\n return release;\n });\n\n if (hasChanges) {\n await mutate(updatedReleases, false);\n }\n }\n\n const hasSelectableRelease = activeReleases?.some(\n (release) => !isReleaseSelected(release.id) && !release.locked\n );\n\n const shouldAddRow =\n (soldOutReleaseCategories &&\n selectedReleaseIsSoldOut(releases) &&\n tickets.length < soldOutReleaseCategories.length + countUnlockedReleases() &&\n !allFilled.length) ||\n (activeReleases &&\n soldOutReleaseCategories?.length &&\n activeReleases?.length > tickets.length &&\n tickets.length < soldOutReleaseCategories.length + countUnlockedReleases() &&\n !allFilled.length) ||\n (tickets.length < countReleaseCategories() && !allFilled.length);\n\n const shouldRemoveEmptyRows =\n allFilled.length > 0 &&\n tickets.length > 1 &&\n !hasSelectableRelease &&\n (!soldOutReleaseCategories?.length || !selectedReleaseIsSoldOut(releases));\n\n if (shouldAddRow) {\n isProcessingRef.current = true;\n setValue(`tickets.${event.id}`, [\n ...tickets,\n {\n releaseId: '',\n quantity: '',\n itemName: '',\n price: 0,\n products: [],\n extraFields: [],\n },\n ]);\n setTimeout(() => (isProcessingRef.current = false), 0);\n } else if (shouldRemoveEmptyRows) {\n // Only remove completely empty rows (no releaseId), keep rows where user started selecting\n const nonEmptyTickets = tickets.filter((item) => item.releaseId);\n if (nonEmptyTickets.length < tickets.length) {\n isProcessingRef.current = true;\n setValue(`tickets.${event.id}`, nonEmptyTickets);\n setTimeout(() => (isProcessingRef.current = false), 0);\n }\n }\n };\n\n return (\n <Stack spacing={3} direction=\"column\" divider={<Divider sx={{ borderStyle: 'dashed' }} />}>\n {!activeReleases && event.type !== EventType.RECURRING ? (\n <Skeleton\n variant=\"rounded\"\n sx={{\n width: '100%',\n height: (theme) => theme.spacing(7.5),\n }}\n />\n ) : (\n activeReleases?.map((release, index) => (\n <ReleaseWithMerchandise\n key={release.id}\n eventId={event.id}\n release={release}\n activeReleases={activeReleases}\n currency={event.currency}\n index={index}\n />\n ))\n )}\n {!activeReleases && event.type === EventType.RECURRING && (\n <Typography variant=\"h5\">{t('event.tickets.stepper.1.select_timeslot')}</Typography>\n )}\n {!!activeReleases && !activeReleases.length && (\n <Typography variant=\"h5\">{t('event.tickets.stepper.1.no_tickets')}</Typography>\n )}\n <Box>\n <Typography variant=\"caption\" component=\"div\" fontStyle=\"italic\" mb={2}>\n *{t('event.tickets.stepper.1.max_ticket_quantity')}\n </Typography>\n {isMobile && <FeeBox event={event} align=\"right\" />}\n </Box>\n </Stack>\n );\n};\n\nexport default TicketWithMerchandiseSelection;\n"],"names":[],"mappings":";;;;;;;;;;;AAkBA,MAAM,8BAA8B,GAAoB,CAAC,EAAE,KAAK,EAAE,KAAI;AACpE,IAAA,MAAM,EAAE,CAAC,EAAE,GAAG,SAAS,EAAE;IACzB,MAAM,QAAQ,GAAG,aAAa,CAAC,MAAM,EAAE,IAAI,CAAC;IAC5C,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,cAAc,EAAe;AACzD,IAAA,MAAM,OAAO,GAAwB,QAAQ,CAAC,EAAE,IAAI,EAAE,CAAA,QAAA,EAAW,KAAK,CAAC,EAAE,EAAE,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC;AAChG,IAAA,MAAM,eAAe,GAAG,KAAK,CAAC,iBAAiB,CAAC;AAChD,IAAA,MAAM,eAAe,GAAG,MAAM,CAAC,KAAK,CAAC;AACrC,IAAA,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,EAAE,GAAG,sBAAsB,CAC7D,KAAK,CAAC,EAAE,EACR,KAAK,EACL,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,SAAS,GAAG,eAAe,GAAG,SAAS,CACjE;IAED,SAAS,CAAC,MAAK;QACb,IAAI,CAAC,eAAe,CAAC,OAAO;AAAE,YAAA,eAAe,EAAE;AACjD,KAAC,EAAE,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;IAE7B,MAAM,sBAAsB,GAAG,MAAa;QAC1C,MAAM,OAAO,GAAG,OAAO,CAAC,cAAc,IAAI,EAAE,EAAE,qBAAqB,CAAC;QACpE,OAAO,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM;AACpC,KAAC;AAED,IAAA,MAAM,wBAAwB,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EAAA,EAAC,OAAO,EAAC,SAAS,EAAC,SAAS,EAAC,KAAK,EAAC,SAAS,EAAC,QAAQ,EAAC,EAAE,EAAE,CAAC,EAAA;;gBAClE,CAAC,CAAC,6CAA6C,CAAC,CACvC;AACZ,YAAA,QAAQ,IAAI,KAAA,CAAA,aAAA,CAAC,MAAM,EAAA,EAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAC,OAAO,EAAA,CAAG,CAC/C,CACA;AAEZ;;;;"}
@@ -54,7 +54,7 @@ const ClientRender = ({ eventSlug, apiUrl, seatingIframeUrl, lang, slots, option
54
54
  }
55
55
  };
56
56
  return (React.createElement(LocalizationProvider, { dateAdapter: AdapterDayjs, adapterLocale: lang || Languages.CS, localeText: getLocalizationProviderLocaleText() },
57
- React.createElement(GlobalProvider, { lang: lang || Languages.CS, showSnackbar: slots?.showSnackbar, callbacks: callbacks, links: links, options: options, content: content, seatingIframeUrl: seatingIframeUrl }, !data || !!error ? (React.createElement(TicketFormSkeleton, null)) : (React.createElement(TicketForm, { event: data, hasGopayIdSsr: options?.hasGopayId || false, isIframe: options?.isIframe, selectedReleaseId: selectedReleaseId, headerSlot: slots?.headerSlot })))));
57
+ React.createElement(GlobalProvider, { lang: lang || Languages.CS, showSnackbar: slots?.showSnackbar, callbacks: callbacks, links: links, options: options, content: content, seatingIframeUrl: seatingIframeUrl }, !data || !!error ? (React.createElement(TicketFormSkeleton, null)) : (React.createElement(TicketForm, { event: data, hasGopayIdSsr: options?.hasGopayId || false, isIframe: options?.isIframe, selectedReleaseId: selectedReleaseId })))));
58
58
  };
59
59
  function Index(props) {
60
60
  return (React.createElement(ClientOnly, null,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/form/index.tsx"],"sourcesContent":["import 'dayjs/locale/cs';\nimport 'dayjs/locale/en';\nimport 'dayjs/locale/de';\nimport 'dayjs/locale/es';\nimport 'dayjs/locale/uk';\nimport 'dayjs/locale/sk';\n\nimport React, { useEffect, ReactNode } from 'react';\nimport TicketForm from '@form/TicketForm';\nimport { GlobalProvider } from '@context/GlobalContext';\nimport api from '@utils/axios';\nimport dayjs from 'dayjs';\nimport utc from 'dayjs/plugin/utc';\nimport timezone from 'dayjs/plugin/timezone';\nimport localeData from 'dayjs/plugin/localeData';\nimport updateLocale from 'dayjs/plugin/updateLocale';\nimport { Languages } from '@utils/data/language';\nimport useEvent from '@hooks/data/useEvent';\nimport { IContent, IGlobalContext, IGlobalContextOptions } from '@utils/types/global.type';\nimport { IUser } from '@utils/types/user.type';\nimport TicketFormSkeleton from '@components/TicketFormSkeleton';\nimport { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';\nimport { LocalizationProvider } from '@mui/x-date-pickers';\nimport ClientOnly from '@components/ClientOnly';\nimport { csCZ, enUS, ukUA, esES, deDE, skSK } from '@mui/x-date-pickers/locales';\n\nexport interface OrderFormProps {\n eventSlug: string;\n apiUrl: string;\n seatingIframeUrl?: string;\n callbacks: IGlobalContext['callbacks'];\n links: IGlobalContext['links'];\n lang?: Languages;\n slots?: {\n showSnackbar: IGlobalContext['showSnackbar'];\n headerSlot?: ReactNode;\n };\n user?: IUser;\n selectedReleaseId?: number;\n options?: IGlobalContextOptions;\n content?: IContent;\n}\n\nconst ClientRender: React.FC<OrderFormProps> = ({\n eventSlug,\n apiUrl,\n seatingIframeUrl,\n lang,\n slots,\n options,\n callbacks,\n selectedReleaseId,\n links,\n content,\n}) => {\n api.defaults.baseURL = apiUrl;\n dayjs.extend(utc);\n dayjs.extend(timezone);\n dayjs.extend(localeData);\n dayjs.extend(updateLocale);\n\n ['cs', 'en', 'de', 'es', 'uk', 'sk'].forEach((loc) => {\n dayjs.updateLocale(loc, { weekStart: 1 });\n });\n\n const { data, error } = useEvent(eventSlug);\n\n useEffect(() => {\n window.dataLayer = window.dataLayer || [];\n }, []);\n\n useEffect(() => {\n api.defaults.headers['Accept-Language'] = lang || Languages.CS;\n }, [lang]);\n\n const getLocalizationProviderLocaleText = () => {\n switch (lang) {\n case 'en':\n return enUS.components.MuiLocalizationProvider.defaultProps.localeText;\n case 'de':\n return deDE.components.MuiLocalizationProvider.defaultProps.localeText;\n case 'uk':\n return ukUA.components.MuiLocalizationProvider.defaultProps.localeText;\n case 'es':\n return esES.components.MuiLocalizationProvider.defaultProps.localeText;\n case 'sk':\n return skSK.components.MuiLocalizationProvider.defaultProps.localeText;\n default:\n return csCZ.components.MuiLocalizationProvider.defaultProps.localeText;\n }\n };\n\n return (\n <LocalizationProvider\n dateAdapter={AdapterDayjs}\n adapterLocale={lang || Languages.CS}\n localeText={getLocalizationProviderLocaleText()}\n >\n <GlobalProvider\n lang={lang || Languages.CS}\n showSnackbar={slots?.showSnackbar}\n callbacks={callbacks}\n links={links}\n options={options}\n content={content}\n seatingIframeUrl={seatingIframeUrl}\n >\n {!data || !!error ? (\n <TicketFormSkeleton />\n ) : (\n <TicketForm\n event={data}\n hasGopayIdSsr={options?.hasGopayId || false}\n isIframe={options?.isIframe}\n selectedReleaseId={selectedReleaseId}\n headerSlot={slots?.headerSlot}\n />\n )}\n </GlobalProvider>\n </LocalizationProvider>\n );\n};\n\nexport default function Index(props: OrderFormProps) {\n return (\n <ClientOnly>\n <ClientRender {...props} />\n </ClientOnly>\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA2CA,MAAM,YAAY,GAA6B,CAAC,EAC9C,SAAS,EACT,MAAM,EACN,gBAAgB,EAChB,IAAI,EACJ,KAAK,EACL,OAAO,EACP,SAAS,EACT,iBAAiB,EACjB,KAAK,EACL,OAAO,GACR,KAAI;AACH,IAAA,GAAG,CAAC,QAAQ,CAAC,OAAO,GAAG,MAAM;AAC7B,IAAA,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC;AACjB,IAAA,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC;AACtB,IAAA,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC;AACxB,IAAA,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC;AAE1B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AAW,EAAE,YAAY,EACzB,aAAa,EAAE,IAAI,IAAI,SAAS,CAAC,EAAE,EACnC,UAAU,EAAE,iCAAiC,EAAE,EAAA;AAE/C,QAAA,KAAA,CAAA,aAAA,CAAC,cAAc,EAAA,EACb,IAAI,EAAE,IAAI,IAAI,SAAS,CAAC,EAAE,EAC1B,YAAY,EAAE,KAAK,EAAE,YAAY,EACjC,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,EAChB,gBAAgB,EAAE,gBAAgB,IAEjC,CAAC,IAAI,IAAI,CAAC,CAAC,KAAK,IACf,oBAAC,kBAAkB,EAAA,IAAA,CAAG,KAEtB,KAAA,CAAA,aAAA,CAAC,UAAU,EAAA,EACT,KAAK,EAAE,IAAI,EACX,aAAa,EAAE,OAAO,EAAE,UAAU,IAAI,KAAK,EAC3C,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAC3B,iBAAiB,EAAE,iBAAiB,EACpC,UAAU,EAAE,KAAK,EAAE,UAAU,EAAA,CAC7B,CACH,CACc,CACI;AAE3B,CAAC;AAEa,SAAU,KAAK,CAAC,KAAqB,EAAA;IACjD,QACE,oBAAC,UAAU,EAAA,IAAA;AACT,QAAA,KAAA,CAAA,aAAA,CAAC,YAAY,EAAA,EAAA,GAAK,KAAK,EAAA,CAAI,CAChB;AAEjB;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/form/index.tsx"],"sourcesContent":["import 'dayjs/locale/cs';\nimport 'dayjs/locale/en';\nimport 'dayjs/locale/de';\nimport 'dayjs/locale/es';\nimport 'dayjs/locale/uk';\nimport 'dayjs/locale/sk';\n\nimport React, { useEffect } from 'react';\nimport TicketForm from '@form/TicketForm';\nimport { GlobalProvider } from '@context/GlobalContext';\nimport api from '@utils/axios';\nimport dayjs from 'dayjs';\nimport utc from 'dayjs/plugin/utc';\nimport timezone from 'dayjs/plugin/timezone';\nimport localeData from 'dayjs/plugin/localeData';\nimport updateLocale from 'dayjs/plugin/updateLocale';\nimport { Languages } from '@utils/data/language';\nimport useEvent from '@hooks/data/useEvent';\nimport { IContent, IGlobalContext, IGlobalContextOptions } from '@utils/types/global.type';\nimport { IUser } from '@utils/types/user.type';\nimport TicketFormSkeleton from '@components/TicketFormSkeleton';\nimport { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';\nimport { LocalizationProvider } from '@mui/x-date-pickers';\nimport ClientOnly from '@components/ClientOnly';\nimport { csCZ, enUS, ukUA, esES, deDE, skSK } from '@mui/x-date-pickers/locales';\n\nexport interface OrderFormProps {\n eventSlug: string;\n apiUrl: string;\n seatingIframeUrl?: string;\n callbacks: IGlobalContext['callbacks'];\n links: IGlobalContext['links'];\n lang?: Languages;\n slots?: {\n showSnackbar: IGlobalContext['showSnackbar'];\n };\n user?: IUser;\n selectedReleaseId?: number;\n options?: IGlobalContextOptions;\n content?: IContent;\n}\n\nconst ClientRender: React.FC<OrderFormProps> = ({\n eventSlug,\n apiUrl,\n seatingIframeUrl,\n lang,\n slots,\n options,\n callbacks,\n selectedReleaseId,\n links,\n content,\n}) => {\n api.defaults.baseURL = apiUrl;\n dayjs.extend(utc);\n dayjs.extend(timezone);\n dayjs.extend(localeData);\n dayjs.extend(updateLocale);\n\n ['cs', 'en', 'de', 'es', 'uk', 'sk'].forEach((loc) => {\n dayjs.updateLocale(loc, { weekStart: 1 });\n });\n\n const { data, error } = useEvent(eventSlug);\n\n useEffect(() => {\n window.dataLayer = window.dataLayer || [];\n }, []);\n\n useEffect(() => {\n api.defaults.headers['Accept-Language'] = lang || Languages.CS;\n }, [lang]);\n\n const getLocalizationProviderLocaleText = () => {\n switch (lang) {\n case 'en':\n return enUS.components.MuiLocalizationProvider.defaultProps.localeText;\n case 'de':\n return deDE.components.MuiLocalizationProvider.defaultProps.localeText;\n case 'uk':\n return ukUA.components.MuiLocalizationProvider.defaultProps.localeText;\n case 'es':\n return esES.components.MuiLocalizationProvider.defaultProps.localeText;\n case 'sk':\n return skSK.components.MuiLocalizationProvider.defaultProps.localeText;\n default:\n return csCZ.components.MuiLocalizationProvider.defaultProps.localeText;\n }\n };\n\n return (\n <LocalizationProvider\n dateAdapter={AdapterDayjs}\n adapterLocale={lang || Languages.CS}\n localeText={getLocalizationProviderLocaleText()}\n >\n <GlobalProvider\n lang={lang || Languages.CS}\n showSnackbar={slots?.showSnackbar}\n callbacks={callbacks}\n links={links}\n options={options}\n content={content}\n seatingIframeUrl={seatingIframeUrl}\n >\n {!data || !!error ? (\n <TicketFormSkeleton />\n ) : (\n <TicketForm\n event={data}\n hasGopayIdSsr={options?.hasGopayId || false}\n isIframe={options?.isIframe}\n selectedReleaseId={selectedReleaseId}\n />\n )}\n </GlobalProvider>\n </LocalizationProvider>\n );\n};\n\nexport default function Index(props: OrderFormProps) {\n return (\n <ClientOnly>\n <ClientRender {...props} />\n </ClientOnly>\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA0CA,MAAM,YAAY,GAA6B,CAAC,EAC9C,SAAS,EACT,MAAM,EACN,gBAAgB,EAChB,IAAI,EACJ,KAAK,EACL,OAAO,EACP,SAAS,EACT,iBAAiB,EACjB,KAAK,EACL,OAAO,GACR,KAAI;AACH,IAAA,GAAG,CAAC,QAAQ,CAAC,OAAO,GAAG,MAAM;AAC7B,IAAA,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC;AACjB,IAAA,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC;AACtB,IAAA,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC;AACxB,IAAA,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC;AAE1B,IAAA,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,KAAI;QACnD,KAAK,CAAC,YAAY,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC;AAC3C,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YAAY,EAAE,KAAK,EAAE,YAAY,EACjC,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,EAChB,gBAAgB,EAAE,gBAAgB,IAEjC,CAAC,IAAI,IAAI,CAAC,CAAC,KAAK,IACf,oBAAC,kBAAkB,EAAA,IAAA,CAAG,KAEtB,oBAAC,UAAU,EAAA,EACT,KAAK,EAAE,IAAI,EACX,aAAa,EAAE,OAAO,EAAE,UAAU,IAAI,KAAK,EAC3C,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAC3B,iBAAiB,EAAE,iBAAiB,EAAA,CACpC,CACH,CACc,CACI;AAE3B,CAAC;AAEa,SAAU,KAAK,CAAC,KAAqB,EAAA;IACjD,QACE,oBAAC,UAAU,EAAA,IAAA;AACT,QAAA,KAAA,CAAA,aAAA,CAAC,YAAY,EAAA,EAAA,GAAK,KAAK,EAAA,CAAI,CAChB;AAEjB;;;;"}
@@ -28,7 +28,10 @@ const FeeBox = ({ event, align = 'left' }) => {
28
28
  React.createElement(Typography, { variant: "subtitle1", sx: { textAlign: 'right' } },
29
29
  t('form.labels.total'),
30
30
  ":")),
31
- React.createElement(Typography, { variant: "subtitle1" }, fCurrency(values.total, lang, event.currency)))));
31
+ React.createElement(Typography, { variant: "subtitle1" }, fCurrency(values.total, lang, event.currency))),
32
+ !!values.totalFee && (React.createElement(Typography, { variant: "caption", sx: {
33
+ color: (theme) => theme.palette.grey.A700,
34
+ } }, t('form.labels.with_fee')))));
32
35
  };
33
36
 
34
37
  export { FeeBox as default };
@@ -1 +1 @@
1
- {"version":3,"file":"FeeBox.js","sources":["../../../../src/form/payment/FeeBox.tsx"],"sourcesContent":["import React from 'react';\nimport { Box, Stack, Tooltip, Typography } from '@mui/material';\nimport { fCurrency } from '@utils/formatNumber';\nimport { Iconify } from '@components/iconify';\nimport { IEvent } from '@utils/types/event.type';\nimport useResponsive from '@hooks/useResponsive';\nimport { useFormContext } from 'react-hook-form';\nimport { ITicketForm } from '@utils/types/ticket.type';\nimport useGlobal from '@hooks/useGlobal.ts';\n\ninterface Props {\n event: IEvent;\n align?: 'left' | 'right';\n}\n\nconst FeeBox: React.FC<Props> = ({ event, align = 'left' }) => {\n const { t, lang } = useGlobal();\n const xs = useResponsive('only', 'xs');\n const { watch } = useFormContext<ITicketForm>();\n const values = watch();\n const isRight = align === 'right';\n\n return (\n <Box mb={1} textAlign={isRight ? 'right' : undefined}>\n {values.promoCodes.length > 0 && (\n <Stack\n direction=\"row\"\n justifyContent={isRight ? 'flex-end' : 'space-between'}\n alignItems=\"center\"\n spacing={1}\n sx={{ color: (theme) => theme.palette.grey.A700 }}\n >\n <Typography variant=\"caption\" sx={{ textAlign: 'right' }}>\n {t('form.labels.original_price')}:\n </Typography>\n <Typography variant=\"caption\" sx={{ textDecoration: 'line-through' }}>\n {fCurrency(values.originalPrice, lang, event.currency)}\n </Typography>\n </Stack>\n )}\n <Stack\n direction=\"row\"\n justifyContent={isRight ? 'flex-end' : 'space-between'}\n alignItems=\"center\"\n spacing={1}\n >\n <Stack direction=\"row\" alignItems=\"center\" spacing={1}>\n <Tooltip\n title={t('form.labels.price_including_service_fee', {\n fee: fCurrency(values.totalFee ?? 0, lang, event.currency),\n })}\n placement={xs ? 'top' : 'left'}\n arrow\n sx={{ cursor: 'help' }}\n >\n <Stack alignItems=\"center\">\n <Iconify icon=\"carbon:information-filled\" />\n </Stack>\n </Tooltip>\n <Typography variant=\"subtitle1\" sx={{ textAlign: 'right' }}>\n {t('form.labels.total')}:\n </Typography>\n </Stack>\n <Typography variant=\"subtitle1\">{fCurrency(values.total, lang, event.currency)}</Typography>\n </Stack>\n </Box>\n );\n};\n\nexport default FeeBox;\n"],"names":[],"mappings":";;;;;;;;AAeA,MAAM,MAAM,GAAoB,CAAC,EAAE,KAAK,EAAE,KAAK,GAAG,MAAM,EAAE,KAAI;IAC5D,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,GAAG,S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EAAA;AAEV,YAAA,KAAA,CAAA,aAAA,CAAC,KAAK,EAAA,EAAC,SAAS,EAAC,KAAK,EAAC,UAAU,EAAC,QAAQ,EAAC,OAAO,EAAE,CAAC,EAAA;AACnD,gBAAA,KAAA,CAAA,aAAA,CAAC,OAAO,EAAA,EACN,KAAK,EAAE,CAAC,CAAC,yCAAyC,EAAE;AAClD,wBAAA,GAAG,EAAE,SAAS,CAAC,MAAM,CAAC,QAAQ,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,QAAQ,CAAC;qBAC3D,CAAC,EACF,SAAS,EAAE,EAAE,GAAG,KAAK,GAAG,MAAM,EAC9B,KAAK,EAAA,IAAA,EACL,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,EAAA;AAEtB,oBAAA,KAAA,CAAA,aAAA,CAAC,KAAK,EAAA,EAAC,UAAU,EAAC,QAAQ,EAAA;AACxB,wBAAA,KAAA,CAAA,aAAA,CAAC,OAAO,EAAA,EAAC,IAAI,EAAC,2BAA2B,EAAA,CAAG,CACtC,CACA;AACV,gBAAA,KAAA,CAAA,aAAA,CAAC,UAAU,EAAA,EAAC,OAAO,EAAC,WAAW,EAAC,EAAE,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,EAAA;oBACvD,CAAC,CAAC,mBAAmB,CAAC;wBACZ,CACP;YACR,KAAA,CAAA,aAAA,CAAC,UAAU,IAAC,OAAO,EAAC,WAAW,EAAA,EAAE,SAAS,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAc,CACtF,CACJ;AAEV;;;;"}
1
+ {"version":3,"file":"FeeBox.js","sources":["../../../../src/form/payment/FeeBox.tsx"],"sourcesContent":["import React from 'react';\nimport { Box, Stack, Tooltip, Typography } from '@mui/material';\nimport { fCurrency } from '@utils/formatNumber';\nimport { Iconify } from '@components/iconify';\nimport { IEvent } from '@utils/types/event.type';\nimport useResponsive from '@hooks/useResponsive';\nimport { useFormContext } from 'react-hook-form';\nimport { ITicketForm } from '@utils/types/ticket.type';\nimport useGlobal from '@hooks/useGlobal.ts';\n\ninterface Props {\n event: IEvent;\n align?: 'left' | 'right';\n}\n\nconst FeeBox: React.FC<Props> = ({ event, align = 'left' }) => {\n const { t, lang } = useGlobal();\n const xs = useResponsive('only', 'xs');\n const { watch } = useFormContext<ITicketForm>();\n const values = watch();\n const isRight = align === 'right';\n\n return (\n <Box mb={1} textAlign={isRight ? 'right' : undefined}>\n {values.promoCodes.length > 0 && (\n <Stack\n direction=\"row\"\n justifyContent={isRight ? 'flex-end' : 'space-between'}\n alignItems=\"center\"\n spacing={1}\n sx={{ color: (theme) => theme.palette.grey.A700 }}\n >\n <Typography variant=\"caption\" sx={{ textAlign: 'right' }}>\n {t('form.labels.original_price')}:\n </Typography>\n <Typography variant=\"caption\" sx={{ textDecoration: 'line-through' }}>\n {fCurrency(values.originalPrice, lang, event.currency)}\n </Typography>\n </Stack>\n )}\n <Stack\n direction=\"row\"\n justifyContent={isRight ? 'flex-end' : 'space-between'}\n alignItems=\"center\"\n spacing={1}\n >\n <Stack direction=\"row\" alignItems=\"center\" spacing={1}>\n <Tooltip\n title={t('form.labels.price_including_service_fee', {\n fee: fCurrency(values.totalFee ?? 0, lang, event.currency),\n })}\n placement={xs ? 'top' : 'left'}\n arrow\n sx={{ cursor: 'help' }}\n >\n <Stack alignItems=\"center\">\n <Iconify icon=\"carbon:information-filled\" />\n </Stack>\n </Tooltip>\n <Typography variant=\"subtitle1\" sx={{ textAlign: 'right' }}>\n {t('form.labels.total')}:\n </Typography>\n </Stack>\n <Typography variant=\"subtitle1\">{fCurrency(values.total, lang, event.currency)}</Typography>\n </Stack>\n {!!values.totalFee && (\n <Typography\n variant=\"caption\"\n sx={{\n color: (theme) => theme.palette.grey.A700,\n }}\n >\n {t('form.labels.with_fee')}\n </Typography>\n )}\n </Box>\n );\n};\n\nexport default FeeBox;\n"],"names":[],"mappings":";;;;;;;;AAeA,MAAM,MAAM,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AE;AACF,gBAAA,KAAK,EAAE,CAAC,KAAK,KAAK,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI;aAC1C,EAAA,EAEA,CAAC,CAAC,sBAAsB,CAAC,CACf,CACd,CACG;AAEV;;;;"}
@@ -1,32 +1,42 @@
1
- import React from 'react';
2
- import { Stack, Typography, Button } from '@mui/material';
3
- import { useFormContext, Controller } from 'react-hook-form';
1
+ import React, { useState } from 'react';
2
+ import { Stack, Typography, Link, Dialog, DialogTitle, IconButton, DialogContent } from '@mui/material';
3
+ import 'react-hook-form';
4
+ import { RHFCheckbox } from '../../components/hook-form/RHFCheckbox.js';
4
5
  import useGlobal from '../../hooks/useGlobal.js';
5
6
  import 'framer-motion';
6
7
  import '../../components/animate/IconButtonAnimate.js';
7
8
  import '@mui/material/styles';
8
9
  import '@mui/material/useMediaQuery';
9
10
  import Iconify from '../../components/iconify/Iconify.js';
10
- import 'react-lazy-load-image-component';
11
11
 
12
- const PaymentOverviewCheckbox = ({ checkboxName, label, value }) => {
12
+ const PaymentOverviewCheckbox = ({ checkboxName, label, value, modal }) => {
13
13
  const { t } = useGlobal();
14
- const { control } = useFormContext();
14
+ const [open, setOpen] = useState(false);
15
+ const handleOpen = (e) => {
16
+ e.preventDefault();
17
+ e.stopPropagation();
18
+ setOpen(true);
19
+ };
20
+ const handleClose = () => setOpen(false);
15
21
  return (React.createElement(React.Fragment, null,
16
- React.createElement(Controller, { name: checkboxName, control: control, render: ({ field }) => (React.createElement(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", spacing: 1, sx: { width: '100%', mb: 0.5 } },
22
+ React.createElement(RHFCheckbox, { name: checkboxName, label: React.createElement(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", spacing: 1, sx: { width: '100%' } },
17
23
  React.createElement(Typography, { variant: "caption", sx: { flex: 1 } }, label),
18
- React.createElement(Stack, { direction: "row", alignItems: "center", spacing: 1 },
19
- React.createElement(Typography, { variant: "caption" }, value),
20
- !field.value && (React.createElement(Button, { variant: "outlined", color: "primary", size: "small", startIcon: React.createElement(Iconify, { icon: "carbon:add" }), onClick: (event) => {
21
- event.preventDefault();
22
- event.stopPropagation();
23
- field.onChange(true);
24
- }, sx: {
25
- borderRadius: 1,
26
- textTransform: 'none',
27
- px: 1.5,
28
- minWidth: 96,
29
- } }, t('add')))))) })));
24
+ React.createElement(Stack, { alignItems: "flex-end" },
25
+ React.createElement(Typography, { variant: "caption", fontWeight: "600" }, value),
26
+ React.createElement(Link, { variant: "caption", onClick: handleOpen }, t('more_info')))), sx: {
27
+ width: 'calc(100% + 11px)',
28
+ mb: 0.5,
29
+ '& > .MuiTypography-root': {
30
+ width: '100%',
31
+ },
32
+ } }),
33
+ React.createElement(Dialog, { open: open, onClose: handleClose, maxWidth: "sm", fullWidth: true },
34
+ React.createElement(DialogTitle, { sx: { display: 'flex', justifyContent: 'space-between', alignItems: 'center' } },
35
+ modal.title,
36
+ React.createElement(IconButton, { onClick: handleClose, size: "small" },
37
+ React.createElement(Iconify, { icon: "carbon:close" }))),
38
+ React.createElement(DialogContent, null,
39
+ React.createElement(Typography, { variant: "body2" }, modal.description)))));
30
40
  };
31
41
 
32
42
  export { PaymentOverviewCheckbox as default };
@@ -1 +1 @@
1
- {"version":3,"file":"PaymentOverviewCheckbox.js","sources":["../../../../src/form/payment/PaymentOverviewCheckbox.tsx"],"sourcesContent":["import React, { JSX } from 'react';\nimport { Button, Stack, Typography } from '@mui/material';\nimport { Controller, useFormContext } from 'react-hook-form';\nimport useGlobal from '@hooks/useGlobal.ts';\nimport { Iconify } from '@components';\n\ninterface Props {\n checkboxName: string;\n label: string;\n value: string | JSX.Element;\n}\n\nconst PaymentOverviewCheckbox: React.FC<Props> = ({ checkboxName, label, value }) => {\n const { t } = useGlobal();\n const { control } = useFormContext();\n\n return (\n <>\n <Controller\n name={checkboxName}\n control={control}\n render={({ field }) => (\n <Stack\n direction=\"row\"\n justifyContent=\"space-between\"\n alignItems=\"center\"\n spacing={1}\n sx={{ width: '100%', mb: 0.5 }}\n >\n <Typography variant=\"caption\" sx={{ flex: 1 }}>\n {label}\n </Typography>\n <Stack direction=\"row\" alignItems=\"center\" spacing={1}>\n <Typography variant=\"caption\">{value}</Typography>\n {!field.value && (\n <Button\n variant=\"outlined\"\n color=\"primary\"\n size=\"small\"\n startIcon={<Iconify icon=\"carbon:add\" />}\n onClick={(event) => {\n event.preventDefault();\n event.stopPropagation();\n field.onChange(true);\n }}\n sx={{\n borderRadius: 1,\n textTransform: 'none',\n px: 1.5,\n minWidth: 96,\n }}\n >\n {t('add')}\n </Button>\n )}\n </Stack>\n </Stack>\n )}\n />\n </>\n );\n};\n\nexport default PaymentOverviewCheckbox;\n"],"names":[],"mappings":";;;;;;;;;;;AAYA,MAAM,uBAAuB,GAAoB,CAAC,EAAE,YAAY,EAAE,KAAK,EAAE,KAAK,EAAE,KAAI;AAClF,IAAA,MAAM,EAAE,CAAC,EAAE,GAAG,SAAS,EAAE;AACzB,IAAA,MAAM,EAAE,OAAO,EAAE,GAAG,cAAc,EAAE;AAEpC,IAAA,QACE,KAAA,CAAA,aAAA,CAAA,KAAA,CAAA,QAAA,EAAA,IAAA;QACE,KAAA,CAAA,aAAA,CAAC,UAAU,IACT,IAAI,EAAE,YAAY,EAClB,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,MAChB,KAAA,CAAA,aAAA,CAAC,KAAK,EAAA,EACJ,SAAS,EAAC,KAAK,EACf,cAAc,EAAC,eAAe,EAC9B,UAAU,EAAC,QAAQ,EACnB,OAAO,EAAE,CAAC,EACV,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,EAAA;AAE9B,gBAAA,KAAA,CAAA,aAAA,CAAC,UAAU,EAAA,EAAC,OAAO,EAAC,SAAS,EAAC,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,EAAA,EAC1C,KAAK,CACK;AACb,gBAAA,KAAA,CAAA,aAAA,CAAC,KAAK,EAAA,EAAC,SAAS,EAAC,KAAK,EAAC,UAAU,EAAC,QAAQ,EAAC,OAAO,EAAE,CAAC,EAAA;AACnD,oBAAA,KAAA,CAAA,aAAA,CAAC,UAAU,EAAA,EAAC,OAAO,EAAC,SAAS,EAAA,EAAE,KAAK,CAAc;AACjD,oBAAA,CAAC,KAAK,CAAC,KAAK,KACX,KAAA,CAAA,aAAA,CAAC,MAAM,EAAA,EACL,OAAO,EAAC,UAAU,EAClB,KAAK,EAAC,SAAS,EACf,IAAI,EAAC,OAAO,EACZ,SAAS,EAAE,KAAA,CAAA,aAAA,CAAC,OAAO,IAAC,IAAI,EAAC,YAAY,EAAA,CAAG,EACxC,OAAO,EAAE,CAAC,KAAK,KAAI;4BACjB,KAAK,CAAC,cAAc,EAAE;4BACtB,KAAK,CAAC,eAAe,EAAE;AACvB,4BAAA,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC;yBACrB,EACD,EAAE,EAAE;AACF,4BAAA,YAAY,EAAE,CAAC;AACf,4BAAA,aAAa,EAAE,MAAM;AACrB,4BAAA,EAAE,EAAE,GAAG;AACP,4BAAA,QAAQ,EAAE,EAAE;AACb,yBAAA,EAAA,EAEA,CAAC,CAAC,KAAK,CAAC,CACF,CACV,CACK,CACF,CACT,EAAA,CACD,CACD;AAEP;;;;"}
1
+ {"version":3,"file":"PaymentOverviewCheckbox.js","sources":["../../../../src/form/payment/PaymentOverviewCheckbox.tsx"],"sourcesContent":["import React, { JSX, useState } from 'react';\nimport {\n Dialog,\n DialogContent,\n DialogTitle,\n IconButton,\n Link,\n Stack,\n Typography,\n} from '@mui/material';\nimport { RHFCheckbox } from '@components/hook-form';\nimport useGlobal from '@hooks/useGlobal.ts';\nimport { Iconify } from '@components';\n\ninterface Props {\n checkboxName: string;\n label: string;\n value: string | JSX.Element;\n modal: {\n title: string;\n description: string | JSX.Element;\n };\n}\n\nconst PaymentOverviewCheckbox: React.FC<Props> = ({ checkboxName, label, value, modal }) => {\n const { t } = useGlobal();\n const [open, setOpen] = useState(false);\n\n const handleOpen = (e: React.MouseEvent<HTMLAnchorElement>) => {\n e.preventDefault();\n e.stopPropagation();\n setOpen(true);\n };\n const handleClose = () => setOpen(false);\n\n return (\n <>\n <RHFCheckbox\n name={checkboxName}\n label={\n <Stack\n direction=\"row\"\n justifyContent=\"space-between\"\n alignItems=\"center\"\n spacing={1}\n sx={{ width: '100%' }}\n >\n <Typography variant=\"caption\" sx={{ flex: 1 }}>\n {label}\n </Typography>\n <Stack alignItems=\"flex-end\">\n <Typography variant=\"caption\" fontWeight=\"600\">\n {value}\n </Typography>\n <Link variant=\"caption\" onClick={handleOpen}>\n {t('more_info')}\n </Link>\n </Stack>\n </Stack>\n }\n sx={{\n width: 'calc(100% + 11px)',\n mb: 0.5,\n '& > .MuiTypography-root': {\n width: '100%',\n },\n }}\n />\n\n <Dialog open={open} onClose={handleClose} maxWidth=\"sm\" fullWidth>\n <DialogTitle\n sx={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}\n >\n {modal.title}\n <IconButton onClick={handleClose} size=\"small\">\n <Iconify icon=\"carbon:close\" />\n </IconButton>\n </DialogTitle>\n <DialogContent>\n <Typography variant=\"body2\">{modal.description}</Typography>\n </DialogContent>\n </Dialog>\n </>\n );\n};\n\nexport default PaymentOverviewCheckbox;\n"],"names":[],"mappings":";;;;;;;;;;;AAwBA,MAAM,uBAAuB,GAAoB,CAAC,EAAE,YAAY,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAI;AACzF,IAAA,MAAM,EAAE,CAAC,EAAE,GAAG,SAAS,EAAE;IACzB,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC;AAEvC,IAAA,MAAM,UAAU,GAAG,CAAC,CAAsC,KAAI;QAC5D,CAAC,CAAC,cAAc,EAAE;QAClB,CAAC,CAAC,eAAe,EAAE;QACnB,OAAO,CAAC,IAAI,CAAC;AACf,KAAC;IAC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,WAAW,EAAA,EACV,EAAE,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,eAAe,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAA;AAE7E,gBAAA,KAAK,CAAC,KAAK;gBACZ,KAAA,CAAA,aAAA,CAAC,UAAU,IAAC,OAAO,EAAE,WAAW,EAAE,IAAI,EAAC,OAAO,EAAA;AAC5C,oBAAA,KAAA,CAAA,aAAA,CAAC,OAAO,EAAA,EAAC,IAAI,EAAC,cAAc,EAAA,CAAG,CACpB,CACD;AACd,YAAA,KAAA,CAAA,aAAA,CAAC,aAAa,EAAA,IAAA;AACZ,gBAAA,KAAA,CAAA,aAAA,CAAC,UAAU,EAAA,EAAC,OAAO,EAAC,OAAO,EAAA,EAAE,KAAK,CAAC,WAAW,CAAc,CAC9C,CACT,CACR;AAEP;;;;"}
@@ -1,70 +1,55 @@
1
- import { Card, Stack, Typography, Box, Button } from '@mui/material';
1
+ import { Card, Stack, Typography, Button } from '@mui/material';
2
+ import Iconify from '../../components/iconify/Iconify.js';
2
3
  import Image from '../../components/Image.js';
3
4
  import React, { useState, useMemo } from 'react';
4
5
  import ProductVariantsDialog from './ProductVariantsDialog.js';
5
6
  import { useFormContext, useWatch } from 'react-hook-form';
6
7
  import { getSelectedQuantityByVariant } from '../../utils/product.js';
7
8
  import useGlobal from '../../hooks/useGlobal.js';
8
- import { fCurrency } from '../../utils/formatNumber.js';
9
9
 
10
10
  const ProductCard = ({ eventProduct, eventId, isOnlyMerchandise }) => {
11
- const { t, lang } = useGlobal();
11
+ const { t } = useGlobal();
12
12
  const [openVariantDialog, setOpenVariantDialog] = useState(false);
13
- const { setValue, getValues } = useFormContext();
13
+ const { setValue } = useFormContext();
14
14
  const tickets = useWatch({ name: `tickets.${eventId}`, defaultValue: [] });
15
15
  const products = useWatch({ name: `products.${eventId}`, defaultValue: [] });
16
- const onSelectVariant = (selectedVariants) => {
17
- const normalized = Array.isArray(selectedVariants) ? selectedVariants : [selectedVariants];
18
- const currentProducts = getValues(`products.${eventId}`) ?? [];
19
- const nextProducts = [...currentProducts];
20
- normalized.forEach((selectedVariant) => {
21
- const index = nextProducts.findIndex((product) => product.eventProductVariantId === selectedVariant.eventProductVariantId);
22
- if (index >= 0) {
23
- if (selectedVariant.quantity <= 0) {
24
- nextProducts.splice(index, 1);
25
- }
26
- else {
27
- nextProducts[index] = {
28
- ...nextProducts[index],
29
- quantity: selectedVariant.quantity,
30
- };
31
- }
16
+ const onSelectVariant = (selectedVariant) => {
17
+ const variant = products.find((product) => product.eventProductVariantId === selectedVariant.eventProductVariantId);
18
+ if (variant) {
19
+ if (selectedVariant.quantity === 0) {
20
+ setValue(`products.${eventId}`, products.filter((product) => product.eventProductVariantId !== variant.eventProductVariantId));
32
21
  }
33
22
  else {
34
- if (selectedVariant.quantity > 0) {
35
- nextProducts.push(selectedVariant);
36
- }
23
+ setValue(`products.${eventId}`, products.map((product) => {
24
+ if (product.eventProductVariantId === selectedVariant.eventProductVariantId) {
25
+ return {
26
+ ...product,
27
+ quantity: selectedVariant.quantity,
28
+ };
29
+ }
30
+ return product;
31
+ }));
37
32
  }
38
- });
39
- setValue(`products.${eventId}`, nextProducts, {
40
- shouldDirty: true,
41
- shouldValidate: true,
42
- });
33
+ }
34
+ else if (selectedVariant.quantity !== 0) {
35
+ setValue(`products.${eventId}`, [...products, selectedVariant]);
36
+ }
43
37
  };
44
- const eventNotEmpty = useMemo(() => {
45
- const variantIds = new Set(eventProduct.eventProductVariants.map((variant) => variant.id));
46
- return products.some((product) => product?.quantity && variantIds.has(product.eventProductVariantId));
47
- }, [products, eventProduct.eventProductVariants]);
38
+ const eventNotEmpty = useMemo(() => products.some((product) => product?.quantity), [products]);
48
39
  return (React.createElement(React.Fragment, null,
49
- React.createElement(Card, { sx: {
50
- p: 0,
51
- borderRadius: 0,
52
- boxShadow: 'none',
53
- background: 'none',
54
- } },
55
- React.createElement(Stack, { spacing: 0 },
56
- React.createElement(Image, { src: eventProduct.product.previewImage.url, ratio: "21/9", sx: { borderRadius: 1, maxHeight: 96 } }),
40
+ React.createElement(Card, { sx: { p: 2 } },
41
+ React.createElement(Stack, { spacing: 1 },
42
+ React.createElement(Image, { src: eventProduct.product.previewImage.url, ratio: "1/1", sx: { borderRadius: 2 } }),
57
43
  React.createElement(Typography, { variant: "h5" }, eventProduct.product.name),
58
- React.createElement(Box, null,
59
- React.createElement(Typography, { variant: "body2", color: "text.primary" }, eventProduct.product.priceWithVat > 0
60
- ? fCurrency(eventProduct.product.priceWithVat, lang, eventProduct.product.currency)
61
- : t('free'))),
62
- React.createElement(Button, { variant: eventNotEmpty ? 'contained' : 'outlined', onClick: () => setOpenVariantDialog(true), fullWidth: true, sx: {
63
- color: eventNotEmpty ? (theme) => theme.palette.common.white : 'inherit',
64
- borderColor: (theme) => theme.palette.grey[300],
65
- } }, eventNotEmpty
66
- ? t('event.tickets.merchandise.show_added')
67
- : t('event.tickets.merchandise.show_sizes')))),
44
+ React.createElement(Typography, { variant: "caption", dangerouslySetInnerHTML: { __html: eventProduct.product.description }, sx: {
45
+ height: 44,
46
+ textOverflow: 'ellipsis',
47
+ overflow: 'hidden',
48
+ display: '-webkit-box',
49
+ WebkitLineClamp: 2,
50
+ WebkitBoxOrient: 'vertical',
51
+ } }),
52
+ React.createElement(Button, { variant: "contained", onClick: () => setOpenVariantDialog(true), fullWidth: true, startIcon: eventNotEmpty ? React.createElement(Iconify, { icon: "eva:edit-fill" }) : React.createElement(Iconify, { icon: "eva:plus-fill" }) }, eventNotEmpty ? t('change') : t('add')))),
68
53
  React.createElement(ProductVariantsDialog, { eventProduct: eventProduct, eventId: eventId, openDialog: openVariantDialog, onClose: () => setOpenVariantDialog(false), callback: onSelectVariant, selectedQuantityByVariant: getSelectedQuantityByVariant(products, tickets), isOnlyMerchandise: isOnlyMerchandise })));
69
54
  };
70
55
 
@@ -1 +1 @@
1
- {"version":3,"file":"ProductCard.js","sources":["../../../../src/form/product/ProductCard.tsx"],"sourcesContent":["import { Box, Button, Card, Stack, Typography } from '@mui/material';\nimport Image from '@components/Image';\nimport { IEventProduct } from '@utils/types/event-product.type';\nimport React, { useMemo, useState } from 'react';\nimport ProductVariantsDialog from '@form/product/ProductVariantsDialog';\nimport { IEventProductForm } from '@utils/types/product.type';\nimport { useFormContext, useWatch } from 'react-hook-form';\nimport { ITicketForm, ITicketFormTicket } from '@utils/types/ticket.type';\nimport { getSelectedQuantityByVariant } from '@utils/product';\nimport useGlobal from '@hooks/useGlobal.ts';\nimport { fCurrency } from '@utils/formatNumber';\n\ninterface Props {\n eventProduct: IEventProduct;\n eventId: number;\n isOnlyMerchandise?: boolean;\n}\n\nconst ProductCard: React.FC<Props> = ({ eventProduct, eventId, isOnlyMerchandise }) => {\n const { t, lang } = useGlobal();\n const [openVariantDialog, setOpenVariantDialog] = useState<boolean>(false);\n const { setValue, getValues } = useFormContext<ITicketForm>();\n const tickets: ITicketFormTicket[] = useWatch({ name: `tickets.${eventId}`, defaultValue: [] });\n const products: IEventProductForm[] = useWatch({ name: `products.${eventId}`, defaultValue: [] });\n\n const onSelectVariant = (selectedVariants: IEventProductForm[] | IEventProductForm) => {\n const normalized = Array.isArray(selectedVariants) ? selectedVariants : [selectedVariants];\n const currentProducts =\n (getValues(`products.${eventId}`) as IEventProductForm[] | undefined) ?? [];\n const nextProducts = [...currentProducts];\n\n normalized.forEach((selectedVariant) => {\n const index = nextProducts.findIndex(\n (product) => product.eventProductVariantId === selectedVariant.eventProductVariantId\n );\n\n if (index >= 0) {\n if (selectedVariant.quantity <= 0) {\n nextProducts.splice(index, 1);\n } else {\n nextProducts[index] = {\n ...nextProducts[index],\n quantity: selectedVariant.quantity,\n };\n }\n } else {\n if (selectedVariant.quantity > 0) {\n nextProducts.push(selectedVariant);\n }\n }\n });\n\n setValue(`products.${eventId}`, nextProducts, {\n shouldDirty: true,\n shouldValidate: true,\n });\n };\n\n const eventNotEmpty = useMemo(() => {\n const variantIds = new Set(eventProduct.eventProductVariants.map((variant) => variant.id));\n return products.some(\n (product) => product?.quantity && variantIds.has(product.eventProductVariantId)\n );\n }, [products, eventProduct.eventProductVariants]);\n\n return (\n <>\n <Card\n sx={{\n p: 0,\n borderRadius: 0,\n boxShadow: 'none',\n background: 'none',\n }}\n >\n <Stack spacing={0}>\n <Image\n src={eventProduct.product.previewImage.url}\n ratio=\"21/9\"\n sx={{ borderRadius: 1, maxHeight: 96 }}\n />\n <Typography variant=\"h5\">{eventProduct.product.name}</Typography>\n <Box>\n <Typography variant=\"body2\" color=\"text.primary\">\n {eventProduct.product.priceWithVat > 0\n ? fCurrency(eventProduct.product.priceWithVat, lang, eventProduct.product.currency)\n : t('free')}\n </Typography>\n </Box>\n <Button\n variant={eventNotEmpty ? 'contained' : 'outlined'}\n onClick={() => setOpenVariantDialog(true)}\n fullWidth\n sx={{\n color: eventNotEmpty ? (theme) => theme.palette.common.white : 'inherit',\n borderColor: (theme) => theme.palette.grey[300],\n }}\n >\n {eventNotEmpty\n ? t('event.tickets.merchandise.show_added')\n : t('event.tickets.merchandise.show_sizes')}\n </Button>\n </Stack>\n </Card>\n <ProductVariantsDialog\n eventProduct={eventProduct}\n eventId={eventId}\n openDialog={openVariantDialog}\n onClose={() => setOpenVariantDialog(false)}\n callback={onSelectVariant}\n selectedQuantityByVariant={getSelectedQuantityByVariant(products, tickets)}\n isOnlyMerchandise={isOnlyMerchandise}\n />\n </>\n );\n};\n\nexport default ProductCard;\n"],"names":[],"mappings":";;;;;;;;;AAkBA,MAAM,WAAW,GAAoB,CAAC,EAAE,YAAY,EAAE,OAAO,EAAE,iBAAiB,EAAE,KAAI;IACpF,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,GAAG,SAAS,EAAE;IAC/B,MAAM,CAAC,iBAAiB,EAAE,oBAAoB,CAAC,GAAG,QAAQ,CAAU,KAAK,CAAC;IAC1E,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,cAAc,EAAe;AAC7D,IAAA,MAAM,OAAO,GAAwB,QAAQ,CA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AA,EAAC,OAAO,EAAC,OAAO,EAAC,KAAK,EAAC,cAAc,EAAA,EAC7C,YAAY,CAAC,OAAO,CAAC,YAAY,GAAG;AACnC,0BAAE,SAAS,CAAC,YAAY,CAAC,OAAO,CAAC,YAAY,EAAE,IAAI,EAAE,YAAY,CAAC,OAAO,CAAC,QAAQ;AAClF,0BAAE,CAAC,CAAC,MAAM,CAAC,CACF,CACT;gBACN,KAAA,CAAA,aAAA,CAAC,MAAM,EAAA,EACL,OAAO,EAAE,aAAa,GAAG,WAAW,GAAG,UAAU,EACjD,OAAO,EAAE,MAAM,oBAAoB,CAAC,IAAI,CAAC,EACzC,SAAS,EAAA,IAAA,EACT,EAAE,EAAE;wBACF,KAAK,EAAE,aAAa,GAAG,CAAC,KAAK,KAAK,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,GAAG,SAAS;AACxE,wBAAA,WAAW,EAAE,CAAC,KAAK,KAAK,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC;AAChD,qBAAA,EAAA,EAEA;AACC,sBAAE,CAAC,CAAC,sCAAsC;AAC1C,sBAAE,CAAC,CAAC,sCAAsC,CAAC,CACtC,CACH,CACH;AACP,QAAA,KAAA,CAAA,aAAA,CAAC,qBAAqB,EAAA,EACpB,YAAY,EAAE,YAAY,EAC1B,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,iBAAiB,EAC7B,OAAO,EAAE,MAAM,oBAAoB,CAAC,KAAK,CAAC,EAC1C,QAAQ,EAAE,eAAe,EACzB,yBAAyB,EAAE,4BAA4B,CAAC,QAAQ,EAAE,OAAO,CAAC,EAC1E,iBAAiB,EAAE,iBAAiB,EAAA,CACpC,CACD;AAEP;;;;"}
1
+ {"version":3,"file":"ProductCard.js","sources":["../../../../src/form/product/ProductCard.tsx"],"sourcesContent":["import { Button, Card, Stack, Typography } from '@mui/material';\nimport { Iconify } from '@components/iconify';\nimport Image from '@components/Image';\nimport { IEventProduct } from '@utils/types/event-product.type';\nimport React, { useMemo, useState } from 'react';\nimport ProductVariantsDialog from '@form/product/ProductVariantsDialog';\nimport { IEventProductForm } from '@utils/types/product.type';\nimport { useFormContext, useWatch } from 'react-hook-form';\nimport { ITicketForm, ITicketFormTicket } from '@utils/types/ticket.type';\nimport { getSelectedQuantityByVariant } from '@utils/product';\nimport useGlobal from '@hooks/useGlobal.ts';\n\ninterface Props {\n eventProduct: IEventProduct;\n eventId: number;\n isOnlyMerchandise?: boolean;\n}\n\nconst ProductCard: React.FC<Props> = ({ eventProduct, eventId, isOnlyMerchandise }) => {\n const { t } = useGlobal();\n const [openVariantDialog, setOpenVariantDialog] = useState<boolean>(false);\n const { setValue } = useFormContext<ITicketForm>();\n const tickets: ITicketFormTicket[] = useWatch({ name: `tickets.${eventId}`, defaultValue: [] });\n const products: IEventProductForm[] = useWatch({ name: `products.${eventId}`, defaultValue: [] });\n\n const onSelectVariant = (selectedVariant: IEventProductForm) => {\n const variant = products.find(\n (product) => product.eventProductVariantId === selectedVariant.eventProductVariantId\n );\n\n if (variant) {\n if (selectedVariant.quantity === 0) {\n setValue(\n `products.${eventId}`,\n products.filter(\n (product) => product.eventProductVariantId !== variant.eventProductVariantId\n )\n );\n } else {\n setValue(\n `products.${eventId}`,\n products.map((product) => {\n if (product.eventProductVariantId === selectedVariant.eventProductVariantId) {\n return {\n ...product,\n quantity: selectedVariant.quantity,\n };\n }\n return product;\n })\n );\n }\n } else if (selectedVariant.quantity !== 0) {\n setValue(`products.${eventId}`, [...products, selectedVariant]);\n }\n };\n\n const eventNotEmpty = useMemo(() => products.some((product) => product?.quantity), [products]);\n\n return (\n <>\n <Card sx={{ p: 2 }}>\n <Stack spacing={1}>\n <Image src={eventProduct.product.previewImage.url} ratio=\"1/1\" sx={{ borderRadius: 2 }} />\n <Typography variant=\"h5\">{eventProduct.product.name}</Typography>\n <Typography\n variant=\"caption\"\n dangerouslySetInnerHTML={{ __html: eventProduct.product.description }}\n sx={{\n height: 44,\n textOverflow: 'ellipsis',\n overflow: 'hidden',\n display: '-webkit-box',\n WebkitLineClamp: 2,\n WebkitBoxOrient: 'vertical',\n }}\n />\n <Button\n variant=\"contained\"\n onClick={() => setOpenVariantDialog(true)}\n fullWidth\n startIcon={\n eventNotEmpty ? <Iconify icon=\"eva:edit-fill\" /> : <Iconify icon=\"eva:plus-fill\" />\n }\n >\n {eventNotEmpty ? t('change') : t('add')}\n </Button>\n </Stack>\n </Card>\n <ProductVariantsDialog\n eventProduct={eventProduct}\n eventId={eventId}\n openDialog={openVariantDialog}\n onClose={() => setOpenVariantDialog(false)}\n callback={onSelectVariant}\n selectedQuantityByVariant={getSelectedQuantityByVariant(products, tickets)}\n isOnlyMerchandise={isOnlyMerchandise}\n />\n </>\n );\n};\n\nexport default ProductCard;\n"],"names":[],"mappings":";;;;;;;;;AAkBA,MAAM,WAAW,GAAoB,CAAC,EAAE,YAAY,EAAE,OAAO,EAAE,iBAAiB,EAAE,KAAI;AACpF,IAAA,MAAM,EAAE,CAAC,EAAE,GAAG,SAAS,EAAE;IACzB,MAAM,CAAC,iBAAiB,EAAE,oBAAoB,CAAC,GAAG,QAAQ,CAAU,KAAK,CAAC;AAC1E,IAAA,MAAM,EAAE,QAAQ,EAAE,GAAG,cAAc,EAAe;AAClD,IAAA,MAAM,OAAO,GAAwB,QAAQ,CAAC,EAAE,IAAI,EAAE,CAAA,QAAA,EAAW,OAAO,CAAA,CAAE,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC;AAC/F,IAAA,MAAM,QAAQ,GAAwB,QAAQ,CAAC,EAAE,IAAI,EAAE,CAAA,SAAA,EAAY,OAAO,CAAA,CAAE,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC;AAEjG,IAAA,MAAM,eAAe,GAAG,CAAC,eAAkC,KAAI;AAC7D,QAAA,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAC3B,CAAC,OAAO,KAAK,OAAO,CAAC,qBAAqB,KAAK,eAAe,CAAC,qBAAqB,CACrF;QAED,IA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