@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,176 +0,0 @@
1
- import { useState } from "react";
2
- import { backInStockNotifications } from "@wix/ecom";
3
- import { WIX_STORES_BACK_IN_STOCK_APP_ID } from "../utils/back-in-stock";
4
-
5
- interface BackInStockFormProps {
6
- productId: string;
7
- variantId?: string;
8
- productName: string;
9
- // Numeric price (number or numeric string). The Wix backend validates
10
- // `itemDetails.price >= 0` against the parsed decimal, so currency-
11
- // formatted strings ("$695") are stripped here before submission.
12
- productPrice: number | string;
13
- variantLabel?: string;
14
- }
15
-
16
- type Status =
17
- | { kind: "idle" }
18
- | { kind: "submitting" }
19
- | { kind: "success"; alreadySubscribed?: boolean }
20
- | { kind: "error"; message: string };
21
-
22
- const EMAIL_RE = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
23
-
24
- function normalizePrice(raw: number | string): string {
25
- const s =
26
- typeof raw === "number" ? String(raw) : String(raw).replace(/[^0-9.]/g, "");
27
- const n = Number(s);
28
- return Number.isFinite(n) && n >= 0 ? s : "0";
29
- }
30
-
31
- function readErrorCode(err: unknown): string | undefined {
32
- if (!err || typeof err !== "object") return undefined;
33
- // Wix SDK errors expose details.applicationError.code; some shapes also
34
- // surface a top-level details.code or http status. Try the common ones.
35
- const e = err as Record<string, any>;
36
- return (
37
- e?.details?.applicationError?.code ??
38
- e?.details?.code ??
39
- e?.applicationError?.code ??
40
- undefined
41
- );
42
- }
43
-
44
- export default function BackInStockForm({
45
- productId,
46
- variantId,
47
- productName,
48
- productPrice,
49
- variantLabel,
50
- }: BackInStockFormProps) {
51
- const [email, setEmail] = useState("");
52
- const [status, setStatus] = useState<Status>({ kind: "idle" });
53
-
54
- const submitting = status.kind === "submitting";
55
- const success = status.kind === "success";
56
-
57
- async function handleSubmit(e: React.FormEvent<HTMLFormElement>) {
58
- e.preventDefault();
59
- if (submitting) return;
60
- if (!EMAIL_RE.test(email)) {
61
- setStatus({ kind: "error", message: "Enter a valid email." });
62
- return;
63
- }
64
- setStatus({ kind: "submitting" });
65
-
66
- // Bare-fields rule: the SDK throws an opaque
67
- // "TypeError: Failed to construct 'URL': Invalid URL" when the optional
68
- // request.itemUrl or itemDetails.image fields are present, even with
69
- // browser-valid URLs. Send only the four required fields:
70
- // catalogReference, email, name, price. The dashboard's Back-in-Stock
71
- // Requests view + the customer notification email both work without
72
- // them; the email just won't have a thumbnail and the dashboard uses
73
- // its default item URL.
74
- const request = {
75
- catalogReference: {
76
- appId: WIX_STORES_BACK_IN_STOCK_APP_ID,
77
- catalogItemId: productId,
78
- ...(variantId ? { options: { variantId } } : {}),
79
- },
80
- email,
81
- };
82
- const itemDetails = {
83
- name: productName,
84
- price: normalizePrice(productPrice),
85
- };
86
-
87
- try {
88
- await backInStockNotifications.createBackInStockNotificationRequest(
89
- request,
90
- itemDetails,
91
- );
92
- setStatus({ kind: "success" });
93
- } catch (err) {
94
- const code = readErrorCode(err);
95
- if (code === "BACK_IN_STOCK_NOTIFICATION_REQUEST_ALREADY_EXISTS") {
96
- setStatus({ kind: "success", alreadySubscribed: true });
97
- return;
98
- }
99
- if (code === "REQUEST_COLLECTION_DISABLED") {
100
- setStatus({
101
- kind: "error",
102
- message: "Notifications aren't being collected right now.",
103
- });
104
- return;
105
- }
106
- console.error("[back-in-stock] subscribe failed:", err);
107
- setStatus({
108
- kind: "error",
109
- message: "Something went wrong. Please try again.",
110
- });
111
- }
112
- }
113
-
114
- if (success) {
115
- return (
116
- <div className="back-in-stock-success" role="status" aria-live="polite">
117
- <p className="back-in-stock-success-headline">
118
- {status.alreadySubscribed
119
- ? "You're already on the list."
120
- : "We'll let you know."}
121
- </p>
122
- <p className="back-in-stock-success-detail">
123
- {status.alreadySubscribed
124
- ? `We had your note for ${productName}${variantLabel ? ` (${variantLabel})` : ""}. We'll email ${email} the moment it's back.`
125
- : `We'll email ${email} the moment ${productName}${variantLabel ? ` (${variantLabel})` : ""} is back in stock.`}
126
- </p>
127
- </div>
128
- );
129
- }
130
-
131
- return (
132
- <form className="back-in-stock-form" onSubmit={handleSubmit} noValidate>
133
- <div className="back-in-stock-headline">
134
- <span className="back-in-stock-eyebrow">Currently sold out</span>
135
- <p className="back-in-stock-lede">
136
- Leave your email and we'll notify you the moment
137
- {variantLabel ? ` ${variantLabel.toLowerCase()}` : ""} is back in
138
- stock.
139
- </p>
140
- </div>
141
- <label className="back-in-stock-label" htmlFor="back-in-stock-email">
142
- Email
143
- </label>
144
- <div className="back-in-stock-row">
145
- <input
146
- id="back-in-stock-email"
147
- type="email"
148
- inputMode="email"
149
- autoComplete="email"
150
- required
151
- placeholder="you@example.com"
152
- value={email}
153
- onChange={(e) => {
154
- setEmail(e.target.value);
155
- if (status.kind === "error") setStatus({ kind: "idle" });
156
- }}
157
- className="back-in-stock-input"
158
- aria-invalid={status.kind === "error"}
159
- disabled={submitting}
160
- />
161
- <button
162
- type="submit"
163
- className="back-in-stock-submit"
164
- disabled={submitting || email.trim().length === 0}
165
- >
166
- {submitting ? "Sending…" : "Notify me"}
167
- </button>
168
- </div>
169
- {status.kind === "error" && (
170
- <p className="back-in-stock-error" role="alert">
171
- {status.message}
172
- </p>
173
- )}
174
- </form>
175
- );
176
- }
@@ -1,69 +0,0 @@
1
- ---
2
- // Shared category-rail + Prev/Next pagination for /products and
3
- // /category/[slug]. Persists across <ClientRouter /> swaps so pill clicks
4
- // feel like an in-place filter, not a navigation. The active pill is
5
- // recomputed from the URL by an astro:after-swap hook in Layout.astro.
6
- //
7
- // Owned by the stores pack. Ecom/blog/etc. do NOT write to this file.
8
- import type { StoreCategory } from "../utils/categories";
9
-
10
- interface Props {
11
- categories: StoreCategory[];
12
- // null = "All" view; otherwise the slug of the active category.
13
- activeSlug: string | null;
14
- prevHref: string | null;
15
- nextHref: string | null;
16
- }
17
-
18
- const { categories, activeSlug, prevHref, nextHref } = Astro.props;
19
- ---
20
-
21
- {categories.length > 0 && (
22
- <nav
23
- class="category-rail"
24
- aria-label="Browse by category"
25
- data-category-rail
26
- transition:persist="category-rail"
27
- transition:name="category-rail"
28
- >
29
- <div class="container-page category-rail-inner">
30
- <a
31
- href="/products"
32
- class="category-pill"
33
- data-category-slug=""
34
- data-astro-prefetch="hover"
35
- aria-current={activeSlug ? undefined : "page"}
36
- >All</a>
37
- {categories.map((cat) => (
38
- <a
39
- href={`/category/${cat.slug}`}
40
- class="category-pill"
41
- data-category-slug={cat.slug}
42
- data-astro-prefetch="hover"
43
- aria-current={activeSlug === cat.slug ? "page" : undefined}
44
- >{cat.name}</a>
45
- ))}
46
- </div>
47
- </nav>
48
- )}
49
-
50
- {(prevHref || nextHref) && (
51
- <nav class="pagination" aria-label="Listing pagination">
52
- <div class="container-page pagination-inner">
53
- {prevHref ? (
54
- <a href={prevHref} class="pagination-link" data-astro-prefetch="hover" rel="prev">
55
- &larr; Previous
56
- </a>
57
- ) : (
58
- <span class="pagination-link is-disabled" aria-disabled="true">&larr; Previous</span>
59
- )}
60
- {nextHref ? (
61
- <a href={nextHref} class="pagination-link" data-astro-prefetch="hover" rel="next">
62
- Next &rarr;
63
- </a>
64
- ) : (
65
- <span class="pagination-link is-disabled" aria-disabled="true">Next &rarr;</span>
66
- )}
67
- </div>
68
- </nav>
69
- )}
@@ -1,79 +0,0 @@
1
- ---
2
- import { resolveWixImageUrl } from "../utils/wix-image";
3
- import { fetchLiveOffers, offersForProduct } from "../utils/discounts";
4
-
5
- interface Props {
6
- product: {
7
- _id?: string;
8
- name?: string;
9
- slug?: string;
10
- media?: { main?: { image?: string }; items?: any[] };
11
- actualPriceRange?: {
12
- minValue?: { formattedAmount?: string; amount?: string; currency?: string };
13
- };
14
- };
15
- // Optional editorial ordinal (01 / 02 / 03). Listings that want it should
16
- // pass their own index; home grids typically omit it.
17
- index?: number;
18
- }
19
-
20
- const { product, index } = Astro.props;
21
-
22
- // fetchLiveOffers is memoized per request via auth.elevate's caching, so
23
- // rendering N ProductCards in one page does NOT fan out N discount-rule
24
- // queries. Pages that mount ProductCard never fetch offers themselves —
25
- // the component owns that concern.
26
- let primaryOffer: { name: string; offer?: string } | undefined;
27
- try {
28
- const offers = await fetchLiveOffers();
29
- primaryOffer = offersForProduct(offers, product._id)[0];
30
- } catch (err) {
31
- console.error("[ProductCard] fetchLiveOffers failed:", err);
32
- }
33
-
34
- const imageUrl = resolveWixImageUrl(product.media?.main?.image, 600, 800);
35
- const price = product.actualPriceRange?.minValue?.formattedAmount;
36
- const amount = product.actualPriceRange?.minValue?.amount;
37
- const currency = product.actualPriceRange?.minValue?.currency;
38
- const indexLabel =
39
- typeof index === "number" ? String(index + 1).padStart(2, "0") : null;
40
- ---
41
-
42
- <a
43
- href={`/products/${product.slug}`}
44
- class="product-card"
45
- data-analytics-product
46
- data-id={product._id}
47
- data-name={product.name}
48
- data-price={amount}
49
- data-currency={currency}
50
- >
51
- <div class="product-card-media">
52
- {imageUrl && <img src={imageUrl} alt={product.name ?? "Product"} loading="lazy" />}
53
- {indexLabel && <span class="product-card-index">N°&nbsp;{indexLabel}</span>}
54
- {primaryOffer && (
55
- <span class="product-card-ribbon" title={primaryOffer.offer}>
56
- {primaryOffer.name}
57
- </span>
58
- )}
59
- </div>
60
- <div class="product-card-body">
61
- <h3 class="product-card-name">{product.name}</h3>
62
- {price && <p class="product-card-price">{price}</p>}
63
- </div>
64
- </a>
65
-
66
- <script>
67
- import { trackEvent } from "../utils/analytics";
68
- document.addEventListener("click", (event) => {
69
- const anchor = (event.target as HTMLElement)?.closest("a[data-analytics-product]") as HTMLAnchorElement | null;
70
- if (!anchor) return;
71
- trackEvent("ClickProduct", {
72
- id: anchor.dataset.id,
73
- name: anchor.dataset.name,
74
- price: anchor.dataset.price ? Number(anchor.dataset.price) : undefined,
75
- currency: anchor.dataset.currency,
76
- origin: "Product Listing",
77
- });
78
- });
79
- </script>