PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 2.4.8
Booking for Appointments and Events Calendar – Amelia v2.4.8
2.4.8 2.4.7 2.4.6 2.4.5 2.4.4 2.4.3 2.4.2 2.4.1 2.4 trunk 1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.15 1.2.16 1.2.17 1.2.18 1.2.19 1.2.2 1.2.20 1.2.21 1.2.22 1.2.23 1.2.24 1.2.25 1.2.26 1.2.27 1.2.28 1.2.29 1.2.3 1.2.30 1.2.31 1.2.32 1.2.33 1.2.34 1.2.35 1.2.36 1.2.37 1.2.38 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.1.3 2.2 2.2.1 2.3
ameliabooking / v3 / src / assets / js / admin / booking.js
ameliabooking / v3 / src / assets / js / admin Last commit date
admin.js 1 month ago appointment.js 1 month ago booking.js 1 day ago customers.js 1 day ago event.js 1 month ago package.js 1 month ago payment.js 1 month ago socialAuthOptions.js 1 month ago status.js 1 month ago useReactiveCustomize.js 1 week ago
booking.js
86 lines
1 function useParams(store, cabinetType) {
2 return {
3 source: 'cabinet-' + cabinetType.value,
4 timeZone: store.getters['cabinet/getTimeZone'],
5 }
6 }
7
8 function getCabinetSource(userType) {
9 return userType === 'employee' || userType === 'provider'
10 ? 'cabinet-provider'
11 : 'cabinet-customer'
12 }
13
14 function useCustomFieldsData(bookings, userType) {
15 let result = []
16
17 bookings.forEach((booking) => {
18 if (['approved', 'pending'].includes(booking.status) && booking.customFields) {
19 let customFields = JSON.parse(booking.customFields)
20
21 Object.keys(customFields).forEach((customFieldId) => {
22 if (customFields[customFieldId]) {
23 let value =
24 customFields[customFieldId].type === 'file'
25 ? customFields[customFieldId]?.value
26 ? customFields[customFieldId].value
27 : ''
28 : customFields[customFieldId].value
29
30 if (Array.isArray(value) ? value.length : value) {
31 result.push({
32 label: customFields[customFieldId].label,
33 value: value,
34 type: customFields[customFieldId].type,
35 id: customFieldId,
36 entityId: booking.id,
37 customerId: booking.customer?.id,
38 source: getCabinetSource(userType),
39 })
40 }
41 }
42 })
43 }
44 })
45
46 if (userType === 'customer') {
47 return result
48 }
49
50 // For employee view, keep unique custom fields with their values
51 const uniqueFields = new Map()
52 result
53 .filter((i) => i.value)
54 .forEach((item) => {
55 if (!uniqueFields.has(item.label)) {
56 uniqueFields.set(item.label, item)
57 }
58 })
59 return Array.from(uniqueFields.values())
60 }
61
62 function useExtrasData(bookings, bookable) {
63 let result = {}
64
65 bookings.forEach((booking) => {
66 if (['approved', 'pending'].includes(booking.status)) {
67 booking.extras.forEach((bookingExtra) => {
68 if (!(bookingExtra.extraId in result)) {
69 result[bookingExtra.extraId] = {
70 quantity: 0,
71 price: bookingExtra.price,
72 name: bookable.extras.find((i) => i.id === bookingExtra.extraId).name,
73 }
74 }
75
76 result[bookingExtra.extraId].quantity =
77 result[bookingExtra.extraId].quantity + bookingExtra.quantity
78 })
79 }
80 })
81
82 return result
83 }
84
85 export { useParams, useCustomFieldsData, useExtrasData }
86