@salifbiaye/create-boutique 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 +1 -0
- package/cli/dist/commands.js +382 -0
- package/cli/dist/create.js +194 -0
- package/cli/dist/docker.js +19 -0
- package/cli/dist/generate.js +322 -0
- package/cli/dist/guide.js +72 -0
- package/cli/dist/index.js +156 -0
- package/cli/dist/paths.js +29 -0
- package/cli/dist/ports.js +54 -0
- package/cli/dist/project.js +119 -0
- package/cli/dist/themes.js +24 -0
- package/docs/fiche-client.en.html +137 -0
- package/docs/fiche-client.html +137 -0
- package/docs/guide-complet.en.html +259 -0
- package/docs/guide-complet.fr.html +259 -0
- package/package.json +51 -0
- package/templates/backend/.dockerignore +9 -0
- package/templates/backend/Dockerfile +30 -0
- package/templates/backend/README.md +78 -0
- package/templates/backend/TEMPLATE_VERSION +1 -0
- package/templates/backend/docker/entrypoint.sh +28 -0
- package/templates/backend/instrumentation.ts +24 -0
- package/templates/backend/medusa-config.ts +114 -0
- package/templates/backend/package-lock.json +16222 -0
- package/templates/backend/package.json +39 -0
- package/templates/backend/src/admin/README.md +33 -0
- package/templates/backend/src/admin/components/image-field.tsx +61 -0
- package/templates/backend/src/admin/i18n/README.md +58 -0
- package/templates/backend/src/admin/i18n/index.ts +8 -0
- package/templates/backend/src/admin/i18n/json/en.json +66 -0
- package/templates/backend/src/admin/i18n/json/fr.json +66 -0
- package/templates/backend/src/admin/lib/client.ts +9 -0
- package/templates/backend/src/admin/routes/boutique-campaigns/campaign-drawer.tsx +286 -0
- package/templates/backend/src/admin/routes/boutique-campaigns/page.tsx +113 -0
- package/templates/backend/src/admin/tsconfig.json +24 -0
- package/templates/backend/src/admin/vite-env.d.ts +1 -0
- package/templates/backend/src/admin/widgets/category-image.tsx +56 -0
- package/templates/backend/src/api/README.md +135 -0
- package/templates/backend/src/api/admin/boutique-campaigns/[salesChannelId]/route.ts +30 -0
- package/templates/backend/src/api/admin/boutique-campaigns/route.ts +24 -0
- package/templates/backend/src/api/middlewares.ts +28 -0
- package/templates/backend/src/api/rate-limit.ts +30 -0
- package/templates/backend/src/api/route.ts +6 -0
- package/templates/backend/src/api/store/campaign/route.ts +25 -0
- package/templates/backend/src/api/store/order-lookup/route.ts +74 -0
- package/templates/backend/src/emails/en.json +64 -0
- package/templates/backend/src/emails/fr.json +64 -0
- package/templates/backend/src/jobs/README.md +38 -0
- package/templates/backend/src/lib/emails.ts +94 -0
- package/templates/backend/src/lib/notify.ts +148 -0
- package/templates/backend/src/lib/project.ts +146 -0
- package/templates/backend/src/links/README.md +26 -0
- package/templates/backend/src/links/campaign-sales-channel.ts +9 -0
- package/templates/backend/src/modules/README.md +117 -0
- package/templates/backend/src/modules/campaign/index.ts +9 -0
- package/templates/backend/src/modules/campaign/migrations/.snapshot-boutique-campaign.json +272 -0
- package/templates/backend/src/modules/campaign/migrations/Migration20260928141440.ts +16 -0
- package/templates/backend/src/modules/campaign/migrations/Migration20260928145243.ts +13 -0
- package/templates/backend/src/modules/campaign/models/campaign.ts +28 -0
- package/templates/backend/src/modules/campaign/service.ts +6 -0
- package/templates/backend/src/modules/campaign/validators.ts +94 -0
- package/templates/backend/src/modules/resend/index.ts +6 -0
- package/templates/backend/src/modules/resend/service.ts +63 -0
- package/templates/backend/src/scripts/README.md +63 -0
- package/templates/backend/src/scripts/campaign-export.ts +15 -0
- package/templates/backend/src/scripts/campaign-import.ts +38 -0
- package/templates/backend/src/scripts/price-report.ts +34 -0
- package/templates/backend/src/scripts/seed.ts +418 -0
- package/templates/backend/src/scripts/storage.ts +63 -0
- package/templates/backend/src/subscribers/README.md +61 -0
- package/templates/backend/src/subscribers/account-emails.ts +27 -0
- package/templates/backend/src/subscribers/fulfillment-emails.ts +42 -0
- package/templates/backend/src/subscribers/order-emails.ts +12 -0
- package/templates/backend/src/subscribers/return-refund-emails.ts +50 -0
- package/templates/backend/src/workflows/README.md +81 -0
- package/templates/backend/src/workflows/steps/upsert-campaign.ts +53 -0
- package/templates/backend/src/workflows/upsert-campaign.ts +30 -0
- package/templates/backend/tsconfig.json +36 -0
- package/templates/storefront/.dockerignore +7 -0
- package/templates/storefront/.github/ISSUE_TEMPLATE/bug-report.yml +71 -0
- package/templates/storefront/.prettierrc +8 -0
- package/templates/storefront/Dockerfile +37 -0
- package/templates/storefront/LICENSE +21 -0
- package/templates/storefront/README.md +127 -0
- package/templates/storefront/locales/en.json +269 -0
- package/templates/storefront/locales/fr.json +269 -0
- package/templates/storefront/next-env.d.ts +7 -0
- package/templates/storefront/next-sitemap.js +19 -0
- package/templates/storefront/next.config.js +29 -0
- package/templates/storefront/package-lock.json +9031 -0
- package/templates/storefront/package.json +49 -0
- package/templates/storefront/postcss.config.js +6 -0
- package/templates/storefront/public/favicon.ico +0 -0
- package/templates/storefront/scripts/sync-design.mjs +30 -0
- package/templates/storefront/src/app/(checkout)/checkout/page.tsx +31 -0
- package/templates/storefront/src/app/(checkout)/layout.tsx +29 -0
- package/templates/storefront/src/app/(checkout)/not-found.tsx +20 -0
- package/templates/storefront/src/app/(main)/account/@dashboard/addresses/page.tsx +34 -0
- package/templates/storefront/src/app/(main)/account/@dashboard/loading.tsx +9 -0
- package/templates/storefront/src/app/(main)/account/@dashboard/orders/details/[id]/page.tsx +33 -0
- package/templates/storefront/src/app/(main)/account/@dashboard/orders/page.tsx +37 -0
- package/templates/storefront/src/app/(main)/account/@dashboard/page.tsx +22 -0
- package/templates/storefront/src/app/(main)/account/@dashboard/profile/page.tsx +53 -0
- package/templates/storefront/src/app/(main)/account/@login/page.tsx +12 -0
- package/templates/storefront/src/app/(main)/account/layout.tsx +20 -0
- package/templates/storefront/src/app/(main)/account/loading.tsx +9 -0
- package/templates/storefront/src/app/(main)/cart/loading.tsx +5 -0
- package/templates/storefront/src/app/(main)/cart/not-found.tsx +21 -0
- package/templates/storefront/src/app/(main)/cart/page.tsx +21 -0
- package/templates/storefront/src/app/(main)/categories/[...category]/page.tsx +55 -0
- package/templates/storefront/src/app/(main)/collections/[handle]/page.tsx +55 -0
- package/templates/storefront/src/app/(main)/layout.tsx +43 -0
- package/templates/storefront/src/app/(main)/legal/[page]/page.tsx +42 -0
- package/templates/storefront/src/app/(main)/not-found.tsx +21 -0
- package/templates/storefront/src/app/(main)/order/[id]/confirmed/loading.tsx +5 -0
- package/templates/storefront/src/app/(main)/order/[id]/confirmed/page.tsx +23 -0
- package/templates/storefront/src/app/(main)/order/[id]/transfer/[token]/accept/page.tsx +42 -0
- package/templates/storefront/src/app/(main)/order/[id]/transfer/[token]/decline/page.tsx +42 -0
- package/templates/storefront/src/app/(main)/order/[id]/transfer/[token]/page.tsx +35 -0
- package/templates/storefront/src/app/(main)/order/track/page.tsx +32 -0
- package/templates/storefront/src/app/(main)/page.tsx +68 -0
- package/templates/storefront/src/app/(main)/products/[handle]/page.tsx +86 -0
- package/templates/storefront/src/app/(main)/store/page.tsx +28 -0
- package/templates/storefront/src/app/api/health/route.ts +13 -0
- package/templates/storefront/src/app/layout.tsx +42 -0
- package/templates/storefront/src/app/not-found.tsx +21 -0
- package/templates/storefront/src/app/opengraph-image.jpg +0 -0
- package/templates/storefront/src/app/twitter-image.jpg +0 -0
- package/templates/storefront/src/instrumentation-node.ts +18 -0
- package/templates/storefront/src/instrumentation.ts +9 -0
- package/templates/storefront/src/lib/boutique/campaign.ts +116 -0
- package/templates/storefront/src/lib/boutique/config.ts +152 -0
- package/templates/storefront/src/lib/boutique/fonts.ts +29 -0
- package/templates/storefront/src/lib/boutique/i18n-client.tsx +34 -0
- package/templates/storefront/src/lib/boutique/i18n.ts +43 -0
- package/templates/storefront/src/lib/boutique/schema.ts +131 -0
- package/templates/storefront/src/lib/config.ts +39 -0
- package/templates/storefront/src/lib/constants.tsx +75 -0
- package/templates/storefront/src/lib/context/modal-context.tsx +34 -0
- package/templates/storefront/src/lib/data/cart.ts +434 -0
- package/templates/storefront/src/lib/data/categories.ts +49 -0
- package/templates/storefront/src/lib/data/collections.ts +59 -0
- package/templates/storefront/src/lib/data/cookies.ts +103 -0
- package/templates/storefront/src/lib/data/customer.ts +261 -0
- package/templates/storefront/src/lib/data/fulfillment.ts +68 -0
- package/templates/storefront/src/lib/data/onboarding.ts +9 -0
- package/templates/storefront/src/lib/data/order-lookup.ts +34 -0
- package/templates/storefront/src/lib/data/orders.ts +112 -0
- package/templates/storefront/src/lib/data/payment.ts +35 -0
- package/templates/storefront/src/lib/data/products.ts +127 -0
- package/templates/storefront/src/lib/data/regions.ts +70 -0
- package/templates/storefront/src/lib/data/variants.ts +38 -0
- package/templates/storefront/src/lib/hooks/use-in-view.tsx +29 -0
- package/templates/storefront/src/lib/hooks/use-toggle-state.tsx +46 -0
- package/templates/storefront/src/lib/util/compare-addresses.ts +28 -0
- package/templates/storefront/src/lib/util/get-percentage-diff.ts +6 -0
- package/templates/storefront/src/lib/util/get-product-price.ts +79 -0
- package/templates/storefront/src/lib/util/isEmpty.ts +11 -0
- package/templates/storefront/src/lib/util/medusa-error.ts +22 -0
- package/templates/storefront/src/lib/util/money.ts +35 -0
- package/templates/storefront/src/lib/util/product.ts +5 -0
- package/templates/storefront/src/lib/util/repeat.ts +5 -0
- package/templates/storefront/src/lib/util/sort-products.ts +50 -0
- package/templates/storefront/src/modules/account/components/account-info/index.tsx +140 -0
- package/templates/storefront/src/modules/account/components/account-nav/index.tsx +198 -0
- package/templates/storefront/src/modules/account/components/address-book/index.tsx +28 -0
- package/templates/storefront/src/modules/account/components/address-card/add-address.tsx +169 -0
- package/templates/storefront/src/modules/account/components/address-card/edit-address-modal.tsx +241 -0
- package/templates/storefront/src/modules/account/components/login/index.tsx +65 -0
- package/templates/storefront/src/modules/account/components/order-card/index.tsx +88 -0
- package/templates/storefront/src/modules/account/components/order-overview/index.tsx +47 -0
- package/templates/storefront/src/modules/account/components/overview/index.tsx +169 -0
- package/templates/storefront/src/modules/account/components/profile-billing-address/index.tsx +193 -0
- package/templates/storefront/src/modules/account/components/profile-email/index.tsx +75 -0
- package/templates/storefront/src/modules/account/components/profile-name/index.tsx +79 -0
- package/templates/storefront/src/modules/account/components/profile-password/index.tsx +72 -0
- package/templates/storefront/src/modules/account/components/profile-phone/index.tsx +74 -0
- package/templates/storefront/src/modules/account/components/register/index.tsx +107 -0
- package/templates/storefront/src/modules/account/components/transfer-request-form/index.tsx +83 -0
- package/templates/storefront/src/modules/account/templates/account-layout.tsx +43 -0
- package/templates/storefront/src/modules/account/templates/login-template.tsx +27 -0
- package/templates/storefront/src/modules/cart/components/cart-item-select/index.tsx +75 -0
- package/templates/storefront/src/modules/cart/components/empty-cart-message/index.tsx +25 -0
- package/templates/storefront/src/modules/cart/components/item/index.tsx +144 -0
- package/templates/storefront/src/modules/cart/components/sign-in-prompt/index.tsx +27 -0
- package/templates/storefront/src/modules/cart/templates/index.tsx +51 -0
- package/templates/storefront/src/modules/cart/templates/items.tsx +58 -0
- package/templates/storefront/src/modules/cart/templates/preview.tsx +51 -0
- package/templates/storefront/src/modules/cart/templates/summary.tsx +50 -0
- package/templates/storefront/src/modules/categories/templates/index.tsx +94 -0
- package/templates/storefront/src/modules/checkout/components/address-select/index.tsx +117 -0
- package/templates/storefront/src/modules/checkout/components/addresses/index.tsx +186 -0
- package/templates/storefront/src/modules/checkout/components/billing_address/index.tsx +114 -0
- package/templates/storefront/src/modules/checkout/components/country-select/index.tsx +50 -0
- package/templates/storefront/src/modules/checkout/components/discount-code/index.tsx +181 -0
- package/templates/storefront/src/modules/checkout/components/error-message/index.tsx +13 -0
- package/templates/storefront/src/modules/checkout/components/payment/index.tsx +261 -0
- package/templates/storefront/src/modules/checkout/components/payment-button/index.tsx +195 -0
- package/templates/storefront/src/modules/checkout/components/payment-container/index.tsx +130 -0
- package/templates/storefront/src/modules/checkout/components/payment-test/index.tsx +12 -0
- package/templates/storefront/src/modules/checkout/components/payment-wrapper/index.tsx +42 -0
- package/templates/storefront/src/modules/checkout/components/payment-wrapper/stripe-wrapper.tsx +54 -0
- package/templates/storefront/src/modules/checkout/components/review/index.tsx +54 -0
- package/templates/storefront/src/modules/checkout/components/shipping/index.tsx +417 -0
- package/templates/storefront/src/modules/checkout/components/shipping-address/index.tsx +219 -0
- package/templates/storefront/src/modules/checkout/components/submit-button/index.tsx +32 -0
- package/templates/storefront/src/modules/checkout/templates/checkout-form/index.tsx +38 -0
- package/templates/storefront/src/modules/checkout/templates/checkout-summary/index.tsx +31 -0
- package/templates/storefront/src/modules/collections/templates/index.tsx +44 -0
- package/templates/storefront/src/modules/common/components/cart-totals/index.tsx +84 -0
- package/templates/storefront/src/modules/common/components/checkbox/index.tsx +44 -0
- package/templates/storefront/src/modules/common/components/delete-button/index.tsx +42 -0
- package/templates/storefront/src/modules/common/components/divider/index.tsx +9 -0
- package/templates/storefront/src/modules/common/components/filter-radio-group/index.tsx +61 -0
- package/templates/storefront/src/modules/common/components/input/index.tsx +79 -0
- package/templates/storefront/src/modules/common/components/interactive-link/index.tsx +33 -0
- package/templates/storefront/src/modules/common/components/line-item-options/index.tsx +26 -0
- package/templates/storefront/src/modules/common/components/line-item-price/index.tsx +63 -0
- package/templates/storefront/src/modules/common/components/line-item-unit-price/index.tsx +62 -0
- package/templates/storefront/src/modules/common/components/localized-client-link/index.tsx +29 -0
- package/templates/storefront/src/modules/common/components/modal/index.tsx +118 -0
- package/templates/storefront/src/modules/common/components/native-select/index.tsx +76 -0
- package/templates/storefront/src/modules/common/components/radio/index.tsx +27 -0
- package/templates/storefront/src/modules/common/icons/back.tsx +37 -0
- package/templates/storefront/src/modules/common/icons/bancontact.tsx +26 -0
- package/templates/storefront/src/modules/common/icons/chevron-down.tsx +30 -0
- package/templates/storefront/src/modules/common/icons/eye-off.tsx +37 -0
- package/templates/storefront/src/modules/common/icons/eye.tsx +37 -0
- package/templates/storefront/src/modules/common/icons/fast-delivery.tsx +65 -0
- package/templates/storefront/src/modules/common/icons/ideal.tsx +26 -0
- package/templates/storefront/src/modules/common/icons/map-pin.tsx +37 -0
- package/templates/storefront/src/modules/common/icons/package.tsx +44 -0
- package/templates/storefront/src/modules/common/icons/paypal.tsx +30 -0
- package/templates/storefront/src/modules/common/icons/placeholder-image.tsx +44 -0
- package/templates/storefront/src/modules/common/icons/refresh.tsx +51 -0
- package/templates/storefront/src/modules/common/icons/spinner.tsx +37 -0
- package/templates/storefront/src/modules/common/icons/trash.tsx +51 -0
- package/templates/storefront/src/modules/common/icons/user.tsx +37 -0
- package/templates/storefront/src/modules/common/icons/x.tsx +37 -0
- package/templates/storefront/src/modules/layout/components/cart-mismatch-banner/index.tsx +59 -0
- package/templates/storefront/src/modules/order/components/help/index.tsx +26 -0
- package/templates/storefront/src/modules/order/components/item/index.tsx +57 -0
- package/templates/storefront/src/modules/order/components/items/index.tsx +44 -0
- package/templates/storefront/src/modules/order/components/onboarding-cta/index.tsx +28 -0
- package/templates/storefront/src/modules/order/components/order-details/index.tsx +64 -0
- package/templates/storefront/src/modules/order/components/order-summary/index.tsx +61 -0
- package/templates/storefront/src/modules/order/components/payment-details/index.tsx +64 -0
- package/templates/storefront/src/modules/order/components/shipping-details/index.tsx +74 -0
- package/templates/storefront/src/modules/order/components/transfer-actions/index.tsx +83 -0
- package/templates/storefront/src/modules/order/components/transfer-image/index.tsx +275 -0
- package/templates/storefront/src/modules/order/templates/order-completed-template.tsx +53 -0
- package/templates/storefront/src/modules/order/templates/order-details-template.tsx +46 -0
- package/templates/storefront/src/modules/products/components/thumbnail/index.tsx +70 -0
- package/templates/storefront/src/modules/products/templates/index.tsx +118 -0
- package/templates/storefront/src/modules/shipping/components/free-shipping-price-nudge/index.tsx +285 -0
- package/templates/storefront/src/modules/skeletons/components/skeleton-button/index.tsx +5 -0
- package/templates/storefront/src/modules/skeletons/components/skeleton-card-details/index.tsx +10 -0
- package/templates/storefront/src/modules/skeletons/components/skeleton-cart-item/index.tsx +35 -0
- package/templates/storefront/src/modules/skeletons/components/skeleton-cart-totals/index.tsx +30 -0
- package/templates/storefront/src/modules/skeletons/components/skeleton-code-form/index.tsx +13 -0
- package/templates/storefront/src/modules/skeletons/components/skeleton-line-item/index.tsx +35 -0
- package/templates/storefront/src/modules/skeletons/components/skeleton-order-confirmed-header/index.tsx +14 -0
- package/templates/storefront/src/modules/skeletons/components/skeleton-order-information/index.tsx +36 -0
- package/templates/storefront/src/modules/skeletons/components/skeleton-order-items/index.tsx +43 -0
- package/templates/storefront/src/modules/skeletons/components/skeleton-order-summary/index.tsx +15 -0
- package/templates/storefront/src/modules/skeletons/components/skeleton-product-preview/index.tsx +15 -0
- package/templates/storefront/src/modules/skeletons/templates/skeleton-cart-page/index.tsx +65 -0
- package/templates/storefront/src/modules/skeletons/templates/skeleton-order-confirmed/index.tsx +21 -0
- package/templates/storefront/src/modules/skeletons/templates/skeleton-product-grid/index.tsx +23 -0
- package/templates/storefront/src/modules/store/components/pagination/index.tsx +114 -0
- package/templates/storefront/src/modules/store/components/refinement-list/index.tsx +41 -0
- package/templates/storefront/src/modules/store/components/refinement-list/sort-products/index.tsx +48 -0
- package/templates/storefront/src/modules/store/templates/index.tsx +42 -0
- package/templates/storefront/src/modules/store/templates/paginated-products.tsx +80 -0
- package/templates/storefront/src/modules/ub/button.tsx +41 -0
- package/templates/storefront/src/modules/ub/campaign-blocks.tsx +197 -0
- package/templates/storefront/src/modules/ub/campaign-ended.tsx +28 -0
- package/templates/storefront/src/modules/ub/category-tiles.tsx +41 -0
- package/templates/storefront/src/modules/ub/countdown.tsx +46 -0
- package/templates/storefront/src/modules/ub/footer.tsx +56 -0
- package/templates/storefront/src/modules/ub/icons.tsx +42 -0
- package/templates/storefront/src/modules/ub/nav.tsx +90 -0
- package/templates/storefront/src/modules/ub/pdp/buy-box.tsx +140 -0
- package/templates/storefront/src/modules/ub/pdp/gallery.tsx +40 -0
- package/templates/storefront/src/modules/ub/product-card.tsx +66 -0
- package/templates/storefront/src/modules/ub/top-bar.tsx +20 -0
- package/templates/storefront/src/modules/ub/track-form.tsx +92 -0
- package/templates/storefront/src/proxy.ts +89 -0
- package/templates/storefront/src/styles/globals.css +98 -0
- package/templates/storefront/src/styles/ub/bundle.css +372 -0
- package/templates/storefront/src/styles/ub/fonts.css +17 -0
- package/templates/storefront/src/styles/ub/medusa-ui.css +90 -0
- package/templates/storefront/src/styles/ub/overrides.css +12 -0
- package/templates/storefront/src/styles/ub/tokens.css +9 -0
- package/templates/storefront/src/types/global.ts +24 -0
- package/templates/storefront/src/types/icon.ts +4 -0
- package/templates/storefront/tailwind.config.js +164 -0
- package/templates/storefront/themes/black-friday/campaign.en.json +31 -0
- package/templates/storefront/themes/black-friday/campaign.fr.json +31 -0
- package/templates/storefront/themes/black-friday/theme.json +9 -0
- package/templates/storefront/themes/cyber-monday/campaign.en.json +31 -0
- package/templates/storefront/themes/cyber-monday/campaign.fr.json +31 -0
- package/templates/storefront/themes/cyber-monday/theme.json +9 -0
- package/templates/storefront/themes/halloween/campaign.en.json +31 -0
- package/templates/storefront/themes/halloween/campaign.fr.json +31 -0
- package/templates/storefront/themes/halloween/theme.json +9 -0
- package/templates/storefront/themes/noel/campaign.en.json +31 -0
- package/templates/storefront/themes/noel/campaign.fr.json +31 -0
- package/templates/storefront/themes/noel/theme.json +9 -0
- package/templates/storefront/themes/nouvel-an/campaign.en.json +31 -0
- package/templates/storefront/themes/nouvel-an/campaign.fr.json +31 -0
- package/templates/storefront/themes/nouvel-an/theme.json +9 -0
- package/templates/storefront/themes/thanksgiving/campaign.en.json +31 -0
- package/templates/storefront/themes/thanksgiving/campaign.fr.json +31 -0
- package/templates/storefront/themes/thanksgiving/theme.json +9 -0
- package/templates/storefront/tsconfig.json +53 -0
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
import { T } from "@lib/boutique/i18n-client"
|
|
5
|
+
import { clx } from "@medusajs/ui"
|
|
6
|
+
import { ArrowRightOnRectangle } from "@medusajs/icons"
|
|
7
|
+
import { usePathname } from "next/navigation"
|
|
8
|
+
|
|
9
|
+
import ChevronDown from "@modules/common/icons/chevron-down"
|
|
10
|
+
import User from "@modules/common/icons/user"
|
|
11
|
+
import MapPin from "@modules/common/icons/map-pin"
|
|
12
|
+
import Package from "@modules/common/icons/package"
|
|
13
|
+
import LocalizedClientLink from "@modules/common/components/localized-client-link"
|
|
14
|
+
import { HttpTypes } from "@medusajs/types"
|
|
15
|
+
import { signout } from "@lib/data/customer"
|
|
16
|
+
|
|
17
|
+
const AccountNav = ({
|
|
18
|
+
customer,
|
|
19
|
+
}: {
|
|
20
|
+
customer: HttpTypes.StoreCustomer | null
|
|
21
|
+
}) => {
|
|
22
|
+
const route = usePathname()
|
|
23
|
+
|
|
24
|
+
const handleLogout = async () => {
|
|
25
|
+
await signout()
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<div>
|
|
30
|
+
<div className="small:hidden" data-testid="mobile-account-nav">
|
|
31
|
+
{route !== "/account" ? (
|
|
32
|
+
<LocalizedClientLink
|
|
33
|
+
href="/account"
|
|
34
|
+
className="flex items-center gap-x-2 text-small-regular py-2"
|
|
35
|
+
data-testid="account-main-link"
|
|
36
|
+
>
|
|
37
|
+
<>
|
|
38
|
+
<ChevronDown className="transform rotate-90" />
|
|
39
|
+
<span><T k="account.title" /></span>
|
|
40
|
+
</>
|
|
41
|
+
</LocalizedClientLink>
|
|
42
|
+
) : (
|
|
43
|
+
<>
|
|
44
|
+
<div className="text-xl-semi mb-4 px-8">
|
|
45
|
+
Hello {customer?.first_name}
|
|
46
|
+
</div>
|
|
47
|
+
<div className="text-base-regular">
|
|
48
|
+
<ul>
|
|
49
|
+
<li>
|
|
50
|
+
<LocalizedClientLink
|
|
51
|
+
href="/account/profile"
|
|
52
|
+
className="flex items-center justify-between py-4 border-b border-gray-200 px-8"
|
|
53
|
+
data-testid="profile-link"
|
|
54
|
+
>
|
|
55
|
+
<>
|
|
56
|
+
<div className="flex items-center gap-x-2">
|
|
57
|
+
<User size={20} />
|
|
58
|
+
<span><T k="account.profile" /></span>
|
|
59
|
+
</div>
|
|
60
|
+
<ChevronDown className="transform -rotate-90" />
|
|
61
|
+
</>
|
|
62
|
+
</LocalizedClientLink>
|
|
63
|
+
</li>
|
|
64
|
+
<li>
|
|
65
|
+
<LocalizedClientLink
|
|
66
|
+
href="/account/addresses"
|
|
67
|
+
className="flex items-center justify-between py-4 border-b border-gray-200 px-8"
|
|
68
|
+
data-testid="addresses-link"
|
|
69
|
+
>
|
|
70
|
+
<>
|
|
71
|
+
<div className="flex items-center gap-x-2">
|
|
72
|
+
<MapPin size={20} />
|
|
73
|
+
<span><T k="account.addresses" /></span>
|
|
74
|
+
</div>
|
|
75
|
+
<ChevronDown className="transform -rotate-90" />
|
|
76
|
+
</>
|
|
77
|
+
</LocalizedClientLink>
|
|
78
|
+
</li>
|
|
79
|
+
<li>
|
|
80
|
+
<LocalizedClientLink
|
|
81
|
+
href="/account/orders"
|
|
82
|
+
className="flex items-center justify-between py-4 border-b border-gray-200 px-8"
|
|
83
|
+
data-testid="orders-link"
|
|
84
|
+
>
|
|
85
|
+
<div className="flex items-center gap-x-2">
|
|
86
|
+
<Package size={20} />
|
|
87
|
+
<span><T k="account.orders" /></span>
|
|
88
|
+
</div>
|
|
89
|
+
<ChevronDown className="transform -rotate-90" />
|
|
90
|
+
</LocalizedClientLink>
|
|
91
|
+
</li>
|
|
92
|
+
<li>
|
|
93
|
+
<button
|
|
94
|
+
type="button"
|
|
95
|
+
className="flex items-center justify-between py-4 border-b border-gray-200 px-8 w-full"
|
|
96
|
+
onClick={handleLogout}
|
|
97
|
+
data-testid="logout-button"
|
|
98
|
+
>
|
|
99
|
+
<div className="flex items-center gap-x-2">
|
|
100
|
+
<ArrowRightOnRectangle />
|
|
101
|
+
<span><T k="account.logout" /></span>
|
|
102
|
+
</div>
|
|
103
|
+
<ChevronDown className="transform -rotate-90" />
|
|
104
|
+
</button>
|
|
105
|
+
</li>
|
|
106
|
+
</ul>
|
|
107
|
+
</div>
|
|
108
|
+
</>
|
|
109
|
+
)}
|
|
110
|
+
</div>
|
|
111
|
+
<div className="hidden small:block" data-testid="account-nav">
|
|
112
|
+
<div>
|
|
113
|
+
<div className="pb-4">
|
|
114
|
+
<h3 className="text-base-semi">Account</h3>
|
|
115
|
+
</div>
|
|
116
|
+
<div className="text-base-regular">
|
|
117
|
+
<ul className="flex mb-0 justify-start items-start flex-col gap-y-4">
|
|
118
|
+
<li>
|
|
119
|
+
<AccountNavLink
|
|
120
|
+
href="/account"
|
|
121
|
+
route={route!}
|
|
122
|
+
data-testid="overview-link"
|
|
123
|
+
>
|
|
124
|
+
<T k="account.overview" />
|
|
125
|
+
</AccountNavLink>
|
|
126
|
+
</li>
|
|
127
|
+
<li>
|
|
128
|
+
<AccountNavLink
|
|
129
|
+
href="/account/profile"
|
|
130
|
+
route={route!}
|
|
131
|
+
data-testid="profile-link"
|
|
132
|
+
>
|
|
133
|
+
<T k="account.profile" />
|
|
134
|
+
</AccountNavLink>
|
|
135
|
+
</li>
|
|
136
|
+
<li>
|
|
137
|
+
<AccountNavLink
|
|
138
|
+
href="/account/addresses"
|
|
139
|
+
route={route!}
|
|
140
|
+
data-testid="addresses-link"
|
|
141
|
+
>
|
|
142
|
+
<T k="account.addresses" />
|
|
143
|
+
</AccountNavLink>
|
|
144
|
+
</li>
|
|
145
|
+
<li>
|
|
146
|
+
<AccountNavLink
|
|
147
|
+
href="/account/orders"
|
|
148
|
+
route={route!}
|
|
149
|
+
data-testid="orders-link"
|
|
150
|
+
>
|
|
151
|
+
<T k="account.orders" />
|
|
152
|
+
</AccountNavLink>
|
|
153
|
+
</li>
|
|
154
|
+
<li className="text-grey-700">
|
|
155
|
+
<button
|
|
156
|
+
type="button"
|
|
157
|
+
onClick={handleLogout}
|
|
158
|
+
data-testid="logout-button"
|
|
159
|
+
>
|
|
160
|
+
<T k="account.logout" />
|
|
161
|
+
</button>
|
|
162
|
+
</li>
|
|
163
|
+
</ul>
|
|
164
|
+
</div>
|
|
165
|
+
</div>
|
|
166
|
+
</div>
|
|
167
|
+
</div>
|
|
168
|
+
)
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
type AccountNavLinkProps = {
|
|
172
|
+
href: string
|
|
173
|
+
route: string
|
|
174
|
+
children: React.ReactNode
|
|
175
|
+
"data-testid"?: string
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
const AccountNavLink = ({
|
|
179
|
+
href,
|
|
180
|
+
route,
|
|
181
|
+
children,
|
|
182
|
+
"data-testid": dataTestId,
|
|
183
|
+
}: AccountNavLinkProps) => {
|
|
184
|
+
const active = route === href
|
|
185
|
+
return (
|
|
186
|
+
<LocalizedClientLink
|
|
187
|
+
href={href}
|
|
188
|
+
className={clx("text-ui-fg-subtle hover:text-ui-fg-base", {
|
|
189
|
+
"text-ui-fg-base font-semibold": active,
|
|
190
|
+
})}
|
|
191
|
+
data-testid={dataTestId}
|
|
192
|
+
>
|
|
193
|
+
{children}
|
|
194
|
+
</LocalizedClientLink>
|
|
195
|
+
)
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export default AccountNav
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
|
|
3
|
+
import AddAddress from "../address-card/add-address"
|
|
4
|
+
import EditAddress from "../address-card/edit-address-modal"
|
|
5
|
+
import { HttpTypes } from "@medusajs/types"
|
|
6
|
+
|
|
7
|
+
type AddressBookProps = {
|
|
8
|
+
customer: HttpTypes.StoreCustomer
|
|
9
|
+
region: HttpTypes.StoreRegion
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const AddressBook: React.FC<AddressBookProps> = ({ customer, region }) => {
|
|
13
|
+
const { addresses } = customer
|
|
14
|
+
return (
|
|
15
|
+
<div className="w-full">
|
|
16
|
+
<div className="grid grid-cols-1 lg:grid-cols-2 gap-4 flex-1 mt-4">
|
|
17
|
+
<AddAddress region={region} addresses={addresses} />
|
|
18
|
+
{addresses.map((address) => {
|
|
19
|
+
return (
|
|
20
|
+
<EditAddress region={region} address={address} key={address.id} />
|
|
21
|
+
)
|
|
22
|
+
})}
|
|
23
|
+
</div>
|
|
24
|
+
</div>
|
|
25
|
+
)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default AddressBook
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
import { T } from "@lib/boutique/i18n-client"
|
|
5
|
+
import { Plus } from "@medusajs/icons"
|
|
6
|
+
import { Button, Heading } from "@medusajs/ui"
|
|
7
|
+
import { useEffect, useState, useActionState } from "react"
|
|
8
|
+
|
|
9
|
+
import useToggleState from "@lib/hooks/use-toggle-state"
|
|
10
|
+
import CountrySelect from "@modules/checkout/components/country-select"
|
|
11
|
+
import Input from "@modules/common/components/input"
|
|
12
|
+
import Modal from "@modules/common/components/modal"
|
|
13
|
+
import { SubmitButton } from "@modules/checkout/components/submit-button"
|
|
14
|
+
import { HttpTypes } from "@medusajs/types"
|
|
15
|
+
import { addCustomerAddress } from "@lib/data/customer"
|
|
16
|
+
|
|
17
|
+
const AddAddress = ({
|
|
18
|
+
region,
|
|
19
|
+
addresses,
|
|
20
|
+
}: {
|
|
21
|
+
region: HttpTypes.StoreRegion
|
|
22
|
+
addresses: HttpTypes.StoreCustomerAddress[]
|
|
23
|
+
}) => {
|
|
24
|
+
const [successState, setSuccessState] = useState(false)
|
|
25
|
+
const { state, open, close: closeModal } = useToggleState(false)
|
|
26
|
+
|
|
27
|
+
const [formState, formAction] = useActionState(addCustomerAddress, {
|
|
28
|
+
isDefaultShipping: addresses.length === 0,
|
|
29
|
+
success: false,
|
|
30
|
+
error: null,
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
const close = () => {
|
|
34
|
+
setSuccessState(false)
|
|
35
|
+
closeModal()
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
if (successState) {
|
|
40
|
+
close()
|
|
41
|
+
}
|
|
42
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
43
|
+
}, [successState])
|
|
44
|
+
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
if (formState.success) {
|
|
47
|
+
setSuccessState(true)
|
|
48
|
+
}
|
|
49
|
+
}, [formState])
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<>
|
|
53
|
+
<button
|
|
54
|
+
className="border border-ui-border-base rounded-rounded p-5 min-h-[220px] h-full w-full flex flex-col justify-between"
|
|
55
|
+
onClick={open}
|
|
56
|
+
data-testid="add-address-button"
|
|
57
|
+
>
|
|
58
|
+
<span className="text-base-semi">New address</span>
|
|
59
|
+
<Plus />
|
|
60
|
+
</button>
|
|
61
|
+
|
|
62
|
+
<Modal isOpen={state} close={close} data-testid="add-address-modal">
|
|
63
|
+
<Modal.Title>
|
|
64
|
+
<Heading className="mb-2">Add address</Heading>
|
|
65
|
+
</Modal.Title>
|
|
66
|
+
<form action={formAction}>
|
|
67
|
+
<Modal.Body>
|
|
68
|
+
<div className="flex flex-col gap-y-2">
|
|
69
|
+
<div className="grid grid-cols-2 gap-x-2">
|
|
70
|
+
<Input
|
|
71
|
+
label="form.firstName"
|
|
72
|
+
name="first_name"
|
|
73
|
+
required
|
|
74
|
+
autoComplete="given-name"
|
|
75
|
+
data-testid="first-name-input"
|
|
76
|
+
/>
|
|
77
|
+
<Input
|
|
78
|
+
label="form.lastName"
|
|
79
|
+
name="last_name"
|
|
80
|
+
required
|
|
81
|
+
autoComplete="family-name"
|
|
82
|
+
data-testid="last-name-input"
|
|
83
|
+
/>
|
|
84
|
+
</div>
|
|
85
|
+
<Input
|
|
86
|
+
label="form.company"
|
|
87
|
+
name="company"
|
|
88
|
+
autoComplete="organization"
|
|
89
|
+
data-testid="company-input"
|
|
90
|
+
/>
|
|
91
|
+
<Input
|
|
92
|
+
label="form.address"
|
|
93
|
+
name="address_1"
|
|
94
|
+
required
|
|
95
|
+
autoComplete="address-line1"
|
|
96
|
+
data-testid="address-1-input"
|
|
97
|
+
/>
|
|
98
|
+
<Input
|
|
99
|
+
label="form.address2"
|
|
100
|
+
name="address_2"
|
|
101
|
+
autoComplete="address-line2"
|
|
102
|
+
data-testid="address-2-input"
|
|
103
|
+
/>
|
|
104
|
+
<div className="grid grid-cols-[144px_1fr] gap-x-2">
|
|
105
|
+
<Input
|
|
106
|
+
label="form.postalCode"
|
|
107
|
+
name="postal_code"
|
|
108
|
+
required
|
|
109
|
+
autoComplete="postal-code"
|
|
110
|
+
data-testid="postal-code-input"
|
|
111
|
+
/>
|
|
112
|
+
<Input
|
|
113
|
+
label="form.city"
|
|
114
|
+
name="city"
|
|
115
|
+
required
|
|
116
|
+
autoComplete="locality"
|
|
117
|
+
data-testid="city-input"
|
|
118
|
+
/>
|
|
119
|
+
</div>
|
|
120
|
+
<Input
|
|
121
|
+
label="form.province"
|
|
122
|
+
name="province"
|
|
123
|
+
autoComplete="address-level1"
|
|
124
|
+
data-testid="state-input"
|
|
125
|
+
/>
|
|
126
|
+
<CountrySelect
|
|
127
|
+
region={region}
|
|
128
|
+
name="country_code"
|
|
129
|
+
required
|
|
130
|
+
autoComplete="country"
|
|
131
|
+
data-testid="country-select"
|
|
132
|
+
/>
|
|
133
|
+
<Input
|
|
134
|
+
label="form.phone"
|
|
135
|
+
name="phone"
|
|
136
|
+
autoComplete="phone"
|
|
137
|
+
data-testid="phone-input"
|
|
138
|
+
/>
|
|
139
|
+
</div>
|
|
140
|
+
{formState.error && (
|
|
141
|
+
<div
|
|
142
|
+
className="text-rose-500 text-small-regular py-2"
|
|
143
|
+
data-testid="address-error"
|
|
144
|
+
>
|
|
145
|
+
{formState.error}
|
|
146
|
+
</div>
|
|
147
|
+
)}
|
|
148
|
+
</Modal.Body>
|
|
149
|
+
<Modal.Footer>
|
|
150
|
+
<div className="flex gap-3 mt-6">
|
|
151
|
+
<Button
|
|
152
|
+
type="reset"
|
|
153
|
+
variant="secondary"
|
|
154
|
+
onClick={close}
|
|
155
|
+
className="h-10"
|
|
156
|
+
data-testid="cancel-button"
|
|
157
|
+
>
|
|
158
|
+
<T k="form.cancel" />
|
|
159
|
+
</Button>
|
|
160
|
+
<SubmitButton data-testid="save-button">Save</SubmitButton>
|
|
161
|
+
</div>
|
|
162
|
+
</Modal.Footer>
|
|
163
|
+
</form>
|
|
164
|
+
</Modal>
|
|
165
|
+
</>
|
|
166
|
+
)
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export default AddAddress
|
package/templates/storefront/src/modules/account/components/address-card/edit-address-modal.tsx
ADDED
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
import { T } from "@lib/boutique/i18n-client"
|
|
5
|
+
import React, { useEffect, useState, useActionState } from "react"
|
|
6
|
+
import { PencilSquare as Edit, Trash } from "@medusajs/icons"
|
|
7
|
+
import { Button, Heading, Text, clx } from "@medusajs/ui"
|
|
8
|
+
|
|
9
|
+
import useToggleState from "@lib/hooks/use-toggle-state"
|
|
10
|
+
import CountrySelect from "@modules/checkout/components/country-select"
|
|
11
|
+
import Input from "@modules/common/components/input"
|
|
12
|
+
import Modal from "@modules/common/components/modal"
|
|
13
|
+
import Spinner from "@modules/common/icons/spinner"
|
|
14
|
+
import { SubmitButton } from "@modules/checkout/components/submit-button"
|
|
15
|
+
import { HttpTypes } from "@medusajs/types"
|
|
16
|
+
import {
|
|
17
|
+
deleteCustomerAddress,
|
|
18
|
+
updateCustomerAddress,
|
|
19
|
+
} from "@lib/data/customer"
|
|
20
|
+
|
|
21
|
+
type EditAddressProps = {
|
|
22
|
+
region: HttpTypes.StoreRegion
|
|
23
|
+
address: HttpTypes.StoreCustomerAddress
|
|
24
|
+
isActive?: boolean
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const EditAddress: React.FC<EditAddressProps> = ({
|
|
28
|
+
region,
|
|
29
|
+
address,
|
|
30
|
+
isActive = false,
|
|
31
|
+
}) => {
|
|
32
|
+
const [removing, setRemoving] = useState(false)
|
|
33
|
+
const [successState, setSuccessState] = useState(false)
|
|
34
|
+
const { state, open, close: closeModal } = useToggleState(false)
|
|
35
|
+
|
|
36
|
+
const [formState, formAction] = useActionState(updateCustomerAddress, {
|
|
37
|
+
success: false,
|
|
38
|
+
error: null,
|
|
39
|
+
addressId: address.id,
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
const close = () => {
|
|
43
|
+
setSuccessState(false)
|
|
44
|
+
closeModal()
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
if (successState) {
|
|
49
|
+
close()
|
|
50
|
+
}
|
|
51
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
52
|
+
}, [successState])
|
|
53
|
+
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
if (formState.success) {
|
|
56
|
+
setSuccessState(true)
|
|
57
|
+
}
|
|
58
|
+
}, [formState])
|
|
59
|
+
|
|
60
|
+
const removeAddress = async () => {
|
|
61
|
+
setRemoving(true)
|
|
62
|
+
await deleteCustomerAddress(address.id)
|
|
63
|
+
setRemoving(false)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return (
|
|
67
|
+
<>
|
|
68
|
+
<div
|
|
69
|
+
className={clx(
|
|
70
|
+
"border rounded-rounded p-5 min-h-[220px] h-full w-full flex flex-col justify-between transition-colors",
|
|
71
|
+
{
|
|
72
|
+
"border-gray-900": isActive,
|
|
73
|
+
}
|
|
74
|
+
)}
|
|
75
|
+
data-testid="address-container"
|
|
76
|
+
>
|
|
77
|
+
<div className="flex flex-col">
|
|
78
|
+
<Heading
|
|
79
|
+
className="text-left text-base-semi"
|
|
80
|
+
data-testid="address-name"
|
|
81
|
+
>
|
|
82
|
+
{address.first_name} {address.last_name}
|
|
83
|
+
</Heading>
|
|
84
|
+
{address.company && (
|
|
85
|
+
<Text
|
|
86
|
+
className="txt-compact-small text-ui-fg-base"
|
|
87
|
+
data-testid="address-company"
|
|
88
|
+
>
|
|
89
|
+
{address.company}
|
|
90
|
+
</Text>
|
|
91
|
+
)}
|
|
92
|
+
<Text className="flex flex-col text-left text-base-regular mt-2">
|
|
93
|
+
<span data-testid="address-address">
|
|
94
|
+
{address.address_1}
|
|
95
|
+
{address.address_2 && <span>, {address.address_2}</span>}
|
|
96
|
+
</span>
|
|
97
|
+
<span data-testid="address-postal-city">
|
|
98
|
+
{address.postal_code}, {address.city}
|
|
99
|
+
</span>
|
|
100
|
+
<span data-testid="address-province-country">
|
|
101
|
+
{address.province && `${address.province}, `}
|
|
102
|
+
{address.country_code?.toUpperCase()}
|
|
103
|
+
</span>
|
|
104
|
+
</Text>
|
|
105
|
+
</div>
|
|
106
|
+
<div className="flex items-center gap-x-4">
|
|
107
|
+
<button
|
|
108
|
+
className="text-small-regular text-ui-fg-base flex items-center gap-x-2"
|
|
109
|
+
onClick={open}
|
|
110
|
+
data-testid="address-edit-button"
|
|
111
|
+
>
|
|
112
|
+
<Edit />
|
|
113
|
+
<T k="form.edit" />
|
|
114
|
+
</button>
|
|
115
|
+
<button
|
|
116
|
+
className="text-small-regular text-ui-fg-base flex items-center gap-x-2"
|
|
117
|
+
onClick={removeAddress}
|
|
118
|
+
data-testid="address-delete-button"
|
|
119
|
+
>
|
|
120
|
+
{removing ? <Spinner /> : <Trash />}
|
|
121
|
+
<T k="form.remove" />
|
|
122
|
+
</button>
|
|
123
|
+
</div>
|
|
124
|
+
</div>
|
|
125
|
+
|
|
126
|
+
<Modal isOpen={state} close={close} data-testid="edit-address-modal">
|
|
127
|
+
<Modal.Title>
|
|
128
|
+
<Heading className="mb-2">Edit address</Heading>
|
|
129
|
+
</Modal.Title>
|
|
130
|
+
<form action={formAction}>
|
|
131
|
+
<input type="hidden" name="addressId" value={address.id} />
|
|
132
|
+
<Modal.Body>
|
|
133
|
+
<div className="grid grid-cols-1 gap-y-2">
|
|
134
|
+
<div className="grid grid-cols-2 gap-x-2">
|
|
135
|
+
<Input
|
|
136
|
+
label="form.firstName"
|
|
137
|
+
name="first_name"
|
|
138
|
+
required
|
|
139
|
+
autoComplete="given-name"
|
|
140
|
+
defaultValue={address.first_name || undefined}
|
|
141
|
+
data-testid="first-name-input"
|
|
142
|
+
/>
|
|
143
|
+
<Input
|
|
144
|
+
label="form.lastName"
|
|
145
|
+
name="last_name"
|
|
146
|
+
required
|
|
147
|
+
autoComplete="family-name"
|
|
148
|
+
defaultValue={address.last_name || undefined}
|
|
149
|
+
data-testid="last-name-input"
|
|
150
|
+
/>
|
|
151
|
+
</div>
|
|
152
|
+
<Input
|
|
153
|
+
label="form.company"
|
|
154
|
+
name="company"
|
|
155
|
+
autoComplete="organization"
|
|
156
|
+
defaultValue={address.company || undefined}
|
|
157
|
+
data-testid="company-input"
|
|
158
|
+
/>
|
|
159
|
+
<Input
|
|
160
|
+
label="form.address"
|
|
161
|
+
name="address_1"
|
|
162
|
+
required
|
|
163
|
+
autoComplete="address-line1"
|
|
164
|
+
defaultValue={address.address_1 || undefined}
|
|
165
|
+
data-testid="address-1-input"
|
|
166
|
+
/>
|
|
167
|
+
<Input
|
|
168
|
+
label="form.address2"
|
|
169
|
+
name="address_2"
|
|
170
|
+
autoComplete="address-line2"
|
|
171
|
+
defaultValue={address.address_2 || undefined}
|
|
172
|
+
data-testid="address-2-input"
|
|
173
|
+
/>
|
|
174
|
+
<div className="grid grid-cols-[144px_1fr] gap-x-2">
|
|
175
|
+
<Input
|
|
176
|
+
label="form.postalCode"
|
|
177
|
+
name="postal_code"
|
|
178
|
+
required
|
|
179
|
+
autoComplete="postal-code"
|
|
180
|
+
defaultValue={address.postal_code || undefined}
|
|
181
|
+
data-testid="postal-code-input"
|
|
182
|
+
/>
|
|
183
|
+
<Input
|
|
184
|
+
label="form.city"
|
|
185
|
+
name="city"
|
|
186
|
+
required
|
|
187
|
+
autoComplete="locality"
|
|
188
|
+
defaultValue={address.city || undefined}
|
|
189
|
+
data-testid="city-input"
|
|
190
|
+
/>
|
|
191
|
+
</div>
|
|
192
|
+
<Input
|
|
193
|
+
label="form.province"
|
|
194
|
+
name="province"
|
|
195
|
+
autoComplete="address-level1"
|
|
196
|
+
defaultValue={address.province || undefined}
|
|
197
|
+
data-testid="state-input"
|
|
198
|
+
/>
|
|
199
|
+
<CountrySelect
|
|
200
|
+
name="country_code"
|
|
201
|
+
region={region}
|
|
202
|
+
required
|
|
203
|
+
autoComplete="country"
|
|
204
|
+
defaultValue={address.country_code || undefined}
|
|
205
|
+
data-testid="country-select"
|
|
206
|
+
/>
|
|
207
|
+
<Input
|
|
208
|
+
label="form.phone"
|
|
209
|
+
name="phone"
|
|
210
|
+
autoComplete="phone"
|
|
211
|
+
defaultValue={address.phone || undefined}
|
|
212
|
+
data-testid="phone-input"
|
|
213
|
+
/>
|
|
214
|
+
</div>
|
|
215
|
+
{formState.error && (
|
|
216
|
+
<div className="text-rose-500 text-small-regular py-2">
|
|
217
|
+
{formState.error}
|
|
218
|
+
</div>
|
|
219
|
+
)}
|
|
220
|
+
</Modal.Body>
|
|
221
|
+
<Modal.Footer>
|
|
222
|
+
<div className="flex gap-3 mt-6">
|
|
223
|
+
<Button
|
|
224
|
+
type="reset"
|
|
225
|
+
variant="secondary"
|
|
226
|
+
onClick={close}
|
|
227
|
+
className="h-10"
|
|
228
|
+
data-testid="cancel-button"
|
|
229
|
+
>
|
|
230
|
+
<T k="form.cancel" />
|
|
231
|
+
</Button>
|
|
232
|
+
<SubmitButton data-testid="save-button">Save</SubmitButton>
|
|
233
|
+
</div>
|
|
234
|
+
</Modal.Footer>
|
|
235
|
+
</form>
|
|
236
|
+
</Modal>
|
|
237
|
+
</>
|
|
238
|
+
)
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export default EditAddress
|