@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,554 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
Package,
|
|
5
|
+
CheckCircle,
|
|
6
|
+
Clock,
|
|
7
|
+
Truck,
|
|
8
|
+
AlertCircle,
|
|
9
|
+
XCircle,
|
|
10
|
+
RefreshCw,
|
|
11
|
+
CreditCard,
|
|
12
|
+
Gift,
|
|
13
|
+
ExternalLink,
|
|
14
|
+
FileText,
|
|
15
|
+
} from "lucide-react";
|
|
16
|
+
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
|
17
|
+
import { Badge } from "@/components/ui/badge";
|
|
18
|
+
import { Button } from "@/components/ui/button";
|
|
19
|
+
import { Separator } from "@/components/ui/separator";
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Return status enum matching backend
|
|
23
|
+
*/
|
|
24
|
+
export type ReturnStatus =
|
|
25
|
+
| "DRAFT"
|
|
26
|
+
| "REQUESTED"
|
|
27
|
+
| "APPROVED"
|
|
28
|
+
| "LABEL_GENERATED"
|
|
29
|
+
| "IN_TRANSIT"
|
|
30
|
+
| "RECEIVED"
|
|
31
|
+
| "INSPECTING"
|
|
32
|
+
| "REFUND_PENDING"
|
|
33
|
+
| "REFUNDED"
|
|
34
|
+
| "COMPLETED"
|
|
35
|
+
| "EXCHANGED"
|
|
36
|
+
| "REPLACED"
|
|
37
|
+
| "REJECTED"
|
|
38
|
+
| "CANCELLED"
|
|
39
|
+
| "EXPIRED"
|
|
40
|
+
| "FAILED";
|
|
41
|
+
|
|
42
|
+
export type ReturnReason =
|
|
43
|
+
| "DEFECTIVE"
|
|
44
|
+
| "NOT_AS_DESCRIBED"
|
|
45
|
+
| "WRONG_ITEM"
|
|
46
|
+
| "CHANGED_MIND"
|
|
47
|
+
| "BETTER_PRICE"
|
|
48
|
+
| "DAMAGED_SHIPPING"
|
|
49
|
+
| "OTHER";
|
|
50
|
+
|
|
51
|
+
export type CompensationType = "REFUND" | "STORE_CREDIT";
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Return item data
|
|
55
|
+
*/
|
|
56
|
+
export interface ReturnItemData {
|
|
57
|
+
id: string;
|
|
58
|
+
productTitle: string;
|
|
59
|
+
variantTitle?: string;
|
|
60
|
+
sku?: string;
|
|
61
|
+
imageUrl?: string;
|
|
62
|
+
quantity: number;
|
|
63
|
+
reason: ReturnReason;
|
|
64
|
+
condition?: string;
|
|
65
|
+
unitPrice?: {
|
|
66
|
+
amount: string;
|
|
67
|
+
currencyCode: string;
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Return data from GraphQL
|
|
73
|
+
*/
|
|
74
|
+
export interface ReturnData {
|
|
75
|
+
id: string;
|
|
76
|
+
returnNumber: string;
|
|
77
|
+
orderId: string;
|
|
78
|
+
orderNumber: string;
|
|
79
|
+
status: ReturnStatus;
|
|
80
|
+
reason: ReturnReason;
|
|
81
|
+
customerNote?: string;
|
|
82
|
+
compensationType?: CompensationType;
|
|
83
|
+
items: ReturnItemData[];
|
|
84
|
+
refundAmount?: {
|
|
85
|
+
amount: string;
|
|
86
|
+
currencyCode: string;
|
|
87
|
+
};
|
|
88
|
+
shippingLabel?: {
|
|
89
|
+
url: string;
|
|
90
|
+
carrier?: string;
|
|
91
|
+
trackingNumber?: string;
|
|
92
|
+
expiresAt?: string;
|
|
93
|
+
};
|
|
94
|
+
requestedAt?: string;
|
|
95
|
+
approvedAt?: string;
|
|
96
|
+
receivedAt?: string;
|
|
97
|
+
refundedAt?: string;
|
|
98
|
+
completedAt?: string;
|
|
99
|
+
createdAt: string;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export interface ReturnStatusCardProps {
|
|
103
|
+
returnData: ReturnData;
|
|
104
|
+
onCancel?: () => void;
|
|
105
|
+
className?: string;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Get status configuration for display
|
|
110
|
+
*/
|
|
111
|
+
function getStatusConfig(status: ReturnStatus) {
|
|
112
|
+
switch (status) {
|
|
113
|
+
case "DRAFT":
|
|
114
|
+
return {
|
|
115
|
+
icon: FileText,
|
|
116
|
+
label: "Draft",
|
|
117
|
+
description: "Return request is being prepared",
|
|
118
|
+
color: "text-gray-600",
|
|
119
|
+
bgColor: "bg-gray-100 dark:bg-gray-900/30",
|
|
120
|
+
variant: "secondary" as const,
|
|
121
|
+
};
|
|
122
|
+
case "REQUESTED":
|
|
123
|
+
return {
|
|
124
|
+
icon: Clock,
|
|
125
|
+
label: "Requested",
|
|
126
|
+
description: "Waiting for approval",
|
|
127
|
+
color: "text-yellow-600",
|
|
128
|
+
bgColor: "bg-yellow-100 dark:bg-yellow-900/30",
|
|
129
|
+
variant: "warning" as const,
|
|
130
|
+
};
|
|
131
|
+
case "APPROVED":
|
|
132
|
+
return {
|
|
133
|
+
icon: CheckCircle,
|
|
134
|
+
label: "Approved",
|
|
135
|
+
description: "Your return has been approved",
|
|
136
|
+
color: "text-green-600",
|
|
137
|
+
bgColor: "bg-green-100 dark:bg-green-900/30",
|
|
138
|
+
variant: "success" as const,
|
|
139
|
+
};
|
|
140
|
+
case "LABEL_GENERATED":
|
|
141
|
+
return {
|
|
142
|
+
icon: Package,
|
|
143
|
+
label: "Label Ready",
|
|
144
|
+
description: "Download your return shipping label",
|
|
145
|
+
color: "text-blue-600",
|
|
146
|
+
bgColor: "bg-blue-100 dark:bg-blue-900/30",
|
|
147
|
+
variant: "default" as const,
|
|
148
|
+
};
|
|
149
|
+
case "IN_TRANSIT":
|
|
150
|
+
return {
|
|
151
|
+
icon: Truck,
|
|
152
|
+
label: "In Transit",
|
|
153
|
+
description: "Your return is on its way to us",
|
|
154
|
+
color: "text-blue-600",
|
|
155
|
+
bgColor: "bg-blue-100 dark:bg-blue-900/30",
|
|
156
|
+
variant: "default" as const,
|
|
157
|
+
};
|
|
158
|
+
case "RECEIVED":
|
|
159
|
+
return {
|
|
160
|
+
icon: Package,
|
|
161
|
+
label: "Received",
|
|
162
|
+
description: "We have received your return",
|
|
163
|
+
color: "text-blue-600",
|
|
164
|
+
bgColor: "bg-blue-100 dark:bg-blue-900/30",
|
|
165
|
+
variant: "default" as const,
|
|
166
|
+
};
|
|
167
|
+
case "INSPECTING":
|
|
168
|
+
return {
|
|
169
|
+
icon: RefreshCw,
|
|
170
|
+
label: "Inspecting",
|
|
171
|
+
description: "Your items are being inspected",
|
|
172
|
+
color: "text-blue-600",
|
|
173
|
+
bgColor: "bg-blue-100 dark:bg-blue-900/30",
|
|
174
|
+
variant: "default" as const,
|
|
175
|
+
};
|
|
176
|
+
case "REFUND_PENDING":
|
|
177
|
+
return {
|
|
178
|
+
icon: CreditCard,
|
|
179
|
+
label: "Refund Pending",
|
|
180
|
+
description: "Your refund is being processed",
|
|
181
|
+
color: "text-yellow-600",
|
|
182
|
+
bgColor: "bg-yellow-100 dark:bg-yellow-900/30",
|
|
183
|
+
variant: "warning" as const,
|
|
184
|
+
};
|
|
185
|
+
case "REFUNDED":
|
|
186
|
+
return {
|
|
187
|
+
icon: CreditCard,
|
|
188
|
+
label: "Refunded",
|
|
189
|
+
description: "Your refund has been issued",
|
|
190
|
+
color: "text-green-600",
|
|
191
|
+
bgColor: "bg-green-100 dark:bg-green-900/30",
|
|
192
|
+
variant: "success" as const,
|
|
193
|
+
};
|
|
194
|
+
case "COMPLETED":
|
|
195
|
+
return {
|
|
196
|
+
icon: CheckCircle,
|
|
197
|
+
label: "Completed",
|
|
198
|
+
description: "Return process completed",
|
|
199
|
+
color: "text-green-600",
|
|
200
|
+
bgColor: "bg-green-100 dark:bg-green-900/30",
|
|
201
|
+
variant: "success" as const,
|
|
202
|
+
};
|
|
203
|
+
case "EXCHANGED":
|
|
204
|
+
return {
|
|
205
|
+
icon: RefreshCw,
|
|
206
|
+
label: "Exchanged",
|
|
207
|
+
description: "Items have been exchanged",
|
|
208
|
+
color: "text-green-600",
|
|
209
|
+
bgColor: "bg-green-100 dark:bg-green-900/30",
|
|
210
|
+
variant: "success" as const,
|
|
211
|
+
};
|
|
212
|
+
case "REPLACED":
|
|
213
|
+
return {
|
|
214
|
+
icon: Package,
|
|
215
|
+
label: "Replaced",
|
|
216
|
+
description: "Replacement items shipped",
|
|
217
|
+
color: "text-green-600",
|
|
218
|
+
bgColor: "bg-green-100 dark:bg-green-900/30",
|
|
219
|
+
variant: "success" as const,
|
|
220
|
+
};
|
|
221
|
+
case "REJECTED":
|
|
222
|
+
return {
|
|
223
|
+
icon: XCircle,
|
|
224
|
+
label: "Rejected",
|
|
225
|
+
description: "Return request was rejected",
|
|
226
|
+
color: "text-red-600",
|
|
227
|
+
bgColor: "bg-red-100 dark:bg-red-900/30",
|
|
228
|
+
variant: "secondary" as const,
|
|
229
|
+
};
|
|
230
|
+
case "CANCELLED":
|
|
231
|
+
return {
|
|
232
|
+
icon: XCircle,
|
|
233
|
+
label: "Cancelled",
|
|
234
|
+
description: "Return request was cancelled",
|
|
235
|
+
color: "text-gray-600",
|
|
236
|
+
bgColor: "bg-gray-100 dark:bg-gray-900/30",
|
|
237
|
+
variant: "secondary" as const,
|
|
238
|
+
};
|
|
239
|
+
case "EXPIRED":
|
|
240
|
+
return {
|
|
241
|
+
icon: AlertCircle,
|
|
242
|
+
label: "Expired",
|
|
243
|
+
description: "Return request has expired",
|
|
244
|
+
color: "text-red-600",
|
|
245
|
+
bgColor: "bg-red-100 dark:bg-red-900/30",
|
|
246
|
+
variant: "secondary" as const,
|
|
247
|
+
};
|
|
248
|
+
case "FAILED":
|
|
249
|
+
return {
|
|
250
|
+
icon: AlertCircle,
|
|
251
|
+
label: "Failed",
|
|
252
|
+
description: "Return process failed",
|
|
253
|
+
color: "text-red-600",
|
|
254
|
+
bgColor: "bg-red-100 dark:bg-red-900/30",
|
|
255
|
+
variant: "secondary" as const,
|
|
256
|
+
};
|
|
257
|
+
default:
|
|
258
|
+
return {
|
|
259
|
+
icon: Package,
|
|
260
|
+
label: "Unknown",
|
|
261
|
+
description: "Status unknown",
|
|
262
|
+
color: "text-gray-600",
|
|
263
|
+
bgColor: "bg-gray-100 dark:bg-gray-900/30",
|
|
264
|
+
variant: "secondary" as const,
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* Get reason label
|
|
271
|
+
*/
|
|
272
|
+
function getReasonLabel(reason: ReturnReason): string {
|
|
273
|
+
const labels: Record<ReturnReason, string> = {
|
|
274
|
+
DEFECTIVE: "Defective Product",
|
|
275
|
+
NOT_AS_DESCRIBED: "Not as Described",
|
|
276
|
+
WRONG_ITEM: "Wrong Item",
|
|
277
|
+
CHANGED_MIND: "Changed Mind",
|
|
278
|
+
BETTER_PRICE: "Better Price Found",
|
|
279
|
+
DAMAGED_SHIPPING: "Damaged in Shipping",
|
|
280
|
+
OTHER: "Other",
|
|
281
|
+
};
|
|
282
|
+
return labels[reason] || reason;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Format date for display
|
|
287
|
+
*/
|
|
288
|
+
function formatDate(dateString: string): string {
|
|
289
|
+
return new Date(dateString).toLocaleDateString("pl-PL", {
|
|
290
|
+
year: "numeric",
|
|
291
|
+
month: "long",
|
|
292
|
+
day: "numeric",
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* Check if return can be cancelled
|
|
298
|
+
*/
|
|
299
|
+
function canCancel(status: ReturnStatus): boolean {
|
|
300
|
+
return ["DRAFT", "REQUESTED", "APPROVED"].includes(status);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* ReturnStatusCard - Display return status and details
|
|
305
|
+
*
|
|
306
|
+
* Shows:
|
|
307
|
+
* - Current return status with icon and badge
|
|
308
|
+
* - Return number and order reference
|
|
309
|
+
* - Items being returned
|
|
310
|
+
* - Shipping label download (if available)
|
|
311
|
+
* - Refund amount (if processed)
|
|
312
|
+
* - Timeline of status changes
|
|
313
|
+
*
|
|
314
|
+
* Requirements: R30.4, R30.5, R30.6, R30.7
|
|
315
|
+
*/
|
|
316
|
+
export function ReturnStatusCard({
|
|
317
|
+
returnData,
|
|
318
|
+
onCancel,
|
|
319
|
+
className = "",
|
|
320
|
+
}: ReturnStatusCardProps) {
|
|
321
|
+
const config = getStatusConfig(returnData.status);
|
|
322
|
+
const Icon = config.icon;
|
|
323
|
+
|
|
324
|
+
return (
|
|
325
|
+
<Card className={className}>
|
|
326
|
+
<CardHeader>
|
|
327
|
+
<div className="flex items-start justify-between">
|
|
328
|
+
<div className="flex items-center gap-3">
|
|
329
|
+
{/* Status Icon */}
|
|
330
|
+
<div className={`rounded-full p-2 ${config.bgColor}`}>
|
|
331
|
+
<Icon className={`h-5 w-5 ${config.color}`} />
|
|
332
|
+
</div>
|
|
333
|
+
|
|
334
|
+
<div>
|
|
335
|
+
<CardTitle className="text-lg flex items-center gap-2">
|
|
336
|
+
Return #{returnData.returnNumber}
|
|
337
|
+
<Badge variant={config.variant}>{config.label}</Badge>
|
|
338
|
+
</CardTitle>
|
|
339
|
+
<p className="text-sm text-muted-foreground mt-1">
|
|
340
|
+
{config.description}
|
|
341
|
+
</p>
|
|
342
|
+
</div>
|
|
343
|
+
</div>
|
|
344
|
+
|
|
345
|
+
{/* Cancel button (if applicable) */}
|
|
346
|
+
{canCancel(returnData.status) && onCancel && (
|
|
347
|
+
<Button variant="outline" size="sm" onClick={onCancel}>
|
|
348
|
+
Cancel Return
|
|
349
|
+
</Button>
|
|
350
|
+
)}
|
|
351
|
+
</div>
|
|
352
|
+
</CardHeader>
|
|
353
|
+
|
|
354
|
+
<CardContent className="space-y-6">
|
|
355
|
+
{/* Order Reference */}
|
|
356
|
+
<div className="flex items-center gap-4 text-sm">
|
|
357
|
+
<div>
|
|
358
|
+
<span className="text-muted-foreground">Order:</span>{" "}
|
|
359
|
+
<span className="font-medium">#{returnData.orderNumber}</span>
|
|
360
|
+
</div>
|
|
361
|
+
<div>
|
|
362
|
+
<span className="text-muted-foreground">Reason:</span>{" "}
|
|
363
|
+
<span className="font-medium">
|
|
364
|
+
{getReasonLabel(returnData.reason)}
|
|
365
|
+
</span>
|
|
366
|
+
</div>
|
|
367
|
+
{returnData.compensationType && (
|
|
368
|
+
<div>
|
|
369
|
+
<span className="text-muted-foreground">Compensation:</span>{" "}
|
|
370
|
+
<span className="font-medium">
|
|
371
|
+
{returnData.compensationType === "REFUND"
|
|
372
|
+
? "Refund"
|
|
373
|
+
: "Store Credit"}
|
|
374
|
+
</span>
|
|
375
|
+
</div>
|
|
376
|
+
)}
|
|
377
|
+
</div>
|
|
378
|
+
|
|
379
|
+
{/* Customer Note */}
|
|
380
|
+
{returnData.customerNote && (
|
|
381
|
+
<div className="bg-muted/50 rounded-lg p-3">
|
|
382
|
+
<p className="text-sm text-muted-foreground">Your note:</p>
|
|
383
|
+
<p className="text-sm mt-1">{returnData.customerNote}</p>
|
|
384
|
+
</div>
|
|
385
|
+
)}
|
|
386
|
+
|
|
387
|
+
{/* Items */}
|
|
388
|
+
<div>
|
|
389
|
+
<h4 className="font-medium mb-3">Items to Return</h4>
|
|
390
|
+
<div className="space-y-3">
|
|
391
|
+
{returnData.items.map((item) => (
|
|
392
|
+
<div
|
|
393
|
+
key={item.id}
|
|
394
|
+
className="flex items-center gap-4 p-3 border border-border rounded-lg"
|
|
395
|
+
>
|
|
396
|
+
{item.imageUrl && (
|
|
397
|
+
<img
|
|
398
|
+
src={item.imageUrl}
|
|
399
|
+
alt={item.productTitle}
|
|
400
|
+
className="w-12 h-12 object-cover rounded"
|
|
401
|
+
/>
|
|
402
|
+
)}
|
|
403
|
+
<div className="flex-1">
|
|
404
|
+
<p className="font-medium">{item.productTitle}</p>
|
|
405
|
+
{item.variantTitle && (
|
|
406
|
+
<p className="text-sm text-muted-foreground">
|
|
407
|
+
{item.variantTitle}
|
|
408
|
+
</p>
|
|
409
|
+
)}
|
|
410
|
+
<p className="text-sm text-muted-foreground">
|
|
411
|
+
Qty: {item.quantity}
|
|
412
|
+
{item.condition && ` | Condition: ${item.condition}`}
|
|
413
|
+
</p>
|
|
414
|
+
</div>
|
|
415
|
+
{item.unitPrice && (
|
|
416
|
+
<p className="font-medium">
|
|
417
|
+
{item.unitPrice.amount} {item.unitPrice.currencyCode}
|
|
418
|
+
</p>
|
|
419
|
+
)}
|
|
420
|
+
</div>
|
|
421
|
+
))}
|
|
422
|
+
</div>
|
|
423
|
+
</div>
|
|
424
|
+
|
|
425
|
+
{/* Shipping Label */}
|
|
426
|
+
{returnData.shippingLabel && (
|
|
427
|
+
<div className="bg-blue-50 dark:bg-blue-900/20 rounded-lg p-4">
|
|
428
|
+
<div className="flex items-center justify-between">
|
|
429
|
+
<div>
|
|
430
|
+
<h4 className="font-medium flex items-center gap-2">
|
|
431
|
+
<Package className="h-4 w-4" />
|
|
432
|
+
Return Shipping Label
|
|
433
|
+
</h4>
|
|
434
|
+
{returnData.shippingLabel.carrier && (
|
|
435
|
+
<p className="text-sm text-muted-foreground mt-1">
|
|
436
|
+
Carrier: {returnData.shippingLabel.carrier}
|
|
437
|
+
{returnData.shippingLabel.trackingNumber &&
|
|
438
|
+
` | Tracking: ${returnData.shippingLabel.trackingNumber}`}
|
|
439
|
+
</p>
|
|
440
|
+
)}
|
|
441
|
+
{returnData.shippingLabel.expiresAt && (
|
|
442
|
+
<p className="text-sm text-muted-foreground">
|
|
443
|
+
Expires: {formatDate(returnData.shippingLabel.expiresAt)}
|
|
444
|
+
</p>
|
|
445
|
+
)}
|
|
446
|
+
</div>
|
|
447
|
+
<Button
|
|
448
|
+
variant="outline"
|
|
449
|
+
size="sm"
|
|
450
|
+
onClick={() =>
|
|
451
|
+
window.open(returnData.shippingLabel!.url, "_blank")
|
|
452
|
+
}
|
|
453
|
+
>
|
|
454
|
+
<ExternalLink className="mr-2 h-4 w-4" />
|
|
455
|
+
Download Label
|
|
456
|
+
</Button>
|
|
457
|
+
</div>
|
|
458
|
+
</div>
|
|
459
|
+
)}
|
|
460
|
+
|
|
461
|
+
{/* Refund Amount */}
|
|
462
|
+
{returnData.refundAmount && (
|
|
463
|
+
<div className="bg-green-50 dark:bg-green-900/20 rounded-lg p-4">
|
|
464
|
+
<div className="flex items-center justify-between">
|
|
465
|
+
<div>
|
|
466
|
+
<h4 className="font-medium flex items-center gap-2">
|
|
467
|
+
{returnData.compensationType === "STORE_CREDIT" ? (
|
|
468
|
+
<Gift className="h-4 w-4" />
|
|
469
|
+
) : (
|
|
470
|
+
<CreditCard className="h-4 w-4" />
|
|
471
|
+
)}
|
|
472
|
+
{returnData.compensationType === "STORE_CREDIT"
|
|
473
|
+
? "Store Credit Issued"
|
|
474
|
+
: "Refund Amount"}
|
|
475
|
+
</h4>
|
|
476
|
+
</div>
|
|
477
|
+
<p className="text-xl font-bold">
|
|
478
|
+
{returnData.refundAmount.amount}{" "}
|
|
479
|
+
{returnData.refundAmount.currencyCode}
|
|
480
|
+
</p>
|
|
481
|
+
</div>
|
|
482
|
+
</div>
|
|
483
|
+
)}
|
|
484
|
+
|
|
485
|
+
<Separator />
|
|
486
|
+
|
|
487
|
+
{/* Timeline */}
|
|
488
|
+
<div>
|
|
489
|
+
<h4 className="font-medium mb-3">Timeline</h4>
|
|
490
|
+
<div className="space-y-2 text-sm">
|
|
491
|
+
{returnData.completedAt && (
|
|
492
|
+
<div className="flex justify-between">
|
|
493
|
+
<span className="text-muted-foreground">Completed</span>
|
|
494
|
+
<span>{formatDate(returnData.completedAt)}</span>
|
|
495
|
+
</div>
|
|
496
|
+
)}
|
|
497
|
+
{returnData.refundedAt && (
|
|
498
|
+
<div className="flex justify-between">
|
|
499
|
+
<span className="text-muted-foreground">Refunded</span>
|
|
500
|
+
<span>{formatDate(returnData.refundedAt)}</span>
|
|
501
|
+
</div>
|
|
502
|
+
)}
|
|
503
|
+
{returnData.receivedAt && (
|
|
504
|
+
<div className="flex justify-between">
|
|
505
|
+
<span className="text-muted-foreground">Received</span>
|
|
506
|
+
<span>{formatDate(returnData.receivedAt)}</span>
|
|
507
|
+
</div>
|
|
508
|
+
)}
|
|
509
|
+
{returnData.approvedAt && (
|
|
510
|
+
<div className="flex justify-between">
|
|
511
|
+
<span className="text-muted-foreground">Approved</span>
|
|
512
|
+
<span>{formatDate(returnData.approvedAt)}</span>
|
|
513
|
+
</div>
|
|
514
|
+
)}
|
|
515
|
+
{returnData.requestedAt && (
|
|
516
|
+
<div className="flex justify-between">
|
|
517
|
+
<span className="text-muted-foreground">Requested</span>
|
|
518
|
+
<span>{formatDate(returnData.requestedAt)}</span>
|
|
519
|
+
</div>
|
|
520
|
+
)}
|
|
521
|
+
<div className="flex justify-between">
|
|
522
|
+
<span className="text-muted-foreground">Created</span>
|
|
523
|
+
<span>{formatDate(returnData.createdAt)}</span>
|
|
524
|
+
</div>
|
|
525
|
+
</div>
|
|
526
|
+
</div>
|
|
527
|
+
</CardContent>
|
|
528
|
+
</Card>
|
|
529
|
+
);
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
/**
|
|
533
|
+
* ReturnStatusCardSkeleton - Loading state
|
|
534
|
+
*/
|
|
535
|
+
export function ReturnStatusCardSkeleton() {
|
|
536
|
+
return (
|
|
537
|
+
<Card>
|
|
538
|
+
<CardHeader>
|
|
539
|
+
<div className="flex items-start gap-3">
|
|
540
|
+
<div className="h-10 w-10 rounded-full bg-muted animate-pulse" />
|
|
541
|
+
<div className="space-y-2">
|
|
542
|
+
<div className="h-5 w-48 bg-muted animate-pulse rounded" />
|
|
543
|
+
<div className="h-4 w-32 bg-muted animate-pulse rounded" />
|
|
544
|
+
</div>
|
|
545
|
+
</div>
|
|
546
|
+
</CardHeader>
|
|
547
|
+
<CardContent className="space-y-4">
|
|
548
|
+
<div className="h-4 w-full bg-muted animate-pulse rounded" />
|
|
549
|
+
<div className="h-20 w-full bg-muted animate-pulse rounded" />
|
|
550
|
+
<div className="h-4 w-3/4 bg-muted animate-pulse rounded" />
|
|
551
|
+
</CardContent>
|
|
552
|
+
</Card>
|
|
553
|
+
);
|
|
554
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { SearchBar } from './search-bar';
|
|
2
|
+
export type { SearchBarProps } from './search-bar';
|
|
3
|
+
|
|
4
|
+
export { SearchSuggestions } from './search-suggestions';
|
|
5
|
+
export type { SearchSuggestionsProps } from './search-suggestions';
|
|
6
|
+
|
|
7
|
+
export { SearchResults } from './search-results';
|
|
8
|
+
export type { SearchResultsProps } from './search-results';
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useState, useEffect, useRef, useCallback } from "react";
|
|
4
|
+
import { useRouter } from "next/navigation";
|
|
5
|
+
import { Search, X } from "lucide-react";
|
|
6
|
+
import { Input } from "@/components/ui/input";
|
|
7
|
+
import { SearchSuggestions } from "./search-suggestions";
|
|
8
|
+
import { cn } from "@/lib/utils";
|
|
9
|
+
|
|
10
|
+
export interface SearchBarProps {
|
|
11
|
+
defaultValue?: string;
|
|
12
|
+
placeholder?: string;
|
|
13
|
+
className?: string;
|
|
14
|
+
showSuggestions?: boolean;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* SearchBar - Search input with autocomplete
|
|
19
|
+
*/
|
|
20
|
+
export function SearchBar({
|
|
21
|
+
defaultValue = "",
|
|
22
|
+
placeholder = "Search products...",
|
|
23
|
+
className,
|
|
24
|
+
showSuggestions = true,
|
|
25
|
+
}: SearchBarProps) {
|
|
26
|
+
const router = useRouter();
|
|
27
|
+
const [query, setQuery] = useState(defaultValue);
|
|
28
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
29
|
+
const [suggestions, setSuggestions] = useState<string[]>([]);
|
|
30
|
+
const inputRef = useRef<HTMLInputElement>(null);
|
|
31
|
+
const blurTimeoutRef = useRef<NodeJS.Timeout | null>(null);
|
|
32
|
+
const debounceTimeoutRef = useRef<NodeJS.Timeout | null>(null);
|
|
33
|
+
|
|
34
|
+
// Cleanup timeouts on unmount
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
return () => {
|
|
37
|
+
if (blurTimeoutRef.current) clearTimeout(blurTimeoutRef.current);
|
|
38
|
+
if (debounceTimeoutRef.current) clearTimeout(debounceTimeoutRef.current);
|
|
39
|
+
};
|
|
40
|
+
}, []);
|
|
41
|
+
|
|
42
|
+
// Fetch suggestions when query changes (debounced)
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
// Clear previous debounce
|
|
45
|
+
if (debounceTimeoutRef.current) {
|
|
46
|
+
clearTimeout(debounceTimeoutRef.current);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (query.length >= 2 && showSuggestions) {
|
|
50
|
+
// Debounce suggestions fetch
|
|
51
|
+
debounceTimeoutRef.current = setTimeout(() => {
|
|
52
|
+
// TODO: Replace placeholder with real API call
|
|
53
|
+
// Example implementation with proper error handling:
|
|
54
|
+
//
|
|
55
|
+
// const controller = new AbortController();
|
|
56
|
+
// fetchSuggestions(query, { signal: controller.signal })
|
|
57
|
+
// .then((results) => setSuggestions(results))
|
|
58
|
+
// .catch((error) => {
|
|
59
|
+
// if (error.name !== 'AbortError') {
|
|
60
|
+
// console.error('Failed to fetch suggestions:', error);
|
|
61
|
+
// setSuggestions([]);
|
|
62
|
+
// }
|
|
63
|
+
// });
|
|
64
|
+
// return () => controller.abort();
|
|
65
|
+
|
|
66
|
+
// Placeholder suggestions (remove when implementing API)
|
|
67
|
+
setSuggestions([
|
|
68
|
+
`${query} laptop`,
|
|
69
|
+
`${query} phone`,
|
|
70
|
+
`${query} accessories`,
|
|
71
|
+
]);
|
|
72
|
+
}, 300);
|
|
73
|
+
} else {
|
|
74
|
+
setSuggestions([]);
|
|
75
|
+
}
|
|
76
|
+
}, [query, showSuggestions]);
|
|
77
|
+
|
|
78
|
+
const handleSubmit = (e: React.FormEvent) => {
|
|
79
|
+
e.preventDefault();
|
|
80
|
+
if (query.trim()) {
|
|
81
|
+
router.push(`/search?q=${encodeURIComponent(query.trim())}`);
|
|
82
|
+
setIsOpen(false);
|
|
83
|
+
inputRef.current?.blur();
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const handleClear = () => {
|
|
88
|
+
setQuery("");
|
|
89
|
+
setSuggestions([]);
|
|
90
|
+
inputRef.current?.focus();
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
const handleSuggestionClick = (suggestion: string) => {
|
|
94
|
+
setQuery(suggestion);
|
|
95
|
+
router.push(`/search?q=${encodeURIComponent(suggestion)}`);
|
|
96
|
+
setIsOpen(false);
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
return (
|
|
100
|
+
<div className={cn("relative", className)}>
|
|
101
|
+
<form onSubmit={handleSubmit}>
|
|
102
|
+
<div className="relative">
|
|
103
|
+
<Search className="absolute left-3 top-1/2 h-5 w-5 -translate-y-1/2 text-muted-foreground" />
|
|
104
|
+
<Input
|
|
105
|
+
ref={inputRef}
|
|
106
|
+
type="search"
|
|
107
|
+
placeholder={placeholder}
|
|
108
|
+
value={query}
|
|
109
|
+
onChange={(e) => setQuery(e.target.value)}
|
|
110
|
+
onFocus={() => setIsOpen(true)}
|
|
111
|
+
onBlur={() => {
|
|
112
|
+
// Delay to allow clicking suggestions
|
|
113
|
+
if (blurTimeoutRef.current) clearTimeout(blurTimeoutRef.current);
|
|
114
|
+
blurTimeoutRef.current = setTimeout(() => setIsOpen(false), 200);
|
|
115
|
+
}}
|
|
116
|
+
className="pl-10 pr-10"
|
|
117
|
+
/>
|
|
118
|
+
{query && (
|
|
119
|
+
<button
|
|
120
|
+
type="button"
|
|
121
|
+
onClick={handleClear}
|
|
122
|
+
className="absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground"
|
|
123
|
+
aria-label="Clear search"
|
|
124
|
+
>
|
|
125
|
+
<X className="h-5 w-5" />
|
|
126
|
+
</button>
|
|
127
|
+
)}
|
|
128
|
+
</div>
|
|
129
|
+
</form>
|
|
130
|
+
|
|
131
|
+
{/* Suggestions dropdown */}
|
|
132
|
+
{isOpen && suggestions.length > 0 && (
|
|
133
|
+
<SearchSuggestions
|
|
134
|
+
suggestions={suggestions}
|
|
135
|
+
onSelect={handleSuggestionClick}
|
|
136
|
+
/>
|
|
137
|
+
)}
|
|
138
|
+
</div>
|
|
139
|
+
);
|
|
140
|
+
}
|