|
| 1 | +--- |
| 2 | +sidebar_label: cards |
| 3 | +title: cards |
| 4 | +description: You can learn about the cards config in the documentation of the DHTMLX JavaScript Booking library. Browse developer guides and API reference, try out code examples and live demos, and download a free 30-day evaluation version of DHTMLX Booking. |
| 5 | +--- |
| 6 | + |
| 7 | +# cards |
| 8 | + |
| 9 | +### Description |
| 10 | + |
| 11 | +@short: Optional. An array of objects containing the cards data |
| 12 | + |
| 13 | +### Usage |
| 14 | + |
| 15 | +~~~jsx {} |
| 16 | +cards?: [ |
| 17 | + { |
| 18 | + id: string | number, |
| 19 | + title: string, |
| 20 | + category?: string, |
| 21 | + subtitle?: string, |
| 22 | + details?: string, |
| 23 | + preview?: string, // url |
| 24 | + price?: string, |
| 25 | + review?: { |
| 26 | + star: number, |
| 27 | + count: number, |
| 28 | + }, |
| 29 | + slots: [ |
| 30 | + { |
| 31 | + from: number, |
| 32 | + to: number, |
| 33 | + size?: number, |
| 34 | + gap?: number, |
| 35 | + days?: array, // array of numbers |
| 36 | + dates?: array, // array of numbers |
| 37 | + }, {...} |
| 38 | + ], |
| 39 | + availableSlots?: array, // array of numbers |
| 40 | + usedSlots?: array, // array of numbers |
| 41 | + }, {...} |
| 42 | +]; |
| 43 | +~~~ |
| 44 | + |
| 45 | +### Parameters |
| 46 | + |
| 47 | +For each card object you can specify the following parameters: |
| 48 | + |
| 49 | +- `id` - (required) the ID of a card |
| 50 | +- `title` - (required) the title of a card (e.g., a specialist's name) |
| 51 | +- `category` - (optional) the category name of a card (e.g., a specialist's job) |
| 52 | +- `subtitle` - (optional) the subtitle of a card |
| 53 | +- `details` - (optional) other details of a card |
| 54 | +- `preview` - (optional) a card preview which is the link to the card image |
| 55 | +- `price` - (optional) the price of the service |
| 56 | +- `review` - (optional) rating information that includes the following parameters: |
| 57 | + - `star` - (optional) the number of rating stars (out of five) |
| 58 | + - `count` - (optional) the number of reviews |
| 59 | +- `slots` - (required) an array of objects with the following parameters for booking slots: |
| 60 | + - `from` - (required) a slot start time in hours from 0 to 24 |
| 61 | + - `to` - (required) a slot end time in hours from 0 to 24 |
| 62 | + - `size` - (optional) the duration of one slot in minutes TBD |
| 63 | + - `gap` - (optional) the gap between slots in minutes; 0 is set by default |
| 64 | + - `days` - (optional) days of the week when a slot is available for booking; possible values: from 0 to 6 where 0 is Sunday and 6 is Saturday; if no days are specified, all days are applied by default; if days are specified, the slot parameters (**to**, **from**, **size**, **gap**) defined for these days will be applied |
| 65 | + - `dates` - (optional) an array of timestamps in milliseconds which are exact dates when a slot is available; the slot parameters (**to**, **from**, **size**, **gap**) for these specified dates will be applied |
| 66 | +:::note |
| 67 | +Slot parameters specified for days will override common parameters defined for all days. |
| 68 | +Slot parameters specified for dates will override parameters defined for specific days and all days. |
| 69 | +If several slots objects are created for the same day, make sure that slots time ranges (**from** and **to**) do not overlap, otherwise, all slots data for these days will not be applied. |
| 70 | +::: |
| 71 | +- `availableSlots` - (optional) an array of timestamps of available slots in milliseconds; if available slots are specified here, all slots from the `slots` array are ignored (i.e., become unavailable) |
| 72 | +- `usedSlots` - (optional) an array of timestamps of booked slots in milliseconds; these slots are not visible for a user |
| 73 | + |
| 74 | +### Example |
| 75 | + |
| 76 | +~~~jsx {1-42,45} |
| 77 | +const cards = [ |
| 78 | + { |
| 79 | + id: "1", |
| 80 | + title: "Debra Weeks", |
| 81 | + category: "Allergist", |
| 82 | + subtitle: "5 years of experience", |
| 83 | + details: "Silverstone Medical Center (Vanderbilt Avenue 13, Chestnut, New Zealand)", |
| 84 | + preview: "https://files.webix.com/30d/d34de82e0a8e3b561988a46ce1e86743/stock-photo-doc.jpg", |
| 85 | + price: "37 $", |
| 86 | + review: { |
| 87 | + star: 1, |
| 88 | + count: 40, |
| 89 | + }, |
| 90 | + slots: [ |
| 91 | + { |
| 92 | + //a common slot rule for all days except those specified for the days and dates below |
| 93 | + from: 14, |
| 94 | + to: 17, |
| 95 | + size: 30, |
| 96 | + gap: 10, |
| 97 | + }, |
| 98 | + { |
| 99 | + //this rule is applied to days 2 and 5 (Tuesdays and Fridays) except |
| 100 | + //the Friday from the slot object below |
| 101 | + from: 12, |
| 102 | + to: 17, |
| 103 | + size: 50, |
| 104 | + gap: 20, |
| 105 | + days: [2,5], |
| 106 | + }, |
| 107 | + { |
| 108 | + //this rule is applied to days 3 and 4 (Wed and Thu) and exact date |
| 109 | + from: 18, |
| 110 | + to: 20, |
| 111 | + size: 45, |
| 112 | + gap: 20, |
| 113 | + days: [1,3] |
| 114 | + dates: [1683234000000] // exact upcoming date (May 5, 2023, Friday) |
| 115 | + }, |
| 116 | + ], |
| 117 | + }, {...} |
| 118 | +]; |
| 119 | + |
| 120 | +new booking.Booking("#root", { |
| 121 | + cards, |
| 122 | + // other parameters |
| 123 | +}); |
| 124 | +~~~ |
| 125 | + |
| 126 | +**Related articles:** |
0 commit comments