@wix/agent-skills 1.21.0 → 1.22.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.
- package/package.json +1 -1
- package/skills/wix-app/SKILL.md +60 -4
- package/skills/wix-app/references/DASHBOARD_PAGE.md +11 -25
- package/skills/wix-app/references/DATA_COLLECTION.md +16 -219
- package/skills/wix-app/references/dashboard-page/DATA_SOURCES.md +182 -0
- package/skills/wix-app/references/dashboard-page/DRAFT_TEMPLATE.md +97 -0
- package/skills/wix-app/references/dashboard-page/DRAFT_TEMPLATE_COLLECTION.md +184 -0
- package/skills/wix-app/references/dashboard-page/DRAFT_TEMPLATE_ROUTER.md +203 -0
- package/skills/wix-app/references/dashboard-page/DRAFT_TEMPLATE_SETTINGS.md +44 -0
- package/skills/wix-app/references/dashboard-page/QUERY_AND_PAGING.md +182 -0
- package/skills/wix-app/references/dashboard-page/TABLE_STATE.md +133 -0
- package/skills/wix-app/references/dashboard-page/UX_SUCCESS_MODEL.md +10 -5
- package/skills/wix-app/references/data-collection/LIFECYCLE.md +68 -0
- package/skills/wix-app/references/data-collection/PERMISSIONS.md +47 -0
- package/skills/wix-app/references/data-collection/SCHEMA.md +181 -0
- package/skills/wix-app/references/data-collection/WIX_DATA.md +38 -66
- package/skills/wix-headless-fast/SKILL.md +61 -223
- package/skills/wix-headless-fast/cold-start/bootstrap.mjs +156 -0
- package/skills/wix-headless-fast/{entry/skill.md → cold-start/cold-start.md} +11 -12
- package/skills/wix-headless-fast/guides/existing-site.md +76 -0
- package/skills/wix-headless-fast/guides/reference-mode.md +97 -0
- package/skills/wix-headless-fast/install/AGENTS.md +6 -3
- package/skills/wix-headless-fast/install/attach.mjs +15 -47
- package/skills/wix-headless-fast/install/deploy.mjs +21 -60
- package/skills/wix-headless-fast/install/lock.mjs +55 -0
- package/skills/wix-headless-fast/install/setup.mjs +32 -12
- package/skills/wix-headless-fast/install/templates.mjs +168 -0
- package/skills/wix-manage/references/google-ads/google-ads-dashboard-navigation.md +27 -0
- package/skills/wix-manage/references/google-ads/manage-campaign-success-guide.md +83 -37
- package/skills/wix-headless-fast/references/blog/INSTRUCTIONS.md +0 -303
- package/skills/wix-headless-fast/references/blog/app/components/blog/BlogFeedView.tsx +0 -136
- package/skills/wix-headless-fast/references/blog/app/components/blog/PostView.tsx +0 -112
- package/skills/wix-headless-fast/references/blog/app/components/blog/RichContent.tsx +0 -42
- package/skills/wix-headless-fast/references/blog/app/hooks/blog/useBlogFeed.ts +0 -31
- package/skills/wix-headless-fast/references/blog/app/hooks/blog/usePost.ts +0 -22
- package/skills/wix-headless-fast/references/blog/app/wix/blog/blog-feed-store.ts +0 -137
- package/skills/wix-headless-fast/references/blog/app/wix/blog/post-store.ts +0 -78
- package/skills/wix-headless-fast/references/blog/app/wix/blog/posts-core.ts +0 -117
- package/skills/wix-headless-fast/references/blog/app/wix/blog/posts.ts +0 -52
- package/skills/wix-headless-fast/references/blog/app/wix/blog/taxonomy-core.ts +0 -47
- package/skills/wix-headless-fast/references/blog/app/wix/blog/taxonomy.ts +0 -58
- package/skills/wix-headless-fast/references/blog/app/wix/blog/types.ts +0 -62
- package/skills/wix-headless-fast/references/blog/app-astro/layouts/SiteLayout.astro +0 -40
- package/skills/wix-headless-fast/references/blog/app-astro/pages/blog/[...slug].astro +0 -97
- package/skills/wix-headless-fast/references/blog/app-astro/pages/blog.astro +0 -24
- package/skills/wix-headless-fast/references/blog/lock/astro/package-lock.json +0 -16156
- package/skills/wix-headless-fast/references/blog/rest/posts.ts +0 -42
- package/skills/wix-headless-fast/references/blog/rest/taxonomy.ts +0 -62
- package/skills/wix-headless-fast/references/blog/seed/SEED.md +0 -81
- package/skills/wix-headless-fast/references/blog/seed/read-site.mjs +0 -22
- package/skills/wix-headless-fast/references/blog/seed/seed-blog.mjs +0 -287
- package/skills/wix-headless-fast/references/bookings/INSTRUCTIONS.md +0 -277
- package/skills/wix-headless-fast/references/bookings/app/components/bookings/ServiceBookingView.tsx +0 -144
- package/skills/wix-headless-fast/references/bookings/app/components/bookings/ServicesView.tsx +0 -119
- package/skills/wix-headless-fast/references/bookings/app/hooks/bookings/useBookingFlow.ts +0 -32
- package/skills/wix-headless-fast/references/bookings/app/hooks/bookings/useServices.ts +0 -23
- package/skills/wix-headless-fast/references/bookings/app/wix/bookings/booking-core.ts +0 -218
- package/skills/wix-headless-fast/references/bookings/app/wix/bookings/booking-flow-store.ts +0 -169
- package/skills/wix-headless-fast/references/bookings/app/wix/bookings/booking.ts +0 -121
- package/skills/wix-headless-fast/references/bookings/app/wix/bookings/services-core.ts +0 -92
- package/skills/wix-headless-fast/references/bookings/app/wix/bookings/services-store.ts +0 -90
- package/skills/wix-headless-fast/references/bookings/app/wix/bookings/services.ts +0 -57
- package/skills/wix-headless-fast/references/bookings/app/wix/bookings/types.ts +0 -72
- package/skills/wix-headless-fast/references/bookings/app-astro/layouts/SiteLayout.astro +0 -40
- package/skills/wix-headless-fast/references/bookings/app-astro/pages/services/[slug].astro +0 -76
- package/skills/wix-headless-fast/references/bookings/app-astro/pages/services.astro +0 -22
- package/skills/wix-headless-fast/references/bookings/lock/astro/package-lock.json +0 -11962
- package/skills/wix-headless-fast/references/bookings/rest/booking.ts +0 -113
- package/skills/wix-headless-fast/references/bookings/rest/services.ts +0 -55
- package/skills/wix-headless-fast/references/bookings/seed/SEED.md +0 -71
- package/skills/wix-headless-fast/references/bookings/seed/read-site.mjs +0 -28
- package/skills/wix-headless-fast/references/bookings/seed/seed-bookings.mjs +0 -302
- package/skills/wix-headless-fast/references/cms/INSTRUCTIONS.md +0 -355
- package/skills/wix-headless-fast/references/cms/app/hooks/cms/useCollection.ts +0 -50
- package/skills/wix-headless-fast/references/cms/app/hooks/cms/useItem.ts +0 -37
- package/skills/wix-headless-fast/references/cms/app/wix/cms/collection-store.ts +0 -158
- package/skills/wix-headless-fast/references/cms/app/wix/cms/item-store.ts +0 -93
- package/skills/wix-headless-fast/references/cms/app/wix/cms/items-core.ts +0 -177
- package/skills/wix-headless-fast/references/cms/app/wix/cms/items.ts +0 -123
- package/skills/wix-headless-fast/references/cms/app/wix/cms/types.ts +0 -75
- package/skills/wix-headless-fast/references/cms/app-astro/layouts/SiteLayout.astro +0 -41
- package/skills/wix-headless-fast/references/cms/lock/astro/package-lock.json +0 -11262
- package/skills/wix-headless-fast/references/cms/rest/items.ts +0 -125
- package/skills/wix-headless-fast/references/cms/seed/SEED.md +0 -112
- package/skills/wix-headless-fast/references/cms/seed/read-site.mjs +0 -20
- package/skills/wix-headless-fast/references/cms/seed/seed-cms.mjs +0 -324
- package/skills/wix-headless-fast/references/events/INSTRUCTIONS.md +0 -307
- package/skills/wix-headless-fast/references/events/app/components/events/EventConfirmationView.tsx +0 -66
- package/skills/wix-headless-fast/references/events/app/components/events/EventRegistrationView.tsx +0 -178
- package/skills/wix-headless-fast/references/events/app/components/events/EventsView.tsx +0 -118
- package/skills/wix-headless-fast/references/events/app/hooks/events/useEventRegistration.ts +0 -35
- package/skills/wix-headless-fast/references/events/app/hooks/events/useEvents.ts +0 -24
- package/skills/wix-headless-fast/references/events/app/wix/events/events-core.ts +0 -130
- package/skills/wix-headless-fast/references/events/app/wix/events/events-store.ts +0 -97
- package/skills/wix-headless-fast/references/events/app/wix/events/events.ts +0 -55
- package/skills/wix-headless-fast/references/events/app/wix/events/registration-core.ts +0 -113
- package/skills/wix-headless-fast/references/events/app/wix/events/registration-store.ts +0 -156
- package/skills/wix-headless-fast/references/events/app/wix/events/registration.ts +0 -97
- package/skills/wix-headless-fast/references/events/app/wix/events/types.ts +0 -61
- package/skills/wix-headless-fast/references/events/app-astro/layouts/SiteLayout.astro +0 -40
- package/skills/wix-headless-fast/references/events/app-astro/pages/event-confirmation.astro +0 -12
- package/skills/wix-headless-fast/references/events/app-astro/pages/events/[slug].astro +0 -80
- package/skills/wix-headless-fast/references/events/app-astro/pages/events.astro +0 -21
- package/skills/wix-headless-fast/references/events/lock/astro/package-lock.json +0 -11884
- package/skills/wix-headless-fast/references/events/rest/events.ts +0 -57
- package/skills/wix-headless-fast/references/events/rest/registration.ts +0 -83
- package/skills/wix-headless-fast/references/events/seed/SEED.md +0 -95
- package/skills/wix-headless-fast/references/events/seed/read-site.mjs +0 -26
- package/skills/wix-headless-fast/references/events/seed/seed-events.mjs +0 -276
- package/skills/wix-headless-fast/references/forms/INSTRUCTIONS.md +0 -340
- package/skills/wix-headless-fast/references/forms/app/hooks/forms/useWixForm.ts +0 -85
- package/skills/wix-headless-fast/references/forms/app/wix/forms/form-store.ts +0 -332
- package/skills/wix-headless-fast/references/forms/app/wix/forms/forms-core.ts +0 -238
- package/skills/wix-headless-fast/references/forms/app/wix/forms/forms.ts +0 -54
- package/skills/wix-headless-fast/references/forms/app/wix/forms/submissions-core.ts +0 -216
- package/skills/wix-headless-fast/references/forms/app/wix/forms/submissions.ts +0 -59
- package/skills/wix-headless-fast/references/forms/app/wix/forms/types.ts +0 -135
- package/skills/wix-headless-fast/references/forms/lock/astro/package-lock.json +0 -10593
- package/skills/wix-headless-fast/references/forms/rest/forms.ts +0 -34
- package/skills/wix-headless-fast/references/forms/rest/submissions.ts +0 -56
- package/skills/wix-headless-fast/references/forms/seed/SEED.md +0 -116
- package/skills/wix-headless-fast/references/forms/seed/read-site.mjs +0 -20
- package/skills/wix-headless-fast/references/forms/seed/seed-forms.mjs +0 -327
- package/skills/wix-headless-fast/references/members/INSTRUCTIONS.md +0 -316
- package/skills/wix-headless-fast/references/members/app/components/members/AccountView.tsx +0 -60
- package/skills/wix-headless-fast/references/members/app/components/members/LoginForm.tsx +0 -155
- package/skills/wix-headless-fast/references/members/app/components/members/MemberMenu.tsx +0 -78
- package/skills/wix-headless-fast/references/members/app/components/members/RequireAuth.tsx +0 -47
- package/skills/wix-headless-fast/references/members/app/hooks/members/useMember.ts +0 -66
- package/skills/wix-headless-fast/references/members/app/wix/members/auth-core.ts +0 -105
- package/skills/wix-headless-fast/references/members/app/wix/members/auth.ts +0 -59
- package/skills/wix-headless-fast/references/members/app/wix/members/client.ts +0 -53
- package/skills/wix-headless-fast/references/members/app/wix/members/member-store.ts +0 -122
- package/skills/wix-headless-fast/references/members/app/wix/members/members-core.ts +0 -43
- package/skills/wix-headless-fast/references/members/app/wix/members/members.ts +0 -29
- package/skills/wix-headless-fast/references/members/app/wix/members/types.ts +0 -21
- package/skills/wix-headless-fast/references/members/app-astro/layouts/SiteLayout.astro +0 -42
- package/skills/wix-headless-fast/references/members/app-astro/pages/account.astro +0 -10
- package/skills/wix-headless-fast/references/members/app-astro/pages/login.astro +0 -11
- package/skills/wix-headless-fast/references/members/lock/astro/package-lock.json +0 -10329
- package/skills/wix-headless-fast/references/members/rest/auth.ts +0 -215
- package/skills/wix-headless-fast/references/members/rest/members.ts +0 -26
- package/skills/wix-headless-fast/references/members/seed/SEED.md +0 -39
- package/skills/wix-headless-fast/references/members/seed/read-site.mjs +0 -15
- package/skills/wix-headless-fast/references/members/seed/seed-members.mjs +0 -94
- package/skills/wix-headless-fast/references/portfolio/INSTRUCTIONS.md +0 -315
- package/skills/wix-headless-fast/references/portfolio/app/components/portfolio/CollectionProjectsView.tsx +0 -110
- package/skills/wix-headless-fast/references/portfolio/app/components/portfolio/CollectionsView.tsx +0 -90
- package/skills/wix-headless-fast/references/portfolio/app/components/portfolio/GalleryMedia.tsx +0 -35
- package/skills/wix-headless-fast/references/portfolio/app/components/portfolio/ProjectDetailView.tsx +0 -85
- package/skills/wix-headless-fast/references/portfolio/app/hooks/portfolio/useCollectionProjects.ts +0 -32
- package/skills/wix-headless-fast/references/portfolio/app/hooks/portfolio/useCollections.ts +0 -21
- package/skills/wix-headless-fast/references/portfolio/app/hooks/portfolio/useProjectDetail.ts +0 -31
- package/skills/wix-headless-fast/references/portfolio/app/wix/portfolio/collection-projects-store.ts +0 -82
- package/skills/wix-headless-fast/references/portfolio/app/wix/portfolio/collections-store.ts +0 -58
- package/skills/wix-headless-fast/references/portfolio/app/wix/portfolio/portfolio-core.ts +0 -177
- package/skills/wix-headless-fast/references/portfolio/app/wix/portfolio/portfolio.ts +0 -78
- package/skills/wix-headless-fast/references/portfolio/app/wix/portfolio/project-detail-store.ts +0 -81
- package/skills/wix-headless-fast/references/portfolio/app/wix/portfolio/types.ts +0 -55
- package/skills/wix-headless-fast/references/portfolio/app-astro/layouts/SiteLayout.astro +0 -40
- package/skills/wix-headless-fast/references/portfolio/app-astro/pages/portfolio/[slug].astro +0 -30
- package/skills/wix-headless-fast/references/portfolio/app-astro/pages/portfolio.astro +0 -21
- package/skills/wix-headless-fast/references/portfolio/app-astro/pages/projects/[slug].astro +0 -29
- package/skills/wix-headless-fast/references/portfolio/lock/astro/package-lock.json +0 -10197
- package/skills/wix-headless-fast/references/portfolio/rest/portfolio.ts +0 -75
- package/skills/wix-headless-fast/references/portfolio/seed/SEED.md +0 -86
- package/skills/wix-headless-fast/references/portfolio/seed/read-site.mjs +0 -20
- package/skills/wix-headless-fast/references/portfolio/seed/seed-portfolio.mjs +0 -256
- package/skills/wix-headless-fast/references/pricing-plans/INSTRUCTIONS.md +0 -296
- package/skills/wix-headless-fast/references/pricing-plans/app/components/pricing-plans/PlanDetailView.tsx +0 -47
- package/skills/wix-headless-fast/references/pricing-plans/app/components/pricing-plans/PlansView.tsx +0 -101
- package/skills/wix-headless-fast/references/pricing-plans/app/components/pricing-plans/SubscribeButton.tsx +0 -41
- package/skills/wix-headless-fast/references/pricing-plans/app/hooks/pricing-plans/usePlanPurchase.ts +0 -16
- package/skills/wix-headless-fast/references/pricing-plans/app/hooks/pricing-plans/usePlans.ts +0 -22
- package/skills/wix-headless-fast/references/pricing-plans/app/wix/pricing-plans/plan-purchase-store.ts +0 -54
- package/skills/wix-headless-fast/references/pricing-plans/app/wix/pricing-plans/plans-core.ts +0 -106
- package/skills/wix-headless-fast/references/pricing-plans/app/wix/pricing-plans/plans-store.ts +0 -64
- package/skills/wix-headless-fast/references/pricing-plans/app/wix/pricing-plans/plans.ts +0 -27
- package/skills/wix-headless-fast/references/pricing-plans/app/wix/pricing-plans/purchase-core.ts +0 -43
- package/skills/wix-headless-fast/references/pricing-plans/app/wix/pricing-plans/purchase.ts +0 -22
- package/skills/wix-headless-fast/references/pricing-plans/app/wix/pricing-plans/types.ts +0 -30
- package/skills/wix-headless-fast/references/pricing-plans/app-astro/layouts/SiteLayout.astro +0 -41
- package/skills/wix-headless-fast/references/pricing-plans/app-astro/pages/plans/[slug].astro +0 -40
- package/skills/wix-headless-fast/references/pricing-plans/app-astro/pages/plans.astro +0 -21
- package/skills/wix-headless-fast/references/pricing-plans/lock/astro/package-lock.json +0 -11226
- package/skills/wix-headless-fast/references/pricing-plans/rest/plans.ts +0 -31
- package/skills/wix-headless-fast/references/pricing-plans/rest/purchase.ts +0 -20
- package/skills/wix-headless-fast/references/pricing-plans/seed/SEED.md +0 -79
- package/skills/wix-headless-fast/references/pricing-plans/seed/read-site.mjs +0 -21
- package/skills/wix-headless-fast/references/pricing-plans/seed/seed-pricing-plans.mjs +0 -279
- package/skills/wix-headless-fast/references/restaurants/INSTRUCTIONS.md +0 -360
- package/skills/wix-headless-fast/references/restaurants/app/components/restaurants/MenuView.tsx +0 -142
- package/skills/wix-headless-fast/references/restaurants/app/components/restaurants/OrderCartButton.tsx +0 -26
- package/skills/wix-headless-fast/references/restaurants/app/components/restaurants/OrderCartDrawer.tsx +0 -121
- package/skills/wix-headless-fast/references/restaurants/app/components/restaurants/ReservationView.tsx +0 -155
- package/skills/wix-headless-fast/references/restaurants/app/hooks/restaurants/useMenus.ts +0 -34
- package/skills/wix-headless-fast/references/restaurants/app/hooks/restaurants/useOrderCart.ts +0 -43
- package/skills/wix-headless-fast/references/restaurants/app/hooks/restaurants/useReservation.ts +0 -34
- package/skills/wix-headless-fast/references/restaurants/app/wix/restaurants/menu-core.ts +0 -155
- package/skills/wix-headless-fast/references/restaurants/app/wix/restaurants/menu-store.ts +0 -89
- package/skills/wix-headless-fast/references/restaurants/app/wix/restaurants/menu.ts +0 -71
- package/skills/wix-headless-fast/references/restaurants/app/wix/restaurants/order-store.ts +0 -103
- package/skills/wix-headless-fast/references/restaurants/app/wix/restaurants/ordering-core.ts +0 -124
- package/skills/wix-headless-fast/references/restaurants/app/wix/restaurants/ordering.ts +0 -185
- package/skills/wix-headless-fast/references/restaurants/app/wix/restaurants/reservation-store.ts +0 -193
- package/skills/wix-headless-fast/references/restaurants/app/wix/restaurants/reservations-core.ts +0 -94
- package/skills/wix-headless-fast/references/restaurants/app/wix/restaurants/reservations.ts +0 -74
- package/skills/wix-headless-fast/references/restaurants/app/wix/restaurants/types.ts +0 -168
- package/skills/wix-headless-fast/references/restaurants/app-astro/layouts/SiteLayout.astro +0 -47
- package/skills/wix-headless-fast/references/restaurants/app-astro/pages/menu.astro +0 -22
- package/skills/wix-headless-fast/references/restaurants/app-astro/pages/reservations.astro +0 -12
- package/skills/wix-headless-fast/references/restaurants/lock/astro/package-lock.json +0 -12560
- package/skills/wix-headless-fast/references/restaurants/rest/menu.ts +0 -60
- package/skills/wix-headless-fast/references/restaurants/rest/ordering.ts +0 -169
- package/skills/wix-headless-fast/references/restaurants/rest/reservations.ts +0 -68
- package/skills/wix-headless-fast/references/restaurants/seed/SEED.md +0 -89
- package/skills/wix-headless-fast/references/restaurants/seed/read-site.mjs +0 -25
- package/skills/wix-headless-fast/references/restaurants/seed/seed-restaurants.mjs +0 -499
- package/skills/wix-headless-fast/references/shared/CONTENT.md +0 -22
- package/skills/wix-headless-fast/references/shared/CUSTOM_OPERATIONS.md +0 -73
- package/skills/wix-headless-fast/references/shared/DESIGN.md +0 -26
- package/skills/wix-headless-fast/references/shared/SUPPLIED-CONTENT.md +0 -23
- package/skills/wix-headless-fast/references/shared/app/styles/global.css +0 -52
- package/skills/wix-headless-fast/references/shared/app/wix/config.ts +0 -15
- package/skills/wix-headless-fast/references/shared/app/wix/media.ts +0 -81
- package/skills/wix-headless-fast/references/shared/app/wix/money.ts +0 -24
- package/skills/wix-headless-fast/references/shared/app/wix/sdk.ts +0 -89
- package/skills/wix-headless-fast/references/shared/capabilities/media-upload/app/wix/media-upload/client.ts +0 -46
- package/skills/wix-headless-fast/references/shared/capabilities/media-upload/app-astro/pages/api/wix/media-upload.ts +0 -46
- package/skills/wix-headless-fast/references/shared/rest/client.ts +0 -155
- package/skills/wix-headless-fast/references/shared/rest/config.ts +0 -3
- package/skills/wix-headless-fast/references/shared/rest/media.ts +0 -65
- package/skills/wix-headless-fast/references/shared/seed/images.mjs +0 -145
- package/skills/wix-headless-fast/references/shared/seed/read-site.mjs +0 -99
- package/skills/wix-headless-fast/references/storefront/INSTRUCTIONS.md +0 -612
- package/skills/wix-headless-fast/references/storefront/app/components/storefront/CartButton.tsx +0 -26
- package/skills/wix-headless-fast/references/storefront/app/components/storefront/CartDrawer.tsx +0 -155
- package/skills/wix-headless-fast/references/storefront/app/components/storefront/FilterPanel.tsx +0 -266
- package/skills/wix-headless-fast/references/storefront/app/components/storefront/OptionPicker.tsx +0 -95
- package/skills/wix-headless-fast/references/storefront/app/components/storefront/QuickAdd.tsx +0 -136
- package/skills/wix-headless-fast/references/storefront/app/hooks/storefront/useCart.ts +0 -48
- package/skills/wix-headless-fast/references/storefront/app/hooks/storefront/useProductDetail.ts +0 -39
- package/skills/wix-headless-fast/references/storefront/app/hooks/storefront/useShop.ts +0 -34
- package/skills/wix-headless-fast/references/storefront/app/wix/storefront/cart-core.ts +0 -121
- package/skills/wix-headless-fast/references/storefront/app/wix/storefront/cart-store.ts +0 -107
- package/skills/wix-headless-fast/references/storefront/app/wix/storefront/cart.ts +0 -138
- package/skills/wix-headless-fast/references/storefront/app/wix/storefront/catalog-core.ts +0 -314
- package/skills/wix-headless-fast/references/storefront/app/wix/storefront/catalog.ts +0 -133
- package/skills/wix-headless-fast/references/storefront/app/wix/storefront/product-detail-store.ts +0 -147
- package/skills/wix-headless-fast/references/storefront/app/wix/storefront/shop-store.ts +0 -289
- package/skills/wix-headless-fast/references/storefront/app/wix/storefront/types.ts +0 -169
- package/skills/wix-headless-fast/references/storefront/app-astro/layouts/SiteLayout.astro +0 -65
- package/skills/wix-headless-fast/references/storefront/lock/astro/package-lock.json +0 -12247
- package/skills/wix-headless-fast/references/storefront/rest/cart.ts +0 -132
- package/skills/wix-headless-fast/references/storefront/rest/catalog.ts +0 -123
- package/skills/wix-headless-fast/references/storefront/seed/SEED.md +0 -130
- package/skills/wix-headless-fast/references/storefront/seed/read-site.mjs +0 -38
- package/skills/wix-headless-fast/references/storefront/seed/seed-store.mjs +0 -561
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
// REFERENCE reservations surface: party/date/time query → AVAILABLE slot pills → hold →
|
|
2
|
-
// details form → confirmed, on the @theme tokens. Correct and complete; per the skill's
|
|
3
|
-
// model you design and build your own on useReservation (which owns ALL booking logic).
|
|
4
|
-
import { useReservation } from "../../hooks/restaurants/useReservation";
|
|
5
|
-
|
|
6
|
-
const input =
|
|
7
|
-
"w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary";
|
|
8
|
-
|
|
9
|
-
export default function ReservationView() {
|
|
10
|
-
const r = useReservation();
|
|
11
|
-
|
|
12
|
-
if (r.locations === null) {
|
|
13
|
-
return <div className="h-64 animate-pulse rounded-lg bg-secondary" aria-busy="true" />;
|
|
14
|
-
}
|
|
15
|
-
if (r.locations.length === 0 || !r.location) {
|
|
16
|
-
return (
|
|
17
|
-
<p className="py-16 text-center text-muted-foreground">
|
|
18
|
-
Table reservations aren't set up yet — call us to book.
|
|
19
|
-
</p>
|
|
20
|
-
);
|
|
21
|
-
}
|
|
22
|
-
if (!r.location.onlineReservationsEnabled) {
|
|
23
|
-
// Premium-gated toggle is off — slots/booking would fail; be honest, don't fake a form.
|
|
24
|
-
return (
|
|
25
|
-
<p className="py-16 text-center text-muted-foreground">
|
|
26
|
-
Online reservations aren't open yet — call us to book a table.
|
|
27
|
-
</p>
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
if (r.confirmed) {
|
|
32
|
-
return (
|
|
33
|
-
<div className="mx-auto max-w-md rounded-lg border border-border p-8 text-center">
|
|
34
|
-
<p className="text-lg font-semibold">
|
|
35
|
-
{r.confirmed.status === "RESERVED" ? "Table reserved" : "Request sent"}
|
|
36
|
-
</p>
|
|
37
|
-
<p className="mt-2 text-sm text-muted-foreground">
|
|
38
|
-
{r.confirmed.status === "RESERVED"
|
|
39
|
-
? "See you soon — a confirmation is on its way."
|
|
40
|
-
: "The restaurant will confirm your reservation shortly."}
|
|
41
|
-
</p>
|
|
42
|
-
<button
|
|
43
|
-
type="button"
|
|
44
|
-
onClick={r.reset}
|
|
45
|
-
className="mt-6 rounded-full border border-border px-5 py-2 text-sm font-medium hover:bg-secondary"
|
|
46
|
-
>
|
|
47
|
-
Make another reservation
|
|
48
|
-
</button>
|
|
49
|
-
</div>
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return (
|
|
54
|
-
<div className="mx-auto max-w-xl">
|
|
55
|
-
<div className="grid grid-cols-1 gap-4 sm:grid-cols-3">
|
|
56
|
-
<label className="block text-sm">
|
|
57
|
-
<span className="text-muted-foreground">Guests</span>
|
|
58
|
-
<input
|
|
59
|
-
type="number"
|
|
60
|
-
min={r.location.partySizeMin}
|
|
61
|
-
max={r.location.partySizeMax}
|
|
62
|
-
value={r.partySize}
|
|
63
|
-
onChange={(e) => r.setPartySize(Number(e.target.value))}
|
|
64
|
-
className={`mt-1 ${input}`}
|
|
65
|
-
/>
|
|
66
|
-
</label>
|
|
67
|
-
<label className="block text-sm">
|
|
68
|
-
<span className="text-muted-foreground">Date</span>
|
|
69
|
-
<input type="date" value={r.date} onChange={(e) => r.setDate(e.target.value)} className={`mt-1 ${input}`} />
|
|
70
|
-
</label>
|
|
71
|
-
<label className="block text-sm">
|
|
72
|
-
<span className="text-muted-foreground">Around</span>
|
|
73
|
-
<input type="time" value={r.time} onChange={(e) => r.setTime(e.target.value)} className={`mt-1 ${input}`} />
|
|
74
|
-
</label>
|
|
75
|
-
</div>
|
|
76
|
-
<button
|
|
77
|
-
type="button"
|
|
78
|
-
disabled={r.loading}
|
|
79
|
-
onClick={() => void r.findSlots()}
|
|
80
|
-
className="mt-4 w-full rounded-full bg-primary py-3 text-sm font-semibold text-primary-foreground transition-opacity hover:opacity-90 disabled:opacity-50"
|
|
81
|
-
>
|
|
82
|
-
{r.loading && r.slots === null ? "Finding times…" : "Find a table"}
|
|
83
|
-
</button>
|
|
84
|
-
|
|
85
|
-
{r.error && <p className="mt-4 text-sm text-red-600">{r.error}</p>}
|
|
86
|
-
|
|
87
|
-
{r.slots !== null && r.slots.length === 0 && !r.error && (
|
|
88
|
-
<p className="mt-6 text-center text-sm text-muted-foreground">
|
|
89
|
-
No tables around that time — try another time or party size.
|
|
90
|
-
</p>
|
|
91
|
-
)}
|
|
92
|
-
|
|
93
|
-
{r.slots !== null && r.slots.length > 0 && !r.held && (
|
|
94
|
-
<div className="mt-6 flex flex-wrap gap-2" role="group" aria-label="Available times">
|
|
95
|
-
{r.slots.map((slot) => (
|
|
96
|
-
<button
|
|
97
|
-
key={slot.startIso}
|
|
98
|
-
type="button"
|
|
99
|
-
disabled={r.loading}
|
|
100
|
-
onClick={() => void r.holdSlot(slot)}
|
|
101
|
-
className="rounded-full border border-border px-4 py-1.5 text-sm font-medium transition-colors hover:bg-secondary disabled:opacity-40"
|
|
102
|
-
>
|
|
103
|
-
{slot.label}
|
|
104
|
-
</button>
|
|
105
|
-
))}
|
|
106
|
-
</div>
|
|
107
|
-
)}
|
|
108
|
-
|
|
109
|
-
{r.held && (
|
|
110
|
-
<div className="mt-6 rounded-lg border border-border p-5">
|
|
111
|
-
<p className="text-sm font-medium">
|
|
112
|
-
Holding {new Date(r.held.startIso).toLocaleString(undefined, { weekday: "short", month: "short", day: "numeric", hour: "numeric", minute: "2-digit" })}{" "}
|
|
113
|
-
for {r.held.partySize} — complete within 10 minutes.
|
|
114
|
-
</p>
|
|
115
|
-
<div className="mt-4 grid grid-cols-1 gap-3 sm:grid-cols-2">
|
|
116
|
-
<input
|
|
117
|
-
placeholder="First name *"
|
|
118
|
-
value={r.reservee.firstName}
|
|
119
|
-
onChange={(e) => r.setReserveeField("firstName", e.target.value)}
|
|
120
|
-
className={input}
|
|
121
|
-
/>
|
|
122
|
-
<input
|
|
123
|
-
placeholder="Last name"
|
|
124
|
-
value={r.reservee.lastName ?? ""}
|
|
125
|
-
onChange={(e) => r.setReserveeField("lastName", e.target.value)}
|
|
126
|
-
className={input}
|
|
127
|
-
/>
|
|
128
|
-
<input
|
|
129
|
-
placeholder="Phone (+15551234567) *"
|
|
130
|
-
type="tel"
|
|
131
|
-
value={r.reservee.phone}
|
|
132
|
-
onChange={(e) => r.setReserveeField("phone", e.target.value)}
|
|
133
|
-
className={input}
|
|
134
|
-
/>
|
|
135
|
-
<input
|
|
136
|
-
placeholder="Email"
|
|
137
|
-
type="email"
|
|
138
|
-
value={r.reservee.email ?? ""}
|
|
139
|
-
onChange={(e) => r.setReserveeField("email", e.target.value)}
|
|
140
|
-
className={input}
|
|
141
|
-
/>
|
|
142
|
-
</div>
|
|
143
|
-
<button
|
|
144
|
-
type="button"
|
|
145
|
-
disabled={!r.canConfirm}
|
|
146
|
-
onClick={() => void r.confirm()}
|
|
147
|
-
className="mt-4 w-full rounded-full bg-primary py-3 text-sm font-semibold text-primary-foreground transition-opacity hover:opacity-90 disabled:opacity-50"
|
|
148
|
-
>
|
|
149
|
-
{r.loading ? "Reserving…" : "Complete reservation"}
|
|
150
|
-
</button>
|
|
151
|
-
</div>
|
|
152
|
-
)}
|
|
153
|
-
</div>
|
|
154
|
-
);
|
|
155
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
// React binding of the menu store (wix/restaurants/menu-store.ts) — menu browsing and switching
|
|
2
|
-
// live there, framework-free; this hook subscribes to one instance per mounted surface. SSR-friendly:
|
|
3
|
-
// pass server-fetched menus as `initialMenus` (Astro frontmatter) and no client fetch happens; a SPA
|
|
4
|
-
// passes nothing. Astro islands and React SPAs use this; a static page, Vue, or Svelte uses the store.
|
|
5
|
-
import { useEffect, useRef, useSyncExternalStore } from "react";
|
|
6
|
-
import { createMenuStore, type MenuStore } from "../../wix/restaurants/menu-store";
|
|
7
|
-
import type { MenuData } from "../../wix/restaurants/types";
|
|
8
|
-
|
|
9
|
-
export interface UseMenusOptions {
|
|
10
|
-
initialMenus?: MenuData[];
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export interface UseMenus {
|
|
14
|
-
/** null while the first load is in flight — render skeletons, not an empty state. */
|
|
15
|
-
menus: MenuData[] | null;
|
|
16
|
-
/** Defaults to the first menu once loaded. */
|
|
17
|
-
activeMenuId: string | null;
|
|
18
|
-
setActiveMenuId: (id: string) => void;
|
|
19
|
-
/** The menu to render (its sections/items are display-ordered). */
|
|
20
|
-
activeMenu: MenuData | null;
|
|
21
|
-
error: string | null;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function useMenus({ initialMenus }: UseMenusOptions = {}): UseMenus {
|
|
25
|
-
const ref = useRef<MenuStore | null>(null);
|
|
26
|
-
if (!ref.current) ref.current = createMenuStore({ initialMenus });
|
|
27
|
-
const store = ref.current;
|
|
28
|
-
useEffect(() => {
|
|
29
|
-
store.start();
|
|
30
|
-
return () => store.stop();
|
|
31
|
-
}, [store]);
|
|
32
|
-
const state = useSyncExternalStore(store.subscribe, store.getState, store.getState);
|
|
33
|
-
return { ...state, setActiveMenuId: store.setActiveMenuId };
|
|
34
|
-
}
|
package/skills/wix-headless-fast/references/restaurants/app/hooks/restaurants/useOrderCart.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
// React binding for the order-cart store. Works in any React root — Astro islands (several
|
|
2
|
-
// on one page share the same store) and SPAs alike.
|
|
3
|
-
import { useSyncExternalStore } from "react";
|
|
4
|
-
import {
|
|
5
|
-
addOrderLine,
|
|
6
|
-
getOrderCartState,
|
|
7
|
-
goToOrderCheckout,
|
|
8
|
-
refreshOrderCart,
|
|
9
|
-
removeLineFromOrder,
|
|
10
|
-
setOrderCartOpen,
|
|
11
|
-
subscribeOrderCart,
|
|
12
|
-
updateOrderLineQuantity,
|
|
13
|
-
type OrderCartState,
|
|
14
|
-
} from "../../wix/restaurants/order-store";
|
|
15
|
-
|
|
16
|
-
const SERVER_STATE = getOrderCartState();
|
|
17
|
-
|
|
18
|
-
export interface UseOrderCart extends OrderCartState {
|
|
19
|
-
itemCount: number;
|
|
20
|
-
/** menuId/sectionId come from the render context (the fetchMenus tree) — pass both. */
|
|
21
|
-
addToOrder: (itemId: string, context: { menuId: string; sectionId: string }, quantity?: number) => Promise<void>;
|
|
22
|
-
updateQuantity: (lineItemId: string, quantity: number) => Promise<void>;
|
|
23
|
-
removeLine: (lineItemId: string) => Promise<void>;
|
|
24
|
-
checkout: () => Promise<void>;
|
|
25
|
-
openCart: () => void;
|
|
26
|
-
closeCart: () => void;
|
|
27
|
-
refresh: () => Promise<void>;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export function useOrderCart(): UseOrderCart {
|
|
31
|
-
const state = useSyncExternalStore(subscribeOrderCart, getOrderCartState, () => SERVER_STATE);
|
|
32
|
-
return {
|
|
33
|
-
...state,
|
|
34
|
-
itemCount: state.cart?.itemCount ?? 0,
|
|
35
|
-
addToOrder: addOrderLine,
|
|
36
|
-
updateQuantity: updateOrderLineQuantity,
|
|
37
|
-
removeLine: removeLineFromOrder,
|
|
38
|
-
checkout: goToOrderCheckout,
|
|
39
|
-
openCart: () => setOrderCartOpen(true),
|
|
40
|
-
closeCart: () => setOrderCartOpen(false),
|
|
41
|
-
refresh: refreshOrderCart,
|
|
42
|
-
};
|
|
43
|
-
}
|
package/skills/wix-headless-fast/references/restaurants/app/hooks/restaurants/useReservation.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
// React binding of the reservation store (wix/restaurants/reservation-store.ts) — the whole
|
|
2
|
-
// table-reservation state machine lives there, framework-free: location, date + party size,
|
|
3
|
-
// AVAILABLE slots, the 10-minute hold, the details form, and confirm. All correctness (AVAILABLE-only
|
|
4
|
-
// slots, hold → reserve with the revision, firstName + E.164 phone, RESERVED vs REQUESTED) lives in
|
|
5
|
-
// the data layer; you own how it looks. Client-only: availability is timezone-specific, so render
|
|
6
|
-
// the surface with client:only="react" in Astro.
|
|
7
|
-
import { useEffect, useRef, useSyncExternalStore } from "react";
|
|
8
|
-
import { createReservationStore, type ReservationState, type ReservationStore } from "../../wix/restaurants/reservation-store";
|
|
9
|
-
|
|
10
|
-
export type UseReservation = ReservationState &
|
|
11
|
-
Pick<ReservationStore, "setLocationId" | "setDate" | "setTime" | "setPartySize" | "findSlots" | "holdSlot" | "setReserveeField" | "confirm" | "reset">;
|
|
12
|
-
|
|
13
|
-
export function useReservation(): UseReservation {
|
|
14
|
-
const ref = useRef<ReservationStore | null>(null);
|
|
15
|
-
if (!ref.current) ref.current = createReservationStore();
|
|
16
|
-
const store = ref.current;
|
|
17
|
-
useEffect(() => {
|
|
18
|
-
store.start();
|
|
19
|
-
return () => store.stop();
|
|
20
|
-
}, [store]);
|
|
21
|
-
const state = useSyncExternalStore(store.subscribe, store.getState, store.getState);
|
|
22
|
-
return {
|
|
23
|
-
...state,
|
|
24
|
-
setLocationId: store.setLocationId,
|
|
25
|
-
setDate: store.setDate,
|
|
26
|
-
setTime: store.setTime,
|
|
27
|
-
setPartySize: store.setPartySize,
|
|
28
|
-
findSlots: store.findSlots,
|
|
29
|
-
holdSlot: store.holdSlot,
|
|
30
|
-
setReserveeField: store.setReserveeField,
|
|
31
|
-
confirm: store.confirm,
|
|
32
|
-
reset: store.reset,
|
|
33
|
-
};
|
|
34
|
-
}
|
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
// Menu rules and DTO mapping — transport-agnostic, imported by BOTH transports: ./menu.ts (the
|
|
2
|
-
// SDK, managed Astro and React) and the REST twin in references/restaurants/rest/menu.ts (fetch,
|
|
3
|
-
// a static site or a port to another language). The hierarchy is Menu → Sections → Items wired by
|
|
4
|
-
// ID ARRAYS: display structure and order live in menu.sectionIds / section.itemIds, never in a
|
|
5
|
-
// list response's order — the tree is stitched here in id-array order and dangling ids dropped.
|
|
6
|
-
// A raw entity carries `_id` (SDK) or `id` (REST); every mapper accepts both. Imports are
|
|
7
|
-
// type-only so a strip to JS emits no imports.
|
|
8
|
-
import type {
|
|
9
|
-
MenuData,
|
|
10
|
-
MenuItem,
|
|
11
|
-
MenuItemLabel,
|
|
12
|
-
MenuItemVariant,
|
|
13
|
-
MenuModifier,
|
|
14
|
-
MenuModifierGroup,
|
|
15
|
-
MenuSection,
|
|
16
|
-
} from "./types";
|
|
17
|
-
|
|
18
|
-
/** A raw Menus V1 entity as either transport returns it. */
|
|
19
|
-
export type Raw = Record<string, any>;
|
|
20
|
-
/** Media value + size → https URL. Injected: the SDK transport scales through @wix/sdk, REST through the URL form. */
|
|
21
|
-
export type ImgSrc = (value: any, width: number, height: number) => string;
|
|
22
|
-
|
|
23
|
-
export const rawId = (raw: Raw | undefined | null): string => raw?._id ?? raw?.id ?? "";
|
|
24
|
-
|
|
25
|
-
/** Index raw entities by id (either spelling). */
|
|
26
|
-
export const byId = (arr: Raw[]): Map<string, Raw> => new Map(arr.map((e) => [rawId(e), e]));
|
|
27
|
-
|
|
28
|
-
const unique = (ids: string[]): string[] => [...new Set(ids.filter(Boolean))];
|
|
29
|
-
|
|
30
|
-
// Menu prices are decimal strings in the site currency with NO symbol; the response may carry a
|
|
31
|
-
// platform-formatted twin (formattedPrice) — prefer it, never invent a symbol.
|
|
32
|
-
export function displayPrice(priceInfo: Raw | undefined): string | null {
|
|
33
|
-
if (!priceInfo) return null;
|
|
34
|
-
return priceInfo.formattedPrice ?? priceInfo.price ?? null;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/** The variant ids the items reference — the second read's `variantIds`. */
|
|
38
|
-
export function collectVariantIds(items: Raw[]): string[] {
|
|
39
|
-
return unique(items.flatMap((i) => ((i.priceVariants?.variants ?? []) as Raw[]).map((v) => v.variantId)));
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/** The modifier-group ids the items reference — the second read's `modifierGroupIds`. */
|
|
43
|
-
export function collectGroupIds(items: Raw[]): string[] {
|
|
44
|
-
return unique(items.flatMap((i) => ((i.modifierGroups ?? []) as Raw[]).map(rawId)));
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/** The modifier ids the groups reference — the third read's `modifierIds`. */
|
|
48
|
-
export function collectModifierIds(groups: Raw[]): string[] {
|
|
49
|
-
return unique(groups.flatMap((g) => ((g.modifiers ?? []) as Raw[]).map(rawId)));
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/** Whether any item carries a label — the labels list is read only then. */
|
|
53
|
-
export function anyLabels(items: Raw[]): boolean {
|
|
54
|
-
return items.some((i) => ((i.labels ?? []) as Raw[]).length > 0);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export interface MenuLookups {
|
|
58
|
-
variantById: Map<string, Raw>;
|
|
59
|
-
groupById: Map<string, Raw>;
|
|
60
|
-
modifierById: Map<string, Raw>;
|
|
61
|
-
labelById: Map<string, Raw>;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export function toItem(raw: Raw, lookups: MenuLookups, imgSrc: ImgSrc): MenuItem {
|
|
65
|
-
const variants: MenuItemVariant[] = ((raw.priceVariants?.variants ?? []) as Raw[])
|
|
66
|
-
.map((v): MenuItemVariant => ({
|
|
67
|
-
variantId: v.variantId ?? "",
|
|
68
|
-
name: lookups.variantById.get(v.variantId)?.name ?? "",
|
|
69
|
-
price: displayPrice(v.priceInfo) ?? v.price ?? "",
|
|
70
|
-
}))
|
|
71
|
-
.filter((v) => v.variantId);
|
|
72
|
-
const modifierGroups: MenuModifierGroup[] = ((raw.modifierGroups ?? []) as Raw[])
|
|
73
|
-
.map((ref) => lookups.groupById.get(rawId(ref)))
|
|
74
|
-
.filter((g): g is Raw => !!g)
|
|
75
|
-
.map((g): MenuModifierGroup => ({
|
|
76
|
-
id: rawId(g),
|
|
77
|
-
name: g.name ?? "",
|
|
78
|
-
required: g.rule?.required === true,
|
|
79
|
-
minSelections: g.rule?.minSelections ?? 0,
|
|
80
|
-
maxSelections: g.rule?.maxSelections ?? null,
|
|
81
|
-
modifiers: ((g.modifiers ?? []) as Raw[]).map((m): MenuModifier => ({
|
|
82
|
-
id: rawId(m),
|
|
83
|
-
name: lookups.modifierById.get(rawId(m))?.name ?? "",
|
|
84
|
-
preSelected: m.preSelected === true,
|
|
85
|
-
additionalCharge: m.additionalChargeInfo?.additionalCharge ?? "0",
|
|
86
|
-
inStock: lookups.modifierById.get(rawId(m))?.inStock !== false,
|
|
87
|
-
})),
|
|
88
|
-
}));
|
|
89
|
-
const labels: MenuItemLabel[] = ((raw.labels ?? []) as Raw[])
|
|
90
|
-
.map((ref) => lookups.labelById.get(rawId(ref)))
|
|
91
|
-
.filter((l): l is Raw => !!l)
|
|
92
|
-
.map((l): MenuItemLabel => ({ id: rawId(l), name: l.name ?? "", iconUrl: imgSrc(l.icon, 48, 48) }));
|
|
93
|
-
const price = displayPrice(raw.priceInfo);
|
|
94
|
-
return {
|
|
95
|
-
id: rawId(raw),
|
|
96
|
-
name: raw.name ?? "",
|
|
97
|
-
description: raw.description ?? "",
|
|
98
|
-
price,
|
|
99
|
-
marketPrice: price === null && variants.length === 0,
|
|
100
|
-
variants,
|
|
101
|
-
imageUrl: imgSrc(raw.image, 800, 800),
|
|
102
|
-
labels,
|
|
103
|
-
modifierGroups,
|
|
104
|
-
inStock: raw.orderSettings?.inStock !== false,
|
|
105
|
-
featured: raw.featured === true,
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
export function toSection(raw: Raw, itemById: Map<string, MenuItem>, imgSrc: ImgSrc): MenuSection {
|
|
110
|
-
return {
|
|
111
|
-
id: rawId(raw),
|
|
112
|
-
name: raw.name ?? "",
|
|
113
|
-
description: raw.description ?? "",
|
|
114
|
-
imageUrl: imgSrc(raw.image, 800, 800),
|
|
115
|
-
items: ((raw.itemIds ?? []) as string[]).map((iid) => itemById.get(iid)).filter((i): i is MenuItem => !!i),
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
export function toMenu(raw: Raw, sectionById: Map<string, Raw>, itemById: Map<string, MenuItem>, imgSrc: ImgSrc): MenuData {
|
|
120
|
-
return {
|
|
121
|
-
id: rawId(raw),
|
|
122
|
-
name: raw.name ?? "",
|
|
123
|
-
description: raw.description ?? "",
|
|
124
|
-
slug: raw.urlQueryParam ?? "",
|
|
125
|
-
sections: ((raw.sectionIds ?? []) as string[])
|
|
126
|
-
.map((sid) => sectionById.get(sid))
|
|
127
|
-
.filter((s): s is Raw => !!s)
|
|
128
|
-
.map((s) => toSection(s, itemById, imgSrc)),
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/** The seven list responses' entity arrays, as either transport returns them. */
|
|
133
|
-
export interface MenuTreeParts {
|
|
134
|
-
menus: Raw[];
|
|
135
|
-
sections: Raw[];
|
|
136
|
-
items: Raw[];
|
|
137
|
-
variants: Raw[];
|
|
138
|
-
groups: Raw[];
|
|
139
|
-
modifiers: Raw[];
|
|
140
|
-
labels: Raw[];
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
/** The display-ordered tree: visible menus → their sections → their items, each item enriched. [] when no menus. */
|
|
144
|
-
export function assembleMenus(parts: MenuTreeParts, imgSrc: ImgSrc): MenuData[] {
|
|
145
|
-
if (!parts.menus.length) return [];
|
|
146
|
-
const lookups: MenuLookups = {
|
|
147
|
-
variantById: byId(parts.variants),
|
|
148
|
-
groupById: byId(parts.groups),
|
|
149
|
-
modifierById: byId(parts.modifiers),
|
|
150
|
-
labelById: byId(parts.labels),
|
|
151
|
-
};
|
|
152
|
-
const sectionById = byId(parts.sections);
|
|
153
|
-
const itemById = new Map<string, MenuItem>(parts.items.map((i) => [rawId(i), toItem(i, lookups, imgSrc)]));
|
|
154
|
-
return parts.menus.map((m) => toMenu(m, sectionById, itemById, imgSrc));
|
|
155
|
-
}
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
// Menu browsing as a framework-free store — the logic behind useMenus, usable from React (useMenus
|
|
2
|
-
// wraps it with useSyncExternalStore), from a static page or Vue/Svelte (subscribe and render), or
|
|
3
|
-
// as the specification for a port. Same shape as order-store.ts: state, actions, subscribe/getState,
|
|
4
|
-
// emit after every change. The whole tree is fetched once; menu switching is local.
|
|
5
|
-
//
|
|
6
|
-
// SSR-friendly: seed with `initialMenus` (Astro frontmatter) and no fetch happens; a SPA passes
|
|
7
|
-
// nothing and `start()` fetches. One store per mounted menu surface: createMenuStore(), not a
|
|
8
|
-
// singleton (the order cart is the singleton — one per visitor).
|
|
9
|
-
import { fetchMenus } from "./menu";
|
|
10
|
-
import type { MenuData } from "./types";
|
|
11
|
-
|
|
12
|
-
export interface MenuStoreOptions {
|
|
13
|
-
initialMenus?: MenuData[];
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/** Everything a menu surface renders from. Read it with getState() or through a subscription. */
|
|
17
|
-
export interface MenuState {
|
|
18
|
-
/** null while the first load is in flight — render skeletons, not an empty state. */
|
|
19
|
-
menus: MenuData[] | null;
|
|
20
|
-
/** Defaults to the first menu once loaded. */
|
|
21
|
-
activeMenuId: string | null;
|
|
22
|
-
/** The menu to render (its sections/items are display-ordered). */
|
|
23
|
-
activeMenu: MenuData | null;
|
|
24
|
-
error: string | null;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export interface MenuStore {
|
|
28
|
-
getState(): MenuState;
|
|
29
|
-
subscribe(listener: () => void): () => void;
|
|
30
|
-
/** Fetch the tree when no `initialMenus` were given. Call once when mounted. */
|
|
31
|
-
start(): void;
|
|
32
|
-
/** Stop reacting; drop a late response. */
|
|
33
|
-
stop(): void;
|
|
34
|
-
setActiveMenuId(id: string): void;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export function createMenuStore({ initialMenus }: MenuStoreOptions = {}): MenuStore {
|
|
38
|
-
let menus: MenuData[] | null = initialMenus ?? null;
|
|
39
|
-
let selectedId: string | null = initialMenus?.[0]?.id ?? null;
|
|
40
|
-
let error: string | null = null;
|
|
41
|
-
let started = false;
|
|
42
|
-
const listeners = new Set<() => void>();
|
|
43
|
-
let snapshot: MenuState | null = null;
|
|
44
|
-
const emit = () => {
|
|
45
|
-
snapshot = null;
|
|
46
|
-
for (const fn of listeners) fn();
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
function getState(): MenuState {
|
|
50
|
-
if (snapshot) return snapshot;
|
|
51
|
-
const activeMenu = menus ? (menus.find((m) => m.id === selectedId) ?? menus[0] ?? null) : null;
|
|
52
|
-
snapshot = { menus, activeMenuId: activeMenu?.id ?? null, activeMenu, error };
|
|
53
|
-
return snapshot;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return {
|
|
57
|
-
getState,
|
|
58
|
-
subscribe(fn) {
|
|
59
|
-
listeners.add(fn);
|
|
60
|
-
return () => listeners.delete(fn);
|
|
61
|
-
},
|
|
62
|
-
start() {
|
|
63
|
-
if (started) return;
|
|
64
|
-
started = true;
|
|
65
|
-
if (initialMenus) return;
|
|
66
|
-
fetchMenus()
|
|
67
|
-
.then((m) => {
|
|
68
|
-
if (!started) return;
|
|
69
|
-
menus = m;
|
|
70
|
-
selectedId ??= m[0]?.id ?? null;
|
|
71
|
-
emit();
|
|
72
|
-
})
|
|
73
|
-
.catch((e) => {
|
|
74
|
-
if (!started) return;
|
|
75
|
-
menus = [];
|
|
76
|
-
error = e instanceof Error ? e.message : String(e);
|
|
77
|
-
emit();
|
|
78
|
-
});
|
|
79
|
-
},
|
|
80
|
-
stop() {
|
|
81
|
-
started = false;
|
|
82
|
-
},
|
|
83
|
-
setActiveMenuId(id) {
|
|
84
|
-
if (id === selectedId) return;
|
|
85
|
-
selectedId = id;
|
|
86
|
-
emit();
|
|
87
|
-
},
|
|
88
|
-
};
|
|
89
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
// Menu reads (Wix Restaurants Menus V1) over the SDK — the only file that touches raw menu
|
|
2
|
-
// entities on this transport. Everything it returns is a plain DTO from ./types. The rules and
|
|
3
|
-
// the tree assembly live in ./menu-core (shared with the REST twin in references/restaurants/rest/);
|
|
4
|
-
// this file is the transport only. Copy as-is; extend by adding functions, not by editing these.
|
|
5
|
-
// docs: https://dev.wix.com/docs/api-reference/business-solutions/restaurants/menus/menus/list-menus.md
|
|
6
|
-
// docs: https://dev.wix.com/docs/api-reference/business-solutions/restaurants/menus/sections/list-sections.md
|
|
7
|
-
// docs: https://dev.wix.com/docs/api-reference/business-solutions/restaurants/menus/items/items/list-items.md
|
|
8
|
-
// docs: https://dev.wix.com/docs/api-reference/business-solutions/restaurants/menus/items/item-variants/list-variants.md
|
|
9
|
-
// docs: https://dev.wix.com/docs/api-reference/business-solutions/restaurants/menus/items/item-modifier-groups/list-modifier-groups.md
|
|
10
|
-
// docs: https://dev.wix.com/docs/api-reference/business-solutions/restaurants/menus/items/item-modifiers/list-modifiers.md
|
|
11
|
-
// docs: https://dev.wix.com/docs/api-reference/business-solutions/restaurants/menus/items/item-labels/list-labels.md
|
|
12
|
-
import {
|
|
13
|
-
menus as menusModule,
|
|
14
|
-
sections as sectionsModule,
|
|
15
|
-
items as itemsModule,
|
|
16
|
-
itemVariants,
|
|
17
|
-
itemModifierGroups,
|
|
18
|
-
itemModifiers,
|
|
19
|
-
itemLabels,
|
|
20
|
-
} from "@wix/restaurants";
|
|
21
|
-
import { wixModule } from "../sdk";
|
|
22
|
-
import { imgSrc } from "../media";
|
|
23
|
-
import { anyLabels, assembleMenus, collectGroupIds, collectModifierIds, collectVariantIds, type Raw } from "./menu-core";
|
|
24
|
-
import type { MenuData } from "./types";
|
|
25
|
-
|
|
26
|
-
const menusApi = wixModule(menusModule);
|
|
27
|
-
const sectionsApi = wixModule(sectionsModule);
|
|
28
|
-
const itemsApi = wixModule(itemsModule);
|
|
29
|
-
const variantsApi = wixModule(itemVariants);
|
|
30
|
-
const groupsApi = wixModule(itemModifierGroups);
|
|
31
|
-
const modifiersApi = wixModule(itemModifiers);
|
|
32
|
-
const labelsApi = wixModule(itemLabels);
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* The site's full menu tree, assembled and display-ordered: visible menus → their sections →
|
|
36
|
-
* their items, each item enriched with resolved price variants, modifier groups, and labels.
|
|
37
|
-
* The one entry point for every menu surface. [] when no menus exist (honest empty state).
|
|
38
|
-
* Caps at the APIs' 500-per-list limit — plenty for a restaurant.
|
|
39
|
-
*/
|
|
40
|
-
export async function fetchMenus(): Promise<MenuData[]> {
|
|
41
|
-
const [menusRes, sectionsRes, itemsRes]: Raw[] = await Promise.all([
|
|
42
|
-
menusApi.listMenus({ onlyVisible: true }),
|
|
43
|
-
sectionsApi.listSections({ onlyVisible: true }),
|
|
44
|
-
itemsApi.listItems({ onlyVisible: true }),
|
|
45
|
-
]);
|
|
46
|
-
const menus: Raw[] = menusRes.menus ?? [];
|
|
47
|
-
if (!menus.length) return [];
|
|
48
|
-
const items: Raw[] = itemsRes.items ?? [];
|
|
49
|
-
const variantIds = collectVariantIds(items);
|
|
50
|
-
const groupIds = collectGroupIds(items);
|
|
51
|
-
const [variantsRes, groupsRes, labelsRes]: Raw[] = await Promise.all([
|
|
52
|
-
variantIds.length ? variantsApi.listVariants({ variantIds }) : Promise.resolve({ variants: [] }),
|
|
53
|
-
groupIds.length ? groupsApi.listModifierGroups({ modifierGroupIds: groupIds }) : Promise.resolve({ modifierGroups: [] }),
|
|
54
|
-
anyLabels(items) ? labelsApi.listLabels() : Promise.resolve({ labels: [] }),
|
|
55
|
-
]);
|
|
56
|
-
const groups: Raw[] = groupsRes.modifierGroups ?? [];
|
|
57
|
-
const modifierIds = collectModifierIds(groups);
|
|
58
|
-
const modifiersRes: Raw = modifierIds.length ? await modifiersApi.listModifiers({ modifierIds }) : { modifiers: [] };
|
|
59
|
-
return assembleMenus(
|
|
60
|
-
{
|
|
61
|
-
menus,
|
|
62
|
-
sections: sectionsRes.sections ?? [],
|
|
63
|
-
items,
|
|
64
|
-
variants: variantsRes.variants ?? [],
|
|
65
|
-
groups,
|
|
66
|
-
modifiers: modifiersRes.modifiers ?? [],
|
|
67
|
-
labels: labelsRes.labels ?? [],
|
|
68
|
-
},
|
|
69
|
-
imgSrc,
|
|
70
|
-
);
|
|
71
|
-
}
|