PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 2.4.6
Booking for Appointments and Events Calendar – Amelia v2.4.6
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 month ago customers.js 1 month 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 6 days ago
booking.js
75 lines
1 function useParams(store, cabinetType) {
2 return {
3 source: 'cabinet-' + cabinetType.value,
4 timeZone: store.getters['cabinet/getTimeZone'],
5 }
6 }
7
8 function useCustomFieldsData(bookings, userType) {
9 let result = []
10
11 bookings.forEach((booking) => {
12 if (['approved', 'pending'].includes(booking.status) && booking.customFields) {
13 let customFields = JSON.parse(booking.customFields)
14
15 Object.keys(customFields).forEach((customFieldId) => {
16 if (customFields[customFieldId]) {
17 let value =
18 customFields[customFieldId].type === 'file'
19 ? customFields[customFieldId]?.value
20 ? customFields[customFieldId].value
21 : ''
22 : customFields[customFieldId].value
23
24 if (Array.isArray(value) ? value.length : value) {
25 result.push({
26 label: customFields[customFieldId].label,
27 value: value,
28 })
29 }
30 }
31 })
32 }
33 })
34
35 if (userType === 'customer') {
36 return result
37 }
38
39 // For employee view, keep unique custom fields with their values
40 const uniqueFields = new Map()
41 result
42 .filter((i) => i.value)
43 .forEach((item) => {
44 if (!uniqueFields.has(item.label)) {
45 uniqueFields.set(item.label, item)
46 }
47 })
48 return Array.from(uniqueFields.values())
49 }
50
51 function useExtrasData(bookings, bookable) {
52 let result = {}
53
54 bookings.forEach((booking) => {
55 if (['approved', 'pending'].includes(booking.status)) {
56 booking.extras.forEach((bookingExtra) => {
57 if (!(bookingExtra.extraId in result)) {
58 result[bookingExtra.extraId] = {
59 quantity: 0,
60 price: bookingExtra.price,
61 name: bookable.extras.find((i) => i.id === bookingExtra.extraId).name,
62 }
63 }
64
65 result[bookingExtra.extraId].quantity =
66 result[bookingExtra.extraId].quantity + bookingExtra.quantity
67 })
68 }
69 })
70
71 return result
72 }
73
74 export { useParams, useCustomFieldsData, useExtrasData }
75