From f5e2fcbf98de247cd1357f96340ae0cd85b2f690 Mon Sep 17 00:00:00 2001 From: Nermin Karic Date: Sun, 22 Nov 2026 21:49:17 +0100 Subject: [PATCH] first commit --- .gitignore | 57 + .npmrc | 1 + AGENTS.md | 233 + ANALIZA_PROJEKTA_SUMAN.md | 255 + CLAUDE.md | 3 + LICENSE | 21 + README.md | 188 + apps/backend/.env.template | 8 + apps/backend/.gitignore | 26 + apps/backend/README.md | 62 + apps/backend/eslint.config.ts | 4 + apps/backend/instrumentation.ts | 24 + apps/backend/integration-tests/setup.js | 3 + apps/backend/jest.config.js | 27 + apps/backend/medusa-config.ts | 21 + apps/backend/package.json | 60 + apps/backend/src/admin/README.md | 33 + apps/backend/src/admin/i18n/README.md | 58 + apps/backend/src/admin/i18n/index.ts | 1 + apps/backend/src/admin/lib/client.ts | 10 + .../src/admin/routes/inquiries/page.tsx | 345 + apps/backend/src/admin/tsconfig.json | 27 + apps/backend/src/admin/vite-env.d.ts | 1 + .../src/admin/widgets/customer-crm-widget.tsx | 157 + .../admin/widgets/product-inquiry-widget.tsx | 228 + apps/backend/src/api/README.md | 135 + apps/backend/src/api/admin/custom/route.ts | 8 + .../src/api/admin/inquiries/[id]/route.ts | 64 + apps/backend/src/api/admin/inquiries/route.ts | 50 + apps/backend/src/api/middlewares.ts | 97 + apps/backend/src/api/store/custom/route.ts | 8 + apps/backend/src/api/store/inquiries/route.ts | 17 + .../src/api/store/inquiries/validators.ts | 26 + apps/backend/src/jobs/README.md | 38 + apps/backend/src/lib/region-store-policies.ts | 24 + apps/backend/src/links/README.md | 26 + apps/backend/src/links/inquiry-product.ts | 9 + .../src/links/inquiry-sales-channel.ts | 9 + .../migration-scripts/initial-data-seed.ts | 841 + .../region-store-policies.ts | 32 + apps/backend/src/modules/README.md | 117 + apps/backend/src/modules/inquiry/index.ts | 9 + .../inquiry/migrations/.snapshot-inquiry.json | 302 + .../migrations/Migration20261109151942.ts | 14 + .../src/modules/inquiry/models/inquiry.ts | 27 + apps/backend/src/modules/inquiry/service.ts | 9 + .../src/scripts/cleanup-keep-ba-hr-only.ts | 179 + .../backend/src/scripts/seed-demo-products.ts | 355 + apps/backend/src/scripts/setup-b2b-pricing.ts | 73 + apps/backend/src/scripts/setup-suman-ba.ts | 726 + apps/backend/src/scripts/setup-suman-hr.ts | 165 + .../src/scripts/setup-umbrella-platform.ts | 285 + .../src/scripts/update-product-scenarios.ts | 68 + .../src/search/helpers/option-values.ts | 29 + apps/backend/src/search/helpers/pricing.ts | 176 + .../src/search/helpers/resolve-product-ids.ts | 141 + apps/backend/src/search/product.ts | 165 + apps/backend/src/subscribers/README.md | 61 + apps/backend/src/subscribers/b2b-order-crm.ts | 82 + apps/backend/src/workflows/README.md | 81 + apps/backend/src/workflows/inquiry/index.ts | 99 + apps/backend/tsconfig.json | 36 + apps/suman-bosna/.prettierrc.json | 3 + apps/suman-bosna/AGENTS.md | 9 + apps/suman-bosna/CLAUDE.md | 1 + apps/suman-bosna/check-env-variables.js | 40 + apps/suman-bosna/components.json | 25 + apps/suman-bosna/eslint.config.mjs | 31 + apps/suman-bosna/next-env.d.ts | 7 + apps/suman-bosna/next.config.js | 91 + apps/suman-bosna/package.json | 72 + apps/suman-bosna/postcss.config.js | 6 + ...nsitioning_from_day_t…_bdaf7175_1080 p.mp4 | Bin 0 -> 13222694 bytes apps/suman-bosna/public/favicon.ico | Bin 0 -> 25931 bytes apps/suman-bosna/public/logo.png | Bin 0 -> 61458 bytes apps/suman-bosna/public/pergola-hero.mp4 | 1 + .../src/app/.well-known/ucp/route.ts | 63 + .../(checkout)/checkout/page.tsx | 30 + .../app/[countryCode]/(checkout)/layout.tsx | 43 + .../[countryCode]/(checkout)/not-found.tsx | 19 + .../account/@dashboard/addresses/page.tsx | 38 + .../(main)/account/@dashboard/default.tsx | 3 + .../(main)/account/@dashboard/loading.tsx | 9 + .../@dashboard/orders/details/[id]/page.tsx | 33 + .../(main)/account/@dashboard/orders/page.tsx | 37 + .../(main)/account/@dashboard/page.tsx | 22 + .../account/@dashboard/profile/page.tsx | 51 + .../(main)/account/@login/default.tsx | 1 + .../(main)/account/@login/page.tsx | 12 + .../[countryCode]/(main)/account/layout.tsx | 20 + .../[countryCode]/(main)/account/loading.tsx | 9 + .../[countryCode]/(main)/cart/add/route.ts | 103 + .../app/[countryCode]/(main)/cart/loading.tsx | 5 + .../[countryCode]/(main)/cart/not-found.tsx | 21 + .../app/[countryCode]/(main)/cart/page.tsx | 21 + .../(main)/cart/resume/[cartId]/route.ts | 35 + .../(main)/categories/[...category]/page.tsx | 62 + .../(main)/collections/[handle]/page.tsx | 59 + .../app/[countryCode]/(main)/contact/page.tsx | 24 + .../src/app/[countryCode]/(main)/layout.tsx | 45 + .../app/[countryCode]/(main)/not-found.tsx | 20 + .../(main)/order/[id]/confirmed/loading.tsx | 5 + .../(main)/order/[id]/confirmed/page.tsx | 23 + .../[id]/transfer/[token]/accept/page.tsx | 41 + .../[id]/transfer/[token]/decline/page.tsx | 41 + .../order/[id]/transfer/[token]/page.tsx | 38 + .../src/app/[countryCode]/(main)/page.tsx | 106 + .../app/[countryCode]/(main)/privacy/page.tsx | 29 + .../products/[handle]/markdown/route.ts | 38 + .../(main)/products/[handle]/page.tsx | 145 + .../app/[countryCode]/(main)/returns/page.tsx | 39 + .../app/[countryCode]/(main)/search/page.tsx | 72 + .../[countryCode]/(main)/shipping/page.tsx | 42 + .../app/[countryCode]/(main)/store/page.tsx | 23 + .../app/[countryCode]/(main)/terms/page.tsx | 29 + .../(main)/verify-account/page.tsx | 25 + .../src/app/api/payment-return/route.ts | 103 + apps/suman-bosna/src/app/buy/[items]/route.ts | 72 + apps/suman-bosna/src/app/layout.tsx | 28 + apps/suman-bosna/src/app/llms.txt/route.ts | 72 + apps/suman-bosna/src/app/not-found.tsx | 31 + apps/suman-bosna/src/app/opengraph-image.jpg | Bin 0 -> 234193 bytes apps/suman-bosna/src/app/robots.ts | 21 + apps/suman-bosna/src/app/sitemap.ts | 72 + apps/suman-bosna/src/app/twitter-image.jpg | Bin 0 -> 234193 bytes apps/suman-bosna/src/app/ucp/mcp/route.ts | 6 + .../src/app/ucp/v1/cart/[cartId]/route.ts | 15 + apps/suman-bosna/src/app/ucp/v1/cart/route.ts | 11 + .../src/app/ucp/v1/catalog/lookup/route.ts | 5 + .../src/app/ucp/v1/catalog/search/route.ts | 5 + .../v1/checkout-sessions/[id]/cancel/route.ts | 7 + .../checkout-sessions/[id]/complete/route.ts | 7 + .../ucp/v1/checkout-sessions/[id]/route.ts | 12 + .../src/app/ucp/v1/checkout-sessions/route.ts | 11 + apps/suman-bosna/src/app/ucp/v1/route.ts | 26 + .../src/components/ui/accordion.tsx | 57 + apps/suman-bosna/src/components/ui/badge.tsx | 36 + apps/suman-bosna/src/components/ui/button.tsx | 74 + apps/suman-bosna/src/components/ui/card.tsx | 76 + apps/suman-bosna/src/components/ui/dialog.tsx | 121 + .../src/components/ui/dropdown-menu.tsx | 185 + .../src/components/ui/dynamic-icon.tsx | 56 + apps/suman-bosna/src/components/ui/input.tsx | 25 + apps/suman-bosna/src/components/ui/label.tsx | 24 + apps/suman-bosna/src/components/ui/logo.tsx | 32 + .../src/components/ui/section-header.tsx | 71 + .../src/components/ui/separator.tsx | 31 + apps/suman-bosna/src/components/ui/sheet.tsx | 140 + .../src/components/ui/skeleton.tsx | 16 + apps/suman-bosna/src/components/ui/table.tsx | 118 + apps/suman-bosna/src/components/ui/tabs.tsx | 55 + apps/suman-bosna/src/config/banner.json | 9 + apps/suman-bosna/src/config/faq.json | 32 + apps/suman-bosna/src/config/footer.json | 53 + apps/suman-bosna/src/config/hero.json | 14 + apps/suman-bosna/src/config/mission.json | 28 + apps/suman-bosna/src/config/navigation.json | 61 + apps/suman-bosna/src/config/news.json | 35 + apps/suman-bosna/src/config/partners.json | 30 + apps/suman-bosna/src/config/product-tabs.json | 66 + .../src/config/products-showcase.json | 63 + apps/suman-bosna/src/config/site.json | 11 + apps/suman-bosna/src/lib/config.ts | 39 + apps/suman-bosna/src/lib/constants.tsx | 127 + .../src/lib/context/modal-context.tsx | 34 + apps/suman-bosna/src/lib/data/adyen.ts | 82 + apps/suman-bosna/src/lib/data/cart.ts | 483 + apps/suman-bosna/src/lib/data/categories.ts | 49 + apps/suman-bosna/src/lib/data/collections.ts | 59 + apps/suman-bosna/src/lib/data/cookies.ts | 140 + apps/suman-bosna/src/lib/data/customer.ts | 381 + apps/suman-bosna/src/lib/data/fulfillment.ts | 68 + apps/suman-bosna/src/lib/data/inquiries.ts | 35 + .../src/lib/data/locale-actions.ts | 74 + apps/suman-bosna/src/lib/data/locales.ts | 28 + apps/suman-bosna/src/lib/data/onboarding.ts | 9 + apps/suman-bosna/src/lib/data/orders.ts | 112 + apps/suman-bosna/src/lib/data/payment.ts | 35 + apps/suman-bosna/src/lib/data/products.ts | 151 + apps/suman-bosna/src/lib/data/regions.ts | 59 + .../src/lib/data/store-policies.ts | 20 + apps/suman-bosna/src/lib/data/variants.ts | 38 + .../suman-bosna/src/lib/hooks/use-in-view.tsx | 29 + .../src/lib/hooks/use-search-settled.tsx | 31 + .../src/lib/hooks/use-toggle-state.tsx | 46 + apps/suman-bosna/src/lib/search-client.ts | 57 + apps/suman-bosna/src/lib/ucp/mcp.ts | 236 + apps/suman-bosna/src/lib/ucp/operations.ts | 547 + apps/suman-bosna/src/lib/ucp/ucp.ts | 203 + apps/suman-bosna/src/lib/util/cart-events.ts | 6 + .../src/lib/util/compare-addresses.ts | 28 + apps/suman-bosna/src/lib/util/env.ts | 3 + .../src/lib/util/get-locale-header.ts | 8 + .../src/lib/util/get-percentage-diff.ts | 6 + .../src/lib/util/get-product-price.ts | 90 + apps/suman-bosna/src/lib/util/inventory.ts | 9 + apps/suman-bosna/src/lib/util/isEmpty.ts | 11 + apps/suman-bosna/src/lib/util/medusa-error.ts | 33 + apps/suman-bosna/src/lib/util/money.ts | 26 + .../suman-bosna/src/lib/util/payment-error.ts | 21 + .../src/lib/util/product-markdown.ts | 77 + .../src/lib/util/product-option-filters.ts | 26 + .../src/lib/util/product-structured-data.ts | 107 + apps/suman-bosna/src/lib/util/product.ts | 5 + apps/suman-bosna/src/lib/util/repeat.ts | 5 + apps/suman-bosna/src/lib/util/server-cart.ts | 53 + apps/suman-bosna/src/lib/util/site.ts | 51 + .../suman-bosna/src/lib/util/sort-products.ts | 50 + .../src/lib/util/store-policies.ts | 103 + apps/suman-bosna/src/lib/utils.ts | 7 + apps/suman-bosna/src/middleware.ts | 133 + .../account/components/account-info/index.tsx | 139 + .../account/components/account-nav/index.tsx | 122 + .../account/components/address-book/index.tsx | 28 + .../components/address-card/add-address.tsx | 165 + .../address-card/edit-address-modal.tsx | 237 + .../account/components/login/index.tsx | 76 + .../account/components/order-card/index.tsx | 87 + .../components/order-overview/index.tsx | 45 + .../account/components/overview/index.tsx | 168 + .../profile-billing-address/index.tsx | 191 + .../components/profile-email/index.tsx | 71 + .../account/components/profile-name/index.tsx | 79 + .../components/profile-password/index.tsx | 71 + .../components/profile-phone/index.tsx | 74 + .../account/components/register/index.tsx | 118 + .../transfer-request-form/index.tsx | 81 + .../components/verify-account/index.tsx | 74 + .../account/templates/account-layout.tsx | 43 + .../account/templates/login-template.tsx | 27 + .../components/cart-item-select/index.tsx | 73 + .../components/empty-cart-message/index.tsx | 30 + .../modules/cart/components/item/index.tsx | 140 + .../cart/components/sign-in-prompt/index.tsx | 26 + .../src/modules/cart/templates/index.tsx | 47 + .../src/modules/cart/templates/items.tsx | 57 + .../src/modules/cart/templates/preview.tsx | 51 + .../src/modules/cart/templates/summary.tsx | 48 + .../modules/categories/templates/index.tsx | 128 + .../components/address-select/index.tsx | 116 + .../checkout/components/addresses/index.tsx | 184 + .../components/billing_address/index.tsx | 114 + .../components/country-select/index.tsx | 50 + .../components/discount-code/index.tsx | 150 + .../components/error-message/index.tsx | 19 + .../payment-button/adyen-payment-button.tsx | 167 + .../components/payment-button/index.tsx | 212 + .../components/payment-container/index.tsx | 115 + .../components/payment-test/index.tsx | 12 + .../components/payment-wrapper/index.tsx | 65 + .../payment-wrapper/stripe-wrapper.tsx | 54 + .../checkout/components/payment/index.tsx | 258 + .../checkout/components/review/index.tsx | 57 + .../components/shipping-address/index.tsx | 258 + .../checkout/components/shipping/index.tsx | 411 + .../components/submit-button/index.tsx | 34 + .../templates/checkout-form/index.tsx | 38 + .../templates/checkout-summary/index.tsx | 31 + .../modules/collections/templates/index.tsx | 51 + .../common/components/cart-totals/index.tsx | 97 + .../common/components/checkbox/index.tsx | 42 + .../common/components/delete-button/index.tsx | 49 + .../common/components/divider/index.tsx | 9 + .../components/filter-radio-group/index.tsx | 61 + .../modules/common/components/input/index.tsx | 76 + .../components/interactive-link/index.tsx | 35 + .../components/line-item-options/index.tsx | 26 + .../components/line-item-price/index.tsx | 64 + .../components/line-item-unit-price/index.tsx | 62 + .../localized-client-link/index.tsx | 32 + .../modules/common/components/modal/index.tsx | 118 + .../common/components/native-select/index.tsx | 74 + .../modules/common/components/radio/index.tsx | 27 + .../modules/common/components/ui/index.tsx | 443 + .../src/modules/common/icons/back.tsx | 37 + .../src/modules/common/icons/bancontact.tsx | 26 + .../src/modules/common/icons/chevron-down.tsx | 30 + .../modules/common/icons/chevron-up-down.tsx | 38 + .../src/modules/common/icons/eye-off.tsx | 37 + .../src/modules/common/icons/eye.tsx | 37 + .../modules/common/icons/fast-delivery.tsx | 65 + .../src/modules/common/icons/ideal.tsx | 26 + .../src/modules/common/icons/map-pin.tsx | 37 + .../src/modules/common/icons/medusa.tsx | 27 + .../src/modules/common/icons/nextjs.tsx | 27 + .../src/modules/common/icons/package.tsx | 44 + .../src/modules/common/icons/paypal.tsx | 30 + .../common/icons/placeholder-image.tsx | 44 + .../src/modules/common/icons/refresh.tsx | 51 + .../src/modules/common/icons/spinner.tsx | 37 + .../src/modules/common/icons/trash.tsx | 51 + .../src/modules/common/icons/user.tsx | 37 + .../src/modules/common/icons/x.tsx | 37 + .../home/components/cta-banner/index.tsx | 51 + .../home/components/faq-section/index.tsx | 74 + .../components/featured-products/index.tsx | 16 + .../featured-products/product-rail/index.tsx | 54 + .../modules/home/components/hero/index.tsx | 93 + .../home/components/latest-news/index.tsx | 88 + .../home/components/mission-section/index.tsx | 102 + .../home/components/partners-ticker/index.tsx | 102 + .../components/product-showcase/index.tsx | 178 + .../layout/components/cart-button/index.tsx | 8 + .../layout/components/cart-dropdown/index.tsx | 390 + .../components/cart-mismatch-banner/index.tsx | 56 + .../components/country-select/index.tsx | 131 + .../components/language-select/index.tsx | 192 + .../layout/components/medusa-cta/index.tsx | 21 + .../layout/components/search/drawer.tsx | 70 + .../modules/layout/components/search/hit.tsx | 57 + .../layout/components/search/index.tsx | 150 + .../layout/components/side-menu/index.tsx | 108 + .../modules/layout/templates/footer/index.tsx | 175 + .../modules/layout/templates/nav/index.tsx | 109 + .../modules/order/components/help/index.tsx | 25 + .../modules/order/components/item/index.tsx | 57 + .../modules/order/components/items/index.tsx | 44 + .../order/components/onboarding-cta/index.tsx | 28 + .../order/components/order-details/index.tsx | 63 + .../order/components/order-summary/index.tsx | 60 + .../components/payment-details/index.tsx | 63 + .../components/shipping-details/index.tsx | 73 + .../components/transfer-actions/index.tsx | 81 + .../order/components/transfer-image/index.tsx | 275 + .../templates/order-completed-template.tsx | 52 + .../templates/order-details-template.tsx | 46 + .../src/modules/policies/templates/index.tsx | 50 + .../gallery-and-configurator/index.tsx | 115 + .../components/image-gallery/index.tsx | 43 + .../image-gallery/variant-image-gallery.tsx | 48 + .../components/inquiry-modal/index.tsx | 299 + .../components/product-actions/index.tsx | 416 + .../product-actions/mobile-actions.tsx | 210 + .../product-actions/option-select.tsx | 148 + .../product-onboarding-cta/index.tsx | 30 + .../components/product-preview/index.tsx | 113 + .../components/product-preview/price.tsx | 32 + .../components/product-price/index.tsx | 64 + .../components/product-tabs/accordion.tsx | 100 + .../components/product-tabs/index.tsx | 119 + .../components/related-products/index.tsx | 69 + .../products/components/thumbnail/index.tsx | 62 + .../umbrella-configurator/index.tsx | 522 + .../custom/prestige-custom-template.tsx | 335 + .../products/templates/custom/registry.ts | 70 + .../products/templates/custom/types.ts | 7 + .../src/modules/products/templates/index.tsx | 76 + .../products/templates/product-info/index.tsx | 47 + .../search/components/search-form/index.tsx | 41 + .../free-shipping-price-nudge/index.tsx | 284 + .../components/skeleton-button/index.tsx | 5 + .../skeleton-card-details/index.tsx | 10 + .../components/skeleton-cart-item/index.tsx | 35 + .../components/skeleton-cart-totals/index.tsx | 30 + .../components/skeleton-code-form/index.tsx | 13 + .../components/skeleton-line-item/index.tsx | 35 + .../skeleton-order-confirmed-header/index.tsx | 14 + .../skeleton-order-information/index.tsx | 36 + .../components/skeleton-order-items/index.tsx | 43 + .../skeleton-order-summary/index.tsx | 15 + .../skeleton-product-preview/index.tsx | 15 + .../templates/skeleton-cart-page/index.tsx | 65 + .../skeleton-order-confirmed/index.tsx | 21 + .../templates/skeleton-product-grid/index.tsx | 23 + .../skeleton-related-products/index.tsx | 25 + .../store/components/pagination/index.tsx | 108 + .../components/refinement-list/index.tsx | 83 + .../refinement-list/options-picker/index.tsx | 154 + .../refinement-list/sort-products/index.tsx | 48 + .../store/components/store-hits/index.tsx | 118 + .../components/store-hits/pagination.tsx | 60 + .../store/components/store-hits/price.tsx | 58 + .../store-refinements/attributes.ts | 28 + .../store-refinements/current-refinements.tsx | 110 + .../components/store-refinements/index.tsx | 48 + .../store-refinements/on-sale-toggle.tsx | 43 + .../store-refinements/option-refinements.tsx | 141 + .../store-refinements/price-range.tsx | 98 + .../store-refinements/refinement-group.tsx | 57 + .../components/store-search-box/index.tsx | 65 + .../src/modules/store/templates/index.tsx | 54 + .../store/templates/paginated-products.tsx | 96 + apps/suman-bosna/src/styles/globals.css | 79 + apps/suman-bosna/src/types/global.ts | 24 + apps/suman-bosna/src/types/icon.ts | 4 + apps/suman-bosna/tailwind.config.js | 86 + apps/suman-bosna/tsconfig.json | 57 + apps/suman-bosna/tsconfig.tsbuildinfo | 1 + apps/suman-hrvatska/.prettierrc.json | 3 + apps/suman-hrvatska/AGENTS.md | 9 + apps/suman-hrvatska/CLAUDE.md | 1 + apps/suman-hrvatska/check-env-variables.js | 40 + apps/suman-hrvatska/eslint.config.mjs | 31 + apps/suman-hrvatska/next-env.d.ts | 7 + apps/suman-hrvatska/next.config.js | 79 + apps/suman-hrvatska/package.json | 61 + apps/suman-hrvatska/postcss.config.js | 6 + apps/suman-hrvatska/public/favicon.ico | Bin 0 -> 25931 bytes apps/suman-hrvatska/public/logo.png | Bin 0 -> 61458 bytes .../src/app/.well-known/ucp/route.ts | 63 + .../(checkout)/checkout/page.tsx | 30 + .../app/[countryCode]/(checkout)/layout.tsx | 43 + .../[countryCode]/(checkout)/not-found.tsx | 19 + .../account/@dashboard/addresses/page.tsx | 38 + .../(main)/account/@dashboard/default.tsx | 3 + .../(main)/account/@dashboard/loading.tsx | 9 + .../@dashboard/orders/details/[id]/page.tsx | 33 + .../(main)/account/@dashboard/orders/page.tsx | 37 + .../(main)/account/@dashboard/page.tsx | 22 + .../account/@dashboard/profile/page.tsx | 51 + .../(main)/account/@login/default.tsx | 1 + .../(main)/account/@login/page.tsx | 12 + .../[countryCode]/(main)/account/layout.tsx | 20 + .../[countryCode]/(main)/account/loading.tsx | 9 + .../[countryCode]/(main)/cart/add/route.ts | 103 + .../app/[countryCode]/(main)/cart/loading.tsx | 5 + .../[countryCode]/(main)/cart/not-found.tsx | 21 + .../app/[countryCode]/(main)/cart/page.tsx | 21 + .../(main)/cart/resume/[cartId]/route.ts | 35 + .../(main)/categories/[...category]/page.tsx | 62 + .../(main)/collections/[handle]/page.tsx | 59 + .../app/[countryCode]/(main)/contact/page.tsx | 24 + .../src/app/[countryCode]/(main)/layout.tsx | 45 + .../app/[countryCode]/(main)/not-found.tsx | 20 + .../(main)/order/[id]/confirmed/loading.tsx | 5 + .../(main)/order/[id]/confirmed/page.tsx | 23 + .../[id]/transfer/[token]/accept/page.tsx | 41 + .../[id]/transfer/[token]/decline/page.tsx | 41 + .../order/[id]/transfer/[token]/page.tsx | 38 + .../src/app/[countryCode]/(main)/page.tsx | 99 + .../app/[countryCode]/(main)/privacy/page.tsx | 29 + .../products/[handle]/markdown/route.ts | 38 + .../(main)/products/[handle]/page.tsx | 145 + .../app/[countryCode]/(main)/returns/page.tsx | 39 + .../app/[countryCode]/(main)/search/page.tsx | 72 + .../[countryCode]/(main)/shipping/page.tsx | 42 + .../app/[countryCode]/(main)/store/page.tsx | 23 + .../app/[countryCode]/(main)/terms/page.tsx | 29 + .../(main)/verify-account/page.tsx | 25 + .../src/app/api/payment-return/route.ts | 103 + .../src/app/buy/[items]/route.ts | 72 + apps/suman-hrvatska/src/app/layout.tsx | 27 + apps/suman-hrvatska/src/app/llms.txt/route.ts | 72 + apps/suman-hrvatska/src/app/not-found.tsx | 27 + .../src/app/opengraph-image.jpg | Bin 0 -> 234193 bytes apps/suman-hrvatska/src/app/robots.ts | 21 + apps/suman-hrvatska/src/app/sitemap.ts | 72 + apps/suman-hrvatska/src/app/twitter-image.jpg | Bin 0 -> 234193 bytes apps/suman-hrvatska/src/app/ucp/mcp/route.ts | 6 + .../src/app/ucp/v1/cart/[cartId]/route.ts | 15 + .../src/app/ucp/v1/cart/route.ts | 11 + .../src/app/ucp/v1/catalog/lookup/route.ts | 5 + .../src/app/ucp/v1/catalog/search/route.ts | 5 + .../v1/checkout-sessions/[id]/cancel/route.ts | 7 + .../checkout-sessions/[id]/complete/route.ts | 7 + .../ucp/v1/checkout-sessions/[id]/route.ts | 12 + .../src/app/ucp/v1/checkout-sessions/route.ts | 11 + apps/suman-hrvatska/src/app/ucp/v1/route.ts | 26 + .../src/components/ui/section-header.tsx | 71 + apps/suman-hrvatska/src/lib/config.ts | 39 + apps/suman-hrvatska/src/lib/constants.tsx | 127 + .../src/lib/context/modal-context.tsx | 34 + apps/suman-hrvatska/src/lib/data/adyen.ts | 82 + apps/suman-hrvatska/src/lib/data/cart.ts | 473 + .../suman-hrvatska/src/lib/data/categories.ts | 49 + .../src/lib/data/collections.ts | 59 + apps/suman-hrvatska/src/lib/data/cookies.ts | 140 + apps/suman-hrvatska/src/lib/data/customer.ts | 381 + .../src/lib/data/fulfillment.ts | 68 + .../src/lib/data/locale-actions.ts | 74 + apps/suman-hrvatska/src/lib/data/locales.ts | 28 + .../suman-hrvatska/src/lib/data/onboarding.ts | 9 + apps/suman-hrvatska/src/lib/data/orders.ts | 112 + apps/suman-hrvatska/src/lib/data/payment.ts | 35 + apps/suman-hrvatska/src/lib/data/products.ts | 151 + apps/suman-hrvatska/src/lib/data/regions.ts | 59 + .../src/lib/data/store-policies.ts | 20 + apps/suman-hrvatska/src/lib/data/variants.ts | 38 + .../src/lib/hooks/use-in-view.tsx | 29 + .../src/lib/hooks/use-search-settled.tsx | 31 + .../src/lib/hooks/use-toggle-state.tsx | 46 + apps/suman-hrvatska/src/lib/search-client.ts | 57 + apps/suman-hrvatska/src/lib/ucp/mcp.ts | 236 + apps/suman-hrvatska/src/lib/ucp/operations.ts | 547 + apps/suman-hrvatska/src/lib/ucp/ucp.ts | 203 + .../src/lib/util/cart-events.ts | 6 + .../src/lib/util/compare-addresses.ts | 28 + apps/suman-hrvatska/src/lib/util/env.ts | 3 + .../src/lib/util/get-locale-header.ts | 8 + .../src/lib/util/get-percentage-diff.ts | 6 + .../src/lib/util/get-product-price.ts | 90 + apps/suman-hrvatska/src/lib/util/inventory.ts | 9 + apps/suman-hrvatska/src/lib/util/isEmpty.ts | 11 + .../src/lib/util/medusa-error.ts | 33 + apps/suman-hrvatska/src/lib/util/money.ts | 26 + .../src/lib/util/payment-error.ts | 21 + .../src/lib/util/product-markdown.ts | 77 + .../src/lib/util/product-option-filters.ts | 26 + .../src/lib/util/product-structured-data.ts | 107 + apps/suman-hrvatska/src/lib/util/product.ts | 5 + apps/suman-hrvatska/src/lib/util/repeat.ts | 5 + .../src/lib/util/server-cart.ts | 53 + apps/suman-hrvatska/src/lib/util/site.ts | 50 + .../src/lib/util/sort-products.ts | 50 + .../src/lib/util/store-policies.ts | 103 + apps/suman-hrvatska/src/middleware.ts | 133 + .../account/components/account-info/index.tsx | 139 + .../account/components/account-nav/index.tsx | 199 + .../account/components/address-book/index.tsx | 28 + .../components/address-card/add-address.tsx | 165 + .../address-card/edit-address-modal.tsx | 237 + .../account/components/login/index.tsx | 76 + .../account/components/order-card/index.tsx | 87 + .../components/order-overview/index.tsx | 45 + .../account/components/overview/index.tsx | 168 + .../profile-billing-address/index.tsx | 191 + .../components/profile-email/index.tsx | 71 + .../account/components/profile-name/index.tsx | 79 + .../components/profile-password/index.tsx | 71 + .../components/profile-phone/index.tsx | 74 + .../account/components/register/index.tsx | 118 + .../transfer-request-form/index.tsx | 81 + .../components/verify-account/index.tsx | 74 + .../account/templates/account-layout.tsx | 43 + .../account/templates/login-template.tsx | 27 + .../components/cart-item-select/index.tsx | 73 + .../components/empty-cart-message/index.tsx | 25 + .../modules/cart/components/item/index.tsx | 144 + .../cart/components/sign-in-prompt/index.tsx | 26 + .../src/modules/cart/templates/index.tsx | 51 + .../src/modules/cart/templates/items.tsx | 57 + .../src/modules/cart/templates/preview.tsx | 51 + .../src/modules/cart/templates/summary.tsx | 46 + .../modules/categories/templates/index.tsx | 105 + .../components/address-select/index.tsx | 116 + .../checkout/components/addresses/index.tsx | 184 + .../components/billing_address/index.tsx | 114 + .../components/country-select/index.tsx | 50 + .../components/discount-code/index.tsx | 176 + .../components/error-message/index.tsx | 13 + .../payment-button/adyen-payment-button.tsx | 167 + .../components/payment-button/index.tsx | 212 + .../components/payment-container/index.tsx | 115 + .../components/payment-test/index.tsx | 12 + .../components/payment-wrapper/index.tsx | 65 + .../payment-wrapper/stripe-wrapper.tsx | 54 + .../checkout/components/payment/index.tsx | 258 + .../checkout/components/review/index.tsx | 57 + .../components/shipping-address/index.tsx | 221 + .../checkout/components/shipping/index.tsx | 411 + .../components/submit-button/index.tsx | 34 + .../templates/checkout-form/index.tsx | 38 + .../templates/checkout-summary/index.tsx | 31 + .../modules/collections/templates/index.tsx | 51 + .../common/components/cart-totals/index.tsx | 82 + .../common/components/checkbox/index.tsx | 42 + .../common/components/delete-button/index.tsx | 45 + .../common/components/divider/index.tsx | 9 + .../components/filter-radio-group/index.tsx | 60 + .../modules/common/components/input/index.tsx | 76 + .../components/interactive-link/index.tsx | 32 + .../components/line-item-options/index.tsx | 26 + .../components/line-item-price/index.tsx | 64 + .../components/line-item-unit-price/index.tsx | 62 + .../localized-client-link/index.tsx | 32 + .../modules/common/components/modal/index.tsx | 118 + .../common/components/native-select/index.tsx | 74 + .../modules/common/components/radio/index.tsx | 27 + .../modules/common/components/ui/index.tsx | 427 + .../src/modules/common/icons/back.tsx | 37 + .../src/modules/common/icons/bancontact.tsx | 26 + .../src/modules/common/icons/chevron-down.tsx | 30 + .../modules/common/icons/chevron-up-down.tsx | 38 + .../src/modules/common/icons/eye-off.tsx | 37 + .../src/modules/common/icons/eye.tsx | 37 + .../modules/common/icons/fast-delivery.tsx | 65 + .../src/modules/common/icons/ideal.tsx | 26 + .../src/modules/common/icons/map-pin.tsx | 37 + .../src/modules/common/icons/medusa.tsx | 27 + .../src/modules/common/icons/nextjs.tsx | 27 + .../src/modules/common/icons/package.tsx | 44 + .../src/modules/common/icons/paypal.tsx | 30 + .../common/icons/placeholder-image.tsx | 44 + .../src/modules/common/icons/refresh.tsx | 51 + .../src/modules/common/icons/spinner.tsx | 37 + .../src/modules/common/icons/trash.tsx | 51 + .../src/modules/common/icons/user.tsx | 37 + .../src/modules/common/icons/x.tsx | 37 + .../components/featured-products/index.tsx | 16 + .../featured-products/product-rail/index.tsx | 47 + .../modules/home/components/hero/index.tsx | 31 + .../layout/components/cart-button/index.tsx | 8 + .../layout/components/cart-dropdown/index.tsx | 258 + .../components/cart-mismatch-banner/index.tsx | 56 + .../components/country-select/index.tsx | 131 + .../components/language-select/index.tsx | 192 + .../layout/components/medusa-cta/index.tsx | 21 + .../layout/components/search/drawer.tsx | 70 + .../modules/layout/components/search/hit.tsx | 58 + .../layout/components/search/index.tsx | 152 + .../layout/components/side-menu/index.tsx | 149 + .../modules/layout/templates/footer/index.tsx | 215 + .../modules/layout/templates/nav/index.tsx | 68 + .../modules/order/components/help/index.tsx | 25 + .../modules/order/components/item/index.tsx | 57 + .../modules/order/components/items/index.tsx | 44 + .../order/components/onboarding-cta/index.tsx | 28 + .../order/components/order-details/index.tsx | 63 + .../order/components/order-summary/index.tsx | 60 + .../components/payment-details/index.tsx | 63 + .../components/shipping-details/index.tsx | 73 + .../components/transfer-actions/index.tsx | 81 + .../order/components/transfer-image/index.tsx | 275 + .../templates/order-completed-template.tsx | 52 + .../templates/order-details-template.tsx | 46 + .../src/modules/policies/templates/index.tsx | 50 + .../components/image-gallery/index.tsx | 41 + .../image-gallery/variant-image-gallery.tsx | 48 + .../components/product-actions/index.tsx | 228 + .../product-actions/mobile-actions.tsx | 207 + .../product-actions/option-select.tsx | 68 + .../product-onboarding-cta/index.tsx | 30 + .../components/product-preview/index.tsx | 51 + .../components/product-preview/price.tsx | 29 + .../components/product-price/index.tsx | 58 + .../components/product-tabs/accordion.tsx | 100 + .../components/product-tabs/index.tsx | 175 + .../components/related-products/index.tsx | 69 + .../products/components/thumbnail/index.tsx | 72 + .../src/modules/products/templates/index.tsx | 58 + .../products/templates/product-info/index.tsx | 40 + .../search/components/search-form/index.tsx | 41 + .../free-shipping-price-nudge/index.tsx | 284 + .../components/skeleton-button/index.tsx | 5 + .../skeleton-card-details/index.tsx | 10 + .../components/skeleton-cart-item/index.tsx | 35 + .../components/skeleton-cart-totals/index.tsx | 30 + .../components/skeleton-code-form/index.tsx | 13 + .../components/skeleton-line-item/index.tsx | 35 + .../skeleton-order-confirmed-header/index.tsx | 14 + .../skeleton-order-information/index.tsx | 36 + .../components/skeleton-order-items/index.tsx | 43 + .../skeleton-order-summary/index.tsx | 15 + .../skeleton-product-preview/index.tsx | 15 + .../templates/skeleton-cart-page/index.tsx | 65 + .../skeleton-order-confirmed/index.tsx | 21 + .../templates/skeleton-product-grid/index.tsx | 23 + .../skeleton-related-products/index.tsx | 25 + .../store/components/pagination/index.tsx | 114 + .../components/refinement-list/index.tsx | 83 + .../refinement-list/options-picker/index.tsx | 162 + .../refinement-list/sort-products/index.tsx | 48 + .../store/components/store-hits/index.tsx | 109 + .../components/store-hits/pagination.tsx | 55 + .../store/components/store-hits/price.tsx | 58 + .../store-refinements/attributes.ts | 28 + .../store-refinements/current-refinements.tsx | 122 + .../components/store-refinements/index.tsx | 46 + .../store-refinements/on-sale-toggle.tsx | 43 + .../store-refinements/option-refinements.tsx | 147 + .../store-refinements/price-range.tsx | 98 + .../store-refinements/refinement-group.tsx | 57 + .../components/store-search-box/index.tsx | 72 + .../src/modules/store/templates/index.tsx | 42 + .../store/templates/paginated-products.tsx | 96 + apps/suman-hrvatska/src/styles/globals.css | 112 + apps/suman-hrvatska/src/types/global.ts | 24 + apps/suman-hrvatska/src/types/icon.ts | 4 + apps/suman-hrvatska/tailwind.config.js | 161 + apps/suman-hrvatska/tsconfig.json | 54 + apps/suman-hrvatska/tsconfig.tsbuildinfo | 1 + docker-compose.yml | 29 + docs/TEHNICKA_DOKUMENTACIJA.md | 299 + .../FAZA-01-hr-webshop-sinhronizacija.md | 79 + .../FAZA-02-prodajni-scenariji-i-upiti.md | 179 + ...03-dinamicki-2d-konfigurator-suncobrana.md | 159 + ...tava-licno-preuzimanje-i-r1-pravna-lica.md | 103 + ...FAZA-05-placanja-kartice-virman-pouzece.md | 81 + ...AZA-06-medusa-admin-nabavka-i-izolacija.md | 87 + ...tiranje-soft-opening-i-korporativni-web.md | 75 + docs/faze-implementacije/README.md | 33 + docs/implementation-plan/README.md | 58 + .../phase-01-infrastructure-and-monorepo.md | 191 + .../phase-02-multichannel-core-and-seeding.md | 245 + .../phase-03-admin-isolation-by-country.md | 163 + .../phase-04-crm-b2b-and-admin-widgets.md | 323 + .../phase-05-storefronts-and-next-intl.md | 214 + .../phase-06-umbrella-catalog-and-specs.md | 154 + ...-07-testing-verification-and-deployment.md | 110 + eslint.config.ts | 4 + package-lock.json | 31646 ++++++++++++++++ package.json | 49 + turbo.json | 25 + 693 files changed, 82975 insertions(+) create mode 100644 .gitignore create mode 100644 .npmrc create mode 100644 AGENTS.md create mode 100644 ANALIZA_PROJEKTA_SUMAN.md create mode 100644 CLAUDE.md create mode 100644 LICENSE create mode 100644 README.md create mode 100644 apps/backend/.env.template create mode 100644 apps/backend/.gitignore create mode 100644 apps/backend/README.md create mode 100644 apps/backend/eslint.config.ts create mode 100644 apps/backend/instrumentation.ts create mode 100644 apps/backend/integration-tests/setup.js create mode 100644 apps/backend/jest.config.js create mode 100644 apps/backend/medusa-config.ts create mode 100644 apps/backend/package.json create mode 100644 apps/backend/src/admin/README.md create mode 100644 apps/backend/src/admin/i18n/README.md create mode 100644 apps/backend/src/admin/i18n/index.ts create mode 100644 apps/backend/src/admin/lib/client.ts create mode 100644 apps/backend/src/admin/routes/inquiries/page.tsx create mode 100644 apps/backend/src/admin/tsconfig.json create mode 100644 apps/backend/src/admin/vite-env.d.ts create mode 100644 apps/backend/src/admin/widgets/customer-crm-widget.tsx create mode 100644 apps/backend/src/admin/widgets/product-inquiry-widget.tsx create mode 100644 apps/backend/src/api/README.md create mode 100644 apps/backend/src/api/admin/custom/route.ts create mode 100644 apps/backend/src/api/admin/inquiries/[id]/route.ts create mode 100644 apps/backend/src/api/admin/inquiries/route.ts create mode 100644 apps/backend/src/api/middlewares.ts create mode 100644 apps/backend/src/api/store/custom/route.ts create mode 100644 apps/backend/src/api/store/inquiries/route.ts create mode 100644 apps/backend/src/api/store/inquiries/validators.ts create mode 100644 apps/backend/src/jobs/README.md create mode 100644 apps/backend/src/lib/region-store-policies.ts create mode 100644 apps/backend/src/links/README.md create mode 100644 apps/backend/src/links/inquiry-product.ts create mode 100644 apps/backend/src/links/inquiry-sales-channel.ts create mode 100644 apps/backend/src/migration-scripts/initial-data-seed.ts create mode 100644 apps/backend/src/migration-scripts/region-store-policies.ts create mode 100644 apps/backend/src/modules/README.md create mode 100644 apps/backend/src/modules/inquiry/index.ts create mode 100644 apps/backend/src/modules/inquiry/migrations/.snapshot-inquiry.json create mode 100644 apps/backend/src/modules/inquiry/migrations/Migration20261109151942.ts create mode 100644 apps/backend/src/modules/inquiry/models/inquiry.ts create mode 100644 apps/backend/src/modules/inquiry/service.ts create mode 100644 apps/backend/src/scripts/cleanup-keep-ba-hr-only.ts create mode 100644 apps/backend/src/scripts/seed-demo-products.ts create mode 100644 apps/backend/src/scripts/setup-b2b-pricing.ts create mode 100644 apps/backend/src/scripts/setup-suman-ba.ts create mode 100644 apps/backend/src/scripts/setup-suman-hr.ts create mode 100644 apps/backend/src/scripts/setup-umbrella-platform.ts create mode 100644 apps/backend/src/scripts/update-product-scenarios.ts create mode 100644 apps/backend/src/search/helpers/option-values.ts create mode 100644 apps/backend/src/search/helpers/pricing.ts create mode 100644 apps/backend/src/search/helpers/resolve-product-ids.ts create mode 100644 apps/backend/src/search/product.ts create mode 100644 apps/backend/src/subscribers/README.md create mode 100644 apps/backend/src/subscribers/b2b-order-crm.ts create mode 100644 apps/backend/src/workflows/README.md create mode 100644 apps/backend/src/workflows/inquiry/index.ts create mode 100644 apps/backend/tsconfig.json create mode 100644 apps/suman-bosna/.prettierrc.json create mode 100644 apps/suman-bosna/AGENTS.md create mode 100644 apps/suman-bosna/CLAUDE.md create mode 100644 apps/suman-bosna/check-env-variables.js create mode 100644 apps/suman-bosna/components.json create mode 100644 apps/suman-bosna/eslint.config.mjs create mode 100644 apps/suman-bosna/next-env.d.ts create mode 100644 apps/suman-bosna/next.config.js create mode 100644 apps/suman-bosna/package.json create mode 100644 apps/suman-bosna/postcss.config.js create mode 100644 apps/suman-bosna/public/Pergola_transitioning_from_day_t…_bdaf7175_1080 p.mp4 create mode 100644 apps/suman-bosna/public/favicon.ico create mode 100644 apps/suman-bosna/public/logo.png create mode 120000 apps/suman-bosna/public/pergola-hero.mp4 create mode 100644 apps/suman-bosna/src/app/.well-known/ucp/route.ts create mode 100644 apps/suman-bosna/src/app/[countryCode]/(checkout)/checkout/page.tsx create mode 100644 apps/suman-bosna/src/app/[countryCode]/(checkout)/layout.tsx create mode 100644 apps/suman-bosna/src/app/[countryCode]/(checkout)/not-found.tsx create mode 100644 apps/suman-bosna/src/app/[countryCode]/(main)/account/@dashboard/addresses/page.tsx create mode 100644 apps/suman-bosna/src/app/[countryCode]/(main)/account/@dashboard/default.tsx create mode 100644 apps/suman-bosna/src/app/[countryCode]/(main)/account/@dashboard/loading.tsx create mode 100644 apps/suman-bosna/src/app/[countryCode]/(main)/account/@dashboard/orders/details/[id]/page.tsx create mode 100644 apps/suman-bosna/src/app/[countryCode]/(main)/account/@dashboard/orders/page.tsx create mode 100644 apps/suman-bosna/src/app/[countryCode]/(main)/account/@dashboard/page.tsx create mode 100644 apps/suman-bosna/src/app/[countryCode]/(main)/account/@dashboard/profile/page.tsx create mode 100644 apps/suman-bosna/src/app/[countryCode]/(main)/account/@login/default.tsx create mode 100644 apps/suman-bosna/src/app/[countryCode]/(main)/account/@login/page.tsx create mode 100644 apps/suman-bosna/src/app/[countryCode]/(main)/account/layout.tsx create mode 100644 apps/suman-bosna/src/app/[countryCode]/(main)/account/loading.tsx create mode 100644 apps/suman-bosna/src/app/[countryCode]/(main)/cart/add/route.ts create mode 100644 apps/suman-bosna/src/app/[countryCode]/(main)/cart/loading.tsx create mode 100644 apps/suman-bosna/src/app/[countryCode]/(main)/cart/not-found.tsx create mode 100644 apps/suman-bosna/src/app/[countryCode]/(main)/cart/page.tsx create mode 100644 apps/suman-bosna/src/app/[countryCode]/(main)/cart/resume/[cartId]/route.ts create mode 100644 apps/suman-bosna/src/app/[countryCode]/(main)/categories/[...category]/page.tsx create mode 100644 apps/suman-bosna/src/app/[countryCode]/(main)/collections/[handle]/page.tsx create mode 100644 apps/suman-bosna/src/app/[countryCode]/(main)/contact/page.tsx create mode 100644 apps/suman-bosna/src/app/[countryCode]/(main)/layout.tsx create mode 100644 apps/suman-bosna/src/app/[countryCode]/(main)/not-found.tsx create mode 100644 apps/suman-bosna/src/app/[countryCode]/(main)/order/[id]/confirmed/loading.tsx create mode 100644 apps/suman-bosna/src/app/[countryCode]/(main)/order/[id]/confirmed/page.tsx create mode 100644 apps/suman-bosna/src/app/[countryCode]/(main)/order/[id]/transfer/[token]/accept/page.tsx create mode 100644 apps/suman-bosna/src/app/[countryCode]/(main)/order/[id]/transfer/[token]/decline/page.tsx create mode 100644 apps/suman-bosna/src/app/[countryCode]/(main)/order/[id]/transfer/[token]/page.tsx create mode 100644 apps/suman-bosna/src/app/[countryCode]/(main)/page.tsx create mode 100644 apps/suman-bosna/src/app/[countryCode]/(main)/privacy/page.tsx create mode 100644 apps/suman-bosna/src/app/[countryCode]/(main)/products/[handle]/markdown/route.ts create mode 100644 apps/suman-bosna/src/app/[countryCode]/(main)/products/[handle]/page.tsx create mode 100644 apps/suman-bosna/src/app/[countryCode]/(main)/returns/page.tsx create mode 100644 apps/suman-bosna/src/app/[countryCode]/(main)/search/page.tsx create mode 100644 apps/suman-bosna/src/app/[countryCode]/(main)/shipping/page.tsx create mode 100644 apps/suman-bosna/src/app/[countryCode]/(main)/store/page.tsx create mode 100644 apps/suman-bosna/src/app/[countryCode]/(main)/terms/page.tsx create mode 100644 apps/suman-bosna/src/app/[countryCode]/(main)/verify-account/page.tsx create mode 100644 apps/suman-bosna/src/app/api/payment-return/route.ts create mode 100644 apps/suman-bosna/src/app/buy/[items]/route.ts create mode 100644 apps/suman-bosna/src/app/layout.tsx create mode 100644 apps/suman-bosna/src/app/llms.txt/route.ts create mode 100644 apps/suman-bosna/src/app/not-found.tsx create mode 100644 apps/suman-bosna/src/app/opengraph-image.jpg create mode 100644 apps/suman-bosna/src/app/robots.ts create mode 100644 apps/suman-bosna/src/app/sitemap.ts create mode 100644 apps/suman-bosna/src/app/twitter-image.jpg create mode 100644 apps/suman-bosna/src/app/ucp/mcp/route.ts create mode 100644 apps/suman-bosna/src/app/ucp/v1/cart/[cartId]/route.ts create mode 100644 apps/suman-bosna/src/app/ucp/v1/cart/route.ts create mode 100644 apps/suman-bosna/src/app/ucp/v1/catalog/lookup/route.ts create mode 100644 apps/suman-bosna/src/app/ucp/v1/catalog/search/route.ts create mode 100644 apps/suman-bosna/src/app/ucp/v1/checkout-sessions/[id]/cancel/route.ts create mode 100644 apps/suman-bosna/src/app/ucp/v1/checkout-sessions/[id]/complete/route.ts create mode 100644 apps/suman-bosna/src/app/ucp/v1/checkout-sessions/[id]/route.ts create mode 100644 apps/suman-bosna/src/app/ucp/v1/checkout-sessions/route.ts create mode 100644 apps/suman-bosna/src/app/ucp/v1/route.ts create mode 100644 apps/suman-bosna/src/components/ui/accordion.tsx create mode 100644 apps/suman-bosna/src/components/ui/badge.tsx create mode 100644 apps/suman-bosna/src/components/ui/button.tsx create mode 100644 apps/suman-bosna/src/components/ui/card.tsx create mode 100644 apps/suman-bosna/src/components/ui/dialog.tsx create mode 100644 apps/suman-bosna/src/components/ui/dropdown-menu.tsx create mode 100644 apps/suman-bosna/src/components/ui/dynamic-icon.tsx create mode 100644 apps/suman-bosna/src/components/ui/input.tsx create mode 100644 apps/suman-bosna/src/components/ui/label.tsx create mode 100644 apps/suman-bosna/src/components/ui/logo.tsx create mode 100644 apps/suman-bosna/src/components/ui/section-header.tsx create mode 100644 apps/suman-bosna/src/components/ui/separator.tsx create mode 100644 apps/suman-bosna/src/components/ui/sheet.tsx create mode 100644 apps/suman-bosna/src/components/ui/skeleton.tsx create mode 100644 apps/suman-bosna/src/components/ui/table.tsx create mode 100644 apps/suman-bosna/src/components/ui/tabs.tsx create mode 100644 apps/suman-bosna/src/config/banner.json create mode 100644 apps/suman-bosna/src/config/faq.json create mode 100644 apps/suman-bosna/src/config/footer.json create mode 100644 apps/suman-bosna/src/config/hero.json create mode 100644 apps/suman-bosna/src/config/mission.json create mode 100644 apps/suman-bosna/src/config/navigation.json create mode 100644 apps/suman-bosna/src/config/news.json create mode 100644 apps/suman-bosna/src/config/partners.json create mode 100644 apps/suman-bosna/src/config/product-tabs.json create mode 100644 apps/suman-bosna/src/config/products-showcase.json create mode 100644 apps/suman-bosna/src/config/site.json create mode 100644 apps/suman-bosna/src/lib/config.ts create mode 100644 apps/suman-bosna/src/lib/constants.tsx create mode 100644 apps/suman-bosna/src/lib/context/modal-context.tsx create mode 100644 apps/suman-bosna/src/lib/data/adyen.ts create mode 100644 apps/suman-bosna/src/lib/data/cart.ts create mode 100644 apps/suman-bosna/src/lib/data/categories.ts create mode 100644 apps/suman-bosna/src/lib/data/collections.ts create mode 100644 apps/suman-bosna/src/lib/data/cookies.ts create mode 100644 apps/suman-bosna/src/lib/data/customer.ts create mode 100644 apps/suman-bosna/src/lib/data/fulfillment.ts create mode 100644 apps/suman-bosna/src/lib/data/inquiries.ts create mode 100644 apps/suman-bosna/src/lib/data/locale-actions.ts create mode 100644 apps/suman-bosna/src/lib/data/locales.ts create mode 100644 apps/suman-bosna/src/lib/data/onboarding.ts create mode 100644 apps/suman-bosna/src/lib/data/orders.ts create mode 100644 apps/suman-bosna/src/lib/data/payment.ts create mode 100644 apps/suman-bosna/src/lib/data/products.ts create mode 100644 apps/suman-bosna/src/lib/data/regions.ts create mode 100644 apps/suman-bosna/src/lib/data/store-policies.ts create mode 100644 apps/suman-bosna/src/lib/data/variants.ts create mode 100644 apps/suman-bosna/src/lib/hooks/use-in-view.tsx create mode 100644 apps/suman-bosna/src/lib/hooks/use-search-settled.tsx create mode 100644 apps/suman-bosna/src/lib/hooks/use-toggle-state.tsx create mode 100644 apps/suman-bosna/src/lib/search-client.ts create mode 100644 apps/suman-bosna/src/lib/ucp/mcp.ts create mode 100644 apps/suman-bosna/src/lib/ucp/operations.ts create mode 100644 apps/suman-bosna/src/lib/ucp/ucp.ts create mode 100644 apps/suman-bosna/src/lib/util/cart-events.ts create mode 100644 apps/suman-bosna/src/lib/util/compare-addresses.ts create mode 100644 apps/suman-bosna/src/lib/util/env.ts create mode 100644 apps/suman-bosna/src/lib/util/get-locale-header.ts create mode 100644 apps/suman-bosna/src/lib/util/get-percentage-diff.ts create mode 100644 apps/suman-bosna/src/lib/util/get-product-price.ts create mode 100644 apps/suman-bosna/src/lib/util/inventory.ts create mode 100644 apps/suman-bosna/src/lib/util/isEmpty.ts create mode 100644 apps/suman-bosna/src/lib/util/medusa-error.ts create mode 100644 apps/suman-bosna/src/lib/util/money.ts create mode 100644 apps/suman-bosna/src/lib/util/payment-error.ts create mode 100644 apps/suman-bosna/src/lib/util/product-markdown.ts create mode 100644 apps/suman-bosna/src/lib/util/product-option-filters.ts create mode 100644 apps/suman-bosna/src/lib/util/product-structured-data.ts create mode 100644 apps/suman-bosna/src/lib/util/product.ts create mode 100644 apps/suman-bosna/src/lib/util/repeat.ts create mode 100644 apps/suman-bosna/src/lib/util/server-cart.ts create mode 100644 apps/suman-bosna/src/lib/util/site.ts create mode 100644 apps/suman-bosna/src/lib/util/sort-products.ts create mode 100644 apps/suman-bosna/src/lib/util/store-policies.ts create mode 100644 apps/suman-bosna/src/lib/utils.ts create mode 100644 apps/suman-bosna/src/middleware.ts create mode 100644 apps/suman-bosna/src/modules/account/components/account-info/index.tsx create mode 100644 apps/suman-bosna/src/modules/account/components/account-nav/index.tsx create mode 100644 apps/suman-bosna/src/modules/account/components/address-book/index.tsx create mode 100644 apps/suman-bosna/src/modules/account/components/address-card/add-address.tsx create mode 100644 apps/suman-bosna/src/modules/account/components/address-card/edit-address-modal.tsx create mode 100644 apps/suman-bosna/src/modules/account/components/login/index.tsx create mode 100644 apps/suman-bosna/src/modules/account/components/order-card/index.tsx create mode 100644 apps/suman-bosna/src/modules/account/components/order-overview/index.tsx create mode 100644 apps/suman-bosna/src/modules/account/components/overview/index.tsx create mode 100644 apps/suman-bosna/src/modules/account/components/profile-billing-address/index.tsx create mode 100644 apps/suman-bosna/src/modules/account/components/profile-email/index.tsx create mode 100644 apps/suman-bosna/src/modules/account/components/profile-name/index.tsx create mode 100644 apps/suman-bosna/src/modules/account/components/profile-password/index.tsx create mode 100644 apps/suman-bosna/src/modules/account/components/profile-phone/index.tsx create mode 100644 apps/suman-bosna/src/modules/account/components/register/index.tsx create mode 100644 apps/suman-bosna/src/modules/account/components/transfer-request-form/index.tsx create mode 100644 apps/suman-bosna/src/modules/account/components/verify-account/index.tsx create mode 100644 apps/suman-bosna/src/modules/account/templates/account-layout.tsx create mode 100644 apps/suman-bosna/src/modules/account/templates/login-template.tsx create mode 100644 apps/suman-bosna/src/modules/cart/components/cart-item-select/index.tsx create mode 100644 apps/suman-bosna/src/modules/cart/components/empty-cart-message/index.tsx create mode 100644 apps/suman-bosna/src/modules/cart/components/item/index.tsx create mode 100644 apps/suman-bosna/src/modules/cart/components/sign-in-prompt/index.tsx create mode 100644 apps/suman-bosna/src/modules/cart/templates/index.tsx create mode 100644 apps/suman-bosna/src/modules/cart/templates/items.tsx create mode 100644 apps/suman-bosna/src/modules/cart/templates/preview.tsx create mode 100644 apps/suman-bosna/src/modules/cart/templates/summary.tsx create mode 100644 apps/suman-bosna/src/modules/categories/templates/index.tsx create mode 100644 apps/suman-bosna/src/modules/checkout/components/address-select/index.tsx create mode 100644 apps/suman-bosna/src/modules/checkout/components/addresses/index.tsx create mode 100644 apps/suman-bosna/src/modules/checkout/components/billing_address/index.tsx create mode 100644 apps/suman-bosna/src/modules/checkout/components/country-select/index.tsx create mode 100644 apps/suman-bosna/src/modules/checkout/components/discount-code/index.tsx create mode 100644 apps/suman-bosna/src/modules/checkout/components/error-message/index.tsx create mode 100644 apps/suman-bosna/src/modules/checkout/components/payment-button/adyen-payment-button.tsx create mode 100644 apps/suman-bosna/src/modules/checkout/components/payment-button/index.tsx create mode 100644 apps/suman-bosna/src/modules/checkout/components/payment-container/index.tsx create mode 100644 apps/suman-bosna/src/modules/checkout/components/payment-test/index.tsx create mode 100644 apps/suman-bosna/src/modules/checkout/components/payment-wrapper/index.tsx create mode 100644 apps/suman-bosna/src/modules/checkout/components/payment-wrapper/stripe-wrapper.tsx create mode 100644 apps/suman-bosna/src/modules/checkout/components/payment/index.tsx create mode 100644 apps/suman-bosna/src/modules/checkout/components/review/index.tsx create mode 100644 apps/suman-bosna/src/modules/checkout/components/shipping-address/index.tsx create mode 100644 apps/suman-bosna/src/modules/checkout/components/shipping/index.tsx create mode 100644 apps/suman-bosna/src/modules/checkout/components/submit-button/index.tsx create mode 100644 apps/suman-bosna/src/modules/checkout/templates/checkout-form/index.tsx create mode 100644 apps/suman-bosna/src/modules/checkout/templates/checkout-summary/index.tsx create mode 100644 apps/suman-bosna/src/modules/collections/templates/index.tsx create mode 100644 apps/suman-bosna/src/modules/common/components/cart-totals/index.tsx create mode 100644 apps/suman-bosna/src/modules/common/components/checkbox/index.tsx create mode 100644 apps/suman-bosna/src/modules/common/components/delete-button/index.tsx create mode 100644 apps/suman-bosna/src/modules/common/components/divider/index.tsx create mode 100644 apps/suman-bosna/src/modules/common/components/filter-radio-group/index.tsx create mode 100644 apps/suman-bosna/src/modules/common/components/input/index.tsx create mode 100644 apps/suman-bosna/src/modules/common/components/interactive-link/index.tsx create mode 100644 apps/suman-bosna/src/modules/common/components/line-item-options/index.tsx create mode 100644 apps/suman-bosna/src/modules/common/components/line-item-price/index.tsx create mode 100644 apps/suman-bosna/src/modules/common/components/line-item-unit-price/index.tsx create mode 100644 apps/suman-bosna/src/modules/common/components/localized-client-link/index.tsx create mode 100644 apps/suman-bosna/src/modules/common/components/modal/index.tsx create mode 100644 apps/suman-bosna/src/modules/common/components/native-select/index.tsx create mode 100644 apps/suman-bosna/src/modules/common/components/radio/index.tsx create mode 100644 apps/suman-bosna/src/modules/common/components/ui/index.tsx create mode 100644 apps/suman-bosna/src/modules/common/icons/back.tsx create mode 100644 apps/suman-bosna/src/modules/common/icons/bancontact.tsx create mode 100644 apps/suman-bosna/src/modules/common/icons/chevron-down.tsx create mode 100644 apps/suman-bosna/src/modules/common/icons/chevron-up-down.tsx create mode 100644 apps/suman-bosna/src/modules/common/icons/eye-off.tsx create mode 100644 apps/suman-bosna/src/modules/common/icons/eye.tsx create mode 100644 apps/suman-bosna/src/modules/common/icons/fast-delivery.tsx create mode 100644 apps/suman-bosna/src/modules/common/icons/ideal.tsx create mode 100644 apps/suman-bosna/src/modules/common/icons/map-pin.tsx create mode 100644 apps/suman-bosna/src/modules/common/icons/medusa.tsx create mode 100644 apps/suman-bosna/src/modules/common/icons/nextjs.tsx create mode 100644 apps/suman-bosna/src/modules/common/icons/package.tsx create mode 100644 apps/suman-bosna/src/modules/common/icons/paypal.tsx create mode 100644 apps/suman-bosna/src/modules/common/icons/placeholder-image.tsx create mode 100644 apps/suman-bosna/src/modules/common/icons/refresh.tsx create mode 100644 apps/suman-bosna/src/modules/common/icons/spinner.tsx create mode 100644 apps/suman-bosna/src/modules/common/icons/trash.tsx create mode 100644 apps/suman-bosna/src/modules/common/icons/user.tsx create mode 100644 apps/suman-bosna/src/modules/common/icons/x.tsx create mode 100644 apps/suman-bosna/src/modules/home/components/cta-banner/index.tsx create mode 100644 apps/suman-bosna/src/modules/home/components/faq-section/index.tsx create mode 100644 apps/suman-bosna/src/modules/home/components/featured-products/index.tsx create mode 100644 apps/suman-bosna/src/modules/home/components/featured-products/product-rail/index.tsx create mode 100644 apps/suman-bosna/src/modules/home/components/hero/index.tsx create mode 100644 apps/suman-bosna/src/modules/home/components/latest-news/index.tsx create mode 100644 apps/suman-bosna/src/modules/home/components/mission-section/index.tsx create mode 100644 apps/suman-bosna/src/modules/home/components/partners-ticker/index.tsx create mode 100644 apps/suman-bosna/src/modules/home/components/product-showcase/index.tsx create mode 100644 apps/suman-bosna/src/modules/layout/components/cart-button/index.tsx create mode 100644 apps/suman-bosna/src/modules/layout/components/cart-dropdown/index.tsx create mode 100644 apps/suman-bosna/src/modules/layout/components/cart-mismatch-banner/index.tsx create mode 100644 apps/suman-bosna/src/modules/layout/components/country-select/index.tsx create mode 100644 apps/suman-bosna/src/modules/layout/components/language-select/index.tsx create mode 100644 apps/suman-bosna/src/modules/layout/components/medusa-cta/index.tsx create mode 100644 apps/suman-bosna/src/modules/layout/components/search/drawer.tsx create mode 100644 apps/suman-bosna/src/modules/layout/components/search/hit.tsx create mode 100644 apps/suman-bosna/src/modules/layout/components/search/index.tsx create mode 100644 apps/suman-bosna/src/modules/layout/components/side-menu/index.tsx create mode 100644 apps/suman-bosna/src/modules/layout/templates/footer/index.tsx create mode 100644 apps/suman-bosna/src/modules/layout/templates/nav/index.tsx create mode 100644 apps/suman-bosna/src/modules/order/components/help/index.tsx create mode 100644 apps/suman-bosna/src/modules/order/components/item/index.tsx create mode 100644 apps/suman-bosna/src/modules/order/components/items/index.tsx create mode 100644 apps/suman-bosna/src/modules/order/components/onboarding-cta/index.tsx create mode 100644 apps/suman-bosna/src/modules/order/components/order-details/index.tsx create mode 100644 apps/suman-bosna/src/modules/order/components/order-summary/index.tsx create mode 100644 apps/suman-bosna/src/modules/order/components/payment-details/index.tsx create mode 100644 apps/suman-bosna/src/modules/order/components/shipping-details/index.tsx create mode 100644 apps/suman-bosna/src/modules/order/components/transfer-actions/index.tsx create mode 100644 apps/suman-bosna/src/modules/order/components/transfer-image/index.tsx create mode 100644 apps/suman-bosna/src/modules/order/templates/order-completed-template.tsx create mode 100644 apps/suman-bosna/src/modules/order/templates/order-details-template.tsx create mode 100644 apps/suman-bosna/src/modules/policies/templates/index.tsx create mode 100644 apps/suman-bosna/src/modules/products/components/gallery-and-configurator/index.tsx create mode 100644 apps/suman-bosna/src/modules/products/components/image-gallery/index.tsx create mode 100644 apps/suman-bosna/src/modules/products/components/image-gallery/variant-image-gallery.tsx create mode 100644 apps/suman-bosna/src/modules/products/components/inquiry-modal/index.tsx create mode 100644 apps/suman-bosna/src/modules/products/components/product-actions/index.tsx create mode 100644 apps/suman-bosna/src/modules/products/components/product-actions/mobile-actions.tsx create mode 100644 apps/suman-bosna/src/modules/products/components/product-actions/option-select.tsx create mode 100644 apps/suman-bosna/src/modules/products/components/product-onboarding-cta/index.tsx create mode 100644 apps/suman-bosna/src/modules/products/components/product-preview/index.tsx create mode 100644 apps/suman-bosna/src/modules/products/components/product-preview/price.tsx create mode 100644 apps/suman-bosna/src/modules/products/components/product-price/index.tsx create mode 100644 apps/suman-bosna/src/modules/products/components/product-tabs/accordion.tsx create mode 100644 apps/suman-bosna/src/modules/products/components/product-tabs/index.tsx create mode 100644 apps/suman-bosna/src/modules/products/components/related-products/index.tsx create mode 100644 apps/suman-bosna/src/modules/products/components/thumbnail/index.tsx create mode 100644 apps/suman-bosna/src/modules/products/components/umbrella-configurator/index.tsx create mode 100644 apps/suman-bosna/src/modules/products/templates/custom/prestige-custom-template.tsx create mode 100644 apps/suman-bosna/src/modules/products/templates/custom/registry.ts create mode 100644 apps/suman-bosna/src/modules/products/templates/custom/types.ts create mode 100644 apps/suman-bosna/src/modules/products/templates/index.tsx create mode 100644 apps/suman-bosna/src/modules/products/templates/product-info/index.tsx create mode 100644 apps/suman-bosna/src/modules/search/components/search-form/index.tsx create mode 100644 apps/suman-bosna/src/modules/shipping/components/free-shipping-price-nudge/index.tsx create mode 100644 apps/suman-bosna/src/modules/skeletons/components/skeleton-button/index.tsx create mode 100644 apps/suman-bosna/src/modules/skeletons/components/skeleton-card-details/index.tsx create mode 100644 apps/suman-bosna/src/modules/skeletons/components/skeleton-cart-item/index.tsx create mode 100644 apps/suman-bosna/src/modules/skeletons/components/skeleton-cart-totals/index.tsx create mode 100644 apps/suman-bosna/src/modules/skeletons/components/skeleton-code-form/index.tsx create mode 100644 apps/suman-bosna/src/modules/skeletons/components/skeleton-line-item/index.tsx create mode 100644 apps/suman-bosna/src/modules/skeletons/components/skeleton-order-confirmed-header/index.tsx create mode 100644 apps/suman-bosna/src/modules/skeletons/components/skeleton-order-information/index.tsx create mode 100644 apps/suman-bosna/src/modules/skeletons/components/skeleton-order-items/index.tsx create mode 100644 apps/suman-bosna/src/modules/skeletons/components/skeleton-order-summary/index.tsx create mode 100644 apps/suman-bosna/src/modules/skeletons/components/skeleton-product-preview/index.tsx create mode 100644 apps/suman-bosna/src/modules/skeletons/templates/skeleton-cart-page/index.tsx create mode 100644 apps/suman-bosna/src/modules/skeletons/templates/skeleton-order-confirmed/index.tsx create mode 100644 apps/suman-bosna/src/modules/skeletons/templates/skeleton-product-grid/index.tsx create mode 100644 apps/suman-bosna/src/modules/skeletons/templates/skeleton-related-products/index.tsx create mode 100644 apps/suman-bosna/src/modules/store/components/pagination/index.tsx create mode 100644 apps/suman-bosna/src/modules/store/components/refinement-list/index.tsx create mode 100644 apps/suman-bosna/src/modules/store/components/refinement-list/options-picker/index.tsx create mode 100644 apps/suman-bosna/src/modules/store/components/refinement-list/sort-products/index.tsx create mode 100644 apps/suman-bosna/src/modules/store/components/store-hits/index.tsx create mode 100644 apps/suman-bosna/src/modules/store/components/store-hits/pagination.tsx create mode 100644 apps/suman-bosna/src/modules/store/components/store-hits/price.tsx create mode 100644 apps/suman-bosna/src/modules/store/components/store-refinements/attributes.ts create mode 100644 apps/suman-bosna/src/modules/store/components/store-refinements/current-refinements.tsx create mode 100644 apps/suman-bosna/src/modules/store/components/store-refinements/index.tsx create mode 100644 apps/suman-bosna/src/modules/store/components/store-refinements/on-sale-toggle.tsx create mode 100644 apps/suman-bosna/src/modules/store/components/store-refinements/option-refinements.tsx create mode 100644 apps/suman-bosna/src/modules/store/components/store-refinements/price-range.tsx create mode 100644 apps/suman-bosna/src/modules/store/components/store-refinements/refinement-group.tsx create mode 100644 apps/suman-bosna/src/modules/store/components/store-search-box/index.tsx create mode 100644 apps/suman-bosna/src/modules/store/templates/index.tsx create mode 100644 apps/suman-bosna/src/modules/store/templates/paginated-products.tsx create mode 100644 apps/suman-bosna/src/styles/globals.css create mode 100644 apps/suman-bosna/src/types/global.ts create mode 100644 apps/suman-bosna/src/types/icon.ts create mode 100644 apps/suman-bosna/tailwind.config.js create mode 100644 apps/suman-bosna/tsconfig.json create mode 100644 apps/suman-bosna/tsconfig.tsbuildinfo create mode 100644 apps/suman-hrvatska/.prettierrc.json create mode 100644 apps/suman-hrvatska/AGENTS.md create mode 100644 apps/suman-hrvatska/CLAUDE.md create mode 100644 apps/suman-hrvatska/check-env-variables.js create mode 100644 apps/suman-hrvatska/eslint.config.mjs create mode 100644 apps/suman-hrvatska/next-env.d.ts create mode 100644 apps/suman-hrvatska/next.config.js create mode 100644 apps/suman-hrvatska/package.json create mode 100644 apps/suman-hrvatska/postcss.config.js create mode 100644 apps/suman-hrvatska/public/favicon.ico create mode 100644 apps/suman-hrvatska/public/logo.png create mode 100644 apps/suman-hrvatska/src/app/.well-known/ucp/route.ts create mode 100644 apps/suman-hrvatska/src/app/[countryCode]/(checkout)/checkout/page.tsx create mode 100644 apps/suman-hrvatska/src/app/[countryCode]/(checkout)/layout.tsx create mode 100644 apps/suman-hrvatska/src/app/[countryCode]/(checkout)/not-found.tsx create mode 100644 apps/suman-hrvatska/src/app/[countryCode]/(main)/account/@dashboard/addresses/page.tsx create mode 100644 apps/suman-hrvatska/src/app/[countryCode]/(main)/account/@dashboard/default.tsx create mode 100644 apps/suman-hrvatska/src/app/[countryCode]/(main)/account/@dashboard/loading.tsx create mode 100644 apps/suman-hrvatska/src/app/[countryCode]/(main)/account/@dashboard/orders/details/[id]/page.tsx create mode 100644 apps/suman-hrvatska/src/app/[countryCode]/(main)/account/@dashboard/orders/page.tsx create mode 100644 apps/suman-hrvatska/src/app/[countryCode]/(main)/account/@dashboard/page.tsx create mode 100644 apps/suman-hrvatska/src/app/[countryCode]/(main)/account/@dashboard/profile/page.tsx create mode 100644 apps/suman-hrvatska/src/app/[countryCode]/(main)/account/@login/default.tsx create mode 100644 apps/suman-hrvatska/src/app/[countryCode]/(main)/account/@login/page.tsx create mode 100644 apps/suman-hrvatska/src/app/[countryCode]/(main)/account/layout.tsx create mode 100644 apps/suman-hrvatska/src/app/[countryCode]/(main)/account/loading.tsx create mode 100644 apps/suman-hrvatska/src/app/[countryCode]/(main)/cart/add/route.ts create mode 100644 apps/suman-hrvatska/src/app/[countryCode]/(main)/cart/loading.tsx create mode 100644 apps/suman-hrvatska/src/app/[countryCode]/(main)/cart/not-found.tsx create mode 100644 apps/suman-hrvatska/src/app/[countryCode]/(main)/cart/page.tsx create mode 100644 apps/suman-hrvatska/src/app/[countryCode]/(main)/cart/resume/[cartId]/route.ts create mode 100644 apps/suman-hrvatska/src/app/[countryCode]/(main)/categories/[...category]/page.tsx create mode 100644 apps/suman-hrvatska/src/app/[countryCode]/(main)/collections/[handle]/page.tsx create mode 100644 apps/suman-hrvatska/src/app/[countryCode]/(main)/contact/page.tsx create mode 100644 apps/suman-hrvatska/src/app/[countryCode]/(main)/layout.tsx create mode 100644 apps/suman-hrvatska/src/app/[countryCode]/(main)/not-found.tsx create mode 100644 apps/suman-hrvatska/src/app/[countryCode]/(main)/order/[id]/confirmed/loading.tsx create mode 100644 apps/suman-hrvatska/src/app/[countryCode]/(main)/order/[id]/confirmed/page.tsx create mode 100644 apps/suman-hrvatska/src/app/[countryCode]/(main)/order/[id]/transfer/[token]/accept/page.tsx create mode 100644 apps/suman-hrvatska/src/app/[countryCode]/(main)/order/[id]/transfer/[token]/decline/page.tsx create mode 100644 apps/suman-hrvatska/src/app/[countryCode]/(main)/order/[id]/transfer/[token]/page.tsx create mode 100644 apps/suman-hrvatska/src/app/[countryCode]/(main)/page.tsx create mode 100644 apps/suman-hrvatska/src/app/[countryCode]/(main)/privacy/page.tsx create mode 100644 apps/suman-hrvatska/src/app/[countryCode]/(main)/products/[handle]/markdown/route.ts create mode 100644 apps/suman-hrvatska/src/app/[countryCode]/(main)/products/[handle]/page.tsx create mode 100644 apps/suman-hrvatska/src/app/[countryCode]/(main)/returns/page.tsx create mode 100644 apps/suman-hrvatska/src/app/[countryCode]/(main)/search/page.tsx create mode 100644 apps/suman-hrvatska/src/app/[countryCode]/(main)/shipping/page.tsx create mode 100644 apps/suman-hrvatska/src/app/[countryCode]/(main)/store/page.tsx create mode 100644 apps/suman-hrvatska/src/app/[countryCode]/(main)/terms/page.tsx create mode 100644 apps/suman-hrvatska/src/app/[countryCode]/(main)/verify-account/page.tsx create mode 100644 apps/suman-hrvatska/src/app/api/payment-return/route.ts create mode 100644 apps/suman-hrvatska/src/app/buy/[items]/route.ts create mode 100644 apps/suman-hrvatska/src/app/layout.tsx create mode 100644 apps/suman-hrvatska/src/app/llms.txt/route.ts create mode 100644 apps/suman-hrvatska/src/app/not-found.tsx create mode 100644 apps/suman-hrvatska/src/app/opengraph-image.jpg create mode 100644 apps/suman-hrvatska/src/app/robots.ts create mode 100644 apps/suman-hrvatska/src/app/sitemap.ts create mode 100644 apps/suman-hrvatska/src/app/twitter-image.jpg create mode 100644 apps/suman-hrvatska/src/app/ucp/mcp/route.ts create mode 100644 apps/suman-hrvatska/src/app/ucp/v1/cart/[cartId]/route.ts create mode 100644 apps/suman-hrvatska/src/app/ucp/v1/cart/route.ts create mode 100644 apps/suman-hrvatska/src/app/ucp/v1/catalog/lookup/route.ts create mode 100644 apps/suman-hrvatska/src/app/ucp/v1/catalog/search/route.ts create mode 100644 apps/suman-hrvatska/src/app/ucp/v1/checkout-sessions/[id]/cancel/route.ts create mode 100644 apps/suman-hrvatska/src/app/ucp/v1/checkout-sessions/[id]/complete/route.ts create mode 100644 apps/suman-hrvatska/src/app/ucp/v1/checkout-sessions/[id]/route.ts create mode 100644 apps/suman-hrvatska/src/app/ucp/v1/checkout-sessions/route.ts create mode 100644 apps/suman-hrvatska/src/app/ucp/v1/route.ts create mode 100644 apps/suman-hrvatska/src/components/ui/section-header.tsx create mode 100644 apps/suman-hrvatska/src/lib/config.ts create mode 100644 apps/suman-hrvatska/src/lib/constants.tsx create mode 100644 apps/suman-hrvatska/src/lib/context/modal-context.tsx create mode 100644 apps/suman-hrvatska/src/lib/data/adyen.ts create mode 100644 apps/suman-hrvatska/src/lib/data/cart.ts create mode 100644 apps/suman-hrvatska/src/lib/data/categories.ts create mode 100644 apps/suman-hrvatska/src/lib/data/collections.ts create mode 100644 apps/suman-hrvatska/src/lib/data/cookies.ts create mode 100644 apps/suman-hrvatska/src/lib/data/customer.ts create mode 100644 apps/suman-hrvatska/src/lib/data/fulfillment.ts create mode 100644 apps/suman-hrvatska/src/lib/data/locale-actions.ts create mode 100644 apps/suman-hrvatska/src/lib/data/locales.ts create mode 100644 apps/suman-hrvatska/src/lib/data/onboarding.ts create mode 100644 apps/suman-hrvatska/src/lib/data/orders.ts create mode 100644 apps/suman-hrvatska/src/lib/data/payment.ts create mode 100644 apps/suman-hrvatska/src/lib/data/products.ts create mode 100644 apps/suman-hrvatska/src/lib/data/regions.ts create mode 100644 apps/suman-hrvatska/src/lib/data/store-policies.ts create mode 100644 apps/suman-hrvatska/src/lib/data/variants.ts create mode 100644 apps/suman-hrvatska/src/lib/hooks/use-in-view.tsx create mode 100644 apps/suman-hrvatska/src/lib/hooks/use-search-settled.tsx create mode 100644 apps/suman-hrvatska/src/lib/hooks/use-toggle-state.tsx create mode 100644 apps/suman-hrvatska/src/lib/search-client.ts create mode 100644 apps/suman-hrvatska/src/lib/ucp/mcp.ts create mode 100644 apps/suman-hrvatska/src/lib/ucp/operations.ts create mode 100644 apps/suman-hrvatska/src/lib/ucp/ucp.ts create mode 100644 apps/suman-hrvatska/src/lib/util/cart-events.ts create mode 100644 apps/suman-hrvatska/src/lib/util/compare-addresses.ts create mode 100644 apps/suman-hrvatska/src/lib/util/env.ts create mode 100644 apps/suman-hrvatska/src/lib/util/get-locale-header.ts create mode 100644 apps/suman-hrvatska/src/lib/util/get-percentage-diff.ts create mode 100644 apps/suman-hrvatska/src/lib/util/get-product-price.ts create mode 100644 apps/suman-hrvatska/src/lib/util/inventory.ts create mode 100644 apps/suman-hrvatska/src/lib/util/isEmpty.ts create mode 100644 apps/suman-hrvatska/src/lib/util/medusa-error.ts create mode 100644 apps/suman-hrvatska/src/lib/util/money.ts create mode 100644 apps/suman-hrvatska/src/lib/util/payment-error.ts create mode 100644 apps/suman-hrvatska/src/lib/util/product-markdown.ts create mode 100644 apps/suman-hrvatska/src/lib/util/product-option-filters.ts create mode 100644 apps/suman-hrvatska/src/lib/util/product-structured-data.ts create mode 100644 apps/suman-hrvatska/src/lib/util/product.ts create mode 100644 apps/suman-hrvatska/src/lib/util/repeat.ts create mode 100644 apps/suman-hrvatska/src/lib/util/server-cart.ts create mode 100644 apps/suman-hrvatska/src/lib/util/site.ts create mode 100644 apps/suman-hrvatska/src/lib/util/sort-products.ts create mode 100644 apps/suman-hrvatska/src/lib/util/store-policies.ts create mode 100644 apps/suman-hrvatska/src/middleware.ts create mode 100644 apps/suman-hrvatska/src/modules/account/components/account-info/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/account/components/account-nav/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/account/components/address-book/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/account/components/address-card/add-address.tsx create mode 100644 apps/suman-hrvatska/src/modules/account/components/address-card/edit-address-modal.tsx create mode 100644 apps/suman-hrvatska/src/modules/account/components/login/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/account/components/order-card/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/account/components/order-overview/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/account/components/overview/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/account/components/profile-billing-address/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/account/components/profile-email/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/account/components/profile-name/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/account/components/profile-password/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/account/components/profile-phone/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/account/components/register/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/account/components/transfer-request-form/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/account/components/verify-account/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/account/templates/account-layout.tsx create mode 100644 apps/suman-hrvatska/src/modules/account/templates/login-template.tsx create mode 100644 apps/suman-hrvatska/src/modules/cart/components/cart-item-select/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/cart/components/empty-cart-message/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/cart/components/item/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/cart/components/sign-in-prompt/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/cart/templates/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/cart/templates/items.tsx create mode 100644 apps/suman-hrvatska/src/modules/cart/templates/preview.tsx create mode 100644 apps/suman-hrvatska/src/modules/cart/templates/summary.tsx create mode 100644 apps/suman-hrvatska/src/modules/categories/templates/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/checkout/components/address-select/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/checkout/components/addresses/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/checkout/components/billing_address/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/checkout/components/country-select/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/checkout/components/discount-code/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/checkout/components/error-message/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/checkout/components/payment-button/adyen-payment-button.tsx create mode 100644 apps/suman-hrvatska/src/modules/checkout/components/payment-button/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/checkout/components/payment-container/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/checkout/components/payment-test/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/checkout/components/payment-wrapper/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/checkout/components/payment-wrapper/stripe-wrapper.tsx create mode 100644 apps/suman-hrvatska/src/modules/checkout/components/payment/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/checkout/components/review/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/checkout/components/shipping-address/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/checkout/components/shipping/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/checkout/components/submit-button/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/checkout/templates/checkout-form/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/checkout/templates/checkout-summary/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/collections/templates/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/common/components/cart-totals/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/common/components/checkbox/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/common/components/delete-button/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/common/components/divider/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/common/components/filter-radio-group/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/common/components/input/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/common/components/interactive-link/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/common/components/line-item-options/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/common/components/line-item-price/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/common/components/line-item-unit-price/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/common/components/localized-client-link/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/common/components/modal/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/common/components/native-select/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/common/components/radio/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/common/components/ui/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/common/icons/back.tsx create mode 100644 apps/suman-hrvatska/src/modules/common/icons/bancontact.tsx create mode 100644 apps/suman-hrvatska/src/modules/common/icons/chevron-down.tsx create mode 100644 apps/suman-hrvatska/src/modules/common/icons/chevron-up-down.tsx create mode 100644 apps/suman-hrvatska/src/modules/common/icons/eye-off.tsx create mode 100644 apps/suman-hrvatska/src/modules/common/icons/eye.tsx create mode 100644 apps/suman-hrvatska/src/modules/common/icons/fast-delivery.tsx create mode 100644 apps/suman-hrvatska/src/modules/common/icons/ideal.tsx create mode 100644 apps/suman-hrvatska/src/modules/common/icons/map-pin.tsx create mode 100644 apps/suman-hrvatska/src/modules/common/icons/medusa.tsx create mode 100644 apps/suman-hrvatska/src/modules/common/icons/nextjs.tsx create mode 100644 apps/suman-hrvatska/src/modules/common/icons/package.tsx create mode 100644 apps/suman-hrvatska/src/modules/common/icons/paypal.tsx create mode 100644 apps/suman-hrvatska/src/modules/common/icons/placeholder-image.tsx create mode 100644 apps/suman-hrvatska/src/modules/common/icons/refresh.tsx create mode 100644 apps/suman-hrvatska/src/modules/common/icons/spinner.tsx create mode 100644 apps/suman-hrvatska/src/modules/common/icons/trash.tsx create mode 100644 apps/suman-hrvatska/src/modules/common/icons/user.tsx create mode 100644 apps/suman-hrvatska/src/modules/common/icons/x.tsx create mode 100644 apps/suman-hrvatska/src/modules/home/components/featured-products/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/home/components/featured-products/product-rail/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/home/components/hero/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/layout/components/cart-button/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/layout/components/cart-dropdown/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/layout/components/cart-mismatch-banner/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/layout/components/country-select/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/layout/components/language-select/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/layout/components/medusa-cta/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/layout/components/search/drawer.tsx create mode 100644 apps/suman-hrvatska/src/modules/layout/components/search/hit.tsx create mode 100644 apps/suman-hrvatska/src/modules/layout/components/search/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/layout/components/side-menu/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/layout/templates/footer/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/layout/templates/nav/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/order/components/help/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/order/components/item/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/order/components/items/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/order/components/onboarding-cta/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/order/components/order-details/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/order/components/order-summary/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/order/components/payment-details/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/order/components/shipping-details/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/order/components/transfer-actions/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/order/components/transfer-image/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/order/templates/order-completed-template.tsx create mode 100644 apps/suman-hrvatska/src/modules/order/templates/order-details-template.tsx create mode 100644 apps/suman-hrvatska/src/modules/policies/templates/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/products/components/image-gallery/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/products/components/image-gallery/variant-image-gallery.tsx create mode 100644 apps/suman-hrvatska/src/modules/products/components/product-actions/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/products/components/product-actions/mobile-actions.tsx create mode 100644 apps/suman-hrvatska/src/modules/products/components/product-actions/option-select.tsx create mode 100644 apps/suman-hrvatska/src/modules/products/components/product-onboarding-cta/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/products/components/product-preview/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/products/components/product-preview/price.tsx create mode 100644 apps/suman-hrvatska/src/modules/products/components/product-price/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/products/components/product-tabs/accordion.tsx create mode 100644 apps/suman-hrvatska/src/modules/products/components/product-tabs/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/products/components/related-products/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/products/components/thumbnail/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/products/templates/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/products/templates/product-info/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/search/components/search-form/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/shipping/components/free-shipping-price-nudge/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/skeletons/components/skeleton-button/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/skeletons/components/skeleton-card-details/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/skeletons/components/skeleton-cart-item/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/skeletons/components/skeleton-cart-totals/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/skeletons/components/skeleton-code-form/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/skeletons/components/skeleton-line-item/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/skeletons/components/skeleton-order-confirmed-header/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/skeletons/components/skeleton-order-information/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/skeletons/components/skeleton-order-items/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/skeletons/components/skeleton-order-summary/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/skeletons/components/skeleton-product-preview/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/skeletons/templates/skeleton-cart-page/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/skeletons/templates/skeleton-order-confirmed/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/skeletons/templates/skeleton-product-grid/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/skeletons/templates/skeleton-related-products/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/store/components/pagination/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/store/components/refinement-list/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/store/components/refinement-list/options-picker/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/store/components/refinement-list/sort-products/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/store/components/store-hits/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/store/components/store-hits/pagination.tsx create mode 100644 apps/suman-hrvatska/src/modules/store/components/store-hits/price.tsx create mode 100644 apps/suman-hrvatska/src/modules/store/components/store-refinements/attributes.ts create mode 100644 apps/suman-hrvatska/src/modules/store/components/store-refinements/current-refinements.tsx create mode 100644 apps/suman-hrvatska/src/modules/store/components/store-refinements/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/store/components/store-refinements/on-sale-toggle.tsx create mode 100644 apps/suman-hrvatska/src/modules/store/components/store-refinements/option-refinements.tsx create mode 100644 apps/suman-hrvatska/src/modules/store/components/store-refinements/price-range.tsx create mode 100644 apps/suman-hrvatska/src/modules/store/components/store-refinements/refinement-group.tsx create mode 100644 apps/suman-hrvatska/src/modules/store/components/store-search-box/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/store/templates/index.tsx create mode 100644 apps/suman-hrvatska/src/modules/store/templates/paginated-products.tsx create mode 100644 apps/suman-hrvatska/src/styles/globals.css create mode 100644 apps/suman-hrvatska/src/types/global.ts create mode 100644 apps/suman-hrvatska/src/types/icon.ts create mode 100644 apps/suman-hrvatska/tailwind.config.js create mode 100644 apps/suman-hrvatska/tsconfig.json create mode 100644 apps/suman-hrvatska/tsconfig.tsbuildinfo create mode 100644 docker-compose.yml create mode 100644 docs/TEHNICKA_DOKUMENTACIJA.md create mode 100644 docs/faze-implementacije/FAZA-01-hr-webshop-sinhronizacija.md create mode 100644 docs/faze-implementacije/FAZA-02-prodajni-scenariji-i-upiti.md create mode 100644 docs/faze-implementacije/FAZA-03-dinamicki-2d-konfigurator-suncobrana.md create mode 100644 docs/faze-implementacije/FAZA-04-dostava-licno-preuzimanje-i-r1-pravna-lica.md create mode 100644 docs/faze-implementacije/FAZA-05-placanja-kartice-virman-pouzece.md create mode 100644 docs/faze-implementacije/FAZA-06-medusa-admin-nabavka-i-izolacija.md create mode 100644 docs/faze-implementacije/FAZA-07-testiranje-soft-opening-i-korporativni-web.md create mode 100644 docs/faze-implementacije/README.md create mode 100644 docs/implementation-plan/README.md create mode 100644 docs/implementation-plan/phase-01-infrastructure-and-monorepo.md create mode 100644 docs/implementation-plan/phase-02-multichannel-core-and-seeding.md create mode 100644 docs/implementation-plan/phase-03-admin-isolation-by-country.md create mode 100644 docs/implementation-plan/phase-04-crm-b2b-and-admin-widgets.md create mode 100644 docs/implementation-plan/phase-05-storefronts-and-next-intl.md create mode 100644 docs/implementation-plan/phase-06-umbrella-catalog-and-specs.md create mode 100644 docs/implementation-plan/phase-07-testing-verification-and-deployment.md create mode 100644 eslint.config.ts create mode 100644 package-lock.json create mode 100644 package.json create mode 100644 turbo.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0e3a4f8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,57 @@ +# Dependencies +node_modules +.pnp +.pnp.js + +# Yarn 2+ +.yarn/* +.yarn +!.yarn/patches +!.yarn/plugins +!.yarn/releases +!.yarn/sdks +!.yarn/versions +.pnp.* + +# Testing +coverage + +# Next.js +**/.next/ +**/out/ + +# Production +**/build +**/dist + +# Misc +*.pem + +# Debug +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Local env files +**/.env +**/.env.local +**/.env.development.local +**/.env.test.local +**/.env.production.local + +# Turbo +.turbo +.vscode + +# vercel +.vercel + +# macOS system files +.DS_Store +.DS_Store? +._* +.Spotlight-V100 +.Trashes +ehthumbs.db +Thumbs.db +**/.DS_Store \ No newline at end of file diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..3e775ef --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +auto-install-peers=true diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..7e28293 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,233 @@ +# AGENTS.md + +## Overview + +Medusa DTC Starter — a Turborepo workspace monorepo containing a Medusa backend (`@medusajs/medusa` 2.x, Node 22.22+, PostgreSQL 15+) and an optional Next.js storefront. + +## Before You Start + +1. **Detect the package manager** (see [Package Manager](#package-manager)). Never assume pnpm. +2. **Check whether `apps/storefront/` exists.** If not, the project is backend-only. +3. **Load the matching Medusa skill** if available (see [Medusa Skills & MCP Server](#medusa-skills--mcp-server)). +4. **Read the `AGENTS.md` of the `@medusajs/*` package you're about to use** (see [Medusa Package Docs](#medusa-package-docs-node_modules)). It describes the installed version, which beats memory. + +## Where to Look + +| Task | Location | Read first | +| --- | --- | --- | +| Store/admin API route | `apps/backend/src/api/{store,admin}//route.ts` | `@medusajs/framework` (`/http`), `@medusajs/medusa` | +| Middleware, auth, body validation | `apps/backend/src/api/middlewares.ts` | `@medusajs/framework` (`/http`) | +| Business logic | `apps/backend/src/workflows/` | `@medusajs/framework` (`/workflows-sdk`), `@medusajs/core-flows` | +| Reuse a built-in flow (create cart, product, order...) | import from `@medusajs/medusa/core-flows` | `@medusajs/core-flows` | +| Custom data model + service | `apps/backend/src/modules//` | `@medusajs/framework` (`/utils`) | +| Extend a commerce module (product, cart, order...) | `apps/backend/src/links/` | `@medusajs/` (e.g. `@medusajs/product`) | +| Events / cron | `apps/backend/src/subscribers/`, `apps/backend/src/jobs/` | `@medusajs/framework` | +| Product search index | `apps/backend/src/search/` | `@medusajs/framework` (`/types` `SearchTypes`) | +| One-off scripts | `apps/backend/src/scripts/` (run with `medusa exec`) | `@medusajs/cli` | +| Admin widgets / pages | `apps/backend/src/admin/` | `@medusajs/admin-sdk`, `@medusajs/ui`, `@medusajs/icons` | +| Module/plugin config | `apps/backend/medusa-config.ts` | `@medusajs/framework` | +| Tests | `apps/backend/integration-tests/`, `src/**/__tests__/` | `@medusajs/test-utils` | +| Storefront API calls | `apps/storefront/src/lib/data/` | `@medusajs/js-sdk`, `@medusajs/types` (`HttpTypes`) | +| Storefront UI | `apps/storefront/src/modules//`, routes in `src/app/` | `@medusajs/ui` | +| Lint failure | the flagged file | `@medusajs/eslint-plugin` | + +## Directory Structure + +```text +. +├── apps/ +│ ├── backend/ # Medusa application (@dtc/backend) +│ │ ├── medusa-config.ts # Medusa config: DB URL, CORS, secrets, modules +│ │ ├── integration-tests/ # setup.js (Jest setupFiles) and http/*.spec.ts suites +│ │ └── src/ +│ │ ├── admin/ # Admin dashboard extensions (widgets/, routes/, i18n/) +│ │ ├── api/ # API routes: api/store/*, api/admin/* (file-based) + middlewares.ts +│ │ ├── jobs/ # Scheduled jobs +│ │ ├── links/ # Module links between modules +│ │ ├── migration-scripts/# Data migrations run by db:migrate (e.g. initial-data-seed.ts) +│ │ ├── modules/ # Custom modules (service + models + migrations) +│ │ ├── scripts/ # medusa exec scripts (e.g. seed-demo-products.ts) +│ │ ├── search/ # Product search index definition +│ │ ├── subscribers/ # Event subscribers +│ │ └── workflows/ # Workflows and workflow steps +│ └── storefront/ # OPTIONAL Next.js storefront (@dtc/storefront) +│ └── src/ +│ ├── app/ # Next.js App Router routes +│ ├── lib/data/ # Server-side Medusa API calls (js-sdk) +│ └── modules/ # Feature UI: cart, checkout, products, account, order... +├── eslint.config.ts # Root ESLint: @medusajs/eslint-plugin recommended +└── turbo.json # Task graph: build, dev, start, lint, test, seed +``` + +**`apps/storefront` is optional and may not exist.** It is skipped when the user chooses not to install it. Before running any storefront command, referencing storefront files, or assuming a full-stack change is possible, check that `apps/storefront/` exists. If it doesn't, the project is backend-only — do not scaffold it or suggest it was deleted by mistake. + +Each app can have its own nested `AGENTS.md`; agents read the nearest one in the directory tree, so put app-specific context there rather than expanding this file. + +## Package Manager + +**The package manager is chosen at install time and is not fixed.** Detect it before running anything, in this order: + +1. The `packageManager` field in the root `package.json` (e.g. `"pnpm@10.11.1"`) — authoritative when present. +2. The lockfile at the repo root: `pnpm-lock.yaml` → pnpm, `yarn.lock` → yarn, `package-lock.json` → npm. + +```bash +node -p "require('./package.json').packageManager ?? 'unset'" +ls pnpm-lock.yaml yarn.lock package-lock.json bun.lock bun.lockb 2>/dev/null +``` + +Use that manager for every command and never introduce a second lockfile. Below, `` means the detected manager. The ` run ` breakouts. */ +export const toJsonLd = (data: unknown) => + JSON.stringify(data).replace(/ { + return product.options?.length === 1 && product.options[0].values?.length === 1; +} \ No newline at end of file diff --git a/apps/suman-bosna/src/lib/util/repeat.ts b/apps/suman-bosna/src/lib/util/repeat.ts new file mode 100644 index 0000000..1b5c24f --- /dev/null +++ b/apps/suman-bosna/src/lib/util/repeat.ts @@ -0,0 +1,5 @@ +const repeat = (times: number) => { + return Array.from(Array(times).keys()) +} + +export default repeat diff --git a/apps/suman-bosna/src/lib/util/server-cart.ts b/apps/suman-bosna/src/lib/util/server-cart.ts new file mode 100644 index 0000000..398d620 --- /dev/null +++ b/apps/suman-bosna/src/lib/util/server-cart.ts @@ -0,0 +1,53 @@ +import "server-only" +import { sdk } from "@lib/config" +import { getCacheTag, setCartId } from "@lib/data/cookies" +import { listRegions } from "@lib/data/regions" +import { HttpTypes } from "@medusajs/types" +import { revalidateTag } from "next/cache" +import { getDefaultCountryCode } from "./site" + +export const MAX_LINE_ITEM_QUANTITY = 100 + +/** Stores the cart in the shopper's cookie and clears cached cart reads. */ +export const activateCart = async (cartId: string) => { + await setCartId(cartId) + const cartCacheTag = await getCacheTag("carts") + if (cartCacheTag) { + revalidateTag(cartCacheTag, { expire: 0 }) + } +} + +/** + * Resolves the region from an explicit country code, falling back to the + * store's default country only when none was requested. + */ +export const resolveRegion = async ( + countryCode?: string +): Promise<{ countryCode: string; region: HttpTypes.StoreRegion } | null> => { + const regions = await listRegions() + const code = countryCode?.toLowerCase() || getDefaultCountryCode(regions) + const region = regions.find((r) => r.countries?.some((c) => c.iso_2 === code)) + return code && region ? { countryCode: code, region } : null +} + +export const createCartWithItems = async ( + regionId: string, + items: { variant_id: string; quantity: number }[] +) => { + const { cart } = await sdk.store.cart.create({ region_id: regionId }) + for (const item of items) { + await sdk.store.cart.createLineItem(cart.id, item) + } + return cart.id +} + +/** Returns the requested variant IDs that don't exist in the store's sales channel. */ +export const findMissingVariantIds = async (variantIds: string[]) => { + const { variants } = await sdk.client.fetch<{ + variants: { id: string }[] + }>("/store/product-variants", { + query: { id: variantIds, fields: "id", limit: variantIds.length }, + }) + const found = new Set(variants.map((variant) => variant.id)) + return variantIds.filter((id) => !found.has(id)) +} diff --git a/apps/suman-bosna/src/lib/util/site.ts b/apps/suman-bosna/src/lib/util/site.ts new file mode 100644 index 0000000..afc1aba --- /dev/null +++ b/apps/suman-bosna/src/lib/util/site.ts @@ -0,0 +1,51 @@ +import "server-only" +import { headers } from "next/headers" +import siteConfig from "@/config/site.json" + +export const STORE_NAME = siteConfig.name + +export const DEFAULT_COUNTRY_CODE = ( + process.env.NEXT_PUBLIC_DEFAULT_REGION || siteConfig.countryCode +).toLowerCase() + +const configuredUrl = () => process.env.NEXT_PUBLIC_BASE_URL?.replace(/\/$/, "") + +const originFromHeaders = (get: (name: string) => string | null) => { + const host = (get("x-forwarded-host") ?? get("host"))?.split(",")[0].trim() + if (!host) { + return undefined + } + const proto = get("x-forwarded-proto")?.split(",")[0].trim() || "https" + return `${proto}://${host}` +} + +export const getRequestOrigin = (request: Request): string => + configuredUrl() || + originFromHeaders((name) => request.headers.get(name)) || + new URL(request.url).origin + +/** Origin for absolute URLs in server components (canonical, JSON-LD, OpenGraph). */ +export const getSiteOrigin = async (): Promise => { + const configured = configuredUrl() + if (configured) { + return configured + } + const requestHeaders = await headers() + return originFromHeaders((name) => requestHeaders.get(name)) || "http://localhost:8000" +} + +export const listCountryCodes = ( + regions: { countries?: { iso_2?: string | null }[] | null }[] +): string[] => + regions.flatMap((region) => + (region.countries ?? []) + .map((country) => country.iso_2?.toLowerCase()) + .filter((code): code is string => Boolean(code)) + ) + +export const getDefaultCountryCode = ( + regions: { countries?: { iso_2?: string | null }[] | null }[] +) => { + const codes = listCountryCodes(regions) + return codes.includes(DEFAULT_COUNTRY_CODE) ? DEFAULT_COUNTRY_CODE : codes[0] +} diff --git a/apps/suman-bosna/src/lib/util/sort-products.ts b/apps/suman-bosna/src/lib/util/sort-products.ts new file mode 100644 index 0000000..eaf21c4 --- /dev/null +++ b/apps/suman-bosna/src/lib/util/sort-products.ts @@ -0,0 +1,50 @@ +import { HttpTypes } from "@medusajs/types" +import { SortOptions } from "@modules/store/components/refinement-list/sort-products" + +interface MinPricedProduct extends HttpTypes.StoreProduct { + _minPrice?: number +} + +/** + * Helper function to sort products by price until the store API supports sorting by price + * @param products + * @param sortBy + * @returns products sorted by price + */ +export function sortProducts( + products: HttpTypes.StoreProduct[], + sortBy: SortOptions +): HttpTypes.StoreProduct[] { + const sortedProducts = products as MinPricedProduct[] + + if (["price_asc", "price_desc"].includes(sortBy)) { + // Precompute the minimum price for each product + sortedProducts.forEach((product) => { + if (product.variants && product.variants.length > 0) { + product._minPrice = Math.min( + ...product.variants.map( + (variant) => variant?.calculated_price?.calculated_amount || 0 + ) + ) + } else { + product._minPrice = Infinity + } + }) + + // Sort products based on the precomputed minimum prices + sortedProducts.sort((a, b) => { + const diff = a._minPrice! - b._minPrice! + return sortBy === "price_asc" ? diff : -diff + }) + } + + if (sortBy === "created_at") { + sortedProducts.sort((a, b) => { + return ( + new Date(b.created_at!).getTime() - new Date(a.created_at!).getTime() + ) + }) + } + + return sortedProducts +} diff --git a/apps/suman-bosna/src/lib/util/store-policies.ts b/apps/suman-bosna/src/lib/util/store-policies.ts new file mode 100644 index 0000000..bc510e5 --- /dev/null +++ b/apps/suman-bosna/src/lib/util/store-policies.ts @@ -0,0 +1,103 @@ +import { HttpTypes } from "@medusajs/types" + +export type StorePolicies = { + returnWindowDays: number + freeReturns: boolean + shippingRate: number + handlingDays: { min: number; max: number } + transitDays: { min: number; max: number } +} + +const toNumber = (value: unknown) => { + const number = + typeof value === "string" && value.trim() === "" ? NaN : Number(value) + return Number.isFinite(number) && number >= 0 ? number : null +} + +/** + * Reads the store policy keys set on a region's metadata in Medusa Admin. + * Returns null when any value is missing or invalid, so callers omit policy + * data instead of publishing guesses. + */ +export const getRegionPolicies = ( + region: Pick | null | undefined +): StorePolicies | null => { + const metadata = region?.metadata ?? {} + const values = { + returnWindowDays: toNumber(metadata.return_window_days), + shippingRate: toNumber(metadata.shipping_rate), + handlingMin: toNumber(metadata.handling_days_min), + handlingMax: toNumber(metadata.handling_days_max), + transitMin: toNumber(metadata.transit_days_min), + transitMax: toNumber(metadata.transit_days_max), + } + if (Object.values(values).some((value) => value === null)) { + return null + } + + return { + returnWindowDays: values.returnWindowDays!, + freeReturns: + metadata.free_returns === true || metadata.free_returns === "true", + shippingRate: values.shippingRate!, + handlingDays: { min: values.handlingMin!, max: values.handlingMax! }, + transitDays: { min: values.transitMin!, max: values.transitMax! }, + } +} + +const businessDays = (range: { min: number; max: number }) => ({ + "@type": "QuantitativeValue", + minValue: range.min, + maxValue: range.max, + unitCode: "DAY", +}) + +export const buildShippingDetails = ( + policies: StorePolicies, + countryCode: string, + currencyCode: string +) => ({ + "@type": "OfferShippingDetails", + shippingRate: { + "@type": "MonetaryAmount", + value: policies.shippingRate, + currency: currencyCode.toUpperCase(), + }, + shippingDestination: { + "@type": "DefinedRegion", + addressCountry: countryCode.toUpperCase(), + }, + deliveryTime: { + "@type": "ShippingDeliveryTime", + handlingTime: businessDays(policies.handlingDays), + transitTime: businessDays(policies.transitDays), + }, +}) + +export const buildReturnPolicy = ( + policies: StorePolicies, + countryCode: string +) => ({ + "@type": "MerchantReturnPolicy", + applicableCountry: countryCode.toUpperCase(), + returnPolicyCategory: "https://schema.org/MerchantReturnFiniteReturnWindow", + merchantReturnDays: policies.returnWindowDays, + returnMethod: "https://schema.org/ReturnByMail", + returnFees: policies.freeReturns + ? "https://schema.org/FreeReturn" + : "https://schema.org/ReturnFeesCustomerResponsibility", +}) + +export const buildRegionsReturnPolicies = (regions: HttpTypes.StoreRegion[]) => + regions.flatMap((region) => { + const policies = getRegionPolicies(region) + if (!policies) { + return [] + } + return (region.countries ?? []) + .filter((country) => country.iso_2) + .map((country) => buildReturnPolicy(policies, country.iso_2!)) + }) + +export const formatDayRange = ({ min, max }: { min: number; max: number }) => + min === max ? `${min}` : `${min}-${max}` diff --git a/apps/suman-bosna/src/lib/utils.ts b/apps/suman-bosna/src/lib/utils.ts new file mode 100644 index 0000000..e8ed525 --- /dev/null +++ b/apps/suman-bosna/src/lib/utils.ts @@ -0,0 +1,7 @@ +import { clsx, type ClassValue } from "clsx" +import { twMerge } from "tailwind-merge" + +export function cn(...inputs: ClassValue[]) { + return twMerge(clsx(inputs)) +} + diff --git a/apps/suman-bosna/src/middleware.ts b/apps/suman-bosna/src/middleware.ts new file mode 100644 index 0000000..a8035c0 --- /dev/null +++ b/apps/suman-bosna/src/middleware.ts @@ -0,0 +1,133 @@ +import { HttpTypes } from "@medusajs/types" +import { NextRequest, NextResponse } from "next/server" + +const BACKEND_URL = process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL +const PUBLISHABLE_API_KEY = process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY +const DEFAULT_REGION = process.env.NEXT_PUBLIC_DEFAULT_REGION || "dk" + +const regionMapCache = { + regionMap: new Map(), + regionMapUpdated: Date.now(), +} + +async function getRegionMap(cacheId: string) { + const { regionMap, regionMapUpdated } = regionMapCache + + if (!BACKEND_URL) { + throw new Error( + "Middleware.ts: Error fetching regions. Did you set up regions in your Medusa Admin and define a NEXT_PUBLIC_MEDUSA_BACKEND_URL environment variable." + ) + } + + if ( + !regionMap.keys().next().value || + regionMapUpdated < Date.now() - 3600 * 1000 + ) { + // Fetch regions from Medusa. We can't use the JS client here because middleware is running on Edge and the client needs a Node environment. + const response = await fetch(`${BACKEND_URL}/store/regions`, { + method: "GET", + headers: { + "x-publishable-api-key": PUBLISHABLE_API_KEY!, + }, + next: { + revalidate: 3600, + tags: [`regions-${cacheId}`], + }, + cache: "force-cache", + }) + + if (!response.ok) { + throw new Error(`Backend returned ${response.status}`) + } + + const json = await response.json() + + const { regions } = json + + if (!regions?.length) { + return new Map() + } + + // Create a map of country codes to regions. + regions.forEach((region: HttpTypes.StoreRegion) => { + region.countries?.forEach((c) => { + regionMapCache.regionMap.set(c.iso_2 ?? "", region) + }) + }) + + regionMapCache.regionMapUpdated = Date.now() + } + + return regionMapCache.regionMap +} + +/** + * Resolves the country code from the URL, falling back to the store default. + * Not IP-based, so crawlers and AI agents get a stable redirect. + */ +async function getCountryCode( + request: NextRequest, + regionMap: Map +) { + let countryCode + + const urlCountryCode = request.nextUrl.pathname.split("/")[1]?.toLowerCase() + + if (urlCountryCode && regionMap.has(urlCountryCode)) { + countryCode = urlCountryCode + } else if (regionMap.has(DEFAULT_REGION)) { + countryCode = DEFAULT_REGION + } else if (regionMap.keys().next().value) { + countryCode = regionMap.keys().next().value + } + + return countryCode +} + +/** + * Middleware to handle region selection and onboarding status. + */ +export async function middleware(request: NextRequest) { + if (request.nextUrl.pathname.includes(".")) { + return NextResponse.next() + } + + const cacheIdCookie = request.cookies.get("_medusa_cache_id") + const cacheId = cacheIdCookie?.value || crypto.randomUUID() + + const regionMap = await getRegionMap(cacheId) + const countryCode = await getCountryCode(request, regionMap) + + // if the country code is available, use it, otherwise use the default region + const country = countryCode || DEFAULT_REGION + const firstPathSegment = request.nextUrl.pathname.split("/")[1]?.toLowerCase() + const urlHasCountry = firstPathSegment === country.toLowerCase() + + // Serve the default region at "/" instead of redirecting, so agents and + // crawlers get the storefront content directly from the root URL. + if (urlHasCountry || request.nextUrl.pathname === "/") { + const response = urlHasCountry + ? NextResponse.next() + : NextResponse.rewrite(new URL(`/${country}`, request.url)) + if (!cacheIdCookie) { + response.cookies.set("_medusa_cache_id", cacheId, { + maxAge: 60 * 60 * 24, + }) + } + return response + } + + // if the url doesn't have the country, redirect to it + const redirectPath = + request.nextUrl.pathname === "/" ? "" : request.nextUrl.pathname + const queryString = request.nextUrl.search || "" + const redirectUrl = `${request.nextUrl.origin}/${country}${redirectPath}${queryString}` + + return NextResponse.redirect(redirectUrl, 307) +} + +export const config = { + matcher: [ + "/((?!api|ucp|buy|_next/static|_next/image|favicon.ico|images|assets|png|svg|jpg|jpeg|gif|webp).*)", + ], +} diff --git a/apps/suman-bosna/src/modules/account/components/account-info/index.tsx b/apps/suman-bosna/src/modules/account/components/account-info/index.tsx new file mode 100644 index 0000000..2d771c1 --- /dev/null +++ b/apps/suman-bosna/src/modules/account/components/account-info/index.tsx @@ -0,0 +1,139 @@ +import { Disclosure } from "@headlessui/react" +import { Badge, Button, clx } from "@modules/common/components/ui" +import { useEffect } from "react" + +import useToggleState from "@lib/hooks/use-toggle-state" +import { useFormStatus } from "react-dom" + +type AccountInfoProps = { + label: string + currentInfo: string | React.ReactNode + isSuccess?: boolean + isError?: boolean + errorMessage?: string + clearState: () => void + children?: React.ReactNode + 'data-testid'?: string +} + +const AccountInfo = ({ + label, + currentInfo, + isSuccess, + isError, + clearState, + errorMessage = "An error occurred, please try again", + children, + 'data-testid': dataTestid +}: AccountInfoProps) => { + const { state, close, toggle } = useToggleState() + + const { pending } = useFormStatus() + + const handleToggle = () => { + clearState() + setTimeout(() => toggle(), 100) + } + + useEffect(() => { + if (isSuccess) { + close() + } + }, [isSuccess, close]) + + return ( +
+
+
+ {label} +
+ {typeof currentInfo === "string" ? ( + {currentInfo} + ) : ( + currentInfo + )} +
+
+
+ +
+
+ + {/* Success state */} + + + + {label} updated succesfully + + + + + {/* Error state */} + + + + {errorMessage} + + + + + + +
+
{children}
+
+ +
+
+
+
+
+ ) +} + +export default AccountInfo diff --git a/apps/suman-bosna/src/modules/account/components/account-nav/index.tsx b/apps/suman-bosna/src/modules/account/components/account-nav/index.tsx new file mode 100644 index 0000000..6ff742c --- /dev/null +++ b/apps/suman-bosna/src/modules/account/components/account-nav/index.tsx @@ -0,0 +1,122 @@ +"use client" + +import { LogOut, User, MapPin, Package, ChevronRight } from "lucide-react" +import { useParams, usePathname } from "next/navigation" +import { signout } from "@lib/data/customer" +import { HttpTypes } from "@medusajs/types" +import LocalizedClientLink from "@modules/common/components/localized-client-link" +import { cn } from "@/lib/utils" + +const AccountNav = ({ + customer, +}: { + customer: HttpTypes.StoreCustomer | null +}) => { + const route = usePathname() + const { countryCode } = useParams() as { countryCode: string } + + const handleLogout = async () => { + await signout(countryCode) + } + + const navLinks = [ + { href: "/account", label: "Pregled Naloga", icon: User }, + { href: "/account/profile", label: "Profil i Podaci", icon: User }, + { href: "/account/addresses", label: "Adrese za Isporuku", icon: MapPin }, + { href: "/account/orders", label: "Moje Narudžbe", icon: Package }, + ] + + return ( +
+ {/* Mobile nav */} +
+ {route !== `/${countryCode}/account` ? ( + + + Nazad na nalog + + ) : ( +
+

+ Pozdrav, {customer?.first_name || "Korisnik"} +

+
+ {navLinks.map((link) => { + const Icon = link.icon + return ( + +
+ + {link.label} +
+ +
+ ) + })} + +
+
+ )} +
+ + {/* Desktop nav */} +
+
+

+ Moj Nalog +

+ +
+
+
+ ) +} + +export default AccountNav diff --git a/apps/suman-bosna/src/modules/account/components/address-book/index.tsx b/apps/suman-bosna/src/modules/account/components/address-book/index.tsx new file mode 100644 index 0000000..edd8ac8 --- /dev/null +++ b/apps/suman-bosna/src/modules/account/components/address-book/index.tsx @@ -0,0 +1,28 @@ +import React from "react" + +import AddAddress from "../address-card/add-address" +import EditAddress from "../address-card/edit-address-modal" +import { HttpTypes } from "@medusajs/types" + +type AddressBookProps = { + customer: HttpTypes.StoreCustomer + region: HttpTypes.StoreRegion +} + +const AddressBook: React.FC = ({ customer, region }) => { + const { addresses } = customer + return ( +
+
+ + {addresses.map((address) => { + return ( + + ) + })} +
+
+ ) +} + +export default AddressBook diff --git a/apps/suman-bosna/src/modules/account/components/address-card/add-address.tsx b/apps/suman-bosna/src/modules/account/components/address-card/add-address.tsx new file mode 100644 index 0000000..4ef7545 --- /dev/null +++ b/apps/suman-bosna/src/modules/account/components/address-card/add-address.tsx @@ -0,0 +1,165 @@ +"use client" + +import { Plus } from "lucide-react" +import { Button, Heading } from "@modules/common/components/ui" +import { useActionState, useEffect, useState } from "react" + +import { addCustomerAddress } from "@lib/data/customer" +import useToggleState from "@lib/hooks/use-toggle-state" +import { HttpTypes } from "@medusajs/types" +import CountrySelect from "@modules/checkout/components/country-select" +import { SubmitButton } from "@modules/checkout/components/submit-button" +import Input from "@modules/common/components/input" +import Modal from "@modules/common/components/modal" + +const AddAddress = ({ + region, +}: { + region: HttpTypes.StoreRegion + addresses: HttpTypes.StoreCustomerAddress[] +}) => { + const [successState, setSuccessState] = useState(false) + const { state, open, close: closeModal } = useToggleState(false) + + const [formState, formAction] = useActionState(addCustomerAddress, { + success: false, + error: null, + } as { success: boolean; error: string | null }) + + const close = () => { + setSuccessState(false) + closeModal() + } + + useEffect(() => { + if (successState) { + close() + } + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [successState]) + + useEffect(() => { + if (formState.success) { + setSuccessState(true) + } + }, [formState]) + + return ( + <> + + + + + Add address + +
+ +
+
+ + +
+ + + +
+ + +
+ + + +
+ {formState.error && ( +
+ {formState.error} +
+ )} +
+ +
+ + Save +
+
+
+
+ + ) +} + +export default AddAddress diff --git a/apps/suman-bosna/src/modules/account/components/address-card/edit-address-modal.tsx b/apps/suman-bosna/src/modules/account/components/address-card/edit-address-modal.tsx new file mode 100644 index 0000000..e386270 --- /dev/null +++ b/apps/suman-bosna/src/modules/account/components/address-card/edit-address-modal.tsx @@ -0,0 +1,237 @@ +"use client" + +import { + deleteCustomerAddress, + updateCustomerAddress, +} from "@lib/data/customer" +import useToggleState from "@lib/hooks/use-toggle-state" +import { Pencil as Edit, Trash2 as Trash } from "lucide-react" +import { HttpTypes } from "@medusajs/types" +import CountrySelect from "@modules/checkout/components/country-select" +import { SubmitButton } from "@modules/checkout/components/submit-button" +import Input from "@modules/common/components/input" +import Modal from "@modules/common/components/modal" +import { Button, Heading, Text, clx } from "@modules/common/components/ui" +import Spinner from "@modules/common/icons/spinner" +import React, { useActionState, useEffect, useState } from "react" + +type EditAddressProps = { + region: HttpTypes.StoreRegion + address: HttpTypes.StoreCustomerAddress + isActive?: boolean +} + +const EditAddress: React.FC = ({ + region, + address, + isActive = false, +}) => { + const [removing, setRemoving] = useState(false) + const [successState, setSuccessState] = useState(false) + const { state, open, close: closeModal } = useToggleState(false) + + const [formState, formAction] = useActionState(updateCustomerAddress, { + success: false, + error: null, + } as { success: boolean; error: string | null }) + + const close = () => { + setSuccessState(false) + closeModal() + } + + useEffect(() => { + if (successState) { + close() + } + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [successState]) + + useEffect(() => { + if (formState.success) { + setSuccessState(true) + } + }, [formState]) + + const removeAddress = async () => { + setRemoving(true) + await deleteCustomerAddress(address.id) + setRemoving(false) + } + + return ( + <> +
+
+ + {address.first_name} {address.last_name} + + {address.company && ( + + {address.company} + + )} + + + {address.address_1} + {address.address_2 && , {address.address_2}} + + + {address.postal_code}, {address.city} + + + {address.province && `${address.province}, `} + {address.country_code?.toUpperCase()} + + +
+
+ + +
+
+ + + + Edit address + +
+ + +
+
+ + +
+ + + +
+ + +
+ + + +
+ {formState.error && ( +
+ {formState.error} +
+ )} +
+ +
+ + Save +
+
+
+
+ + ) +} + +export default EditAddress diff --git a/apps/suman-bosna/src/modules/account/components/login/index.tsx b/apps/suman-bosna/src/modules/account/components/login/index.tsx new file mode 100644 index 0000000..bd489e8 --- /dev/null +++ b/apps/suman-bosna/src/modules/account/components/login/index.tsx @@ -0,0 +1,76 @@ +import { login } from "@lib/data/customer" +import { LOGIN_VIEW } from "@modules/account/templates/login-template" +import ErrorMessage from "@modules/checkout/components/error-message" +import { SubmitButton } from "@modules/checkout/components/submit-button" +import Input from "@modules/common/components/input" +import { useActionState } from "react" + +type Props = { + setCurrentView: (view: LOGIN_VIEW) => void +} + +const Login = ({ setCurrentView }: Props) => { + const [message, formAction] = useActionState(login, null) + + return ( +
+

Welcome back

+

+ Sign in to access an enhanced shopping experience. +

+ {message?.state === "verification_required" && ( +
+ We sent a verification link to {message.email}. + Please verify your email, then sign in. +
+ )} +
+
+ + +
+ + + Sign in + + + + Not a member?{" "} + + . + +
+ ) +} + +export default Login diff --git a/apps/suman-bosna/src/modules/account/components/order-card/index.tsx b/apps/suman-bosna/src/modules/account/components/order-card/index.tsx new file mode 100644 index 0000000..843d92b --- /dev/null +++ b/apps/suman-bosna/src/modules/account/components/order-card/index.tsx @@ -0,0 +1,87 @@ +import { Button } from "@modules/common/components/ui" +import { useMemo } from "react" + +import Thumbnail from "@modules/products/components/thumbnail" +import LocalizedClientLink from "@modules/common/components/localized-client-link" +import { convertToLocale } from "@lib/util/money" +import { HttpTypes } from "@medusajs/types" + +type OrderCardProps = { + order: HttpTypes.StoreOrder +} + +const OrderCard = ({ order }: OrderCardProps) => { + const numberOfLines = useMemo(() => { + return ( + order.items?.reduce((acc, item) => { + return acc + item.quantity + }, 0) ?? 0 + ) + }, [order]) + + const numberOfProducts = useMemo(() => { + return order.items?.length ?? 0 + }, [order]) + + return ( +
+
+ #{order.display_id} +
+
+ + {new Date(order.created_at).toDateString()} + + + {convertToLocale({ + amount: order.total, + currency_code: order.currency_code, + })} + + {`${numberOfLines} ${ + numberOfLines > 1 ? "items" : "item" + }`} +
+
+ {order.items?.slice(0, 3).map((i) => { + return ( +
+ +
+ + {i.title} + + x + {i.quantity} +
+
+ ) + })} + {numberOfProducts > 4 && ( +
+ + + {numberOfLines - 4} + + more +
+ )} +
+
+ + + +
+
+ ) +} + +export default OrderCard diff --git a/apps/suman-bosna/src/modules/account/components/order-overview/index.tsx b/apps/suman-bosna/src/modules/account/components/order-overview/index.tsx new file mode 100644 index 0000000..035a7ab --- /dev/null +++ b/apps/suman-bosna/src/modules/account/components/order-overview/index.tsx @@ -0,0 +1,45 @@ +"use client" + +import { Button } from "@modules/common/components/ui" + +import OrderCard from "../order-card" +import LocalizedClientLink from "@modules/common/components/localized-client-link" +import { HttpTypes } from "@medusajs/types" + +const OrderOverview = ({ orders }: { orders: HttpTypes.StoreOrder[] }) => { + if (orders?.length) { + return ( +
+ {orders.map((o) => ( +
+ +
+ ))} +
+ ) + } + + return ( +
+

Nothing to see here

+

+ You don't have any orders yet, let us change that {":)"} +

+
+ + + +
+
+ ) +} + +export default OrderOverview diff --git a/apps/suman-bosna/src/modules/account/components/overview/index.tsx b/apps/suman-bosna/src/modules/account/components/overview/index.tsx new file mode 100644 index 0000000..eb21f77 --- /dev/null +++ b/apps/suman-bosna/src/modules/account/components/overview/index.tsx @@ -0,0 +1,168 @@ +import { Container } from "@modules/common/components/ui" + +import ChevronDown from "@modules/common/icons/chevron-down" +import LocalizedClientLink from "@modules/common/components/localized-client-link" +import { convertToLocale } from "@lib/util/money" +import { HttpTypes } from "@medusajs/types" + +type OverviewProps = { + customer: HttpTypes.StoreCustomer | null + orders: HttpTypes.StoreOrder[] | null +} + +const Overview = ({ customer, orders }: OverviewProps) => { + return ( +
+
+
+ + Hello {customer?.first_name} + + + Signed in as:{" "} + + {customer?.email} + + +
+
+
+
+
+

Profile

+
+ + {getProfileCompletion(customer)}% + + + Completed + +
+
+ +
+

Addresses

+
+ + {customer?.addresses?.length || 0} + + + Saved + +
+
+
+ +
+
+

Recent orders

+
+
    + {orders && orders.length > 0 ? ( + orders.slice(0, 5).map((order) => { + return ( +
  • + + +
    + Date placed + + Order number + + + Total amount + + + {new Date(order.created_at).toDateString()} + + + #{order.display_id} + + + {convertToLocale({ + amount: order.total, + currency_code: order.currency_code, + })} + +
    + +
    +
    +
  • + ) + }) + ) : ( + No recent orders + )} +
+
+
+
+
+
+ ) +} + +const getProfileCompletion = (customer: HttpTypes.StoreCustomer | null) => { + let count = 0 + + if (!customer) { + return 0 + } + + if (customer.email) { + count++ + } + + if (customer.first_name && customer.last_name) { + count++ + } + + if (customer.phone) { + count++ + } + + const billingAddress = customer.addresses?.find( + (addr) => addr.is_default_billing + ) + + if (billingAddress) { + count++ + } + + return (count / 4) * 100 +} + +export default Overview diff --git a/apps/suman-bosna/src/modules/account/components/profile-billing-address/index.tsx b/apps/suman-bosna/src/modules/account/components/profile-billing-address/index.tsx new file mode 100644 index 0000000..9309bc7 --- /dev/null +++ b/apps/suman-bosna/src/modules/account/components/profile-billing-address/index.tsx @@ -0,0 +1,191 @@ +"use client" + +import React, { useActionState, useEffect, useMemo } from "react" + +import Input from "@modules/common/components/input" +import NativeSelect from "@modules/common/components/native-select" + +import { addCustomerAddress, updateCustomerAddress } from "@lib/data/customer" +import { HttpTypes } from "@medusajs/types" +import AccountInfo from "../account-info" + +type MyInformationProps = { + customer: HttpTypes.StoreCustomer + regions: HttpTypes.StoreRegion[] +} + +const ProfileBillingAddress: React.FC = ({ + customer, + regions, +}) => { + const regionOptions = useMemo(() => { + return ( + regions + ?.map((region) => { + return region.countries?.map((country) => ({ + value: country.iso_2, + label: country.display_name, + })) + }) + .flat() || [] + ) + }, [regions]) + + const [successState, setSuccessState] = React.useState(false) + + const billingAddress = customer.addresses?.find( + (addr) => addr.is_default_billing + ) + + const initialState: Record = { + isDefaultBilling: true, + isDefaultShipping: false, + error: false, + success: false, + } + + if (billingAddress) { + initialState.addressId = billingAddress.id + } + + const [state, formAction] = useActionState( + billingAddress ? updateCustomerAddress : addCustomerAddress, + initialState + ) + + const clearState = () => { + setSuccessState(false) + } + + useEffect(() => { + setSuccessState(!!state.success) + }, [state]) + + const currentInfo = useMemo(() => { + if (!billingAddress) { + return "No billing address" + } + + const country = + regionOptions?.find( + (country) => country?.value === billingAddress.country_code + )?.label || billingAddress.country_code?.toUpperCase() + + return ( +
+ + {billingAddress.first_name} {billingAddress.last_name} + + {billingAddress.company} + + {billingAddress.address_1} + {billingAddress.address_2 ? `, ${billingAddress.address_2}` : ""} + + + {billingAddress.postal_code}, {billingAddress.city} + + {country} +
+ ) + }, [billingAddress, regionOptions]) + + return ( +
clearState()} className="w-full"> + + +
+
+ + +
+ + + + +
+ + +
+ + + + {regionOptions.map((option, i) => { + return ( + + ) + })} + +
+
+
+ ) +} + +export default ProfileBillingAddress diff --git a/apps/suman-bosna/src/modules/account/components/profile-email/index.tsx b/apps/suman-bosna/src/modules/account/components/profile-email/index.tsx new file mode 100644 index 0000000..267c0e8 --- /dev/null +++ b/apps/suman-bosna/src/modules/account/components/profile-email/index.tsx @@ -0,0 +1,71 @@ +"use client" + +import React, { useEffect, useActionState } from "react"; + +import Input from "@modules/common/components/input" + +import AccountInfo from "../account-info" +import { HttpTypes } from "@medusajs/types" +// import { updateCustomer } from "@lib/data/customer" + +type MyInformationProps = { + customer: HttpTypes.StoreCustomer +} + +const ProfileEmail: React.FC = ({ customer }) => { + const [successState, setSuccessState] = React.useState(false) + + // TODO: It seems we don't support updating emails now? + const updateCustomerEmail = ( + _currentState: Record, + _formData: FormData + ) => { + try { + // email: formData.get("email") as string + return { success: true, error: null } + } catch (error) { + return { success: false, error: String(error) } + } + } + + const [state, formAction] = useActionState(updateCustomerEmail, { + error: null as string | null, + success: false, + }) + + const clearState = () => { + setSuccessState(false) + } + + useEffect(() => { + setSuccessState(state.success) + }, [state]) + + return ( +
+ +
+ +
+
+
+ ) +} + +export default ProfileEmail diff --git a/apps/suman-bosna/src/modules/account/components/profile-name/index.tsx b/apps/suman-bosna/src/modules/account/components/profile-name/index.tsx new file mode 100644 index 0000000..97a9954 --- /dev/null +++ b/apps/suman-bosna/src/modules/account/components/profile-name/index.tsx @@ -0,0 +1,79 @@ +"use client" + +import React, { useEffect, useActionState } from "react"; + +import Input from "@modules/common/components/input" + +import AccountInfo from "../account-info" +import { HttpTypes } from "@medusajs/types" +import { updateCustomer } from "@lib/data/customer" + +type MyInformationProps = { + customer: HttpTypes.StoreCustomer +} + +const ProfileName: React.FC = ({ customer }) => { + const [successState, setSuccessState] = React.useState(false) + + const updateCustomerName = async ( + _currentState: Record, + formData: FormData + ) => { + const customer = { + first_name: formData.get("first_name") as string, + last_name: formData.get("last_name") as string, + } + + try { + await updateCustomer(customer) + return { success: true, error: null } + } catch (error) { + return { success: false, error: String(error) } + } + } + + const [state, formAction] = useActionState(updateCustomerName, { + error: null as string | null, + success: false, + }) + + const clearState = () => { + setSuccessState(false) + } + + useEffect(() => { + setSuccessState(state.success) + }, [state]) + + return ( +
+ +
+ + +
+
+
+ ) +} + +export default ProfileName diff --git a/apps/suman-bosna/src/modules/account/components/profile-password/index.tsx b/apps/suman-bosna/src/modules/account/components/profile-password/index.tsx new file mode 100644 index 0000000..c808db0 --- /dev/null +++ b/apps/suman-bosna/src/modules/account/components/profile-password/index.tsx @@ -0,0 +1,71 @@ +"use client" + +import React from "react" +import Input from "@modules/common/components/input" +import AccountInfo from "../account-info" +import { HttpTypes } from "@medusajs/types" +// TODO: Re-add toast notifications when Toaster component is implemented + +type MyInformationProps = { + customer: HttpTypes.StoreCustomer +} + +const ProfilePassword: React.FC = ({ customer: _customer }) => { + const [successState, setSuccessState] = React.useState(false) + + // TODO: Add support for password updates + const updatePassword = async () => { + // TODO: Re-add toast notification when Toaster component is implemented + console.info("Password update is not implemented") + } + + const clearState = () => { + setSuccessState(false) + } + + return ( +
clearState()} + className="w-full" + > + The password is not shown for security reasons + } + isSuccess={successState} + isError={false} + errorMessage={undefined} + clearState={clearState} + data-testid="account-password-editor" + > +
+ + + +
+
+
+ ) +} + +export default ProfilePassword diff --git a/apps/suman-bosna/src/modules/account/components/profile-phone/index.tsx b/apps/suman-bosna/src/modules/account/components/profile-phone/index.tsx new file mode 100644 index 0000000..7723fdf --- /dev/null +++ b/apps/suman-bosna/src/modules/account/components/profile-phone/index.tsx @@ -0,0 +1,74 @@ +"use client" + +import React, { useEffect, useActionState } from "react"; + +import Input from "@modules/common/components/input" + +import AccountInfo from "../account-info" +import { HttpTypes } from "@medusajs/types" +import { updateCustomer } from "@lib/data/customer" + +type MyInformationProps = { + customer: HttpTypes.StoreCustomer +} + +const ProfileEmail: React.FC = ({ customer }) => { + const [successState, setSuccessState] = React.useState(false) + + const updateCustomerPhone = async ( + _currentState: Record, + formData: FormData + ) => { + const customer = { + phone: formData.get("phone") as string, + } + + try { + await updateCustomer(customer) + return { success: true, error: null } + } catch (error) { + return { success: false, error: String(error) } + } + } + + const [state, formAction] = useActionState(updateCustomerPhone, { + error: null as string | null, + success: false, + }) + + const clearState = () => { + setSuccessState(false) + } + + useEffect(() => { + setSuccessState(state.success) + }, [state]) + + return ( +
+ +
+ +
+
+
+ ) +} + +export default ProfileEmail diff --git a/apps/suman-bosna/src/modules/account/components/register/index.tsx b/apps/suman-bosna/src/modules/account/components/register/index.tsx new file mode 100644 index 0000000..0b53626 --- /dev/null +++ b/apps/suman-bosna/src/modules/account/components/register/index.tsx @@ -0,0 +1,118 @@ +"use client" + +import { useActionState } from "react" +import Input from "@modules/common/components/input" +import { LOGIN_VIEW } from "@modules/account/templates/login-template" +import ErrorMessage from "@modules/checkout/components/error-message" +import { SubmitButton } from "@modules/checkout/components/submit-button" +import LocalizedClientLink from "@modules/common/components/localized-client-link" +import { signup } from "@lib/data/customer" + +type Props = { + setCurrentView: (view: LOGIN_VIEW) => void +} + +const Register = ({ setCurrentView }: Props) => { + const [message, formAction] = useActionState(signup, null) + + return ( +
+

+ Become a Medusa Store Member +

+

+ Create your Medusa Store Member profile, and get access to an enhanced + shopping experience. +

+ {message?.state === "verification_required" && ( +
+ We sent a verification link to {message.email}. + Please check your inbox to verify your email, then sign in. +
+ )} +
+
+ + + + + +
+ + + By creating an account, you agree to Medusa Store's{" "} + + Privacy Policy + {" "} + and{" "} + + Terms of Use + + . + + + Join + + + + Already a member?{" "} + + . + +
+ ) +} + +export default Register diff --git a/apps/suman-bosna/src/modules/account/components/transfer-request-form/index.tsx b/apps/suman-bosna/src/modules/account/components/transfer-request-form/index.tsx new file mode 100644 index 0000000..0a0b6dd --- /dev/null +++ b/apps/suman-bosna/src/modules/account/components/transfer-request-form/index.tsx @@ -0,0 +1,81 @@ +"use client" +import { createTransferRequest } from "@lib/data/orders" +import { CheckCircle2 as CheckCircleMiniSolid, XCircle as XCircleSolid } from "lucide-react" +import { Heading, IconButton, Input, Text } from "@modules/common/components/ui" +import { useActionState } from "react" +// TODO: Re-add Toaster component when needed +import { SubmitButton } from "@modules/checkout/components/submit-button" +import { useEffect, useState } from "react" + +export default function TransferRequestForm() { + const [showSuccess, setShowSuccess] = useState(false) + + const [state, formAction] = useActionState(createTransferRequest, { + success: false, + error: null, + order: null, + }) + + useEffect(() => { + if (state.success && state.order) { + setShowSuccess(true) + } + }, [state.success, state.order]) + + return ( +
+
+
+ + Order transfers + +

+ Can't find the order you are looking for? +
Connect an order to your account. +

+
+
+
+ + + Request transfer + +
+
+
+ {!state.success && state.error && ( + + {state.error} + + )} + {showSuccess && ( +
+
+ +
+ + Transfer for order {state.order?.id} requested + + + Transfer request email sent to {state.order?.email} + +
+
+ setShowSuccess(false)} + > + + +
+ )} +
+ ) +} diff --git a/apps/suman-bosna/src/modules/account/components/verify-account/index.tsx b/apps/suman-bosna/src/modules/account/components/verify-account/index.tsx new file mode 100644 index 0000000..aefdcb6 --- /dev/null +++ b/apps/suman-bosna/src/modules/account/components/verify-account/index.tsx @@ -0,0 +1,74 @@ +"use client" + +import { useEffect, useRef, useState } from "react" +import { useSearchParams } from "next/navigation" +import { Button } from "@modules/common/components/ui" +import { confirmEmailVerification } from "@lib/data/customer" +import LocalizedClientLink from "@modules/common/components/localized-client-link" + +type VerificationState = "verifying" | "success" | "error" + +const VerifyAccount = () => { + const searchParams = useSearchParams() + const token = searchParams.get("token") + const [state, setState] = useState("verifying") + // Guard against the effect running twice in React Strict Mode, which would + // consume the single-use token before the customer sees the result. + const confirmed = useRef(false) + + useEffect(() => { + if (confirmed.current) { + return + } + confirmed.current = true + + if (!token) { + setState("error") + return + } + + confirmEmailVerification(token).then(({ success }) => + setState(success ? "success" : "error") + ) + }, [token]) + + return ( +
+

Email verification

+ + {state === "verifying" && ( +

+ Verifying your email... +

+ )} + + {state === "success" && ( + <> +

+ Your email is verified. You can now sign in to your account. +

+ + + + + )} + + {state === "error" && ( + <> +

+ This verification link is invalid or has expired. Sign in to receive + a new verification email. +

+ + + + + )} +
+ ) +} + +export default VerifyAccount diff --git a/apps/suman-bosna/src/modules/account/templates/account-layout.tsx b/apps/suman-bosna/src/modules/account/templates/account-layout.tsx new file mode 100644 index 0000000..2d29490 --- /dev/null +++ b/apps/suman-bosna/src/modules/account/templates/account-layout.tsx @@ -0,0 +1,43 @@ +import React from "react" + +import UnderlineLink from "@modules/common/components/interactive-link" + +import AccountNav from "../components/account-nav" +import { HttpTypes } from "@medusajs/types" + +interface AccountLayoutProps { + customer: HttpTypes.StoreCustomer | null + children: React.ReactNode +} + +const AccountLayout: React.FC = ({ + customer, + children, +}) => { + return ( +
+
+
+
{customer && }
+
{children}
+
+
+
+

Got questions?

+ + You can find frequently asked questions and answers on our + customer service page. + +
+
+ + Customer Service + +
+
+
+
+ ) +} + +export default AccountLayout diff --git a/apps/suman-bosna/src/modules/account/templates/login-template.tsx b/apps/suman-bosna/src/modules/account/templates/login-template.tsx new file mode 100644 index 0000000..5d68e64 --- /dev/null +++ b/apps/suman-bosna/src/modules/account/templates/login-template.tsx @@ -0,0 +1,27 @@ +"use client" + +import { useState } from "react" + +import Register from "@modules/account/components/register" +import Login from "@modules/account/components/login" + +export enum LOGIN_VIEW { + SIGN_IN = "sign-in", + REGISTER = "register", +} + +const LoginTemplate = () => { + const [currentView, setCurrentView] = useState("sign-in") + + return ( +
+ {currentView === "sign-in" ? ( + + ) : ( + + )} +
+ ) +} + +export default LoginTemplate diff --git a/apps/suman-bosna/src/modules/cart/components/cart-item-select/index.tsx b/apps/suman-bosna/src/modules/cart/components/cart-item-select/index.tsx new file mode 100644 index 0000000..2f77c0e --- /dev/null +++ b/apps/suman-bosna/src/modules/cart/components/cart-item-select/index.tsx @@ -0,0 +1,73 @@ +"use client" + +import { IconBadge, clx } from "@modules/common/components/ui" +import { + SelectHTMLAttributes, + forwardRef, + useEffect, + useImperativeHandle, + useRef, + useState, +} from "react" + +import ChevronDown from "@modules/common/icons/chevron-down" + +type NativeSelectProps = { + placeholder?: string + errors?: Record + touched?: Record +} & Omit, "size"> + +const CartItemSelect = forwardRef( + ({ placeholder = "Select...", className, children, ...props }, ref) => { + const innerRef = useRef(null) + const [isPlaceholder, setIsPlaceholder] = useState(false) + + useImperativeHandle( + ref, + () => innerRef.current + ) + + useEffect(() => { + if (innerRef.current && innerRef.current.value === "") { + setIsPlaceholder(true) + } else { + setIsPlaceholder(false) + } + }, [innerRef.current?.value]) + + return ( +
+ innerRef.current?.focus()} + onBlur={() => innerRef.current?.blur()} + className={clx( + "relative flex items-center txt-compact-small border text-ui-fg-base group", + className, + { + "text-ui-fg-subtle": isPlaceholder, + } + )} + > + + + + + +
+ ) + } +) + +CartItemSelect.displayName = "CartItemSelect" + +export default CartItemSelect diff --git a/apps/suman-bosna/src/modules/cart/components/empty-cart-message/index.tsx b/apps/suman-bosna/src/modules/cart/components/empty-cart-message/index.tsx new file mode 100644 index 0000000..8c1b41c --- /dev/null +++ b/apps/suman-bosna/src/modules/cart/components/empty-cart-message/index.tsx @@ -0,0 +1,30 @@ +import LocalizedClientLink from "@modules/common/components/localized-client-link" +import { Button } from "@/components/ui/button" +import { ShoppingBag, ArrowRight } from "lucide-react" + +const EmptyCartMessage = () => { + return ( +
+
+ +
+

+ Vaša korpa je prazna +

+

+ Trenutno nemate dodanih proizvoda u korpi. Istražite našu ponudu profesionalnih suncobrana, pergola i opreme za zaštitu od sunca. +

+ + + +
+ ) +} + +export default EmptyCartMessage diff --git a/apps/suman-bosna/src/modules/cart/components/item/index.tsx b/apps/suman-bosna/src/modules/cart/components/item/index.tsx new file mode 100644 index 0000000..f7a9436 --- /dev/null +++ b/apps/suman-bosna/src/modules/cart/components/item/index.tsx @@ -0,0 +1,140 @@ +"use client" + +import { Table } from "@modules/common/components/ui" +import { updateLineItem } from "@lib/data/cart" +import { HttpTypes } from "@medusajs/types" +import CartItemSelect from "@modules/cart/components/cart-item-select" +import ErrorMessage from "@modules/checkout/components/error-message" +import DeleteButton from "@modules/common/components/delete-button" +import LineItemOptions from "@modules/common/components/line-item-options" +import LineItemPrice from "@modules/common/components/line-item-price" +import LineItemUnitPrice from "@modules/common/components/line-item-unit-price" +import LocalizedClientLink from "@modules/common/components/localized-client-link" +import Thumbnail from "@modules/products/components/thumbnail" +import { useState } from "react" +import { Loader2 } from "lucide-react" +import { cn } from "@/lib/utils" + +type ItemProps = { + item: HttpTypes.StoreCartLineItem + type?: "full" | "preview" + currencyCode: string +} + +const Item = ({ item, type = "full", currencyCode }: ItemProps) => { + const [updating, setUpdating] = useState(false) + const [error, setError] = useState(null) + + const changeQuantity = async (quantity: number) => { + setError(null) + setUpdating(true) + + await updateLineItem({ + lineId: item.id, + quantity, + }) + .catch((err) => { + setError(err.message) + }) + .finally(() => { + setUpdating(false) + }) + } + + const maxQtyFromInventory = 10 + const maxQuantity = item.variant?.manage_inventory ? 10 : maxQtyFromInventory + + return ( + + + + + + + + + + {item.product_title} + + + + + {type === "full" && ( + +
+ + changeQuantity(parseInt(value.target.value))} + className="h-9 rounded-md border border-input bg-background px-2 text-sm" + data-testid="product-select-button" + > + {Array.from( + { + length: Math.min(maxQuantity, 10), + }, + (_, i) => ( + + ) + )} + + {updating && } +
+ +
+ )} + + {type === "full" && ( + + + + )} + + + + {type === "preview" && ( + + {item.quantity}x + + + )} + + + +
+ ) +} + +export default Item diff --git a/apps/suman-bosna/src/modules/cart/components/sign-in-prompt/index.tsx b/apps/suman-bosna/src/modules/cart/components/sign-in-prompt/index.tsx new file mode 100644 index 0000000..09a5571 --- /dev/null +++ b/apps/suman-bosna/src/modules/cart/components/sign-in-prompt/index.tsx @@ -0,0 +1,26 @@ +import { Button } from "@/components/ui/button" +import LocalizedClientLink from "@modules/common/components/localized-client-link" + +const SignInPrompt = () => { + return ( +
+
+

+ Već imate nalog? +

+

+ Prijavite se za brže naručivanje i praćenje statusa isporuke. +

+
+
+ + + +
+
+ ) +} + +export default SignInPrompt diff --git a/apps/suman-bosna/src/modules/cart/templates/index.tsx b/apps/suman-bosna/src/modules/cart/templates/index.tsx new file mode 100644 index 0000000..570076a --- /dev/null +++ b/apps/suman-bosna/src/modules/cart/templates/index.tsx @@ -0,0 +1,47 @@ +import ItemsTemplate from "./items" +import Summary from "./summary" +import EmptyCartMessage from "../components/empty-cart-message" +import SignInPrompt from "../components/sign-in-prompt" +import { Separator } from "@/components/ui/separator" +import { HttpTypes } from "@medusajs/types" + +const CartTemplate = ({ + cart, + customer, +}: { + cart: HttpTypes.StoreCart | null + customer: HttpTypes.StoreCustomer | null +}) => { + return ( +
+
+ {cart?.items?.length ? ( +
+
+ {!customer && ( + <> + + + + )} + +
+
+ {cart && cart.region && ( +
+ +
+ )} +
+
+ ) : ( +
+ +
+ )} +
+
+ ) +} + +export default CartTemplate diff --git a/apps/suman-bosna/src/modules/cart/templates/items.tsx b/apps/suman-bosna/src/modules/cart/templates/items.tsx new file mode 100644 index 0000000..24613a8 --- /dev/null +++ b/apps/suman-bosna/src/modules/cart/templates/items.tsx @@ -0,0 +1,57 @@ +import repeat from "@lib/util/repeat" +import { HttpTypes } from "@medusajs/types" +import { Heading, Table } from "@modules/common/components/ui" + +import Item from "@modules/cart/components/item" +import SkeletonLineItem from "@modules/skeletons/components/skeleton-line-item" + +type ItemsTemplateProps = { + cart?: HttpTypes.StoreCart +} + +const ItemsTemplate = ({ cart }: ItemsTemplateProps) => { + const items = cart?.items + return ( +
+
+ Cart +
+ + + + Item + + Quantity + + Price + + + Total + + + + + {items + ? items + .sort((a, b) => { + return (a.created_at ?? "") > (b.created_at ?? "") ? -1 : 1 + }) + .map((item) => { + return ( + + ) + }) + : repeat(5).map((i) => { + return + })} + +
+
+ ) +} + +export default ItemsTemplate diff --git a/apps/suman-bosna/src/modules/cart/templates/preview.tsx b/apps/suman-bosna/src/modules/cart/templates/preview.tsx new file mode 100644 index 0000000..5f38f1d --- /dev/null +++ b/apps/suman-bosna/src/modules/cart/templates/preview.tsx @@ -0,0 +1,51 @@ +"use client" + +import repeat from "@lib/util/repeat" +import { HttpTypes } from "@medusajs/types" +import { Table, clx } from "@modules/common/components/ui" + +import Item from "@modules/cart/components/item" +import SkeletonLineItem from "@modules/skeletons/components/skeleton-line-item" + +type ItemsTemplateProps = { + cart: HttpTypes.StoreCart +} + +const ItemsPreviewTemplate = ({ cart }: ItemsTemplateProps) => { + const items = cart.items + const hasOverflow = items && items.length > 4 + + return ( +
+ + + {items + ? items + .sort((a, b) => { + return (a.created_at ?? "") > (b.created_at ?? "") ? -1 : 1 + }) + .map((item) => { + return ( + + ) + }) + : repeat(5).map((i) => { + return + })} + +
+
+ ) +} + +export default ItemsPreviewTemplate diff --git a/apps/suman-bosna/src/modules/cart/templates/summary.tsx b/apps/suman-bosna/src/modules/cart/templates/summary.tsx new file mode 100644 index 0000000..f662d5a --- /dev/null +++ b/apps/suman-bosna/src/modules/cart/templates/summary.tsx @@ -0,0 +1,48 @@ +"use client" + +import { Button } from "@/components/ui/button" +import CartTotals from "@modules/common/components/cart-totals" +import { Separator } from "@/components/ui/separator" +import DiscountCode from "@modules/checkout/components/discount-code" +import LocalizedClientLink from "@modules/common/components/localized-client-link" +import { HttpTypes } from "@medusajs/types" + +type SummaryProps = { + cart: HttpTypes.StoreCart +} + +function getCheckoutStep(cart: HttpTypes.StoreCart) { + if (!cart?.shipping_address?.address_1 || !cart.email) { + return "address" + } else if (cart?.shipping_methods?.length === 0) { + return "delivery" + } else { + return "payment" + } +} + +const Summary = ({ cart }: SummaryProps) => { + const step = getCheckoutStep(cart) + + return ( +
+

+ Pregled Narudžbe +

+ + + + + + +
+ ) +} + +export default Summary diff --git a/apps/suman-bosna/src/modules/categories/templates/index.tsx b/apps/suman-bosna/src/modules/categories/templates/index.tsx new file mode 100644 index 0000000..21c420a --- /dev/null +++ b/apps/suman-bosna/src/modules/categories/templates/index.tsx @@ -0,0 +1,128 @@ +import { notFound } from "next/navigation" +import { Suspense } from "react" +import SkeletonProductGrid from "@modules/skeletons/templates/skeleton-product-grid" +import RefinementList from "@modules/store/components/refinement-list" +import { SortOptions } from "@modules/store/components/refinement-list/sort-products" +import PaginatedProducts from "@modules/store/templates/paginated-products" +import LocalizedClientLink from "@modules/common/components/localized-client-link" +import { HttpTypes } from "@medusajs/types" +import { OptionValueIds } from "@lib/util/product-option-filters" +import { ChevronRight } from "lucide-react" +import { Badge } from "@/components/ui/badge" + +export default function CategoryTemplate({ + category, + sortBy, + page, + countryCode, + optionValueIds, +}: { + category: HttpTypes.StoreProductCategory + sortBy?: SortOptions + page?: string + countryCode: string + optionValueIds?: OptionValueIds +}) { + const pageNumber = page ? parseInt(page) : 1 + const sort = sortBy || "created_at" + + if (!category || !countryCode) notFound() + + const parents = [] as HttpTypes.StoreProductCategory[] + + const getParents = (category: HttpTypes.StoreProductCategory) => { + if (category.parent_category) { + parents.push(category.parent_category) + getParents(category.parent_category) + } + } + + getParents(category) + + return ( +
+ {/* Breadcrumb Navigation */} + + + {/* Category Header */} +
+

+ {category.name} +

+ {category.description && ( +

+ {category.description} +

+ )} + {category.category_children && category.category_children.length > 0 && ( +
+ {category.category_children.map((c) => ( + + + {c.name} + + + ))} +
+ )} +
+ + {/* Main Grid: Sidebar + Products */} +
+
+
+ +
+
+
+ + } + > + + +
+
+
+ ) +} diff --git a/apps/suman-bosna/src/modules/checkout/components/address-select/index.tsx b/apps/suman-bosna/src/modules/checkout/components/address-select/index.tsx new file mode 100644 index 0000000..14a5be7 --- /dev/null +++ b/apps/suman-bosna/src/modules/checkout/components/address-select/index.tsx @@ -0,0 +1,116 @@ +import { Listbox, Transition } from "@headlessui/react" +import { ChevronsUpDown } from "lucide-react" +import { clx } from "@modules/common/components/ui" +import { Fragment, useMemo } from "react" + +import compareAddresses from "@lib/util/compare-addresses" +import { HttpTypes } from "@medusajs/types" +import Radio from "@modules/common/components/radio" + +type AddressSelectProps = { + addresses: HttpTypes.StoreCustomerAddress[] + addressInput: HttpTypes.StoreCartAddress | null + onSelect: ( + address: HttpTypes.StoreCartAddress | undefined, + email?: string + ) => void +} + +const AddressSelect = ({ + addresses, + addressInput, + onSelect, +}: AddressSelectProps) => { + const handleSelect = (id: string) => { + const savedAddress = addresses.find((a) => a.id === id) + if (savedAddress) { + onSelect(savedAddress as HttpTypes.StoreCartAddress) + } + } + + const selectedAddress = useMemo(() => { + return addresses.find((a) => addressInput && compareAddresses(a, addressInput)) + }, [addresses, addressInput]) + + return ( + +
+ + {({ open }) => ( + <> + + {selectedAddress + ? selectedAddress.address_1 + : "Choose an address"} + + + + )} + + + + {addresses.map((address) => { + return ( + +
+ +
+ + {address.first_name} {address.last_name} + + {address.company && ( + + {address.company} + + )} +
+ + {address.address_1} + {address.address_2 && ( + , {address.address_2} + )} + + + {address.postal_code}, {address.city} + + + {address.province && `${address.province}, `} + {address.country_code?.toUpperCase()} + +
+
+
+
+ ) + })} +
+
+
+
+ ) +} + +export default AddressSelect diff --git a/apps/suman-bosna/src/modules/checkout/components/addresses/index.tsx b/apps/suman-bosna/src/modules/checkout/components/addresses/index.tsx new file mode 100644 index 0000000..286db1d --- /dev/null +++ b/apps/suman-bosna/src/modules/checkout/components/addresses/index.tsx @@ -0,0 +1,184 @@ +"use client" +import { setAddresses } from "@lib/data/cart" +import useToggleState from "@lib/hooks/use-toggle-state" +import compareAddresses from "@lib/util/compare-addresses" +import { CheckCircle2 as CheckCircleSolid } from "lucide-react" +import { HttpTypes } from "@medusajs/types" +import Divider from "@modules/common/components/divider" +import { Heading, Text } from "@modules/common/components/ui" +import Spinner from "@modules/common/icons/spinner" +import { usePathname, useRouter, useSearchParams } from "next/navigation" +import { useActionState } from "react" +import BillingAddress from "../billing_address" +import ErrorMessage from "../error-message" +import ShippingAddress from "../shipping-address" +import { SubmitButton } from "../submit-button" + +const Addresses = ({ + cart, + customer, +}: { + cart: HttpTypes.StoreCart | null + customer: HttpTypes.StoreCustomer | null +}) => { + const searchParams = useSearchParams() + const router = useRouter() + const pathname = usePathname() + + const isOpen = searchParams.get("step") === "address" + + const { state: sameAsBilling, toggle: toggleSameAsBilling } = useToggleState( + cart?.shipping_address && cart?.billing_address + ? compareAddresses(cart?.shipping_address, cart?.billing_address) + : true + ) + + const handleEdit = () => { + router.push(pathname + "?step=address") + } + + const [message, formAction] = useActionState(setAddresses, null) + + return ( +
+
+ + Shipping Address + {!isOpen && } + + {!isOpen && cart?.shipping_address && ( + + + + )} +
+ {isOpen ? ( +
+
+ + + {!sameAsBilling && ( +
+ + Billing address + + + +
+ )} + + Continue to delivery + + +
+
+ ) : ( +
+
+ {cart && cart.shipping_address ? ( +
+
+
+ + Shipping Address + + + {cart.shipping_address.first_name}{" "} + {cart.shipping_address.last_name} + + + {cart.shipping_address.address_1}{" "} + {cart.shipping_address.address_2} + + + {cart.shipping_address.postal_code},{" "} + {cart.shipping_address.city} + + + {cart.shipping_address.country_code?.toUpperCase()} + +
+ +
+ + Contact + + + {cart.shipping_address.phone} + + + {cart.email} + +
+ +
+ + Billing Address + + + {sameAsBilling ? ( + + Billing and delivery address are the same. + + ) : ( + <> + + {cart.billing_address?.first_name}{" "} + {cart.billing_address?.last_name} + + + {cart.billing_address?.address_1}{" "} + {cart.billing_address?.address_2} + + + {cart.billing_address?.postal_code},{" "} + {cart.billing_address?.city} + + + {cart.billing_address?.country_code?.toUpperCase()} + + + )} +
+
+
+ ) : ( +
+ +
+ )} +
+
+ )} + +
+ ) +} + +export default Addresses diff --git a/apps/suman-bosna/src/modules/checkout/components/billing_address/index.tsx b/apps/suman-bosna/src/modules/checkout/components/billing_address/index.tsx new file mode 100644 index 0000000..4417137 --- /dev/null +++ b/apps/suman-bosna/src/modules/checkout/components/billing_address/index.tsx @@ -0,0 +1,114 @@ +import { HttpTypes } from "@medusajs/types" +import Input from "@modules/common/components/input" +import React, { useState } from "react" +import CountrySelect from "../country-select" + +const BillingAddress = ({ cart }: { cart: HttpTypes.StoreCart | null }) => { + const [formData, setFormData] = useState>({ + "billing_address.first_name": cart?.billing_address?.first_name || "", + "billing_address.last_name": cart?.billing_address?.last_name || "", + "billing_address.address_1": cart?.billing_address?.address_1 || "", + "billing_address.company": cart?.billing_address?.company || "", + "billing_address.postal_code": cart?.billing_address?.postal_code || "", + "billing_address.city": cart?.billing_address?.city || "", + "billing_address.country_code": cart?.billing_address?.country_code || "", + "billing_address.province": cart?.billing_address?.province || "", + "billing_address.phone": cart?.billing_address?.phone || "", + }) + + const handleChange = ( + e: React.ChangeEvent< + HTMLInputElement | HTMLInputElement | HTMLSelectElement + > + ) => { + setFormData({ + ...formData, + [e.target.name]: e.target.value, + }) + } + + return ( + <> +
+ + + + + + + + + +
+ + ) +} + +export default BillingAddress diff --git a/apps/suman-bosna/src/modules/checkout/components/country-select/index.tsx b/apps/suman-bosna/src/modules/checkout/components/country-select/index.tsx new file mode 100644 index 0000000..67f3d68 --- /dev/null +++ b/apps/suman-bosna/src/modules/checkout/components/country-select/index.tsx @@ -0,0 +1,50 @@ +import { forwardRef, useImperativeHandle, useMemo, useRef } from "react" + +import NativeSelect, { + NativeSelectProps, +} from "@modules/common/components/native-select" +import { HttpTypes } from "@medusajs/types" + +const CountrySelect = forwardRef< + HTMLSelectElement, + NativeSelectProps & { + region?: HttpTypes.StoreRegion + } +>(({ placeholder = "Country", region, defaultValue, ...props }, ref) => { + const innerRef = useRef(null) + + useImperativeHandle( + ref, + () => innerRef.current + ) + + const countryOptions = useMemo(() => { + if (!region) { + return [] + } + + return region.countries?.map((country) => ({ + value: country.iso_2, + label: country.display_name, + })) + }, [region]) + + return ( + + {countryOptions?.map(({ value, label }, index) => ( + + ))} + + ) +}) + +CountrySelect.displayName = "CountrySelect" + +export default CountrySelect diff --git a/apps/suman-bosna/src/modules/checkout/components/discount-code/index.tsx b/apps/suman-bosna/src/modules/checkout/components/discount-code/index.tsx new file mode 100644 index 0000000..224b595 --- /dev/null +++ b/apps/suman-bosna/src/modules/checkout/components/discount-code/index.tsx @@ -0,0 +1,150 @@ +"use client" + +import React, { useState } from "react" +import { applyPromotions } from "@lib/data/cart" +import { convertToLocale } from "@lib/util/money" +import { HttpTypes } from "@medusajs/types" +import { Button } from "@/components/ui/button" +import { Input } from "@/components/ui/input" +import { Badge } from "@/components/ui/badge" +import { Trash2, Tag } from "lucide-react" +import ErrorMessage from "../error-message" +import { SubmitButton } from "../submit-button" + +type DiscountCodeProps = { + cart: HttpTypes.StoreCart +} + +const DiscountCode: React.FC = ({ cart }) => { + const [isOpen, setIsOpen] = useState(false) + const [errorMessage, setErrorMessage] = useState("") + + const { promotions = [] } = cart + + const removePromotionCode = async (code: string) => { + const validPromotions = promotions.filter( + (promotion) => promotion.code !== code + ) + + await applyPromotions( + validPromotions.filter((p) => p.code !== undefined).map((p) => p.code!) + ) + } + + const addPromotionCode = async (formData: FormData) => { + setErrorMessage("") + + const code = formData.get("code") + if (!code) { + return + } + const input = document.getElementById("promotion-input") as HTMLInputElement + const codes = promotions + .filter((p) => p.code !== undefined) + .map((p) => p.code!) + codes.push(code.toString()) + + try { + await applyPromotions(codes) + } catch (e) { + setErrorMessage(e instanceof Error ? e.message : String(e)) + } + + if (input) { + input.value = "" + } + } + + return ( +
+
addPromotionCode(a)} className="w-full"> + + + {isOpen && ( +
+
+ + + Primijeni + +
+ + +
+ )} +
+ + {promotions.length > 0 && ( +
+ + Primijenjeni popusti: + + + {promotions.map((promotion) => ( +
+
+ + {promotion.code} + + {promotion.application_method?.value !== undefined && + promotion.application_method.currency_code !== undefined && ( + + ({promotion.application_method.type === "percentage" + ? `${promotion.application_method.value}%` + : convertToLocale({ + amount: +promotion.application_method.value, + currency_code: + promotion.application_method.currency_code, + })}) + + )} +
+ {!promotion.is_automatic && ( + + )} +
+ ))} +
+ )} +
+ ) +} + +export default DiscountCode diff --git a/apps/suman-bosna/src/modules/checkout/components/error-message/index.tsx b/apps/suman-bosna/src/modules/checkout/components/error-message/index.tsx new file mode 100644 index 0000000..05f2dec --- /dev/null +++ b/apps/suman-bosna/src/modules/checkout/components/error-message/index.tsx @@ -0,0 +1,19 @@ +const ErrorMessage = ({ + error, + "data-testid": dataTestid, +}: { + error?: string | null + "data-testid"?: string +}) => { + if (!error) { + return null + } + + return ( +
+ {error} +
+ ) +} + +export default ErrorMessage diff --git a/apps/suman-bosna/src/modules/checkout/components/payment-button/adyen-payment-button.tsx b/apps/suman-bosna/src/modules/checkout/components/payment-button/adyen-payment-button.tsx new file mode 100644 index 0000000..cc4d1f2 --- /dev/null +++ b/apps/suman-bosna/src/modules/checkout/components/payment-button/adyen-payment-button.tsx @@ -0,0 +1,167 @@ +"use client" + +import "@adyen/adyen-web/styles/adyen.css" + +import type { + AdditionalDetailsActions, + PaymentAction, + PaymentMethodsResponse, + ResultCode, + SubmitActions, +} from "@adyen/adyen-web" +import { isAdyen } from "@lib/constants" +import { AdyenPaymentResult, submitAdyenPayment } from "@lib/data/adyen" +import { HttpTypes } from "@medusajs/types" +import { Button } from "@modules/common/components/ui" +import { useParams } from "next/navigation" +import { useEffect, useRef, useState } from "react" +import ErrorMessage from "../error-message" + +const clientKey = process.env.NEXT_PUBLIC_ADYEN_CLIENT_KEY +const environment = + process.env.NEXT_PUBLIC_ADYEN_ENVIRONMENT === "live" ? "live" : "test" + +type AdyenPaymentButtonProps = { + cart: HttpTypes.StoreCart + notReady: boolean + "data-testid"?: string +} + +// Renders Adyen's Drop-in, whose pay button places the order. The session's data holds the +// payment methods Drop-in offers, which are cards, Apple Pay, and Google Pay. +const AdyenPaymentButton = ({ + cart, + notReady, + "data-testid": dataTestId, +}: AdyenPaymentButtonProps) => { + const containerRef = useRef(null) + const [errorMessage, setErrorMessage] = useState(null) + const { countryCode } = useParams() + + const session = cart.payment_collection?.payment_sessions?.find((s) => + isAdyen(s.provider_id) + ) + + useEffect(() => { + if (!session || notReady || !clientKey || !containerRef.current) { + return + } + + let cancelled = false + let unmount: (() => void) | undefined + + const handleResult = ( + result: AdyenPaymentResult, + actions: SubmitActions | AdditionalDetailsActions + ) => { + if ("action" in result) { + actions.resolve({ + resultCode: result.resultCode as ResultCode, + action: result.action as unknown as PaymentAction, + }) + return + } + + setErrorMessage(result.error) + actions.reject() + } + + const mount = async () => { + const { AdyenCheckout, Dropin, Card, ApplePay, GooglePay } = await import( + "@adyen/adyen-web" + ) + + const checkout = await AdyenCheckout({ + clientKey, + environment, + locale: "en-US", + countryCode: cart.billing_address?.country_code?.toUpperCase(), + amount: { + value: session.data?.amount as number, + currency: session.data?.currency as string, + }, + paymentMethodsResponse: session.data + ?.payment_methods as PaymentMethodsResponse, + onSubmit: async (state, _component, actions) => { + setErrorMessage(null) + handleResult( + await submitAdyenPayment({ + payment_method: state.data.paymentMethod, + browser_info: state.data.browserInfo, + store_payment_method: state.data.storePaymentMethod, + origin: window.location.origin, + // Used when the shopper's bank redirects them for authentication. + return_url: `${window.location.origin}/api/payment-return?cart_id=${cart.id}&country_code=${countryCode}`, + }), + actions + ) + }, + onAdditionalDetails: async (state, _component, actions) => { + handleResult( + await submitAdyenPayment({ details: state.data.details }), + actions + ) + }, + onError: (error) => { + // Closing a wallet's payment sheet isn't an error worth showing. + if (error.name !== "CANCEL") { + setErrorMessage("Could not process the payment. Please try again.") + } + }, + }) + + if (cancelled || !containerRef.current) { + return + } + + const dropin = new Dropin(checkout, { + paymentMethodComponents: [Card, ApplePay, GooglePay], + paymentMethodsConfiguration: { + card: { + hasHolderName: true, + holderNameRequired: true, + // Saving cards needs an account holder, which only logged-in customers have. + enableStoreDetails: !!session.data?.shopper_reference, + }, + }, + }).mount(containerRef.current) + + unmount = () => dropin.unmount() + } + + mount().catch(() => { + setErrorMessage("Could not load the payment methods.") + }) + + return () => { + cancelled = true + unmount?.() + } + // Drop-in is mounted once per session, so the shopper's input isn't lost when the cart refreshes. + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [session?.id, notReady]) + + if (notReady) { + return ( + + ) + } + + return ( + <> +
+ + + ) +} + +export default AdyenPaymentButton diff --git a/apps/suman-bosna/src/modules/checkout/components/payment-button/index.tsx b/apps/suman-bosna/src/modules/checkout/components/payment-button/index.tsx new file mode 100644 index 0000000..2acc0dc --- /dev/null +++ b/apps/suman-bosna/src/modules/checkout/components/payment-button/index.tsx @@ -0,0 +1,212 @@ +"use client" + +import { isAdyen, isManual, isStripeLike } from "@lib/constants" +import { placeOrder } from "@lib/data/cart" +import { HttpTypes } from "@medusajs/types" +import { Button } from "@modules/common/components/ui" +import { useElements, useStripe } from "@stripe/react-stripe-js" +import { useParams } from "next/navigation" +import React, { useState } from "react" +import ErrorMessage from "../error-message" +import { getPaymentErrorMessage } from "@lib/util/payment-error" +import AdyenPaymentButton from "./adyen-payment-button" + +type PaymentButtonProps = { + cart: HttpTypes.StoreCart + "data-testid": string +} + +const PaymentButton: React.FC = ({ + cart, + "data-testid": dataTestId, +}) => { + const notReady = + !cart || + !cart.shipping_address || + !cart.billing_address || + !cart.email || + (cart.shipping_methods?.length ?? 0) < 1 + + const paymentSession = cart.payment_collection?.payment_sessions?.[0] + + switch (true) { + case isStripeLike(paymentSession?.provider_id): + return ( + + ) + case isAdyen(paymentSession?.provider_id): + return ( + + ) + case isManual(paymentSession?.provider_id): + return ( + + ) + default: + return + } +} + +const StripePaymentButton = ({ + cart, + notReady, + "data-testid": dataTestId, +}: { + cart: HttpTypes.StoreCart + notReady: boolean + "data-testid"?: string +}) => { + const [submitting, setSubmitting] = useState(false) + const [errorMessage, setErrorMessage] = useState(null) + + const onPaymentCompleted = async () => { + await placeOrder() + .catch((err) => { + setErrorMessage(err.message) + }) + .finally(() => { + setSubmitting(false) + }) + } + + const stripe = useStripe() + const elements = useElements() + const { countryCode } = useParams() + + const disabled = !stripe || !elements ? true : false + + const handlePayment = async () => { + if (!stripe || !elements || !cart) { + return + } + + setSubmitting(true) + + await stripe + .confirmPayment({ + elements, + confirmParams: { + return_url: `${window.location.origin}/api/payment-return?cart_id=${cart.id}&country_code=${countryCode}`, + payment_method_data: { + billing_details: { + name: + cart.billing_address?.first_name + + " " + + cart.billing_address?.last_name, + address: { + city: cart.billing_address?.city ?? undefined, + country: cart.billing_address?.country_code ?? undefined, + line1: cart.billing_address?.address_1 ?? undefined, + line2: cart.billing_address?.address_2 ?? undefined, + postal_code: cart.billing_address?.postal_code ?? undefined, + state: cart.billing_address?.province ?? undefined, + }, + email: cart.email, + phone: cart.billing_address?.phone ?? undefined, + }, + }, + }, + // Only leave the site when the selected method actually requires it, so + // card payments still complete inline. + redirect: "if_required", + }) + .then(({ error, paymentIntent }) => { + if (error) { + const pi = error.payment_intent + + if ( + (pi && pi.status === "requires_capture") || + (pi && pi.status === "succeeded") + ) { + onPaymentCompleted() + return + } + + setErrorMessage(getPaymentErrorMessage(error)) + setSubmitting(false) + return + } + + if ( + paymentIntent.status === "requires_capture" || + paymentIntent.status === "succeeded" + ) { + onPaymentCompleted() + return + } + + setSubmitting(false) + }) + .catch((error) => { + setErrorMessage(getPaymentErrorMessage(error)) + setSubmitting(false) + }) + } + + return ( + <> + + + + ) +} + +const ManualTestPaymentButton = ({ notReady }: { notReady: boolean }) => { + const [submitting, setSubmitting] = useState(false) + const [errorMessage, setErrorMessage] = useState(null) + + const onPaymentCompleted = async () => { + await placeOrder() + .catch((err) => { + setErrorMessage(err.message) + }) + .finally(() => { + setSubmitting(false) + }) + } + + const handlePayment = () => { + setSubmitting(true) + + onPaymentCompleted() + } + + return ( + <> + + + + ) +} + +export default PaymentButton diff --git a/apps/suman-bosna/src/modules/checkout/components/payment-container/index.tsx b/apps/suman-bosna/src/modules/checkout/components/payment-container/index.tsx new file mode 100644 index 0000000..2916217 --- /dev/null +++ b/apps/suman-bosna/src/modules/checkout/components/payment-container/index.tsx @@ -0,0 +1,115 @@ +import { Radio as RadioGroupOption } from "@headlessui/react" +import { Text, clx } from "@modules/common/components/ui" +import React, { useContext } from "react" + +import Radio from "@modules/common/components/radio" + +import { getPaymentInfo, isManual } from "@lib/constants" +import { getPaymentErrorMessage } from "@lib/util/payment-error" +import SkeletonCardDetails from "@modules/skeletons/components/skeleton-card-details" +import { PaymentElement } from "@stripe/react-stripe-js" +import PaymentTest from "../payment-test" +import { StripeContext } from "../payment-wrapper/stripe-wrapper" + +type PaymentContainerProps = { + paymentProviderId: string + selectedPaymentOptionId: string | null + disabled?: boolean + children?: React.ReactNode +} + +const PaymentContainer: React.FC = ({ + paymentProviderId, + selectedPaymentOptionId, + disabled = false, + children, +}) => { + const isDevelopment = process.env.NODE_ENV === "development" + const paymentInfo = getPaymentInfo(paymentProviderId) + + return ( + +
+
+ + + {paymentInfo?.title || paymentProviderId} + + {isManual(paymentProviderId) && isDevelopment && ( + + )} +
+ + {paymentInfo?.icon} + +
+ {isManual(paymentProviderId) && isDevelopment && ( + + )} + {children} +
+ ) +} + +export default PaymentContainer + +export const StripePaymentContainer = ({ + paymentProviderId, + selectedPaymentOptionId, + disabled = false, + setError, + setPaymentComplete, +}: Omit & { + setError: (error: string | null) => void + setPaymentComplete: (complete: boolean) => void +}) => { + const stripeReady = useContext(StripeContext) + + return ( + + {selectedPaymentOptionId === paymentProviderId && + (stripeReady ? ( +
+ + Enter your payment details: + + { + setError(null) + setPaymentComplete(e.complete) + }} + // Without a handler Stripe.js reports a failed mount as an + // unhandled "payment Element loaderror" and the option renders + // blank with no explanation. Surface it in the checkout's own + // error slot instead. + onLoadError={(e) => { + setPaymentComplete(false) + setError( + getPaymentErrorMessage(e.error) ?? + "Could not load the payment methods." + ) + }} + /> +
+ ) : ( + + ))} +
+ ) +} diff --git a/apps/suman-bosna/src/modules/checkout/components/payment-test/index.tsx b/apps/suman-bosna/src/modules/checkout/components/payment-test/index.tsx new file mode 100644 index 0000000..dd96ab6 --- /dev/null +++ b/apps/suman-bosna/src/modules/checkout/components/payment-test/index.tsx @@ -0,0 +1,12 @@ +import { Badge } from "@modules/common/components/ui" + +const PaymentTest = ({ className }: { className?: string }) => { + return ( + + Attention: For testing purposes + only. + + ) +} + +export default PaymentTest diff --git a/apps/suman-bosna/src/modules/checkout/components/payment-wrapper/index.tsx b/apps/suman-bosna/src/modules/checkout/components/payment-wrapper/index.tsx new file mode 100644 index 0000000..b1fc866 --- /dev/null +++ b/apps/suman-bosna/src/modules/checkout/components/payment-wrapper/index.tsx @@ -0,0 +1,65 @@ +"use client" + +import { loadStripe, Stripe } from "@stripe/stripe-js" +import React from "react" +import StripeWrapper from "./stripe-wrapper" +import { HttpTypes } from "@medusajs/types" +import { + getMedusaPaymentsAccount, + isMedusaPayments, + isStripeLike, +} from "@lib/constants" + +type PaymentWrapperProps = { + cart: HttpTypes.StoreCart + children: React.ReactNode +} + +const stripeKey = process.env.NEXT_PUBLIC_STRIPE_KEY +const medusaPaymentsKey = + process.env.NEXT_PUBLIC_MEDUSA_PAYMENTS_PUBLISHABLE_KEY + +// loadStripe should only be called once per configuration, so we cache the promises. +const stripePromises = new Map>() + +const getStripePromise = (key: string, stripeAccount?: string) => { + const cacheKey = `${key}:${stripeAccount ?? ""}` + if (!stripePromises.has(cacheKey)) { + stripePromises.set( + cacheKey, + loadStripe(key, stripeAccount ? { stripeAccount } : undefined) + ) + } + return stripePromises.get(cacheKey)! +} + +const PaymentWrapper: React.FC = ({ cart, children }) => { + const paymentSession = cart.payment_collection?.payment_sessions?.find( + (s) => s.status === "pending" + ) + + if (paymentSession && isStripeLike(paymentSession.provider_id)) { + // Medusa Payments creates the payment on the account's Stripe connected account, + // so Stripe.js needs to be initialized for that account. + const key = isMedusaPayments(paymentSession.provider_id) + ? medusaPaymentsKey + : stripeKey + const stripePromise = key + ? getStripePromise(key, getMedusaPaymentsAccount(paymentSession)) + : null + + return ( + + {children} + + ) + } + + return
{children}
+} + +export default PaymentWrapper diff --git a/apps/suman-bosna/src/modules/checkout/components/payment-wrapper/stripe-wrapper.tsx b/apps/suman-bosna/src/modules/checkout/components/payment-wrapper/stripe-wrapper.tsx new file mode 100644 index 0000000..3bf75ff --- /dev/null +++ b/apps/suman-bosna/src/modules/checkout/components/payment-wrapper/stripe-wrapper.tsx @@ -0,0 +1,54 @@ +"use client" + +import { Stripe, StripeElementsOptions } from "@stripe/stripe-js" +import { Elements } from "@stripe/react-stripe-js" +import { HttpTypes } from "@medusajs/types" +import { createContext } from "react" + +type StripeWrapperProps = { + paymentSession: HttpTypes.StorePaymentSession + stripeKey?: string + stripePromise: Promise | null + children: React.ReactNode +} + +export const StripeContext = createContext(false) + +const StripeWrapper: React.FC = ({ + paymentSession, + stripeKey, + stripePromise, + children, +}) => { + const options: StripeElementsOptions = { + clientSecret: paymentSession!.data?.client_secret as string | undefined, + } + + if (!stripeKey) { + throw new Error( + "Stripe key is missing. Set the NEXT_PUBLIC_STRIPE_KEY (Stripe) or NEXT_PUBLIC_MEDUSA_PAYMENTS_PUBLISHABLE_KEY (Medusa Payments) environment variable." + ) + } + + if (!stripePromise) { + throw new Error( + "Stripe promise is missing. Make sure you have provided a valid Stripe key." + ) + } + + if (!paymentSession?.data?.client_secret) { + throw new Error( + "Stripe client secret is missing. Cannot initialize Stripe." + ) + } + + return ( + + + {children} + + + ) +} + +export default StripeWrapper diff --git a/apps/suman-bosna/src/modules/checkout/components/payment/index.tsx b/apps/suman-bosna/src/modules/checkout/components/payment/index.tsx new file mode 100644 index 0000000..7252c67 --- /dev/null +++ b/apps/suman-bosna/src/modules/checkout/components/payment/index.tsx @@ -0,0 +1,258 @@ +"use client" +import { RadioGroup } from "@headlessui/react" +import { getPaymentInfo, isStripeLike } from "@lib/constants" +import { initiatePaymentSession } from "@lib/data/cart" +import { CheckCircle2 as CheckCircleSolid, CreditCard } from "lucide-react" +import ErrorMessage from "@modules/checkout/components/error-message" +import PaymentContainer, { + StripePaymentContainer, +} from "@modules/checkout/components/payment-container" +import Divider from "@modules/common/components/divider" +import { + Button, + Container, + Heading, + Text, + clx, +} from "@modules/common/components/ui" +import { HttpTypes } from "@medusajs/types" +import { usePathname, useRouter, useSearchParams } from "next/navigation" +import { useCallback, useEffect, useState } from "react" + +const Payment = ({ + cart, + availablePaymentMethods, +}: { + cart: HttpTypes.StoreCart + availablePaymentMethods: { id: string }[] +}) => { + const activeSession = cart.payment_collection?.payment_sessions?.find( + (paymentSession) => paymentSession.status === "pending" + ) + + const [isLoading, setIsLoading] = useState(false) + const [error, setError] = useState(null) + const [paymentComplete, setPaymentComplete] = useState(false) + const [selectedPaymentMethod, setSelectedPaymentMethod] = useState( + activeSession?.provider_id ?? "" + ) + + const searchParams = useSearchParams() + const router = useRouter() + const pathname = usePathname() + + const isOpen = searchParams.get("step") === "payment" + + const setPaymentMethod = async (method: string) => { + setError(null) + setSelectedPaymentMethod(method) + if (isStripeLike(method)) { + await initiatePaymentSession(cart, { + provider_id: method, + }) + } + } + + const paidByGiftcard = !!( + (cart as unknown as Record)?.gift_cards && ((cart as unknown as Record)?.gift_cards as unknown[])?.length > 0 && cart?.total === 0 + ) + + const paymentReady = + (activeSession && (cart?.shipping_methods?.length ?? 0) !== 0) || paidByGiftcard + + const createQueryString = useCallback( + (name: string, value: string) => { + const params = new URLSearchParams(searchParams) + params.set(name, value) + + return params.toString() + }, + [searchParams] + ) + + const handleEdit = () => { + router.push(pathname + "?" + createQueryString("step", "payment"), { + scroll: false, + }) + } + + const handleSubmit = async () => { + setIsLoading(true) + try { + const shouldInputPaymentDetails = + isStripeLike(selectedPaymentMethod) && !activeSession + + const checkActiveSession = + activeSession?.provider_id === selectedPaymentMethod + + if (!checkActiveSession) { + await initiatePaymentSession(cart, { + provider_id: selectedPaymentMethod, + }) + } + + if (!shouldInputPaymentDetails) { + return router.push( + pathname + "?" + createQueryString("step", "review"), + { + scroll: false, + } + ) + } + } catch (err) { + setError(err instanceof Error ? err.message : String(err)) + } finally { + setIsLoading(false) + } + } + + useEffect(() => { + setError(null) + }, [isOpen]) + + return ( +
+
+ + Payment + {!isOpen && paymentReady && } + + {!isOpen && paymentReady && ( + + + + )} +
+
+
+ {!paidByGiftcard && availablePaymentMethods?.length && ( + <> + setPaymentMethod(value)} + > + {availablePaymentMethods.map((paymentMethod) => ( +
+ {isStripeLike(paymentMethod.id) ? ( + + ) : ( + + )} +
+ ))} +
+ + )} + + {paidByGiftcard && ( +
+ + Payment method + + + Gift card + +
+ )} + + + + +
+ +
+ {cart && paymentReady && activeSession ? ( +
+
+ + Payment method + + + {getPaymentInfo(activeSession?.provider_id)?.title || + activeSession?.provider_id} + +
+
+ + Payment details + +
+ + {getPaymentInfo(selectedPaymentMethod)?.icon || ( + + )} + + Another step will appear +
+
+
+ ) : paidByGiftcard ? ( +
+ + Payment method + + + Gift card + +
+ ) : null} +
+
+ +
+ ) +} + +export default Payment diff --git a/apps/suman-bosna/src/modules/checkout/components/review/index.tsx b/apps/suman-bosna/src/modules/checkout/components/review/index.tsx new file mode 100644 index 0000000..0d29def --- /dev/null +++ b/apps/suman-bosna/src/modules/checkout/components/review/index.tsx @@ -0,0 +1,57 @@ +"use client" + +import { Heading, Text, clx } from "@modules/common/components/ui" + +import PaymentButton from "../payment-button" +import { useSearchParams } from "next/navigation" +import { HttpTypes } from "@medusajs/types" + +const Review = ({ cart }: { cart: HttpTypes.StoreCart }) => { + const searchParams = useSearchParams() + + const isOpen = searchParams.get("step") === "review" + + const paidByGiftcard = !!( + (cart as unknown as Record)?.gift_cards && ((cart as unknown as Record)?.gift_cards as unknown[])?.length > 0 && cart?.total === 0 + ) + + const previousStepsCompleted = + cart.shipping_address && + (cart.shipping_methods?.length ?? 0) > 0 && + (cart.payment_collection || paidByGiftcard) + + return ( +
+
+ + Review + +
+ {isOpen && previousStepsCompleted && ( + <> +
+
+ + By clicking the Place Order button, you confirm that you have + read, understand and accept our Terms of Use, Terms of Sale and + Returns Policy and acknowledge that you have read Medusa + Store's Privacy Policy. + +
+
+ + + )} +
+ ) +} + +export default Review diff --git a/apps/suman-bosna/src/modules/checkout/components/shipping-address/index.tsx b/apps/suman-bosna/src/modules/checkout/components/shipping-address/index.tsx new file mode 100644 index 0000000..618ef33 --- /dev/null +++ b/apps/suman-bosna/src/modules/checkout/components/shipping-address/index.tsx @@ -0,0 +1,258 @@ +import { HttpTypes } from "@medusajs/types" +import { Container } from "@modules/common/components/ui" +import Checkbox from "@modules/common/components/checkbox" +import Input from "@modules/common/components/input" +import { mapKeys } from "lodash" +import React, { useEffect, useMemo, useState } from "react" +import AddressSelect from "../address-select" +import CountrySelect from "../country-select" + +const ShippingAddress = ({ + customer, + cart, + checked, + onChange, +}: { + customer: HttpTypes.StoreCustomer | null + cart: HttpTypes.StoreCart | null + checked: boolean + onChange: () => void +}) => { + const [formData, setFormData] = useState>({ + "shipping_address.first_name": cart?.shipping_address?.first_name || "", + "shipping_address.last_name": cart?.shipping_address?.last_name || "", + "shipping_address.address_1": cart?.shipping_address?.address_1 || "", + "shipping_address.company": cart?.shipping_address?.company || "", + "shipping_address.postal_code": cart?.shipping_address?.postal_code || "", + "shipping_address.city": cart?.shipping_address?.city || "", + "shipping_address.country_code": cart?.shipping_address?.country_code || "", + "shipping_address.province": cart?.shipping_address?.province || "", + "shipping_address.phone": cart?.shipping_address?.phone || "", + email: cart?.email || "", + }) + + const [isBusiness, setIsBusiness] = useState( + Boolean((cart?.shipping_address?.metadata as any)?.is_business) + ) + const [jib, setJib] = useState( + ((cart?.shipping_address?.metadata as any)?.jib as string) || "" + ) + const [pdv, setPdv] = useState( + ((cart?.shipping_address?.metadata as any)?.pdv as string) || "" + ) + + const countriesInRegion = useMemo( + () => cart?.region?.countries?.map((c) => c.iso_2), + [cart?.region] + ) + + // check if customer has saved addresses that are in the current region + const addressesInRegion = useMemo( + () => + customer?.addresses.filter( + (a) => a.country_code && countriesInRegion?.includes(a.country_code) + ), + [customer?.addresses, countriesInRegion] + ) + + const setFormAddress = ( + address?: HttpTypes.StoreCartAddress, + email?: string + ) => { + if (address) { + setFormData((prevState: Record) => ({ + ...prevState, + "shipping_address.first_name": address?.first_name || "", + "shipping_address.last_name": address?.last_name || "", + "shipping_address.address_1": address?.address_1 || "", + "shipping_address.company": address?.company || "", + "shipping_address.postal_code": address?.postal_code || "", + "shipping_address.city": address?.city || "", + "shipping_address.country_code": address?.country_code || "", + "shipping_address.province": address?.province || "", + "shipping_address.phone": address?.phone || "", + })) + } + + if (email) { + setFormData((prevState: Record) => ({ + ...prevState, + email: email, + })) + } + } + + useEffect(() => { + // Ensure cart is not null and has a shipping_address before setting form data + if (cart && cart.shipping_address) { + setFormAddress(cart?.shipping_address, cart?.email) + } + + if (cart && !cart.email && customer?.email) { + setFormAddress(undefined, customer.email) + } + }, [cart]) // Add cart as a dependency + + const handleChange = ( + e: React.ChangeEvent< + HTMLInputElement | HTMLInputElement | HTMLSelectElement + > + ) => { + setFormData({ + ...formData, + [e.target.name]: e.target.value, + }) + } + + return ( + <> + {customer && (addressesInRegion?.length || 0) > 0 && ( + +

+ {`Hi ${customer.first_name}, do you want to use one of your saved addresses?`} +

+ + key.replace("shipping_address.", "") + ) as unknown as HttpTypes.StoreCartAddress + } + onSelect={setFormAddress} + /> +
+ )} +
+ + + + +
+ setIsBusiness(!isBusiness)} + /> + {isBusiness && ( +
+ setJib(e.target.value)} + required={isBusiness} + /> + setPdv(e.target.value)} + /> +
+ )} +
+ + + + +
+
+ +
+
+ + +
+ + ) +} + +export default ShippingAddress diff --git a/apps/suman-bosna/src/modules/checkout/components/shipping/index.tsx b/apps/suman-bosna/src/modules/checkout/components/shipping/index.tsx new file mode 100644 index 0000000..53d195c --- /dev/null +++ b/apps/suman-bosna/src/modules/checkout/components/shipping/index.tsx @@ -0,0 +1,411 @@ +"use client" +import { Radio, RadioGroup } from "@headlessui/react" +import { setShippingMethod } from "@lib/data/cart" +import { calculatePriceForShippingOption } from "@lib/data/fulfillment" +import { convertToLocale } from "@lib/util/money" +import { CheckCircle2 as CheckCircleSolid, Loader2 as Loader } from "lucide-react" +import { HttpTypes } from "@medusajs/types" +import ErrorMessage from "@modules/checkout/components/error-message" +import Divider from "@modules/common/components/divider" +import MedusaRadio from "@modules/common/components/radio" +import { Button, clx, Heading, Text } from "@modules/common/components/ui" +import { usePathname, useRouter, useSearchParams } from "next/navigation" +import { useEffect, useState } from "react" + +const PICKUP_OPTION_ON = "__PICKUP_ON" +const PICKUP_OPTION_OFF = "__PICKUP_OFF" + +type ShippingProps = { + cart: HttpTypes.StoreCart + availableShippingMethods: HttpTypes.StoreCartShippingOption[] | null +} + +function formatAddress(address: HttpTypes.StoreCartAddress) { + if (!address) { + return "" + } + + let ret = "" + + if (address.address_1) { + ret += ` ${address.address_1}` + } + + if (address.address_2) { + ret += `, ${address.address_2}` + } + + if (address.postal_code) { + ret += `, ${address.postal_code} ${address.city}` + } + + if (address.country_code) { + ret += `, ${address.country_code.toUpperCase()}` + } + + return ret +} + +const Shipping: React.FC = ({ + cart, + availableShippingMethods, +}) => { + const [isLoading, setIsLoading] = useState(false) + const [isLoadingPrices, setIsLoadingPrices] = useState(true) + + const [showPickupOptions, setShowPickupOptions] = + useState(PICKUP_OPTION_OFF) + const [calculatedPricesMap, setCalculatedPricesMap] = useState< + Record + >({}) + const [error, setError] = useState(null) + const [shippingMethodId, setShippingMethodId] = useState( + cart.shipping_methods?.at(-1)?.shipping_option_id || null + ) + + const searchParams = useSearchParams() + const router = useRouter() + const pathname = usePathname() + + const isOpen = searchParams.get("step") === "delivery" + + const _shippingMethods = availableShippingMethods?.filter( + (sm) => (sm as unknown as { service_zone?: { fulfillment_set?: { type?: string; location?: { address: HttpTypes.StoreCartAddress } } } }).service_zone?.fulfillment_set?.type !== "pickup" + ) + + const _pickupMethods = availableShippingMethods?.filter( + (sm) => (sm as unknown as { service_zone?: { fulfillment_set?: { type?: string; location?: { address: HttpTypes.StoreCartAddress } } } }).service_zone?.fulfillment_set?.type === "pickup" + ) + + const hasPickupOptions = !!_pickupMethods?.length + + useEffect(() => { + setIsLoadingPrices(true) + + if (_shippingMethods?.length) { + const promises = _shippingMethods + .filter((sm) => sm.price_type === "calculated") + .map((sm) => calculatePriceForShippingOption(sm.id, cart.id)) + + if (promises.length) { + Promise.allSettled(promises).then((res) => { + const pricesMap: Record = {} + res + .filter((r) => r.status === "fulfilled") + .forEach((p) => { + if (p.value?.id) { + pricesMap[p.value.id] = p.value.amount ?? 0 + } + }) + + setCalculatedPricesMap(pricesMap) + setIsLoadingPrices(false) + }) + } + } + + if (_pickupMethods?.find((m) => m.id === shippingMethodId)) { + setShowPickupOptions(PICKUP_OPTION_ON) + } + }, [availableShippingMethods]) + + const handleEdit = () => { + router.push(pathname + "?step=delivery", { scroll: false }) + } + + const handleSubmit = () => { + router.push(pathname + "?step=payment", { scroll: false }) + } + + const handleSetShippingMethod = async ( + id: string, + variant: "shipping" | "pickup" + ) => { + setError(null) + + if (variant === "pickup") { + setShowPickupOptions(PICKUP_OPTION_ON) + } else { + setShowPickupOptions(PICKUP_OPTION_OFF) + } + + let currentId: string | null = null + setIsLoading(true) + setShippingMethodId((prev) => { + currentId = prev + return id + }) + + await setShippingMethod({ cartId: cart.id, shippingMethodId: id }) + .catch((err) => { + setShippingMethodId(currentId) + + setError(err.message) + }) + .finally(() => { + setIsLoading(false) + }) + } + + useEffect(() => { + setError(null) + }, [isOpen]) + + return ( +
+
+ + Delivery + {!isOpen && (cart.shipping_methods?.length ?? 0) > 0 && ( + + )} + + {!isOpen && + cart?.shipping_address && + cart?.billing_address && + cart?.email && ( + + + + )} +
+ {isOpen ? ( + <> +
+
+ + Shipping method + + + How would you like you order delivered + +
+
+
+ {hasPickupOptions && ( + { + const id = _pickupMethods.find( + (option) => !option.insufficient_inventory + )?.id + + if (id) { + handleSetShippingMethod(id, "pickup") + } + }} + > + +
+ + + Pick up your order + +
+ + - + +
+
+ )} + { + if (v) { + return handleSetShippingMethod(v, "shipping") + } + }} + > + {_shippingMethods?.map((option) => { + const isDisabled = + option.price_type === "calculated" && + !isLoadingPrices && + typeof calculatedPricesMap[option.id] !== "number" + + return ( + +
+ + + {option.name} + +
+ + {option.price_type === "flat" ? ( + convertToLocale({ + amount: option.amount!, + currency_code: cart?.currency_code, + }) + ) : calculatedPricesMap[option.id] ? ( + convertToLocale({ + amount: calculatedPricesMap[option.id], + currency_code: cart?.currency_code, + }) + ) : isLoadingPrices ? ( + + ) : ( + "-" + )} + +
+ ) + })} +
+
+
+
+ + {showPickupOptions === PICKUP_OPTION_ON && ( +
+
+ + Store + + + Choose a store near you + +
+
+
+ { + if (v) { + return handleSetShippingMethod(v, "pickup") + } + }} + > + {_pickupMethods?.map((option) => { + return ( + +
+ +
+ + {option.name} + + + {formatAddress( + (option as unknown as { service_zone?: { fulfillment_set?: { location?: { address: HttpTypes.StoreCartAddress } } } }).service_zone?.fulfillment_set?.location + ?.address as HttpTypes.StoreCartAddress + )} + +
+
+ + {convertToLocale({ + amount: option.amount!, + currency_code: cart?.currency_code, + })} + +
+ ) + })} +
+
+
+
+ )} + +
+ + +
+ + ) : ( +
+
+ {cart && (cart.shipping_methods?.length ?? 0) > 0 && ( +
+ + Method + + + {cart.shipping_methods!.at(-1)!.name}{" "} + {convertToLocale({ + amount: cart.shipping_methods!.at(-1)!.amount!, + currency_code: cart?.currency_code, + })} + +
+ )} +
+
+ )} + +
+ ) +} + +export default Shipping diff --git a/apps/suman-bosna/src/modules/checkout/components/submit-button/index.tsx b/apps/suman-bosna/src/modules/checkout/components/submit-button/index.tsx new file mode 100644 index 0000000..7690538 --- /dev/null +++ b/apps/suman-bosna/src/modules/checkout/components/submit-button/index.tsx @@ -0,0 +1,34 @@ +"use client" + +import { Button } from "@modules/common/components/ui" +import React from "react" +import { useFormStatus } from "react-dom" + +export function SubmitButton({ + children, + variant = "primary", + size = "medium", + className, + "data-testid": dataTestId, +}: { + children: React.ReactNode + variant?: "primary" | "secondary" | "transparent" | null + size?: "small" | "medium" | "large" + className?: string + "data-testid"?: string +}) { + const { pending } = useFormStatus() + + return ( + + ) +} diff --git a/apps/suman-bosna/src/modules/checkout/templates/checkout-form/index.tsx b/apps/suman-bosna/src/modules/checkout/templates/checkout-form/index.tsx new file mode 100644 index 0000000..e7e8964 --- /dev/null +++ b/apps/suman-bosna/src/modules/checkout/templates/checkout-form/index.tsx @@ -0,0 +1,38 @@ +import { listCartShippingMethods } from "@lib/data/fulfillment" +import { listCartPaymentMethods } from "@lib/data/payment" +import { HttpTypes } from "@medusajs/types" +import Addresses from "@modules/checkout/components/addresses" +import Payment from "@modules/checkout/components/payment" +import Review from "@modules/checkout/components/review" +import Shipping from "@modules/checkout/components/shipping" + +export default async function CheckoutForm({ + cart, + customer, +}: { + cart: HttpTypes.StoreCart | null + customer: HttpTypes.StoreCustomer | null +}) { + if (!cart) { + return null + } + + const shippingMethods = await listCartShippingMethods(cart.id) + const paymentMethods = await listCartPaymentMethods(cart.region?.id ?? "") + + if (!shippingMethods || !paymentMethods) { + return null + } + + return ( +
+ + + + + + + +
+ ) +} diff --git a/apps/suman-bosna/src/modules/checkout/templates/checkout-summary/index.tsx b/apps/suman-bosna/src/modules/checkout/templates/checkout-summary/index.tsx new file mode 100644 index 0000000..cf2f018 --- /dev/null +++ b/apps/suman-bosna/src/modules/checkout/templates/checkout-summary/index.tsx @@ -0,0 +1,31 @@ +import { Heading } from "@modules/common/components/ui" + +import ItemsPreviewTemplate from "@modules/cart/templates/preview" +import DiscountCode from "@modules/checkout/components/discount-code" +import CartTotals from "@modules/common/components/cart-totals" +import Divider from "@modules/common/components/divider" +import { HttpTypes } from "@medusajs/types" + +const CheckoutSummary = ({ cart }: { cart: HttpTypes.StoreCart }) => { + return ( +
+
+ + + In your Cart + + + + +
+ +
+
+
+ ) +} + +export default CheckoutSummary diff --git a/apps/suman-bosna/src/modules/collections/templates/index.tsx b/apps/suman-bosna/src/modules/collections/templates/index.tsx new file mode 100644 index 0000000..ebbebd3 --- /dev/null +++ b/apps/suman-bosna/src/modules/collections/templates/index.tsx @@ -0,0 +1,51 @@ +import { Suspense } from "react" + +import SkeletonProductGrid from "@modules/skeletons/templates/skeleton-product-grid" +import RefinementList from "@modules/store/components/refinement-list" +import { SortOptions } from "@modules/store/components/refinement-list/sort-products" +import PaginatedProducts from "@modules/store/templates/paginated-products" +import { HttpTypes } from "@medusajs/types" +import { OptionValueIds } from "@lib/util/product-option-filters" + +export default function CollectionTemplate({ + sortBy, + collection, + page, + countryCode, + optionValueIds, +}: { + sortBy?: SortOptions + collection: HttpTypes.StoreCollection + page?: string + countryCode: string + optionValueIds?: OptionValueIds +}) { + const pageNumber = page ? parseInt(page) : 1 + const sort = sortBy || "created_at" + + return ( +
+ +
+
+

{collection.title}

+
+ + } + > + + +
+
+ ) +} diff --git a/apps/suman-bosna/src/modules/common/components/cart-totals/index.tsx b/apps/suman-bosna/src/modules/common/components/cart-totals/index.tsx new file mode 100644 index 0000000..195c59c --- /dev/null +++ b/apps/suman-bosna/src/modules/common/components/cart-totals/index.tsx @@ -0,0 +1,97 @@ +"use client" + +import { convertToLocale } from "@lib/util/money" +import React from "react" +import { Separator } from "@/components/ui/separator" +import { ShieldCheck } from "lucide-react" + +type CartTotalsProps = { + totals: { + total?: number | null + subtotal?: number | null + tax_total?: number | null + currency_code: string + item_subtotal?: number | null + shipping_subtotal?: number | null + discount_subtotal?: number | null + } +} + +const CartTotals: React.FC = ({ totals }) => { + const { + currency_code, + total, + tax_total, + item_subtotal, + shipping_subtotal, + discount_subtotal, + } = totals + + // U BiH su maloprodajne cijene sa uračunatim 17% PDV-om + const grossAmount = total ?? item_subtotal ?? 0 + const effectiveTax = tax_total && tax_total > 0 + ? tax_total + : grossAmount > 0 + ? Math.round((grossAmount * 17) / 117 * 100) / 100 + : 0 + + return ( +
+
+
+ Međuzbir stavki + + {convertToLocale({ amount: item_subtotal ?? 0, currency_code })} + +
+
+ Dostava + + {shipping_subtotal ? convertToLocale({ amount: shipping_subtotal, currency_code }) : "Besplatno / Obračun"} + +
+ {!!discount_subtotal && ( +
+ Popust + + -{" "} + {convertToLocale({ + amount: discount_subtotal ?? 0, + currency_code, + })} + +
+ )} +
+ Uračunati PDV (17%) + + {convertToLocale({ amount: effectiveTax, currency_code })} + +
+
+ + + +
+ Ukupno za uplatu + + {convertToLocale({ amount: total ?? 0, currency_code })} + +
+ +
+ + Fiskalni račun i R1 porezna faktura za firme sa JIB/PDV brojem +
+
+ ) +} + +export default CartTotals diff --git a/apps/suman-bosna/src/modules/common/components/checkbox/index.tsx b/apps/suman-bosna/src/modules/common/components/checkbox/index.tsx new file mode 100644 index 0000000..9f93f9a --- /dev/null +++ b/apps/suman-bosna/src/modules/common/components/checkbox/index.tsx @@ -0,0 +1,42 @@ +import { Checkbox, Label } from "@modules/common/components/ui" +import React from "react" + +type CheckboxProps = { + checked?: boolean + onChange?: () => void + label: string + name?: string + 'data-testid'?: string +} + +const CheckboxWithLabel: React.FC = ({ + checked = true, + onChange, + label, + name, + 'data-testid': dataTestId +}) => { + return ( +
+ + +
+ ) +} + +export default CheckboxWithLabel diff --git a/apps/suman-bosna/src/modules/common/components/delete-button/index.tsx b/apps/suman-bosna/src/modules/common/components/delete-button/index.tsx new file mode 100644 index 0000000..2d56b78 --- /dev/null +++ b/apps/suman-bosna/src/modules/common/components/delete-button/index.tsx @@ -0,0 +1,49 @@ +"use client" + +import { useState } from "react" +import { deleteLineItem } from "@lib/data/cart" +import { notifyCartUpdated } from "@lib/util/cart-events" +import { cn } from "@/lib/utils" +import { Trash2, Loader2 } from "lucide-react" + +const DeleteButton = ({ + id, + children, + className, +}: { + id: string + children?: React.ReactNode + className?: string +}) => { + const [isDeleting, setIsDeleting] = useState(false) + + const handleDelete = async (id: string) => { + setIsDeleting(true) + await deleteLineItem(id) + .then(notifyCartUpdated) + .catch((_err) => { + setIsDeleting(false) + }) + } + + return ( +
+ +
+ ) +} + +export default DeleteButton diff --git a/apps/suman-bosna/src/modules/common/components/divider/index.tsx b/apps/suman-bosna/src/modules/common/components/divider/index.tsx new file mode 100644 index 0000000..b3aec41 --- /dev/null +++ b/apps/suman-bosna/src/modules/common/components/divider/index.tsx @@ -0,0 +1,9 @@ +import { cn } from "@/lib/utils" + +const Divider = ({ className }: { className?: string }) => ( +
+) + +export default Divider diff --git a/apps/suman-bosna/src/modules/common/components/filter-radio-group/index.tsx b/apps/suman-bosna/src/modules/common/components/filter-radio-group/index.tsx new file mode 100644 index 0000000..9a931a6 --- /dev/null +++ b/apps/suman-bosna/src/modules/common/components/filter-radio-group/index.tsx @@ -0,0 +1,61 @@ +"use client" + +import { Label } from "@/components/ui/label" +import { cn } from "@/lib/utils" + +type FilterRadioGroupProps = { + title: string + items: { + value: string + label: string + }[] + value: string + handleChange: (value: string) => void + "data-testid"?: string +} + +const FilterRadioGroup = ({ + title, + items, + value, + handleChange, + "data-testid": dataTestId, +}: FilterRadioGroupProps) => { + return ( +
+ + {title} + +
+ {items?.map((item) => { + const isSelected = item.value === value + return ( + + ) + })} +
+
+ ) +} + +export default FilterRadioGroup diff --git a/apps/suman-bosna/src/modules/common/components/input/index.tsx b/apps/suman-bosna/src/modules/common/components/input/index.tsx new file mode 100644 index 0000000..827e64c --- /dev/null +++ b/apps/suman-bosna/src/modules/common/components/input/index.tsx @@ -0,0 +1,76 @@ +import { Label } from "@modules/common/components/ui" +import React, { useEffect, useImperativeHandle, useState } from "react" + +import Eye from "@modules/common/icons/eye" +import EyeOff from "@modules/common/icons/eye-off" + +type InputProps = Omit< + Omit, "size">, + "placeholder" +> & { + label: string + errors?: Record + touched?: Record + name: string + topLabel?: string +} + +const Input = React.forwardRef( + ({ type, name, label, touched: _touched, required, topLabel, ...props }, ref) => { + const inputRef = React.useRef(null) + const [showPassword, setShowPassword] = useState(false) + const [inputType, setInputType] = useState(type) + + useEffect(() => { + if (type === "password" && showPassword) { + setInputType("text") + } + + if (type === "password" && !showPassword) { + setInputType("password") + } + }, [type, showPassword]) + + useImperativeHandle(ref, () => inputRef.current!) + + return ( +
+ {topLabel && ( + + )} +
+ + + {type === "password" && ( + + )} +
+
+ ) + } +) + +Input.displayName = "Input" + +export default Input diff --git a/apps/suman-bosna/src/modules/common/components/interactive-link/index.tsx b/apps/suman-bosna/src/modules/common/components/interactive-link/index.tsx new file mode 100644 index 0000000..a5ecb11 --- /dev/null +++ b/apps/suman-bosna/src/modules/common/components/interactive-link/index.tsx @@ -0,0 +1,35 @@ +import { ArrowRight } from "lucide-react" +import LocalizedClientLink from "../localized-client-link" +import { cn } from "@/lib/utils" + +type InteractiveLinkProps = { + href: string + children?: React.ReactNode + onClick?: () => void + className?: string +} + +const InteractiveLink = ({ + href, + children, + onClick, + className, + ...props +}: InteractiveLinkProps) => { + return ( + + {children} + + + ) +} + +export default InteractiveLink diff --git a/apps/suman-bosna/src/modules/common/components/line-item-options/index.tsx b/apps/suman-bosna/src/modules/common/components/line-item-options/index.tsx new file mode 100644 index 0000000..c3a5006 --- /dev/null +++ b/apps/suman-bosna/src/modules/common/components/line-item-options/index.tsx @@ -0,0 +1,26 @@ +import { HttpTypes } from "@medusajs/types" +import { Text } from "@modules/common/components/ui" + +type LineItemOptionsProps = { + variant: HttpTypes.StoreProductVariant | undefined + "data-testid"?: string + "data-value"?: HttpTypes.StoreProductVariant +} + +const LineItemOptions = ({ + variant, + "data-testid": dataTestid, + "data-value": dataValue, +}: LineItemOptionsProps) => { + return ( + + Variant: {variant?.title} + + ) +} + +export default LineItemOptions diff --git a/apps/suman-bosna/src/modules/common/components/line-item-price/index.tsx b/apps/suman-bosna/src/modules/common/components/line-item-price/index.tsx new file mode 100644 index 0000000..0f3c96e --- /dev/null +++ b/apps/suman-bosna/src/modules/common/components/line-item-price/index.tsx @@ -0,0 +1,64 @@ +import { getPercentageDiff } from "@lib/util/get-percentage-diff" +import { convertToLocale } from "@lib/util/money" +import { HttpTypes } from "@medusajs/types" +import { clx } from "@modules/common/components/ui" + +type LineItemPriceProps = { + item: HttpTypes.StoreCartLineItem | HttpTypes.StoreOrderLineItem + style?: "default" | "tight" + currencyCode: string +} + +const LineItemPrice = ({ + item, + style = "default", + currencyCode, +}: LineItemPriceProps) => { + const { total, original_total } = item + const originalPrice = original_total ?? 0 + const currentPrice = total ?? 0 + const hasReducedPrice = currentPrice < originalPrice + + return ( +
+
+ {hasReducedPrice && ( + <> +

+ {style === "default" && ( + Original: + )} + + {convertToLocale({ + amount: originalPrice, + currency_code: currencyCode, + })} + +

+ {style === "default" && ( + + -{getPercentageDiff(originalPrice, currentPrice || 0)}% + + )} + + )} + + {convertToLocale({ + amount: currentPrice, + currency_code: currencyCode, + })} + +
+
+ ) +} + +export default LineItemPrice diff --git a/apps/suman-bosna/src/modules/common/components/line-item-unit-price/index.tsx b/apps/suman-bosna/src/modules/common/components/line-item-unit-price/index.tsx new file mode 100644 index 0000000..dd43a6f --- /dev/null +++ b/apps/suman-bosna/src/modules/common/components/line-item-unit-price/index.tsx @@ -0,0 +1,62 @@ +import { convertToLocale } from "@lib/util/money" +import { HttpTypes } from "@medusajs/types" +import { clx } from "@modules/common/components/ui" + +type LineItemUnitPriceProps = { + item: HttpTypes.StoreCartLineItem | HttpTypes.StoreOrderLineItem + style?: "default" | "tight" + currencyCode: string +} + +const LineItemUnitPrice = ({ + item, + style = "default", + currencyCode, +}: LineItemUnitPriceProps) => { + const total = item.total ?? 0 + const original_total = item.original_total ?? 0 + const hasReducedPrice = total < original_total + + const percentage_diff = Math.round( + ((original_total - total) / original_total) * 100 + ) + + return ( +
+ {hasReducedPrice && ( + <> +

+ {style === "default" && ( + Original: + )} + + {convertToLocale({ + amount: original_total / item.quantity, + currency_code: currencyCode, + })} + +

+ {style === "default" && ( + -{percentage_diff}% + )} + + )} + + {convertToLocale({ + amount: total / item.quantity, + currency_code: currencyCode, + })} + +
+ ) +} + +export default LineItemUnitPrice diff --git a/apps/suman-bosna/src/modules/common/components/localized-client-link/index.tsx b/apps/suman-bosna/src/modules/common/components/localized-client-link/index.tsx new file mode 100644 index 0000000..dc899cc --- /dev/null +++ b/apps/suman-bosna/src/modules/common/components/localized-client-link/index.tsx @@ -0,0 +1,32 @@ +"use client" + +import Link from "next/link" +import { useParams } from "next/navigation" +import React from "react" + +/** + * Use this component to create a Next.js `` that persists the current country code in the url, + * without having to explicitly pass it as a prop. + */ +const LocalizedClientLink = ({ + children, + href, + ...props +}: { + children?: React.ReactNode + href: string + className?: string + onClick?: () => void + passHref?: true + [x: string]: unknown +}) => { + const { countryCode } = useParams() + + return ( + + {children} + + ) +} + +export default LocalizedClientLink diff --git a/apps/suman-bosna/src/modules/common/components/modal/index.tsx b/apps/suman-bosna/src/modules/common/components/modal/index.tsx new file mode 100644 index 0000000..fc95d15 --- /dev/null +++ b/apps/suman-bosna/src/modules/common/components/modal/index.tsx @@ -0,0 +1,118 @@ +import { Dialog, Transition } from "@headlessui/react" +import { clx } from "@modules/common/components/ui" +import React, { Fragment } from "react" + +import { ModalProvider, useModal } from "@lib/context/modal-context" +import X from "@modules/common/icons/x" + +type ModalProps = { + isOpen: boolean + close: () => void + size?: "small" | "medium" | "large" + search?: boolean + children: React.ReactNode + 'data-testid'?: string +} + +const Modal = ({ + isOpen, + close, + size = "medium", + search = false, + children, + 'data-testid': dataTestId +}: ModalProps) => { + return ( + + + +
+ + +
+
+ + + {children} + + +
+
+
+
+ ) +} + +const Title: React.FC<{ children: React.ReactNode }> = ({ children }) => { + const { close } = useModal() + + return ( + +
{children}
+
+ +
+
+ ) +} + +const Description: React.FC<{ children: React.ReactNode }> = ({ children }) => { + return ( + + {children} + + ) +} + +const Body: React.FC<{ children: React.ReactNode }> = ({ children }) => { + return
{children}
+} + +const Footer: React.FC<{ children: React.ReactNode }> = ({ children }) => { + return
{children}
+} + +Modal.Title = Title +Modal.Description = Description +Modal.Body = Body +Modal.Footer = Footer + +export default Modal diff --git a/apps/suman-bosna/src/modules/common/components/native-select/index.tsx b/apps/suman-bosna/src/modules/common/components/native-select/index.tsx new file mode 100644 index 0000000..a81999b --- /dev/null +++ b/apps/suman-bosna/src/modules/common/components/native-select/index.tsx @@ -0,0 +1,74 @@ +import { ChevronsUpDown } from "lucide-react" +import { cn } from "@/lib/utils" +import { + SelectHTMLAttributes, + forwardRef, + useEffect, + useImperativeHandle, + useRef, + useState, +} from "react" + +export type NativeSelectProps = { + placeholder?: string + errors?: Record + touched?: Record +} & SelectHTMLAttributes + +const NativeSelect = forwardRef( + ( + { placeholder = "Odaberite...", defaultValue, className, children, ...props }, + ref + ) => { + const innerRef = useRef(null) + const [isPlaceholder, setIsPlaceholder] = useState(false) + + useImperativeHandle( + ref, + () => innerRef.current + ) + + useEffect(() => { + if (innerRef.current && innerRef.current.value === "") { + setIsPlaceholder(true) + } else { + setIsPlaceholder(false) + } + }, [innerRef.current?.value]) + + return ( +
+
innerRef.current?.focus()} + onBlur={() => innerRef.current?.blur()} + className={cn( + "relative flex items-center rounded-md border border-input bg-background text-sm shadow-sm transition-colors focus-within:ring-1 focus-within:ring-ring", + className, + { + "text-muted-foreground": isPlaceholder, + } + )} + > + + + + +
+
+ ) + } +) + +NativeSelect.displayName = "NativeSelect" + +export default NativeSelect diff --git a/apps/suman-bosna/src/modules/common/components/radio/index.tsx b/apps/suman-bosna/src/modules/common/components/radio/index.tsx new file mode 100644 index 0000000..fc52f52 --- /dev/null +++ b/apps/suman-bosna/src/modules/common/components/radio/index.tsx @@ -0,0 +1,27 @@ +const Radio = ({ checked, 'data-testid': dataTestId }: { checked: boolean, 'data-testid'?: string }) => { + return ( + <> + + + ) +} + +export default Radio diff --git a/apps/suman-bosna/src/modules/common/components/ui/index.tsx b/apps/suman-bosna/src/modules/common/components/ui/index.tsx new file mode 100644 index 0000000..747dda2 --- /dev/null +++ b/apps/suman-bosna/src/modules/common/components/ui/index.tsx @@ -0,0 +1,443 @@ +import * as React from "react" +import { cn } from "@/lib/utils" + +export { cn as clx } + +// Text Component +type TextProps = React.HTMLAttributes & { + as?: "p" | "span" | "div" +} + +export const Text = React.forwardRef( + ({ className, as: Component = "p", children, ...props }, ref) => { + return ( + + {children} + + ) + } +) +Text.displayName = "Text" + +// Heading Component +type HeadingProps = React.HTMLAttributes & { + level?: "h1" | "h2" | "h3" +} + +export const Heading = React.forwardRef( + ({ className, level: Component = "h2", children, ...props }, ref) => { + return ( + + {children} + + ) + } +) +Heading.displayName = "Heading" + +// Button Component +type ButtonProps = React.ButtonHTMLAttributes & { + variant?: "primary" | "secondary" | "transparent" | "outline" | "danger" + size?: "small" | "medium" | "large" + isLoading?: boolean +} + +export const Button = React.forwardRef( + ( + { + className, + variant = "primary", + size = "medium", + isLoading, + disabled, + children, + ...props + }, + ref + ) => { + return ( + + ) + } +) +Button.displayName = "Button" + +// Container Component +type ContainerProps = React.HTMLAttributes + +export const Container = React.forwardRef( + ({ className, children, ...props }, ref) => { + return ( +
+ {children} +
+ ) + } +) +Container.displayName = "Container" + +// Badge Component +type BadgeProps = React.HTMLAttributes & { + color?: "green" | "red" | "blue" | "orange" | "grey" | "purple" +} + +export const Badge = React.forwardRef( + ({ className, color = "grey", children, ...props }, ref) => { + return ( + + {children} + + ) + } +) +Badge.displayName = "Badge" + +// IconBadge Component +type IconBadgeProps = React.HTMLAttributes + +export const IconBadge = React.forwardRef( + ({ className, children, ...props }, ref) => { + return ( + + {children} + + ) + } +) +IconBadge.displayName = "IconBadge" + +// IconButton Component +type IconButtonProps = React.ButtonHTMLAttributes + +export const IconButton = React.forwardRef( + ({ className, children, ...props }, ref) => { + return ( + + ) + } +) +IconButton.displayName = "IconButton" + +// Label Component +type LabelProps = React.LabelHTMLAttributes + +export const Label = React.forwardRef( + ({ className, children, ...props }, ref) => { + return ( + + ) + } +) +Label.displayName = "Label" + +// Input Component +type InputProps = React.InputHTMLAttributes & { + label?: string +} + +export const Input = React.forwardRef( + ({ className, label, ...props }, ref) => { + return ( +
+ {label && } + +
+ ) + } +) +Input.displayName = "Input" + +// Table Components +type TableProps = React.HTMLAttributes + +const TableRoot = React.forwardRef( + ({ className, children, ...props }, ref) => { + return ( +
+ + {children} +
+
+ ) + } +) +TableRoot.displayName = "Table" + +type TableHeaderProps = React.HTMLAttributes + +const TableHeader = React.forwardRef( + ({ className, children, ...props }, ref) => { + return ( + + {children} + + ) + } +) +TableHeader.displayName = "TableHeader" + +type TableBodyProps = React.HTMLAttributes + +const TableBody = React.forwardRef( + ({ className, children, ...props }, ref) => { + return ( + + {children} + + ) + } +) +TableBody.displayName = "TableBody" + +type TableRowProps = React.HTMLAttributes + +const TableRow = React.forwardRef( + ({ className, children, ...props }, ref) => { + return ( + + {children} + + ) + } +) +TableRow.displayName = "TableRow" + +type TableHeadProps = React.ThHTMLAttributes + +const TableHead = React.forwardRef( + ({ className, children, ...props }, ref) => { + return ( + + {children} + + ) + } +) +TableHead.displayName = "TableHead" + +type TableCellProps = React.TdHTMLAttributes + +const TableCell = React.forwardRef( + ({ className, children, ...props }, ref) => { + return ( + + {children} + + ) + } +) +TableCell.displayName = "TableCell" + +export const Table = Object.assign(TableRoot, { + Header: TableHeader, + Body: TableBody, + Row: TableRow, + Head: TableHead, + HeaderCell: TableHead, + Cell: TableCell, +}) + +// RadioGroup Components +type RadioGroupProps = React.HTMLAttributes + +const RadioGroupRoot = React.forwardRef( + ({ className, children, ...props }, ref) => { + return ( +
+ {children} +
+ ) + } +) +RadioGroupRoot.displayName = "RadioGroup" + +type RadioGroupItemProps = React.InputHTMLAttributes & { + label?: string +} + +const RadioGroupItem = React.forwardRef( + ({ className, label, id, ...props }, ref) => { + return ( +
+ + {label && } +
+ ) + } +) +RadioGroupItem.displayName = "RadioGroupItem" + +export const RadioGroup = Object.assign(RadioGroupRoot, { + Item: RadioGroupItem, +}) + +// Checkbox Component +type CheckboxProps = Omit, "type"> & { + label?: string +} + +export const Checkbox = React.forwardRef( + ({ className, label, id, ...props }, ref) => { + return ( +
+ + {label && } +
+ ) + } +) +Checkbox.displayName = "Checkbox" diff --git a/apps/suman-bosna/src/modules/common/icons/back.tsx b/apps/suman-bosna/src/modules/common/icons/back.tsx new file mode 100644 index 0000000..078dfe0 --- /dev/null +++ b/apps/suman-bosna/src/modules/common/icons/back.tsx @@ -0,0 +1,37 @@ +import React from "react" + +import { IconProps } from "types/icon" + +const Back: React.FC = ({ + size = "16", + color = "currentColor", + ...attributes +}) => { + return ( + + + + + ) +} + +export default Back diff --git a/apps/suman-bosna/src/modules/common/icons/bancontact.tsx b/apps/suman-bosna/src/modules/common/icons/bancontact.tsx new file mode 100644 index 0000000..327fc67 --- /dev/null +++ b/apps/suman-bosna/src/modules/common/icons/bancontact.tsx @@ -0,0 +1,26 @@ +import React from "react" + +import { IconProps } from "types/icon" + +const Ideal: React.FC = ({ + size: _size = "20", + color = "currentColor", + ...attributes +}) => { + return ( + + Bancontact icon + + + ) +} + +export default Ideal diff --git a/apps/suman-bosna/src/modules/common/icons/chevron-down.tsx b/apps/suman-bosna/src/modules/common/icons/chevron-down.tsx new file mode 100644 index 0000000..98e261c --- /dev/null +++ b/apps/suman-bosna/src/modules/common/icons/chevron-down.tsx @@ -0,0 +1,30 @@ +import React from "react" + +import { IconProps } from "types/icon" + +const ChevronDown: React.FC = ({ + size = "16", + color = "currentColor", + ...attributes +}) => { + return ( + + + + ) +} + +export default ChevronDown diff --git a/apps/suman-bosna/src/modules/common/icons/chevron-up-down.tsx b/apps/suman-bosna/src/modules/common/icons/chevron-up-down.tsx new file mode 100644 index 0000000..24d0336 --- /dev/null +++ b/apps/suman-bosna/src/modules/common/icons/chevron-up-down.tsx @@ -0,0 +1,38 @@ +import React from "react" + +import { IconProps } from "types/icon" + +const ChevronUpDown: React.FC = ({ + size = "16", + color = "currentColor", + ...attributes +}) => { + return ( + + + + + ) +} + +export default ChevronUpDown + diff --git a/apps/suman-bosna/src/modules/common/icons/eye-off.tsx b/apps/suman-bosna/src/modules/common/icons/eye-off.tsx new file mode 100644 index 0000000..a0cafbb --- /dev/null +++ b/apps/suman-bosna/src/modules/common/icons/eye-off.tsx @@ -0,0 +1,37 @@ +import React from "react" + +import { IconProps } from "types/icon" + +const EyeOff: React.FC = ({ + size = "20", + color = "currentColor", + ...attributes +}) => { + return ( + + + + + ) +} + +export default EyeOff diff --git a/apps/suman-bosna/src/modules/common/icons/eye.tsx b/apps/suman-bosna/src/modules/common/icons/eye.tsx new file mode 100644 index 0000000..766b67f --- /dev/null +++ b/apps/suman-bosna/src/modules/common/icons/eye.tsx @@ -0,0 +1,37 @@ +import React from "react" + +import { IconProps } from "types/icon" + +const Eye: React.FC = ({ + size = "20", + color = "currentColor", + ...attributes +}) => { + return ( + + + + + ) +} + +export default Eye diff --git a/apps/suman-bosna/src/modules/common/icons/fast-delivery.tsx b/apps/suman-bosna/src/modules/common/icons/fast-delivery.tsx new file mode 100644 index 0000000..89537e3 --- /dev/null +++ b/apps/suman-bosna/src/modules/common/icons/fast-delivery.tsx @@ -0,0 +1,65 @@ +import React from "react" + +import { IconProps } from "types/icon" + +const FastDelivery: React.FC = ({ + size = "16", + color = "currentColor", + ...attributes +}) => { + return ( + + + + + + + + + ) +} + +export default FastDelivery diff --git a/apps/suman-bosna/src/modules/common/icons/ideal.tsx b/apps/suman-bosna/src/modules/common/icons/ideal.tsx new file mode 100644 index 0000000..c320bd2 --- /dev/null +++ b/apps/suman-bosna/src/modules/common/icons/ideal.tsx @@ -0,0 +1,26 @@ +import React from "react" + +import { IconProps } from "types/icon" + +const Ideal: React.FC = ({ + size: _size = "20", + color = "currentColor", + ...attributes +}) => { + return ( + + iDEAL icon + + + ) +} + +export default Ideal diff --git a/apps/suman-bosna/src/modules/common/icons/map-pin.tsx b/apps/suman-bosna/src/modules/common/icons/map-pin.tsx new file mode 100644 index 0000000..427d3cc --- /dev/null +++ b/apps/suman-bosna/src/modules/common/icons/map-pin.tsx @@ -0,0 +1,37 @@ +import React from "react" + +import { IconProps } from "types/icon" + +const MapPin: React.FC = ({ + size = "20", + color = "currentColor", + ...attributes +}) => { + return ( + + + + + ) +} + +export default MapPin diff --git a/apps/suman-bosna/src/modules/common/icons/medusa.tsx b/apps/suman-bosna/src/modules/common/icons/medusa.tsx new file mode 100644 index 0000000..8d5009c --- /dev/null +++ b/apps/suman-bosna/src/modules/common/icons/medusa.tsx @@ -0,0 +1,27 @@ +import React from "react" + +import { IconProps } from "types/icon" + +const Medusa: React.FC = ({ + size: _size = "20", + color = "#9CA3AF", + ...attributes +}) => { + return ( + + + + ) +} + +export default Medusa diff --git a/apps/suman-bosna/src/modules/common/icons/nextjs.tsx b/apps/suman-bosna/src/modules/common/icons/nextjs.tsx new file mode 100644 index 0000000..dd32f5e --- /dev/null +++ b/apps/suman-bosna/src/modules/common/icons/nextjs.tsx @@ -0,0 +1,27 @@ +import React from "react" + +import { IconProps } from "types/icon" + +const NextJs: React.FC = ({ + size: _size = "20", + color = "#9CA3AF", + ...attributes +}) => { + return ( + + + + ) +} + +export default NextJs diff --git a/apps/suman-bosna/src/modules/common/icons/package.tsx b/apps/suman-bosna/src/modules/common/icons/package.tsx new file mode 100644 index 0000000..af03f04 --- /dev/null +++ b/apps/suman-bosna/src/modules/common/icons/package.tsx @@ -0,0 +1,44 @@ +import React from "react" + +import { IconProps } from "types/icon" + +const Package: React.FC = ({ + size = "20", + color = "currentColor", + ...attributes +}) => { + return ( + + + + + + ) +} + +export default Package diff --git a/apps/suman-bosna/src/modules/common/icons/paypal.tsx b/apps/suman-bosna/src/modules/common/icons/paypal.tsx new file mode 100644 index 0000000..e147f97 --- /dev/null +++ b/apps/suman-bosna/src/modules/common/icons/paypal.tsx @@ -0,0 +1,30 @@ +const PayPal = () => { + return ( + + + + + ) +} + +export default PayPal diff --git a/apps/suman-bosna/src/modules/common/icons/placeholder-image.tsx b/apps/suman-bosna/src/modules/common/icons/placeholder-image.tsx new file mode 100644 index 0000000..9c381c6 --- /dev/null +++ b/apps/suman-bosna/src/modules/common/icons/placeholder-image.tsx @@ -0,0 +1,44 @@ +import React from "react" + +import { IconProps } from "types/icon" + +const PlaceholderImage: React.FC = ({ + size = "20", + color = "currentColor", + ...attributes +}) => { + return ( + + + + + + ) +} + +export default PlaceholderImage diff --git a/apps/suman-bosna/src/modules/common/icons/refresh.tsx b/apps/suman-bosna/src/modules/common/icons/refresh.tsx new file mode 100644 index 0000000..bf3374a --- /dev/null +++ b/apps/suman-bosna/src/modules/common/icons/refresh.tsx @@ -0,0 +1,51 @@ +import React from "react" + +import { IconProps } from "types/icon" + +const Refresh: React.FC = ({ + size = "16", + color = "currentColor", + ...attributes +}) => { + return ( + + + + + + + ) +} + +export default Refresh diff --git a/apps/suman-bosna/src/modules/common/icons/spinner.tsx b/apps/suman-bosna/src/modules/common/icons/spinner.tsx new file mode 100644 index 0000000..af5d84e --- /dev/null +++ b/apps/suman-bosna/src/modules/common/icons/spinner.tsx @@ -0,0 +1,37 @@ +import React from "react" + +import { IconProps } from "types/icon" + +const Spinner: React.FC = ({ + size = "16", + color = "currentColor", + ...attributes +}) => { + return ( + + + + + ) +} + +export default Spinner diff --git a/apps/suman-bosna/src/modules/common/icons/trash.tsx b/apps/suman-bosna/src/modules/common/icons/trash.tsx new file mode 100644 index 0000000..6b1abe6 --- /dev/null +++ b/apps/suman-bosna/src/modules/common/icons/trash.tsx @@ -0,0 +1,51 @@ +import React from "react" + +import { IconProps } from "types/icon" + +const Trash: React.FC = ({ + size = "16", + color = "currentColor", + ...attributes +}) => { + return ( + + + + + + + ) +} + +export default Trash diff --git a/apps/suman-bosna/src/modules/common/icons/user.tsx b/apps/suman-bosna/src/modules/common/icons/user.tsx new file mode 100644 index 0000000..c972c1e --- /dev/null +++ b/apps/suman-bosna/src/modules/common/icons/user.tsx @@ -0,0 +1,37 @@ +import React from "react" + +import { IconProps } from "types/icon" + +const User: React.FC = ({ + size = "16", + color = "currentColor", + ...attributes +}) => { + return ( + + + + + ) +} + +export default User diff --git a/apps/suman-bosna/src/modules/common/icons/x.tsx b/apps/suman-bosna/src/modules/common/icons/x.tsx new file mode 100644 index 0000000..cabac7b --- /dev/null +++ b/apps/suman-bosna/src/modules/common/icons/x.tsx @@ -0,0 +1,37 @@ +import React from "react" + +import { IconProps } from "types/icon" + +const X: React.FC = ({ + size = "20", + color = "currentColor", + ...attributes +}) => { + return ( + + + + + ) +} + +export default X diff --git a/apps/suman-bosna/src/modules/home/components/cta-banner/index.tsx b/apps/suman-bosna/src/modules/home/components/cta-banner/index.tsx new file mode 100644 index 0000000..8017fcf --- /dev/null +++ b/apps/suman-bosna/src/modules/home/components/cta-banner/index.tsx @@ -0,0 +1,51 @@ +import Image from "next/image" +import { ArrowRight } from "lucide-react" +import LocalizedClientLink from "@modules/common/components/localized-client-link" +import bannerConfig from "@/config/banner.json" + +export default function CtaBanner() { + const { title, image, cta } = bannerConfig + + return ( +
+ {/* Background Image - Edge to edge full screen cover */} + {title} + + {/* Gradient Overlay for contrast and readability */} +
+
+ + {/* Inner Content matching content container grid */} +
+ {/* Top-Left Heading */} +
+

+ {title} +

+
+ + {/* Bottom-Right Pill CTA Button */} +
+ + + {cta.label} + +
+ +
+
+
+
+
+ ) +} diff --git a/apps/suman-bosna/src/modules/home/components/faq-section/index.tsx b/apps/suman-bosna/src/modules/home/components/faq-section/index.tsx new file mode 100644 index 0000000..d0c4203 --- /dev/null +++ b/apps/suman-bosna/src/modules/home/components/faq-section/index.tsx @@ -0,0 +1,74 @@ +"use client" + +import * as React from "react" +import * as AccordionPrimitive from "@radix-ui/react-accordion" +import { Plus, Minus, ArrowRight } from "lucide-react" +import LocalizedClientLink from "@modules/common/components/localized-client-link" +import faqConfig from "@/config/faq.json" + +export default function FaqSection() { + const { kicker, titleLine1, titleLine2, cta, items } = faqConfig + + return ( +
+
+ {/* Left Column: Heading & Pill CTA button */} +
+
+ {kicker} +
+

+ {titleLine1} + {titleLine2} +

+ +
+ + + {cta.label} + +
+ +
+
+
+
+ + {/* Right Column: Accordion list with Plus/Minus toggle */} +
+ + {items.map((item, idx) => ( + + + + {item.question} +
+ + +
+
+
+ +
{item.answer}
+
+
+ ))} +
+
+
+
+ ) +} + diff --git a/apps/suman-bosna/src/modules/home/components/featured-products/index.tsx b/apps/suman-bosna/src/modules/home/components/featured-products/index.tsx new file mode 100644 index 0000000..5f7899f --- /dev/null +++ b/apps/suman-bosna/src/modules/home/components/featured-products/index.tsx @@ -0,0 +1,16 @@ +import { HttpTypes } from "@medusajs/types" +import ProductRail from "@modules/home/components/featured-products/product-rail" + +export default async function FeaturedProducts({ + collections, + region, +}: { + collections: HttpTypes.StoreCollection[] + region: HttpTypes.StoreRegion +}) { + return collections.map((collection) => ( +
  • + +
  • + )) +} diff --git a/apps/suman-bosna/src/modules/home/components/featured-products/product-rail/index.tsx b/apps/suman-bosna/src/modules/home/components/featured-products/product-rail/index.tsx new file mode 100644 index 0000000..b75a54d --- /dev/null +++ b/apps/suman-bosna/src/modules/home/components/featured-products/product-rail/index.tsx @@ -0,0 +1,54 @@ +import { listProducts } from "@lib/data/products" +import { HttpTypes } from "@medusajs/types" +import InteractiveLink from "@modules/common/components/interactive-link" +import ProductPreview from "@modules/products/components/product-preview" + +export default async function ProductRail({ + collection, + region, +}: { + collection: HttpTypes.StoreCollection + region: HttpTypes.StoreRegion +}) { + const { + response: { products: pricedProducts }, + } = await listProducts({ + regionId: region.id, + queryParams: { + collection_id: collection.id, + fields: "*variants.calculated_price", + }, + }) + + if (!pricedProducts || pricedProducts.length === 0) { + return null + } + + return ( +
    +
    +
    +

    + {collection.title} +

    +

    + Istražite odabrane modele iz ove linije proizvoda. +

    +
    + + Pogledaj sve + +
    +
    + {pricedProducts.map((product) => ( + + ))} +
    +
    + ) +} diff --git a/apps/suman-bosna/src/modules/home/components/hero/index.tsx b/apps/suman-bosna/src/modules/home/components/hero/index.tsx new file mode 100644 index 0000000..b793ae0 --- /dev/null +++ b/apps/suman-bosna/src/modules/home/components/hero/index.tsx @@ -0,0 +1,93 @@ +import Image from "next/image" +import LocalizedClientLink from "@modules/common/components/localized-client-link" +import { Button } from "@/components/ui/button" +import { ArrowRight } from "lucide-react" +import heroConfig from "@/config/hero.json" +import navigationConfig from "@/config/navigation.json" + +const Hero = () => { + const isFloating = + (navigationConfig as { headerVersion?: string }).headerVersion !== "classic" + + return ( +
    + {/* Background Video or Fallback Image - Full screen cover */} + {heroConfig.video ? ( + + ) : ( + {heroConfig.title} + )} + + {/* Subtle translucent dark overlay so the video shines through clearly */} +
    + + {/* Hero Content - Centered with top clearance for floating header */} +
    + {/* Main Heading from hero.json */} +

    + {heroConfig.title} +

    + + {/* Subtitle from hero.json */} +

    + {heroConfig.subtitle} +

    + + {/* CTA Buttons from hero.json */} +
    + + + + + + +
    +
    +
    + ) +} + +export default Hero diff --git a/apps/suman-bosna/src/modules/home/components/latest-news/index.tsx b/apps/suman-bosna/src/modules/home/components/latest-news/index.tsx new file mode 100644 index 0000000..e8c6c4a --- /dev/null +++ b/apps/suman-bosna/src/modules/home/components/latest-news/index.tsx @@ -0,0 +1,88 @@ +"use client" + +import { useRef } from "react" +import Image from "next/image" +import { ArrowRight } from "lucide-react" +import LocalizedClientLink from "@modules/common/components/localized-client-link" +import newsConfig from "@/config/news.json" + +export default function LatestNews() { + const scrollRef = useRef(null) + const { kicker, title, cta, articles } = newsConfig + + return ( +
    + {/* Centered Top Heading */} +
    +
    + {kicker} +
    +

    + {title} +

    +
    + + {/* Edge-to-Edge Cards Slider Track */} +
    + {articles.map((article, idx) => ( +
    + +
    + {/* Background photo */} + {article.title} + + {/* Dark gradient overlay matching reference */} +
    + + {/* Top-Right circle arrow button matching reference image */} +
    +
    + +
    +
    + + {/* Bottom: Date & Title */} +
    + + {article.date} + +

    + {article.title} +

    +
    +
    + +
    + ))} +
    + + {/* Bottom Center Pill CTA Button matching reference image */} +
    + + + {cta.label} + +
    + +
    +
    +
    +
    + ) +} diff --git a/apps/suman-bosna/src/modules/home/components/mission-section/index.tsx b/apps/suman-bosna/src/modules/home/components/mission-section/index.tsx new file mode 100644 index 0000000..4f65479 --- /dev/null +++ b/apps/suman-bosna/src/modules/home/components/mission-section/index.tsx @@ -0,0 +1,102 @@ +import Image from "next/image" +import { DynamicIcon } from "@/components/ui/dynamic-icon" +import { SectionHeader } from "@/components/ui/section-header" +import missionConfig from "@/config/mission.json" + +export default function MissionSection() { + const { kicker, title, statCard, visionCard, qualityCard } = missionConfig + + return ( +
    + {/* Top Header Section */} + + + {/* 3-Cards Grid matching the screenshot */} +
    + {/* Card 1: Dark Navy Stats Card */} +
    + {/* Top row */} +
    + + {statCard.topLabel} + +
    + +
    +
    + + {/* Middle pill badge */} +
    + + {statCard.badge} + +
    + + {/* Bottom big numbers */} +
    +
    + {statCard.number} +
    +

    + {statCard.subtext} +

    +
    +
    + + {/* Card 2: Photo Card with Vision Text */} +
    + {/* Background image */} + {visionCard.title} + {/* Dark gradient overlay */} +
    + + {/* Top right icon */} +
    +
    + +
    +
    + + {/* Bottom vision text */} +
    +

    + {visionCard.title} +

    +

    + {visionCard.description} +

    +
    +
    + + {/* Card 3: Quality & Tags Card */} +
    + {/* Top statement */} +
    +

    + {qualityCard.title} +

    +
    + + {/* Bottom tags cloud */} +
    + {qualityCard.tags.map((tag, idx) => ( + + {tag} + + ))} +
    +
    +
    +
    + ) +} + diff --git a/apps/suman-bosna/src/modules/home/components/partners-ticker/index.tsx b/apps/suman-bosna/src/modules/home/components/partners-ticker/index.tsx new file mode 100644 index 0000000..03e8411 --- /dev/null +++ b/apps/suman-bosna/src/modules/home/components/partners-ticker/index.tsx @@ -0,0 +1,102 @@ +import partnersConfig from "@/config/partners.json" + +function PartnerLogo({ id, name }: { id: string; name: string }) { + switch (id) { + case "wskt": + return ( + + WSKT + + ) + case "fluor": + return ( + + FLUOR® + + ) + case "vinci": + return ( +
    + + VINCI + + + + + + + + +
    + ) + case "sinarmas": + return ( +
    + + + + + + + sinarmas land + +
    + ) + case "pakuwon": + return ( +
    +
    + + + +
    + + PAKUWON GROUP + +
    + ) + case "metland": + return ( + + Metland + + ) + default: + return ( + + {name} + + ) + } +} + +export default function PartnersTicker() { + const partners = partnersConfig.items || [] + + return ( +
    + {/* Left and right gradient fade masks - exact match to user's reference image */} +
    +
    + + {/* Marquee Track */} +
    + {/* Repeating partners for continuous loop */} + {[...partners, ...partners, ...partners, ...partners].map((partner, idx) => ( +
    + +
    + ))} +
    +
    + ) +} + diff --git a/apps/suman-bosna/src/modules/home/components/product-showcase/index.tsx b/apps/suman-bosna/src/modules/home/components/product-showcase/index.tsx new file mode 100644 index 0000000..ad1387d --- /dev/null +++ b/apps/suman-bosna/src/modules/home/components/product-showcase/index.tsx @@ -0,0 +1,178 @@ +"use client" + +import { useRef, useState, useEffect } from "react" +import Image from "next/image" +import { ArrowLeft, ArrowRight } from "lucide-react" +import LocalizedClientLink from "@modules/common/components/localized-client-link" +import { Button } from "@/components/ui/button" +import { SectionHeader } from "@/components/ui/section-header" +import showcaseConfig from "@/config/products-showcase.json" + +export default function ProductShowcase() { + const scrollRef = useRef(null) + const [activeIndex, setActiveIndex] = useState(0) + const [canScrollLeft, setCanScrollLeft] = useState(false) + const [canScrollRight, setCanScrollRight] = useState(true) + + const items = showcaseConfig.items || [] + + // Check scroll position and update active indicators & button states + const updateScrollState = () => { + if (!scrollRef.current) return + const { scrollLeft, scrollWidth, clientWidth } = scrollRef.current + setCanScrollLeft(scrollLeft > 10) + setCanScrollRight(scrollLeft < scrollWidth - clientWidth - 10) + + const maxScroll = scrollWidth - clientWidth + if (maxScroll > 0) { + const progress = scrollLeft / maxScroll + const indicatorCount = 4 // matches the 4-segment design in screenshot + const idx = Math.min( + indicatorCount - 1, + Math.max(0, Math.round(progress * (indicatorCount - 1))) + ) + setActiveIndex(idx) + } + } + + useEffect(() => { + const el = scrollRef.current + if (!el) return + updateScrollState() + el.addEventListener("scroll", updateScrollState, { passive: true }) + window.addEventListener("resize", updateScrollState) + return () => { + el.removeEventListener("scroll", updateScrollState) + window.removeEventListener("resize", updateScrollState) + } + }, [items.length]) + + const scroll = (direction: "left" | "right") => { + if (!scrollRef.current) return + const container = scrollRef.current + const itemEl = container.firstElementChild as HTMLElement + const itemWidth = itemEl ? itemEl.offsetWidth + 24 : 340 // width + gap + container.scrollBy({ + left: direction === "left" ? -itemWidth : itemWidth, + behavior: "smooth", + }) + } + + const scrollToIndex = (index: number) => { + if (!scrollRef.current) return + const container = scrollRef.current + const { scrollWidth, clientWidth } = container + const maxScroll = scrollWidth - clientWidth + const indicatorCount = 4 + const targetScroll = (maxScroll / (indicatorCount - 1)) * index + container.scrollTo({ + left: targetScroll, + behavior: "smooth", + }) + } + + return ( +
    + {/* Top Header Section */} + + + {/* Cards Slider Track */} +
    + {items.map((item, idx) => ( +
    + {/* Number on top: 01, 02, etc. */} +
    + {item.number} +
    + + {/* Rounded Card */} + +
    + {/* Product Image - Full Cover */} + {item.title} + + {/* Subtle gradient overlay at bottom for depth */} +
    + + {/* Floating circular arrow button at bottom right */} +
    + +
    +
    + + {/* Title & Description below the card */} +
    +

    + {item.title} +

    +

    + {item.description} +

    +
    + +
    + ))} +
    + + {/* Bottom Carousel Controls: Prev arrow, Progress segments, Next arrow */} +
    + {/* Left Arrow Button */} + + + {/* Progress Bar Segments */} +
    + {[0, 1, 2, 3].map((idx) => ( +
    + + {/* Right Arrow Button */} + +
    +
    + ) +} + diff --git a/apps/suman-bosna/src/modules/layout/components/cart-button/index.tsx b/apps/suman-bosna/src/modules/layout/components/cart-button/index.tsx new file mode 100644 index 0000000..4d5bbd5 --- /dev/null +++ b/apps/suman-bosna/src/modules/layout/components/cart-button/index.tsx @@ -0,0 +1,8 @@ +import { retrieveCart } from "@lib/data/cart" +import CartDropdown from "../cart-dropdown" + +export default async function CartButton() { + const cart = await retrieveCart().catch(() => null) + + return +} diff --git a/apps/suman-bosna/src/modules/layout/components/cart-dropdown/index.tsx b/apps/suman-bosna/src/modules/layout/components/cart-dropdown/index.tsx new file mode 100644 index 0000000..7253d69 --- /dev/null +++ b/apps/suman-bosna/src/modules/layout/components/cart-dropdown/index.tsx @@ -0,0 +1,390 @@ +"use client" + +import React, { useEffect, useRef, useState } from "react" +import { usePathname } from "next/navigation" +import { HttpTypes } from "@medusajs/types" +import { retrieveCart, updateLineItem, deleteLineItem } from "@lib/data/cart" +import { CART_UPDATED_EVENT, notifyCartUpdated } from "@lib/util/cart-events" +import { convertToLocale } from "@lib/util/money" +import { + Sheet, + SheetTrigger, + SheetContent, + SheetHeader, + SheetTitle, + SheetClose, +} from "@/components/ui/sheet" +import { Button } from "@/components/ui/button" +import { Badge } from "@/components/ui/badge" +import { Separator } from "@/components/ui/separator" +import Thumbnail from "@modules/products/components/thumbnail" +import LineItemOptions from "@modules/common/components/line-item-options" +import LineItemPrice from "@modules/common/components/line-item-price" +import LocalizedClientLink from "@modules/common/components/localized-client-link" +import { + ShoppingBag, + Minus, + Plus, + Trash2, + Loader2, + ArrowRight, + ShieldCheck, + Truck, + CheckCircle2, +} from "lucide-react" + +const countItems = (cart?: HttpTypes.StoreCart | null) => + cart?.items?.reduce((acc, item) => acc + item.quantity, 0) || 0 + +// Komponenta za pojedinačni artikal u korpi sa +/- i brisanjem +function CartDrawerItem({ + item, + currencyCode, +}: { + item: HttpTypes.StoreCartLineItem + currencyCode: string +}) { + const [isUpdating, setIsUpdating] = useState(false) + const [isDeleting, setIsDeleting] = useState(false) + + const handleUpdate = async (newQty: number) => { + if (newQty < 1 || isUpdating) return + setIsUpdating(true) + try { + await updateLineItem({ lineId: item.id, quantity: newQty }) + notifyCartUpdated() + } catch (_err) { + // ignore + } finally { + setIsUpdating(false) + } + } + + const handleDelete = async () => { + if (isDeleting) return + setIsDeleting(true) + try { + await deleteLineItem(item.id) + notifyCartUpdated() + } catch (_err) { + setIsDeleting(false) + } + } + + return ( +
    + + + + +
    +
    + + {item.title} + + +
    + +
    + +
    + +
    + {/* Stepper količine */} +
    + + + {isUpdating ? ( + + ) : ( + item.quantity + )} + + +
    + + {/* Cijena stavke */} +
    + +
    +
    +
    +
    + ) +} + +export default function CartDropdown({ + cart: serverCart, +}: { + cart?: HttpTypes.StoreCart | null +}) { + const [clientCart, setClientCart] = useState(null) + const cartState = clientCart ?? serverCart + const [isOpen, setIsOpen] = useState(false) + const pathname = usePathname() + + const totalItems = countItems(cartState) + const subtotal = cartState?.subtotal ?? 0 + const prevItemsCount = useRef(totalItems || 0) + + // Osvježavanje korpe na klijentu prilikom CART_UPDATED_EVENT događaja + useEffect(() => { + const handleCartUpdate = () => { + retrieveCart() + .then((freshCart) => { + setClientCart(freshCart) + // Ako smo na stranici proizvoda, automatski otvori drawer da potvrdi unos + if (!pathname.includes("/cart") && !pathname.includes("/checkout")) { + setIsOpen(true) + } + }) + .catch(() => {}) + } + + window.addEventListener(CART_UPDATED_EVENT, handleCartUpdate) + return () => window.removeEventListener(CART_UPDATED_EVENT, handleCartUpdate) + }, [pathname]) + + // PDV specifikacija za BiH (17% uračunat u maloprodajnu cijenu) + const taxAmount = (subtotal * 17) / 117 + const baseAmount = subtotal - taxAmount + + return ( + + {/* Okidač: dugme korpe u navigaciji */} + + + + + {/* Slide-in Drawer sa desne strane */} + + {/* Drawer Header */} + +
    + + + Vaša Korpa + + ({totalItems} {totalItems === 1 ? "artikal" : "artikala"}) + + +
    + {/* Brzi benefit banner */} +
    + + + Brza dostava 24/48h širom BiH | Preuzimanje u Gračanici + +
    +
    + + {/* Drawer Body */} +
    + {cartState && cartState.items && cartState.items.length > 0 ? ( +
    + {cartState.items + .sort((a, b) => ((a.created_at ?? "") > (b.created_at ?? "") ? -1 : 1)) + .map((item) => ( + + ))} + + {/* Preporučeni dodaci (Cross-sell za suncobrane) */} +
    + + Preporučena dodatna oprema: + +
    +
    +
    + +
    +
    +

    + Zaštitna navlaka sa zipom +

    +

    + Štiti platno od kiše i smoga van sezone +

    +
    +
    + setIsOpen(false)} + className="flex-shrink-0 text-xs font-semibold text-primary hover:underline" + > + Vidi baze & opremu + +
    +
    +
    + ) : ( +
    +
    + +
    +
    +

    + Vaša korpa je prazna +

    +

    + Istražite našu ponudu profesionalnih suncobrana, pergola i tendi. +

    +
    + + + +
    + )} +
    + + {/* Drawer Footer (Sticky at bottom) */} + {cartState && cartState.items && cartState.items.length > 0 && ( +
    + {/* Specifikacija cijena sa 17% PDV */} +
    +
    + Osnovica bez PDV-a: + + {convertToLocale({ + amount: baseAmount, + currency_code: cartState.currency_code, + })} + +
    +
    + PDV (17%): + + {convertToLocale({ + amount: taxAmount, + currency_code: cartState.currency_code, + })} + +
    + +
    + Ukupno za uplatu: + + {convertToLocale({ + amount: subtotal, + currency_code: cartState.currency_code, + })} + +
    +
    + + U cijene je uračunat PDV 17% (B2B R1 račun) +
    +
    + + {/* Dugmad za akciju */} +
    + setIsOpen(false)}> + + + +
    + setIsOpen(false)} + > + + + + + +
    +
    +
    + )} +
    +
    + ) +} diff --git a/apps/suman-bosna/src/modules/layout/components/cart-mismatch-banner/index.tsx b/apps/suman-bosna/src/modules/layout/components/cart-mismatch-banner/index.tsx new file mode 100644 index 0000000..8177bf0 --- /dev/null +++ b/apps/suman-bosna/src/modules/layout/components/cart-mismatch-banner/index.tsx @@ -0,0 +1,56 @@ +"use client" + +import { transferCart } from "@lib/data/customer" +import { AlertCircle as ExclamationCircleSolid } from "lucide-react" +import { StoreCart, StoreCustomer } from "@medusajs/types" +import { Button } from "@modules/common/components/ui" +import { useState } from "react" +function CartMismatchBanner(props: { + customer: StoreCustomer + cart: StoreCart +}) { + const { customer, cart } = props + const [isPending, setIsPending] = useState(false) + const [actionText, setActionText] = useState("Run transfer again") + + if (!customer || !!cart.customer_id) { + return + } + + const handleSubmit = async () => { + try { + setIsPending(true) + setActionText("Transferring..") + + await transferCart() + } catch { + setActionText("Run transfer again") + setIsPending(false) + } + } + + return ( +
    +
    + + + Something went wrong when we tried to transfer your cart + + + · + + +
    +
    + ) +} + +export default CartMismatchBanner diff --git a/apps/suman-bosna/src/modules/layout/components/country-select/index.tsx b/apps/suman-bosna/src/modules/layout/components/country-select/index.tsx new file mode 100644 index 0000000..b6906cf --- /dev/null +++ b/apps/suman-bosna/src/modules/layout/components/country-select/index.tsx @@ -0,0 +1,131 @@ +"use client" + +import { + Listbox, + ListboxButton, + ListboxOption, + ListboxOptions, + Transition, +} from "@headlessui/react" +import { Fragment, useEffect, useMemo, useState } from "react" +import ReactCountryFlag from "react-country-flag" + +import { StateType } from "@lib/hooks/use-toggle-state" +import { useParams, usePathname } from "next/navigation" +import { updateRegion } from "@lib/data/cart" +import { HttpTypes } from "@medusajs/types" + +type CountryOption = { + country: string + region: string + label: string +} + +type CountrySelectProps = { + toggleState: StateType + regions: HttpTypes.StoreRegion[] +} + +const CountrySelect = ({ toggleState, regions }: CountrySelectProps) => { + const [current, setCurrent] = useState(undefined) + + const { countryCode } = useParams() + const currentPath = usePathname().split(`/${countryCode}`)[1] + + const { state, close } = toggleState + + const options = useMemo(() => { + return regions + ?.map((r) => { + return r.countries?.map((c) => ({ + country: c.iso_2 ?? "", + region: r.id, + label: c.display_name ?? "", + })) + }) + .flat() + .filter((o): o is CountryOption => !!o) + .sort((a, b) => a.label.localeCompare(b.label)) + }, [regions]) + + useEffect(() => { + if (countryCode) { + const option = options?.find((o) => o?.country === countryCode) + setCurrent(option) + } + }, [options, countryCode]) + + const handleChange = (option: CountryOption) => { + updateRegion(option.country, currentPath) + close() + } + + return ( +
    + o?.country === countryCode) + : undefined + } + > + +
    + Shipping to: + {current && ( + + + {current.label} + + )} +
    +
    +
    + + + {options?.map((o, index) => { + return ( + + {" "} + {o?.label} + + ) + })} + + +
    +
    +
    + ) +} + +export default CountrySelect diff --git a/apps/suman-bosna/src/modules/layout/components/language-select/index.tsx b/apps/suman-bosna/src/modules/layout/components/language-select/index.tsx new file mode 100644 index 0000000..efda716 --- /dev/null +++ b/apps/suman-bosna/src/modules/layout/components/language-select/index.tsx @@ -0,0 +1,192 @@ +"use client" + +import { + Listbox, + ListboxButton, + ListboxOption, + ListboxOptions, + Transition, +} from "@headlessui/react" +import { Fragment, useEffect, useMemo, useState, useTransition } from "react" +import { useRouter } from "next/navigation" +import ReactCountryFlag from "react-country-flag" + +import { StateType } from "@lib/hooks/use-toggle-state" +import { updateLocale } from "@lib/data/locale-actions" +import { Locale } from "@lib/data/locales" + +type LanguageOption = { + code: string + name: string + localizedName: string + countryCode: string +} + +const getCountryCodeFromLocale = (localeCode: string): string => { + try { + const locale = new Intl.Locale(localeCode) + if (locale.region) { + return locale.region.toUpperCase() + } + const maximized = locale.maximize() + return maximized.region?.toUpperCase() ?? localeCode.toUpperCase() + } catch { + const parts = localeCode.split(/[-_]/) + return parts.length > 1 ? parts[1].toUpperCase() : parts[0].toUpperCase() + } +} + +type LanguageSelectProps = { + toggleState: StateType + locales: Locale[] + currentLocale: string | null +} + +/** + * Gets the localized display name for a language code using Intl API. + * Falls back to the provided name if Intl is unavailable. + */ +const getLocalizedLanguageName = ( + code: string, + fallbackName: string, + displayLocale: string = "en-US" +): string => { + try { + const displayNames = new Intl.DisplayNames([displayLocale], { + type: "language", + }) + return displayNames.of(code) ?? fallbackName + } catch { + return fallbackName + } +} + +const DEFAULT_OPTION: LanguageOption = { + code: "", + name: "Default", + localizedName: "Default", + countryCode: "", +} + +const LanguageSelect = ({ + toggleState, + locales, + currentLocale, +}: LanguageSelectProps) => { + const [current, setCurrent] = useState(undefined) + const [isPending, startTransition] = useTransition() + const router = useRouter() + + const { state, close } = toggleState + + const options = useMemo(() => { + const localeOptions = locales.map((locale) => ({ + code: locale.code, + name: locale.name, + localizedName: getLocalizedLanguageName( + locale.code, + locale.name, + currentLocale ?? "en-US" + ), + countryCode: getCountryCodeFromLocale(locale.code), + })) + return [DEFAULT_OPTION, ...localeOptions] + }, [locales, currentLocale]) + + useEffect(() => { + if (currentLocale) { + const option = options.find( + (o) => o.code.toLowerCase() === currentLocale.toLowerCase() + ) + setCurrent(option ?? DEFAULT_OPTION) + } else { + setCurrent(DEFAULT_OPTION) + } + }, [options, currentLocale]) + + const handleChange = (option: LanguageOption) => { + startTransition(async () => { + await updateLocale(option.code) + close() + router.refresh() + }) + } + + return ( +
    + o.code.toLowerCase() === currentLocale.toLowerCase() + ) ?? DEFAULT_OPTION + : DEFAULT_OPTION + } + disabled={isPending} + > + +
    + Language: + {current && ( + + {current.countryCode && ( + /* @ts-ignore */ + + )} + {isPending ? "..." : current.localizedName} + + )} +
    +
    +
    + + + {options.map((o) => ( + + {o.countryCode ? ( + /* @ts-ignore */ + + ) : ( + + )} + {o.localizedName} + + ))} + + +
    +
    +
    + ) +} + +export default LanguageSelect diff --git a/apps/suman-bosna/src/modules/layout/components/medusa-cta/index.tsx b/apps/suman-bosna/src/modules/layout/components/medusa-cta/index.tsx new file mode 100644 index 0000000..01c9510 --- /dev/null +++ b/apps/suman-bosna/src/modules/layout/components/medusa-cta/index.tsx @@ -0,0 +1,21 @@ +import { Text } from "@modules/common/components/ui" + +import Medusa from "../../../common/icons/medusa" +import NextJs from "../../../common/icons/nextjs" + +const MedusaCTA = () => { + return ( + + Powered by + + + + & + + + + + ) +} + +export default MedusaCTA diff --git a/apps/suman-bosna/src/modules/layout/components/search/drawer.tsx b/apps/suman-bosna/src/modules/layout/components/search/drawer.tsx new file mode 100644 index 0000000..22bc9db --- /dev/null +++ b/apps/suman-bosna/src/modules/layout/components/search/drawer.tsx @@ -0,0 +1,70 @@ +"use client" + +import { Dialog, Transition } from "@headlessui/react" +import { X } from "lucide-react" +import React, { Fragment } from "react" + +type SearchDrawerProps = { + isOpen: boolean + close: () => void + children: React.ReactNode +} + +const SearchDrawer = ({ isOpen, close, children }: SearchDrawerProps) => { + return ( + + + +
    + + +
    +
    + + +
    +
    + + Pretraga Suman Asortimana + + +
    + {children} +
    +
    +
    +
    +
    +
    +
    + ) +} + +export default SearchDrawer diff --git a/apps/suman-bosna/src/modules/layout/components/search/hit.tsx b/apps/suman-bosna/src/modules/layout/components/search/hit.tsx new file mode 100644 index 0000000..c4abad5 --- /dev/null +++ b/apps/suman-bosna/src/modules/layout/components/search/hit.tsx @@ -0,0 +1,57 @@ +"use client" + +import Image from "next/image" +import type { Hit as HitType } from "instantsearch.js" + +import LocalizedClientLink from "@modules/common/components/localized-client-link" +import { ImageIcon } from "lucide-react" + +export type ProductHit = HitType<{ + title: string | null + handle: string | null + thumbnail: string | null +}> + +type SearchHitProps = { + hit: ProductHit + onNavigate?: () => void +} + +const SearchHit = ({ hit, onNavigate }: SearchHitProps) => { + if (!hit.handle) { + return null + } + + return ( +
  • + +
    + {hit.thumbnail ? ( + {hit.title + ) : ( +
    + +
    + )} +
    + + {hit.title} + +
    +
  • + ) +} + +export default SearchHit diff --git a/apps/suman-bosna/src/modules/layout/components/search/index.tsx b/apps/suman-bosna/src/modules/layout/components/search/index.tsx new file mode 100644 index 0000000..13c0205 --- /dev/null +++ b/apps/suman-bosna/src/modules/layout/components/search/index.tsx @@ -0,0 +1,150 @@ +"use client" + +import { Search as SearchIcon } from "lucide-react" +import Link from "next/link" +import { useParams } from "next/navigation" +import { useCallback, useEffect, useRef, useState } from "react" +import type { SearchClient } from "instantsearch.js" +import { + Configure, + InstantSearch, + useHits, + useInstantSearch, + useSearchBox, +} from "react-instantsearch" + +import useSearchSettled from "@lib/hooks/use-search-settled" +import useToggleState from "@lib/hooks/use-toggle-state" +import { PRODUCT_INDEX_NAME, searchClient } from "@lib/search-client" +import SearchDrawer from "./drawer" +import SearchHit, { ProductHit } from "./hit" + +const HITS_PER_PAGE = 12 +const DEBOUNCE_MS = 250 + +const SearchPanel = ({ onNavigate }: { onNavigate: () => void }) => { + const timer = useRef(undefined) + + const queryHook = useCallback( + (nextQuery: string, search: (value: string) => void) => { + window.clearTimeout(timer.current) + timer.current = window.setTimeout(() => search(nextQuery), DEBOUNCE_MS) + }, + [] + ) + + const { query, refine } = useSearchBox({ queryHook }) + const { items } = useHits() + const { status, error } = useInstantSearch() + const { isSettled } = useSearchSettled() + + const [inputValue, setInputValue] = useState(query) + + useEffect(() => () => window.clearTimeout(timer.current), []) + + const hasInput = Boolean(inputValue.trim()) + const isPending = inputValue.trim() !== query.trim() + const hasResults = Boolean(query.trim()) && items.length > 0 + + return ( + <> +
    + + { + setInputValue(event.target.value) + refine(event.target.value) + }} + placeholder="Unesite pojam za pretragu..." + aria-label="Pretraži proizvode" + autoFocus + className="w-full bg-transparent py-3 text-sm text-foreground outline-none placeholder:text-muted-foreground" + data-testid="search-input" + /> +
    + +
    + {!hasInput ? ( +

    + Počnite tipkati da pretražite suncobrane, pergole i dodatke. +

    + ) : status === "error" ? ( +

    + Greška pri pretrazi + {error?.message ? `: ${error.message}` : "."} +

    + ) : !isSettled ? ( +

    + Pretražujem… +

    + ) : hasResults ? ( +
      + {items.map((hit) => ( + + ))} +
    + ) : isPending || !query.trim() ? ( +

    + Pretražujem… +

    + ) : ( +

    + Nema rezultata za upit "{query}" +

    + )} +
    + + ) +} + +const Search = () => { + const { state: isOpen, open, close } = useToggleState() + const { countryCode } = useParams<{ countryCode: string }>() + + return ( + <> + { + event.preventDefault() + open() + }} + aria-label="Pretraga" + className="inline-flex items-center justify-center h-9 w-9 rounded-md text-primary-foreground/90 hover:text-white hover:bg-white/10 transition-colors" + data-testid="nav-search-button" + > + + + + + + + + + + + ) +} + +export default Search diff --git a/apps/suman-bosna/src/modules/layout/components/side-menu/index.tsx b/apps/suman-bosna/src/modules/layout/components/side-menu/index.tsx new file mode 100644 index 0000000..07edb02 --- /dev/null +++ b/apps/suman-bosna/src/modules/layout/components/side-menu/index.tsx @@ -0,0 +1,108 @@ +"use client" + +import { useState } from "react" +import { HttpTypes } from "@medusajs/types" +import { Locale } from "@lib/data/locales" +import LocalizedClientLink from "@modules/common/components/localized-client-link" +import CountrySelect from "../country-select" +import LanguageSelect from "../language-select" +import useToggleState from "@lib/hooks/use-toggle-state" +import { + Sheet, + SheetContent, + SheetHeader, + SheetTitle, + SheetTrigger, +} from "@/components/ui/sheet" +import { Button } from "@/components/ui/button" +import { Separator } from "@/components/ui/separator" +import { Menu, ChevronRight } from "lucide-react" +import navigationConfig from "@/config/navigation.json" + +type SideMenuProps = { + regions: HttpTypes.StoreRegion[] | null + locales: Locale[] | null + currentLocale: string | null +} + +const SideMenu = ({ regions, locales, currentLocale }: SideMenuProps) => { + const [open, setOpen] = useState(false) + const countryToggleState = useToggleState() + const languageToggleState = useToggleState() + + return ( + + + + + +
    + + + {navigationConfig.brand.name} + {navigationConfig.brand.badge ? ( + + {navigationConfig.brand.badge} + + ) : null} + +

    + {navigationConfig.brand.tagline} +

    +
    + + + + +
    + +
    + {!!locales?.length && ( +
    + Jezik: + +
    + )} + {regions && ( +
    + Država: + +
    + )} +

    + © {new Date().getFullYear()} {navigationConfig.brand.name} {navigationConfig.brand.badge}. Sva prava zadržana. +

    +
    +
    +
    + ) +} + +export default SideMenu diff --git a/apps/suman-bosna/src/modules/layout/templates/footer/index.tsx b/apps/suman-bosna/src/modules/layout/templates/footer/index.tsx new file mode 100644 index 0000000..c89cb25 --- /dev/null +++ b/apps/suman-bosna/src/modules/layout/templates/footer/index.tsx @@ -0,0 +1,175 @@ +import Image from "next/image" +import { Phone, Mail, MapPin, ArrowRight } from "lucide-react" +import LocalizedClientLink from "@modules/common/components/localized-client-link" +import footerConfig from "@/config/footer.json" + +function SocialIcon({ name }: { name: string }) { + switch (name.toLowerCase()) { + case "instagram": + return ( + + + + + + ) + case "facebook": + return ( + + + + ) + case "x": + case "twitter": + return ( + + + + ) + case "linkedin": + return ( + + + + + + ) + default: + return null + } +} + +export default async function Footer() { + const { banner, brand, columns, contact, bottomBar } = footerConfig + + return ( +
    +
    + {/* Top Banner Card matching user reference image */} +
    + {/* Background image */} + {banner.title} + + {/* Dark gradient overlay on the left */} +
    +
    + + {/* Banner content */} +
    +

    + {banner.title} +

    +

    + {banner.subtitle} +

    +
    + + + {banner.cta.label} + +
    + +
    +
    +
    +
    +
    + + {/* 4-Columns Main Footer Grid matching screenshot */} +
    + {/* Column 1: Brand description and social media icons */} +
    +

    + {brand.description} +

    +
    + {brand.socials.map((social) => ( + + + + ))} +
    +
    + + {/* Column 2 & 3: Configurable Navigation Columns */} + {columns.map((col, idx) => ( +
    +

    + {col.title} +

    +
      + {col.links.map((link) => ( +
    • + + {link.title} + +
    • + ))} +
    +
    + ))} + + {/* Column 4: Contact details with icons */} +
    +

    + {contact.title} +

    + +
    +
    + + {/* Bottom Bar: Copyright & Policy Links */} +
    +

    © {new Date().getFullYear()} {bottomBar.copyright}

    +
    + {bottomBar.links.map((link) => ( + + {link.title} + + ))} +
    +
    +
    +
    + ) +} diff --git a/apps/suman-bosna/src/modules/layout/templates/nav/index.tsx b/apps/suman-bosna/src/modules/layout/templates/nav/index.tsx new file mode 100644 index 0000000..74d814e --- /dev/null +++ b/apps/suman-bosna/src/modules/layout/templates/nav/index.tsx @@ -0,0 +1,109 @@ +import { Suspense } from "react" +import { listLocales } from "@lib/data/locales" +import { getLocale } from "@lib/data/locale-actions" +import { listRegions } from "@lib/data/regions" +import { StoreRegion } from "@medusajs/types" +import LocalizedClientLink from "@modules/common/components/localized-client-link" +import CartButton from "@modules/layout/components/cart-button" +import Search from "@modules/layout/components/search" +import SideMenu from "@modules/layout/components/side-menu" +import { User, ShoppingBag } from "lucide-react" +import navigationConfig from "@/config/navigation.json" +import { Logo } from "@/components/ui/logo" + +interface NavProps { + variant?: "floating" | "classic" +} + +export default async function Nav({ variant }: NavProps) { + const [regions, locales, currentLocale] = await Promise.all([ + listRegions().then((regions: StoreRegion[]) => regions), + listLocales(), + getLocale(), + ]) + + const effectiveVariant = + variant || (navigationConfig as { headerVersion?: "floating" | "classic" }).headerVersion || "floating" + + const navContent = ( + <> + {/* Left: Brand Logo */} + + + + + {/* Center: Desktop Navigation Links from navigation.json */} + + + {/* Right: Search, Account, Cart, Mobile Menu */} +
    + + + + + + + 0 + + } + > + + + + {/* Mobile menu trigger - only visible on small screens */} +
    + +
    +
    + + ) + + // Version 1: Floating with border radius, detached from top, left, and right + if (effectiveVariant === "floating") { + return ( +
    +
    + {navContent} +
    +
    + ) + } + + // Version 2: Classic edge-to-edge full width sticky header + return ( +
    +
    + {navContent} +
    +
    + ) +} diff --git a/apps/suman-bosna/src/modules/order/components/help/index.tsx b/apps/suman-bosna/src/modules/order/components/help/index.tsx new file mode 100644 index 0000000..127e607 --- /dev/null +++ b/apps/suman-bosna/src/modules/order/components/help/index.tsx @@ -0,0 +1,25 @@ +import { Heading } from "@modules/common/components/ui" +import LocalizedClientLink from "@modules/common/components/localized-client-link" +import React from "react" + +const Help = () => { + return ( +
    + Need help? +
    +
      +
    • + Contact +
    • +
    • + + Returns & Exchanges + +
    • +
    +
    +
    + ) +} + +export default Help diff --git a/apps/suman-bosna/src/modules/order/components/item/index.tsx b/apps/suman-bosna/src/modules/order/components/item/index.tsx new file mode 100644 index 0000000..f92bf69 --- /dev/null +++ b/apps/suman-bosna/src/modules/order/components/item/index.tsx @@ -0,0 +1,57 @@ +import { HttpTypes } from "@medusajs/types" +import { Table, Text } from "@modules/common/components/ui" + +import LineItemOptions from "@modules/common/components/line-item-options" +import LineItemPrice from "@modules/common/components/line-item-price" +import LineItemUnitPrice from "@modules/common/components/line-item-unit-price" +import Thumbnail from "@modules/products/components/thumbnail" + +type ItemProps = { + item: HttpTypes.StoreCartLineItem | HttpTypes.StoreOrderLineItem + currencyCode: string +} + +const Item = ({ item, currencyCode }: ItemProps) => { + return ( + + +
    + +
    +
    + + + + {item.product_title} + + + + + + + + + {item.quantity}x{" "} + + + + + + + +
    + ) +} + +export default Item diff --git a/apps/suman-bosna/src/modules/order/components/items/index.tsx b/apps/suman-bosna/src/modules/order/components/items/index.tsx new file mode 100644 index 0000000..2a14ac0 --- /dev/null +++ b/apps/suman-bosna/src/modules/order/components/items/index.tsx @@ -0,0 +1,44 @@ +import repeat from "@lib/util/repeat" +import { HttpTypes } from "@medusajs/types" +import { Table } from "@modules/common/components/ui" + +import Divider from "@modules/common/components/divider" +import Item from "@modules/order/components/item" +import SkeletonLineItem from "@modules/skeletons/components/skeleton-line-item" + +type ItemsProps = { + order: HttpTypes.StoreOrder +} + +const Items = ({ order }: ItemsProps) => { + const items = order.items + + return ( +
    + + + + {items?.length + ? items + .sort((a, b) => { + return (a.created_at ?? "") > (b.created_at ?? "") ? -1 : 1 + }) + .map((item) => { + return ( + + ) + }) + : repeat(5).map((i) => { + return + })} + +
    +
    + ) +} + +export default Items diff --git a/apps/suman-bosna/src/modules/order/components/onboarding-cta/index.tsx b/apps/suman-bosna/src/modules/order/components/onboarding-cta/index.tsx new file mode 100644 index 0000000..b1d675b --- /dev/null +++ b/apps/suman-bosna/src/modules/order/components/onboarding-cta/index.tsx @@ -0,0 +1,28 @@ +"use client" + +import { resetOnboardingState } from "@lib/data/onboarding" +import { Button, Container, Text } from "@modules/common/components/ui" + +const OnboardingCta = ({ orderId }: { orderId: string }) => { + return ( + +
    + + Your test order was successfully created! 🎉 + + + You can now complete setting up your store in the admin. + + +
    +
    + ) +} + +export default OnboardingCta diff --git a/apps/suman-bosna/src/modules/order/components/order-details/index.tsx b/apps/suman-bosna/src/modules/order/components/order-details/index.tsx new file mode 100644 index 0000000..c3acfb2 --- /dev/null +++ b/apps/suman-bosna/src/modules/order/components/order-details/index.tsx @@ -0,0 +1,63 @@ +import { HttpTypes } from "@medusajs/types" +import { Text } from "@modules/common/components/ui" + +type OrderDetailsProps = { + order: HttpTypes.StoreOrder + showStatus?: boolean +} + +const OrderDetails = ({ order, showStatus }: OrderDetailsProps) => { + const formatStatus = (str: string) => { + const formatted = str.split("_").join(" ") + + return formatted.slice(0, 1).toUpperCase() + formatted.slice(1) + } + + return ( +
    + + We have sent the order confirmation details to{" "} + + {order.email} + + . + + + Order date:{" "} + + {new Date(order.created_at).toDateString()} + + + + Order number: {order.display_id} + + +
    + {showStatus && ( + <> + + Order status:{" "} + + {formatStatus(order.fulfillment_status)} + + + + Payment status:{" "} + + {formatStatus(order.payment_status)} + + + + )} +
    +
    + ) +} + +export default OrderDetails diff --git a/apps/suman-bosna/src/modules/order/components/order-summary/index.tsx b/apps/suman-bosna/src/modules/order/components/order-summary/index.tsx new file mode 100644 index 0000000..caf2952 --- /dev/null +++ b/apps/suman-bosna/src/modules/order/components/order-summary/index.tsx @@ -0,0 +1,60 @@ +import { convertToLocale } from "@lib/util/money" +import { HttpTypes } from "@medusajs/types" + +type OrderSummaryProps = { + order: HttpTypes.StoreOrder +} + +const OrderSummary = ({ order }: OrderSummaryProps) => { + const getAmount = (amount?: number | null) => { + if (!amount) { + return + } + + return convertToLocale({ + amount, + currency_code: order.currency_code, + }) + } + + return ( +
    +

    Order Summary

    +
    +
    + Subtotal + {getAmount(order.subtotal)} +
    +
    + {order.discount_total > 0 && ( +
    + Discount + - {getAmount(order.discount_total)} +
    + )} + {order.gift_card_total > 0 && ( +
    + Discount + - {getAmount(order.gift_card_total)} +
    + )} +
    + Shipping + {getAmount(order.shipping_total)} +
    +
    + Taxes + {getAmount(order.tax_total)} +
    +
    +
    +
    + Total + {getAmount(order.total)} +
    +
    +
    + ) +} + +export default OrderSummary diff --git a/apps/suman-bosna/src/modules/order/components/payment-details/index.tsx b/apps/suman-bosna/src/modules/order/components/payment-details/index.tsx new file mode 100644 index 0000000..bd01690 --- /dev/null +++ b/apps/suman-bosna/src/modules/order/components/payment-details/index.tsx @@ -0,0 +1,63 @@ +import { Container, Heading, Text } from "@modules/common/components/ui" + +import { getPaymentInfo, isStripeLike } from "@lib/constants" +import Divider from "@modules/common/components/divider" +import { convertToLocale } from "@lib/util/money" +import { HttpTypes } from "@medusajs/types" + +type PaymentDetailsProps = { + order: HttpTypes.StoreOrder +} + +const PaymentDetails = ({ order }: PaymentDetailsProps) => { + const payment = order.payment_collections?.[0].payments?.[0] + + return ( +
    + + Payment + +
    + {payment && ( +
    +
    + + Payment method + + + {getPaymentInfo(payment.provider_id)?.title || payment.provider_id} + +
    +
    + + Payment details + +
    + + {getPaymentInfo(payment.provider_id)?.icon} + + + {isStripeLike(payment.provider_id) && payment.data?.card_last4 + ? `**** **** **** ${payment.data.card_last4}` + : `${convertToLocale({ + amount: payment.amount, + currency_code: order.currency_code, + })} paid at ${new Date( + payment.created_at ?? "" + ).toLocaleString()}`} + +
    +
    +
    + )} +
    + + +
    + ) +} + +export default PaymentDetails diff --git a/apps/suman-bosna/src/modules/order/components/shipping-details/index.tsx b/apps/suman-bosna/src/modules/order/components/shipping-details/index.tsx new file mode 100644 index 0000000..c475efc --- /dev/null +++ b/apps/suman-bosna/src/modules/order/components/shipping-details/index.tsx @@ -0,0 +1,73 @@ +import { convertToLocale } from "@lib/util/money" +import { HttpTypes } from "@medusajs/types" +import { Heading, Text } from "@modules/common/components/ui" + +import Divider from "@modules/common/components/divider" + +type ShippingDetailsProps = { + order: HttpTypes.StoreOrder +} + +const ShippingDetails = ({ order }: ShippingDetailsProps) => { + return ( +
    + + Delivery + +
    +
    + + Shipping Address + + + {order.shipping_address?.first_name}{" "} + {order.shipping_address?.last_name} + + + {order.shipping_address?.address_1}{" "} + {order.shipping_address?.address_2} + + + {order.shipping_address?.postal_code},{" "} + {order.shipping_address?.city} + + + {order.shipping_address?.country_code?.toUpperCase()} + +
    + +
    + Contact + + {order.shipping_address?.phone} + + {order.email} +
    + +
    + Method + + {(order.shipping_methods?.[0] as { name?: string })?.name} ( + {convertToLocale({ + amount: order.shipping_methods?.[0]?.total ?? 0, + currency_code: order.currency_code, + })} + ) + +
    +
    + +
    + ) +} + +export default ShippingDetails diff --git a/apps/suman-bosna/src/modules/order/components/transfer-actions/index.tsx b/apps/suman-bosna/src/modules/order/components/transfer-actions/index.tsx new file mode 100644 index 0000000..16206d8 --- /dev/null +++ b/apps/suman-bosna/src/modules/order/components/transfer-actions/index.tsx @@ -0,0 +1,81 @@ +"use client" + +import { acceptTransferRequest, declineTransferRequest } from "@lib/data/orders" +import { Button, Text } from "@modules/common/components/ui" +import { useState } from "react" + +type TransferStatus = "pending" | "success" | "error" + +const TransferActions = ({ id, token }: { id: string; token: string }) => { + const [errorMessage, setErrorMessage] = useState(null) + const [status, setStatus] = useState<{ + accept: TransferStatus | null + decline: TransferStatus | null + } | null>({ + accept: null, + decline: null, + }) + + const acceptTransfer = async () => { + setStatus({ accept: "pending", decline: null }) + setErrorMessage(null) + + const { success, error } = await acceptTransferRequest(id, token) + + if (error) setErrorMessage(error) + setStatus({ accept: success ? "success" : "error", decline: null }) + } + + const declineTransfer = async () => { + setStatus({ accept: null, decline: "pending" }) + setErrorMessage(null) + + const { success, error } = await declineTransferRequest(id, token) + + if (error) setErrorMessage(error) + setStatus({ accept: null, decline: success ? "success" : "error" }) + } + + return ( +
    + {status?.accept === "success" && ( + + Order transferred successfully! + + )} + {status?.decline === "success" && ( + + Order transfer declined successfully! + + )} + {status?.accept !== "success" && status?.decline !== "success" && ( +
    + + +
    + )} + {errorMessage && {errorMessage}} +
    + ) +} + +export default TransferActions diff --git a/apps/suman-bosna/src/modules/order/components/transfer-image/index.tsx b/apps/suman-bosna/src/modules/order/components/transfer-image/index.tsx new file mode 100644 index 0000000..13bd047 --- /dev/null +++ b/apps/suman-bosna/src/modules/order/components/transfer-image/index.tsx @@ -0,0 +1,275 @@ +import { SVGProps } from "react" + +const TransferImage = (_props: SVGProps) => ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +) + +export default TransferImage diff --git a/apps/suman-bosna/src/modules/order/templates/order-completed-template.tsx b/apps/suman-bosna/src/modules/order/templates/order-completed-template.tsx new file mode 100644 index 0000000..4c85f35 --- /dev/null +++ b/apps/suman-bosna/src/modules/order/templates/order-completed-template.tsx @@ -0,0 +1,52 @@ +import { Heading } from "@modules/common/components/ui" +import { cookies as nextCookies } from "next/headers" + +import CartTotals from "@modules/common/components/cart-totals" +import Help from "@modules/order/components/help" +import Items from "@modules/order/components/items" +import OnboardingCta from "@modules/order/components/onboarding-cta" +import OrderDetails from "@modules/order/components/order-details" +import ShippingDetails from "@modules/order/components/shipping-details" +import PaymentDetails from "@modules/order/components/payment-details" +import { HttpTypes } from "@medusajs/types" + +type OrderCompletedTemplateProps = { + order: HttpTypes.StoreOrder +} + +export default async function OrderCompletedTemplate({ + order, +}: OrderCompletedTemplateProps) { + const cookies = await nextCookies() + + const isOnboarding = cookies.get("_medusa_onboarding")?.value === "true" + + return ( +
    +
    + {isOnboarding && } +
    + + Thank you! + Your order was placed successfully. + + + + Summary + + + + + + +
    +
    +
    + ) +} diff --git a/apps/suman-bosna/src/modules/order/templates/order-details-template.tsx b/apps/suman-bosna/src/modules/order/templates/order-details-template.tsx new file mode 100644 index 0000000..10b8109 --- /dev/null +++ b/apps/suman-bosna/src/modules/order/templates/order-details-template.tsx @@ -0,0 +1,46 @@ +"use client" + +import { ArrowLeft } from "lucide-react" +import { HttpTypes } from "@medusajs/types" +import LocalizedClientLink from "@modules/common/components/localized-client-link" +import Help from "@modules/order/components/help" +import Items from "@modules/order/components/items" +import OrderDetails from "@modules/order/components/order-details" +import OrderSummary from "@modules/order/components/order-summary" +import ShippingDetails from "@modules/order/components/shipping-details" +import React from "react" + +type OrderDetailsTemplateProps = { + order: HttpTypes.StoreOrder +} + +const OrderDetailsTemplate: React.FC = ({ + order, +}) => { + return ( +
    +
    +

    Order details

    + + Nazad na pregled + +
    +
    + + + + + +
    +
    + ) +} + +export default OrderDetailsTemplate diff --git a/apps/suman-bosna/src/modules/policies/templates/index.tsx b/apps/suman-bosna/src/modules/policies/templates/index.tsx new file mode 100644 index 0000000..c77aac9 --- /dev/null +++ b/apps/suman-bosna/src/modules/policies/templates/index.tsx @@ -0,0 +1,50 @@ +import { convertToLocale } from "@lib/util/money" +import { formatDayRange, StorePolicies } from "@lib/util/store-policies" + +export const formatShippingRate = (rate: number, currencyCode: string) => + rate === 0 ? "Free" : convertToLocale({ amount: rate, currency_code: currencyCode }) + +export const PolicyPage = ({ + title, + children, +}: { + title: string + children: React.ReactNode +}) => ( +
    +

    {title}

    +
    + {children} +
    +
    +) + +export const PoliciesUnavailable = () => ( +

    + Policy details for this region haven't been published yet. +

    +) + +export const ShippingSummary = ({ + policies, + currencyCode, +}: { + policies: StorePolicies + currencyCode: string +}) => ( +
    +
    Shipping rate
    +
    {formatShippingRate(policies.shippingRate, currencyCode)}
    +
    Processing time
    +
    {formatDayRange(policies.handlingDays)} business days
    +
    Delivery time
    +
    {formatDayRange(policies.transitDays)} business days after dispatch
    +
    +) + +export const PlaceholderNotice = () => ( +

    + This is placeholder content from the Medusa starter. Replace it with your + store's own text before launch. +

    +) diff --git a/apps/suman-bosna/src/modules/products/components/gallery-and-configurator/index.tsx b/apps/suman-bosna/src/modules/products/components/gallery-and-configurator/index.tsx new file mode 100644 index 0000000..74bab21 --- /dev/null +++ b/apps/suman-bosna/src/modules/products/components/gallery-and-configurator/index.tsx @@ -0,0 +1,115 @@ +"use client" + +import React, { useState, useEffect } from "react" +import { HttpTypes } from "@medusajs/types" +import VariantImageGallery from "@modules/products/components/image-gallery/variant-image-gallery" +import Umbrella2DConfigurator from "@modules/products/components/umbrella-configurator" +import { Image as ImageIcon, Sparkles } from "lucide-react" +import { usePathname, useRouter, useSearchParams } from "next/navigation" + +type GalleryAndConfiguratorProps = { + product: HttpTypes.StoreProduct +} + +export default function GalleryAndConfigurator({ + product, +}: GalleryAndConfiguratorProps) { + const router = useRouter() + const pathname = usePathname() + const searchParams = useSearchParams() + + const allowCustomization = Boolean(product.metadata?.allow_customization) + const isConfigParam = searchParams.get("view") === "configurator" + const [activeTab, setActiveTab] = useState<"gallery" | "configurator">( + isConfigParam ? "configurator" : "gallery" + ) + + useEffect(() => { + if (isConfigParam) { + setActiveTab("configurator") + } + }, [isConfigParam]) + + // Helper za dobavljanje trenutnih opcija iz varijante u URL-u + const currentVariantId = searchParams.get("v_id") + const currentVariant = + product.variants?.find((v) => v.id === currentVariantId) || + product.variants?.[0] + + const optionsMap: Record = {} + currentVariant?.options?.forEach((opt) => { + if (opt.option_id) optionsMap[opt.option_id] = opt.value + }) + + const handleSelectOption = (optionId: string, value: string) => { + // Pronađi varijantu koja ima ovu opciju + const targetVariant = product.variants?.find((v) => { + const matchTarget = v.options?.some( + (o) => o.option_id === optionId && o.value === value + ) + return matchTarget + }) + + if (targetVariant) { + const params = new URLSearchParams(searchParams.toString()) + params.set("v_id", targetVariant.id) + router.replace(pathname + "?" + params.toString()) + } + } + + const switchTab = (tab: "gallery" | "configurator") => { + setActiveTab(tab) + const params = new URLSearchParams(searchParams.toString()) + if (tab === "configurator") { + params.set("view", "configurator") + } else { + params.delete("view") + } + router.replace(pathname + "?" + params.toString(), { scroll: false }) + } + + return ( + + ) +} diff --git a/apps/suman-bosna/src/modules/products/components/image-gallery/index.tsx b/apps/suman-bosna/src/modules/products/components/image-gallery/index.tsx new file mode 100644 index 0000000..eb9015e --- /dev/null +++ b/apps/suman-bosna/src/modules/products/components/image-gallery/index.tsx @@ -0,0 +1,43 @@ +import { HttpTypes } from "@medusajs/types" +import Image from "next/image" + +type ImageGalleryProps = { + images: HttpTypes.StoreProductImage[] +} + +const ImageGallery = ({ images }: ImageGalleryProps) => { + if (!images || images.length === 0) { + return ( +
    + Nema slike za ovaj proizvod +
    + ) + } + + return ( +
    + {images.map((image, index) => { + return ( +
    + {!!image.url && ( + {`Suman + )} +
    + ) + })} +
    + ) +} + +export default ImageGallery diff --git a/apps/suman-bosna/src/modules/products/components/image-gallery/variant-image-gallery.tsx b/apps/suman-bosna/src/modules/products/components/image-gallery/variant-image-gallery.tsx new file mode 100644 index 0000000..5f49330 --- /dev/null +++ b/apps/suman-bosna/src/modules/products/components/image-gallery/variant-image-gallery.tsx @@ -0,0 +1,48 @@ +"use client" + +import { HttpTypes } from "@medusajs/types" +import { useSearchParams } from "next/navigation" +import { useEffect, useMemo, useState } from "react" +import ImageGallery from "." + +const getImagesForVariant = ( + product: HttpTypes.StoreProduct, + selectedVariantId?: string, +) => { + if (!selectedVariantId || !product.variants) { + return product.images + } + + const variant = product.variants!.find((v) => v.id === selectedVariantId) + if (!variant || !variant.images?.length) { + return product.images + } + + const imageIdsMap = new Map(variant.images!.map((i) => [i.id, true])) + return product.images?.filter((i) => imageIdsMap.has(i.id)) ?? null +} + +/** + * Shows the images of the variant selected with `?v_id=`. Product pages are + * statically rendered, so the filter is only applied after hydration. + */ +const VariantImageGallery = ({ + product, +}: { + product: HttpTypes.StoreProduct +}) => { + const searchParams = useSearchParams() + const [isMounted, setIsMounted] = useState(false) + + useEffect(() => setIsMounted(true), []) + + const variantId = isMounted ? searchParams.get("v_id") ?? undefined : undefined + const images = useMemo( + () => getImagesForVariant(product, variantId) ?? [], + [product, variantId] + ) + + return +} + +export default VariantImageGallery diff --git a/apps/suman-bosna/src/modules/products/components/inquiry-modal/index.tsx b/apps/suman-bosna/src/modules/products/components/inquiry-modal/index.tsx new file mode 100644 index 0000000..1e6a398 --- /dev/null +++ b/apps/suman-bosna/src/modules/products/components/inquiry-modal/index.tsx @@ -0,0 +1,299 @@ +"use client" + +import React, { useState } from "react" +import { HttpTypes } from "@medusajs/types" +import { + Dialog, + DialogContent, + DialogHeader, + DialogTitle, + DialogDescription, +} from "@/components/ui/dialog" +import { Button } from "@/components/ui/button" +import { Input } from "@/components/ui/input" +import { Label } from "@/components/ui/label" +import { Badge } from "@/components/ui/badge" +import { submitInquiry } from "@lib/data/inquiries" +import { CheckCircle2, Send, PhoneCall, ShieldCheck, AlertCircle } from "lucide-react" +import Image from "next/image" + +type InquiryModalProps = { + product: HttpTypes.StoreProduct + open: boolean + onOpenChange: (open: boolean) => void + selectedOptions?: Record +} + +export default function InquiryModal({ + product, + open, + onOpenChange, + selectedOptions, +}: InquiryModalProps) { + const [name, setName] = useState("") + const [email, setEmail] = useState("") + const [phone, setPhone] = useState("") + const [companyName, setCompanyName] = useState("") + const [city, setCity] = useState("") + const [dimensions, setDimensions] = useState("") + const [message, setMessage] = useState("") + + const [loading, setLoading] = useState(false) + const [error, setError] = useState(null) + const [submitted, setSubmitted] = useState(false) + + const handleSubmit = async (e: React.FormEvent) => { + e.preventDefault() + setError(null) + + if (!name || !email || !phone || !city) { + setError("Molimo ispunite obavezna polja (Ime, Email, Telefon, Grad).") + return + } + + setLoading(true) + + try { + const formattedOptions = selectedOptions + ? Object.entries(selectedOptions) + .filter(([_, v]) => Boolean(v)) + .map(([k, v]) => `${k}: ${v}`) + .join(", ") + : "" + + const fullMessage = formattedOptions + ? `${message}\n\n[Odabrana konfiguracija sa sajta: ${formattedOptions}]` + : message + + const result = await submitInquiry({ + name, + email, + phone, + company_name: companyName || null, + city, + dimensions: dimensions || null, + message: fullMessage, + product_id: product.id, + metadata: { + product_title: product.title, + product_handle: product.handle, + selected_options: selectedOptions || {}, + }, + }) + + if (result.success) { + setSubmitted(true) + } else { + setError(result.error || "Došlo je do greške. Pokušajte ponovo.") + } + } catch (err: any) { + setError(err?.message || "Greška pri slanju upita.") + } finally { + setLoading(false) + } + } + + const handleClose = () => { + onOpenChange(false) + if (submitted) { + setTimeout(() => { + setSubmitted(false) + setName("") + setEmail("") + setPhone("") + setCompanyName("") + setCity("") + setDimensions("") + setMessage("") + setError(null) + }, 300) + } + } + + return ( + + + {submitted ? ( +
    +
    + +
    + + Zahvaljujemo na Vašem upitu! + + + Vaš zahtjev za model {product.title} je uspješno proslijeđen Suman tehničkom timu. Kontaktirat ćemo Vas u roku od 24 sata sa detaljnom ponudom i savjetima. + +
    + +
    +
    + ) : ( + <> + +
    + + Direktno od proizvođača + + + + 3 do 5 god. garancije + +
    + + Zatražite besplatnu ponudu i savjetovanje + + + Unesite podatke za {product.title} i naš tim će izraditi optimalno tehničko rješenje po Vašim mjerama. + +
    + + {/* Product Quick Banner */} +
    + {product.thumbnail && ( +
    + {product.title} +
    + )} +
    +
    + {product.title} +
    +
    + {(product.metadata?.quote_subtitle as string) || "Izrada po mjeri sa profesionalnom montažom"} +
    +
    +
    + + {error && ( +
    + + {error} +
    + )} + +
    +
    +
    + + setName(e.target.value)} + placeholder="npr. Emir Hadžić" + required + /> +
    + +
    + + setCompanyName(e.target.value)} + placeholder="npr. Hotel & Caffe Suman" + /> +
    + +
    + + setEmail(e.target.value)} + placeholder="vas@email.com" + required + /> +
    + +
    + + setPhone(e.target.value)} + placeholder="+387 61 000 000" + required + /> +
    + +
    + + setCity(e.target.value)} + placeholder="npr. Sarajevo, Mostar, Tuzla..." + required + /> +
    + +
    + + setDimensions(e.target.value)} + placeholder="npr. 5x4 m ili 30 m²" + /> +
    +
    + +
    + +