@wix/agent-skills 1.14.0 → 1.15.0

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 (247) hide show
  1. package/README.md +4 -1
  2. package/package.json +1 -1
  3. package/skills/README.md +23 -0
  4. package/skills/wix-app/SKILL.md +10 -2
  5. package/skills/wix-app/references/AUTO_PATTERNS_DASHBOARD.md +326 -0
  6. package/skills/wix-app/references/CODE_QUALITY.md +1 -0
  7. package/skills/wix-app/references/CUSTOM_ELEMENT_WIDGET.md +124 -115
  8. package/skills/wix-app/references/DASHBOARD_PAGE.md +3 -0
  9. package/skills/wix-app/references/EDITOR_REACT_COMPONENT.md +23 -9
  10. package/skills/wix-app/references/SITE_PLUGIN.md +1 -1
  11. package/skills/wix-app/references/auto-patterns-dashboard/action-cell.md +115 -0
  12. package/skills/wix-app/references/auto-patterns-dashboard/app-config-structure.md +264 -0
  13. package/skills/wix-app/references/auto-patterns-dashboard/app-context.md +37 -0
  14. package/skills/wix-app/references/auto-patterns-dashboard/bulk-actions.md +86 -0
  15. package/skills/wix-app/references/auto-patterns-dashboard/collection-page-actions.md +119 -0
  16. package/skills/wix-app/references/auto-patterns-dashboard/collection-page.md +103 -0
  17. package/skills/wix-app/references/auto-patterns-dashboard/custom-actions-override.md +76 -0
  18. package/skills/wix-app/references/auto-patterns-dashboard/custom-columns-override.md +82 -0
  19. package/skills/wix-app/references/auto-patterns-dashboard/custom-components-override.md +89 -0
  20. package/skills/wix-app/references/auto-patterns-dashboard/custom-header-override.md +124 -0
  21. package/skills/wix-app/references/auto-patterns-dashboard/custom-sections-override.md +91 -0
  22. package/skills/wix-app/references/auto-patterns-dashboard/custom-slots-override.md +71 -0
  23. package/skills/wix-app/references/auto-patterns-dashboard/entity-page-actions.md +70 -0
  24. package/skills/wix-app/references/auto-patterns-dashboard/entity-page-view-actions.md +73 -0
  25. package/skills/wix-app/references/auto-patterns-dashboard/entity-page.md +98 -0
  26. package/skills/wix-app/references/auto-patterns-dashboard/example-patterns.json +278 -0
  27. package/skills/wix-app/references/auto-patterns-dashboard/pages-configuration.md +94 -0
  28. package/skills/wix-app/references/auto-patterns-dashboard/resolved-action.md +43 -0
  29. package/skills/wix-app/references/auto-patterns-dashboard/sdk-utilities.md +66 -0
  30. package/skills/wix-app/references/auto-patterns-dashboard/views.md +76 -0
  31. package/skills/wix-app/references/editor-react-component/ACCESSIBILITY.md +1 -14
  32. package/skills/wix-app/references/editor-react-component/COMPONENT-API.md +54 -29
  33. package/skills/wix-app/references/editor-react-component/COMPONENT-CONFIGURATION.md +2 -2
  34. package/skills/wix-app/references/editor-react-component/CSS-GUIDELINES.md +17 -105
  35. package/skills/wix-app/references/editor-react-component/DESIGN-STATES.md +127 -0
  36. package/skills/wix-app/references/editor-react-component/PARTS.md +2 -1
  37. package/skills/wix-app/references/editor-react-component/REACT-GUIDELINES.md +15 -15
  38. package/skills/wix-app/references/editor-react-component/REACT-PATTERNS.md +25 -53
  39. package/skills/wix-app/scripts/generate-auto-patterns.js +510 -0
  40. package/skills/wix-auth/SKILL.md +12 -0
  41. package/skills/wix-auth/references/device-flow.md +140 -0
  42. package/skills/wix-docs/SKILL.md +188 -0
  43. package/skills/wix-docs/references/API_SPEC_SEARCH.md +213 -0
  44. package/skills/wix-docs/references/EXTRACTING.md +120 -0
  45. package/skills/wix-headless/SKILL.md +84 -130
  46. package/skills/wix-headless/entry/bootstrap.mjs +93 -0
  47. package/skills/wix-headless/entry/skill.md +78 -0
  48. package/skills/wix-headless/references/AI_FEATURES.md +178 -0
  49. package/skills/wix-headless/references/CAPABILITIES.md +84 -0
  50. package/skills/wix-headless/references/DISCOVERY.md +34 -56
  51. package/skills/wix-headless/references/DOC_DISCOVERY.md +37 -0
  52. package/skills/wix-headless/references/FEEDBACK.md +118 -0
  53. package/skills/wix-headless/references/IMAGE_GENERATION.md +69 -0
  54. package/skills/wix-headless/references/SDK_HANDOFF.md +97 -0
  55. package/skills/wix-headless/references/SEED.md +44 -188
  56. package/skills/wix-headless/references/SETUP.md +32 -103
  57. package/skills/wix-headless/references/astro.md +98 -0
  58. package/skills/wix-headless/references/inline-recipes/how-to-code-a-blog.md +196 -0
  59. package/skills/wix-headless/references/inline-recipes/how-to-code-a-store.md +236 -0
  60. package/skills/wix-headless/references/inline-recipes/how-to-code-bookings.md +279 -0
  61. package/skills/wix-headless/references/inline-recipes/how-to-code-cms.md +163 -0
  62. package/skills/wix-headless/references/inline-recipes/how-to-code-events.md +203 -0
  63. package/skills/wix-headless/references/inline-recipes/how-to-code-forms.md +222 -0
  64. package/skills/wix-headless/references/inline-recipes/how-to-code-members-astro.md +124 -0
  65. package/skills/wix-headless/references/inline-recipes/how-to-code-members-custom-login.md +160 -0
  66. package/skills/wix-headless/references/inline-recipes/how-to-code-members-non-astro.md +118 -0
  67. package/skills/wix-headless/references/inline-recipes/how-to-code-portfolio.md +132 -0
  68. package/skills/wix-headless/references/inline-recipes/how-to-code-pricing-plans.md +124 -0
  69. package/skills/wix-headless/references/inline-recipes/how-to-code-restaurant-orders.md +188 -0
  70. package/skills/wix-headless/references/inline-recipes/how-to-code-restaurant-reservations.md +173 -0
  71. package/skills/wix-headless/references/inline-recipes/how-to-code-restaurants.md +161 -0
  72. package/skills/wix-headless/references/inline-recipes/setup-blog.md +175 -0
  73. package/skills/wix-headless/references/inline-recipes/setup-bookings.md +228 -0
  74. package/skills/wix-headless/references/inline-recipes/setup-cms.md +200 -0
  75. package/skills/wix-headless/references/inline-recipes/setup-events.md +196 -0
  76. package/skills/wix-headless/references/inline-recipes/setup-forms.md +174 -0
  77. package/skills/wix-headless/references/inline-recipes/setup-online-store.md +176 -0
  78. package/skills/wix-headless/references/inline-recipes/setup-portfolio.md +153 -0
  79. package/skills/wix-headless/references/inline-recipes/setup-pricing-plans.md +229 -0
  80. package/skills/wix-headless/references/inline-recipes/setup-restaurant-orders.md +161 -0
  81. package/skills/wix-headless/references/inline-recipes/setup-restaurant-reservations.md +117 -0
  82. package/skills/wix-headless/references/inline-recipes/setup-restaurants.md +152 -0
  83. package/skills/wix-headless/references/managed/AUTHENTICATION.md +57 -0
  84. package/skills/wix-headless/references/managed/CONNECT.md +74 -0
  85. package/skills/wix-headless/references/managed/CREATE.md +130 -0
  86. package/skills/wix-headless/references/managed/DEPLOYMENT.md +57 -0
  87. package/skills/wix-headless/references/non-astro.md +59 -0
  88. package/skills/wix-headless/references/self-managed/AUTHENTICATION.md +22 -0
  89. package/skills/wix-headless/references/self-managed/DEPLOYMENT.md +7 -0
  90. package/skills/wix-headless/references/stripe/AUTHENTICATION.md +55 -0
  91. package/skills/wix-headless/references/stripe/DEPLOYMENT.md +63 -0
  92. package/skills/wix-manage/SKILL.md +24 -1
  93. package/skills/wix-manage/references/analytics/query-site-analytics.md +241 -0
  94. package/skills/wix-manage/references/bookings/create-and-update-booking-services.md +1 -1
  95. package/skills/wix-manage/references/bookings/diagnose-availability-issues.md +265 -0
  96. package/skills/wix-manage/references/marketing/create-and-publish-social-post.md +436 -0
  97. package/skills/wix-manage/references/marketing/generate-and-publish-marketing-plan.md +209 -0
  98. package/skills/wix-manage/references/rich-content/author-ricos-rich-content.md +249 -0
  99. package/skills/wix-manage/references/stores/create-product-with-options-catalog-v3.md +51 -0
  100. package/skills/wix-vibe-headless/SKILL.md +136 -0
  101. package/skills/wix-vibe-headless/references/blog/INSTRUCTIONS.md +128 -0
  102. package/skills/wix-vibe-headless/references/blog/wix-blog.js +217 -0
  103. package/skills/wix-vibe-headless/references/bookings/INSTRUCTIONS.md +153 -0
  104. package/skills/wix-vibe-headless/references/bookings/wix-bookings-checkout.js +147 -0
  105. package/skills/wix-vibe-headless/references/bookings/wix-bookings-services.js +215 -0
  106. package/skills/wix-vibe-headless/references/cms/INSTRUCTIONS.md +154 -0
  107. package/skills/wix-vibe-headless/references/cms/wix-cms.js +186 -0
  108. package/skills/wix-vibe-headless/references/events/INSTRUCTIONS.md +142 -0
  109. package/skills/wix-vibe-headless/references/events/wix-events-browse.js +135 -0
  110. package/skills/wix-vibe-headless/references/events/wix-events-registration.js +187 -0
  111. package/skills/wix-vibe-headless/references/members/INSTRUCTIONS.md +211 -0
  112. package/skills/wix-vibe-headless/references/members/wix-members-auth.js +387 -0
  113. package/skills/wix-vibe-headless/references/portfolio/INSTRUCTIONS.md +111 -0
  114. package/skills/wix-vibe-headless/references/portfolio/wix-portfolio.js +194 -0
  115. package/skills/wix-vibe-headless/references/pricing-plans/INSTRUCTIONS.md +127 -0
  116. package/skills/wix-vibe-headless/references/pricing-plans/wix-pricing-plans.js +157 -0
  117. package/skills/wix-vibe-headless/references/restaurants/INSTRUCTIONS.md +138 -0
  118. package/skills/wix-vibe-headless/references/restaurants/wix-restaurants-menu.js +224 -0
  119. package/skills/wix-vibe-headless/references/restaurants/wix-restaurants-ordering.js +156 -0
  120. package/skills/wix-vibe-headless/references/restaurants/wix-restaurants-reservations.js +107 -0
  121. package/skills/wix-vibe-headless/references/shared/wix-client.js +186 -0
  122. package/skills/wix-vibe-headless/references/storefront/INSTRUCTIONS.md +155 -0
  123. package/skills/wix-vibe-headless/references/storefront/wix-store-cart.js +147 -0
  124. package/skills/wix-vibe-headless/references/storefront/wix-store-catalog.js +142 -0
  125. package/skills/wix-headless/references/BUILD-astro.md +0 -253
  126. package/skills/wix-headless/references/BUILD-own-build.md +0 -167
  127. package/skills/wix-headless/references/BUILD.md +0 -105
  128. package/skills/wix-headless/references/DESIGN_SYSTEM.md +0 -165
  129. package/skills/wix-headless/references/DISCOVERY-connect.md +0 -55
  130. package/skills/wix-headless/references/DISCOVERY-create.md +0 -238
  131. package/skills/wix-headless/references/PLAN-connect.md +0 -19
  132. package/skills/wix-headless/references/PLAN-create.md +0 -17
  133. package/skills/wix-headless/references/PLAN.md +0 -92
  134. package/skills/wix-headless/references/astro/blog/BLOG_PAGES.md +0 -300
  135. package/skills/wix-headless/references/astro/blog/BLOG_SETUP.md +0 -218
  136. package/skills/wix-headless/references/astro/bookings/COMPONENTS.md +0 -45
  137. package/skills/wix-headless/references/astro/bookings/SERVICES_PAGES.md +0 -77
  138. package/skills/wix-headless/references/astro/cms/CMS_FOUNDATIONS.md +0 -214
  139. package/skills/wix-headless/references/astro/cms/FAQ_KNOWLEDGE_BASE.md +0 -231
  140. package/skills/wix-headless/references/astro/cms/PORTFOLIO.md +0 -453
  141. package/skills/wix-headless/references/astro/cms/RESOURCE_LIBRARY.md +0 -354
  142. package/skills/wix-headless/references/astro/cms/TEAM_DIRECTORY.md +0 -299
  143. package/skills/wix-headless/references/astro/designer/INSTRUCTIONS.md +0 -351
  144. package/skills/wix-headless/references/astro/ecom/CART_PAGES.md +0 -119
  145. package/skills/wix-headless/references/astro/ecom/CART_WIRING.md +0 -103
  146. package/skills/wix-headless/references/astro/ecom/COMPONENTS_CSS.md +0 -132
  147. package/skills/wix-headless/references/astro/forms/CONTACT_FORM.md +0 -463
  148. package/skills/wix-headless/references/astro/gift-cards/COMPONENTS.md +0 -119
  149. package/skills/wix-headless/references/astro/gift-cards/PAGES.md +0 -129
  150. package/skills/wix-headless/references/astro/stores/BACK_IN_STOCK.md +0 -178
  151. package/skills/wix-headless/references/astro/stores/CATEGORY_PAGES.md +0 -85
  152. package/skills/wix-headless/references/astro/stores/COMPONENTS_CSS.md +0 -129
  153. package/skills/wix-headless/references/astro/stores/HOME_AND_NAV.md +0 -229
  154. package/skills/wix-headless/references/astro/stores/PRODUCT_PAGES.md +0 -215
  155. package/skills/wix-headless/references/astro/stores/SHARED_WIRING.md +0 -165
  156. package/skills/wix-headless/references/astro/templates/Layout.astro +0 -132
  157. package/skills/wix-headless/references/astro/templates/astro.config.mjs +0 -41
  158. package/skills/wix-headless/references/astro/templates/bookings/AvailabilityCalendar.tsx +0 -374
  159. package/skills/wix-headless/references/astro/templates/bookings/BookingForm.tsx +0 -136
  160. package/skills/wix-headless/references/astro/templates/bookings/SeoTags.astro +0 -25
  161. package/skills/wix-headless/references/astro/templates/bookings/ServiceBookingFlow.tsx +0 -71
  162. package/skills/wix-headless/references/astro/templates/bookings/ServiceCard.astro +0 -54
  163. package/skills/wix-headless/references/astro/templates/bookings/booking-confirmation.astro +0 -49
  164. package/skills/wix-headless/references/astro/templates/bookings/bookingDriver.ts +0 -245
  165. package/skills/wix-headless/references/astro/templates/bookings/components-bookings.css +0 -424
  166. package/skills/wix-headless/references/astro/templates/bookings/services/[slug].astro +0 -176
  167. package/skills/wix-headless/references/astro/templates/bookings/services/index.astro +0 -181
  168. package/skills/wix-headless/references/astro/templates/ecom/CartBadge.tsx +0 -84
  169. package/skills/wix-headless/references/astro/templates/ecom/CartView.tsx +0 -543
  170. package/skills/wix-headless/references/astro/templates/ecom/cart.astro +0 -13
  171. package/skills/wix-headless/references/astro/templates/ecom/components-ecom.css +0 -302
  172. package/skills/wix-headless/references/astro/templates/ecom/discounts.ts +0 -71
  173. package/skills/wix-headless/references/astro/templates/ecom/thank-you.astro +0 -24
  174. package/skills/wix-headless/references/astro/templates/gift-cards/GiftCardPurchase.tsx +0 -172
  175. package/skills/wix-headless/references/astro/templates/gift-cards/_home-teaser-snippet.astro +0 -42
  176. package/skills/wix-headless/references/astro/templates/gift-cards/_nav-snippet.astro +0 -11
  177. package/skills/wix-headless/references/astro/templates/gift-cards/components-gift-cards.css +0 -220
  178. package/skills/wix-headless/references/astro/templates/gift-cards/gift-cards.astro +0 -51
  179. package/skills/wix-headless/references/astro/templates/gift-cards/gift-cards.ts +0 -75
  180. package/skills/wix-headless/references/astro/templates/global.css +0 -288
  181. package/skills/wix-headless/references/astro/templates/stores/AddToCartButton.tsx +0 -77
  182. package/skills/wix-headless/references/astro/templates/stores/BackInStockForm.tsx +0 -176
  183. package/skills/wix-headless/references/astro/templates/stores/CategoryRail.astro +0 -69
  184. package/skills/wix-headless/references/astro/templates/stores/ProductCard.astro +0 -79
  185. package/skills/wix-headless/references/astro/templates/stores/ProductPurchase.tsx +0 -397
  186. package/skills/wix-headless/references/astro/templates/stores/SeoTags.astro +0 -21
  187. package/skills/wix-headless/references/astro/templates/stores/back-in-stock.ts +0 -67
  188. package/skills/wix-headless/references/astro/templates/stores/categories.ts +0 -155
  189. package/skills/wix-headless/references/astro/templates/stores/category/[slug].astro +0 -130
  190. package/skills/wix-headless/references/astro/templates/stores/components-stores.css +0 -400
  191. package/skills/wix-headless/references/astro/templates/stores/products/[slug].astro +0 -128
  192. package/skills/wix-headless/references/astro/templates/stores/products/index.astro +0 -101
  193. package/skills/wix-headless/references/blog/BLOG_CONTENT.md +0 -161
  194. package/skills/wix-headless/references/blog/INSTRUCTIONS.md +0 -32
  195. package/skills/wix-headless/references/bookings/FLOW.md +0 -246
  196. package/skills/wix-headless/references/bookings/INSTRUCTIONS.md +0 -95
  197. package/skills/wix-headless/references/bookings/SERVICES_DATA.md +0 -355
  198. package/skills/wix-headless/references/cms/CMS_FOUNDATIONS.md +0 -176
  199. package/skills/wix-headless/references/cms/INSTRUCTIONS.md +0 -71
  200. package/skills/wix-headless/references/commands/known-apps.json +0 -6
  201. package/skills/wix-headless/references/custom/CONNECTION_PLAN.md +0 -142
  202. package/skills/wix-headless/references/custom/INSTRUCTIONS.md +0 -88
  203. package/skills/wix-headless/references/custom/blog/WIRING.md +0 -52
  204. package/skills/wix-headless/references/custom/bookings/WIRING.md +0 -197
  205. package/skills/wix-headless/references/custom/cms/WIRING.md +0 -97
  206. package/skills/wix-headless/references/custom/ecom/WIRING.md +0 -67
  207. package/skills/wix-headless/references/custom/forms/WIRING.md +0 -101
  208. package/skills/wix-headless/references/custom/stores/WIRING.md +0 -80
  209. package/skills/wix-headless/references/ecom/INSTRUCTIONS.md +0 -59
  210. package/skills/wix-headless/references/forms/INSTRUCTIONS.md +0 -43
  211. package/skills/wix-headless/references/gift-cards/INSTRUCTIONS.md +0 -51
  212. package/skills/wix-headless/references/images/INSTRUCTIONS.md +0 -357
  213. package/skills/wix-headless/references/seed-recipes.md +0 -49
  214. package/skills/wix-headless/references/shared/AGENTS_MD.md +0 -47
  215. package/skills/wix-headless/references/shared/AUTHENTICATION.md +0 -108
  216. package/skills/wix-headless/references/shared/BUILD_NOISE.md +0 -8
  217. package/skills/wix-headless/references/shared/DESIGN_MD.md +0 -84
  218. package/skills/wix-headless/references/shared/DOCS_SEARCH.md +0 -41
  219. package/skills/wix-headless/references/shared/IMAGE_GENERATION.md +0 -186
  220. package/skills/wix-headless/references/shared/IMPLEMENTER.md +0 -206
  221. package/skills/wix-headless/references/shared/PRODUCTION_SHARP_EDGES.md +0 -97
  222. package/skills/wix-headless/references/shared/RETURN_CONTRACT.md +0 -143
  223. package/skills/wix-headless/references/shared/STYLING.md +0 -140
  224. package/skills/wix-headless/references/stores/INSTRUCTIONS.md +0 -126
  225. package/skills/wix-headless/references/stores/PRODUCT_CATALOG_DATA.md +0 -252
  226. package/skills/wix-headless/references/verticals/_schema.json +0 -74
  227. package/skills/wix-headless/references/verticals/_schema.md +0 -95
  228. package/skills/wix-headless/references/verticals/blog.md +0 -31
  229. package/skills/wix-headless/references/verticals/bookings.md +0 -41
  230. package/skills/wix-headless/references/verticals/cms.md +0 -30
  231. package/skills/wix-headless/references/verticals/ecom.md +0 -25
  232. package/skills/wix-headless/references/verticals/forms.md +0 -26
  233. package/skills/wix-headless/references/verticals/gift-cards.md +0 -24
  234. package/skills/wix-headless/references/verticals/stores.md +0 -33
  235. package/skills/wix-headless/scripts/check-manifest.mjs +0 -335
  236. package/skills/wix-headless/scripts/compose.mjs +0 -520
  237. package/skills/wix-headless/scripts/emit-design-tokens.mjs +0 -157
  238. package/skills/wix-headless/scripts/flatten.sh +0 -61
  239. package/skills/wix-headless/scripts/generate-images.mjs +0 -242
  240. package/skills/wix-headless/scripts/patch-decorative-slots.mjs +0 -154
  241. package/skills/wix-headless/scripts/plan-entity-image-waves.mjs +0 -190
  242. package/skills/wix-headless/scripts/scaffold.sh +0 -139
  243. package/skills/wix-headless/scripts/seed-utilities.sh +0 -93
  244. package/skills/wix-headless/scripts/write-decorative-json.mjs +0 -62
  245. package/skills/wix-headless/shared-utilities/analytics.ts +0 -40
  246. package/skills/wix-headless/shared-utilities/ricos.ts +0 -179
  247. package/skills/wix-headless/shared-utilities/wix-image.ts +0 -72
@@ -1,136 +0,0 @@
1
- import { useState } from "react";
2
- import { book, navigateToCheckout, BookResultType } from "./bookingDriver";
3
- import type { SelectedSlot } from "./bookingDriver";
4
-
5
- // BookingForm.tsx — client:only="react" island. Renders the service's booking
6
- // form SCHEMA (from @wix/forms, fetched server-side and passed in as `fields`),
7
- // collects the values keyed by each field's `target`, and drives the booking
8
- // sequence in bookingDriver.book(). This is the same schema-driven renderer the
9
- // forms vertical uses (references/astro/forms/CONTACT_FORM.md) — generic inputs
10
- // chosen by `componentType` — so it adapts to whatever fields the booking form
11
- // defines, rather than hardcoding first/last/email/phone.
12
- //
13
- // On submit: book() returns CheckoutRequired (paid → hand off to the Wix-hosted
14
- // checkout) or CheckoutSkipped (free / pay-in-person → straight to confirmation).
15
-
16
- export interface BookingFormField {
17
- label: string;
18
- target: string; // the key createBooking expects in formSubmission
19
- required: boolean;
20
- componentType: string; // "TEXT_INPUT" | "DROPDOWN" | "PHONE_INPUT"
21
- identifier?: string;
22
- options?: { value: string; label: string }[];
23
- }
24
-
25
- interface Props {
26
- service: any; // SSR-fetched service — bookingDriver reads payment + bookingPolicy
27
- serviceName: string;
28
- slot: SelectedSlot;
29
- fields: BookingFormField[];
30
- onSuccess: (id: string, startDate?: string) => void;
31
- onCancel: () => void;
32
- }
33
-
34
- const friendlyError = (err: any): string => {
35
- // Surface field validation (e.g. a malformed phone number) rather than crashing.
36
- const violations = err?.details?.validationError?.fieldViolations ?? [];
37
- const first = violations[0]?.description ?? violations[0]?.data?.errors?.[0]?.errorMessage;
38
- if (first) return first;
39
- if (typeof err?.message === "string") return err.message;
40
- return "Something went wrong completing your booking. Please try again.";
41
- };
42
-
43
- export default function BookingForm({ service, serviceName, slot, fields, onSuccess, onCancel }: Props) {
44
- const [values, setValues] = useState<Record<string, string>>({});
45
- const [status, setStatus] = useState<"idle" | "submitting">("idle");
46
- const [error, setError] = useState<string | null>(null);
47
-
48
- const set = (target: string, v: string) =>
49
- setValues((prev) => ({ ...prev, [target]: v }));
50
-
51
- const when = new Date(slot.localStartDate).toLocaleString([], {
52
- weekday: "long", month: "long", day: "numeric", hour: "2-digit", minute: "2-digit",
53
- });
54
-
55
- const handleSubmit = async (e: React.FormEvent) => {
56
- e.preventDefault();
57
- setStatus("submitting"); setError(null);
58
- try {
59
- const result = await book({
60
- service,
61
- slot,
62
- formSubmission: values, // keyed by each field's `target`
63
- timezone: slot.timezone,
64
- });
65
- if (result.type === BookResultType.CheckoutRequired) {
66
- // Paid: hand the cart to the Wix-hosted checkout; it returns to /booking-confirmation.
67
- // Carry service + start time on the return URL so the confirmation can show them
68
- // (the in-memory selection is lost across the full-page redirect to Wix and back).
69
- await navigateToCheckout(
70
- result.cartId,
71
- `${window.location.origin}/booking-confirmation?service=${encodeURIComponent(serviceName)}&startDate=${encodeURIComponent(slot.localStartDate)}`,
72
- );
73
- return; // redirect in progress
74
- }
75
- onSuccess(result.orderId, slot.localStartDate); // free / pay-in-person
76
- } catch (err) {
77
- console.error("[booking] failed:", err);
78
- setError(friendlyError(err));
79
- setStatus("idle");
80
- }
81
- };
82
-
83
- return (
84
- <form className="booking-form" onSubmit={handleSubmit}>
85
- <div className="booking-form-summary">
86
- <strong>{serviceName}</strong>
87
- <span>{when}</span>
88
- <button type="button" className="booking-form-change" onClick={onCancel}>Choose another time</button>
89
- </div>
90
-
91
- {fields.map((field) => (
92
- <div key={field.target} className="booking-field">
93
- <label className="booking-label">
94
- {field.label}
95
- {field.required && <span className="booking-required" aria-hidden="true"> *</span>}
96
- </label>
97
- {field.componentType === "DROPDOWN" && field.options ? (
98
- <select
99
- className="booking-input"
100
- required={field.required}
101
- value={values[field.target] ?? ""}
102
- onChange={(e) => set(field.target, e.target.value)}
103
- >
104
- <option value="">Select an option</option>
105
- {field.options.map((o) => (
106
- <option key={o.value} value={o.value}>{o.label}</option>
107
- ))}
108
- </select>
109
- ) : field.identifier === "TEXT_AREA" || field.target?.includes("message") ? (
110
- <textarea
111
- className="booking-input"
112
- required={field.required}
113
- rows={4}
114
- value={values[field.target] ?? ""}
115
- onChange={(e) => set(field.target, e.target.value)}
116
- />
117
- ) : (
118
- <input
119
- className="booking-input"
120
- type={field.target === "email" ? "email" : field.componentType === "PHONE_INPUT" ? "tel" : "text"}
121
- required={field.required}
122
- value={values[field.target] ?? ""}
123
- onChange={(e) => set(field.target, e.target.value)}
124
- />
125
- )}
126
- </div>
127
- ))}
128
-
129
- {error && <p className="booking-error" role="alert">{error}</p>}
130
-
131
- <button type="submit" className="booking-cta" disabled={status === "submitting"}>
132
- {status === "submitting" ? "Booking…" : "Confirm booking"}
133
- </button>
134
- </form>
135
- );
136
- }
@@ -1,25 +0,0 @@
1
- ---
2
- // SeoTags.astro — renders Wix-resolved SEO tags into <head> for service pages.
3
- // Pass `service.seoData.tags` (Services V2) — title/meta/link/script — so the
4
- // service detail page ships Wix's sitemap/SEO/social tags. Mirrors the stores
5
- // SeoTags template. Mount inside the Layout's `head` slot on `/services/[slug]`.
6
- interface SeoTag {
7
- type?: string;
8
- props?: Record<string, any> | null;
9
- children?: string;
10
- disabled?: boolean;
11
- }
12
- interface Props { tags?: SeoTag[]; }
13
- const { tags = [] } = Astro.props;
14
- const visibleTags = tags.filter((t) => !t.disabled);
15
- ---
16
- {
17
- visibleTags.map((tag) => {
18
- const props = tag.props ?? {};
19
- if (tag.type === "title") return <title set:html={tag.children ?? ""} />;
20
- if (tag.type === "meta") return <meta {...props} />;
21
- if (tag.type === "link") return <link {...props} />;
22
- if (tag.type === "script") return <script {...props} is:inline set:html={tag.children ?? ""} />;
23
- return null;
24
- })
25
- }
@@ -1,71 +0,0 @@
1
- import { useState } from "react";
2
- import AvailabilityCalendar, { type StaffMemberOption, type LocationOption } from "./AvailabilityCalendar";
3
- import BookingForm, { type BookingFormField } from "./BookingForm";
4
- import type { SelectedSlot } from "./bookingDriver";
5
-
6
- // ServiceBookingFlow.tsx — client:only="react" coordinator island. Holds the
7
- // selected-slot state shared between the calendar and the form, transitions
8
- // between them, and redirects to the confirmation page on success. The SSR
9
- // detail page passes the full `service` (the driver reads its payment/policy),
10
- // the booking-form `fields` (the @wix/forms schema), the service's `staffMembers`
11
- // (for the optional staff picker), the service's business `locations` + the
12
- // catalog-chosen `locationId` (so the calendar scopes availability to one
13
- // location — see AvailabilityCalendar) through to the calendar.
14
- //
15
- // This is the framework-agnostic flow shape (a step coordinator + shared
16
- // selection state). On another framework, the same two steps + shared state can
17
- // be route-driven instead — see references/bookings/FLOW.md.
18
-
19
- interface Props {
20
- service: any;
21
- serviceName: string;
22
- serviceType: "APPOINTMENT" | "CLASS";
23
- fields: BookingFormField[];
24
- staffMembers?: StaffMemberOption[];
25
- locations?: LocationOption[];
26
- locationId?: string;
27
- }
28
-
29
- export default function ServiceBookingFlow({
30
- service,
31
- serviceName,
32
- serviceType,
33
- fields,
34
- staffMembers,
35
- locations,
36
- locationId,
37
- }: Props) {
38
- const [selectedSlot, setSelectedSlot] = useState<SelectedSlot | null>(null);
39
-
40
- const handleSuccess = (_orderId: string, startDate?: string) => {
41
- const params = new URLSearchParams();
42
- if (startDate) params.set("startDate", startDate);
43
- if (serviceName) params.set("service", serviceName);
44
- window.location.href = `/booking-confirmation?${params.toString()}`;
45
- };
46
-
47
- if (!selectedSlot) {
48
- return (
49
- <AvailabilityCalendar
50
- serviceId={service._id}
51
- serviceName={serviceName}
52
- serviceType={serviceType}
53
- staffMembers={staffMembers}
54
- locations={locations}
55
- locationId={locationId}
56
- onSlotSelected={setSelectedSlot}
57
- />
58
- );
59
- }
60
-
61
- return (
62
- <BookingForm
63
- service={service}
64
- serviceName={serviceName}
65
- slot={selectedSlot}
66
- fields={fields}
67
- onSuccess={handleSuccess}
68
- onCancel={() => setSelectedSlot(null)}
69
- />
70
- );
71
- }
@@ -1,54 +0,0 @@
1
- ---
2
- // ServiceCard.astro — static card for the services listing grid.
3
- // Props in, HTML out; no client-side interactivity. Works for APPOINTMENT and
4
- // CLASS services. Classes (.service-card, .service-card-image,
5
- // .service-card-meta, .service-card-price, …) are owned by
6
- // src/styles/components-bookings.css (pre-copied by the orchestrator).
7
- interface Props {
8
- id: string;
9
- slug: string;
10
- name: string;
11
- tagLine?: string;
12
- durationMinutes: number;
13
- price?: string; // formatted string, e.g. "$75.00" — already formatted by caller
14
- currency?: string;
15
- imageUrl?: string;
16
- type: "APPOINTMENT" | "CLASS";
17
- locationId?: string; // when a location is selected on the catalog, carry it to the detail page
18
- locationType?: string;
19
- }
20
-
21
- const { slug, name, tagLine, durationMinutes, price, imageUrl, locationId, locationType } = Astro.props;
22
-
23
- // Carry the selected location into the detail page so availability is scoped to it.
24
- const q = new URLSearchParams();
25
- if (locationId) q.set("locationId", locationId);
26
- if (locationType) q.set("locationType", locationType);
27
- const qs = q.toString();
28
- const href = qs ? `/services/${slug}?${qs}` : `/services/${slug}`;
29
- ---
30
-
31
- <a href={href} class="service-card">
32
- {
33
- imageUrl ? (
34
- <div class="service-card-image">
35
- <img src={imageUrl} alt={name} loading="lazy" />
36
- </div>
37
- ) : (
38
- <div
39
- class="service-card-image service-card-image--placeholder"
40
- aria-hidden="true"
41
- style="background-color: var(--color-surface-secondary, var(--color-paper-warm, var(--color-cream)));"
42
- />
43
- )
44
- }
45
-
46
- <div class="service-card-meta">
47
- <h3 class="service-card-name">{name}</h3>
48
- {tagLine && <p class="service-card-tagline">{tagLine}</p>}
49
- <div class="service-card-price">
50
- <span>{durationMinutes} min</span>
51
- {price && <span>{price}</span>}
52
- </div>
53
- </div>
54
- </a>
@@ -1,49 +0,0 @@
1
- ---
2
- // src/pages/booking-confirmation.astro — post-booking confirmation.
3
- //
4
- // Renders from the redirect query params (service name + start date) that the
5
- // booking step passes through. The Wix-hosted checkout returns here after a paid
6
- // booking; a free / pay-in-person booking lands here directly. Do not re-fetch a
7
- // stranger's booking from this public page — show what the flow passed in.
8
- import Layout from "../layouts/Layout.astro";
9
-
10
- const serviceName = Astro.url.searchParams.get("service") ?? "your service";
11
- const startDateParam = Astro.url.searchParams.get("startDate");
12
- const formattedDate = startDateParam
13
- ? new Date(startDateParam).toLocaleString("en-US", {
14
- weekday: "long", month: "long", day: "numeric", hour: "2-digit", minute: "2-digit",
15
- })
16
- : null;
17
- ---
18
-
19
- <!-- `max-w-prose` (built-in literal = 65ch), not a bare max-w-<size> that could
20
- collapse to the spacing scale. -->
21
- <Layout title="Booking confirmed">
22
- <section class="max-w-prose mx-auto px-6 py-24 text-center">
23
- <div class="w-16 h-16 rounded-full flex items-center justify-center mx-auto mb-8"
24
- style="background-color: var(--color-accent);" aria-hidden="true">
25
- <span class="text-2xl" style="color: var(--color-paper);">✓</span>
26
- </div>
27
- <hr class="editorial-rule w-16 mx-auto mb-6" />
28
- <h1 class="font-display text-4xl md:text-5xl leading-tight mb-4">Thank you for booking</h1>
29
-
30
- {
31
- formattedDate ? (
32
- <p class="text-lg text-mute leading-relaxed mb-4">
33
- Your spot in <strong class="text-ink">{serviceName}</strong> is <strong class="text-ink">confirmed</strong> for{" "}
34
- <strong class="text-ink">{formattedDate}</strong>. We've sent the details to your email.
35
- </p>
36
- ) : (
37
- <p class="text-lg text-mute leading-relaxed mb-4">
38
- Your booking for <strong class="text-ink">{serviceName}</strong> is <strong class="text-ink">confirmed</strong>. We've sent the details to your email.
39
- </p>
40
- )
41
- }
42
-
43
- <div class="flex flex-col gap-4 items-center">
44
- <a href="/services" class="inline-block font-display text-base px-8 py-4 rounded-sm"
45
- style="background-color: var(--color-accent); color: var(--color-paper);">Browse more services</a>
46
- <a href="/" class="text-sm text-mute hover:text-ink">Return home</a>
47
- </div>
48
- </section>
49
- </Layout>
@@ -1,245 +0,0 @@
1
- // bookingDriver.ts — the booking sequence in plain @wix SDK calls.
2
- // Framework-agnostic: no React, no signals, no UI. Any framework's booking step
3
- // imports book()/navigateToCheckout() and drives them; APPOINTMENT and CLASS
4
- // share the same sequence.
5
- //
6
- // Mechanism = ecom Cart V2 on every path: createBooking leaves the booking
7
- // CREATED, then the cart holds the seat — a paid service hands off to the
8
- // Wix-hosted checkout, a free / pay-in-person service places the order directly.
9
- //
10
- // On @wix/astro the SDK calls run ambiently (the visitor client is provided by
11
- // @wix/essentials, like the ecom CartView island) — no createClient/OAuthStrategy
12
- // needed. On an own/own-build SPA, acquire a visitor client with
13
- // createClient({ modules, auth: OAuthStrategy({ clientId }) }) and call the same
14
- // functions through it. Keep the SDK calls, payload shapes, and the sequence;
15
- // adapt only brand copy/styling in the UI that drives this module.
16
-
17
- import { bookings } from "@wix/bookings";
18
- import { createCart, calculateCart, placeOrder } from "@wix/auto_sdk_ecom_cart-v-2";
19
- import { redirects } from "@wix/redirects";
20
-
21
- // ── Constants (C:src/services/constants.ts) ────────────────────────────────
22
- export const BOOKING_APP_ID = "13d21c63-b5ec-5912-8397-c3a5ddb27a97";
23
- export const STAFF_MEMBER_RESOURCE_TYPE_ID = "1cd44cf8-756f-41c3-bd90-3e2ffcaf1155";
24
-
25
- // ── Types ───────────────────────────────────────────────────────────────────
26
- // FormValues = the submitted booking-form values, keyed by each field's `target`
27
- // (NOT hardcoded field names). The default booking form's targets are snake_case
28
- // `first_name`/`last_name`/`email`/`phone`; read them from the form schema and key
29
- // the values by `target` — never hardcode the keys here.
30
- export type FormValues = Record<string, unknown>;
31
-
32
- export interface SelectedSlot {
33
- serviceType: "APPOINTMENT" | "CLASS";
34
- serviceId: string;
35
- localStartDate: string; // local "YYYY-MM-DDTHH:mm:ss" (NOT UTC) — maps to slot.startDate
36
- localEndDate: string; // " " → slot.endDate
37
- timezone: string;
38
- // APPOINTMENT:
39
- scheduleId?: string;
40
- locationId?: string; // from slot.location._id (the id field is `_id`, not `.id`)
41
- locationType?: string; // "BUSINESS" | "CUSTOMER" | "CUSTOM"
42
- // CLASS:
43
- eventId?: string;
44
- // Resource chosen on the slot (flow 5). When absent the driver emits the
45
- // ANY_RESOURCE fallback so Wix auto-assigns a bookable staff member.
46
- resource?: { _id: string; name?: string };
47
- }
48
-
49
- export interface BookParams {
50
- service: any; // the @wix/bookings Service (read payment.options + bookingPolicy)
51
- slot: SelectedSlot;
52
- formSubmission: FormValues; // values from the @wix/forms Form, keyed by target
53
- timezone: string;
54
- totalParticipants?: number;
55
- /** consumer override; when omitted, derived from service.payment.options */
56
- selectedPaymentOption?: "ONLINE" | "OFFLINE";
57
- }
58
-
59
- export const BookResultType = {
60
- CheckoutRequired: "checkout_required",
61
- CheckoutSkipped: "checkout_skipped",
62
- } as const;
63
- export type BookResult =
64
- | { type: typeof BookResultType.CheckoutRequired; cartId: string }
65
- | { type: typeof BookResultType.CheckoutSkipped; orderId: string };
66
-
67
- // ── Payment derivation ───────────────────────────────────────────────────────
68
- function deriveSelectedPaymentOption(service: any): "ONLINE" | "OFFLINE" {
69
- const options = service?.payment?.options;
70
- if (options?.online && !options?.inPerson) return "ONLINE";
71
- if (!options?.online && options?.inPerson) return "OFFLINE";
72
- return "ONLINE"; // both / neither → ONLINE (consumer override wins, see below)
73
- }
74
-
75
- // LocationType maps from the availability slot's type → the booking endpoint enum.
76
- function mapLocationType(slotType?: string): string {
77
- switch (slotType) {
78
- case "BUSINESS":
79
- return "OWNER_BUSINESS";
80
- case "CUSTOMER":
81
- return "CUSTOM";
82
- case "CUSTOM":
83
- return "OWNER_CUSTOM";
84
- default:
85
- return "OWNER_BUSINESS";
86
- }
87
- }
88
-
89
- // ── buildBookingRequest ───────────────────────────────────────────────────────
90
- function buildBookingRequest(params: BookParams) {
91
- const { service, slot, formSubmission, timezone } = params;
92
- const resource = slot.resource; // prefer the slot's chosen resource when present
93
-
94
- return {
95
- booking: {
96
- // Consumer override wins over the service-config heuristic.
97
- selectedPaymentOption:
98
- params.selectedPaymentOption ?? deriveSelectedPaymentOption(service),
99
- totalParticipants: params.totalParticipants || 1,
100
- bookedEntity: {
101
- slot: {
102
- serviceId: slot.serviceId,
103
- // APPOINTMENT carries scheduleId; CLASS carries eventId (Wix derives the rest).
104
- scheduleId: slot.scheduleId ?? undefined,
105
- startDate: slot.localStartDate,
106
- endDate: slot.localEndDate,
107
- timezone,
108
- eventId: slot.eventId ?? undefined,
109
- // Resource: use the chosen one, else the ANY_RESOURCE fallback so Wix
110
- // auto-assigns a bookable staff member. Appointment availability slots
111
- // return availableResources:[] yet book fine via ANY_RESOURCE.
112
- ...(resource
113
- ? { resource: { _id: resource._id, name: resource.name } }
114
- : {
115
- resourceSelections: [
116
- {
117
- resourceTypeId: STAFF_MEMBER_RESOURCE_TYPE_ID,
118
- selectionMethod: "ANY_RESOURCE",
119
- },
120
- ],
121
- }),
122
- location:
123
- slot.locationId || slot.locationType
124
- ? {
125
- ...(slot.locationId ? { _id: slot.locationId } : {}),
126
- locationType: mapLocationType(slot.locationType),
127
- }
128
- : { locationType: "OWNER_BUSINESS" },
129
- },
130
- },
131
- },
132
- participantNotification: {
133
- metadata: { channels: "EMAIL,SMS" },
134
- notifyParticipants: true,
135
- },
136
- sendSmsReminder: true,
137
- formSubmission,
138
- };
139
- }
140
-
141
- // ── buildCartRequest ──────────────────────────────────────────────────────────
142
- function buildCartRequest(args: {
143
- bookingIds: string[];
144
- contactDetails?: any;
145
- businessLocationId?: string | null;
146
- }) {
147
- const cart: any = { source: { channelType: "WEB" } };
148
- if (args.businessLocationId)
149
- cart.businessInfo = { locationId: args.businessLocationId };
150
- if (args.contactDetails) {
151
- cart.customerInfo = args.contactDetails.email
152
- ? { email: args.contactDetails.email }
153
- : {};
154
- if (args.contactDetails.fullAddress?.country) {
155
- cart.deliveryInfo = { address: { ...args.contactDetails.fullAddress } };
156
- cart.paymentInfo = {
157
- billingAddress: { ...args.contactDetails.fullAddress },
158
- };
159
- }
160
- }
161
- return {
162
- catalogItems: args.bookingIds.map((id) => ({
163
- quantity: 1,
164
- catalogReference: { catalogItemId: id, appId: BOOKING_APP_ID },
165
- })),
166
- cart,
167
- };
168
- }
169
-
170
- // ── isCheckoutRequired ────────────────────────────────────────────────────────
171
- function isCheckoutRequired(cart: any, summary: any, service: any): boolean {
172
- if (service?.bookingPolicy?.cancellationFeePolicy?.enabled) return true;
173
- const total = Number(summary?.priceSummary?.total?.amount ?? 0);
174
- if (total === 0) return false;
175
- if (cart?.lineItems?.[0]?.paymentConfig?.paymentOption === "FULL_PAYMENT_OFFLINE")
176
- return false;
177
- return true;
178
- }
179
-
180
- // ── canBook ───────────────────────────────────────────────────────────────────
181
- function canBook(params: BookParams): boolean {
182
- const slotOk =
183
- !!params.slot &&
184
- !!params.slot.localStartDate &&
185
- (params.slot.serviceType === "CLASS"
186
- ? !!params.slot.eventId
187
- : !!params.slot.scheduleId);
188
- return slotOk && params.formSubmission != null;
189
- }
190
-
191
- // ── book — the full sequence ──────────────────────────────────────────────────
192
- export async function book(params: BookParams): Promise<BookResult> {
193
- if (!canBook(params))
194
- throw new Error("Cannot book: missing slot or form submission");
195
-
196
- // 1. createBooking → CREATED (the cart holds the seat)
197
- const req = buildBookingRequest(params);
198
- const created = await bookings.createBooking(req.booking as any, {
199
- participantNotification: req.participantNotification,
200
- sendSmsReminder: req.sendSmsReminder,
201
- formSubmission: req.formSubmission as any,
202
- });
203
- const bookingId = created?.booking?._id;
204
- if (!bookingId) throw new Error("Failed to create booking");
205
- const contactDetails = created?.booking?.contactDetails;
206
-
207
- // 2. createCart — one catalog item per booking id (channel WEB, bookings appId)
208
- const businessLocationId = params.slot.locationId ?? undefined;
209
- const cart = await createCart(
210
- buildCartRequest({ bookingIds: [bookingId], contactDetails, businessLocationId }),
211
- );
212
- const cartId = cart?._id;
213
- if (!cartId) throw new Error("Failed to create cart");
214
-
215
- // 3. calculateCart → totals (not stored on the Cart V2 entity)
216
- const { cart: calculatedCart, summary } = await calculateCart(cartId);
217
- if (!calculatedCart || !summary) throw new Error("Failed to calculate cart");
218
-
219
- // 4. checkout required? → redirect (paid) ; else placeOrder (free/offline)
220
- if (isCheckoutRequired(calculatedCart, summary, params.service)) {
221
- return { type: BookResultType.CheckoutRequired, cartId };
222
- }
223
- const order = await placeOrder(cartId);
224
- const orderId = order?.orderId;
225
- if (!orderId) throw new Error("Failed to place order");
226
- return { type: BookResultType.CheckoutSkipped, orderId };
227
- }
228
-
229
- // ── navigateToCheckout ────────────────────────────────────────────────────────
230
- // Paid services: hand the cart to the Wix-hosted ecom checkout. Same shape on
231
- // every path — ecomCheckout.checkoutId = the cartId.
232
- export async function navigateToCheckout(
233
- cartId: string,
234
- postFlowUrl: string,
235
- ): Promise<void> {
236
- const { redirectSession } = await redirects.createRedirectSession({
237
- ecomCheckout: { checkoutId: cartId },
238
- callbacks: { postFlowUrl },
239
- });
240
- if (redirectSession?.fullUrl) {
241
- window.location.href = redirectSession.fullUrl;
242
- } else {
243
- throw new Error("Failed to create redirect session");
244
- }
245
- }