@doswiftly/cli 0.1.1
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/README.md +357 -0
- package/bin/doswiftly.js +2 -0
- package/dist/commands/auth-github.d.ts +6 -0
- package/dist/commands/auth-github.d.ts.map +1 -0
- package/dist/commands/auth-github.js +89 -0
- package/dist/commands/auth-github.js.map +1 -0
- package/dist/commands/auth-token.d.ts +12 -0
- package/dist/commands/auth-token.d.ts.map +1 -0
- package/dist/commands/auth-token.js +43 -0
- package/dist/commands/auth-token.js.map +1 -0
- package/dist/commands/auth.d.ts +22 -0
- package/dist/commands/auth.d.ts.map +1 -0
- package/dist/commands/auth.js +348 -0
- package/dist/commands/auth.js.map +1 -0
- package/dist/commands/check.d.ts +5 -0
- package/dist/commands/check.d.ts.map +1 -0
- package/dist/commands/check.js +234 -0
- package/dist/commands/check.js.map +1 -0
- package/dist/commands/config.d.ts +3 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +104 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/deploy.d.ts +37 -0
- package/dist/commands/deploy.d.ts.map +1 -0
- package/dist/commands/deploy.js +580 -0
- package/dist/commands/deploy.js.map +1 -0
- package/dist/commands/dev.d.ts +8 -0
- package/dist/commands/dev.d.ts.map +1 -0
- package/dist/commands/dev.js +83 -0
- package/dist/commands/dev.js.map +1 -0
- package/dist/commands/doctor.d.ts +5 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +363 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/domain.d.ts +13 -0
- package/dist/commands/domain.d.ts.map +1 -0
- package/dist/commands/domain.js +128 -0
- package/dist/commands/domain.js.map +1 -0
- package/dist/commands/env.d.ts +25 -0
- package/dist/commands/env.d.ts.map +1 -0
- package/dist/commands/env.js +228 -0
- package/dist/commands/env.js.map +1 -0
- package/dist/commands/init.d.ts +11 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +1028 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/inspect.d.ts +12 -0
- package/dist/commands/inspect.d.ts.map +1 -0
- package/dist/commands/inspect.js +162 -0
- package/dist/commands/inspect.js.map +1 -0
- package/dist/commands/migrate.d.ts +18 -0
- package/dist/commands/migrate.d.ts.map +1 -0
- package/dist/commands/migrate.js +355 -0
- package/dist/commands/migrate.js.map +1 -0
- package/dist/commands/preview.d.ts +29 -0
- package/dist/commands/preview.d.ts.map +1 -0
- package/dist/commands/preview.js +199 -0
- package/dist/commands/preview.js.map +1 -0
- package/dist/commands/proxy.d.ts +9 -0
- package/dist/commands/proxy.d.ts.map +1 -0
- package/dist/commands/proxy.js +37 -0
- package/dist/commands/proxy.js.map +1 -0
- package/dist/commands/sdk.d.ts +5 -0
- package/dist/commands/sdk.d.ts.map +1 -0
- package/dist/commands/sdk.js +82 -0
- package/dist/commands/sdk.js.map +1 -0
- package/dist/commands/template.d.ts +107 -0
- package/dist/commands/template.d.ts.map +1 -0
- package/dist/commands/template.js +1309 -0
- package/dist/commands/template.js.map +1 -0
- package/dist/commands/types.d.ts +5 -0
- package/dist/commands/types.d.ts.map +1 -0
- package/dist/commands/types.js +82 -0
- package/dist/commands/types.js.map +1 -0
- package/dist/commands/update.d.ts +2 -0
- package/dist/commands/update.d.ts.map +1 -0
- package/dist/commands/update.js +103 -0
- package/dist/commands/update.js.map +1 -0
- package/dist/commands/upgrade.d.ts +18 -0
- package/dist/commands/upgrade.d.ts.map +1 -0
- package/dist/commands/upgrade.js +55 -0
- package/dist/commands/upgrade.js.map +1 -0
- package/dist/commands/verify.d.ts +5 -0
- package/dist/commands/verify.d.ts.map +1 -0
- package/dist/commands/verify.js +232 -0
- package/dist/commands/verify.js.map +1 -0
- package/dist/commands/whoami.d.ts +5 -0
- package/dist/commands/whoami.d.ts.map +1 -0
- package/dist/commands/whoami.js +60 -0
- package/dist/commands/whoami.js.map +1 -0
- package/dist/config/types.d.ts +173 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config/types.js +48 -0
- package/dist/config/types.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +416 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/api-url.d.ts +14 -0
- package/dist/lib/api-url.d.ts.map +1 -0
- package/dist/lib/api-url.js +24 -0
- package/dist/lib/api-url.js.map +1 -0
- package/dist/lib/api.d.ts +67 -0
- package/dist/lib/api.d.ts.map +1 -0
- package/dist/lib/api.js +36 -0
- package/dist/lib/api.js.map +1 -0
- package/dist/lib/config.d.ts +39 -0
- package/dist/lib/config.d.ts.map +1 -0
- package/dist/lib/config.js +195 -0
- package/dist/lib/config.js.map +1 -0
- package/dist/lib/env-storage.d.ts +140 -0
- package/dist/lib/env-storage.d.ts.map +1 -0
- package/dist/lib/env-storage.js +464 -0
- package/dist/lib/env-storage.js.map +1 -0
- package/dist/lib/errors.d.ts +61 -0
- package/dist/lib/errors.d.ts.map +1 -0
- package/dist/lib/errors.js +204 -0
- package/dist/lib/errors.js.map +1 -0
- package/dist/lib/i18n.d.ts +99 -0
- package/dist/lib/i18n.d.ts.map +1 -0
- package/dist/lib/i18n.js +184 -0
- package/dist/lib/i18n.js.map +1 -0
- package/dist/lib/logger.d.ts +95 -0
- package/dist/lib/logger.d.ts.map +1 -0
- package/dist/lib/logger.js +168 -0
- package/dist/lib/logger.js.map +1 -0
- package/dist/lib/package-manager.d.ts +91 -0
- package/dist/lib/package-manager.d.ts.map +1 -0
- package/dist/lib/package-manager.js +205 -0
- package/dist/lib/package-manager.js.map +1 -0
- package/dist/lib/proxy-server.d.ts +24 -0
- package/dist/lib/proxy-server.d.ts.map +1 -0
- package/dist/lib/proxy-server.js +173 -0
- package/dist/lib/proxy-server.js.map +1 -0
- package/dist/lib/select-with-back.d.ts +34 -0
- package/dist/lib/select-with-back.d.ts.map +1 -0
- package/dist/lib/select-with-back.js +94 -0
- package/dist/lib/select-with-back.js.map +1 -0
- package/dist/lib/shared-api-client.d.ts +40 -0
- package/dist/lib/shared-api-client.d.ts.map +1 -0
- package/dist/lib/shared-api-client.js +92 -0
- package/dist/lib/shared-api-client.js.map +1 -0
- package/dist/lib/wizard-engine.d.ts +128 -0
- package/dist/lib/wizard-engine.d.ts.map +1 -0
- package/dist/lib/wizard-engine.js +168 -0
- package/dist/lib/wizard-engine.js.map +1 -0
- package/package.json +85 -0
- package/templates/storefront-minimal/.env.example +10 -0
- package/templates/storefront-minimal/.github/workflows/build-template.yml +109 -0
- package/templates/storefront-minimal/app/globals.css +18 -0
- package/templates/storefront-minimal/app/layout.tsx +26 -0
- package/templates/storefront-minimal/app/page.tsx +93 -0
- package/templates/storefront-minimal/lib/graphql-client.ts +23 -0
- package/templates/storefront-minimal/next.config.ts +15 -0
- package/templates/storefront-minimal/open-next.config.ts +3 -0
- package/templates/storefront-minimal/package.json +30 -0
- package/templates/storefront-minimal/postcss.config.mjs +5 -0
- package/templates/storefront-minimal/tailwind.config.ts +14 -0
- package/templates/storefront-minimal/tsconfig.json +27 -0
- package/templates/storefront-minimal/wrangler.toml +9 -0
- package/templates/storefront-nextjs/.env.example +68 -0
- package/templates/storefront-nextjs/.github/workflows/build-template.yml +109 -0
- package/templates/storefront-nextjs/.github/workflows/deploy.yml +25 -0
- package/templates/storefront-nextjs/.github/workflows/preview.yml +22 -0
- package/templates/storefront-nextjs/README.md +520 -0
- package/templates/storefront-nextjs/app/account/orders/page.tsx +216 -0
- package/templates/storefront-nextjs/app/account/page.tsx +167 -0
- package/templates/storefront-nextjs/app/auth/login/page.tsx +135 -0
- package/templates/storefront-nextjs/app/auth/register/page.tsx +228 -0
- package/templates/storefront-nextjs/app/cart/page.tsx +263 -0
- package/templates/storefront-nextjs/app/categories/[slug]/page.tsx +200 -0
- package/templates/storefront-nextjs/app/categories/page.tsx +58 -0
- package/templates/storefront-nextjs/app/checkout/page.tsx +351 -0
- package/templates/storefront-nextjs/app/collections/[slug]/page.tsx +158 -0
- package/templates/storefront-nextjs/app/collections/page.tsx +61 -0
- package/templates/storefront-nextjs/app/globals.css +98 -0
- package/templates/storefront-nextjs/app/layout.tsx +39 -0
- package/templates/storefront-nextjs/app/page.tsx +136 -0
- package/templates/storefront-nextjs/app/products/[slug]/page.tsx +119 -0
- package/templates/storefront-nextjs/app/products/page.tsx +107 -0
- package/templates/storefront-nextjs/app/search/page.tsx +127 -0
- package/templates/storefront-nextjs/components/auth/auth-guard.tsx +94 -0
- package/templates/storefront-nextjs/components/commerce/add-to-cart-button.tsx +77 -0
- package/templates/storefront-nextjs/components/commerce/cart-icon.tsx +29 -0
- package/templates/storefront-nextjs/components/commerce/currency-selector.tsx +217 -0
- package/templates/storefront-nextjs/components/commerce/pagination.tsx +62 -0
- package/templates/storefront-nextjs/components/commerce/product-actions.tsx +135 -0
- package/templates/storefront-nextjs/components/commerce/product-filters.tsx +109 -0
- package/templates/storefront-nextjs/components/commerce/product-price.tsx +375 -0
- package/templates/storefront-nextjs/components/commerce/search-input.tsx +178 -0
- package/templates/storefront-nextjs/components/commerce/sort-select.tsx +64 -0
- package/templates/storefront-nextjs/components/commerce/variant-selector.tsx +210 -0
- package/templates/storefront-nextjs/components/layout/footer.tsx +107 -0
- package/templates/storefront-nextjs/components/layout/header.tsx +104 -0
- package/templates/storefront-nextjs/components/providers.tsx +62 -0
- package/templates/storefront-nextjs/lib/auth/routes.ts +52 -0
- package/templates/storefront-nextjs/lib/currency.tsx +140 -0
- package/templates/storefront-nextjs/lib/format.ts +159 -0
- package/templates/storefront-nextjs/lib/graphql-queries.ts +629 -0
- package/templates/storefront-nextjs/lib/hooks.ts +30 -0
- package/templates/storefront-nextjs/middleware.ts +80 -0
- package/templates/storefront-nextjs/next.config.ts +37 -0
- package/templates/storefront-nextjs/open-next.config.ts +3 -0
- package/templates/storefront-nextjs/package.dev.json +30 -0
- package/templates/storefront-nextjs/package.json +32 -0
- package/templates/storefront-nextjs/package.json.template +32 -0
- package/templates/storefront-nextjs/postcss.config.mjs +8 -0
- package/templates/storefront-nextjs/tailwind.config.ts +111 -0
- package/templates/storefront-nextjs/tsconfig.json +27 -0
- package/templates/storefront-nextjs/wrangler.toml +9 -0
- package/templates/storefront-nextjs-shadcn/.env.example +68 -0
- package/templates/storefront-nextjs-shadcn/.github/workflows/build-template.yml +109 -0
- package/templates/storefront-nextjs-shadcn/.github/workflows/deploy.yml +25 -0
- package/templates/storefront-nextjs-shadcn/.github/workflows/preview.yml +22 -0
- package/templates/storefront-nextjs-shadcn/CART_INTEGRATION.md +282 -0
- package/templates/storefront-nextjs-shadcn/CLAUDE.md +96 -0
- package/templates/storefront-nextjs-shadcn/GRAPHQL_DOCUMENT_NAMES.md +190 -0
- package/templates/storefront-nextjs-shadcn/GRAPHQL_ERROR_HANDLING.md +263 -0
- package/templates/storefront-nextjs-shadcn/GRAPHQL_FIXES_SUMMARY.md +135 -0
- package/templates/storefront-nextjs-shadcn/GRAPHQL_INTEGRATION_COMPLETE.md +142 -0
- package/templates/storefront-nextjs-shadcn/INTEGRATION_CHECKLIST.md +448 -0
- package/templates/storefront-nextjs-shadcn/PRODUCT_DETAIL_PAGE_IMPLEMENTATION.md +307 -0
- package/templates/storefront-nextjs-shadcn/README.md +195 -0
- package/templates/storefront-nextjs-shadcn/THEME_CUSTOMIZATION.md +245 -0
- package/templates/storefront-nextjs-shadcn/app/about/page.tsx +34 -0
- package/templates/storefront-nextjs-shadcn/app/account/addresses/page.tsx +215 -0
- package/templates/storefront-nextjs-shadcn/app/account/loyalty/page.tsx +484 -0
- package/templates/storefront-nextjs-shadcn/app/account/orders/[id]/page.tsx +128 -0
- package/templates/storefront-nextjs-shadcn/app/account/orders/[id]/tracking/page.tsx +206 -0
- package/templates/storefront-nextjs-shadcn/app/account/orders/page.tsx +80 -0
- package/templates/storefront-nextjs-shadcn/app/account/page.tsx +107 -0
- package/templates/storefront-nextjs-shadcn/app/account/settings/page.tsx +195 -0
- package/templates/storefront-nextjs-shadcn/app/api/auth/clear-token/route.ts +87 -0
- package/templates/storefront-nextjs-shadcn/app/api/auth/set-token/route.ts +125 -0
- package/templates/storefront-nextjs-shadcn/app/auth/forgot-password/page.tsx +131 -0
- package/templates/storefront-nextjs-shadcn/app/auth/login/page.tsx +24 -0
- package/templates/storefront-nextjs-shadcn/app/auth/register/page.tsx +20 -0
- package/templates/storefront-nextjs-shadcn/app/blog/[slug]/page.tsx +323 -0
- package/templates/storefront-nextjs-shadcn/app/blog/page.tsx +159 -0
- package/templates/storefront-nextjs-shadcn/app/brands/[slug]/page.tsx +170 -0
- package/templates/storefront-nextjs-shadcn/app/brands/page.tsx +73 -0
- package/templates/storefront-nextjs-shadcn/app/cart/page.tsx +165 -0
- package/templates/storefront-nextjs-shadcn/app/categories/[slug]/page.tsx +78 -0
- package/templates/storefront-nextjs-shadcn/app/categories/page.tsx +75 -0
- package/templates/storefront-nextjs-shadcn/app/checkout/page.tsx +1752 -0
- package/templates/storefront-nextjs-shadcn/app/checkout/success/[orderId]/page.tsx +256 -0
- package/templates/storefront-nextjs-shadcn/app/collections/[handle]/page.tsx +74 -0
- package/templates/storefront-nextjs-shadcn/app/collections/page.tsx +75 -0
- package/templates/storefront-nextjs-shadcn/app/contact/page.tsx +114 -0
- package/templates/storefront-nextjs-shadcn/app/error.tsx +90 -0
- package/templates/storefront-nextjs-shadcn/app/globals.css +125 -0
- package/templates/storefront-nextjs-shadcn/app/layout.tsx +57 -0
- package/templates/storefront-nextjs-shadcn/app/not-found.tsx +68 -0
- package/templates/storefront-nextjs-shadcn/app/page.tsx +21 -0
- package/templates/storefront-nextjs-shadcn/app/products/[slug]/page.tsx +246 -0
- package/templates/storefront-nextjs-shadcn/app/products/[slug]/product-client.tsx +343 -0
- package/templates/storefront-nextjs-shadcn/app/products/page.tsx +25 -0
- package/templates/storefront-nextjs-shadcn/app/products/products-client.tsx +192 -0
- package/templates/storefront-nextjs-shadcn/app/returns/page.tsx +77 -0
- package/templates/storefront-nextjs-shadcn/app/robots.ts +53 -0
- package/templates/storefront-nextjs-shadcn/app/search/page.tsx +16 -0
- package/templates/storefront-nextjs-shadcn/app/search/search-client.tsx +47 -0
- package/templates/storefront-nextjs-shadcn/app/shipping/page.tsx +62 -0
- package/templates/storefront-nextjs-shadcn/app/sitemap.ts +144 -0
- package/templates/storefront-nextjs-shadcn/app/wishlist/page.tsx +179 -0
- package/templates/storefront-nextjs-shadcn/codegen.ts +51 -0
- package/templates/storefront-nextjs-shadcn/components/account/address-form.tsx +348 -0
- package/templates/storefront-nextjs-shadcn/components/account/address-list.tsx +144 -0
- package/templates/storefront-nextjs-shadcn/components/account/order-details.tsx +258 -0
- package/templates/storefront-nextjs-shadcn/components/account/order-history.tsx +107 -0
- package/templates/storefront-nextjs-shadcn/components/auth/account-menu.tsx +132 -0
- package/templates/storefront-nextjs-shadcn/components/auth/login-form.tsx +188 -0
- package/templates/storefront-nextjs-shadcn/components/auth/register-form.tsx +305 -0
- package/templates/storefront-nextjs-shadcn/components/blog/blog-card.tsx +240 -0
- package/templates/storefront-nextjs-shadcn/components/blog/blog-sidebar.tsx +177 -0
- package/templates/storefront-nextjs-shadcn/components/blog/index.ts +8 -0
- package/templates/storefront-nextjs-shadcn/components/brand/brand-card.tsx +119 -0
- package/templates/storefront-nextjs-shadcn/components/brand/brand-grid.tsx +64 -0
- package/templates/storefront-nextjs-shadcn/components/cart/cart-drawer.tsx +140 -0
- package/templates/storefront-nextjs-shadcn/components/cart/cart-icon.tsx +48 -0
- package/templates/storefront-nextjs-shadcn/components/cart/cart-item.tsx +112 -0
- package/templates/storefront-nextjs-shadcn/components/cart/cart-summary.tsx +84 -0
- package/templates/storefront-nextjs-shadcn/components/cart/index.ts +17 -0
- package/templates/storefront-nextjs-shadcn/components/cart/promo-code-input.tsx +121 -0
- package/templates/storefront-nextjs-shadcn/components/cart/shipping-estimator.tsx +162 -0
- package/templates/storefront-nextjs-shadcn/components/checkout/index.ts +25 -0
- package/templates/storefront-nextjs-shadcn/components/checkout/payment-method-card.tsx +187 -0
- package/templates/storefront-nextjs-shadcn/components/checkout/payment-step.tsx +160 -0
- package/templates/storefront-nextjs-shadcn/components/checkout/tax-breakdown.tsx +154 -0
- package/templates/storefront-nextjs-shadcn/components/commerce/currency-selector.tsx +225 -0
- package/templates/storefront-nextjs-shadcn/components/commerce/pagination.tsx +62 -0
- package/templates/storefront-nextjs-shadcn/components/commerce/product-actions.tsx +158 -0
- package/templates/storefront-nextjs-shadcn/components/commerce/search-input.tsx +174 -0
- package/templates/storefront-nextjs-shadcn/components/commerce/variant-selector.tsx +210 -0
- package/templates/storefront-nextjs-shadcn/components/common/category-card.tsx +97 -0
- package/templates/storefront-nextjs-shadcn/components/common/collection-card.tsx +187 -0
- package/templates/storefront-nextjs-shadcn/components/common/price-display.tsx +151 -0
- package/templates/storefront-nextjs-shadcn/components/common/social-share.tsx +166 -0
- package/templates/storefront-nextjs-shadcn/components/discount/discount-breakdown.tsx +245 -0
- package/templates/storefront-nextjs-shadcn/components/discount/discount-code-input.tsx +246 -0
- package/templates/storefront-nextjs-shadcn/components/discount/index.ts +19 -0
- package/templates/storefront-nextjs-shadcn/components/error/error-boundary.tsx +113 -0
- package/templates/storefront-nextjs-shadcn/components/error/index.ts +7 -0
- package/templates/storefront-nextjs-shadcn/components/filters/attribute-filter.tsx +153 -0
- package/templates/storefront-nextjs-shadcn/components/filters/checkbox-group-filter.tsx +167 -0
- package/templates/storefront-nextjs-shadcn/components/filters/color-swatch-filter.tsx +176 -0
- package/templates/storefront-nextjs-shadcn/components/filters/dynamic-attribute-filters.tsx +220 -0
- package/templates/storefront-nextjs-shadcn/components/filters/index.ts +36 -0
- package/templates/storefront-nextjs-shadcn/components/filters/range-slider-filter.tsx +193 -0
- package/templates/storefront-nextjs-shadcn/components/filters/toggle-filter.tsx +132 -0
- package/templates/storefront-nextjs-shadcn/components/gift-card/gift-card-balance.tsx +321 -0
- package/templates/storefront-nextjs-shadcn/components/gift-card/gift-card-input.tsx +309 -0
- package/templates/storefront-nextjs-shadcn/components/gift-card/index.ts +24 -0
- package/templates/storefront-nextjs-shadcn/components/home/category-grid.tsx +72 -0
- package/templates/storefront-nextjs-shadcn/components/home/featured-collections.tsx +107 -0
- package/templates/storefront-nextjs-shadcn/components/home/featured-products.tsx +85 -0
- package/templates/storefront-nextjs-shadcn/components/home/hero-section.tsx +34 -0
- package/templates/storefront-nextjs-shadcn/components/home/index.ts +8 -0
- package/templates/storefront-nextjs-shadcn/components/home/newsletter-signup.tsx +108 -0
- package/templates/storefront-nextjs-shadcn/components/layout/breadcrumbs.tsx +133 -0
- package/templates/storefront-nextjs-shadcn/components/layout/currency-selector.tsx +341 -0
- package/templates/storefront-nextjs-shadcn/components/layout/footer.tsx +128 -0
- package/templates/storefront-nextjs-shadcn/components/layout/header.tsx +147 -0
- package/templates/storefront-nextjs-shadcn/components/layout/index.ts +9 -0
- package/templates/storefront-nextjs-shadcn/components/layout/mobile-menu.tsx +211 -0
- package/templates/storefront-nextjs-shadcn/components/layout/navigation.tsx +95 -0
- package/templates/storefront-nextjs-shadcn/components/layout/theme-switcher.tsx +192 -0
- package/templates/storefront-nextjs-shadcn/components/loyalty/index.ts +11 -0
- package/templates/storefront-nextjs-shadcn/components/loyalty/points-balance.tsx +93 -0
- package/templates/storefront-nextjs-shadcn/components/loyalty/points-history.tsx +177 -0
- package/templates/storefront-nextjs-shadcn/components/loyalty/referral-section.tsx +250 -0
- package/templates/storefront-nextjs-shadcn/components/loyalty/rewards-catalog.tsx +217 -0
- package/templates/storefront-nextjs-shadcn/components/loyalty/tier-badge.tsx +106 -0
- package/templates/storefront-nextjs-shadcn/components/loyalty/tier-progress.tsx +131 -0
- package/templates/storefront-nextjs-shadcn/components/order/delivery-estimate.tsx +196 -0
- package/templates/storefront-nextjs-shadcn/components/order/index.ts +11 -0
- package/templates/storefront-nextjs-shadcn/components/order/order-tracking.tsx +200 -0
- package/templates/storefront-nextjs-shadcn/components/order/shipment-card.tsx +407 -0
- package/templates/storefront-nextjs-shadcn/components/order/tracking-status.tsx +222 -0
- package/templates/storefront-nextjs-shadcn/components/order/tracking-timeline.tsx +205 -0
- package/templates/storefront-nextjs-shadcn/components/product/add-to-cart-button.tsx +161 -0
- package/templates/storefront-nextjs-shadcn/components/product/b2b-price-display.tsx +250 -0
- package/templates/storefront-nextjs-shadcn/components/product/discount-badge.tsx +196 -0
- package/templates/storefront-nextjs-shadcn/components/product/index.ts +41 -0
- package/templates/storefront-nextjs-shadcn/components/product/product-card.tsx +147 -0
- package/templates/storefront-nextjs-shadcn/components/product/product-filters.tsx +217 -0
- package/templates/storefront-nextjs-shadcn/components/product/product-gallery.tsx +143 -0
- package/templates/storefront-nextjs-shadcn/components/product/product-grid.tsx +83 -0
- package/templates/storefront-nextjs-shadcn/components/product/product-image.tsx +155 -0
- package/templates/storefront-nextjs-shadcn/components/product/product-price.tsx +158 -0
- package/templates/storefront-nextjs-shadcn/components/product/product-quantity-selector.tsx +111 -0
- package/templates/storefront-nextjs-shadcn/components/product/product-reviews.tsx +238 -0
- package/templates/storefront-nextjs-shadcn/components/product/product-sort.tsx +58 -0
- package/templates/storefront-nextjs-shadcn/components/product/product-variant-selector.tsx +169 -0
- package/templates/storefront-nextjs-shadcn/components/product/review-card.tsx +220 -0
- package/templates/storefront-nextjs-shadcn/components/product/review-form.tsx +338 -0
- package/templates/storefront-nextjs-shadcn/components/product/review-summary.tsx +143 -0
- package/templates/storefront-nextjs-shadcn/components/product/sale-countdown.tsx +166 -0
- package/templates/storefront-nextjs-shadcn/components/product/savings-display.tsx +213 -0
- package/templates/storefront-nextjs-shadcn/components/product/similar-products.tsx +57 -0
- package/templates/storefront-nextjs-shadcn/components/product/stock-indicator.tsx +91 -0
- package/templates/storefront-nextjs-shadcn/components/providers/currency-provider.tsx +103 -0
- package/templates/storefront-nextjs-shadcn/components/providers/index.ts +8 -0
- package/templates/storefront-nextjs-shadcn/components/providers/query-provider.tsx +260 -0
- package/templates/storefront-nextjs-shadcn/components/providers/theme-provider.tsx +13 -0
- package/templates/storefront-nextjs-shadcn/components/returns/index.ts +26 -0
- package/templates/storefront-nextjs-shadcn/components/returns/return-request-form.tsx +608 -0
- package/templates/storefront-nextjs-shadcn/components/returns/return-status-card.tsx +554 -0
- package/templates/storefront-nextjs-shadcn/components/search/index.ts +8 -0
- package/templates/storefront-nextjs-shadcn/components/search/search-bar.tsx +140 -0
- package/templates/storefront-nextjs-shadcn/components/search/search-results.tsx +58 -0
- package/templates/storefront-nextjs-shadcn/components/search/search-suggestions.tsx +43 -0
- package/templates/storefront-nextjs-shadcn/components/seo/index.ts +12 -0
- package/templates/storefront-nextjs-shadcn/components/seo/json-ld.tsx +56 -0
- package/templates/storefront-nextjs-shadcn/components/seo/product-json-ld.ts +167 -0
- package/templates/storefront-nextjs-shadcn/components/shipping/index.ts +16 -0
- package/templates/storefront-nextjs-shadcn/components/shipping/shipping-method-selector.tsx +337 -0
- package/templates/storefront-nextjs-shadcn/components/ui/accordion.tsx +153 -0
- package/templates/storefront-nextjs-shadcn/components/ui/alert.tsx +59 -0
- package/templates/storefront-nextjs-shadcn/components/ui/badge.tsx +34 -0
- package/templates/storefront-nextjs-shadcn/components/ui/button.tsx +51 -0
- package/templates/storefront-nextjs-shadcn/components/ui/card.tsx +77 -0
- package/templates/storefront-nextjs-shadcn/components/ui/checkbox.tsx +30 -0
- package/templates/storefront-nextjs-shadcn/components/ui/dialog.tsx +137 -0
- package/templates/storefront-nextjs-shadcn/components/ui/empty-state.tsx +207 -0
- package/templates/storefront-nextjs-shadcn/components/ui/index.ts +67 -0
- package/templates/storefront-nextjs-shadcn/components/ui/input.tsx +65 -0
- package/templates/storefront-nextjs-shadcn/components/ui/label.tsx +26 -0
- package/templates/storefront-nextjs-shadcn/components/ui/pagination.tsx +205 -0
- package/templates/storefront-nextjs-shadcn/components/ui/radio-group.tsx +44 -0
- package/templates/storefront-nextjs-shadcn/components/ui/select.tsx +160 -0
- package/templates/storefront-nextjs-shadcn/components/ui/separator.tsx +28 -0
- package/templates/storefront-nextjs-shadcn/components/ui/skeleton.tsx +20 -0
- package/templates/storefront-nextjs-shadcn/components/ui/spinner.tsx +82 -0
- package/templates/storefront-nextjs-shadcn/components/ui/tabs.tsx +119 -0
- package/templates/storefront-nextjs-shadcn/components/ui/toast.tsx +96 -0
- package/templates/storefront-nextjs-shadcn/components/wishlist/index.ts +9 -0
- package/templates/storefront-nextjs-shadcn/components/wishlist/wishlist-button.tsx +148 -0
- package/templates/storefront-nextjs-shadcn/components/wishlist/wishlist-icon.tsx +47 -0
- package/templates/storefront-nextjs-shadcn/components/wishlist/wishlist-item.tsx +165 -0
- package/templates/storefront-nextjs-shadcn/components.json +19 -0
- package/templates/storefront-nextjs-shadcn/generated/.gitkeep +2 -0
- package/templates/storefront-nextjs-shadcn/graphql/.gitkeep +31 -0
- package/templates/storefront-nextjs-shadcn/graphql/collections.example.ts +168 -0
- package/templates/storefront-nextjs-shadcn/graphql/products.example.ts +160 -0
- package/templates/storefront-nextjs-shadcn/hooks/index.ts +9 -0
- package/templates/storefront-nextjs-shadcn/hooks/use-auth.ts +310 -0
- package/templates/storefront-nextjs-shadcn/hooks/use-cart-actions.ts +286 -0
- package/templates/storefront-nextjs-shadcn/hooks/use-cart-sync.ts +110 -0
- package/templates/storefront-nextjs-shadcn/hooks/use-filter-params.test.ts +173 -0
- package/templates/storefront-nextjs-shadcn/hooks/use-filter-params.ts +298 -0
- package/templates/storefront-nextjs-shadcn/lib/auth/cookies.ts +220 -0
- package/templates/storefront-nextjs-shadcn/lib/auth/routes.ts +57 -0
- package/templates/storefront-nextjs-shadcn/lib/config.ts +46 -0
- package/templates/storefront-nextjs-shadcn/lib/currency/IMPLEMENTATION_SUMMARY.md +254 -0
- package/templates/storefront-nextjs-shadcn/lib/currency/README.md +464 -0
- package/templates/storefront-nextjs-shadcn/lib/currency/cookie-manager.test.ts +328 -0
- package/templates/storefront-nextjs-shadcn/lib/currency/cookie-manager.ts +295 -0
- package/templates/storefront-nextjs-shadcn/lib/currency/index.ts +27 -0
- package/templates/storefront-nextjs-shadcn/lib/format.test.ts +397 -0
- package/templates/storefront-nextjs-shadcn/lib/format.ts +226 -0
- package/templates/storefront-nextjs-shadcn/lib/graphql/client.ts +109 -0
- package/templates/storefront-nextjs-shadcn/lib/graphql/hooks.ts +1183 -0
- package/templates/storefront-nextjs-shadcn/lib/graphql/server.ts +267 -0
- package/templates/storefront-nextjs-shadcn/lib/hooks.ts +30 -0
- package/templates/storefront-nextjs-shadcn/lib/theme/theme-config.ts +89 -0
- package/templates/storefront-nextjs-shadcn/lib/utils.ts +6 -0
- package/templates/storefront-nextjs-shadcn/next.config.ts +47 -0
- package/templates/storefront-nextjs-shadcn/open-next.config.ts +3 -0
- package/templates/storefront-nextjs-shadcn/package.dev.json +30 -0
- package/templates/storefront-nextjs-shadcn/package.json +60 -0
- package/templates/storefront-nextjs-shadcn/package.json.template +46 -0
- package/templates/storefront-nextjs-shadcn/postcss.config.mjs +8 -0
- package/templates/storefront-nextjs-shadcn/proxy.ts +80 -0
- package/templates/storefront-nextjs-shadcn/public/icons/payment/apple-pay.svg +8 -0
- package/templates/storefront-nextjs-shadcn/public/icons/payment/bank-transfer.svg +10 -0
- package/templates/storefront-nextjs-shadcn/public/icons/payment/blik.svg +6 -0
- package/templates/storefront-nextjs-shadcn/public/icons/payment/cash-on-delivery.svg +11 -0
- package/templates/storefront-nextjs-shadcn/public/icons/payment/google-pay.svg +11 -0
- package/templates/storefront-nextjs-shadcn/public/icons/payment/mastercard.svg +7 -0
- package/templates/storefront-nextjs-shadcn/public/icons/payment/paypal.svg +7 -0
- package/templates/storefront-nextjs-shadcn/public/icons/payment/payu.svg +7 -0
- package/templates/storefront-nextjs-shadcn/public/icons/payment/przelewy24.svg +7 -0
- package/templates/storefront-nextjs-shadcn/public/icons/payment/stripe.svg +4 -0
- package/templates/storefront-nextjs-shadcn/public/icons/payment/visa.svg +5 -0
- package/templates/storefront-nextjs-shadcn/stores/auth-store.ts +66 -0
- package/templates/storefront-nextjs-shadcn/stores/cart-store.ts +56 -0
- package/templates/storefront-nextjs-shadcn/stores/checkout-store.ts +184 -0
- package/templates/storefront-nextjs-shadcn/stores/currency-store.ts +103 -0
- package/templates/storefront-nextjs-shadcn/stores/wishlist-store.ts +291 -0
- package/templates/storefront-nextjs-shadcn/tailwind.config.ts +111 -0
- package/templates/storefront-nextjs-shadcn/tsconfig.json +27 -0
- package/templates/storefront-nextjs-shadcn/wrangler.toml +9 -0
|
@@ -0,0 +1,484 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Loyalty Dashboard Page
|
|
5
|
+
*
|
|
6
|
+
* Displays customer loyalty program information including:
|
|
7
|
+
* - Current tier and points balance
|
|
8
|
+
* - Progress towards next tier
|
|
9
|
+
* - Available rewards to redeem
|
|
10
|
+
* - Points transaction history
|
|
11
|
+
* - Referral program (if enabled)
|
|
12
|
+
*
|
|
13
|
+
* Integrates with GraphQL API via commerce-sdk hooks.
|
|
14
|
+
* Requirements: R7, R8, R10.4
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { useState, useEffect } from 'react';
|
|
18
|
+
import Link from 'next/link';
|
|
19
|
+
import { ArrowLeft, Gift, Award, History, Loader2, Users, AlertCircle } from 'lucide-react';
|
|
20
|
+
import { Button } from '@/components/ui/button';
|
|
21
|
+
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
|
|
22
|
+
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
|
|
23
|
+
import { Alert, AlertDescription } from '@/components/ui/alert';
|
|
24
|
+
import { TierBadge } from '@/components/loyalty/tier-badge';
|
|
25
|
+
import { PointsBalance } from '@/components/loyalty/points-balance';
|
|
26
|
+
import { TierProgress } from '@/components/loyalty/tier-progress';
|
|
27
|
+
import { RewardsCatalog } from '@/components/loyalty/rewards-catalog';
|
|
28
|
+
import { PointsHistory } from '@/components/loyalty/points-history';
|
|
29
|
+
import { ReferralSection } from '@/components/loyalty/referral-section';
|
|
30
|
+
import { useAuth } from '@doswiftly/commerce-sdk/graphql/react';
|
|
31
|
+
|
|
32
|
+
// Type imports - these match the GraphQL schema
|
|
33
|
+
type TierType = 'BRONZE' | 'SILVER' | 'GOLD' | 'PLATINUM' | 'DIAMOND';
|
|
34
|
+
|
|
35
|
+
interface CustomBenefit {
|
|
36
|
+
name: string;
|
|
37
|
+
description?: string | null;
|
|
38
|
+
icon?: string | null;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
interface LoyaltyTier {
|
|
42
|
+
id: string;
|
|
43
|
+
name: string;
|
|
44
|
+
type?: TierType | null;
|
|
45
|
+
minPoints: number;
|
|
46
|
+
minAnnualSpend?: { amount: string; currencyCode: string } | null;
|
|
47
|
+
pointsMultiplier: number;
|
|
48
|
+
customBenefits: CustomBenefit[];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
interface PointsSummary {
|
|
52
|
+
totalPoints: number;
|
|
53
|
+
currentPoints: number;
|
|
54
|
+
pendingPoints: number;
|
|
55
|
+
redeemedPoints: number;
|
|
56
|
+
expiredPoints: number;
|
|
57
|
+
expiringPoints?: number;
|
|
58
|
+
nextExpiryDate?: string;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
interface TierProgressData {
|
|
62
|
+
currentTier: LoyaltyTier;
|
|
63
|
+
nextTier?: LoyaltyTier;
|
|
64
|
+
pointsToNextTier: number;
|
|
65
|
+
progressPercent: number;
|
|
66
|
+
spendToNextTier?: { amount: string; currencyCode: string };
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
interface LoyaltyMember {
|
|
70
|
+
id: string;
|
|
71
|
+
customerId: string;
|
|
72
|
+
points: PointsSummary;
|
|
73
|
+
tier?: LoyaltyTier;
|
|
74
|
+
tierProgress?: TierProgressData;
|
|
75
|
+
annualSpend: { amount: string; currencyCode: string };
|
|
76
|
+
lastActivityAt?: string;
|
|
77
|
+
enrolledAt: string;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
interface LoyaltyReward {
|
|
81
|
+
id: string;
|
|
82
|
+
name: string;
|
|
83
|
+
slug: string;
|
|
84
|
+
type: string;
|
|
85
|
+
pointsCost: number;
|
|
86
|
+
discountPercent?: number | null;
|
|
87
|
+
discountAmount?: { amount: string; currencyCode: string } | null;
|
|
88
|
+
description?: string | null;
|
|
89
|
+
image?: { url: string; altText?: string | null } | null;
|
|
90
|
+
available: boolean;
|
|
91
|
+
tierRequired?: LoyaltyTier | null;
|
|
92
|
+
remainingRedemptions?: number | null;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
interface LoyaltyTransaction {
|
|
96
|
+
id: string;
|
|
97
|
+
type: string;
|
|
98
|
+
points: number;
|
|
99
|
+
balanceAfter: number;
|
|
100
|
+
orderId?: string;
|
|
101
|
+
description?: string;
|
|
102
|
+
expiresAt?: string;
|
|
103
|
+
createdAt: string;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
interface LoyaltySettings {
|
|
107
|
+
enabled: boolean;
|
|
108
|
+
pointsName: string;
|
|
109
|
+
pointsPerCurrency: number;
|
|
110
|
+
pointsExpiryMonths?: number;
|
|
111
|
+
referralEnabled: boolean;
|
|
112
|
+
referralPoints?: number;
|
|
113
|
+
referralBonusPoints?: number;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
interface ReferralStats {
|
|
117
|
+
referralCode: string;
|
|
118
|
+
shareUrl: string;
|
|
119
|
+
totalReferred: number;
|
|
120
|
+
completedReferrals: number;
|
|
121
|
+
pendingReferrals: number;
|
|
122
|
+
totalPointsEarned: number;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// Real hooks from generated GraphQL
|
|
126
|
+
import {
|
|
127
|
+
useLoyaltyMember,
|
|
128
|
+
useLoyaltyRewards,
|
|
129
|
+
useLoyaltyTransactions,
|
|
130
|
+
useLoyaltySettings,
|
|
131
|
+
useReferralStats,
|
|
132
|
+
useRedeemLoyaltyReward,
|
|
133
|
+
} from '@/lib/graphql/hooks';
|
|
134
|
+
|
|
135
|
+
export default function LoyaltyPage() {
|
|
136
|
+
const [activeTab, setActiveTab] = useState('overview');
|
|
137
|
+
const { isAuthenticated } = useAuth();
|
|
138
|
+
|
|
139
|
+
// Fetch loyalty data using real GraphQL hooks
|
|
140
|
+
const { data: memberData, isLoading: memberLoading } = useLoyaltyMember();
|
|
141
|
+
const { data: rewardsData, isLoading: rewardsLoading } = useLoyaltyRewards();
|
|
142
|
+
const { data: transactionsData } = useLoyaltyTransactions({ first: 20 });
|
|
143
|
+
const { data: settingsData } = useLoyaltySettings();
|
|
144
|
+
const { data: referralData } = useReferralStats();
|
|
145
|
+
const redeemMutation = useRedeemLoyaltyReward();
|
|
146
|
+
|
|
147
|
+
// Extract data from query responses
|
|
148
|
+
const member = memberData?.loyaltyMember;
|
|
149
|
+
const rewards = rewardsData?.loyaltyRewards ?? [];
|
|
150
|
+
const transactions = transactionsData?.loyaltyTransactions?.edges?.map((e: any) => e.node) ?? [];
|
|
151
|
+
const settings = settingsData?.loyaltySettings;
|
|
152
|
+
const referralStats = referralData?.referralStats;
|
|
153
|
+
|
|
154
|
+
const isLoading = memberLoading || rewardsLoading;
|
|
155
|
+
|
|
156
|
+
// Check if program is disabled
|
|
157
|
+
const programDisabled = settings && !settings.enabled;
|
|
158
|
+
|
|
159
|
+
// Handle reward redemption
|
|
160
|
+
// Returns the resulting code (discount, product discount, or gift card)
|
|
161
|
+
const handleRedeemReward = async (rewardId: string) => {
|
|
162
|
+
try {
|
|
163
|
+
const result = await redeemMutation.mutateAsync({ input: { rewardId } });
|
|
164
|
+
const payload = result.redeemLoyaltyReward;
|
|
165
|
+
|
|
166
|
+
if (payload?.userErrors?.length) {
|
|
167
|
+
throw new Error(payload.userErrors[0]);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if (payload?.success) {
|
|
171
|
+
// Return all possible code types
|
|
172
|
+
return {
|
|
173
|
+
discountCode: payload.discountCode,
|
|
174
|
+
productDiscountCode: payload.productDiscountCode,
|
|
175
|
+
giftCardCode: payload.giftCardCode,
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
throw new Error('Nie udało się wymienić nagrody');
|
|
180
|
+
} catch (error) {
|
|
181
|
+
throw error;
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
// Show login prompt if not authenticated
|
|
186
|
+
if (!isAuthenticated) {
|
|
187
|
+
return (
|
|
188
|
+
<div className="container max-w-6xl py-8">
|
|
189
|
+
<Link href="/account">
|
|
190
|
+
<Button variant="ghost" size="sm" className="mb-4">
|
|
191
|
+
<ArrowLeft className="h-4 w-4 mr-2" />
|
|
192
|
+
Powrót do konta
|
|
193
|
+
</Button>
|
|
194
|
+
</Link>
|
|
195
|
+
|
|
196
|
+
<Card className="max-w-md mx-auto">
|
|
197
|
+
<CardHeader>
|
|
198
|
+
<CardTitle className="flex items-center gap-2">
|
|
199
|
+
<Award className="h-5 w-5" />
|
|
200
|
+
Program lojalnościowy
|
|
201
|
+
</CardTitle>
|
|
202
|
+
</CardHeader>
|
|
203
|
+
<CardContent>
|
|
204
|
+
<p className="text-muted-foreground mb-4">
|
|
205
|
+
Zaloguj się, aby zobaczyć swoje punkty i nagrody.
|
|
206
|
+
</p>
|
|
207
|
+
<Link href="/auth/login?redirect=/account/loyalty">
|
|
208
|
+
<Button className="w-full">Zaloguj się</Button>
|
|
209
|
+
</Link>
|
|
210
|
+
</CardContent>
|
|
211
|
+
</Card>
|
|
212
|
+
</div>
|
|
213
|
+
);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// Show loading state
|
|
217
|
+
if (isLoading) {
|
|
218
|
+
return (
|
|
219
|
+
<div className="container max-w-6xl py-8">
|
|
220
|
+
<div className="flex items-center justify-center min-h-[400px]">
|
|
221
|
+
<Loader2 className="h-8 w-8 animate-spin text-muted-foreground" />
|
|
222
|
+
</div>
|
|
223
|
+
</div>
|
|
224
|
+
);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// Show disabled program message
|
|
228
|
+
if (programDisabled) {
|
|
229
|
+
return (
|
|
230
|
+
<div className="container max-w-6xl py-8">
|
|
231
|
+
<Link href="/account">
|
|
232
|
+
<Button variant="ghost" size="sm" className="mb-4">
|
|
233
|
+
<ArrowLeft className="h-4 w-4 mr-2" />
|
|
234
|
+
Powrót do konta
|
|
235
|
+
</Button>
|
|
236
|
+
</Link>
|
|
237
|
+
|
|
238
|
+
<Alert>
|
|
239
|
+
<AlertCircle className="h-4 w-4" />
|
|
240
|
+
<AlertDescription>
|
|
241
|
+
Program lojalnościowy jest obecnie niedostępny. Sprawdź ponownie później.
|
|
242
|
+
</AlertDescription>
|
|
243
|
+
</Alert>
|
|
244
|
+
</div>
|
|
245
|
+
);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
// Show message if not enrolled
|
|
249
|
+
if (!member) {
|
|
250
|
+
return (
|
|
251
|
+
<div className="container max-w-6xl py-8">
|
|
252
|
+
<Link href="/account">
|
|
253
|
+
<Button variant="ghost" size="sm" className="mb-4">
|
|
254
|
+
<ArrowLeft className="h-4 w-4 mr-2" />
|
|
255
|
+
Powrót do konta
|
|
256
|
+
</Button>
|
|
257
|
+
</Link>
|
|
258
|
+
|
|
259
|
+
<Card className="max-w-md mx-auto">
|
|
260
|
+
<CardHeader>
|
|
261
|
+
<CardTitle className="flex items-center gap-2">
|
|
262
|
+
<Award className="h-5 w-5" />
|
|
263
|
+
Dołącz do programu lojalnościowego
|
|
264
|
+
</CardTitle>
|
|
265
|
+
</CardHeader>
|
|
266
|
+
<CardContent>
|
|
267
|
+
<p className="text-muted-foreground mb-4">
|
|
268
|
+
Zbieraj punkty za zakupy i wymieniaj je na nagrody! Zapisanie jest automatyczne
|
|
269
|
+
przy pierwszym zakupie.
|
|
270
|
+
</p>
|
|
271
|
+
<Link href="/products">
|
|
272
|
+
<Button className="w-full">Przeglądaj produkty</Button>
|
|
273
|
+
</Link>
|
|
274
|
+
</CardContent>
|
|
275
|
+
</Card>
|
|
276
|
+
</div>
|
|
277
|
+
);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
// Map tier data for components
|
|
281
|
+
const tierData = member.tier
|
|
282
|
+
? {
|
|
283
|
+
id: member.tier.id,
|
|
284
|
+
name: member.tier.name,
|
|
285
|
+
type: member.tier.type,
|
|
286
|
+
minPoints: member.tier.minPoints,
|
|
287
|
+
pointsMultiplier: member.tier.pointsMultiplier,
|
|
288
|
+
customBenefits: member.tier.customBenefits ?? [],
|
|
289
|
+
}
|
|
290
|
+
: null;
|
|
291
|
+
|
|
292
|
+
const progressData = member.tierProgress
|
|
293
|
+
? {
|
|
294
|
+
currentTier: {
|
|
295
|
+
id: member.tierProgress.currentTier.id,
|
|
296
|
+
name: member.tierProgress.currentTier.name,
|
|
297
|
+
type: member.tierProgress.currentTier.type,
|
|
298
|
+
minPoints: member.tierProgress.currentTier.minPoints,
|
|
299
|
+
pointsMultiplier: member.tierProgress.currentTier.pointsMultiplier,
|
|
300
|
+
customBenefits: member.tierProgress.currentTier.customBenefits ?? [],
|
|
301
|
+
},
|
|
302
|
+
nextTier: member.tierProgress.nextTier
|
|
303
|
+
? {
|
|
304
|
+
id: member.tierProgress.nextTier.id,
|
|
305
|
+
name: member.tierProgress.nextTier.name,
|
|
306
|
+
type: member.tierProgress.nextTier.type,
|
|
307
|
+
minPoints: member.tierProgress.nextTier.minPoints,
|
|
308
|
+
pointsMultiplier: member.tierProgress.nextTier.pointsMultiplier,
|
|
309
|
+
customBenefits: member.tierProgress.nextTier.customBenefits ?? [],
|
|
310
|
+
}
|
|
311
|
+
: undefined,
|
|
312
|
+
pointsToNextTier: member.tierProgress.pointsToNextTier,
|
|
313
|
+
progressPercent: member.tierProgress.progressPercent,
|
|
314
|
+
}
|
|
315
|
+
: null;
|
|
316
|
+
|
|
317
|
+
// Check if referral tab should be shown
|
|
318
|
+
const showReferralTab = settings?.referralEnabled && referralStats;
|
|
319
|
+
|
|
320
|
+
return (
|
|
321
|
+
<div className="container max-w-6xl py-8">
|
|
322
|
+
{/* Header */}
|
|
323
|
+
<div className="mb-8">
|
|
324
|
+
<Link href="/account">
|
|
325
|
+
<Button variant="ghost" size="sm" className="mb-4">
|
|
326
|
+
<ArrowLeft className="h-4 w-4 mr-2" />
|
|
327
|
+
Powrót do konta
|
|
328
|
+
</Button>
|
|
329
|
+
</Link>
|
|
330
|
+
|
|
331
|
+
<div className="flex items-center justify-between">
|
|
332
|
+
<div>
|
|
333
|
+
<h1 className="text-3xl font-bold mb-2">Program lojalnościowy</h1>
|
|
334
|
+
<p className="text-muted-foreground">
|
|
335
|
+
Zbieraj {settings?.pointsName ?? 'punkty'} i wymieniaj je na nagrody
|
|
336
|
+
</p>
|
|
337
|
+
</div>
|
|
338
|
+
{tierData && <TierBadge tier={tierData.type} name={tierData.name} size="lg" />}
|
|
339
|
+
</div>
|
|
340
|
+
</div>
|
|
341
|
+
|
|
342
|
+
{/* Tabs */}
|
|
343
|
+
<Tabs value={activeTab} onValueChange={setActiveTab}>
|
|
344
|
+
<TabsList className="mb-6">
|
|
345
|
+
<TabsTrigger value="overview" className="gap-2">
|
|
346
|
+
<Award className="h-4 w-4" />
|
|
347
|
+
Przegląd
|
|
348
|
+
</TabsTrigger>
|
|
349
|
+
<TabsTrigger value="rewards" className="gap-2">
|
|
350
|
+
<Gift className="h-4 w-4" />
|
|
351
|
+
Nagrody
|
|
352
|
+
</TabsTrigger>
|
|
353
|
+
<TabsTrigger value="history" className="gap-2">
|
|
354
|
+
<History className="h-4 w-4" />
|
|
355
|
+
Historia
|
|
356
|
+
</TabsTrigger>
|
|
357
|
+
{showReferralTab && (
|
|
358
|
+
<TabsTrigger value="referral" className="gap-2">
|
|
359
|
+
<Users className="h-4 w-4" />
|
|
360
|
+
Polecenia
|
|
361
|
+
</TabsTrigger>
|
|
362
|
+
)}
|
|
363
|
+
</TabsList>
|
|
364
|
+
|
|
365
|
+
{/* Overview Tab */}
|
|
366
|
+
<TabsContent value="overview" className="space-y-6">
|
|
367
|
+
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
|
|
368
|
+
<PointsBalance points={member.points} />
|
|
369
|
+
{progressData && <TierProgress progress={progressData} />}
|
|
370
|
+
</div>
|
|
371
|
+
|
|
372
|
+
{/* Tier Benefits */}
|
|
373
|
+
{tierData && (
|
|
374
|
+
<div className="p-6 bg-gradient-to-r from-amber-50 to-yellow-50 dark:from-amber-950/30 dark:to-yellow-950/30 rounded-lg border border-amber-200 dark:border-amber-800">
|
|
375
|
+
<h3 className="font-semibold mb-4 flex items-center gap-2">
|
|
376
|
+
<Award className="h-5 w-5 text-amber-600" />
|
|
377
|
+
Twoje korzyści na poziomie {tierData.name}
|
|
378
|
+
</h3>
|
|
379
|
+
<div className="grid grid-cols-1 sm:grid-cols-3 gap-4 text-sm">
|
|
380
|
+
<div className="p-3 bg-white/50 dark:bg-black/20 rounded-lg">
|
|
381
|
+
<div className="font-medium">Mnożnik punktów</div>
|
|
382
|
+
<div className="text-2xl font-bold text-amber-600">x{tierData.pointsMultiplier}</div>
|
|
383
|
+
</div>
|
|
384
|
+
{tierData.customBenefits.slice(0, 2).map((benefit, idx) => (
|
|
385
|
+
<div key={idx} className="p-3 bg-white/50 dark:bg-black/20 rounded-lg">
|
|
386
|
+
<div className="font-medium">{benefit.name}</div>
|
|
387
|
+
{benefit.description && (
|
|
388
|
+
<div className="text-sm text-amber-600">{benefit.description}</div>
|
|
389
|
+
)}
|
|
390
|
+
</div>
|
|
391
|
+
))}
|
|
392
|
+
</div>
|
|
393
|
+
{tierData.customBenefits.length > 2 && (
|
|
394
|
+
<div className="mt-4 flex flex-wrap gap-2">
|
|
395
|
+
{tierData.customBenefits.slice(2).map((benefit, idx) => (
|
|
396
|
+
<div key={idx} className="px-3 py-1.5 bg-white/50 dark:bg-black/20 rounded-full text-sm">
|
|
397
|
+
{benefit.name}
|
|
398
|
+
</div>
|
|
399
|
+
))}
|
|
400
|
+
</div>
|
|
401
|
+
)}
|
|
402
|
+
</div>
|
|
403
|
+
)}
|
|
404
|
+
|
|
405
|
+
{/* Quick Actions */}
|
|
406
|
+
<div className="flex flex-wrap gap-4">
|
|
407
|
+
<Button onClick={() => setActiveTab('rewards')}>
|
|
408
|
+
<Gift className="h-4 w-4 mr-2" />
|
|
409
|
+
Przeglądaj nagrody
|
|
410
|
+
</Button>
|
|
411
|
+
<Button variant="outline" onClick={() => setActiveTab('history')}>
|
|
412
|
+
<History className="h-4 w-4 mr-2" />
|
|
413
|
+
Zobacz historię
|
|
414
|
+
</Button>
|
|
415
|
+
{showReferralTab && (
|
|
416
|
+
<Button variant="outline" onClick={() => setActiveTab('referral')}>
|
|
417
|
+
<Users className="h-4 w-4 mr-2" />
|
|
418
|
+
Poleć znajomego
|
|
419
|
+
</Button>
|
|
420
|
+
)}
|
|
421
|
+
</div>
|
|
422
|
+
</TabsContent>
|
|
423
|
+
|
|
424
|
+
{/* Rewards Tab */}
|
|
425
|
+
<TabsContent value="rewards">
|
|
426
|
+
<div className="mb-6">
|
|
427
|
+
<h2 className="text-xl font-semibold mb-2">Dostępne nagrody</h2>
|
|
428
|
+
<p className="text-muted-foreground">
|
|
429
|
+
Wymień swoje {settings?.pointsName ?? 'punkty'} na atrakcyjne nagrody
|
|
430
|
+
</p>
|
|
431
|
+
</div>
|
|
432
|
+
<RewardsCatalog
|
|
433
|
+
rewards={rewards.map((r) => ({
|
|
434
|
+
...r,
|
|
435
|
+
discountAmount: r.discountAmount
|
|
436
|
+
? { amount: r.discountAmount.amount, currencyCode: r.discountAmount.currencyCode }
|
|
437
|
+
: undefined,
|
|
438
|
+
// Map tierRequired from LoyaltyTier object to just the type string
|
|
439
|
+
tierRequired: r.tierRequired?.type,
|
|
440
|
+
}))}
|
|
441
|
+
currentPoints={member.points.currentPoints}
|
|
442
|
+
currentTier={member.tier?.type}
|
|
443
|
+
onRedeem={handleRedeemReward}
|
|
444
|
+
/>
|
|
445
|
+
</TabsContent>
|
|
446
|
+
|
|
447
|
+
{/* History Tab */}
|
|
448
|
+
<TabsContent value="history">
|
|
449
|
+
<div className="mb-6">
|
|
450
|
+
<h2 className="text-xl font-semibold mb-2">Historia punktów</h2>
|
|
451
|
+
<p className="text-muted-foreground">Przegląd wszystkich transakcji punktowych</p>
|
|
452
|
+
</div>
|
|
453
|
+
<PointsHistory transactions={transactions} />
|
|
454
|
+
</TabsContent>
|
|
455
|
+
|
|
456
|
+
{/* Referral Tab */}
|
|
457
|
+
{showReferralTab && referralStats && (
|
|
458
|
+
<TabsContent value="referral">
|
|
459
|
+
<div className="mb-6">
|
|
460
|
+
<h2 className="text-xl font-semibold mb-2">Poleć znajomego</h2>
|
|
461
|
+
<p className="text-muted-foreground">
|
|
462
|
+
Zaproś znajomych i otrzymaj {settings?.referralPoints ?? 0}{' '}
|
|
463
|
+
{settings?.pointsName ?? 'punktów'} za każde polecenie
|
|
464
|
+
</p>
|
|
465
|
+
</div>
|
|
466
|
+
<ReferralSection
|
|
467
|
+
referralCode={referralStats.referralCode}
|
|
468
|
+
shareUrl={referralStats.shareUrl}
|
|
469
|
+
stats={{
|
|
470
|
+
totalReferred: referralStats.totalReferred,
|
|
471
|
+
completedReferrals: referralStats.completedReferrals,
|
|
472
|
+
pendingReferrals: referralStats.pendingReferrals,
|
|
473
|
+
totalPointsEarned: referralStats.totalPointsEarned,
|
|
474
|
+
}}
|
|
475
|
+
pointsName={settings?.pointsName ?? 'punktów'}
|
|
476
|
+
referralPoints={settings?.referralPoints ?? 0}
|
|
477
|
+
bonusPoints={settings?.referralBonusPoints ?? 0}
|
|
478
|
+
/>
|
|
479
|
+
</TabsContent>
|
|
480
|
+
)}
|
|
481
|
+
</Tabs>
|
|
482
|
+
</div>
|
|
483
|
+
);
|
|
484
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useParams } from "next/navigation";
|
|
4
|
+
import Link from "next/link";
|
|
5
|
+
import { ChevronLeft } from "lucide-react";
|
|
6
|
+
import { useQuery } from "@tanstack/react-query";
|
|
7
|
+
import { getGraphQLClient } from "@/lib/graphql/client";
|
|
8
|
+
import { useAuthStore } from "@/stores/auth-store";
|
|
9
|
+
import { CustomerDocument } from "@/generated/graphql";
|
|
10
|
+
import { Button } from "@/components/ui/button";
|
|
11
|
+
import { Breadcrumbs } from "@/components/layout/breadcrumbs";
|
|
12
|
+
import {
|
|
13
|
+
OrderDetails,
|
|
14
|
+
type OrderDetailsData,
|
|
15
|
+
} from "@/components/account/order-details";
|
|
16
|
+
|
|
17
|
+
export default function OrderDetailPage() {
|
|
18
|
+
const params = useParams();
|
|
19
|
+
const orderId = params.id as string;
|
|
20
|
+
const { accessToken } = useAuthStore();
|
|
21
|
+
const client = getGraphQLClient();
|
|
22
|
+
|
|
23
|
+
// Fetch customer orders
|
|
24
|
+
const { data: customerData, isLoading } = useQuery({
|
|
25
|
+
queryKey: ["customer", "orders", accessToken],
|
|
26
|
+
queryFn: async () => {
|
|
27
|
+
if (!accessToken) return null;
|
|
28
|
+
return client.request(CustomerDocument, { customerAccessToken: accessToken });
|
|
29
|
+
},
|
|
30
|
+
enabled: !!accessToken,
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
// Find specific order
|
|
34
|
+
const order = customerData?.customer?.orders?.edges?.find(
|
|
35
|
+
(edge) => edge.node.id === orderId
|
|
36
|
+
)?.node;
|
|
37
|
+
|
|
38
|
+
if (isLoading) {
|
|
39
|
+
return (
|
|
40
|
+
<div className="container mx-auto px-4 py-8">
|
|
41
|
+
<div className="animate-pulse space-y-4">
|
|
42
|
+
<div className="h-8 bg-muted rounded w-1/4"></div>
|
|
43
|
+
<div className="h-64 bg-muted rounded"></div>
|
|
44
|
+
</div>
|
|
45
|
+
</div>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (!order) {
|
|
50
|
+
return (
|
|
51
|
+
<div className="container mx-auto px-4 py-8">
|
|
52
|
+
<div className="text-center">
|
|
53
|
+
<h1 className="text-2xl font-bold">Order not found</h1>
|
|
54
|
+
<Link href="/account/orders">
|
|
55
|
+
<Button className="mt-4">Back to Orders</Button>
|
|
56
|
+
</Link>
|
|
57
|
+
</div>
|
|
58
|
+
</div>
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Transform order data to match OrderDetailsData interface
|
|
63
|
+
const orderDetails: OrderDetailsData = {
|
|
64
|
+
id: order.id,
|
|
65
|
+
orderNumber: order.orderNumber?.toString() || order.id,
|
|
66
|
+
date: new Date(order.processedAt).toLocaleDateString(),
|
|
67
|
+
status: order.fulfillmentStatus?.toLowerCase() || "pending",
|
|
68
|
+
items: order.lineItems.edges.map((edge) => ({
|
|
69
|
+
id: edge.node.variant?.id || edge.node.title,
|
|
70
|
+
title: edge.node.title,
|
|
71
|
+
variantTitle: edge.node.variant?.title || "",
|
|
72
|
+
quantity: edge.node.quantity,
|
|
73
|
+
price: edge.node.originalTotalPrice.amount,
|
|
74
|
+
currency: edge.node.originalTotalPrice.currencyCode,
|
|
75
|
+
imageUrl: edge.node.variant?.image?.url || "",
|
|
76
|
+
})),
|
|
77
|
+
subtotal: order.subtotalPrice?.amount || "0",
|
|
78
|
+
shipping: order.totalShippingPrice?.amount || "0",
|
|
79
|
+
tax: order.totalTax?.amount || "0",
|
|
80
|
+
total: order.totalPrice.amount,
|
|
81
|
+
currency: order.totalPrice.currencyCode,
|
|
82
|
+
shippingAddress: order.shippingAddress
|
|
83
|
+
? {
|
|
84
|
+
firstName: order.shippingAddress.firstName || "",
|
|
85
|
+
lastName: order.shippingAddress.lastName || "",
|
|
86
|
+
address1: order.shippingAddress.address1 || "",
|
|
87
|
+
address2: order.shippingAddress.address2 || "",
|
|
88
|
+
city: order.shippingAddress.city || "",
|
|
89
|
+
province: order.shippingAddress.province || "",
|
|
90
|
+
zip: order.shippingAddress.zip || "",
|
|
91
|
+
country: order.shippingAddress.country || "",
|
|
92
|
+
phone: order.shippingAddress.phone || "",
|
|
93
|
+
}
|
|
94
|
+
: undefined,
|
|
95
|
+
billingAddress: order.billingAddress
|
|
96
|
+
? {
|
|
97
|
+
firstName: order.billingAddress.firstName || "",
|
|
98
|
+
lastName: order.billingAddress.lastName || "",
|
|
99
|
+
address1: order.billingAddress.address1 || "",
|
|
100
|
+
address2: order.billingAddress.address2 || "",
|
|
101
|
+
city: order.billingAddress.city || "",
|
|
102
|
+
province: order.billingAddress.province || "",
|
|
103
|
+
zip: order.billingAddress.zip || "",
|
|
104
|
+
country: order.billingAddress.country || "",
|
|
105
|
+
phone: order.billingAddress.phone || "",
|
|
106
|
+
}
|
|
107
|
+
: undefined,
|
|
108
|
+
trackingNumber: order.successfulFulfillments?.[0]?.trackingInfo?.[0]?.number,
|
|
109
|
+
estimatedDelivery: order.successfulFulfillments?.[0]?.estimatedDeliveryAt,
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
return (
|
|
113
|
+
<div className="container mx-auto px-4 py-8">
|
|
114
|
+
<Breadcrumbs className="mb-6" />
|
|
115
|
+
|
|
116
|
+
<div className="mb-6">
|
|
117
|
+
<Button variant="ghost" asChild>
|
|
118
|
+
<Link href="/account/orders">
|
|
119
|
+
<ChevronLeft className="mr-2 h-4 w-4" />
|
|
120
|
+
Back to Orders
|
|
121
|
+
</Link>
|
|
122
|
+
</Button>
|
|
123
|
+
</div>
|
|
124
|
+
|
|
125
|
+
<OrderDetails order={orderDetails} />
|
|
126
|
+
</div>
|
|
127
|
+
);
|
|
128
|
+
}
|