Compare commits
2 Commits
fix/low-me
...
feature/do
| Author | SHA1 | Date | |
|---|---|---|---|
| 7fccd56a8f | |||
|
|
78f7c348c4 |
@@ -1,11 +0,0 @@
|
||||
{
|
||||
"version": "0.0.1",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "suman-hrvatska",
|
||||
"runtimeExecutable": "sh",
|
||||
"runtimeArgs": ["-c", "cd apps/suman-hrvatska && npx next dev -p 8020"],
|
||||
"port": 8020
|
||||
}
|
||||
]
|
||||
}
|
||||
12
Dockerfile
12
Dockerfile
@@ -26,16 +26,15 @@ COPY apps/backend ./apps/backend
|
||||
ENV NODE_ENV=production
|
||||
ENV NODE_OPTIONS="--max-old-space-size=2048"
|
||||
|
||||
# Build Medusa backend and admin dashboard (compiled to .medusa/server)
|
||||
# Build Medusa backend and admin dashboard
|
||||
RUN npm run build --workspace=@dtc/backend
|
||||
|
||||
# Prune devDependencies to keep image light and avoid OOM during copy
|
||||
RUN npm prune --production --workspace=@dtc/backend
|
||||
|
||||
# 3. Production runner stage
|
||||
# In Medusa v2, production runtime runs from the compiled .medusa/server directory
|
||||
FROM node:22-alpine AS runner
|
||||
WORKDIR /app/apps/backend/.medusa/server
|
||||
WORKDIR /app/apps/backend
|
||||
|
||||
RUN apk add --no-cache libc6-compat curl
|
||||
|
||||
@@ -46,18 +45,17 @@ ENV PORT=9000
|
||||
RUN addgroup --system --gid 1001 nodejs && \
|
||||
adduser --system --uid 1001 medusa
|
||||
|
||||
# Copy dependencies and compiled server artifacts
|
||||
# Copy pruned dependencies from builder (sequential dependency prevents BuildKit parallel I/O spike)
|
||||
COPY --from=builder --chown=medusa:nodejs /app/node_modules /app/node_modules
|
||||
COPY --from=builder --chown=medusa:nodejs /app/package.json /app/package-lock.json /app/
|
||||
COPY --from=builder --chown=medusa:nodejs /app/apps/backend /app/apps/backend
|
||||
|
||||
# Uploads directory
|
||||
RUN mkdir -p /app/apps/backend/.medusa/server/uploads /app/apps/backend/uploads && \
|
||||
chown -R medusa:nodejs /app/apps/backend
|
||||
RUN mkdir -p /app/apps/backend/uploads && chown -R medusa:nodejs /app/apps/backend/uploads
|
||||
|
||||
USER medusa
|
||||
|
||||
EXPOSE 9000
|
||||
|
||||
# Medusa v2 production entrypoint: run migrations then start server from compiled .medusa/server
|
||||
# Run migrations and start Medusa production server
|
||||
CMD ["sh", "-c", "npx medusa db:migrate && npm run start"]
|
||||
|
||||
@@ -25,16 +25,15 @@ COPY apps/backend ./apps/backend
|
||||
ENV NODE_ENV=production
|
||||
ENV NODE_OPTIONS="--max-old-space-size=2048"
|
||||
|
||||
# Build Medusa backend and admin dashboard (compiled to .medusa/server)
|
||||
# Build Medusa backend and admin dashboard
|
||||
RUN npm run build --workspace=@dtc/backend
|
||||
|
||||
# Prune devDependencies to keep image light and avoid OOM during copy
|
||||
RUN npm prune --production --workspace=@dtc/backend
|
||||
|
||||
# 3. Production runner stage
|
||||
# In Medusa v2, production runtime runs from the compiled .medusa/server directory
|
||||
FROM node:22-alpine AS runner
|
||||
WORKDIR /app/apps/backend/.medusa/server
|
||||
WORKDIR /app/apps/backend
|
||||
|
||||
RUN apk add --no-cache libc6-compat curl
|
||||
|
||||
@@ -45,18 +44,17 @@ ENV PORT=9000
|
||||
RUN addgroup --system --gid 1001 nodejs && \
|
||||
adduser --system --uid 1001 medusa
|
||||
|
||||
# Copy dependencies and compiled server artifacts
|
||||
# Copy pruned dependencies from builder (sequential dependency prevents BuildKit parallel I/O spike)
|
||||
COPY --from=builder --chown=medusa:nodejs /app/node_modules /app/node_modules
|
||||
COPY --from=builder --chown=medusa:nodejs /app/package.json /app/package-lock.json /app/
|
||||
COPY --from=builder --chown=medusa:nodejs /app/apps/backend /app/apps/backend
|
||||
|
||||
# Uploads directory
|
||||
RUN mkdir -p /app/apps/backend/.medusa/server/uploads /app/apps/backend/uploads && \
|
||||
chown -R medusa:nodejs /app/apps/backend
|
||||
RUN mkdir -p /app/apps/backend/uploads && chown -R medusa:nodejs /app/apps/backend/uploads
|
||||
|
||||
USER medusa
|
||||
|
||||
EXPOSE 9000
|
||||
|
||||
# Medusa v2 production entrypoint: run migrations then start server from compiled .medusa/server
|
||||
# Run migrations and start Medusa production server
|
||||
CMD ["sh", "-c", "npx medusa db:migrate && npm run start"]
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("@medusajs/framework/utils");
|
||||
(0, utils_1.loadEnv)(process.env.NODE_ENV || 'development', process.cwd());
|
||||
module.exports = (0, utils_1.defineConfig)({
|
||||
projectConfig: {
|
||||
databaseUrl: process.env.DATABASE_URL,
|
||||
http: {
|
||||
storeCors: process.env.STORE_CORS,
|
||||
adminCors: process.env.ADMIN_CORS,
|
||||
authCors: process.env.AUTH_CORS,
|
||||
jwtSecret: process.env.JWT_SECRET,
|
||||
cookieSecret: process.env.COOKIE_SECRET,
|
||||
}
|
||||
},
|
||||
modules: [
|
||||
{
|
||||
resolve: "./src/modules/inquiry",
|
||||
},
|
||||
],
|
||||
});
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWVkdXNhLWNvbmZpZy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL21lZHVzYS1jb25maWcudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSxxREFBaUU7QUFFakUsSUFBQSxlQUFPLEVBQUMsT0FBTyxDQUFDLEdBQUcsQ0FBQyxRQUFRLElBQUksYUFBYSxFQUFFLE9BQU8sQ0FBQyxHQUFHLEVBQUUsQ0FBQyxDQUFBO0FBRTdELE1BQU0sQ0FBQyxPQUFPLEdBQUcsSUFBQSxvQkFBWSxFQUFDO0lBQzVCLGFBQWEsRUFBRTtRQUNiLFdBQVcsRUFBRSxPQUFPLENBQUMsR0FBRyxDQUFDLFlBQVk7UUFDckMsSUFBSSxFQUFFO1lBQ0osU0FBUyxFQUFFLE9BQU8sQ0FBQyxHQUFHLENBQUMsVUFBVztZQUNsQyxTQUFTLEVBQUUsT0FBTyxDQUFDLEdBQUcsQ0FBQyxVQUFXO1lBQ2xDLFFBQVEsRUFBRSxPQUFPLENBQUMsR0FBRyxDQUFDLFNBQVU7WUFDaEMsU0FBUyxFQUFFLE9BQU8sQ0FBQyxHQUFHLENBQUMsVUFBVTtZQUNqQyxZQUFZLEVBQUUsT0FBTyxDQUFDLEdBQUcsQ0FBQyxhQUFhO1NBQ3hDO0tBQ0Y7SUFDRCxPQUFPLEVBQUU7UUFDUDtZQUNFLE9BQU8sRUFBRSx1QkFBdUI7U0FDakM7S0FDRjtDQUNGLENBQUMsQ0FBQSJ9
|
||||
@@ -20,9 +20,9 @@ WORKDIR /app
|
||||
|
||||
COPY apps/suman-bosna ./apps/suman-bosna
|
||||
|
||||
ARG NEXT_PUBLIC_MEDUSA_BACKEND_URL=http://backend:9000
|
||||
ARG NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY=pk_b722e44870bc8cc7828d0713980537e95b2e74ff229a529a4b3fa8155035f1f0
|
||||
ARG NEXT_PUBLIC_BASE_URL=http://localhost:8000
|
||||
ARG NEXT_PUBLIC_MEDUSA_BACKEND_URL
|
||||
ARG NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY
|
||||
ARG NEXT_PUBLIC_BASE_URL
|
||||
ARG NEXT_PUBLIC_DEFAULT_REGION=ba
|
||||
|
||||
ENV NEXT_PUBLIC_MEDUSA_BACKEND_URL=$NEXT_PUBLIC_MEDUSA_BACKEND_URL
|
||||
@@ -30,7 +30,6 @@ ENV NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY=$NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY
|
||||
ENV NEXT_PUBLIC_BASE_URL=$NEXT_PUBLIC_BASE_URL
|
||||
ENV NEXT_PUBLIC_DEFAULT_REGION=$NEXT_PUBLIC_DEFAULT_REGION
|
||||
ENV NODE_ENV=production
|
||||
ENV NODE_OPTIONS="--max-old-space-size=1024"
|
||||
|
||||
RUN npm run build --workspace=@dtc/suman-bosna
|
||||
|
||||
|
||||
@@ -10,10 +10,6 @@ const requiredEnvs = [
|
||||
];
|
||||
|
||||
function checkEnvVariables() {
|
||||
if (!process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY) {
|
||||
process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY = "pk_b722e44870bc8cc7828d0713980537e95b2e74ff229a529a4b3fa8155035f1f0";
|
||||
}
|
||||
|
||||
const missingEnvs = requiredEnvs.filter(function (env) {
|
||||
c;
|
||||
return !process.env[env.key];
|
||||
|
||||
@@ -13,9 +13,6 @@ const S3_PATHNAME = process.env.MEDUSA_CLOUD_S3_PATHNAME
|
||||
*/
|
||||
const nextConfig = {
|
||||
reactStrictMode: true,
|
||||
experimental: {
|
||||
cpus: 1,
|
||||
},
|
||||
async headers() {
|
||||
return [
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
],
|
||||
"scripts": {
|
||||
"dev": "next dev -p 8000",
|
||||
"build": "next build --webpack",
|
||||
"build": "next build",
|
||||
"start": "next start -p 8000",
|
||||
"lint": "eslint .",
|
||||
"analyze": "ANALYZE=true next build"
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 292 KiB |
@@ -1,55 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 22.0.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 97 100" style="enable-background:new 0 0 97 100;" xml:space="preserve">
|
||||
<style type="text/css">
|
||||
.st0{fill-rule:evenodd;clip-rule:evenodd;fill:#002655;}
|
||||
.st1{fill-rule:evenodd;clip-rule:evenodd;fill:#F9D81C;}
|
||||
.st2{fill:#F9D81C;}
|
||||
</style>
|
||||
<rect class="st0" width="97.2" height="97.2"/>
|
||||
<rect y="97.2" class="st1" width="97.2" height="2.8"/>
|
||||
<path class="st2" d="M67.6,82v-2.2l-0.3,0.1c-0.7,0.1-1.3,0.3-1.7,0.4c-0.5,0.2-0.8,0.3-1.1,0.5l0,0c-0.2,0.2-0.3,0.4-0.4,0.6
|
||||
c-0.1,0.2-0.1,0.5-0.1,0.7c0,0.5,0.1,0.8,0.4,1l0,0c0.2,0.1,0.3,0.2,0.5,0.3c0.2,0.1,0.4,0.1,0.7,0.1c0.2,0,0.4,0,0.6-0.1
|
||||
c0.2-0.1,0.4-0.2,0.6-0.3l0,0c0.2-0.1,0.3-0.2,0.4-0.4l0,0c0.1-0.1,0.2-0.3,0.3-0.4v0L67.6,82z M83.9,85.6h-4.4h-0.2v-0.2v-0.8v-0.2
|
||||
l0.2,0c0.3,0,0.5-0.1,0.5-0.4h0c0-0.1,0-0.2,0-0.2c0,0,0-0.1,0-0.1v-5.2c0-0.3,0-0.6-0.1-0.8c-0.1-0.2-0.1-0.4-0.3-0.6l0,0
|
||||
c-0.1-0.2-0.3-0.3-0.5-0.4v0c-1-0.4-1.9,0-2.6,0.7l-0.3,0.4v5.9v0.2c0,0.1,0,0.2,0,0.3v0c0,0.2,0.3,0.2,0.4,0.2l0,0l0,0l0.2,0l0.2,0
|
||||
v0.2v0.8v0.2h-0.2h-4.3h-0.2v-0.2v-0.8v-0.2l0.2,0c0.2,0,0.5,0,0.5-0.3c0-0.1,0-0.2,0-0.3v-0.2v-6.8c0-0.2,0-0.4,0-0.5
|
||||
c0-0.4-0.1-0.6-0.5-0.7l-0.2,0v-0.2v-0.8v-0.2h0.2h3.3h0.2v0.2v0.5c0.1-0.1,0.1-0.1,0.2-0.2c0.3-0.2,0.6-0.3,1-0.5l0,0
|
||||
c0.4-0.2,0.8-0.3,1.1-0.4c0.4-0.1,0.8-0.1,1.2-0.1c0.6,0,1.1,0.1,1.6,0.3c0.5,0.2,0.9,0.5,1.2,0.9l0,0c0.3,0.4,0.5,0.8,0.7,1.4
|
||||
c0.1,0.5,0.2,1.1,0.2,1.8v5.2c0,0.2,0,0.3,0,0.4v0c0,0.3,0.2,0.3,0.4,0.3l0,0l0.2,0l0.2,0v0.2v0.8v0.2H83.9z M59.1,85.6h-4.2h-0.2
|
||||
v-0.2v-0.8v-0.2l0.2,0c0.2,0,0.4-0.1,0.4-0.3c0,0,0-0.1,0-0.2c0-0.1,0-0.3,0-0.4v-5.1c0-0.3,0-0.6-0.1-0.8c-0.1-0.2-0.2-0.4-0.4-0.5
|
||||
c-0.1-0.1-0.3-0.2-0.5-0.3c-1.3-0.4-2,0.2-2.7,1.1v5.9c0,0.1,0,0.2,0,0.2c0,0.3,0.1,0.5,0.4,0.5l0,0l0.2,0l0.2,0v0.2v0.8v0.2h-0.2
|
||||
h-4.3h-0.2v-0.2v-0.8v-0.2l0.2,0c0.3-0.1,0.5,0,0.5-0.5l0,0c0,0,0-0.1,0-0.2c0-0.1,0-0.1,0-0.1l0,0v-5.2c0-0.3,0-0.6-0.1-0.8
|
||||
c-0.1-0.2-0.2-0.4-0.3-0.6l0,0c-0.1-0.2-0.3-0.3-0.5-0.4c-1.2-0.5-2.2,0.2-2.8,1.2v5.8v0.3c0,0.5,0.2,0.4,0.6,0.4l0.2,0v0.2v0.8v0.2
|
||||
h-0.2h-4.2h-0.2v-0.2v-0.8v-0.2l0.2,0c0.4-0.1,0.5,0,0.5-0.4v-0.3v-7c0-0.1,0-0.3,0-0.4v0c0-0.2,0-0.2-0.1-0.3
|
||||
c-0.2-0.1-0.4-0.2-0.7-0.1v-0.3v-0.8v-0.2h0.2h3.5h0.2v0.2v0.6c0.1-0.1,0.2-0.1,0.2-0.2c0.2-0.2,0.5-0.3,0.8-0.5l0,0
|
||||
c0.4-0.2,0.7-0.3,1.1-0.4c0.4-0.1,0.7-0.1,1.1-0.1c0.7,0,1.3,0.1,1.8,0.4c0.3,0.1,0.5,0.3,0.8,0.5c0.2,0.2,0.4,0.3,0.5,0.5
|
||||
c0.1-0.1,0.3-0.3,0.5-0.4c0.3-0.2,0.6-0.4,0.9-0.5l0,0c0.4-0.2,0.8-0.3,1.2-0.4c0.4-0.1,0.8-0.1,1.2-0.1c0.6,0,1.2,0.1,1.7,0.3
|
||||
c0.5,0.2,0.9,0.5,1.2,0.8h0c0.3,0.3,0.5,0.8,0.7,1.3c0.1,0.5,0.2,1.1,0.2,1.7v5.2v0.4c0,0.1,0,0.2,0,0.3v0c0,0.2,0.3,0.2,0.5,0.2
|
||||
l0,0l0.2,0l0.2,0v0.2v0.8v0.2H59.1z M39.6,85.6h-3.5h-0.2v-0.2v-0.7c-0.3,0.2-0.6,0.4-0.8,0.5c-0.3,0.2-0.5,0.3-0.8,0.4
|
||||
c-0.3,0.1-0.5,0.2-0.8,0.2c-0.3,0.1-0.6,0.1-0.9,0.1c-0.6,0-1.2-0.1-1.7-0.3c-0.5-0.2-0.9-0.5-1.3-0.8l0,0c-0.3-0.3-0.6-0.7-0.8-1.2
|
||||
c-0.2-0.4-0.3-0.9-0.3-1.4v-5.9h0c0-0.4,0-0.7-0.5-0.6l-0.3,0v-0.3v-0.8v-0.2h0.2h3.6h0.2v0.2v7.2c0,0.3,0,0.5,0.1,0.7
|
||||
c0.1,0.2,0.2,0.4,0.3,0.5c0.1,0.2,0.3,0.3,0.5,0.4c0.2,0.1,0.5,0.1,0.8,0.1c0.5,0,1-0.2,1.5-0.5h0c0.3-0.2,0.5-0.4,0.6-0.6
|
||||
c0.1-0.2,0.2-0.4,0.2-0.7v-5.3c0-0.1,0-0.2,0-0.2c0-0.4-0.3-0.5-0.6-0.4l-0.3,0v-0.3v-0.8v-0.2H35h3.8H39v0.2v8.9c0,0.1,0,0.2,0,0.2
|
||||
c0,0.5,0.2,0.5,0.6,0.5l0.2,0v0.2v0.8v0.2H39.6z M26.9,80.7c0,0.8-0.2,1.5-0.5,2.1c-0.3,0.6-0.8,1.2-1.5,1.7
|
||||
c-0.6,0.5-1.4,0.8-2.2,1.1c-0.9,0.2-1.8,0.4-2.9,0.4c-0.7,0-1.3-0.1-1.9-0.2c-0.6-0.1-1.2-0.4-1.7-0.7c-0.6-0.3-1.1-0.7-1.6-1.2
|
||||
c-0.5-0.5-0.9-1-1.2-1.6l0,0l-0.3-0.5l-0.1-0.2l0.2-0.1l3.1-2.2l0.2-0.1l0.1,0.2l0.7,0.7l0.1,0.2l-0.1,0.2l-0.2,0.3l0,0
|
||||
c-0.1,0.1-0.1,0.2-0.2,0.3v0c0,0.1-0.1,0.2-0.1,0.3c0,0.5,0.3,1,0.8,1.3h0c0.3,0.2,0.7,0.4,1.1,0.5c0.4,0.1,0.9,0.2,1.3,0.2
|
||||
c0.5,0,0.9,0,1.2-0.1c0.4-0.1,0.7-0.2,0.9-0.4l0,0c0.3-0.2,0.6-0.5,0.8-0.8c0.2-0.3,0.3-0.7,0.3-1.1c0-0.3-0.1-0.6-0.3-0.9
|
||||
c-0.2-0.3-0.5-0.5-0.9-0.7l0,0c-0.1-0.1-0.4-0.2-0.9-0.3c-0.4-0.1-1-0.3-1.7-0.4l0,0l-1-0.3c-0.7-0.2-1.4-0.4-1.9-0.6
|
||||
c-0.5-0.2-1-0.4-1.3-0.7v0c-0.5-0.4-0.9-0.8-1.1-1.3c-0.2-0.5-0.4-1.1-0.4-1.8c0-0.7,0.2-1.4,0.5-2c0.3-0.6,0.8-1.1,1.4-1.5l0,0
|
||||
c0.6-0.4,1.2-0.7,2-0.9c0.7-0.2,1.6-0.3,2.5-0.3c0.6,0,1.2,0.1,1.8,0.2c0.6,0.1,1.1,0.3,1.6,0.5c0.5,0.2,1,0.5,1.4,0.8
|
||||
c0.4,0.3,0.9,0.8,1.2,1.2l0.2,0.3l0.1,0.2l-0.2,0.2l-2.5,2.2L23.8,75l-0.2-0.1l-0.7-0.6l-0.1-0.1l0.1-0.2l0.1-0.4l0,0
|
||||
c0,0,0-0.1,0-0.1h0c0,0,0,0,0-0.1c0,0,0,0,0-0.1c0-0.2-0.1-0.4-0.2-0.5c-0.2-0.2-0.4-0.4-0.7-0.5c-0.3-0.2-0.7-0.3-1-0.4
|
||||
c-0.3-0.1-0.7-0.1-1-0.1c-0.4,0-0.8,0-1.1,0.1c-0.3,0.1-0.6,0.1-0.8,0.2v0c-0.3,0.1-0.5,0.3-0.7,0.5c-0.1,0.2-0.2,0.5-0.2,0.7
|
||||
c0,0.3,0.1,0.6,0.2,0.8c0.2,0.2,0.4,0.4,0.8,0.6v0c0.1,0.1,0.4,0.1,0.8,0.2c0.4,0.1,0.9,0.2,1.5,0.4l0,0l1.2,0.3l0,0
|
||||
c0.8,0.2,1.4,0.4,2,0.6c0.6,0.3,1.1,0.6,1.5,0.9c0.5,0.4,0.9,1,1.2,1.5C26.8,79.3,26.9,80,26.9,80.7z M71.3,85.6H68h-0.2v-0.2v-0.5
|
||||
c-0.4,0.3-0.9,0.6-1.4,0.8c-0.6,0.2-1.2,0.3-1.9,0.3c-0.6,0-1.1-0.1-1.6-0.2c-0.5-0.2-0.9-0.4-1.3-0.7h0c-0.4-0.3-0.7-0.8-0.9-1.2
|
||||
c-0.2-0.5-0.3-1-0.3-1.5c0-0.5,0.1-0.9,0.3-1.3c0.2-0.4,0.4-0.8,0.8-1.1c0.3-0.3,0.7-0.5,1.1-0.7c0.4-0.2,0.9-0.4,1.4-0.6l0,0
|
||||
c0.4-0.1,0.8-0.2,1.4-0.3c0.5-0.1,1.1-0.2,1.7-0.3h0l0.5-0.1v-0.1c0-0.2,0-0.4-0.1-0.5c-0.1-0.2-0.3-0.3-0.5-0.4
|
||||
c-0.2-0.1-0.5-0.2-0.8-0.3c-0.3-0.1-0.7-0.1-1.2-0.1c-0.2,0-0.4,0-0.6,0.1c-0.2,0-0.4,0.1-0.6,0.2l0,0c-0.2,0.1-0.4,0.2-0.5,0.3
|
||||
c-0.2,0.1-0.3,0.3-0.4,0.4l-0.2,0.2l-0.1,0.1h-0.1h-1h-0.2v-0.2V75v-0.2l0.2-0.1l0.4-0.1l0,0c0.3-0.1,0.7-0.2,1.1-0.3
|
||||
c0.4-0.1,0.7-0.1,1.1-0.2c0.4-0.1,0.7-0.1,1-0.1c0.3,0,0.6,0,0.9,0c1.6,0,2.8,0.3,3.7,1c0.8,0.7,1.3,1.6,1.3,3v6
|
||||
c0,0.3,0.2,0.5,0.5,0.4l0.3-0.1v0.3v0.8v0.2H71.3z"/>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 5.7 KiB |
@@ -7,7 +7,7 @@ import { Metadata } from "next"
|
||||
import { notFound } from "next/navigation"
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "Plaćanje",
|
||||
title: "Checkout",
|
||||
}
|
||||
|
||||
export default async function Checkout() {
|
||||
@@ -20,7 +20,7 @@ export default async function Checkout() {
|
||||
const customer = await retrieveCustomer()
|
||||
|
||||
return (
|
||||
<div className="content-container grid grid-cols-1 gap-x-16 xl:gap-x-24 py-10 sm:py-14 lg:grid-cols-[1fr_420px]">
|
||||
<div className="grid grid-cols-1 small:grid-cols-[1fr_416px] content-container gap-x-40 py-12">
|
||||
<PaymentWrapper cart={cart}>
|
||||
<CheckoutForm cart={cart} customer={customer} />
|
||||
</PaymentWrapper>
|
||||
|
||||
@@ -1,44 +1,42 @@
|
||||
import LocalizedClientLink from "@modules/common/components/localized-client-link"
|
||||
import { Logo } from "@/components/ui/logo"
|
||||
import { ArrowLeft, Lock } from "lucide-react"
|
||||
import ChevronDown from "@modules/common/icons/chevron-down"
|
||||
import MedusaCTA from "@modules/layout/components/medusa-cta"
|
||||
|
||||
/** Focused checkout shell: back to cart, logo, secure-payment note */
|
||||
export default function CheckoutLayout({
|
||||
children,
|
||||
}: {
|
||||
children: React.ReactNode
|
||||
}) {
|
||||
return (
|
||||
<div className="relative w-full bg-background lg:min-h-screen">
|
||||
<div className="sticky top-0 z-50 border-b border-border/70 bg-background">
|
||||
<nav className="content-container grid h-14 grid-cols-[1fr_auto_1fr] items-center sm:h-16">
|
||||
<div className="w-full bg-white relative small:min-h-screen">
|
||||
<div className="h-16 bg-white border-b ">
|
||||
<nav className="flex h-full items-center content-container justify-between">
|
||||
<LocalizedClientLink
|
||||
href="/cart"
|
||||
className="flex items-center gap-2 justify-self-start text-sm text-muted-foreground transition-colors hover:text-foreground"
|
||||
className="text-small-semi text-ui-fg-base flex items-center gap-x-2 uppercase flex-1 basis-0"
|
||||
data-testid="back-to-cart-link"
|
||||
>
|
||||
<ArrowLeft className="h-4 w-4" />
|
||||
<span className="hidden sm:inline">Nazad u korpu</span>
|
||||
<span className="sm:hidden">Nazad</span>
|
||||
<ChevronDown className="rotate-90" size={16} />
|
||||
<span className="mt-px hidden small:block txt-compact-plus text-ui-fg-subtle hover:text-ui-fg-base ">
|
||||
Back to shopping cart
|
||||
</span>
|
||||
<span className="mt-px block small:hidden txt-compact-plus text-ui-fg-subtle hover:text-ui-fg-base">
|
||||
Back
|
||||
</span>
|
||||
</LocalizedClientLink>
|
||||
<LocalizedClientLink
|
||||
href="/"
|
||||
className="relative w-[56px] self-stretch sm:w-[72px]"
|
||||
className="txt-compact-xlarge-plus text-ui-fg-subtle hover:text-ui-fg-base uppercase"
|
||||
data-testid="store-link"
|
||||
aria-label="Suman d.o.o. početna"
|
||||
>
|
||||
<span className="absolute inset-x-0 top-0 block">
|
||||
<Logo priority alt="" />
|
||||
</span>
|
||||
Medusa Store
|
||||
</LocalizedClientLink>
|
||||
<p className="flex items-center gap-1.5 justify-self-end text-xs text-muted-foreground">
|
||||
<Lock className="h-3.5 w-3.5" />
|
||||
<span className="hidden sm:inline">Sigurno plaćanje</span>
|
||||
</p>
|
||||
<div className="flex-1 basis-0" />
|
||||
</nav>
|
||||
</div>
|
||||
<div className="relative" data-testid="checkout-container">
|
||||
{children}
|
||||
<div className="relative" data-testid="checkout-container">{children}</div>
|
||||
<div className="py-4 w-full flex items-center justify-center">
|
||||
<MedusaCTA />
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -3,14 +3,14 @@ import { Metadata } from "next"
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "404",
|
||||
description: "Stranica nije pronađena.",
|
||||
description: "Something went wrong",
|
||||
}
|
||||
|
||||
export default async function NotFound() {
|
||||
return (
|
||||
<div className="flex flex-col gap-4 items-center justify-center min-h-[calc(100vh-64px)]">
|
||||
<h1 className="font-display text-2xl text-foreground">Page not found</h1>
|
||||
<p className="text-sm text-foreground">
|
||||
<h1 className="text-2xl-semi text-ui-fg-base">Page not found</h1>
|
||||
<p className="text-small-regular text-ui-fg-base">
|
||||
The page you tried to access does not exist.
|
||||
</p>
|
||||
<InteractiveLink href="/">Go to frontpage</InteractiveLink>
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import SectionHeading from "@modules/account/components/section-heading"
|
||||
import { Metadata } from "next"
|
||||
import { notFound } from "next/navigation"
|
||||
|
||||
@@ -9,7 +8,7 @@ import { retrieveCustomer } from "@lib/data/customer"
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "Addresses",
|
||||
description: "Pregled vaših adresa.",
|
||||
description: "View your addresses",
|
||||
}
|
||||
|
||||
export default async function Addresses(props: {
|
||||
@@ -26,10 +25,13 @@ export default async function Addresses(props: {
|
||||
|
||||
return (
|
||||
<div className="w-full" data-testid="addresses-page-wrapper">
|
||||
<SectionHeading
|
||||
title="Adrese za dostavu"
|
||||
description="Sačuvane adrese nude se automatski pri plaćanju, pa naručujete brže."
|
||||
/>
|
||||
<div className="mb-8 flex flex-col gap-y-4">
|
||||
<h1 className="text-2xl-semi">Shipping Addresses</h1>
|
||||
<p className="text-base-regular">
|
||||
View and update your shipping addresses, you can add as many as you
|
||||
like. Saving your addresses will make them available during checkout.
|
||||
</p>
|
||||
</div>
|
||||
<AddressBook customer={customer} region={region} />
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -2,7 +2,7 @@ import Spinner from "@modules/common/icons/spinner"
|
||||
|
||||
export default function Loading() {
|
||||
return (
|
||||
<div className="flex items-center justify-center w-full h-full text-foreground">
|
||||
<div className="flex items-center justify-center w-full h-full text-ui-fg-base">
|
||||
<Spinner size={36} />
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import SectionHeading from "@modules/account/components/section-heading"
|
||||
import { Metadata } from "next"
|
||||
|
||||
import OrderOverview from "@modules/account/components/order-overview"
|
||||
import { notFound } from "next/navigation"
|
||||
import { listOrders } from "@lib/data/orders"
|
||||
import Divider from "@modules/common/components/divider"
|
||||
import TransferRequestForm from "@modules/account/components/transfer-request-form"
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "Narudžbe",
|
||||
description: "Pregled vaših prethodnih narudžbi.",
|
||||
title: "Orders",
|
||||
description: "Overview of your previous orders.",
|
||||
}
|
||||
|
||||
export default async function Orders() {
|
||||
@@ -20,12 +20,16 @@ export default async function Orders() {
|
||||
|
||||
return (
|
||||
<div className="w-full" data-testid="orders-page-wrapper">
|
||||
<SectionHeading
|
||||
title="Narudžbe"
|
||||
description="Pregled vaših narudžbi, statusa i isporuka."
|
||||
/>
|
||||
<div className="mb-8 flex flex-col gap-y-4">
|
||||
<h1 className="text-2xl-semi">Orders</h1>
|
||||
<p className="text-base-regular">
|
||||
View your previous orders and their status. You can also create
|
||||
returns or exchanges for your orders if needed.
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
<OrderOverview orders={orders} />
|
||||
<div className="mt-14 rounded-2xl bg-muted p-6 sm:p-8">
|
||||
<Divider className="mb-8 mt-8" />
|
||||
<TransferRequestForm />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -6,8 +6,8 @@ import { retrieveCustomer } from "@lib/data/customer"
|
||||
import { listOrders } from "@lib/data/orders"
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "Moj račun",
|
||||
description: "Pregled aktivnosti na vašem računu.",
|
||||
title: "Account",
|
||||
description: "Overview of your account activity.",
|
||||
}
|
||||
|
||||
export default async function OverviewTemplate() {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import SectionHeading from "@modules/account/components/section-heading"
|
||||
import { Metadata } from "next"
|
||||
|
||||
import ProfilePhone from "@modules/account//components/profile-phone"
|
||||
@@ -11,7 +10,7 @@ import { retrieveCustomer } from "@lib/data/customer"
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "Profile",
|
||||
description: "Pregled i izmjena vašeg profila.",
|
||||
description: "View and edit your Medusa Store profile.",
|
||||
}
|
||||
|
||||
export default async function Profile() {
|
||||
@@ -24,19 +23,29 @@ export default async function Profile() {
|
||||
|
||||
return (
|
||||
<div className="w-full" data-testid="profile-page-wrapper">
|
||||
<SectionHeading
|
||||
title="Profil"
|
||||
description="Ime, email, telefon i adresa za račun koje koristimo za vaše narudžbe."
|
||||
/>
|
||||
<div className="flex w-full flex-col divide-y divide-border/70 border-y border-border/70">
|
||||
<div className="mb-8 flex flex-col gap-y-4">
|
||||
<h1 className="text-2xl-semi">Profile</h1>
|
||||
<p className="text-base-regular">
|
||||
View and update your profile information, including your name, email,
|
||||
and phone number. You can also update your billing address, or change
|
||||
your password.
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex flex-col gap-y-8 w-full">
|
||||
<ProfileName customer={customer} />
|
||||
<Divider />
|
||||
<ProfileEmail customer={customer} />
|
||||
<Divider />
|
||||
<ProfilePhone customer={customer} />
|
||||
{/* <ProfilePassword customer={customer} /> */}
|
||||
<Divider />
|
||||
{/* <ProfilePassword customer={customer} />
|
||||
<Divider /> */}
|
||||
<ProfileBillingAddress customer={customer} regions={regions} />
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
const Divider = () => {
|
||||
return <div className="w-full h-px bg-gray-200" />
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ import { Metadata } from "next"
|
||||
import LoginTemplate from "@modules/account/templates/login-template"
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "Prijava",
|
||||
description: "Prijavite se na svoj Suman račun.",
|
||||
title: "Sign in",
|
||||
description: "Sign in to your Medusa Store account.",
|
||||
}
|
||||
|
||||
export default function Login() {
|
||||
|
||||
@@ -2,7 +2,7 @@ import Spinner from "@modules/common/icons/spinner"
|
||||
|
||||
export default function Loading() {
|
||||
return (
|
||||
<div className="flex items-center justify-center w-full h-full text-foreground">
|
||||
<div className="flex items-center justify-center w-full h-full text-ui-fg-base">
|
||||
<Spinner size={36} />
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -4,14 +4,14 @@ import InteractiveLink from "@modules/common/components/interactive-link"
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "404",
|
||||
description: "Nešto nije u redu.",
|
||||
description: "Something went wrong",
|
||||
}
|
||||
|
||||
export default function NotFound() {
|
||||
return (
|
||||
<div className="flex flex-col items-center justify-center min-h-[calc(100vh-64px)]">
|
||||
<h1 className="font-display text-2xl text-foreground">Page not found</h1>
|
||||
<p className="text-sm text-foreground">
|
||||
<h1 className="text-2xl-semi text-ui-fg-base">Page not found</h1>
|
||||
<p className="text-small-regular text-ui-fg-base">
|
||||
The cart you tried to access does not exist. Clear your cookies and try
|
||||
again.
|
||||
</p>
|
||||
|
||||
@@ -5,8 +5,8 @@ import { Metadata } from "next"
|
||||
import { notFound } from "next/navigation"
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "Korpa",
|
||||
description: "Pregled vaše korpe.",
|
||||
title: "Cart",
|
||||
description: "View your cart",
|
||||
}
|
||||
|
||||
export default async function Cart() {
|
||||
|
||||
@@ -22,12 +22,12 @@ export async function generateMetadata(props: Props): Promise<Metadata> {
|
||||
try {
|
||||
const productCategory = await getCategoryByHandle(params.category)
|
||||
|
||||
const title = productCategory.name
|
||||
const title = productCategory.name + " | Medusa Store"
|
||||
|
||||
const description = productCategory.description ?? `${title} category.`
|
||||
|
||||
return {
|
||||
title: `${title} | Suman d.o.o.`,
|
||||
title: `${title} | Medusa Store`,
|
||||
description,
|
||||
alternates: {
|
||||
canonical: `${params.category.join("/")}`,
|
||||
|
||||
@@ -26,7 +26,7 @@ export async function generateMetadata(props: Props): Promise<Metadata> {
|
||||
}
|
||||
|
||||
const metadata = {
|
||||
title: `${collection.title} | Suman d.o.o.`,
|
||||
title: `${collection.title} | Medusa Store`,
|
||||
description: `${collection.title} collection`,
|
||||
} as Metadata
|
||||
|
||||
|
||||
@@ -1,79 +1,24 @@
|
||||
import { Metadata } from "next"
|
||||
|
||||
import { STORE_NAME } from "@lib/util/site"
|
||||
import LocalizedClientLink from "@modules/common/components/localized-client-link"
|
||||
import footerConfig from "@/config/footer.json"
|
||||
import { PlaceholderNotice, PolicyPage } from "@modules/policies/templates"
|
||||
|
||||
export const dynamic = "force-static"
|
||||
export const revalidate = 60
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "Kontakt",
|
||||
description: `Kontakt i upiti za ${STORE_NAME}: telefon, email i adresa u Gračanici.`,
|
||||
title: "Contact",
|
||||
description: `How to contact ${STORE_NAME}.`,
|
||||
}
|
||||
|
||||
export default function ContactPage() {
|
||||
const { phone, email, address } = footerConfig.contact
|
||||
const channels = [
|
||||
{ label: "Telefon", value: phone, href: `tel:${phone.replace(/[^\d+]/g, "")}`, note: "Radnim danima" },
|
||||
{ label: "Email", value: email, href: `mailto:${email}`, note: "Odgovor u roku od jednog radnog dana" },
|
||||
{ label: "Proizvodnja i lager", value: address, href: null, note: "Lično preuzimanje narudžbi" },
|
||||
]
|
||||
|
||||
return (
|
||||
<div className="content-container pb-24 sm:pb-32" data-testid="policy-page">
|
||||
<header className="pt-14 sm:pt-20 pb-12 sm:pb-16 text-center">
|
||||
<p className="eyebrow">Kontakt</p>
|
||||
<h1 className="display-heading mt-5 text-4xl sm:text-6xl text-foreground">Razgovarajmo</h1>
|
||||
<p className="mx-auto mt-5 max-w-xl text-sm sm:text-base text-muted-foreground leading-relaxed">
|
||||
Pitanje o narudžbi, dostavi ili opremanju terase? Javite se direktno proizvođaču.
|
||||
<PolicyPage title="Contact">
|
||||
<PlaceholderNotice />
|
||||
<p>
|
||||
Questions about an order, shipping or returns? Contact {STORE_NAME}{" "}
|
||||
customer service and include your order number.
|
||||
</p>
|
||||
</header>
|
||||
|
||||
<div className="grid grid-cols-1 md:grid-cols-3 rounded-2xl border border-border/80 divide-y md:divide-y-0 md:divide-x divide-border/80">
|
||||
{channels.map((c) => (
|
||||
<div key={c.label} className="flex flex-col justify-between gap-10 p-7 sm:p-9">
|
||||
<p className="eyebrow text-muted-foreground">{c.label}</p>
|
||||
<div>
|
||||
{c.href ? (
|
||||
<a href={c.href} className="font-display text-2xl text-foreground transition-colors hover:text-primary">
|
||||
{c.value}
|
||||
</a>
|
||||
) : (
|
||||
<p className="font-display text-2xl text-foreground">{c.value}</p>
|
||||
)}
|
||||
<p className="mt-2 text-sm text-muted-foreground">{c.note}</p>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<section className="mt-16 sm:mt-24 grid grid-cols-1 lg:grid-cols-12 gap-8 border-t border-border/70 pt-12">
|
||||
<p className="lg:col-span-4 eyebrow text-muted-foreground">Upiti za ponudu</p>
|
||||
<div className="lg:col-span-8">
|
||||
<h2 className="display-heading text-3xl sm:text-4xl text-foreground">
|
||||
Pergole i tende izrađujemo po mjeri
|
||||
</h2>
|
||||
<p className="mt-4 max-w-xl text-sm sm:text-base text-muted-foreground leading-relaxed">
|
||||
Na stranici svakog proizvoda možete poslati upit s odabranim opcijama. Naš tim dolazi na mjerenje i
|
||||
priprema preciznu ponudu.
|
||||
</p>
|
||||
<div className="mt-7 flex flex-col sm:flex-row gap-3">
|
||||
<LocalizedClientLink
|
||||
href="/categories/pergole-i-bioklimatske-tende"
|
||||
className="inline-flex h-11 items-center justify-center rounded-md bg-primary px-6 text-sm text-primary-foreground transition-colors hover:bg-primary/90"
|
||||
>
|
||||
Pergole
|
||||
</LocalizedClientLink>
|
||||
<LocalizedClientLink
|
||||
href="/categories/tende"
|
||||
className="inline-flex h-11 items-center justify-center rounded-md border border-border px-6 text-sm text-foreground transition-colors hover:bg-muted"
|
||||
>
|
||||
Tende
|
||||
</LocalizedClientLink>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</PolicyPage>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,34 +1,20 @@
|
||||
import { Metadata } from "next"
|
||||
|
||||
import LocalizedClientLink from "@modules/common/components/localized-client-link"
|
||||
import InteractiveLink from "@modules/common/components/interactive-link"
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "404",
|
||||
description: "Stranica nije pronađena.",
|
||||
description: "Something went wrong",
|
||||
}
|
||||
|
||||
export default function NotFound() {
|
||||
return (
|
||||
<div className="content-container flex min-h-[calc(100vh-64px)] flex-col items-center justify-center py-24 text-center">
|
||||
<p className="eyebrow">Greška 404</p>
|
||||
<h1 className="display-heading mt-5 text-4xl sm:text-6xl text-foreground">Stranica nije pronađena</h1>
|
||||
<p className="mt-5 max-w-md text-sm text-muted-foreground leading-relaxed">
|
||||
Stranica koju tražite ne postoji ili je premještena.
|
||||
<div className="flex flex-col gap-4 items-center justify-center min-h-[calc(100vh-64px)]">
|
||||
<h1 className="text-2xl-semi text-ui-fg-base">Page not found</h1>
|
||||
<p className="text-small-regular text-ui-fg-base">
|
||||
The page you tried to access does not exist.
|
||||
</p>
|
||||
<div className="mt-8 flex flex-col sm:flex-row gap-3">
|
||||
<LocalizedClientLink
|
||||
href="/"
|
||||
className="inline-flex h-11 items-center justify-center rounded-md bg-primary px-6 text-sm text-primary-foreground transition-colors hover:bg-primary/90"
|
||||
>
|
||||
Na početnu
|
||||
</LocalizedClientLink>
|
||||
<LocalizedClientLink
|
||||
href="/store"
|
||||
className="inline-flex h-11 items-center justify-center rounded-md border border-border px-6 text-sm text-foreground transition-colors hover:bg-muted"
|
||||
>
|
||||
Katalog proizvoda
|
||||
</LocalizedClientLink>
|
||||
</div>
|
||||
<InteractiveLink href="/">Go to frontpage</InteractiveLink>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -7,8 +7,8 @@ type Props = {
|
||||
params: Promise<{ id: string }>
|
||||
}
|
||||
export const metadata: Metadata = {
|
||||
title: "Narudžba potvrđena",
|
||||
description: "Vaša narudžba je uspješno zaprimljena.",
|
||||
title: "Order Confirmed",
|
||||
description: "You purchase was successful",
|
||||
}
|
||||
|
||||
export default async function OrderConfirmedPage(props: Props) {
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { Metadata } from "next"
|
||||
|
||||
import LandingHero from "@modules/home/components/landing/hero"
|
||||
import LandingMission from "@modules/home/components/landing/mission"
|
||||
import LandingMethod from "@modules/home/components/landing/method"
|
||||
import LandingProducts from "@modules/home/components/landing/products"
|
||||
import LandingStats from "@modules/home/components/landing/stats"
|
||||
import LandingImpact from "@modules/home/components/landing/impact"
|
||||
import LandingFaq from "@modules/home/components/landing/faq"
|
||||
import Hero from "@modules/home/components/hero"
|
||||
import PartnersTicker from "@modules/home/components/partners-ticker"
|
||||
import ProductShowcase from "@modules/home/components/product-showcase"
|
||||
import MissionSection from "@modules/home/components/mission-section"
|
||||
import CtaBanner from "@modules/home/components/cta-banner"
|
||||
import LatestNews from "@modules/home/components/latest-news"
|
||||
import FaqSection from "@modules/home/components/faq-section"
|
||||
import { listCollections } from "@lib/data/collections"
|
||||
import { getRegion, listRegions } from "@lib/data/regions"
|
||||
import { toJsonLd } from "@lib/util/product-structured-data"
|
||||
@@ -94,13 +94,13 @@ export default async function Home(props: {
|
||||
type="application/ld+json"
|
||||
dangerouslySetInnerHTML={{ __html: toJsonLd(structuredData) }}
|
||||
/>
|
||||
<LandingHero />
|
||||
<LandingMission />
|
||||
<LandingMethod />
|
||||
<LandingProducts />
|
||||
<LandingStats />
|
||||
<LandingImpact />
|
||||
<LandingFaq />
|
||||
<Hero />
|
||||
<PartnersTicker />
|
||||
<ProductShowcase />
|
||||
<MissionSection />
|
||||
<CtaBanner />
|
||||
<LatestNews />
|
||||
<FaqSection />
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -7,22 +7,22 @@ export const dynamic = "force-static"
|
||||
export const revalidate = 60
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "Politika privatnosti",
|
||||
description: `Kako ${STORE_NAME} prikuplja i koristi lične podatke.`,
|
||||
title: "Privacy policy",
|
||||
description: `How ${STORE_NAME} collects and uses personal data.`,
|
||||
}
|
||||
|
||||
export default function PrivacyPage() {
|
||||
return (
|
||||
<PolicyPage title="Politika privatnosti">
|
||||
<PolicyPage title="Privacy policy">
|
||||
<PlaceholderNotice />
|
||||
<p>
|
||||
{STORE_NAME} prikuplja podatke koje unesete prilikom narudžbe, poput
|
||||
imena, email adrese i adrese dostave, kako bi obradio i isporučio vašu
|
||||
narudžbu.
|
||||
{STORE_NAME} collects the information you provide at checkout, such as
|
||||
your name, email address and shipping address, to process and deliver
|
||||
your order.
|
||||
</p>
|
||||
<p>
|
||||
Podatke o plaćanju obrađuje naš procesor plaćanja i trgovina ih ne
|
||||
čuva. Kolačići se koriste za čuvanje korpe i prijave na račun.
|
||||
Payment details are handled by our payment provider and are not stored
|
||||
by the store. Cookies are used to keep your cart and sign-in session.
|
||||
</p>
|
||||
</PolicyPage>
|
||||
)
|
||||
|
||||
@@ -7,8 +7,8 @@ export const dynamic = "force-static"
|
||||
export const revalidate = 60
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "Povrat robe",
|
||||
description: "Kako vratiti proizvod i dobiti povrat novca.",
|
||||
title: "Return policy",
|
||||
description: "How to return items and get a refund.",
|
||||
}
|
||||
|
||||
export default async function ReturnsPage(props: {
|
||||
@@ -18,17 +18,17 @@ export default async function ReturnsPage(props: {
|
||||
const { current } = await getStorePolicies(countryCode)
|
||||
|
||||
return (
|
||||
<PolicyPage title="Povrat robe">
|
||||
<PolicyPage title="Return policy">
|
||||
{current ? (
|
||||
<>
|
||||
<p>
|
||||
Proizvode možete vratiti u roku od {current.returnWindowDays} dana od
|
||||
isporuke. Povrat se šalje poštom.
|
||||
You can return items within {current.returnWindowDays} days of
|
||||
delivery. Items are returned by mail.
|
||||
</p>
|
||||
<p>
|
||||
{current.freeReturns
|
||||
? "Troškove povrata snosimo mi."
|
||||
: "Troškove povrata snosi kupac."}
|
||||
? "Return shipping is free."
|
||||
: "Return shipping costs are paid by the customer."}
|
||||
</p>
|
||||
</>
|
||||
) : (
|
||||
|
||||
@@ -42,22 +42,22 @@ export default async function SearchPage(props: Props) {
|
||||
|
||||
return (
|
||||
<div className="content-container py-6" data-testid="search-container">
|
||||
<h1 className="font-display text-2xl mb-6">
|
||||
<h1 className="text-2xl-semi mb-6">
|
||||
{query ? `Search results for "${query}"` : "Search"}
|
||||
</h1>
|
||||
<SearchForm countryCode={countryCode} defaultValue={query} className="mb-8 max-w-xl" />
|
||||
{query && (
|
||||
<p className="text-sm text-muted-foreground mb-6">
|
||||
<p className="text-small-regular text-ui-fg-subtle mb-6">
|
||||
{response.count} {response.count === 1 ? "product" : "products"} found
|
||||
</p>
|
||||
)}
|
||||
{query && response.products.length === 0 ? (
|
||||
<p className="text-muted-foreground">
|
||||
<p className="text-ui-fg-subtle">
|
||||
No products match your search. Try a different keyword.
|
||||
</p>
|
||||
) : (
|
||||
<ul
|
||||
className="grid grid-cols-2 w-full lg:grid-cols-3 xl:grid-cols-4 gap-x-6 gap-y-8"
|
||||
className="grid grid-cols-2 w-full small:grid-cols-3 medium:grid-cols-4 gap-x-6 gap-y-8"
|
||||
data-testid="search-results"
|
||||
>
|
||||
{response.products.map((product) => (
|
||||
|
||||
@@ -11,8 +11,8 @@ export const dynamic = "force-static"
|
||||
export const revalidate = 60
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "Dostava",
|
||||
description: "Cijene i rokovi dostave.",
|
||||
title: "Shipping information",
|
||||
description: "Shipping rates and delivery times.",
|
||||
}
|
||||
|
||||
export default async function ShippingPage(props: {
|
||||
@@ -22,16 +22,16 @@ export default async function ShippingPage(props: {
|
||||
const { current, currencyCode } = await getStorePolicies(countryCode)
|
||||
|
||||
return (
|
||||
<PolicyPage title="Dostava">
|
||||
<PolicyPage title="Shipping information">
|
||||
{current ? (
|
||||
<>
|
||||
<p>
|
||||
Za narudžbe u {countryCode.toUpperCase()} važe sljedeće cijene i rokovi
|
||||
dostave.
|
||||
Orders to {countryCode.toUpperCase()} ship with the following rates
|
||||
and delivery times.
|
||||
</p>
|
||||
<ShippingSummary policies={current} currencyCode={currencyCode} />
|
||||
<p className="text-muted-foreground">
|
||||
Dostupni načini dostave i konačna cijena prikazuju se u koraku plaćanja.
|
||||
<p className="text-ui-fg-subtle">
|
||||
Available shipping methods and final costs are shown at checkout.
|
||||
</p>
|
||||
</>
|
||||
) : (
|
||||
|
||||
@@ -1,16 +1,12 @@
|
||||
import { Metadata } from "next"
|
||||
import { notFound } from "next/navigation"
|
||||
|
||||
import { listProducts } from "@lib/data/products"
|
||||
import { getRegion } from "@lib/data/regions"
|
||||
import { getSaleInfo, SaleInfo } from "@lib/util/sale-scenario"
|
||||
import CatalogHeader from "@modules/store/components/catalog-header"
|
||||
import StoreTemplate from "@modules/store/templates"
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "Katalog proizvoda",
|
||||
description:
|
||||
"Profesionalni suncobrani, bioklimatske pergole i tende iz vlastite proizvodnje.",
|
||||
title: "Store",
|
||||
description: "Explore all of our products.",
|
||||
}
|
||||
|
||||
export default async function StorePage(props: {
|
||||
@@ -23,29 +19,5 @@ export default async function StorePage(props: {
|
||||
notFound()
|
||||
}
|
||||
|
||||
// Search hits carry no metadata, so resolve each product's sale scenario here
|
||||
const {
|
||||
response: { products },
|
||||
} = await listProducts({
|
||||
countryCode,
|
||||
queryParams: { limit: 100, fields: "handle,+metadata" },
|
||||
})
|
||||
const saleByHandle: Record<string, SaleInfo> = Object.fromEntries(
|
||||
products
|
||||
.filter((p) => p.handle)
|
||||
.map((p) => [p.handle as string, getSaleInfo(p.metadata)])
|
||||
)
|
||||
|
||||
return (
|
||||
<div className="content-container pb-20 sm:pb-28" data-testid="category-container">
|
||||
<CatalogHeader
|
||||
kicker="Katalog"
|
||||
title="Sistemi za zaštitu od sunca"
|
||||
description="Suncobrani koje možete konfigurisati i naručiti online, te pergole i tende po mjeri vašeg prostora."
|
||||
activeHandle={null}
|
||||
titleTestId="store-page-title"
|
||||
/>
|
||||
<StoreTemplate currencyCode={region.currency_code} saleByHandle={saleByHandle} />
|
||||
</div>
|
||||
)
|
||||
return <StoreTemplate currencyCode={region.currency_code} />
|
||||
}
|
||||
|
||||
@@ -7,22 +7,22 @@ export const dynamic = "force-static"
|
||||
export const revalidate = 60
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "Uslovi poslovanja",
|
||||
description: `Uslovi koji važe za kupovinu kod ${STORE_NAME}.`,
|
||||
title: "Terms of service",
|
||||
description: `Terms that apply to purchases from ${STORE_NAME}.`,
|
||||
}
|
||||
|
||||
export default function TermsPage() {
|
||||
return (
|
||||
<PolicyPage title="Uslovi poslovanja">
|
||||
<PolicyPage title="Terms of service">
|
||||
<PlaceholderNotice />
|
||||
<p>
|
||||
Narudžbom kod {STORE_NAME} prihvatate ove uslove. Cijene, dostupnost
|
||||
proizvoda i opcije dostave prikazane su na stranicama proizvoda i u
|
||||
koraku plaćanja, i mogu se mijenjati bez prethodne najave.
|
||||
By placing an order with {STORE_NAME} you agree to these terms. Prices,
|
||||
product availability and shipping options are shown on the product
|
||||
pages and at checkout, and may change without notice.
|
||||
</p>
|
||||
<p>
|
||||
Narudžbe potvrđujemo emailom nakon prijema uplate. Povrat robe i novca
|
||||
rješavamo prema pravilima o povratu.
|
||||
Orders are confirmed by email once payment is received. Returns and
|
||||
refunds are handled according to our return policy.
|
||||
</p>
|
||||
</PolicyPage>
|
||||
)
|
||||
|
||||
@@ -4,8 +4,8 @@ import { Suspense } from "react"
|
||||
import VerifyAccount from "@modules/account/components/verify-account"
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "Potvrda email adrese",
|
||||
description: "Potvrdite email adresu da završite registraciju.",
|
||||
title: "Verify your email",
|
||||
description: "Verify your email address to complete your registration.",
|
||||
}
|
||||
|
||||
export default function VerifyAccountPage() {
|
||||
@@ -13,7 +13,7 @@ export default function VerifyAccountPage() {
|
||||
<div className="w-full flex justify-center px-8 py-12">
|
||||
<Suspense
|
||||
fallback={
|
||||
<p className="text-base text-foreground">
|
||||
<p className="text-base-regular text-ui-fg-base">
|
||||
Verifying your email...
|
||||
</p>
|
||||
}
|
||||
|
||||
@@ -1,30 +1,22 @@
|
||||
import { getBaseURL } from "@lib/util/env"
|
||||
import { Metadata } from "next"
|
||||
import { DM_Sans, Geist } from "next/font/google"
|
||||
import { Plus_Jakarta_Sans } from "next/font/google"
|
||||
import { cn } from "@/lib/utils"
|
||||
import "styles/globals.css"
|
||||
|
||||
// Body text: closest free match to Biograph's Apercu Pro
|
||||
const fontSans = DM_Sans({
|
||||
const fontSans = Plus_Jakarta_Sans({
|
||||
subsets: ["latin", "latin-ext"],
|
||||
variable: "--font-sans",
|
||||
display: "swap",
|
||||
})
|
||||
|
||||
// Headings: closest free match to Biograph's Aeonik
|
||||
const fontDisplay = Geist({
|
||||
subsets: ["latin", "latin-ext"],
|
||||
variable: "--font-display",
|
||||
display: "swap",
|
||||
})
|
||||
|
||||
export const metadata: Metadata = {
|
||||
metadataBase: new URL(getBaseURL()),
|
||||
}
|
||||
|
||||
export default function RootLayout(props: { children: React.ReactNode }) {
|
||||
return (
|
||||
<html lang="bs" data-mode="light" className={cn(fontSans.variable, fontDisplay.variable)}>
|
||||
<html lang="bs" data-mode="light" className={fontSans.variable}>
|
||||
<head>
|
||||
<link rel="ucp" href="/.well-known/ucp" />
|
||||
</head>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { ArrowRight } from "lucide-react"
|
||||
import { Metadata } from "next"
|
||||
import Link from "next/link"
|
||||
import { Button } from "@/components/ui/button"
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "404 - Stranica nije pronađena",
|
||||
@@ -10,19 +11,20 @@ export const metadata: Metadata = {
|
||||
export default function NotFound() {
|
||||
return (
|
||||
<div className="flex flex-col items-center justify-center min-h-[70vh] text-center px-4">
|
||||
<p className="eyebrow">Greška 404</p>
|
||||
<h1 className="display-heading mt-5 text-4xl sm:text-6xl text-foreground">
|
||||
<span className="text-sm font-semibold uppercase tracking-widest text-primary">
|
||||
Greška 404
|
||||
</span>
|
||||
<h1 className="mt-2 text-3xl sm:text-4xl font-extrabold tracking-tight text-foreground">
|
||||
Stranica nije pronađena
|
||||
</h1>
|
||||
<p className="mt-5 text-sm text-muted-foreground max-w-md leading-relaxed">
|
||||
<p className="mt-3 text-sm text-muted-foreground max-w-md">
|
||||
Stranica koju tražite ne postoji ili je premještena. Pregledajte naš asortiman suncobrana i pergola na početnoj stranici.
|
||||
</p>
|
||||
<Link
|
||||
href="/"
|
||||
className="mt-8 inline-flex h-11 items-center gap-2 rounded-md bg-primary px-6 text-sm text-primary-foreground transition-colors hover:bg-primary/90"
|
||||
>
|
||||
Povratak na početnu
|
||||
<Link href="/" className="mt-6">
|
||||
<Button size="lg" className="gap-2">
|
||||
<span>Povratak na početnu</span>
|
||||
<ArrowRight className="h-4 w-4" />
|
||||
</Button>
|
||||
</Link>
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -19,7 +19,7 @@ const DialogOverlay = React.forwardRef<
|
||||
<DialogPrimitive.Overlay
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"fixed inset-0 z-50 bg-black/40 backdrop-blur-[2px] data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
||||
"fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
@@ -42,7 +42,7 @@ const DialogContent = React.forwardRef<
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
<DialogPrimitive.Close className="absolute right-4 top-4 flex h-9 w-9 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none">
|
||||
<DialogPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground">
|
||||
<X className="h-4 w-4" />
|
||||
<span className="sr-only">Close</span>
|
||||
</DialogPrimitive.Close>
|
||||
|
||||
@@ -1,28 +1,32 @@
|
||||
import Image from "next/image"
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
/** Intrinsic size of public/logo-suman.svg (viewBox 0 0 97 100) */
|
||||
export const LOGO_WIDTH = 97
|
||||
export const LOGO_HEIGHT = 100
|
||||
|
||||
export interface LogoProps {
|
||||
className?: string
|
||||
width?: number
|
||||
height?: number
|
||||
priority?: boolean
|
||||
alt?: string
|
||||
}
|
||||
|
||||
/** Suman logo: navy square with the yellow wordmark and bottom strip */
|
||||
export function Logo({ className, priority = false, alt = "Suman d.o.o." }: LogoProps) {
|
||||
export function Logo({
|
||||
className,
|
||||
width = 160,
|
||||
height = 68,
|
||||
priority = true,
|
||||
alt = "Suman d.o.o.",
|
||||
}: LogoProps) {
|
||||
return (
|
||||
<Image
|
||||
src="/logo-suman.svg"
|
||||
src="/logo.png"
|
||||
alt={alt}
|
||||
width={LOGO_WIDTH}
|
||||
height={LOGO_HEIGHT}
|
||||
width={width}
|
||||
height={height}
|
||||
priority={priority}
|
||||
className={cn("h-auto w-full", className)}
|
||||
className={cn("h-9 w-auto object-contain transition-opacity duration-200 group-hover:opacity-90", className)}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
export default Logo
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ const SheetOverlay = React.forwardRef<
|
||||
>(({ className, ...props }, ref) => (
|
||||
<SheetPrimitive.Overlay
|
||||
className={cn(
|
||||
"fixed inset-0 z-50 bg-black/40 backdrop-blur-[2px] data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
||||
"fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
@@ -63,7 +63,7 @@ const SheetContent = React.forwardRef<
|
||||
className={cn(sheetVariants({ side }), className)}
|
||||
{...props}
|
||||
>
|
||||
<SheetPrimitive.Close className="absolute right-4 top-4 flex h-9 w-9 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none">
|
||||
<SheetPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary">
|
||||
<X className="size-4" />
|
||||
<span className="sr-only">Close</span>
|
||||
</SheetPrimitive.Close>
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
{
|
||||
"_readme": "Umbrella configurator. Layers are stacked bottom to top. To switch a layer from the SVG drawing to real photography, add its images under products.<handle>.images.<layerId>.<view>.<key> (or under default.images for all products). Key = selected value (e.g. 'Bordo Crvena'), '<size>|<value>' for a shape-specific image, or '*' for any value. All images of one product must be exported at canvas size with a transparent background. Add-on items get a real price and their own cart line once variantId points to a Medusa variant.",
|
||||
"default": {
|
||||
"canvas": { "width": 1600, "height": 1200 },
|
||||
"views": ["side", "top"],
|
||||
"layers": [
|
||||
{ "id": "shadow", "fallback": "shadow", "views": ["side"] },
|
||||
{ "id": "base", "fallback": "base", "driver": { "addon": "postolje" }, "views": ["side"] },
|
||||
{ "id": "mast", "fallback": "mast", "driver": { "option": "frame" } },
|
||||
{ "id": "canopy", "fallback": "canopy", "driver": { "option": "fabric" } },
|
||||
{ "id": "led", "fallback": "led", "driver": { "addon": "oprema", "item": "led" }, "views": ["side"] },
|
||||
{ "id": "heater", "fallback": "heater", "driver": { "addon": "oprema", "item": "grijac" }, "views": ["side"] }
|
||||
],
|
||||
"images": {},
|
||||
"addons": [
|
||||
{
|
||||
"id": "postolje",
|
||||
"title": "Postolje",
|
||||
"description": "Kako će suncobran stajati na vašoj terasi.",
|
||||
"type": "single",
|
||||
"defaults": ["krizno"],
|
||||
"items": [
|
||||
{
|
||||
"id": "krizno",
|
||||
"label": "Križno postolje s pločama",
|
||||
"description": "Čelični križ za betonske ploče, bez bušenja podloge."
|
||||
},
|
||||
{
|
||||
"id": "mobilno",
|
||||
"label": "Mobilno postolje s utezima",
|
||||
"description": "Lako se premješta, za manje suncobrane.",
|
||||
"incompatibleWith": ["3.5x3.5", "4x4", "4.5x4.5", "5x5", "6x6", "Ø 3.5", "Duo"],
|
||||
"reason": "Prelagano za ovu dimenziju platna"
|
||||
},
|
||||
{
|
||||
"id": "prirubnica",
|
||||
"label": "Ugradna prirubnica",
|
||||
"description": "Trajna ugradnja u betonsku podlogu, najveća stabilnost."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "oprema",
|
||||
"title": "Dodatna oprema",
|
||||
"description": "Odaberite jednu ili više stavki.",
|
||||
"type": "multi",
|
||||
"items": [
|
||||
{
|
||||
"id": "led",
|
||||
"label": "LED rasvjeta",
|
||||
"description": "Integrisana rasvjeta u krakovima, za večernji rad terase."
|
||||
},
|
||||
{
|
||||
"id": "grijac",
|
||||
"label": "Infracrveni grijač",
|
||||
"description": "Montira se na stub, produžava sezonu na terasi."
|
||||
},
|
||||
{
|
||||
"id": "navlaka",
|
||||
"label": "Zaštitna navlaka",
|
||||
"description": "Štiti zatvoreno platno od prašine i vremenskih uslova."
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"products": {
|
||||
"suncobran-beach": {
|
||||
"hideAddons": ["oprema"]
|
||||
},
|
||||
"suncobran-console": {
|
||||
"hideAddons": ["postolje"]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,65 +11,29 @@
|
||||
"brand": {
|
||||
"description": "Vodeći proizvođač profesionalnih ugostiteljskih suncobrana, bioklimatskih pergola i tendi u Bosni i Hercegovini. Tradicija kvaliteta i pouzdanosti.",
|
||||
"socials": [
|
||||
{
|
||||
"name": "instagram",
|
||||
"href": "https://instagram.com"
|
||||
},
|
||||
{
|
||||
"name": "facebook",
|
||||
"href": "https://facebook.com"
|
||||
},
|
||||
{
|
||||
"name": "x",
|
||||
"href": "https://twitter.com"
|
||||
},
|
||||
{
|
||||
"name": "linkedin",
|
||||
"href": "https://linkedin.com"
|
||||
}
|
||||
{ "name": "instagram", "href": "https://instagram.com" },
|
||||
{ "name": "facebook", "href": "https://facebook.com" },
|
||||
{ "name": "x", "href": "https://twitter.com" },
|
||||
{ "name": "linkedin", "href": "https://linkedin.com" }
|
||||
]
|
||||
},
|
||||
"columns": [
|
||||
{
|
||||
"title": "Kompanija",
|
||||
"links": [
|
||||
{
|
||||
"title": "Početna",
|
||||
"href": "/"
|
||||
},
|
||||
{
|
||||
"title": "Svi proizvodi",
|
||||
"href": "/store"
|
||||
},
|
||||
{
|
||||
"title": "Konfigurator suncobrana",
|
||||
"href": "/categories/suncobrani"
|
||||
},
|
||||
{
|
||||
"title": "Kontakt",
|
||||
"href": "/contact"
|
||||
}
|
||||
{ "title": "Početna", "href": "/" },
|
||||
{ "title": "O Nama", "href": "/about" },
|
||||
{ "title": "Proizvodi", "href": "/store" },
|
||||
{ "title": "Reference", "href": "/categories/suncobrani" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "Podrška",
|
||||
"links": [
|
||||
{
|
||||
"title": "Dostava",
|
||||
"href": "/shipping"
|
||||
},
|
||||
{
|
||||
"title": "Povrat robe",
|
||||
"href": "/returns"
|
||||
},
|
||||
{
|
||||
"title": "Uslovi poslovanja",
|
||||
"href": "/terms"
|
||||
},
|
||||
{
|
||||
"title": "B2B saradnja",
|
||||
"href": "/contact"
|
||||
}
|
||||
{ "title": "Naša Priča", "href": "/about" },
|
||||
{ "title": "Dostava i Montaža", "href": "/shipping" },
|
||||
{ "title": "Garancija i Servis", "href": "/terms" },
|
||||
{ "title": "B2B Saradnja", "href": "/contact" }
|
||||
]
|
||||
}
|
||||
],
|
||||
@@ -82,14 +46,8 @@
|
||||
"bottomBar": {
|
||||
"copyright": "Suman d.o.o. Sva prava zadržana.",
|
||||
"links": [
|
||||
{
|
||||
"title": "Uslovi poslovanja",
|
||||
"href": "/terms"
|
||||
},
|
||||
{
|
||||
"title": "Politika privatnosti",
|
||||
"href": "/privacy"
|
||||
}
|
||||
{ "title": "Uvjeti korištenja", "href": "/terms" },
|
||||
{ "title": "Politika privatnosti", "href": "/privacy" }
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,192 +0,0 @@
|
||||
{
|
||||
"hero": {
|
||||
"intervalMs": 7000,
|
||||
"slides": [
|
||||
{
|
||||
"id": "suncobrani",
|
||||
"kicker": "Suncobrani",
|
||||
"title": "Najugodnije mjesto pod suncem",
|
||||
"subtitle": "Profesionalni suncobrani iz vlastite proizvodnje u Gračanici. Odaberite dimenziju, platno i konstrukciju u konfiguratoru i naručite online.",
|
||||
"image": "https://placehold.co/1920x1080/c9ced6/c9ced6",
|
||||
"cta": {
|
||||
"label": "Konfiguriši suncobran",
|
||||
"href": "/categories/suncobrani"
|
||||
},
|
||||
"stats": [
|
||||
{
|
||||
"value": "UPF 50+",
|
||||
"label": "UV zaštita platna"
|
||||
},
|
||||
{
|
||||
"value": "do 6 × 6 m",
|
||||
"label": "Raspon platna"
|
||||
},
|
||||
{
|
||||
"value": "3–5 god.",
|
||||
"label": "Garancija"
|
||||
}
|
||||
],
|
||||
"overlay": 0
|
||||
},
|
||||
{
|
||||
"id": "pergole",
|
||||
"kicker": "Bioklimatske pergole",
|
||||
"title": "Terasa za svako godišnje doba",
|
||||
"subtitle": "Aluminijske pergole s pokretnim lamelama, izrađene po mjeri vašeg prostora i montirane od strane našeg tima.",
|
||||
"image": "/hero/pergole-desktop.webp",
|
||||
"cta": {
|
||||
"label": "Pogledajte pergole",
|
||||
"href": "/categories/pergole-i-bioklimatske-tende"
|
||||
},
|
||||
"stats": [
|
||||
{
|
||||
"value": "150 kg/m²",
|
||||
"label": "Nosivost snijega"
|
||||
},
|
||||
{
|
||||
"value": "do 13 m",
|
||||
"label": "Raspon konstrukcije"
|
||||
},
|
||||
{
|
||||
"value": "5 god.",
|
||||
"label": "Garancija"
|
||||
}
|
||||
],
|
||||
"overlay": 0.35
|
||||
},
|
||||
{
|
||||
"id": "tende",
|
||||
"kicker": "Tende",
|
||||
"title": "Hlad tačno tamo gdje vam treba",
|
||||
"subtitle": "Zglobne, kasetne i kupolaste tende za terase, balkone i izloge, uz mogućnost motorizacije i brendiranja.",
|
||||
"image": "https://placehold.co/1920x1080/d6cfc5/d6cfc5",
|
||||
"cta": {
|
||||
"label": "Pogledajte tende",
|
||||
"href": "/categories/tende"
|
||||
},
|
||||
"stats": [
|
||||
{
|
||||
"value": "0–45°",
|
||||
"label": "Podesiv nagib"
|
||||
},
|
||||
{
|
||||
"value": "do 6 m",
|
||||
"label": "Širina tende"
|
||||
},
|
||||
{
|
||||
"value": "Somfy",
|
||||
"label": "Motorizacija"
|
||||
}
|
||||
],
|
||||
"overlay": 0
|
||||
}
|
||||
]
|
||||
},
|
||||
"mission": {
|
||||
"kicker": "Naša misija",
|
||||
"title": "Uživajte u vanjskom prostoru, bez obzira na vrijeme",
|
||||
"text": "Povezujemo inovaciju, preciznu proizvodnju i vrhunske materijale za dugotrajna rješenja zaštite od sunca. Ne pravimo samo hlad, nego prostor u kojem se gosti zadržavaju duže."
|
||||
},
|
||||
"method": {
|
||||
"kicker": "Kako radimo",
|
||||
"title": "Od ideje do montaže",
|
||||
"text": "Svaki sistem prolazi isti put: vi birate konfiguraciju, mi ga izrađujemo u Gračanici i isporučujemo spremnog za upotrebu.",
|
||||
"cta": {
|
||||
"label": "Saznajte više",
|
||||
"href": "/contact"
|
||||
},
|
||||
"steps": [
|
||||
{
|
||||
"title": "Odaberite i konfigurišite",
|
||||
"text": "Izaberite model suncobrana, dimenzije, platno, boju konstrukcije i postolje. Pregled se mijenja uživo, a cijena se računa odmah.",
|
||||
"image": "https://placehold.co/800x1000/d4d8de/8a919c?text=Konfigurator"
|
||||
},
|
||||
{
|
||||
"title": "Izrada u našoj fabrici",
|
||||
"text": "Konstrukcija od plastificiranog aluminija sa inox spojnim elementima. Tipski suncobrani i tende su spremni za 7 do 15 radnih dana.",
|
||||
"image": "https://placehold.co/800x1000/d4d8de/8a919c?text=Proizvodnja"
|
||||
},
|
||||
{
|
||||
"title": "Isporuka i podrška",
|
||||
"text": "Dostava širom BiH ili lično preuzimanje u Gračanici. Rezervni dijelovi i nova platna su uvijek dostupni na našem lageru.",
|
||||
"image": "https://placehold.co/800x1000/d4d8de/8a919c?text=Isporuka+i+montaza"
|
||||
}
|
||||
]
|
||||
},
|
||||
"products": {
|
||||
"kicker": "Asortiman",
|
||||
"title": "Sistemi za svaki prostor",
|
||||
"featured": {
|
||||
"kicker": "Suman suncobrani",
|
||||
"title": "Konfigurišite i naručite direktno online",
|
||||
"text": "Modeli Prestige, Magnum, Console i Advance u kvadratnom, pravougaonom ili okruglom obliku, sa preko deset dezena akrilnog platna.",
|
||||
"image": "https://placehold.co/1200x1000/e8ebef/8a919c?text=Suncobran",
|
||||
"href": "/categories/suncobrani",
|
||||
"cta": "Pogledajte suncobrane",
|
||||
"stats": [
|
||||
{
|
||||
"value": "4",
|
||||
"label": "Modela"
|
||||
},
|
||||
{
|
||||
"value": "10+",
|
||||
"label": "Dezena platna"
|
||||
},
|
||||
{
|
||||
"value": "4",
|
||||
"label": "Boje konstrukcije"
|
||||
}
|
||||
]
|
||||
},
|
||||
"secondary": [
|
||||
{
|
||||
"kicker": "Bioklimatske pergole",
|
||||
"title": "Pokretne lamele za potpunu kontrolu svjetla",
|
||||
"text": "Izrađuju se po mjeri prostora. Pošaljite upit i naš tim će pripremiti ponudu.",
|
||||
"image": "https://placehold.co/1000x700/e8ebef/8a919c?text=Pergola",
|
||||
"href": "/categories/pergole-i-bioklimatske-tende",
|
||||
"cta": "Pošaljite upit"
|
||||
},
|
||||
{
|
||||
"kicker": "Tende",
|
||||
"title": "Zglobne i kupolaste tende za terase i izloge",
|
||||
"text": "Elegantna zaštita za privatne i ugostiteljske objekte, uz mogućnost brendiranja.",
|
||||
"image": "https://placehold.co/1000x700/e8ebef/8a919c?text=Tenda",
|
||||
"href": "/categories/tende",
|
||||
"cta": "Pošaljite upit"
|
||||
}
|
||||
]
|
||||
},
|
||||
"stats": [
|
||||
{
|
||||
"value": "10.000",
|
||||
"suffix": "+",
|
||||
"text": "Instaliranih suncobrana, pergola i tendi na terasama, u hotelima i baštama širom regije i EU."
|
||||
},
|
||||
{
|
||||
"value": "100",
|
||||
"suffix": "%",
|
||||
"text": "Aluminijska konstrukcija sa nehrđajućim inox spojnim elementima, bez dijelova koji hrđaju."
|
||||
},
|
||||
{
|
||||
"value": "7–15",
|
||||
"suffix": "",
|
||||
"text": "Radnih dana je uobičajen rok isporuke za tipske suncobrane i zglobne tende."
|
||||
}
|
||||
],
|
||||
"impact": {
|
||||
"kicker": "Reference",
|
||||
"title": "Na terasama širom regije",
|
||||
"text": "Od malih kafića do hotelskih kompleksa, Suman sistemi su dio prostora u kojima ljudi provode ljeto.",
|
||||
"image": "https://placehold.co/1920x1100/d4d8de/8a919c?text=Referentni+objekat"
|
||||
},
|
||||
"faq": {
|
||||
"kicker": "Saznajte više",
|
||||
"title": "Često postavljana pitanja",
|
||||
"sideLabel": "01 — Sumanov pristup",
|
||||
"cta": {
|
||||
"label": "Postavite pitanje",
|
||||
"href": "/contact"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,7 @@
|
||||
},
|
||||
{
|
||||
"title": "Pergole",
|
||||
"href": "/categories/pergole-i-bioklimatske-tende"
|
||||
"href": "/categories/pergole"
|
||||
},
|
||||
{
|
||||
"title": "Tende",
|
||||
@@ -42,7 +42,7 @@
|
||||
},
|
||||
{
|
||||
"title": "Pergole",
|
||||
"href": "/categories/pergole-i-bioklimatske-tende"
|
||||
"href": "/categories/pergole"
|
||||
},
|
||||
{
|
||||
"title": "Tende",
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"_readme": "Images for the quote configurator (pergole, tende). Left side shows the image of the step being read; in an option step it shows the image of the selected value. Per product handle: steps.<uvod|postupak|specifikacije|sazetak> = url, options.<option title>.<value> = url. Anything not set falls back to a generated placeholder. Recommended 1600x1200 (4:3), WebP.",
|
||||
"products": {}
|
||||
}
|
||||
@@ -1,169 +0,0 @@
|
||||
import { HttpTypes } from "@medusajs/types"
|
||||
import configuratorData from "@/config/configurator.json"
|
||||
import {
|
||||
AddonGroup,
|
||||
AddonItem,
|
||||
ConfiguratorConfig,
|
||||
ConfiguratorOverride,
|
||||
ConfiguratorView,
|
||||
LayerDef,
|
||||
LayerImages,
|
||||
OptionDriver,
|
||||
} from "./types"
|
||||
|
||||
export * from "./types"
|
||||
|
||||
/** Selected add-on items per group id */
|
||||
export type AddonSelection = Record<string, string[]>
|
||||
|
||||
export type LayerContext = {
|
||||
options: Partial<Record<OptionDriver, string>>
|
||||
addons: AddonSelection
|
||||
}
|
||||
|
||||
const data = configuratorData as unknown as {
|
||||
default: ConfiguratorConfig
|
||||
products: Record<string, ConfiguratorOverride>
|
||||
}
|
||||
|
||||
function parseMetadataOverride(raw: unknown): ConfiguratorOverride | null {
|
||||
if (!raw) return null
|
||||
if (typeof raw === "object") return raw as ConfiguratorOverride
|
||||
if (typeof raw === "string") {
|
||||
try {
|
||||
return JSON.parse(raw) as ConfiguratorOverride
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
function mergeImages(...sources: (LayerImages | undefined)[]): LayerImages {
|
||||
const out: LayerImages = {}
|
||||
for (const src of sources) {
|
||||
if (!src) continue
|
||||
for (const [layerId, views] of Object.entries(src)) {
|
||||
const target = (out[layerId] ??= {})
|
||||
for (const [view, keys] of Object.entries(views ?? {})) {
|
||||
target[view as ConfiguratorView] = {
|
||||
...(target[view as ConfiguratorView] ?? {}),
|
||||
...(keys ?? {}),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
/**
|
||||
* Effective configurator config for a product:
|
||||
* defaults <- products[handle] in configurator.json <- product.metadata.configurator
|
||||
*/
|
||||
export function getConfiguratorConfig(
|
||||
product: HttpTypes.StoreProduct
|
||||
): ConfiguratorConfig {
|
||||
const base = data.default
|
||||
const byHandle = product.handle ? data.products[product.handle] : undefined
|
||||
const fromMetadata = parseMetadataOverride(product.metadata?.configurator)
|
||||
const hidden = new Set([
|
||||
...(byHandle?.hideAddons ?? []),
|
||||
...(fromMetadata?.hideAddons ?? []),
|
||||
])
|
||||
const addons = (fromMetadata?.addons ?? byHandle?.addons ?? base.addons).filter(
|
||||
(g) => !hidden.has(g.id)
|
||||
)
|
||||
|
||||
return {
|
||||
canvas: fromMetadata?.canvas ?? byHandle?.canvas ?? base.canvas,
|
||||
views: fromMetadata?.views ?? byHandle?.views ?? base.views,
|
||||
layers: fromMetadata?.layers ?? byHandle?.layers ?? base.layers,
|
||||
images: mergeImages(base.images, byHandle?.images, fromMetadata?.images),
|
||||
addons,
|
||||
}
|
||||
}
|
||||
|
||||
/** Whether a layer is drawn for the current view and selection */
|
||||
export function isLayerActive(
|
||||
layer: LayerDef,
|
||||
view: ConfiguratorView,
|
||||
ctx: LayerContext,
|
||||
addonGroups: AddonGroup[]
|
||||
) {
|
||||
if (layer.views && !layer.views.includes(view)) return false
|
||||
const driver = layer.driver
|
||||
if (driver && "addon" in driver) {
|
||||
// Layer belongs to an add-on group that this product does not offer
|
||||
if (!addonGroups.some((g) => g.id === driver.addon)) return false
|
||||
if ("item" in driver) return (ctx.addons[driver.addon] ?? []).includes(driver.item)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
/** Value that drives a layer, e.g. the selected fabric or base item */
|
||||
export function getLayerValue(layer: LayerDef, ctx: LayerContext) {
|
||||
const driver = layer.driver
|
||||
if (!driver) return undefined
|
||||
if ("option" in driver) return ctx.options[driver.option]
|
||||
if ("item" in driver) return driver.item
|
||||
return ctx.addons[driver.addon]?.[0]
|
||||
}
|
||||
|
||||
/**
|
||||
* Image for a layer, most specific key first:
|
||||
* "<size>|<value>", "<value>", "<size>|*", "*". Undefined means: draw the SVG.
|
||||
*/
|
||||
export function resolveLayerImage(
|
||||
config: ConfiguratorConfig,
|
||||
layer: LayerDef,
|
||||
view: ConfiguratorView,
|
||||
ctx: LayerContext
|
||||
) {
|
||||
const keys = config.images[layer.id]?.[view]
|
||||
if (!keys) return undefined
|
||||
const value = getLayerValue(layer, ctx)
|
||||
const size = ctx.options.size
|
||||
const candidates = [
|
||||
size && value ? `${size}|${value}` : null,
|
||||
value ?? null,
|
||||
size ? `${size}|*` : null,
|
||||
"*",
|
||||
].filter(Boolean) as string[]
|
||||
for (const key of candidates) {
|
||||
if (keys[key]) return keys[key]
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
|
||||
/** Reason the item cannot be picked with the current options, or null */
|
||||
export function getAddonConflict(item: AddonItem, selectedValues: string[]) {
|
||||
const hit = item.incompatibleWith?.find((needle) =>
|
||||
selectedValues.some((v) => v.toLowerCase().includes(needle.toLowerCase()))
|
||||
)
|
||||
return hit ? item.reason ?? "Nije kompatibilno s odabranom konfiguracijom" : null
|
||||
}
|
||||
|
||||
export function defaultAddonSelection(groups: AddonGroup[]): AddonSelection {
|
||||
return Object.fromEntries(groups.map((g) => [g.id, g.defaults ?? []]))
|
||||
}
|
||||
|
||||
/** "postolje:krizno;oprema:led,grijac" for shareable URLs */
|
||||
export function encodeAddons(selection: AddonSelection) {
|
||||
return Object.entries(selection)
|
||||
.filter(([, items]) => items.length)
|
||||
.map(([group, items]) => `${group}:${items.join(",")}`)
|
||||
.join(";")
|
||||
}
|
||||
|
||||
export function decodeAddons(raw: string | null, groups: AddonGroup[]): AddonSelection | null {
|
||||
if (!raw) return null
|
||||
const out = defaultAddonSelection(groups)
|
||||
for (const part of raw.split(";")) {
|
||||
const [groupId, items] = part.split(":")
|
||||
const group = groups.find((g) => g.id === groupId)
|
||||
if (!group || !items) continue
|
||||
const valid = items.split(",").filter((id) => group.items.some((i) => i.id === id))
|
||||
out[groupId] = group.type === "single" ? valid.slice(0, 1) : valid
|
||||
}
|
||||
return out
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
/**
|
||||
* Umbrella configurator schema.
|
||||
*
|
||||
* The preview is a stack of layers (bottom to top). Each layer is either an
|
||||
* image (transparent PNG/WebP, all drawn on the same canvas size) or, while
|
||||
* no image is set, a built-in SVG drawing. Images can be added per layer, per
|
||||
* view and per selected value without code changes; see `configurator.json`.
|
||||
*/
|
||||
|
||||
export type ConfiguratorView = "side" | "top"
|
||||
|
||||
/** Medusa product option kinds the configurator understands */
|
||||
export type OptionDriver = "size" | "fabric" | "frame"
|
||||
|
||||
export type LayerDriver =
|
||||
/** Image chosen by the selected value of a Medusa option */
|
||||
| { option: OptionDriver }
|
||||
/** Image chosen by the selected item of an add-on group */
|
||||
| { addon: string }
|
||||
/** Layer shown only when this add-on item is selected */
|
||||
| { addon: string; item: string }
|
||||
|
||||
/** Built-in SVG fallback drawn when the layer has no image */
|
||||
export type LayerFallback = "shadow" | "base" | "mast" | "canopy" | "led" | "heater"
|
||||
|
||||
export type LayerDef = {
|
||||
id: string
|
||||
fallback?: LayerFallback
|
||||
driver?: LayerDriver
|
||||
/** Views this layer appears in; defaults to all */
|
||||
views?: ConfiguratorView[]
|
||||
}
|
||||
|
||||
/**
|
||||
* Layer images: layerId -> view -> key -> url.
|
||||
* Key is the selected value that drives the layer (e.g. "Bordo Crvena"),
|
||||
* "<size>|<value>" for a shape-specific image, or "*" for any value.
|
||||
*/
|
||||
export type LayerImages = Partial<
|
||||
Record<string, Partial<Record<ConfiguratorView, Record<string, string>>>>
|
||||
>
|
||||
|
||||
export type AddonItem = {
|
||||
id: string
|
||||
label: string
|
||||
description?: string
|
||||
/** Medusa variant added to the cart as its own line; enables a real price */
|
||||
variantId?: string
|
||||
/**
|
||||
* Substrings of selected option values this item cannot be combined with,
|
||||
* e.g. ["4x4", "5x5"] for a base that is too light for large canopies.
|
||||
*/
|
||||
incompatibleWith?: string[]
|
||||
/** Shown when the item is disabled by `incompatibleWith` */
|
||||
reason?: string
|
||||
}
|
||||
|
||||
export type AddonGroup = {
|
||||
id: string
|
||||
title: string
|
||||
description?: string
|
||||
type: "single" | "multi"
|
||||
/** Preselected item(s) */
|
||||
defaults?: string[]
|
||||
items: AddonItem[]
|
||||
}
|
||||
|
||||
export type ConfiguratorConfig = {
|
||||
/** Pixel size all layer images are exported at */
|
||||
canvas: { width: number; height: number }
|
||||
views: ConfiguratorView[]
|
||||
layers: LayerDef[]
|
||||
images: LayerImages
|
||||
addons: AddonGroup[]
|
||||
}
|
||||
|
||||
/** Partial override per product handle or from product.metadata.configurator */
|
||||
export type ConfiguratorOverride = Partial<Omit<ConfiguratorConfig, "canvas">> & {
|
||||
canvas?: ConfiguratorConfig["canvas"]
|
||||
/** Add-on group ids to hide for this product */
|
||||
hideAddons?: string[]
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
import visualsData from "@/config/product-visuals.json"
|
||||
|
||||
/** Fixed steps of the quote configurator that have their own image */
|
||||
export type VisualStep = "uvod" | "postupak" | "specifikacije" | "sazetak"
|
||||
|
||||
type ProductVisuals = {
|
||||
steps?: Partial<Record<VisualStep, string>>
|
||||
/** option title -> value -> url */
|
||||
options?: Record<string, Record<string, string>>
|
||||
}
|
||||
|
||||
const data = visualsData as unknown as { products: Record<string, ProductVisuals> }
|
||||
|
||||
const STEP_TEXT: Record<VisualStep, string> = {
|
||||
uvod: "",
|
||||
postupak: "Mjerenje i montaža",
|
||||
specifikacije: "Detalji izrade",
|
||||
sazetak: "",
|
||||
}
|
||||
|
||||
function placeholder(text: string, bg = "d4d8de", fg = "6b7280") {
|
||||
const t = encodeURIComponent(text).replace(/%20/g, "+")
|
||||
return `https://placehold.co/1600x1200/${bg}/${fg}?text=${t}`
|
||||
}
|
||||
|
||||
/** Image for a fixed step, or a placeholder named after the step */
|
||||
export function getStepVisual(handle: string | null | undefined, title: string, step: VisualStep) {
|
||||
const custom = handle ? data.products[handle]?.steps?.[step] : undefined
|
||||
return custom ?? placeholder(STEP_TEXT[step] || title)
|
||||
}
|
||||
|
||||
/**
|
||||
* Image for an option value. Colour-like values get a placeholder in that
|
||||
* colour (from `colorHex`), so changing e.g. the fabric visibly swaps it.
|
||||
*/
|
||||
export function getOptionVisual(
|
||||
handle: string | null | undefined,
|
||||
optionTitle: string,
|
||||
value: string,
|
||||
colorHex?: string,
|
||||
isDark?: boolean
|
||||
) {
|
||||
const custom = handle ? data.products[handle]?.options?.[optionTitle]?.[value] : undefined
|
||||
if (custom) return custom
|
||||
if (colorHex?.startsWith("#")) {
|
||||
return placeholder(`${optionTitle}: ${value}`, colorHex.slice(1), isDark ? "ffffff" : "1f2937")
|
||||
}
|
||||
return placeholder(`${optionTitle}: ${value}`)
|
||||
}
|
||||
@@ -118,13 +118,10 @@ export async function addToCart({
|
||||
variantId,
|
||||
quantity,
|
||||
countryCode,
|
||||
metadata,
|
||||
}: {
|
||||
variantId: string
|
||||
quantity: number
|
||||
countryCode: string
|
||||
/** Stored on the line item, e.g. the configurator selection */
|
||||
metadata?: Record<string, unknown>
|
||||
}) {
|
||||
if (!variantId) {
|
||||
throw new Error("Missing variant ID when adding to cart")
|
||||
@@ -146,7 +143,6 @@ export async function addToCart({
|
||||
{
|
||||
variant_id: variantId,
|
||||
quantity,
|
||||
...(metadata ? { metadata } : {}),
|
||||
},
|
||||
{},
|
||||
headers
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
/**
|
||||
* How an option is presented: colour swatches, stacked size/model cards,
|
||||
* or plain choice cards for everything else.
|
||||
*/
|
||||
export type OptionKind = "fabric" | "frame" | "size" | "choice"
|
||||
|
||||
export function getOptionKind(title?: string | null): OptionKind {
|
||||
const t = (title ?? "").toLowerCase()
|
||||
if (/konstrukcij|profil|frame/.test(t)) return "frame"
|
||||
if (/boja|platn|dezen|color/.test(t)) return "fabric"
|
||||
if (/dimenzij|izvedb|raspon|širin|sirin|veličin|velicin|size/.test(t)) return "size"
|
||||
return "choice"
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
/** "1 proizvod", "21 proizvod", "2 proizvoda", "12 proizvoda" */
|
||||
export function productCount(n: number) {
|
||||
return n % 10 === 1 && n % 100 !== 11 ? `${n} proizvod` : `${n} proizvoda`
|
||||
}
|
||||
@@ -1,158 +0,0 @@
|
||||
import { HttpTypes } from "@medusajs/types"
|
||||
|
||||
/**
|
||||
* Sale scenarios set per product in Medusa Admin (product-inquiry widget):
|
||||
* - in_stock: available now, add to cart
|
||||
* - made_to_order: add to cart, delivered after `lead_time_days`
|
||||
* - quote_only: no price or cart, customer sends an inquiry
|
||||
*/
|
||||
export type SaleScenario = "in_stock" | "made_to_order" | "quote_only"
|
||||
|
||||
export type SaleInfo = {
|
||||
scenario: SaleScenario
|
||||
/** Short status, e.g. "Na stanju" */
|
||||
label: string
|
||||
/** One line with delivery detail, e.g. "Isporuka za 14 dana" */
|
||||
detail: string
|
||||
leadTimeDays: number
|
||||
allowCustomization: boolean
|
||||
quoteSubtitle: string
|
||||
/** Tailwind classes for the small status dot */
|
||||
dotClass: string
|
||||
}
|
||||
|
||||
type Metadata = Record<string, unknown> | null | undefined
|
||||
|
||||
export function getSaleInfo(metadata: Metadata): SaleInfo {
|
||||
const raw = metadata?.sale_scenario
|
||||
const scenario: SaleScenario =
|
||||
raw === "quote_only" || raw === "made_to_order" ? raw : "in_stock"
|
||||
const leadTimeDays = Number(metadata?.lead_time_days) || 14
|
||||
const allowCustomization = Boolean(metadata?.allow_customization)
|
||||
const quoteSubtitle =
|
||||
(metadata?.quote_subtitle as string) ||
|
||||
"Izrada po mjeri sa profesionalnom montažom i garancijom"
|
||||
|
||||
if (scenario === "quote_only") {
|
||||
return {
|
||||
scenario,
|
||||
label: "Na upit",
|
||||
detail: "Izrada po mjeri, cijena na upit",
|
||||
leadTimeDays,
|
||||
allowCustomization,
|
||||
quoteSubtitle,
|
||||
dotClass: "bg-primary",
|
||||
}
|
||||
}
|
||||
|
||||
if (scenario === "made_to_order") {
|
||||
return {
|
||||
scenario,
|
||||
label: "Po narudžbi",
|
||||
detail: `Isporuka za ${leadTimeDays} dana`,
|
||||
leadTimeDays,
|
||||
allowCustomization,
|
||||
quoteSubtitle,
|
||||
dotClass: "bg-amber-500",
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
scenario,
|
||||
label: "Na stanju",
|
||||
detail: "Isporuka za 24–48h",
|
||||
leadTimeDays,
|
||||
allowCustomization,
|
||||
quoteSubtitle,
|
||||
dotClass: "bg-emerald-500",
|
||||
}
|
||||
}
|
||||
|
||||
/** Metadata keys that drive behaviour and are not shown as specs */
|
||||
const CONTROL_KEYS = new Set([
|
||||
"sale_scenario",
|
||||
"lead_time_days",
|
||||
"allow_customization",
|
||||
"quote_subtitle",
|
||||
"badge",
|
||||
"custom_template",
|
||||
"hero_image",
|
||||
])
|
||||
|
||||
const SPEC_LABELS: Record<string, string> = {
|
||||
fabric: "Platno",
|
||||
fabric_weight: "Platno",
|
||||
canvas: "Platno",
|
||||
mast_diameter: "Stub",
|
||||
mast_construction: "Stub",
|
||||
ribs_profile: "Krakovi",
|
||||
uv_protection: "UV zaštita",
|
||||
water_column: "Vodeni stub",
|
||||
wind_resistance: "Otpornost na vjetar",
|
||||
wind_vent: "Lufter",
|
||||
warranty_years: "Garancija",
|
||||
opening_mechanism: "Mehanizam otvaranja",
|
||||
rotation: "Rotacija",
|
||||
free_space: "Slobodan prostor",
|
||||
durability: "Izdržljivost",
|
||||
design_system: "Dizajn",
|
||||
special_feature: "Posebnost",
|
||||
origin: "Porijeklo",
|
||||
weight: "Težina",
|
||||
motor: "Motorizacija",
|
||||
profile: "Profil",
|
||||
drainage: "Odvod vode",
|
||||
lamellas: "Lamele",
|
||||
snow_load: "Nosivost snijega",
|
||||
automation: "Automatika",
|
||||
construction: "Konstrukcija",
|
||||
four_seasons: "Cjelogodišnje korištenje",
|
||||
zip_compatible: "Kompatibilnost",
|
||||
arms: "Ruke",
|
||||
tilt_angle: "Nagib",
|
||||
system: "Sistem",
|
||||
insulation: "Izolacija",
|
||||
frame: "Okvir",
|
||||
branding: "Brendiranje",
|
||||
options_available: "Dodatna oprema",
|
||||
}
|
||||
|
||||
function prettifyKey(key: string) {
|
||||
const text = key.replace(/_/g, " ")
|
||||
return text.charAt(0).toUpperCase() + text.slice(1)
|
||||
}
|
||||
|
||||
/** Human-readable spec rows from product metadata */
|
||||
export function getProductSpecs(product: HttpTypes.StoreProduct) {
|
||||
const metadata = (product.metadata ?? {}) as Record<string, unknown>
|
||||
return Object.entries(metadata)
|
||||
.filter(
|
||||
([key, value]) =>
|
||||
!CONTROL_KEYS.has(key) &&
|
||||
(typeof value === "string" || typeof value === "number") &&
|
||||
String(value).trim() !== ""
|
||||
)
|
||||
.map(([key, value]) => ({
|
||||
key,
|
||||
label: SPEC_LABELS[key] ?? prettifyKey(key),
|
||||
value: String(value),
|
||||
}))
|
||||
}
|
||||
|
||||
/**
|
||||
* Full-width hero image. Uses `metadata.hero_image` when set in Medusa Admin,
|
||||
* otherwise a neutral placeholder until real photography is uploaded.
|
||||
*/
|
||||
export function getProductHeroImage(product: HttpTypes.StoreProduct) {
|
||||
const custom = product.metadata?.hero_image
|
||||
if (typeof custom === "string" && custom.trim()) {
|
||||
return custom
|
||||
}
|
||||
return "https://placehold.co/2400x1350/c9ced6/c9ced6"
|
||||
}
|
||||
|
||||
/** Card image for listings, same placeholder logic as the hero */
|
||||
export function getProductCardImage(title?: string | null) {
|
||||
const text = encodeURIComponent(title ?? "Suman").replace(/%20/g, "+")
|
||||
return `https://placehold.co/900x1100/e8ebef/8a919c?text=${text}`
|
||||
}
|
||||
@@ -22,7 +22,7 @@ const AccountInfo = ({
|
||||
isSuccess,
|
||||
isError,
|
||||
clearState,
|
||||
errorMessage = "Došlo je do greške, pokušajte ponovo",
|
||||
errorMessage = "An error occurred, please try again",
|
||||
children,
|
||||
'data-testid': dataTestid
|
||||
}: AccountInfoProps) => {
|
||||
@@ -42,28 +42,28 @@ const AccountInfo = ({
|
||||
}, [isSuccess, close])
|
||||
|
||||
return (
|
||||
<div className="py-6 text-sm" data-testid={dataTestid}>
|
||||
<div className="flex items-center justify-between gap-6">
|
||||
<div className="flex min-w-0 flex-col gap-1.5">
|
||||
<span className="eyebrow text-muted-foreground">{label}</span>
|
||||
<div className="text-base text-foreground">
|
||||
<div className="text-small-regular" data-testid={dataTestid}>
|
||||
<div className="flex items-end justify-between">
|
||||
<div className="flex flex-col">
|
||||
<span className="uppercase text-ui-fg-base">{label}</span>
|
||||
<div className="flex items-center flex-1 basis-0 justify-end gap-x-4">
|
||||
{typeof currentInfo === "string" ? (
|
||||
<span data-testid="current-info">{currentInfo}</span>
|
||||
<span className="font-semibold" data-testid="current-info">{currentInfo}</span>
|
||||
) : (
|
||||
currentInfo
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<div className="shrink-0">
|
||||
<div>
|
||||
<Button
|
||||
variant="secondary"
|
||||
className="h-9 w-[104px]"
|
||||
className="w-[100px] min-h-[25px] py-1"
|
||||
onClick={handleToggle}
|
||||
type={state ? "reset" : "button"}
|
||||
data-testid="edit-button"
|
||||
data-active={state}
|
||||
>
|
||||
{state ? "Odustani" : "Izmijeni"}
|
||||
{state ? "Cancel" : "Edit"}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -82,7 +82,7 @@ const AccountInfo = ({
|
||||
data-testid="success-message"
|
||||
>
|
||||
<Badge className="p-2 my-4" color="green">
|
||||
<span>Sačuvano</span>
|
||||
<span>{label} updated succesfully</span>
|
||||
</Badge>
|
||||
</Disclosure.Panel>
|
||||
</Disclosure>
|
||||
@@ -117,16 +117,16 @@ const AccountInfo = ({
|
||||
}
|
||||
)}
|
||||
>
|
||||
<div className="flex flex-col gap-y-3 pt-5">
|
||||
<div className="flex flex-col gap-y-2 py-4">
|
||||
<div>{children}</div>
|
||||
<div className="mt-2 flex items-center justify-end">
|
||||
<div className="flex items-center justify-end mt-2">
|
||||
<Button
|
||||
isLoading={pending}
|
||||
className="h-11 w-full sm:w-auto sm:px-6"
|
||||
className="w-full small:max-w-[140px]"
|
||||
type="submit"
|
||||
data-testid="save-button"
|
||||
>
|
||||
Sačuvaj izmjene
|
||||
Save changes
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,59 +1,121 @@
|
||||
"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 NAV_LINKS = [
|
||||
{ href: "/account", label: "Pregled" },
|
||||
{ href: "/account/profile", label: "Profil" },
|
||||
{ href: "/account/addresses", label: "Adrese" },
|
||||
{ href: "/account/orders", label: "Narudžbe" },
|
||||
]
|
||||
|
||||
/** Account tabs, same pill style as the catalog category tabs */
|
||||
const AccountNav = ({ customer: _customer }: { customer: HttpTypes.StoreCustomer | null }) => {
|
||||
const AccountNav = ({
|
||||
customer,
|
||||
}: {
|
||||
customer: HttpTypes.StoreCustomer | null
|
||||
}) => {
|
||||
const route = usePathname()
|
||||
const { countryCode } = useParams() as { countryCode: string }
|
||||
|
||||
const isActive = (href: string) => {
|
||||
const full = `/${countryCode}${href}`
|
||||
// Order details live under /account/orders/details/...
|
||||
return href === "/account" ? route === full : route.startsWith(full)
|
||||
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 (
|
||||
<nav aria-label="Moj račun" className="flex justify-center" data-testid="account-nav">
|
||||
<div className="inline-flex max-w-full items-center gap-1 overflow-x-auto rounded-lg bg-muted p-1 text-sm">
|
||||
{NAV_LINKS.map((link) => {
|
||||
const active = isActive(link.href)
|
||||
<div className="w-full">
|
||||
{/* Mobile nav */}
|
||||
<div className="sm:hidden" data-testid="mobile-account-nav">
|
||||
{route !== `/${countryCode}/account` ? (
|
||||
<LocalizedClientLink
|
||||
href="/account"
|
||||
className="flex items-center gap-2 text-sm font-medium py-3 border-b border-border"
|
||||
data-testid="account-main-link"
|
||||
>
|
||||
<ChevronRight className="h-4 w-4 rotate-180 text-muted-foreground" />
|
||||
<span>Nazad na nalog</span>
|
||||
</LocalizedClientLink>
|
||||
) : (
|
||||
<div className="flex flex-col gap-3 py-4">
|
||||
<h2 className="text-xl font-bold tracking-tight text-foreground">
|
||||
Pozdrav, {customer?.first_name || "Korisnik"}
|
||||
</h2>
|
||||
<div className="flex flex-col divide-y divide-border rounded-xl border border-border bg-card">
|
||||
{navLinks.map((link) => {
|
||||
const Icon = link.icon
|
||||
return (
|
||||
<LocalizedClientLink
|
||||
key={link.href}
|
||||
href={link.href}
|
||||
aria-current={active ? "page" : undefined}
|
||||
className={cn(
|
||||
"whitespace-nowrap rounded-md px-4 py-2 transition-colors",
|
||||
active ? "bg-background text-foreground shadow-sm" : "text-muted-foreground hover:text-foreground"
|
||||
)}
|
||||
data-testid={link.href === "/account" ? "account-main-link" : undefined}
|
||||
className="flex items-center justify-between p-4 text-sm font-medium text-foreground hover:bg-accent"
|
||||
>
|
||||
{link.label}
|
||||
<div className="flex items-center gap-3">
|
||||
<Icon className="h-4 w-4 text-muted-foreground" />
|
||||
<span>{link.label}</span>
|
||||
</div>
|
||||
<ChevronRight className="h-4 w-4 text-muted-foreground" />
|
||||
</LocalizedClientLink>
|
||||
)
|
||||
})}
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => signout(countryCode)}
|
||||
className="whitespace-nowrap rounded-md px-4 py-2 text-muted-foreground transition-colors hover:text-destructive"
|
||||
className="flex items-center justify-between p-4 text-sm font-medium text-destructive hover:bg-destructive/10 text-left"
|
||||
onClick={handleLogout}
|
||||
data-testid="logout-button"
|
||||
>
|
||||
Odjava
|
||||
<div className="flex items-center gap-3">
|
||||
<LogOut className="h-4 w-4" />
|
||||
<span>Odjavi se</span>
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Desktop nav */}
|
||||
<div className="hidden sm:block" data-testid="account-nav">
|
||||
<div className="flex flex-col gap-4 rounded-xl border border-border bg-card p-5">
|
||||
<h3 className="text-sm font-semibold uppercase tracking-wider text-muted-foreground px-3">
|
||||
Moj Nalog
|
||||
</h3>
|
||||
<nav className="flex flex-col gap-1">
|
||||
{navLinks.map((link) => {
|
||||
const Icon = link.icon
|
||||
const active = route.endsWith(link.href)
|
||||
return (
|
||||
<LocalizedClientLink
|
||||
key={link.href}
|
||||
href={link.href}
|
||||
className={cn(
|
||||
"flex items-center gap-3 px-3 py-2 rounded-lg text-sm font-medium transition-colors",
|
||||
active
|
||||
? "bg-primary text-primary-foreground shadow-sm"
|
||||
: "text-muted-foreground hover:text-foreground hover:bg-muted"
|
||||
)}
|
||||
>
|
||||
<Icon className="h-4 w-4" />
|
||||
<span>{link.label}</span>
|
||||
</LocalizedClientLink>
|
||||
)
|
||||
})}
|
||||
<button
|
||||
type="button"
|
||||
onClick={handleLogout}
|
||||
className="flex items-center gap-3 px-3 py-2 rounded-lg text-sm font-medium text-destructive hover:bg-destructive/10 transition-colors text-left mt-2 pt-2 border-t border-border"
|
||||
data-testid="logout-button"
|
||||
>
|
||||
<LogOut className="h-4 w-4" />
|
||||
<span>Odjava</span>
|
||||
</button>
|
||||
</nav>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ const AddressBook: React.FC<AddressBookProps> = ({ customer, region }) => {
|
||||
const { addresses } = customer
|
||||
return (
|
||||
<div className="w-full">
|
||||
<div className="grid flex-1 grid-cols-1 gap-4 sm:grid-cols-2">
|
||||
<div className="grid grid-cols-1 lg:grid-cols-2 gap-4 flex-1 mt-4">
|
||||
<AddAddress region={region} addresses={addresses} />
|
||||
{addresses.map((address) => {
|
||||
return (
|
||||
|
||||
@@ -47,31 +47,31 @@ const AddAddress = ({
|
||||
return (
|
||||
<>
|
||||
<button
|
||||
className="group flex h-full min-h-[200px] w-full flex-col justify-between rounded-2xl border border-dashed border-border p-6 text-left transition-colors hover:border-primary hover:bg-muted/50"
|
||||
className="border border-ui-border-base rounded-rounded p-5 min-h-[220px] h-full w-full flex flex-col justify-between"
|
||||
onClick={open}
|
||||
data-testid="add-address-button"
|
||||
>
|
||||
<span className="font-display text-xl text-foreground">Nova adresa</span>
|
||||
<span className="text-base-semi">New address</span>
|
||||
<Plus />
|
||||
</button>
|
||||
|
||||
<Modal isOpen={state} close={close} data-testid="add-address-modal">
|
||||
<Modal.Title>
|
||||
<Heading className="font-display text-2xl font-normal">Nova adresa</Heading>
|
||||
<Heading className="mb-2">Add address</Heading>
|
||||
</Modal.Title>
|
||||
<form action={formAction}>
|
||||
<Modal.Body>
|
||||
<div className="flex flex-col gap-y-2">
|
||||
<div className="grid grid-cols-2 gap-x-2">
|
||||
<Input
|
||||
label="Ime"
|
||||
label="First name"
|
||||
name="first_name"
|
||||
required
|
||||
autoComplete="given-name"
|
||||
data-testid="first-name-input"
|
||||
/>
|
||||
<Input
|
||||
label="Prezime"
|
||||
label="Last name"
|
||||
name="last_name"
|
||||
required
|
||||
autoComplete="family-name"
|
||||
@@ -79,34 +79,34 @@ const AddAddress = ({
|
||||
/>
|
||||
</div>
|
||||
<Input
|
||||
label="Firma"
|
||||
label="Company"
|
||||
name="company"
|
||||
autoComplete="organization"
|
||||
data-testid="company-input"
|
||||
/>
|
||||
<Input
|
||||
label="Adresa"
|
||||
label="Address"
|
||||
name="address_1"
|
||||
required
|
||||
autoComplete="address-line1"
|
||||
data-testid="address-1-input"
|
||||
/>
|
||||
<Input
|
||||
label="Stan, sprat i sl."
|
||||
label="Apartment, suite, etc."
|
||||
name="address_2"
|
||||
autoComplete="address-line2"
|
||||
data-testid="address-2-input"
|
||||
/>
|
||||
<div className="grid grid-cols-[144px_1fr] gap-x-2">
|
||||
<Input
|
||||
label="Poštanski broj"
|
||||
label="Postal code"
|
||||
name="postal_code"
|
||||
required
|
||||
autoComplete="postal-code"
|
||||
data-testid="postal-code-input"
|
||||
/>
|
||||
<Input
|
||||
label="Grad"
|
||||
label="City"
|
||||
name="city"
|
||||
required
|
||||
autoComplete="locality"
|
||||
@@ -114,7 +114,7 @@ const AddAddress = ({
|
||||
/>
|
||||
</div>
|
||||
<Input
|
||||
label="Kanton / entitet"
|
||||
label="Province / State"
|
||||
name="province"
|
||||
autoComplete="address-level1"
|
||||
data-testid="state-input"
|
||||
@@ -127,7 +127,7 @@ const AddAddress = ({
|
||||
data-testid="country-select"
|
||||
/>
|
||||
<Input
|
||||
label="Telefon"
|
||||
label="Phone"
|
||||
name="phone"
|
||||
autoComplete="phone"
|
||||
data-testid="phone-input"
|
||||
@@ -135,7 +135,7 @@ const AddAddress = ({
|
||||
</div>
|
||||
{formState.error && (
|
||||
<div
|
||||
className="text-rose-500 text-sm py-2"
|
||||
className="text-rose-500 text-small-regular py-2"
|
||||
data-testid="address-error"
|
||||
>
|
||||
{formState.error}
|
||||
@@ -151,7 +151,7 @@ const AddAddress = ({
|
||||
className="h-10"
|
||||
data-testid="cancel-button"
|
||||
>
|
||||
Odustani
|
||||
Cancel
|
||||
</Button>
|
||||
<SubmitButton data-testid="save-button">Save</SubmitButton>
|
||||
</div>
|
||||
|
||||
@@ -63,29 +63,29 @@ const EditAddress: React.FC<EditAddressProps> = ({
|
||||
<>
|
||||
<div
|
||||
className={clx(
|
||||
"flex h-full min-h-[200px] w-full flex-col justify-between rounded-2xl border border-border p-6 transition-colors",
|
||||
"border rounded-rounded p-5 min-h-[220px] h-full w-full flex flex-col justify-between transition-colors",
|
||||
{
|
||||
"border-primary": isActive,
|
||||
"border-gray-900": isActive,
|
||||
}
|
||||
)}
|
||||
data-testid="address-container"
|
||||
>
|
||||
<div className="flex flex-col">
|
||||
<Heading
|
||||
className="text-left font-display text-xl font-normal"
|
||||
className="text-left text-base-semi"
|
||||
data-testid="address-name"
|
||||
>
|
||||
{address.first_name} {address.last_name}
|
||||
</Heading>
|
||||
{address.company && (
|
||||
<Text
|
||||
className="text-sm text-foreground"
|
||||
className="txt-compact-small text-ui-fg-base"
|
||||
data-testid="address-company"
|
||||
>
|
||||
{address.company}
|
||||
</Text>
|
||||
)}
|
||||
<Text className="mt-3 flex flex-col text-left text-sm text-muted-foreground">
|
||||
<Text className="flex flex-col text-left text-base-regular mt-2">
|
||||
<span data-testid="address-address">
|
||||
{address.address_1}
|
||||
{address.address_2 && <span>, {address.address_2}</span>}
|
||||
@@ -99,29 +99,29 @@ const EditAddress: React.FC<EditAddressProps> = ({
|
||||
</span>
|
||||
</Text>
|
||||
</div>
|
||||
<div className="mt-6 flex items-center gap-x-5 border-t border-border/70 pt-4">
|
||||
<div className="flex items-center gap-x-4">
|
||||
<button
|
||||
className="flex items-center gap-x-2 text-sm text-foreground transition-colors hover:text-primary"
|
||||
className="text-small-regular text-ui-fg-base flex items-center gap-x-2"
|
||||
onClick={open}
|
||||
data-testid="address-edit-button"
|
||||
>
|
||||
<Edit />
|
||||
Izmijeni
|
||||
Edit
|
||||
</button>
|
||||
<button
|
||||
className="flex items-center gap-x-2 text-sm text-muted-foreground transition-colors hover:text-destructive"
|
||||
className="text-small-regular text-ui-fg-base flex items-center gap-x-2"
|
||||
onClick={removeAddress}
|
||||
data-testid="address-delete-button"
|
||||
>
|
||||
{removing ? <Spinner /> : <Trash />}
|
||||
Ukloni
|
||||
Remove
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Modal isOpen={state} close={close} data-testid="edit-address-modal">
|
||||
<Modal.Title>
|
||||
<Heading className="font-display text-2xl font-normal">Izmjena adrese</Heading>
|
||||
<Heading className="mb-2">Edit address</Heading>
|
||||
</Modal.Title>
|
||||
<form action={formAction}>
|
||||
<input type="hidden" name="addressId" value={address.id} />
|
||||
@@ -129,7 +129,7 @@ const EditAddress: React.FC<EditAddressProps> = ({
|
||||
<div className="grid grid-cols-1 gap-y-2">
|
||||
<div className="grid grid-cols-2 gap-x-2">
|
||||
<Input
|
||||
label="Ime"
|
||||
label="First name"
|
||||
name="first_name"
|
||||
required
|
||||
autoComplete="given-name"
|
||||
@@ -137,7 +137,7 @@ const EditAddress: React.FC<EditAddressProps> = ({
|
||||
data-testid="first-name-input"
|
||||
/>
|
||||
<Input
|
||||
label="Prezime"
|
||||
label="Last name"
|
||||
name="last_name"
|
||||
required
|
||||
autoComplete="family-name"
|
||||
@@ -146,14 +146,14 @@ const EditAddress: React.FC<EditAddressProps> = ({
|
||||
/>
|
||||
</div>
|
||||
<Input
|
||||
label="Firma"
|
||||
label="Company"
|
||||
name="company"
|
||||
autoComplete="organization"
|
||||
defaultValue={address.company || undefined}
|
||||
data-testid="company-input"
|
||||
/>
|
||||
<Input
|
||||
label="Adresa"
|
||||
label="Address"
|
||||
name="address_1"
|
||||
required
|
||||
autoComplete="address-line1"
|
||||
@@ -161,7 +161,7 @@ const EditAddress: React.FC<EditAddressProps> = ({
|
||||
data-testid="address-1-input"
|
||||
/>
|
||||
<Input
|
||||
label="Stan, sprat i sl."
|
||||
label="Apartment, suite, etc."
|
||||
name="address_2"
|
||||
autoComplete="address-line2"
|
||||
defaultValue={address.address_2 || undefined}
|
||||
@@ -169,7 +169,7 @@ const EditAddress: React.FC<EditAddressProps> = ({
|
||||
/>
|
||||
<div className="grid grid-cols-[144px_1fr] gap-x-2">
|
||||
<Input
|
||||
label="Poštanski broj"
|
||||
label="Postal code"
|
||||
name="postal_code"
|
||||
required
|
||||
autoComplete="postal-code"
|
||||
@@ -177,7 +177,7 @@ const EditAddress: React.FC<EditAddressProps> = ({
|
||||
data-testid="postal-code-input"
|
||||
/>
|
||||
<Input
|
||||
label="Grad"
|
||||
label="City"
|
||||
name="city"
|
||||
required
|
||||
autoComplete="locality"
|
||||
@@ -186,7 +186,7 @@ const EditAddress: React.FC<EditAddressProps> = ({
|
||||
/>
|
||||
</div>
|
||||
<Input
|
||||
label="Kanton / entitet"
|
||||
label="Province / State"
|
||||
name="province"
|
||||
autoComplete="address-level1"
|
||||
defaultValue={address.province || undefined}
|
||||
@@ -201,7 +201,7 @@ const EditAddress: React.FC<EditAddressProps> = ({
|
||||
data-testid="country-select"
|
||||
/>
|
||||
<Input
|
||||
label="Telefon"
|
||||
label="Phone"
|
||||
name="phone"
|
||||
autoComplete="phone"
|
||||
defaultValue={address.phone || undefined}
|
||||
@@ -209,7 +209,7 @@ const EditAddress: React.FC<EditAddressProps> = ({
|
||||
/>
|
||||
</div>
|
||||
{formState.error && (
|
||||
<div className="text-rose-500 text-sm py-2">
|
||||
<div className="text-rose-500 text-small-regular py-2">
|
||||
{formState.error}
|
||||
</div>
|
||||
)}
|
||||
@@ -223,7 +223,7 @@ const EditAddress: React.FC<EditAddressProps> = ({
|
||||
className="h-10"
|
||||
data-testid="cancel-button"
|
||||
>
|
||||
Odustani
|
||||
Cancel
|
||||
</Button>
|
||||
<SubmitButton data-testid="save-button">Save</SubmitButton>
|
||||
</div>
|
||||
|
||||
@@ -13,37 +13,36 @@ const Login = ({ setCurrentView }: Props) => {
|
||||
const [message, formAction] = useActionState(login, null)
|
||||
|
||||
return (
|
||||
<div className="flex w-full max-w-sm flex-col" data-testid="login-page">
|
||||
<header className="text-center">
|
||||
<p className="eyebrow">Moj račun</p>
|
||||
<h1 className="display-heading mt-5 text-4xl sm:text-5xl text-foreground">Prijava</h1>
|
||||
<p className="mt-4 text-sm text-muted-foreground">
|
||||
Pratite narudžbe, sačuvajte adrese i naručujte brže.
|
||||
<div
|
||||
className="max-w-sm w-full flex flex-col items-center"
|
||||
data-testid="login-page"
|
||||
>
|
||||
<h1 className="text-large-semi uppercase mb-6">Welcome back</h1>
|
||||
<p className="text-center text-base-regular text-ui-fg-base mb-8">
|
||||
Sign in to access an enhanced shopping experience.
|
||||
</p>
|
||||
</header>
|
||||
|
||||
{message?.state === "verification_required" && (
|
||||
<div
|
||||
className="mt-8 rounded-lg bg-muted p-4 text-center text-sm text-foreground"
|
||||
className="w-full mb-6 text-center text-base-regular text-ui-fg-base bg-ui-bg-subtle border border-ui-border-base rounded-rounded p-4"
|
||||
data-testid="login-verification-message"
|
||||
>
|
||||
Poslali smo link za potvrdu na <strong>{message.email}</strong>. Potvrdite email, pa se prijavite.
|
||||
We sent a verification link to <strong>{message.email}</strong>.
|
||||
Please verify your email, then sign in.
|
||||
</div>
|
||||
)}
|
||||
|
||||
<form className="mt-10 w-full" action={formAction}>
|
||||
<div className="flex w-full flex-col gap-y-3">
|
||||
<form className="w-full" action={formAction}>
|
||||
<div className="flex flex-col w-full gap-y-2">
|
||||
<Input
|
||||
label="Email"
|
||||
name="email"
|
||||
type="email"
|
||||
title="Unesite ispravnu email adresu."
|
||||
title="Enter a valid email address."
|
||||
autoComplete="email"
|
||||
required
|
||||
data-testid="email-input"
|
||||
/>
|
||||
<Input
|
||||
label="Lozinka"
|
||||
label="Password"
|
||||
name="password"
|
||||
type="password"
|
||||
autoComplete="current-password"
|
||||
@@ -55,21 +54,21 @@ const Login = ({ setCurrentView }: Props) => {
|
||||
error={message?.state === "error" ? message.error : null}
|
||||
data-testid="login-error-message"
|
||||
/>
|
||||
<SubmitButton data-testid="sign-in-button" className="mt-6 h-12 w-full">
|
||||
Prijava
|
||||
<SubmitButton data-testid="sign-in-button" className="w-full mt-6">
|
||||
Sign in
|
||||
</SubmitButton>
|
||||
</form>
|
||||
|
||||
<p className="mt-8 border-t border-border/70 pt-6 text-center text-sm text-muted-foreground">
|
||||
Nemate račun?{" "}
|
||||
<span className="text-center text-ui-fg-base text-small-regular mt-6">
|
||||
Not a member?{" "}
|
||||
<button
|
||||
onClick={() => setCurrentView(LOGIN_VIEW.REGISTER)}
|
||||
className="text-primary underline underline-offset-4 hover:opacity-80"
|
||||
className="underline"
|
||||
data-testid="register-button"
|
||||
>
|
||||
Registrujte se
|
||||
Join us
|
||||
</button>
|
||||
</p>
|
||||
.
|
||||
</span>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,72 +1,86 @@
|
||||
import Image from "next/image"
|
||||
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 { getProductCardImage } from "@lib/util/sale-scenario"
|
||||
import { HttpTypes } from "@medusajs/types"
|
||||
import { ArrowRight } from "lucide-react"
|
||||
|
||||
type OrderCardProps = {
|
||||
order: HttpTypes.StoreOrder
|
||||
}
|
||||
|
||||
const OrderCard = ({ order }: OrderCardProps) => {
|
||||
const itemCount = useMemo(
|
||||
() => order.items?.reduce((acc, item) => acc + item.quantity, 0) ?? 0,
|
||||
[order]
|
||||
const numberOfLines = useMemo(() => {
|
||||
return (
|
||||
order.items?.reduce((acc, item) => {
|
||||
return acc + item.quantity
|
||||
}, 0) ?? 0
|
||||
)
|
||||
const extra = (order.items?.length ?? 0) - 4
|
||||
}, [order])
|
||||
|
||||
const numberOfProducts = useMemo(() => {
|
||||
return order.items?.length ?? 0
|
||||
}, [order])
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-5" data-testid="order-card">
|
||||
<div className="flex flex-wrap items-baseline justify-between gap-3">
|
||||
<p className="font-display text-2xl text-foreground">
|
||||
<div className="bg-white flex flex-col" data-testid="order-card">
|
||||
<div className="uppercase text-large-semi mb-1">
|
||||
#<span data-testid="order-display-id">{order.display_id}</span>
|
||||
</p>
|
||||
<p className="flex items-center gap-3 text-sm text-muted-foreground">
|
||||
<span data-testid="order-created-at">
|
||||
{new Date(order.created_at).toLocaleDateString("bs-BA", {
|
||||
day: "numeric",
|
||||
month: "long",
|
||||
year: "numeric",
|
||||
</div>
|
||||
<div className="flex items-center divide-x divide-gray-200 text-small-regular text-ui-fg-base">
|
||||
<span className="pr-2" data-testid="order-created-at">
|
||||
{new Date(order.created_at).toDateString()}
|
||||
</span>
|
||||
<span className="px-2" data-testid="order-amount">
|
||||
{convertToLocale({
|
||||
amount: order.total,
|
||||
currency_code: order.currency_code,
|
||||
})}
|
||||
</span>
|
||||
<span aria-hidden="true">·</span>
|
||||
<span>{itemCount % 10 === 1 && itemCount % 100 !== 11 ? `${itemCount} artikal` : `${itemCount} artikala`}</span>
|
||||
<span aria-hidden="true">·</span>
|
||||
<span className="text-foreground tabular-nums" data-testid="order-amount">
|
||||
{convertToLocale({ amount: order.total, currency_code: order.currency_code })}
|
||||
</span>
|
||||
</p>
|
||||
<span className="pl-2">{`${numberOfLines} ${
|
||||
numberOfLines > 1 ? "items" : "item"
|
||||
}`}</span>
|
||||
</div>
|
||||
|
||||
<ul className="grid grid-cols-4 gap-3">
|
||||
{order.items?.slice(0, 4).map((i) => (
|
||||
<li key={i.id} data-testid="order-item">
|
||||
<div className="relative aspect-[4/5] overflow-hidden rounded-lg bg-muted">
|
||||
<Image src={getProductCardImage(i.product_title ?? i.title)} alt="" fill sizes="160px" className="object-cover" />
|
||||
</div>
|
||||
<p className="mt-2 truncate text-xs text-foreground" data-testid="item-title">
|
||||
{i.product_title ?? i.title}
|
||||
</p>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
× <span data-testid="item-quantity">{i.quantity}</span>
|
||||
</p>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
{extra > 0 && <p className="-mt-2 text-xs text-muted-foreground">+ još {extra}</p>}
|
||||
|
||||
<LocalizedClientLink
|
||||
href={`/account/orders/details/${order.id}`}
|
||||
className="group inline-flex items-center gap-2 self-start text-sm text-primary"
|
||||
data-testid="order-details-link"
|
||||
<div className="grid grid-cols-2 small:grid-cols-4 gap-4 my-4">
|
||||
{order.items?.slice(0, 3).map((i) => {
|
||||
return (
|
||||
<div
|
||||
key={i.id}
|
||||
className="flex flex-col gap-y-2"
|
||||
data-testid="order-item"
|
||||
>
|
||||
Pogledaj detalje
|
||||
<ArrowRight className="h-4 w-4 transition-transform group-hover:translate-x-0.5" />
|
||||
<Thumbnail thumbnail={i.thumbnail} images={[]} size="full" />
|
||||
<div className="flex items-center text-small-regular text-ui-fg-base">
|
||||
<span
|
||||
className="text-ui-fg-base font-semibold"
|
||||
data-testid="item-title"
|
||||
>
|
||||
{i.title}
|
||||
</span>
|
||||
<span className="ml-2">x</span>
|
||||
<span data-testid="item-quantity">{i.quantity}</span>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
{numberOfProducts > 4 && (
|
||||
<div className="w-full h-full flex flex-col items-center justify-center">
|
||||
<span className="text-small-regular text-ui-fg-base">
|
||||
+ {numberOfLines - 4}
|
||||
</span>
|
||||
<span className="text-small-regular text-ui-fg-base">more</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="flex justify-end">
|
||||
<LocalizedClientLink href={`/account/orders/details/${order.id}`}>
|
||||
<Button data-testid="order-details-link" variant="secondary">
|
||||
See details
|
||||
</Button>
|
||||
</LocalizedClientLink>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -9,29 +9,32 @@ import { HttpTypes } from "@medusajs/types"
|
||||
const OrderOverview = ({ orders }: { orders: HttpTypes.StoreOrder[] }) => {
|
||||
if (orders?.length) {
|
||||
return (
|
||||
<ul className="w-full divide-y divide-border/70 border-y border-border/70">
|
||||
<div className="flex flex-col gap-y-8 w-full">
|
||||
{orders.map((o) => (
|
||||
<li key={o.id} className="py-8">
|
||||
<div
|
||||
key={o.id}
|
||||
className="border-b border-gray-200 pb-6 last:pb-0 last:border-none"
|
||||
>
|
||||
<OrderCard order={o} />
|
||||
</li>
|
||||
</div>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
className="w-full flex flex-col items-center gap-y-3 rounded-2xl bg-muted px-6 py-14 text-center"
|
||||
className="w-full flex flex-col items-center gap-y-4"
|
||||
data-testid="no-orders-container"
|
||||
>
|
||||
<h2 className="font-display text-2xl text-foreground">Još nemate narudžbi</h2>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Kad naručite, ovdje ćete pratiti status i isporuku.
|
||||
<h2 className="text-large-semi">Nothing to see here</h2>
|
||||
<p className="text-base-regular">
|
||||
You don't have any orders yet, let us change that {":)"}
|
||||
</p>
|
||||
<div className="mt-4">
|
||||
<LocalizedClientLink href="/store" passHref>
|
||||
<Button data-testid="continue-shopping-button" className="h-11 px-6">
|
||||
Nastavite kupovinu
|
||||
<LocalizedClientLink href="/" passHref>
|
||||
<Button data-testid="continue-shopping-button">
|
||||
Continue shopping
|
||||
</Button>
|
||||
</LocalizedClientLink>
|
||||
</div>
|
||||
|
||||
@@ -1,96 +1,167 @@
|
||||
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"
|
||||
import { ArrowRight } from "lucide-react"
|
||||
|
||||
type OverviewProps = {
|
||||
customer: HttpTypes.StoreCustomer | null
|
||||
orders: HttpTypes.StoreOrder[] | null
|
||||
}
|
||||
|
||||
const formatDate = (value: string | Date) =>
|
||||
new Date(value).toLocaleDateString("bs-BA", { day: "numeric", month: "long", year: "numeric" })
|
||||
|
||||
const Overview = ({ customer, orders }: OverviewProps) => {
|
||||
const stats = [
|
||||
{ value: `${getProfileCompletion(customer)}%`, label: "Profil popunjen", href: "/account/profile", testId: "customer-profile-completion" },
|
||||
{ value: String(customer?.addresses?.length ?? 0), label: "Sačuvane adrese", href: "/account/addresses", testId: "addresses-count" },
|
||||
{ value: String(orders?.length ?? 0), label: "Narudžbe", href: "/account/orders", testId: "orders-count" },
|
||||
]
|
||||
|
||||
return (
|
||||
<div data-testid="overview-page-wrapper">
|
||||
<span className="sr-only" data-testid="welcome-message" data-value={customer?.first_name}>
|
||||
Pozdrav {customer?.first_name}
|
||||
<div className="hidden small:block">
|
||||
<div className="text-xl-semi flex justify-between items-center mb-4">
|
||||
<span data-testid="welcome-message" data-value={customer?.first_name}>
|
||||
Hello {customer?.first_name}
|
||||
</span>
|
||||
<span className="sr-only" data-testid="customer-email" data-value={customer?.email}>
|
||||
<span className="text-small-regular text-ui-fg-base">
|
||||
Signed in as:{" "}
|
||||
<span
|
||||
className="font-semibold"
|
||||
data-testid="customer-email"
|
||||
data-value={customer?.email}
|
||||
>
|
||||
{customer?.email}
|
||||
</span>
|
||||
|
||||
<div className="grid grid-cols-1 sm:grid-cols-3 rounded-2xl border border-border/80 divide-y sm:divide-y-0 sm:divide-x divide-border/80">
|
||||
{stats.map((s) => (
|
||||
<LocalizedClientLink key={s.label} href={s.href} className="group flex flex-col justify-between gap-10 p-6 transition-colors hover:bg-muted/60">
|
||||
<p className="font-display text-5xl text-primary" data-testid={s.testId} data-value={s.value}>
|
||||
{s.value}
|
||||
</p>
|
||||
<p className="flex items-center justify-between text-sm text-muted-foreground">
|
||||
{s.label}
|
||||
<ArrowRight className="h-4 w-4 transition-transform group-hover:translate-x-0.5" />
|
||||
</p>
|
||||
</LocalizedClientLink>
|
||||
))}
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex flex-col py-8 border-t border-gray-200">
|
||||
<div className="flex flex-col gap-y-4 h-full col-span-1 row-span-2 flex-1">
|
||||
<div className="flex items-start gap-x-16 mb-6">
|
||||
<div className="flex flex-col gap-y-4">
|
||||
<h3 className="text-large-semi">Profile</h3>
|
||||
<div className="flex items-end gap-x-2">
|
||||
<span
|
||||
className="text-3xl-semi leading-none"
|
||||
data-testid="customer-profile-completion"
|
||||
data-value={getProfileCompletion(customer)}
|
||||
>
|
||||
{getProfileCompletion(customer)}%
|
||||
</span>
|
||||
<span className="uppercase text-base-regular text-ui-fg-subtle">
|
||||
Completed
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<section className="mt-14">
|
||||
<div className="mb-5 flex items-baseline justify-between">
|
||||
<h3 className="font-display text-2xl text-foreground">Nedavne narudžbe</h3>
|
||||
<LocalizedClientLink href="/account/orders" className="text-sm text-primary underline-offset-4 hover:underline">
|
||||
Sve narudžbe
|
||||
</LocalizedClientLink>
|
||||
<div className="flex flex-col gap-y-4">
|
||||
<h3 className="text-large-semi">Addresses</h3>
|
||||
<div className="flex items-end gap-x-2">
|
||||
<span
|
||||
className="text-3xl-semi leading-none"
|
||||
data-testid="addresses-count"
|
||||
data-value={customer?.addresses?.length || 0}
|
||||
>
|
||||
{customer?.addresses?.length || 0}
|
||||
</span>
|
||||
<span className="uppercase text-base-regular text-ui-fg-subtle">
|
||||
Saved
|
||||
</span>
|
||||
</div>
|
||||
<ul className="divide-y divide-border/70 border-y border-border/70" data-testid="orders-wrapper">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex flex-col gap-y-4">
|
||||
<div className="flex items-center gap-x-2">
|
||||
<h3 className="text-large-semi">Recent orders</h3>
|
||||
</div>
|
||||
<ul
|
||||
className="flex flex-col gap-y-4"
|
||||
data-testid="orders-wrapper"
|
||||
>
|
||||
{orders && orders.length > 0 ? (
|
||||
orders.slice(0, 5).map((order) => (
|
||||
<li key={order.id} data-testid="order-wrapper" data-value={order.id}>
|
||||
orders.slice(0, 5).map((order) => {
|
||||
return (
|
||||
<li
|
||||
key={order.id}
|
||||
data-testid="order-wrapper"
|
||||
data-value={order.id}
|
||||
>
|
||||
<LocalizedClientLink
|
||||
href={`/account/orders/details/${order.id}`}
|
||||
className="group grid grid-cols-[1fr_auto] items-center gap-4 py-4 sm:grid-cols-[120px_1fr_auto_auto]"
|
||||
data-testid="open-order-button"
|
||||
>
|
||||
<span className="text-sm text-foreground" data-testid="order-id" data-value={order.display_id}>
|
||||
<Container className="bg-gray-50 flex justify-between items-center p-4">
|
||||
<div className="grid grid-cols-3 grid-rows-2 text-small-regular gap-x-4 flex-1">
|
||||
<span className="font-semibold">Date placed</span>
|
||||
<span className="font-semibold">
|
||||
Order number
|
||||
</span>
|
||||
<span className="font-semibold">
|
||||
Total amount
|
||||
</span>
|
||||
<span data-testid="order-created-date">
|
||||
{new Date(order.created_at).toDateString()}
|
||||
</span>
|
||||
<span
|
||||
data-testid="order-id"
|
||||
data-value={order.display_id}
|
||||
>
|
||||
#{order.display_id}
|
||||
</span>
|
||||
<span className="hidden text-sm text-muted-foreground sm:block" data-testid="order-created-date">
|
||||
{formatDate(order.created_at)}
|
||||
<span data-testid="order-amount">
|
||||
{convertToLocale({
|
||||
amount: order.total,
|
||||
currency_code: order.currency_code,
|
||||
})}
|
||||
</span>
|
||||
<span className="text-sm text-foreground tabular-nums" data-testid="order-amount">
|
||||
{convertToLocale({ amount: order.total, currency_code: order.currency_code })}
|
||||
</div>
|
||||
<button
|
||||
className="flex items-center justify-between"
|
||||
data-testid="open-order-button"
|
||||
>
|
||||
<span className="sr-only">
|
||||
Go to order #{order.display_id}
|
||||
</span>
|
||||
<ArrowRight className="hidden h-4 w-4 text-muted-foreground transition-transform group-hover:translate-x-0.5 sm:block" />
|
||||
<ChevronDown className="-rotate-90" />
|
||||
</button>
|
||||
</Container>
|
||||
</LocalizedClientLink>
|
||||
</li>
|
||||
))
|
||||
)
|
||||
})
|
||||
) : (
|
||||
<li className="py-10 text-center text-sm text-muted-foreground" data-testid="no-orders-message">
|
||||
Još nemate narudžbi.{" "}
|
||||
<LocalizedClientLink href="/store" className="text-primary underline underline-offset-4">
|
||||
Pogledajte katalog
|
||||
</LocalizedClientLink>
|
||||
</li>
|
||||
<span data-testid="no-orders-message">No recent orders</span>
|
||||
)}
|
||||
</ul>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
const getProfileCompletion = (customer: HttpTypes.StoreCustomer | null) => {
|
||||
if (!customer) return 0
|
||||
let count = 0
|
||||
if (customer.email) count++
|
||||
if (customer.first_name && customer.last_name) count++
|
||||
if (customer.phone) count++
|
||||
if (customer.addresses?.find((addr) => addr.is_default_billing)) count++
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ const ProfileBillingAddress: React.FC<MyInformationProps> = ({
|
||||
|
||||
const currentInfo = useMemo(() => {
|
||||
if (!billingAddress) {
|
||||
return "Nema adrese za račun"
|
||||
return "No billing address"
|
||||
}
|
||||
|
||||
const country =
|
||||
@@ -93,7 +93,7 @@ const ProfileBillingAddress: React.FC<MyInformationProps> = ({
|
||||
<form action={formAction} onReset={() => clearState()} className="w-full">
|
||||
<input type="hidden" name="addressId" value={billingAddress?.id} />
|
||||
<AccountInfo
|
||||
label="Adresa za račun"
|
||||
label="Billing address"
|
||||
currentInfo={currentInfo}
|
||||
isSuccess={successState}
|
||||
isError={!!state.error}
|
||||
@@ -103,14 +103,14 @@ const ProfileBillingAddress: React.FC<MyInformationProps> = ({
|
||||
<div className="grid grid-cols-1 gap-y-2">
|
||||
<div className="grid grid-cols-2 gap-x-2">
|
||||
<Input
|
||||
label="Ime"
|
||||
label="First name"
|
||||
name="first_name"
|
||||
defaultValue={billingAddress?.first_name || undefined}
|
||||
required
|
||||
data-testid="billing-first-name-input"
|
||||
/>
|
||||
<Input
|
||||
label="Prezime"
|
||||
label="Last name"
|
||||
name="last_name"
|
||||
defaultValue={billingAddress?.last_name || undefined}
|
||||
required
|
||||
@@ -118,13 +118,13 @@ const ProfileBillingAddress: React.FC<MyInformationProps> = ({
|
||||
/>
|
||||
</div>
|
||||
<Input
|
||||
label="Firma"
|
||||
label="Company"
|
||||
name="company"
|
||||
defaultValue={billingAddress?.company || undefined}
|
||||
data-testid="billing-company-input"
|
||||
/>
|
||||
<Input
|
||||
label="Telefon"
|
||||
label="Phone"
|
||||
name="phone"
|
||||
type="phone"
|
||||
autoComplete="phone"
|
||||
@@ -133,28 +133,28 @@ const ProfileBillingAddress: React.FC<MyInformationProps> = ({
|
||||
data-testid="billing-phone-input"
|
||||
/>
|
||||
<Input
|
||||
label="Adresa"
|
||||
label="Address"
|
||||
name="address_1"
|
||||
defaultValue={billingAddress?.address_1 || undefined}
|
||||
required
|
||||
data-testid="billing-address-1-input"
|
||||
/>
|
||||
<Input
|
||||
label="Stan, sprat i sl."
|
||||
label="Apartment, suite, etc."
|
||||
name="address_2"
|
||||
defaultValue={billingAddress?.address_2 || undefined}
|
||||
data-testid="billing-address-2-input"
|
||||
/>
|
||||
<div className="grid grid-cols-[144px_1fr] gap-x-2">
|
||||
<Input
|
||||
label="Poštanski broj"
|
||||
label="Postal code"
|
||||
name="postal_code"
|
||||
defaultValue={billingAddress?.postal_code || undefined}
|
||||
required
|
||||
data-testid="billing-postcal-code-input"
|
||||
/>
|
||||
<Input
|
||||
label="Grad"
|
||||
label="City"
|
||||
name="city"
|
||||
defaultValue={billingAddress?.city || undefined}
|
||||
required
|
||||
@@ -162,7 +162,7 @@ const ProfileBillingAddress: React.FC<MyInformationProps> = ({
|
||||
/>
|
||||
</div>
|
||||
<Input
|
||||
label="Kanton"
|
||||
label="Province"
|
||||
name="province"
|
||||
defaultValue={billingAddress?.province || undefined}
|
||||
data-testid="billing-province-input"
|
||||
|
||||
@@ -48,7 +48,7 @@ const ProfileName: React.FC<MyInformationProps> = ({ customer }) => {
|
||||
return (
|
||||
<form action={formAction} className="w-full overflow-visible">
|
||||
<AccountInfo
|
||||
label="Ime i prezime"
|
||||
label="Name"
|
||||
currentInfo={`${customer.first_name} ${customer.last_name}`}
|
||||
isSuccess={successState}
|
||||
isError={!!state?.error}
|
||||
@@ -57,14 +57,14 @@ const ProfileName: React.FC<MyInformationProps> = ({ customer }) => {
|
||||
>
|
||||
<div className="grid grid-cols-2 gap-x-4">
|
||||
<Input
|
||||
label="Ime"
|
||||
label="First name"
|
||||
name="first_name"
|
||||
required
|
||||
defaultValue={customer.first_name ?? ""}
|
||||
data-testid="first-name-input"
|
||||
/>
|
||||
<Input
|
||||
label="Prezime"
|
||||
label="Last name"
|
||||
name="last_name"
|
||||
required
|
||||
defaultValue={customer.last_name ?? ""}
|
||||
|
||||
@@ -16,7 +16,7 @@ const ProfilePassword: React.FC<MyInformationProps> = ({ customer: _customer })
|
||||
// TODO: Add support for password updates
|
||||
const updatePassword = async () => {
|
||||
// TODO: Re-add toast notification when Toaster component is implemented
|
||||
console.info("Promjena lozinke trenutno nije dostupna")
|
||||
console.info("Password update is not implemented")
|
||||
}
|
||||
|
||||
const clearState = () => {
|
||||
@@ -30,7 +30,7 @@ const ProfilePassword: React.FC<MyInformationProps> = ({ customer: _customer })
|
||||
className="w-full"
|
||||
>
|
||||
<AccountInfo
|
||||
label="Lozinka"
|
||||
label="Password"
|
||||
currentInfo={
|
||||
<span>The password is not shown for security reasons</span>
|
||||
}
|
||||
@@ -42,21 +42,21 @@ const ProfilePassword: React.FC<MyInformationProps> = ({ customer: _customer })
|
||||
>
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<Input
|
||||
label="Stara lozinka"
|
||||
label="Old password"
|
||||
name="old_password"
|
||||
required
|
||||
type="password"
|
||||
data-testid="old-password-input"
|
||||
/>
|
||||
<Input
|
||||
label="Nova lozinka"
|
||||
label="New password"
|
||||
type="password"
|
||||
name="new_password"
|
||||
required
|
||||
data-testid="new-password-input"
|
||||
/>
|
||||
<Input
|
||||
label="Potvrdite lozinku"
|
||||
label="Confirm password"
|
||||
type="password"
|
||||
name="confirm_password"
|
||||
required
|
||||
|
||||
@@ -47,7 +47,7 @@ const ProfileEmail: React.FC<MyInformationProps> = ({ customer }) => {
|
||||
return (
|
||||
<form action={formAction} className="w-full">
|
||||
<AccountInfo
|
||||
label="Telefon"
|
||||
label="Phone"
|
||||
currentInfo={`${customer.phone}`}
|
||||
isSuccess={successState}
|
||||
isError={!!state.error}
|
||||
@@ -57,7 +57,7 @@ const ProfileEmail: React.FC<MyInformationProps> = ({ customer }) => {
|
||||
>
|
||||
<div className="grid grid-cols-1 gap-y-2">
|
||||
<Input
|
||||
label="Telefon"
|
||||
label="Phone"
|
||||
name="phone"
|
||||
type="phone"
|
||||
autoComplete="phone"
|
||||
|
||||
@@ -16,34 +16,37 @@ const Register = ({ setCurrentView }: Props) => {
|
||||
const [message, formAction] = useActionState(signup, null)
|
||||
|
||||
return (
|
||||
<div className="flex w-full max-w-sm flex-col" data-testid="register-page">
|
||||
<header className="mb-10 text-center">
|
||||
<p className="eyebrow">Moj račun</p>
|
||||
<h1 className="display-heading mt-5 text-4xl sm:text-5xl text-foreground">Registracija</h1>
|
||||
<p className="mt-4 text-sm text-muted-foreground">
|
||||
Napravite račun za brže naručivanje i praćenje isporuke.
|
||||
<div
|
||||
className="max-w-sm flex flex-col items-center"
|
||||
data-testid="register-page"
|
||||
>
|
||||
<h1 className="text-large-semi uppercase mb-6">
|
||||
Become a Medusa Store Member
|
||||
</h1>
|
||||
<p className="text-center text-base-regular text-ui-fg-base mb-4">
|
||||
Create your Medusa Store Member profile, and get access to an enhanced
|
||||
shopping experience.
|
||||
</p>
|
||||
</header>
|
||||
{message?.state === "verification_required" && (
|
||||
<div
|
||||
className="mb-6 w-full rounded-lg bg-muted p-4 text-center text-sm text-foreground"
|
||||
className="w-full mb-4 text-center text-base-regular text-ui-fg-base bg-ui-bg-subtle border border-ui-border-base rounded-rounded p-4"
|
||||
data-testid="register-verification-message"
|
||||
>
|
||||
Poslali smo link za potvrdu na <strong>{message.email}</strong>.
|
||||
Potvrdite email, pa se prijavite.
|
||||
We sent a verification link to <strong>{message.email}</strong>.
|
||||
Please check your inbox to verify your email, then sign in.
|
||||
</div>
|
||||
)}
|
||||
<form className="w-full flex flex-col" action={formAction}>
|
||||
<div className="flex flex-col w-full gap-y-3">
|
||||
<div className="flex flex-col w-full gap-y-2">
|
||||
<Input
|
||||
label="Ime"
|
||||
label="First name"
|
||||
name="first_name"
|
||||
required
|
||||
autoComplete="given-name"
|
||||
data-testid="first-name-input"
|
||||
/>
|
||||
<Input
|
||||
label="Prezime"
|
||||
label="Last name"
|
||||
name="last_name"
|
||||
required
|
||||
autoComplete="family-name"
|
||||
@@ -58,14 +61,14 @@ const Register = ({ setCurrentView }: Props) => {
|
||||
data-testid="email-input"
|
||||
/>
|
||||
<Input
|
||||
label="Telefon"
|
||||
label="Phone"
|
||||
name="phone"
|
||||
type="tel"
|
||||
autoComplete="tel"
|
||||
data-testid="phone-input"
|
||||
/>
|
||||
<Input
|
||||
label="Lozinka"
|
||||
label="Password"
|
||||
name="password"
|
||||
required
|
||||
type="password"
|
||||
@@ -77,36 +80,37 @@ const Register = ({ setCurrentView }: Props) => {
|
||||
error={message?.state === "error" ? message.error : null}
|
||||
data-testid="register-error"
|
||||
/>
|
||||
<span className="mt-6 text-center text-xs text-muted-foreground">
|
||||
Registracijom prihvatate{" "}
|
||||
<span className="text-center text-ui-fg-base text-small-regular mt-6">
|
||||
By creating an account, you agree to Medusa Store's{" "}
|
||||
<LocalizedClientLink
|
||||
href="/privacy"
|
||||
href="/content/privacy-policy"
|
||||
className="underline"
|
||||
>
|
||||
Politikom privatnosti
|
||||
Privacy Policy
|
||||
</LocalizedClientLink>{" "}
|
||||
i{" "}
|
||||
and{" "}
|
||||
<LocalizedClientLink
|
||||
href="/terms"
|
||||
href="/content/terms-of-use"
|
||||
className="underline"
|
||||
>
|
||||
Uslovima korištenja
|
||||
Terms of Use
|
||||
</LocalizedClientLink>
|
||||
.
|
||||
</span>
|
||||
<SubmitButton className="mt-6 h-12 w-full" data-testid="register-button">
|
||||
Registracija
|
||||
<SubmitButton className="w-full mt-6" data-testid="register-button">
|
||||
Join
|
||||
</SubmitButton>
|
||||
</form>
|
||||
<p className="mt-8 border-t border-border/70 pt-6 text-center text-sm text-muted-foreground">
|
||||
Već imate račun?{" "}
|
||||
<span className="text-center text-ui-fg-base text-small-regular mt-6">
|
||||
Already a member?{" "}
|
||||
<button
|
||||
onClick={() => setCurrentView(LOGIN_VIEW.SIGN_IN)}
|
||||
className="text-primary underline underline-offset-4 hover:opacity-80"
|
||||
className="underline"
|
||||
>
|
||||
Prijava
|
||||
Sign in
|
||||
</button>
|
||||
</p>
|
||||
.
|
||||
</span>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
/** Title + short description at the top of each account screen */
|
||||
export default function SectionHeading({
|
||||
title,
|
||||
description,
|
||||
}: {
|
||||
title: string
|
||||
description?: string
|
||||
}) {
|
||||
return (
|
||||
<div className="mb-10 text-center">
|
||||
<h2 className="display-heading text-3xl sm:text-4xl text-foreground">{title}</h2>
|
||||
{description && (
|
||||
<p className="mx-auto mt-3 max-w-lg text-sm text-muted-foreground leading-relaxed">{description}</p>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -27,11 +27,11 @@ export default function TransferRequestForm() {
|
||||
<div className="grid sm:grid-cols-2 items-center gap-x-8 gap-y-4 w-full">
|
||||
<div className="flex flex-col gap-y-1">
|
||||
<Heading level="h3" className="!text-sm font-semibold text-neutral-950">
|
||||
Prijenos narudžbi
|
||||
Order transfers
|
||||
</Heading>
|
||||
<p className="text-sm text-neutral-500">
|
||||
Ne vidite narudžbu koju tražite?
|
||||
<br /> Povežite narudžbu sa svojim računom.
|
||||
<p className="text-small-regular text-neutral-500">
|
||||
Can't find the order you are looking for?
|
||||
<br /> Connect an order to your account.
|
||||
</p>
|
||||
</div>
|
||||
<form
|
||||
@@ -39,31 +39,31 @@ export default function TransferRequestForm() {
|
||||
className="flex flex-col gap-y-1 sm:items-end"
|
||||
>
|
||||
<div className="flex flex-col gap-y-2 w-full">
|
||||
<Input className="w-full" name="order_id" placeholder="Broj narudžbe" />
|
||||
<Input className="w-full" name="order_id" placeholder="Order ID" />
|
||||
<SubmitButton
|
||||
variant="secondary"
|
||||
size="small"
|
||||
className="w-fit whitespace-nowrap self-end"
|
||||
>
|
||||
Zatraži prijenos
|
||||
Request transfer
|
||||
</SubmitButton>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
{!state.success && state.error && (
|
||||
<Text className="text-base text-rose-500 text-right">
|
||||
<Text className="text-base-regular text-rose-500 text-right">
|
||||
{state.error}
|
||||
</Text>
|
||||
)}
|
||||
{showSuccess && (
|
||||
<div className="flex justify-between p-4 bg-neutral-50 border border-border w-full self-stretch items-center">
|
||||
<div className="flex justify-between p-4 bg-neutral-50 shadow-borders-base w-full self-stretch items-center">
|
||||
<div className="flex gap-x-2 items-center">
|
||||
<CheckCircleMiniSolid className="w-4 h-4 text-emerald-500" />
|
||||
<div className="flex flex-col gap-y-1">
|
||||
<Text className="text-medim-pl text-neutral-950">
|
||||
Transfer for order {state.order?.id} requested
|
||||
</Text>
|
||||
<Text className="text-base text-neutral-600">
|
||||
<Text className="text-base-regular text-neutral-600">
|
||||
Transfer request email sent to {state.order?.email}
|
||||
</Text>
|
||||
</div>
|
||||
|
||||
@@ -37,33 +37,33 @@ const VerifyAccount = () => {
|
||||
className="max-w-sm w-full flex flex-col items-center text-center gap-y-4"
|
||||
data-testid="verify-account-page"
|
||||
>
|
||||
<h1 className="text-lg font-medium uppercase">Email verification</h1>
|
||||
<h1 className="text-large-semi uppercase">Email verification</h1>
|
||||
|
||||
{state === "verifying" && (
|
||||
<p className="text-base text-foreground">
|
||||
Potvrđujemo vašu email adresu…
|
||||
<p className="text-base-regular text-ui-fg-base">
|
||||
Verifying your email...
|
||||
</p>
|
||||
)}
|
||||
|
||||
{state === "success" && (
|
||||
<>
|
||||
<p className="text-base text-foreground">
|
||||
Email adresa je potvrđena. Sada se možete prijaviti na svoj račun.
|
||||
<p className="text-base-regular text-ui-fg-base">
|
||||
Your email is verified. You can now sign in to your account.
|
||||
</p>
|
||||
<LocalizedClientLink href="/account">
|
||||
<Button variant="primary">Na prijavu</Button>
|
||||
<Button variant="primary">Go to sign in</Button>
|
||||
</LocalizedClientLink>
|
||||
</>
|
||||
)}
|
||||
|
||||
{state === "error" && (
|
||||
<>
|
||||
<p className="text-base text-foreground">
|
||||
Link za potvrdu nije ispravan ili je istekao. Prijavite se da dobijete
|
||||
novi email za potvrdu.
|
||||
<p className="text-base-regular text-ui-fg-base">
|
||||
This verification link is invalid or has expired. Sign in to receive
|
||||
a new verification email.
|
||||
</p>
|
||||
<LocalizedClientLink href="/account">
|
||||
<Button variant="secondary">Na prijavu</Button>
|
||||
<Button variant="secondary">Go to sign in</Button>
|
||||
</LocalizedClientLink>
|
||||
</>
|
||||
)}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import React from "react"
|
||||
|
||||
import LocalizedClientLink from "@modules/common/components/localized-client-link"
|
||||
import UnderlineLink from "@modules/common/components/interactive-link"
|
||||
|
||||
import AccountNav from "../components/account-nav"
|
||||
import { HttpTypes } from "@medusajs/types"
|
||||
|
||||
@@ -9,46 +10,31 @@ interface AccountLayoutProps {
|
||||
children: React.ReactNode
|
||||
}
|
||||
|
||||
/**
|
||||
* Signed out: the login/register screen is centred on its own.
|
||||
* Signed in: centred greeting, tab navigation, one readable content column.
|
||||
*/
|
||||
const AccountLayout: React.FC<AccountLayoutProps> = ({ customer, children }) => {
|
||||
if (!customer) {
|
||||
const AccountLayout: React.FC<AccountLayoutProps> = ({
|
||||
customer,
|
||||
children,
|
||||
}) => {
|
||||
return (
|
||||
<div className="w-full" data-testid="account-page">
|
||||
{children}
|
||||
<div className="flex-1 small:py-12" data-testid="account-page">
|
||||
<div className="flex-1 content-container h-full max-w-5xl mx-auto bg-white flex flex-col">
|
||||
<div className="grid grid-cols-1 small:grid-cols-[240px_1fr] py-12">
|
||||
<div>{customer && <AccountNav customer={customer} />}</div>
|
||||
<div className="flex-1">{children}</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="content-container pb-20 sm:pb-28" data-testid="account-page">
|
||||
<header className="pt-14 sm:pt-20 pb-10 text-center">
|
||||
<p className="eyebrow">Moj račun</p>
|
||||
<h1 className="display-heading mt-5 text-4xl sm:text-6xl text-foreground">
|
||||
Pozdrav, {customer.first_name || "dobro došli"}
|
||||
</h1>
|
||||
<p className="mt-4 text-sm text-muted-foreground">{customer.email}</p>
|
||||
</header>
|
||||
|
||||
<AccountNav customer={customer} />
|
||||
|
||||
<div className="mx-auto mt-12 w-full max-w-3xl">{children}</div>
|
||||
|
||||
<div className="mx-auto mt-20 flex max-w-3xl flex-col items-start justify-between gap-4 border-t border-border/70 pt-8 sm:flex-row sm:items-center">
|
||||
<div className="flex flex-col small:flex-row items-end justify-between small:border-t border-gray-200 py-12 gap-8">
|
||||
<div>
|
||||
<p className="text-sm text-foreground">Imate pitanja?</p>
|
||||
<p className="mt-1 text-sm text-muted-foreground">
|
||||
Pišite nam ili nas nazovite, odgovaramo u roku od jednog radnog dana.
|
||||
</p>
|
||||
<h3 className="text-xl-semi mb-4">Got questions?</h3>
|
||||
<span className="txt-medium">
|
||||
You can find frequently asked questions and answers on our
|
||||
customer service page.
|
||||
</span>
|
||||
</div>
|
||||
<div>
|
||||
<UnderlineLink href="/customer-service">
|
||||
Customer Service
|
||||
</UnderlineLink>
|
||||
</div>
|
||||
</div>
|
||||
<LocalizedClientLink
|
||||
href="/contact"
|
||||
className="inline-flex h-10 shrink-0 items-center rounded-md border border-border px-5 text-sm text-foreground transition-colors hover:bg-muted"
|
||||
>
|
||||
Kontakt
|
||||
</LocalizedClientLink>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -14,7 +14,7 @@ const LoginTemplate = () => {
|
||||
const [currentView, setCurrentView] = useState("sign-in")
|
||||
|
||||
return (
|
||||
<div className="content-container flex w-full justify-center py-16 sm:py-24">
|
||||
<div className="w-full flex justify-start px-8 py-8">
|
||||
{currentView === "sign-in" ? (
|
||||
<Login setCurrentView={setCurrentView} />
|
||||
) : (
|
||||
|
||||
@@ -42,10 +42,10 @@ const CartItemSelect = forwardRef<HTMLSelectElement, NativeSelectProps>(
|
||||
onFocus={() => innerRef.current?.focus()}
|
||||
onBlur={() => innerRef.current?.blur()}
|
||||
className={clx(
|
||||
"relative flex items-center text-sm border text-foreground group",
|
||||
"relative flex items-center txt-compact-small border text-ui-fg-base group",
|
||||
className,
|
||||
{
|
||||
"text-muted-foreground": isPlaceholder,
|
||||
"text-ui-fg-subtle": isPlaceholder,
|
||||
}
|
||||
)}
|
||||
>
|
||||
|
||||
@@ -1,30 +1,28 @@
|
||||
import LocalizedClientLink from "@modules/common/components/localized-client-link"
|
||||
import { Button } from "@/components/ui/button"
|
||||
import { ShoppingBag, ArrowRight } from "lucide-react"
|
||||
|
||||
const EmptyCartMessage = () => {
|
||||
return (
|
||||
<div
|
||||
className="mx-auto flex max-w-md flex-col items-center py-28 sm:py-36 text-center"
|
||||
className="py-24 sm:py-32 flex flex-col items-center justify-center text-center max-w-md mx-auto"
|
||||
data-testid="empty-cart-message"
|
||||
>
|
||||
<p className="eyebrow">Korpa</p>
|
||||
<h1 className="display-heading mt-5 text-4xl sm:text-5xl text-foreground">Korpa je prazna</h1>
|
||||
<p className="mt-5 text-sm text-muted-foreground leading-relaxed">
|
||||
Konfigurišite suncobran po svojoj mjeri ili pogledajte pergole i tende iz naše proizvodnje.
|
||||
</p>
|
||||
<div className="mt-8 flex flex-col sm:flex-row gap-3">
|
||||
<LocalizedClientLink
|
||||
href="/categories/suncobrani"
|
||||
className="inline-flex h-11 items-center justify-center rounded-md bg-primary px-6 text-sm text-primary-foreground transition-colors hover:bg-primary/90"
|
||||
>
|
||||
Konfiguriši suncobran
|
||||
</LocalizedClientLink>
|
||||
<LocalizedClientLink
|
||||
href="/store"
|
||||
className="inline-flex h-11 items-center justify-center rounded-md border border-border px-6 text-sm text-foreground transition-colors hover:bg-muted"
|
||||
>
|
||||
Pogledajte katalog
|
||||
</LocalizedClientLink>
|
||||
<div className="h-16 w-16 rounded-full bg-muted flex items-center justify-center text-muted-foreground mb-4">
|
||||
<ShoppingBag className="h-8 w-8" />
|
||||
</div>
|
||||
<h1 className="text-2xl sm:text-3xl font-bold tracking-tight text-foreground">
|
||||
Vaša korpa je prazna
|
||||
</h1>
|
||||
<p className="mt-2 text-sm text-muted-foreground leading-relaxed">
|
||||
Trenutno nemate dodanih proizvoda u korpi. Istražite našu ponudu profesionalnih suncobrana, pergola i opreme za zaštitu od sunca.
|
||||
</p>
|
||||
<LocalizedClientLink href="/store" className="mt-6">
|
||||
<Button size="lg" className="gap-2">
|
||||
<span>Pregledaj Katalog</span>
|
||||
<ArrowRight className="h-4 w-4" />
|
||||
</Button>
|
||||
</LocalizedClientLink>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,143 +1,139 @@
|
||||
"use client"
|
||||
|
||||
import Image from "next/image"
|
||||
import { updateLineItem, deleteLineItem } from "@lib/data/cart"
|
||||
import { notifyCartUpdated } from "@lib/util/cart-events"
|
||||
import { convertToLocale } from "@lib/util/money"
|
||||
import { getProductCardImage } from "@lib/util/sale-scenario"
|
||||
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, Minus, Plus } from "lucide-react"
|
||||
import { Loader2 } from "lucide-react"
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
type ItemProps = {
|
||||
item: HttpTypes.StoreCartLineItem
|
||||
/** full: cart page with quantity controls; preview: checkout summary */
|
||||
type?: "full" | "preview"
|
||||
currencyCode: string
|
||||
}
|
||||
|
||||
const MAX_QUANTITY = 99
|
||||
|
||||
/** Cart line as a list row (cart page and checkout summary) */
|
||||
const Item = ({ item, type = "full", currencyCode }: ItemProps) => {
|
||||
const [updating, setUpdating] = useState(false)
|
||||
const [removing, setRemoving] = useState(false)
|
||||
const [error, setError] = useState<string | null>(null)
|
||||
const isFull = type === "full"
|
||||
const money = (amount?: number | null) =>
|
||||
convertToLocale({ amount: amount ?? 0, currency_code: currencyCode })
|
||||
|
||||
const changeQuantity = async (quantity: number) => {
|
||||
if (quantity < 1 || quantity > MAX_QUANTITY) return
|
||||
setError(null)
|
||||
setUpdating(true)
|
||||
await updateLineItem({ lineId: item.id, quantity })
|
||||
.then(() => notifyCartUpdated())
|
||||
.catch((err) => setError(err.message))
|
||||
.finally(() => setUpdating(false))
|
||||
}
|
||||
|
||||
const remove = async () => {
|
||||
setRemoving(true)
|
||||
await deleteLineItem(item.id)
|
||||
.then(() => notifyCartUpdated())
|
||||
await updateLineItem({
|
||||
lineId: item.id,
|
||||
quantity,
|
||||
})
|
||||
.catch((err) => {
|
||||
setError(err.message)
|
||||
setRemoving(false)
|
||||
})
|
||||
.finally(() => {
|
||||
setUpdating(false)
|
||||
})
|
||||
}
|
||||
|
||||
const maxQtyFromInventory = 10
|
||||
const maxQuantity = item.variant?.manage_inventory ? 10 : maxQtyFromInventory
|
||||
|
||||
return (
|
||||
<li
|
||||
className={cn("flex gap-4 sm:gap-6", isFull ? "py-6" : "py-4", removing && "opacity-40")}
|
||||
data-testid="product-row"
|
||||
>
|
||||
<Table.Row className="w-full border-b border-border" data-testid="product-row">
|
||||
<Table.Cell className="p-3 w-20">
|
||||
<LocalizedClientLink
|
||||
href={`/products/${item.product_handle}`}
|
||||
className={cn(
|
||||
"relative aspect-[4/5] shrink-0 overflow-hidden rounded-lg bg-muted",
|
||||
isFull ? "w-24 sm:w-32" : "w-14"
|
||||
)}
|
||||
className={cn("flex rounded-md overflow-hidden border border-border", {
|
||||
"w-14 h-14": type === "preview",
|
||||
"sm:w-20 sm:h-20 w-14 h-14": type === "full",
|
||||
})}
|
||||
>
|
||||
<Image
|
||||
src={getProductCardImage(item.product_title)}
|
||||
alt={item.product_title ?? ""}
|
||||
fill
|
||||
sizes={isFull ? "128px" : "56px"}
|
||||
className="object-cover"
|
||||
<Thumbnail
|
||||
thumbnail={item.thumbnail}
|
||||
images={item.variant?.product?.images}
|
||||
size="square"
|
||||
/>
|
||||
</LocalizedClientLink>
|
||||
</Table.Cell>
|
||||
|
||||
<div className="flex min-w-0 flex-1 flex-col">
|
||||
<div className="flex items-start justify-between gap-4">
|
||||
<div className="min-w-0">
|
||||
<Table.Cell className="text-left py-3">
|
||||
<LocalizedClientLink
|
||||
href={`/products/${item.product_handle}`}
|
||||
className={cn(
|
||||
"text-foreground transition-colors hover:text-primary line-clamp-2",
|
||||
isFull ? "text-base" : "text-sm"
|
||||
)}
|
||||
className="font-medium text-foreground hover:underline line-clamp-2 text-sm sm:text-base"
|
||||
data-testid="product-title"
|
||||
>
|
||||
{item.product_title}
|
||||
</LocalizedClientLink>
|
||||
<LineItemOptions variant={item.variant} metadata={item.metadata} data-testid="product-variant" />
|
||||
</div>
|
||||
<div className="shrink-0 text-right">
|
||||
<p className={cn("text-foreground tabular-nums", isFull ? "text-base" : "text-sm")} data-testid="product-price">
|
||||
{money(item.total)}
|
||||
</p>
|
||||
{(isFull ? item.quantity > 1 : true) && (
|
||||
<p className="mt-0.5 text-xs text-muted-foreground tabular-nums">
|
||||
{item.quantity} × {money(item.unit_price)}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<LineItemOptions variant={item.variant} data-testid="product-variant" />
|
||||
</Table.Cell>
|
||||
|
||||
{isFull && (
|
||||
<div className="mt-auto flex items-center justify-between pt-4">
|
||||
<div className="inline-flex items-center rounded-full border border-border" data-testid="product-select-button">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => changeQuantity(item.quantity - 1)}
|
||||
disabled={updating || item.quantity <= 1}
|
||||
className="flex h-9 w-9 items-center justify-center rounded-full text-muted-foreground transition-colors hover:text-foreground disabled:opacity-30"
|
||||
aria-label="Smanji količinu"
|
||||
{type === "full" && (
|
||||
<Table.Cell className="py-3">
|
||||
<div className="flex gap-2 items-center w-28">
|
||||
<DeleteButton id={item.id} data-testid="product-delete-button" />
|
||||
<CartItemSelect
|
||||
value={item.quantity}
|
||||
onChange={(value) => changeQuantity(parseInt(value.target.value))}
|
||||
className="h-9 rounded-md border border-input bg-background px-2 text-sm"
|
||||
data-testid="product-select-button"
|
||||
>
|
||||
<Minus className="h-3.5 w-3.5" />
|
||||
</button>
|
||||
<span className="w-8 text-center text-sm tabular-nums" aria-live="polite">
|
||||
{updating ? <Loader2 className="mx-auto h-3.5 w-3.5 animate-spin text-primary" /> : item.quantity}
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => changeQuantity(item.quantity + 1)}
|
||||
disabled={updating || item.quantity >= MAX_QUANTITY}
|
||||
className="flex h-9 w-9 items-center justify-center rounded-full text-muted-foreground transition-colors hover:text-foreground disabled:opacity-30"
|
||||
aria-label="Povećaj količinu"
|
||||
>
|
||||
<Plus className="h-3.5 w-3.5" />
|
||||
</button>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
onClick={remove}
|
||||
disabled={removing || updating}
|
||||
className="text-sm text-muted-foreground underline-offset-4 transition-colors hover:text-destructive hover:underline disabled:opacity-40"
|
||||
data-testid="product-delete-button"
|
||||
>
|
||||
Ukloni
|
||||
</button>
|
||||
</div>
|
||||
{Array.from(
|
||||
{
|
||||
length: Math.min(maxQuantity, 10),
|
||||
},
|
||||
(_, i) => (
|
||||
<option value={i + 1} key={i}>
|
||||
{i + 1}
|
||||
</option>
|
||||
)
|
||||
)}
|
||||
<ErrorMessage error={error} data-testid="product-error-message" />
|
||||
</CartItemSelect>
|
||||
{updating && <Loader2 className="h-4 w-4 animate-spin text-muted-foreground" />}
|
||||
</div>
|
||||
</li>
|
||||
<ErrorMessage error={error} data-testid="product-error-message" />
|
||||
</Table.Cell>
|
||||
)}
|
||||
|
||||
{type === "full" && (
|
||||
<Table.Cell className="hidden sm:table-cell py-3 text-muted-foreground text-sm">
|
||||
<LineItemUnitPrice
|
||||
item={item}
|
||||
style="tight"
|
||||
currencyCode={currencyCode}
|
||||
/>
|
||||
</Table.Cell>
|
||||
)}
|
||||
|
||||
<Table.Cell className="text-right py-3 pr-4 font-semibold text-foreground text-sm">
|
||||
<span
|
||||
className={cn({
|
||||
"flex flex-col items-end h-full justify-center": type === "preview",
|
||||
})}
|
||||
>
|
||||
{type === "preview" && (
|
||||
<span className="flex gap-x-1 text-xs text-muted-foreground font-normal">
|
||||
<span>{item.quantity}x </span>
|
||||
<LineItemUnitPrice
|
||||
item={item}
|
||||
style="tight"
|
||||
currencyCode={currencyCode}
|
||||
/>
|
||||
</span>
|
||||
)}
|
||||
<LineItemPrice
|
||||
item={item}
|
||||
style="tight"
|
||||
currencyCode={currencyCode}
|
||||
/>
|
||||
</span>
|
||||
</Table.Cell>
|
||||
</Table.Row>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,22 +1,25 @@
|
||||
import { Button } from "@/components/ui/button"
|
||||
import LocalizedClientLink from "@modules/common/components/localized-client-link"
|
||||
|
||||
const SignInPrompt = () => {
|
||||
return (
|
||||
<div className="flex flex-col sm:flex-row sm:items-center justify-between gap-4 rounded-xl border border-border/80 p-5 sm:p-6">
|
||||
<div className="flex items-center justify-between rounded-xl border border-border bg-muted/30 p-4 sm:p-5">
|
||||
<div>
|
||||
<p className="text-sm text-foreground">Već imate nalog?</p>
|
||||
<p className="mt-1 text-xs text-muted-foreground">
|
||||
Prijavite se za brže naručivanje i praćenje isporuke.
|
||||
<h3 className="text-base font-semibold text-foreground">
|
||||
Već imate nalog?
|
||||
</h3>
|
||||
<p className="text-xs sm:text-sm text-muted-foreground mt-0.5">
|
||||
Prijavite se za brže naručivanje i praćenje statusa isporuke.
|
||||
</p>
|
||||
</div>
|
||||
<LocalizedClientLink
|
||||
href="/account"
|
||||
className="inline-flex h-10 shrink-0 items-center justify-center rounded-md border border-border px-5 text-sm text-foreground transition-colors hover:bg-muted"
|
||||
data-testid="sign-in-button"
|
||||
>
|
||||
<div>
|
||||
<LocalizedClientLink href="/account">
|
||||
<Button variant="outline" size="sm" data-testid="sign-in-button">
|
||||
Prijava
|
||||
</Button>
|
||||
</LocalizedClientLink>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ 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 = ({
|
||||
@@ -11,34 +12,34 @@ const CartTemplate = ({
|
||||
cart: HttpTypes.StoreCart | null
|
||||
customer: HttpTypes.StoreCustomer | null
|
||||
}) => {
|
||||
const count = cart?.items?.reduce((sum, i) => sum + i.quantity, 0) ?? 0
|
||||
|
||||
return (
|
||||
<div className="content-container pb-20 sm:pb-28" data-testid="cart-container">
|
||||
<div className="py-8 sm:py-12">
|
||||
<div className="content-container" data-testid="cart-container">
|
||||
{cart?.items?.length ? (
|
||||
<div className="grid grid-cols-1 lg:grid-cols-12 gap-8 items-start">
|
||||
<div className="lg:col-span-8 flex flex-col gap-6">
|
||||
{!customer && (
|
||||
<>
|
||||
<header className="pt-14 sm:pt-20 pb-10 sm:pb-14 text-center">
|
||||
<p className="eyebrow">Korpa</p>
|
||||
<h1 className="display-heading mt-5 text-4xl sm:text-6xl text-foreground">Vaša korpa</h1>
|
||||
<p className="mt-4 text-sm text-muted-foreground">
|
||||
{count % 10 === 1 && count % 100 !== 11 ? `${count} artikal` : `${count} artikala`} · Dostava za
|
||||
24–48h širom BiH ili preuzimanje u Gračanici
|
||||
</p>
|
||||
</header>
|
||||
|
||||
<div className="grid grid-cols-1 lg:grid-cols-12 gap-10 lg:gap-16 items-start">
|
||||
<div className="lg:col-span-7 xl:col-span-8 flex flex-col gap-8">
|
||||
<ItemsTemplate cart={cart} />
|
||||
{!customer && <SignInPrompt />}
|
||||
</div>
|
||||
<aside className="lg:col-span-5 xl:col-span-4 lg:sticky lg:top-28">
|
||||
{cart.region && <Summary cart={cart} />}
|
||||
</aside>
|
||||
</div>
|
||||
<SignInPrompt />
|
||||
<Separator />
|
||||
</>
|
||||
) : (
|
||||
<EmptyCartMessage />
|
||||
)}
|
||||
<ItemsTemplate cart={cart} />
|
||||
</div>
|
||||
<div className="lg:col-span-4 sticky top-24">
|
||||
{cart && cart.region && (
|
||||
<div className="rounded-xl border border-border bg-card p-6 shadow-sm">
|
||||
<Summary cart={cart} />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<div>
|
||||
<EmptyCartMessage />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,21 +1,56 @@
|
||||
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 ?? [])].sort((a, b) =>
|
||||
(a.created_at ?? "") > (b.created_at ?? "") ? -1 : 1
|
||||
)
|
||||
|
||||
const items = cart?.items
|
||||
return (
|
||||
<ul className="divide-y divide-border/70 border-y border-border/70" data-testid="items-table">
|
||||
{items.map((item) => (
|
||||
<Item key={item.id} item={item} currencyCode={cart?.currency_code ?? ""} />
|
||||
))}
|
||||
</ul>
|
||||
<div>
|
||||
<div className="pb-3 flex items-center">
|
||||
<Heading className="text-[2rem] leading-[2.75rem]">Cart</Heading>
|
||||
</div>
|
||||
<Table>
|
||||
<Table.Header className="border-t-0">
|
||||
<Table.Row className="text-ui-fg-subtle txt-medium-plus">
|
||||
<Table.HeaderCell className="!pl-0">Item</Table.HeaderCell>
|
||||
<Table.HeaderCell></Table.HeaderCell>
|
||||
<Table.HeaderCell>Quantity</Table.HeaderCell>
|
||||
<Table.HeaderCell className="hidden small:table-cell">
|
||||
Price
|
||||
</Table.HeaderCell>
|
||||
<Table.HeaderCell className="!pr-0 text-right">
|
||||
Total
|
||||
</Table.HeaderCell>
|
||||
</Table.Row>
|
||||
</Table.Header>
|
||||
<Table.Body>
|
||||
{items
|
||||
? items
|
||||
.sort((a, b) => {
|
||||
return (a.created_at ?? "") > (b.created_at ?? "") ? -1 : 1
|
||||
})
|
||||
.map((item) => {
|
||||
return (
|
||||
<Item
|
||||
key={item.id}
|
||||
item={item}
|
||||
currencyCode={cart?.currency_code}
|
||||
/>
|
||||
)
|
||||
})
|
||||
: repeat(5).map((i) => {
|
||||
return <SkeletonLineItem key={i} />
|
||||
})}
|
||||
</Table.Body>
|
||||
</Table>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,32 +1,50 @@
|
||||
"use client"
|
||||
|
||||
import repeat from "@lib/util/repeat"
|
||||
import { HttpTypes } from "@medusajs/types"
|
||||
import { cn } from "@/lib/utils"
|
||||
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
|
||||
}
|
||||
|
||||
/** Compact item list for the checkout summary */
|
||||
const ItemsPreviewTemplate = ({ cart }: ItemsTemplateProps) => {
|
||||
const items = [...(cart.items ?? [])].sort((a, b) =>
|
||||
(a.created_at ?? "") > (b.created_at ?? "") ? -1 : 1
|
||||
)
|
||||
const hasOverflow = items.length > 4
|
||||
const items = cart.items
|
||||
const hasOverflow = items && items.length > 4
|
||||
|
||||
return (
|
||||
<ul
|
||||
className={cn(
|
||||
"divide-y divide-border/70",
|
||||
hasOverflow && "max-h-[420px] overflow-y-auto no-scrollbar"
|
||||
)}
|
||||
data-testid="items-table"
|
||||
<div
|
||||
className={clx({
|
||||
"pl-[1px] overflow-y-scroll overflow-x-hidden no-scrollbar max-h-[420px]":
|
||||
hasOverflow,
|
||||
})}
|
||||
>
|
||||
{items.map((item) => (
|
||||
<Item key={item.id} item={item} type="preview" currencyCode={cart.currency_code} />
|
||||
))}
|
||||
</ul>
|
||||
<Table>
|
||||
<Table.Body data-testid="items-table">
|
||||
{items
|
||||
? items
|
||||
.sort((a, b) => {
|
||||
return (a.created_at ?? "") > (b.created_at ?? "") ? -1 : 1
|
||||
})
|
||||
.map((item) => {
|
||||
return (
|
||||
<Item
|
||||
key={item.id}
|
||||
item={item}
|
||||
type="preview"
|
||||
currencyCode={cart.currency_code}
|
||||
/>
|
||||
)
|
||||
})
|
||||
: repeat(5).map((i) => {
|
||||
return <SkeletonLineItem key={i} />
|
||||
})}
|
||||
</Table.Body>
|
||||
</Table>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
"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"
|
||||
import { ArrowRight } from "lucide-react"
|
||||
|
||||
type SummaryProps = {
|
||||
cart: HttpTypes.StoreCart
|
||||
@@ -24,22 +25,22 @@ const Summary = ({ cart }: SummaryProps) => {
|
||||
const step = getCheckoutStep(cart)
|
||||
|
||||
return (
|
||||
<div className="rounded-2xl bg-muted p-6 sm:p-8">
|
||||
<p className="eyebrow text-muted-foreground">Pregled narudžbe</p>
|
||||
<div className="mt-6">
|
||||
<div className="flex flex-col gap-4">
|
||||
<h2 className="text-xl font-bold tracking-tight text-foreground">
|
||||
Pregled Narudžbe
|
||||
</h2>
|
||||
<DiscountCode cart={cart} />
|
||||
<Separator />
|
||||
<CartTotals totals={cart} />
|
||||
</div>
|
||||
<LocalizedClientLink
|
||||
href={"/checkout?step=" + step}
|
||||
data-testid="checkout-button"
|
||||
className="mt-6 flex h-12 w-full items-center justify-center gap-2 rounded-md bg-primary text-sm text-primary-foreground transition-colors hover:bg-primary/90"
|
||||
className="w-full"
|
||||
>
|
||||
Nastavite na plaćanje
|
||||
<ArrowRight className="h-4 w-4" />
|
||||
<Button className="w-full h-11 text-base font-semibold">
|
||||
Nastavi na plaćanje
|
||||
</Button>
|
||||
</LocalizedClientLink>
|
||||
<div className="mt-6 border-t border-border pt-6">
|
||||
<DiscountCode cart={cart} />
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
"use client"
|
||||
|
||||
import { Search } from "lucide-react"
|
||||
import { useParams, usePathname, useRouter } from "next/navigation"
|
||||
import { useState } from "react"
|
||||
import { PRODUCT_INDEX_NAME } from "@lib/search-client"
|
||||
import RefinementList from "@modules/store/components/refinement-list"
|
||||
import { SortOptions } from "@modules/store/components/refinement-list/sort-products"
|
||||
import CatalogToolbar from "@modules/store/components/catalog-toolbar"
|
||||
|
||||
const SORT_LABELS: Record<SortOptions, string> = {
|
||||
created_at: "Najnovije",
|
||||
price_asc: "Cijena: od najniže",
|
||||
price_desc: "Cijena: od najviše",
|
||||
}
|
||||
|
||||
/** Category search hands the query to the full-catalog search on /store */
|
||||
function CategorySearch({ onClose }: { onClose: () => void }) {
|
||||
const router = useRouter()
|
||||
const { countryCode } = useParams<{ countryCode: string }>()
|
||||
const [value, setValue] = useState("")
|
||||
|
||||
return (
|
||||
<form
|
||||
role="search"
|
||||
onSubmit={(event) => {
|
||||
event.preventDefault()
|
||||
const query = value.trim()
|
||||
if (!query) return
|
||||
const params = new URLSearchParams({ [`${PRODUCT_INDEX_NAME}[query]`]: query })
|
||||
router.push(`/${countryCode}/store?${params.toString()}`)
|
||||
}}
|
||||
className="relative flex items-center"
|
||||
>
|
||||
<Search className="pointer-events-none absolute left-1 h-4 w-4 text-muted-foreground" />
|
||||
<input
|
||||
type="search"
|
||||
autoFocus
|
||||
value={value}
|
||||
onChange={(e) => setValue(e.target.value)}
|
||||
onKeyDown={(e) => e.key === "Escape" && onClose()}
|
||||
placeholder="Pretražite sve proizvode i pritisnite Enter"
|
||||
aria-label="Pretraži proizvode"
|
||||
className="h-10 w-full bg-transparent pl-8 text-base sm:text-sm placeholder:text-muted-foreground focus-visible:outline-none [&::-webkit-search-cancel-button]:hidden"
|
||||
/>
|
||||
</form>
|
||||
)
|
||||
}
|
||||
|
||||
export default function CategoryToolbar({ sortBy }: { sortBy: SortOptions }) {
|
||||
const router = useRouter()
|
||||
const pathname = usePathname()
|
||||
const isDefaultSort = sortBy === "created_at"
|
||||
|
||||
return (
|
||||
<CatalogToolbar
|
||||
summary={`Sortiranje: ${SORT_LABELS[sortBy] ?? SORT_LABELS.created_at}`}
|
||||
filters={<RefinementList sortBy={sortBy} data-testid="sort-by-container" hideOptionsPicker />}
|
||||
activeFilters={isDefaultSort ? 0 : 1}
|
||||
onClearFilters={() => router.push(pathname)}
|
||||
renderSearch={({ onClose }) => <CategorySearch onClose={onClose} />}
|
||||
/>
|
||||
)
|
||||
}
|
||||
@@ -1,12 +1,14 @@
|
||||
import { notFound } from "next/navigation"
|
||||
import { Suspense } from "react"
|
||||
import SkeletonProductGrid from "@modules/skeletons/templates/skeleton-product-grid"
|
||||
import CategoryToolbar from "@modules/categories/components/category-toolbar"
|
||||
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 CatalogHeader from "@modules/store/components/catalog-header"
|
||||
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,
|
||||
@@ -26,20 +28,84 @@ export default function CategoryTemplate({
|
||||
|
||||
if (!category || !countryCode) notFound()
|
||||
|
||||
const rootHandle =
|
||||
category.parent_category?.handle ?? category.handle ?? null
|
||||
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 (
|
||||
<div className="content-container pb-20 sm:pb-28" data-testid="category-container">
|
||||
<CatalogHeader
|
||||
kicker="Katalog"
|
||||
title={category.name}
|
||||
description={category.description}
|
||||
activeHandle={rootHandle}
|
||||
titleTestId="category-page-title"
|
||||
/>
|
||||
<div
|
||||
className="content-container py-8 sm:py-12"
|
||||
data-testid="category-container"
|
||||
>
|
||||
{/* Breadcrumb Navigation */}
|
||||
<nav className="flex items-center gap-2 text-xs text-muted-foreground mb-4">
|
||||
<LocalizedClientLink href="/" className="hover:text-foreground">
|
||||
Početna
|
||||
</LocalizedClientLink>
|
||||
<ChevronRight className="h-3 w-3" />
|
||||
<LocalizedClientLink href="/store" className="hover:text-foreground">
|
||||
Katalog
|
||||
</LocalizedClientLink>
|
||||
{parents.reverse().map((parent) => (
|
||||
<span key={parent.id} className="flex items-center gap-2">
|
||||
<ChevronRight className="h-3 w-3" />
|
||||
<LocalizedClientLink
|
||||
href={`/categories/${parent.handle}`}
|
||||
className="hover:text-foreground"
|
||||
>
|
||||
{parent.name}
|
||||
</LocalizedClientLink>
|
||||
</span>
|
||||
))}
|
||||
<ChevronRight className="h-3 w-3" />
|
||||
<span className="text-foreground font-medium">{category.name}</span>
|
||||
</nav>
|
||||
|
||||
<CategoryToolbar sortBy={sort} />
|
||||
{/* Category Header */}
|
||||
<div className="mb-8 border-b border-border pb-6">
|
||||
<h1
|
||||
className="text-3xl sm:text-4xl font-extrabold tracking-tight text-foreground"
|
||||
data-testid="category-page-title"
|
||||
>
|
||||
{category.name}
|
||||
</h1>
|
||||
{category.description && (
|
||||
<p className="mt-2 text-base text-muted-foreground max-w-3xl leading-relaxed">
|
||||
{category.description}
|
||||
</p>
|
||||
)}
|
||||
{category.category_children && category.category_children.length > 0 && (
|
||||
<div className="mt-4 flex flex-wrap gap-2">
|
||||
{category.category_children.map((c) => (
|
||||
<LocalizedClientLink key={c.id} href={`/categories/${c.handle}`}>
|
||||
<Badge variant="outline" className="px-3 py-1 hover:bg-accent transition-colors">
|
||||
{c.name}
|
||||
</Badge>
|
||||
</LocalizedClientLink>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Main Grid: Sidebar + Products */}
|
||||
<div className="grid grid-cols-1 lg:grid-cols-4 gap-8">
|
||||
<div className="lg:col-span-1">
|
||||
<div className="rounded-xl border border-border bg-card p-4 sm:p-5 shadow-sm sticky top-24">
|
||||
<RefinementList
|
||||
sortBy={sort}
|
||||
data-testid="sort-by-container"
|
||||
hideOptionsPicker
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div className="lg:col-span-3">
|
||||
<Suspense
|
||||
fallback={
|
||||
<SkeletonProductGrid
|
||||
@@ -56,5 +122,7 @@ export default function CategoryTemplate({
|
||||
/>
|
||||
</Suspense>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ const AddressSelect = ({
|
||||
<Listbox onChange={handleSelect} value={selectedAddress?.id}>
|
||||
<div className="relative">
|
||||
<Listbox.Button
|
||||
className="relative w-full flex justify-between items-center px-4 py-[10px] text-left bg-white cursor-default focus:outline-none border rounded-rounded focus-visible:ring-2 focus-visible:ring-opacity-75 focus-visible:ring-white focus-visible:ring-offset-gray-300 focus-visible:ring-offset-2 focus-visible:border-gray-300 text-base"
|
||||
className="relative w-full flex justify-between items-center px-4 py-[10px] text-left bg-white cursor-default focus:outline-none border rounded-rounded focus-visible:ring-2 focus-visible:ring-opacity-75 focus-visible:ring-white focus-visible:ring-offset-gray-300 focus-visible:ring-offset-2 focus-visible:border-gray-300 text-base-regular"
|
||||
data-testid="shipping-address-select"
|
||||
>
|
||||
{({ open }) => (
|
||||
@@ -44,7 +44,7 @@ const AddressSelect = ({
|
||||
<span className="block truncate">
|
||||
{selectedAddress
|
||||
? selectedAddress.address_1
|
||||
: "Odaberite adresu"}
|
||||
: "Choose an address"}
|
||||
</span>
|
||||
<ChevronsUpDown
|
||||
className={clx("h-4 w-4 transition-transform duration-200", {
|
||||
@@ -61,7 +61,7 @@ const AddressSelect = ({
|
||||
leaveTo="opacity-0"
|
||||
>
|
||||
<Listbox.Options
|
||||
className="absolute z-20 w-full overflow-auto text-sm bg-white border border-top-0 max-h-60 focus:outline-none sm:text-sm"
|
||||
className="absolute z-20 w-full overflow-auto text-small-regular bg-white border border-top-0 max-h-60 focus:outline-none sm:text-sm"
|
||||
data-testid="shipping-address-options"
|
||||
>
|
||||
{addresses.map((address) => {
|
||||
@@ -78,15 +78,15 @@ const AddressSelect = ({
|
||||
data-testid="shipping-address-radio"
|
||||
/>
|
||||
<div className="flex flex-col">
|
||||
<span className="text-left text-base font-semibold">
|
||||
<span className="text-left text-base-semi">
|
||||
{address.first_name} {address.last_name}
|
||||
</span>
|
||||
{address.company && (
|
||||
<span className="text-sm text-foreground">
|
||||
<span className="text-small-regular text-ui-fg-base">
|
||||
{address.company}
|
||||
</span>
|
||||
)}
|
||||
<div className="flex flex-col text-left text-base mt-2">
|
||||
<div className="flex flex-col text-left text-base-regular mt-2">
|
||||
<span>
|
||||
{address.address_1}
|
||||
{address.address_2 && (
|
||||
|
||||
@@ -44,19 +44,19 @@ const Addresses = ({
|
||||
<div className="flex flex-row items-center justify-between mb-6">
|
||||
<Heading
|
||||
level="h2"
|
||||
className="flex flex-row font-display text-3xl gap-x-2 items-baseline"
|
||||
className="flex flex-row text-3xl-regular gap-x-2 items-baseline"
|
||||
>
|
||||
Adresa dostave
|
||||
Shipping Address
|
||||
{!isOpen && <CheckCircleSolid />}
|
||||
</Heading>
|
||||
{!isOpen && cart?.shipping_address && (
|
||||
<Text>
|
||||
<button
|
||||
onClick={handleEdit}
|
||||
className="text-primary hover:text-primary/80"
|
||||
className="text-ui-fg-interactive hover:text-ui-fg-interactive-hover"
|
||||
data-testid="edit-address-button"
|
||||
>
|
||||
Izmijeni
|
||||
Edit
|
||||
</button>
|
||||
</Text>
|
||||
)}
|
||||
@@ -75,23 +75,23 @@ const Addresses = ({
|
||||
<div>
|
||||
<Heading
|
||||
level="h2"
|
||||
className="font-display text-3xl gap-x-4 pb-6 pt-8"
|
||||
className="text-3xl-regular gap-x-4 pb-6 pt-8"
|
||||
>
|
||||
Adresa za račun
|
||||
Billing address
|
||||
</Heading>
|
||||
|
||||
<BillingAddress cart={cart} />
|
||||
</div>
|
||||
)}
|
||||
<SubmitButton className="mt-6" data-testid="submit-address-button">
|
||||
Nastavite na dostavu
|
||||
Continue to delivery
|
||||
</SubmitButton>
|
||||
<ErrorMessage error={message} data-testid="address-error-message" />
|
||||
</div>
|
||||
</form>
|
||||
) : (
|
||||
<div>
|
||||
<div className="text-sm">
|
||||
<div className="text-small-regular">
|
||||
{cart && cart.shipping_address ? (
|
||||
<div className="flex items-start gap-x-8">
|
||||
<div className="flex items-start gap-x-1 w-full">
|
||||
@@ -99,22 +99,22 @@ const Addresses = ({
|
||||
className="flex flex-col w-1/3"
|
||||
data-testid="shipping-address-summary"
|
||||
>
|
||||
<Text className="text-sm font-medium text-foreground mb-1">
|
||||
Adresa dostave
|
||||
<Text className="txt-medium-plus text-ui-fg-base mb-1">
|
||||
Shipping Address
|
||||
</Text>
|
||||
<Text className="text-sm text-muted-foreground">
|
||||
<Text className="txt-medium text-ui-fg-subtle">
|
||||
{cart.shipping_address.first_name}{" "}
|
||||
{cart.shipping_address.last_name}
|
||||
</Text>
|
||||
<Text className="text-sm text-muted-foreground">
|
||||
<Text className="txt-medium text-ui-fg-subtle">
|
||||
{cart.shipping_address.address_1}{" "}
|
||||
{cart.shipping_address.address_2}
|
||||
</Text>
|
||||
<Text className="text-sm text-muted-foreground">
|
||||
<Text className="txt-medium text-ui-fg-subtle">
|
||||
{cart.shipping_address.postal_code},{" "}
|
||||
{cart.shipping_address.city}
|
||||
</Text>
|
||||
<Text className="text-sm text-muted-foreground">
|
||||
<Text className="txt-medium text-ui-fg-subtle">
|
||||
{cart.shipping_address.country_code?.toUpperCase()}
|
||||
</Text>
|
||||
</div>
|
||||
@@ -123,13 +123,13 @@ const Addresses = ({
|
||||
className="flex flex-col w-1/3 "
|
||||
data-testid="shipping-contact-summary"
|
||||
>
|
||||
<Text className="text-sm font-medium text-foreground mb-1">
|
||||
Kontakt
|
||||
<Text className="txt-medium-plus text-ui-fg-base mb-1">
|
||||
Contact
|
||||
</Text>
|
||||
<Text className="text-sm text-muted-foreground">
|
||||
<Text className="txt-medium text-ui-fg-subtle">
|
||||
{cart.shipping_address.phone}
|
||||
</Text>
|
||||
<Text className="text-sm text-muted-foreground">
|
||||
<Text className="txt-medium text-ui-fg-subtle">
|
||||
{cart.email}
|
||||
</Text>
|
||||
</div>
|
||||
@@ -138,29 +138,29 @@ const Addresses = ({
|
||||
className="flex flex-col w-1/3"
|
||||
data-testid="billing-address-summary"
|
||||
>
|
||||
<Text className="text-sm font-medium text-foreground mb-1">
|
||||
Adresa za račun
|
||||
<Text className="txt-medium-plus text-ui-fg-base mb-1">
|
||||
Billing Address
|
||||
</Text>
|
||||
|
||||
{sameAsBilling ? (
|
||||
<Text className="text-sm text-muted-foreground">
|
||||
Adresa za račun ista je kao adresa dostave.
|
||||
<Text className="txt-medium text-ui-fg-subtle">
|
||||
Billing and delivery address are the same.
|
||||
</Text>
|
||||
) : (
|
||||
<>
|
||||
<Text className="text-sm text-muted-foreground">
|
||||
<Text className="txt-medium text-ui-fg-subtle">
|
||||
{cart.billing_address?.first_name}{" "}
|
||||
{cart.billing_address?.last_name}
|
||||
</Text>
|
||||
<Text className="text-sm text-muted-foreground">
|
||||
<Text className="txt-medium text-ui-fg-subtle">
|
||||
{cart.billing_address?.address_1}{" "}
|
||||
{cart.billing_address?.address_2}
|
||||
</Text>
|
||||
<Text className="text-sm text-muted-foreground">
|
||||
<Text className="txt-medium text-ui-fg-subtle">
|
||||
{cart.billing_address?.postal_code},{" "}
|
||||
{cart.billing_address?.city}
|
||||
</Text>
|
||||
<Text className="text-sm text-muted-foreground">
|
||||
<Text className="txt-medium text-ui-fg-subtle">
|
||||
{cart.billing_address?.country_code?.toUpperCase()}
|
||||
</Text>
|
||||
</>
|
||||
|
||||
@@ -31,7 +31,7 @@ const BillingAddress = ({ cart }: { cart: HttpTypes.StoreCart | null }) => {
|
||||
<>
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<Input
|
||||
label="Ime"
|
||||
label="First name"
|
||||
name="billing_address.first_name"
|
||||
autoComplete="given-name"
|
||||
value={formData["billing_address.first_name"]}
|
||||
@@ -40,7 +40,7 @@ const BillingAddress = ({ cart }: { cart: HttpTypes.StoreCart | null }) => {
|
||||
data-testid="billing-first-name-input"
|
||||
/>
|
||||
<Input
|
||||
label="Prezime"
|
||||
label="Last name"
|
||||
name="billing_address.last_name"
|
||||
autoComplete="family-name"
|
||||
value={formData["billing_address.last_name"]}
|
||||
@@ -49,7 +49,7 @@ const BillingAddress = ({ cart }: { cart: HttpTypes.StoreCart | null }) => {
|
||||
data-testid="billing-last-name-input"
|
||||
/>
|
||||
<Input
|
||||
label="Adresa"
|
||||
label="Address"
|
||||
name="billing_address.address_1"
|
||||
autoComplete="address-line1"
|
||||
value={formData["billing_address.address_1"]}
|
||||
@@ -58,7 +58,7 @@ const BillingAddress = ({ cart }: { cart: HttpTypes.StoreCart | null }) => {
|
||||
data-testid="billing-address-input"
|
||||
/>
|
||||
<Input
|
||||
label="Firma"
|
||||
label="Company"
|
||||
name="billing_address.company"
|
||||
value={formData["billing_address.company"]}
|
||||
onChange={handleChange}
|
||||
@@ -66,7 +66,7 @@ const BillingAddress = ({ cart }: { cart: HttpTypes.StoreCart | null }) => {
|
||||
data-testid="billing-company-input"
|
||||
/>
|
||||
<Input
|
||||
label="Poštanski broj"
|
||||
label="Postal code"
|
||||
name="billing_address.postal_code"
|
||||
autoComplete="postal-code"
|
||||
value={formData["billing_address.postal_code"]}
|
||||
@@ -75,7 +75,7 @@ const BillingAddress = ({ cart }: { cart: HttpTypes.StoreCart | null }) => {
|
||||
data-testid="billing-postal-input"
|
||||
/>
|
||||
<Input
|
||||
label="Grad"
|
||||
label="City"
|
||||
name="billing_address.city"
|
||||
autoComplete="address-level2"
|
||||
value={formData["billing_address.city"]}
|
||||
@@ -91,7 +91,7 @@ const BillingAddress = ({ cart }: { cart: HttpTypes.StoreCart | null }) => {
|
||||
data-testid="billing-country-select"
|
||||
/>
|
||||
<Input
|
||||
label="Kanton / entitet"
|
||||
label="State / Province"
|
||||
name="billing_address.province"
|
||||
autoComplete="address-level1"
|
||||
value={formData["billing_address.province"]}
|
||||
@@ -99,7 +99,7 @@ const BillingAddress = ({ cart }: { cart: HttpTypes.StoreCart | null }) => {
|
||||
data-testid="billing-province-input"
|
||||
/>
|
||||
<Input
|
||||
label="Telefon"
|
||||
label="Phone"
|
||||
name="billing_address.phone"
|
||||
autoComplete="tel"
|
||||
value={formData["billing_address.phone"]}
|
||||
|
||||
@@ -10,7 +10,7 @@ const CountrySelect = forwardRef<
|
||||
NativeSelectProps & {
|
||||
region?: HttpTypes.StoreRegion
|
||||
}
|
||||
>(({ placeholder = "Država", region, defaultValue, ...props }, ref) => {
|
||||
>(({ placeholder = "Country", region, defaultValue, ...props }, ref) => {
|
||||
const innerRef = useRef<HTMLSelectElement>(null)
|
||||
|
||||
useImperativeHandle<HTMLSelectElement | null, HTMLSelectElement | null>(
|
||||
|
||||
@@ -130,7 +130,7 @@ const AdyenPaymentButton = ({
|
||||
}
|
||||
|
||||
mount().catch(() => {
|
||||
setErrorMessage("Načini plaćanja se nisu mogli učitati.")
|
||||
setErrorMessage("Could not load the payment methods.")
|
||||
})
|
||||
|
||||
return () => {
|
||||
@@ -144,7 +144,7 @@ const AdyenPaymentButton = ({
|
||||
if (notReady) {
|
||||
return (
|
||||
<Button disabled size="large" data-testid={dataTestId}>
|
||||
Potvrdi narudžbu
|
||||
Place order
|
||||
</Button>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ const PaymentButton: React.FC<PaymentButtonProps> = ({
|
||||
<ManualTestPaymentButton notReady={notReady} data-testid={dataTestId} />
|
||||
)
|
||||
default:
|
||||
return <Button disabled>Odaberite način plaćanja</Button>
|
||||
return <Button disabled>Select a payment method</Button>
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,7 +160,7 @@ const StripePaymentButton = ({
|
||||
isLoading={submitting}
|
||||
data-testid={dataTestId}
|
||||
>
|
||||
Potvrdi narudžbu
|
||||
Place order
|
||||
</Button>
|
||||
<ErrorMessage
|
||||
error={errorMessage}
|
||||
@@ -199,7 +199,7 @@ const ManualTestPaymentButton = ({ notReady }: { notReady: boolean }) => {
|
||||
size="large"
|
||||
data-testid="submit-order-button"
|
||||
>
|
||||
Potvrdi narudžbu
|
||||
Place order
|
||||
</Button>
|
||||
<ErrorMessage
|
||||
error={errorMessage}
|
||||
|
||||
@@ -33,9 +33,9 @@ const PaymentContainer: React.FC<PaymentContainerProps> = ({
|
||||
value={paymentProviderId}
|
||||
disabled={disabled}
|
||||
className={clx(
|
||||
"flex flex-col gap-y-2 text-sm cursor-pointer py-4 border rounded-rounded px-8 mb-2 hover:border-primary",
|
||||
"flex flex-col gap-y-2 text-small-regular cursor-pointer py-4 border rounded-rounded px-8 mb-2 hover:shadow-borders-interactive-with-active",
|
||||
{
|
||||
"border-primary":
|
||||
"border-ui-border-interactive":
|
||||
selectedPaymentOptionId === paymentProviderId,
|
||||
}
|
||||
)}
|
||||
@@ -43,19 +43,19 @@ const PaymentContainer: React.FC<PaymentContainerProps> = ({
|
||||
<div className="flex items-center justify-between ">
|
||||
<div className="flex items-center gap-x-4">
|
||||
<Radio checked={selectedPaymentOptionId === paymentProviderId} />
|
||||
<Text className="text-base">
|
||||
<Text className="text-base-regular">
|
||||
{paymentInfo?.title || paymentProviderId}
|
||||
</Text>
|
||||
{isManual(paymentProviderId) && isDevelopment && (
|
||||
<PaymentTest className="hidden lg:block" />
|
||||
<PaymentTest className="hidden small:block" />
|
||||
)}
|
||||
</div>
|
||||
<span className="justify-self-end text-foreground">
|
||||
<span className="justify-self-end text-ui-fg-base">
|
||||
{paymentInfo?.icon}
|
||||
</span>
|
||||
</div>
|
||||
{isManual(paymentProviderId) && isDevelopment && (
|
||||
<PaymentTest className="lg:hidden text-[10px]" />
|
||||
<PaymentTest className="small:hidden text-[10px]" />
|
||||
)}
|
||||
{children}
|
||||
</RadioGroupOption>
|
||||
@@ -85,8 +85,8 @@ export const StripePaymentContainer = ({
|
||||
{selectedPaymentOptionId === paymentProviderId &&
|
||||
(stripeReady ? (
|
||||
<div className="my-4 transition-all duration-150 ease-in-out">
|
||||
<Text className="text-sm font-medium text-foreground mb-1">
|
||||
Unesite podatke za plaćanje:
|
||||
<Text className="txt-medium-plus text-ui-fg-base mb-1">
|
||||
Enter your payment details:
|
||||
</Text>
|
||||
<PaymentElement
|
||||
options={{ layout: "accordion" }}
|
||||
@@ -102,7 +102,7 @@ export const StripePaymentContainer = ({
|
||||
setPaymentComplete(false)
|
||||
setError(
|
||||
getPaymentErrorMessage(e.error) ??
|
||||
"Načini plaćanja se nisu mogli učitati."
|
||||
"Could not load the payment methods."
|
||||
)
|
||||
}}
|
||||
/>
|
||||
|
||||
@@ -3,7 +3,7 @@ import { Badge } from "@modules/common/components/ui"
|
||||
const PaymentTest = ({ className }: { className?: string }) => {
|
||||
return (
|
||||
<Badge color="orange" className={className}>
|
||||
<span className="font-semibold">Pažnja:</span> For testing purposes
|
||||
<span className="font-semibold">Attention:</span> For testing purposes
|
||||
only.
|
||||
</Badge>
|
||||
)
|
||||
|
||||
@@ -116,24 +116,24 @@ const Payment = ({
|
||||
<Heading
|
||||
level="h2"
|
||||
className={clx(
|
||||
"flex flex-row font-display text-3xl gap-x-2 items-baseline",
|
||||
"flex flex-row text-3xl-regular gap-x-2 items-baseline",
|
||||
{
|
||||
"opacity-50 pointer-events-none select-none":
|
||||
!isOpen && !paymentReady,
|
||||
}
|
||||
)}
|
||||
>
|
||||
Plaćanje
|
||||
Payment
|
||||
{!isOpen && paymentReady && <CheckCircleSolid />}
|
||||
</Heading>
|
||||
{!isOpen && paymentReady && (
|
||||
<Text>
|
||||
<button
|
||||
onClick={handleEdit}
|
||||
className="text-primary hover:text-primary/80"
|
||||
className="text-ui-fg-interactive hover:text-ui-fg-interactive-hover"
|
||||
data-testid="edit-payment-button"
|
||||
>
|
||||
Izmijeni
|
||||
Edit
|
||||
</button>
|
||||
</Text>
|
||||
)}
|
||||
@@ -169,14 +169,14 @@ const Payment = ({
|
||||
|
||||
{paidByGiftcard && (
|
||||
<div className="flex flex-col w-1/3">
|
||||
<Text className="text-sm font-medium text-foreground mb-1">
|
||||
Način plaćanja
|
||||
<Text className="txt-medium-plus text-ui-fg-base mb-1">
|
||||
Payment method
|
||||
</Text>
|
||||
<Text
|
||||
className="text-sm text-muted-foreground"
|
||||
className="txt-medium text-ui-fg-subtle"
|
||||
data-testid="payment-method-summary"
|
||||
>
|
||||
Poklon kartica
|
||||
Gift card
|
||||
</Text>
|
||||
</div>
|
||||
)}
|
||||
@@ -198,8 +198,8 @@ const Payment = ({
|
||||
data-testid="submit-payment-button"
|
||||
>
|
||||
{!activeSession && isStripeLike(selectedPaymentMethod)
|
||||
? "Unesite podatke za plaćanje"
|
||||
: "Nastavite na pregled"}
|
||||
? "Enter payment details"
|
||||
: "Continue to review"}
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
@@ -207,11 +207,11 @@ const Payment = ({
|
||||
{cart && paymentReady && activeSession ? (
|
||||
<div className="flex items-start gap-x-1 w-full">
|
||||
<div className="flex flex-col w-1/3">
|
||||
<Text className="text-sm font-medium text-foreground mb-1">
|
||||
Način plaćanja
|
||||
<Text className="txt-medium-plus text-ui-fg-base mb-1">
|
||||
Payment method
|
||||
</Text>
|
||||
<Text
|
||||
className="text-sm text-muted-foreground"
|
||||
className="txt-medium text-ui-fg-subtle"
|
||||
data-testid="payment-method-summary"
|
||||
>
|
||||
{getPaymentInfo(activeSession?.provider_id)?.title ||
|
||||
@@ -219,14 +219,14 @@ const Payment = ({
|
||||
</Text>
|
||||
</div>
|
||||
<div className="flex flex-col w-1/3">
|
||||
<Text className="text-sm font-medium text-foreground mb-1">
|
||||
Podaci o plaćanju
|
||||
<Text className="txt-medium-plus text-ui-fg-base mb-1">
|
||||
Payment details
|
||||
</Text>
|
||||
<div
|
||||
className="flex gap-2 text-sm text-muted-foreground items-center"
|
||||
className="flex gap-2 txt-medium text-ui-fg-subtle items-center"
|
||||
data-testid="payment-details-summary"
|
||||
>
|
||||
<Container className="flex items-center h-7 w-fit p-2 bg-muted">
|
||||
<Container className="flex items-center h-7 w-fit p-2 bg-ui-button-neutral-hover">
|
||||
{getPaymentInfo(selectedPaymentMethod)?.icon || (
|
||||
<CreditCard />
|
||||
)}
|
||||
@@ -237,14 +237,14 @@ const Payment = ({
|
||||
</div>
|
||||
) : paidByGiftcard ? (
|
||||
<div className="flex flex-col w-1/3">
|
||||
<Text className="text-sm font-medium text-foreground mb-1">
|
||||
Način plaćanja
|
||||
<Text className="txt-medium-plus text-ui-fg-base mb-1">
|
||||
Payment method
|
||||
</Text>
|
||||
<Text
|
||||
className="text-sm text-muted-foreground"
|
||||
className="txt-medium text-ui-fg-subtle"
|
||||
data-testid="payment-method-summary"
|
||||
>
|
||||
Poklon kartica
|
||||
Gift card
|
||||
</Text>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
@@ -26,23 +26,24 @@ const Review = ({ cart }: { cart: HttpTypes.StoreCart }) => {
|
||||
<Heading
|
||||
level="h2"
|
||||
className={clx(
|
||||
"flex flex-row font-display text-3xl gap-x-2 items-baseline",
|
||||
"flex flex-row text-3xl-regular gap-x-2 items-baseline",
|
||||
{
|
||||
"opacity-50 pointer-events-none select-none": !isOpen,
|
||||
}
|
||||
)}
|
||||
>
|
||||
Pregled
|
||||
Review
|
||||
</Heading>
|
||||
</div>
|
||||
{isOpen && previousStepsCompleted && (
|
||||
<>
|
||||
<div className="flex items-start gap-x-1 w-full mb-6">
|
||||
<div className="w-full">
|
||||
<Text className="text-sm font-medium text-foreground mb-1">
|
||||
Klikom na „Potvrdi narudžbu“ potvrđujete da ste pročitali i
|
||||
prihvatate uslove poslovanja i pravila o povratu robe, te da ste
|
||||
upoznati s politikom privatnosti Suman d.o.o.
|
||||
<Text className="txt-medium-plus text-ui-fg-base mb-1">
|
||||
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.
|
||||
</Text>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -108,7 +108,7 @@ const ShippingAddress = ({
|
||||
<>
|
||||
{customer && (addressesInRegion?.length || 0) > 0 && (
|
||||
<Container className="mb-6 flex flex-col gap-y-4 p-5">
|
||||
<p className="text-sm">
|
||||
<p className="text-small-regular">
|
||||
{`Hi ${customer.first_name}, do you want to use one of your saved addresses?`}
|
||||
</p>
|
||||
<AddressSelect
|
||||
@@ -124,7 +124,7 @@ const ShippingAddress = ({
|
||||
)}
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<Input
|
||||
label="Ime"
|
||||
label="First name"
|
||||
name="shipping_address.first_name"
|
||||
autoComplete="given-name"
|
||||
value={formData["shipping_address.first_name"]}
|
||||
@@ -133,7 +133,7 @@ const ShippingAddress = ({
|
||||
data-testid="shipping-first-name-input"
|
||||
/>
|
||||
<Input
|
||||
label="Prezime"
|
||||
label="Last name"
|
||||
name="shipping_address.last_name"
|
||||
autoComplete="family-name"
|
||||
value={formData["shipping_address.last_name"]}
|
||||
@@ -142,7 +142,7 @@ const ShippingAddress = ({
|
||||
data-testid="shipping-last-name-input"
|
||||
/>
|
||||
<Input
|
||||
label="Adresa"
|
||||
label="Address"
|
||||
name="shipping_address.address_1"
|
||||
autoComplete="address-line1"
|
||||
value={formData["shipping_address.address_1"]}
|
||||
@@ -151,7 +151,7 @@ const ShippingAddress = ({
|
||||
data-testid="shipping-address-input"
|
||||
/>
|
||||
<Input
|
||||
label="Firma"
|
||||
label="Company"
|
||||
name="shipping_address.company"
|
||||
value={formData["shipping_address.company"]}
|
||||
onChange={handleChange}
|
||||
@@ -186,7 +186,7 @@ const ShippingAddress = ({
|
||||
)}
|
||||
</div>
|
||||
<Input
|
||||
label="Poštanski broj"
|
||||
label="Postal code"
|
||||
name="shipping_address.postal_code"
|
||||
autoComplete="postal-code"
|
||||
value={formData["shipping_address.postal_code"]}
|
||||
@@ -195,7 +195,7 @@ const ShippingAddress = ({
|
||||
data-testid="shipping-postal-code-input"
|
||||
/>
|
||||
<Input
|
||||
label="Grad"
|
||||
label="City"
|
||||
name="shipping_address.city"
|
||||
autoComplete="address-level2"
|
||||
value={formData["shipping_address.city"]}
|
||||
@@ -213,7 +213,7 @@ const ShippingAddress = ({
|
||||
data-testid="shipping-country-select"
|
||||
/>
|
||||
<Input
|
||||
label="Kanton / entitet"
|
||||
label="State / Province"
|
||||
name="shipping_address.province"
|
||||
autoComplete="address-level1"
|
||||
value={formData["shipping_address.province"]}
|
||||
@@ -223,7 +223,7 @@ const ShippingAddress = ({
|
||||
</div>
|
||||
<div className="my-8">
|
||||
<Checkbox
|
||||
label="Adresa za račun ista je kao adresa dostave"
|
||||
label="Billing address same as shipping address"
|
||||
name="same_as_billing"
|
||||
checked={checked}
|
||||
onChange={onChange}
|
||||
@@ -235,7 +235,7 @@ const ShippingAddress = ({
|
||||
label="Email"
|
||||
name="email"
|
||||
type="email"
|
||||
title="Unesite ispravnu email adresu."
|
||||
title="Enter a valid email address."
|
||||
autoComplete="email"
|
||||
value={formData.email}
|
||||
onChange={handleChange}
|
||||
@@ -243,7 +243,7 @@ const ShippingAddress = ({
|
||||
data-testid="shipping-email-input"
|
||||
/>
|
||||
<Input
|
||||
label="Telefon"
|
||||
label="Phone"
|
||||
name="shipping_address.phone"
|
||||
autoComplete="tel"
|
||||
value={formData["shipping_address.phone"]}
|
||||
|
||||
@@ -157,14 +157,14 @@ const Shipping: React.FC<ShippingProps> = ({
|
||||
<Heading
|
||||
level="h2"
|
||||
className={clx(
|
||||
"flex flex-row font-display text-3xl gap-x-2 items-baseline",
|
||||
"flex flex-row text-3xl-regular gap-x-2 items-baseline",
|
||||
{
|
||||
"opacity-50 pointer-events-none select-none":
|
||||
!isOpen && cart.shipping_methods?.length === 0,
|
||||
}
|
||||
)}
|
||||
>
|
||||
Dostava
|
||||
Delivery
|
||||
{!isOpen && (cart.shipping_methods?.length ?? 0) > 0 && (
|
||||
<CheckCircleSolid />
|
||||
)}
|
||||
@@ -176,10 +176,10 @@ const Shipping: React.FC<ShippingProps> = ({
|
||||
<Text>
|
||||
<button
|
||||
onClick={handleEdit}
|
||||
className="text-primary hover:text-primary/80"
|
||||
className="text-ui-fg-interactive hover:text-ui-fg-interactive-hover"
|
||||
data-testid="edit-delivery-button"
|
||||
>
|
||||
Izmijeni
|
||||
Edit
|
||||
</button>
|
||||
</Text>
|
||||
)}
|
||||
@@ -188,11 +188,11 @@ const Shipping: React.FC<ShippingProps> = ({
|
||||
<>
|
||||
<div className="grid">
|
||||
<div className="flex flex-col">
|
||||
<span className="font-medium text-sm text-foreground">
|
||||
Način dostave
|
||||
<span className="font-medium txt-medium text-ui-fg-base">
|
||||
Shipping method
|
||||
</span>
|
||||
<span className="mb-4 text-muted-foreground text-sm">
|
||||
Kako želite da vam isporučimo narudžbu
|
||||
<span className="mb-4 text-ui-fg-muted txt-medium">
|
||||
How would you like you order delivered
|
||||
</span>
|
||||
</div>
|
||||
<div data-testid="delivery-options-container">
|
||||
@@ -214,9 +214,9 @@ const Shipping: React.FC<ShippingProps> = ({
|
||||
value={PICKUP_OPTION_ON}
|
||||
data-testid="delivery-option-radio"
|
||||
className={clx(
|
||||
"flex items-center justify-between text-sm cursor-pointer py-4 border rounded-rounded px-8 mb-2 hover:border-primary",
|
||||
"flex items-center justify-between text-small-regular cursor-pointer py-4 border rounded-rounded px-8 mb-2 hover:shadow-borders-interactive-with-active",
|
||||
{
|
||||
"border-primary":
|
||||
"border-ui-border-interactive":
|
||||
showPickupOptions === PICKUP_OPTION_ON,
|
||||
}
|
||||
)}
|
||||
@@ -225,11 +225,11 @@ const Shipping: React.FC<ShippingProps> = ({
|
||||
<MedusaRadio
|
||||
checked={showPickupOptions === PICKUP_OPTION_ON}
|
||||
/>
|
||||
<span className="text-base">
|
||||
Preuzmite narudžbu lično
|
||||
<span className="text-base-regular">
|
||||
Pick up your order
|
||||
</span>
|
||||
</div>
|
||||
<span className="justify-self-end text-foreground">
|
||||
<span className="justify-self-end text-ui-fg-base">
|
||||
-
|
||||
</span>
|
||||
</Radio>
|
||||
@@ -256,9 +256,9 @@ const Shipping: React.FC<ShippingProps> = ({
|
||||
data-testid="delivery-option-radio"
|
||||
disabled={isDisabled}
|
||||
className={clx(
|
||||
"flex items-center justify-between text-sm cursor-pointer py-4 border rounded-rounded px-8 mb-2 hover:border-primary",
|
||||
"flex items-center justify-between text-small-regular cursor-pointer py-4 border rounded-rounded px-8 mb-2 hover:shadow-borders-interactive-with-active",
|
||||
{
|
||||
"border-primary":
|
||||
"border-ui-border-interactive":
|
||||
option.id === shippingMethodId,
|
||||
"hover:shadow-brders-none cursor-not-allowed":
|
||||
isDisabled,
|
||||
@@ -269,11 +269,11 @@ const Shipping: React.FC<ShippingProps> = ({
|
||||
<MedusaRadio
|
||||
checked={option.id === shippingMethodId}
|
||||
/>
|
||||
<span className="text-base">
|
||||
<span className="text-base-regular">
|
||||
{option.name}
|
||||
</span>
|
||||
</div>
|
||||
<span className="justify-self-end text-foreground">
|
||||
<span className="justify-self-end text-ui-fg-base">
|
||||
{option.price_type === "flat" ? (
|
||||
convertToLocale({
|
||||
amount: option.amount!,
|
||||
@@ -301,11 +301,11 @@ const Shipping: React.FC<ShippingProps> = ({
|
||||
{showPickupOptions === PICKUP_OPTION_ON && (
|
||||
<div className="grid">
|
||||
<div className="flex flex-col">
|
||||
<span className="font-medium text-sm text-foreground">
|
||||
Prodajno mjesto
|
||||
<span className="font-medium txt-medium text-ui-fg-base">
|
||||
Store
|
||||
</span>
|
||||
<span className="mb-4 text-muted-foreground text-sm">
|
||||
Odaberite najbliže prodajno mjesto
|
||||
<span className="mb-4 text-ui-fg-muted txt-medium">
|
||||
Choose a store near you
|
||||
</span>
|
||||
</div>
|
||||
<div data-testid="delivery-options-container">
|
||||
@@ -326,9 +326,9 @@ const Shipping: React.FC<ShippingProps> = ({
|
||||
disabled={option.insufficient_inventory}
|
||||
data-testid="delivery-option-radio"
|
||||
className={clx(
|
||||
"flex items-center justify-between text-sm cursor-pointer py-4 border rounded-rounded px-8 mb-2 hover:border-primary",
|
||||
"flex items-center justify-between text-small-regular cursor-pointer py-4 border rounded-rounded px-8 mb-2 hover:shadow-borders-interactive-with-active",
|
||||
{
|
||||
"border-primary":
|
||||
"border-ui-border-interactive":
|
||||
option.id === shippingMethodId,
|
||||
"hover:shadow-brders-none cursor-not-allowed":
|
||||
option.insufficient_inventory,
|
||||
@@ -340,10 +340,10 @@ const Shipping: React.FC<ShippingProps> = ({
|
||||
checked={option.id === shippingMethodId}
|
||||
/>
|
||||
<div className="flex flex-col">
|
||||
<span className="text-base">
|
||||
<span className="text-base-regular">
|
||||
{option.name}
|
||||
</span>
|
||||
<span className="text-base text-muted-foreground">
|
||||
<span className="text-base-regular text-ui-fg-muted">
|
||||
{formatAddress(
|
||||
(option as unknown as { service_zone?: { fulfillment_set?: { location?: { address: HttpTypes.StoreCartAddress } } } }).service_zone?.fulfillment_set?.location
|
||||
?.address as HttpTypes.StoreCartAddress
|
||||
@@ -351,7 +351,7 @@ const Shipping: React.FC<ShippingProps> = ({
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<span className="justify-self-end text-foreground">
|
||||
<span className="justify-self-end text-ui-fg-base">
|
||||
{convertToLocale({
|
||||
amount: option.amount!,
|
||||
currency_code: cart?.currency_code,
|
||||
@@ -379,19 +379,19 @@ const Shipping: React.FC<ShippingProps> = ({
|
||||
disabled={!cart.shipping_methods?.[0]}
|
||||
data-testid="submit-delivery-option-button"
|
||||
>
|
||||
Nastavite na plaćanje
|
||||
Continue to payment
|
||||
</Button>
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
<div>
|
||||
<div className="text-sm">
|
||||
<div className="text-small-regular">
|
||||
{cart && (cart.shipping_methods?.length ?? 0) > 0 && (
|
||||
<div className="flex flex-col w-1/3">
|
||||
<Text className="text-sm font-medium text-foreground mb-1">
|
||||
Način
|
||||
<Text className="txt-medium-plus text-ui-fg-base mb-1">
|
||||
Method
|
||||
</Text>
|
||||
<Text className="text-sm text-muted-foreground">
|
||||
<Text className="txt-medium text-ui-fg-subtle">
|
||||
{cart.shipping_methods!.at(-1)!.name}{" "}
|
||||
{convertToLocale({
|
||||
amount: cart.shipping_methods!.at(-1)!.amount!,
|
||||
|
||||
@@ -1,24 +1,30 @@
|
||||
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 (
|
||||
<aside className="lg:sticky lg:top-24 self-start">
|
||||
<div className="rounded-2xl bg-muted p-6 sm:p-8">
|
||||
<p className="eyebrow text-muted-foreground">Vaša narudžba</p>
|
||||
<div className="mt-4">
|
||||
<ItemsPreviewTemplate cart={cart} />
|
||||
</div>
|
||||
<div className="mt-4 border-t border-border pt-6">
|
||||
<div className="sticky top-0 flex flex-col-reverse small:flex-col gap-y-8 py-8 small:py-0 ">
|
||||
<div className="w-full bg-white flex flex-col">
|
||||
<Divider className="my-6 small:hidden" />
|
||||
<Heading
|
||||
level="h2"
|
||||
className="flex flex-row text-3xl-regular items-baseline"
|
||||
>
|
||||
In your Cart
|
||||
</Heading>
|
||||
<Divider className="my-6" />
|
||||
<CartTotals totals={cart} />
|
||||
</div>
|
||||
<div className="mt-6 border-t border-border pt-6">
|
||||
<ItemsPreviewTemplate cart={cart} />
|
||||
<div className="my-6">
|
||||
<DiscountCode cart={cart} />
|
||||
</div>
|
||||
</div>
|
||||
</aside>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -24,10 +24,10 @@ export default function CollectionTemplate({
|
||||
const sort = sortBy || "created_at"
|
||||
|
||||
return (
|
||||
<div className="flex flex-col lg:flex-row lg:items-start py-6 content-container">
|
||||
<div className="flex flex-col small:flex-row small:items-start py-6 content-container">
|
||||
<RefinementList sortBy={sort} hideOptionsPicker />
|
||||
<div className="w-full">
|
||||
<div className="mb-8 font-display text-2xl">
|
||||
<div className="mb-8 text-2xl-semi">
|
||||
<h1>{collection.title}</h1>
|
||||
</div>
|
||||
<Suspense
|
||||
|
||||
@@ -73,12 +73,12 @@ const CartTotals: React.FC<CartTotalsProps> = ({ totals }) => {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Separator className="my-2" />
|
||||
<Separator className="my-1" />
|
||||
|
||||
<div className="flex items-baseline justify-between text-foreground">
|
||||
<span className="text-sm">Ukupno za uplatu</span>
|
||||
<div className="flex items-center justify-between text-foreground">
|
||||
<span className="font-semibold text-base">Ukupno za uplatu</span>
|
||||
<span
|
||||
className="font-display text-3xl tracking-tight text-foreground tabular-nums"
|
||||
className="text-xl font-extrabold text-primary"
|
||||
data-testid="cart-total"
|
||||
data-value={total || 0}
|
||||
>
|
||||
@@ -86,10 +86,10 @@ const CartTotals: React.FC<CartTotalsProps> = ({ totals }) => {
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<p className="flex items-center gap-1.5 text-xs text-muted-foreground">
|
||||
<ShieldCheck className="h-3.5 w-3.5 shrink-0" />
|
||||
Fiskalni račun i R1 faktura za firme s JIB/PDV brojem
|
||||
</p>
|
||||
<div className="mt-1 flex items-center gap-1.5 text-[11px] text-muted-foreground/90 bg-muted/40 p-2.5 rounded-lg border border-border/60">
|
||||
<ShieldCheck className="w-3.5 h-3.5 text-emerald-600 shrink-0" />
|
||||
<span>Fiskalni račun i R1 porezna faktura za firme sa JIB/PDV brojem</span>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ const CheckboxWithLabel: React.FC<CheckboxProps> = ({
|
||||
return (
|
||||
<div className="flex items-center space-x-2 ">
|
||||
<Checkbox
|
||||
className="text-base flex items-center gap-x-2"
|
||||
className="text-base-regular flex items-center gap-x-2"
|
||||
id="checkbox"
|
||||
role="checkbox"
|
||||
checked={checked}
|
||||
@@ -31,7 +31,7 @@ const CheckboxWithLabel: React.FC<CheckboxProps> = ({
|
||||
/>
|
||||
<Label
|
||||
htmlFor="checkbox"
|
||||
className="!transform-none !text-sm"
|
||||
className="!transform-none !txt-medium"
|
||||
>
|
||||
{label}
|
||||
</Label>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
"use client"
|
||||
|
||||
import { Label } from "@/components/ui/label"
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
type FilterRadioGroupProps = {
|
||||
@@ -21,46 +22,39 @@ const FilterRadioGroup = ({
|
||||
"data-testid": dataTestId,
|
||||
}: FilterRadioGroupProps) => {
|
||||
return (
|
||||
<fieldset className="flex flex-col gap-4">
|
||||
<legend className="eyebrow text-muted-foreground mb-4">{title}</legend>
|
||||
<div className="flex flex-col gap-0.5" data-testid={dataTestId}>
|
||||
<div className="flex flex-col gap-3">
|
||||
<span className="text-xs font-semibold uppercase tracking-wider text-muted-foreground">
|
||||
{title}
|
||||
</span>
|
||||
<div className="flex flex-col gap-2" data-testid={dataTestId}>
|
||||
{items?.map((item) => {
|
||||
const isSelected = item.value === value
|
||||
return (
|
||||
<label
|
||||
key={item.value}
|
||||
htmlFor={`${title}-${item.value}`}
|
||||
htmlFor={item.value}
|
||||
className={cn(
|
||||
"flex items-center gap-2.5 py-1.5 text-sm cursor-pointer transition-colors",
|
||||
"flex items-center gap-2.5 px-3 py-2 rounded-md text-sm font-medium cursor-pointer transition-colors border",
|
||||
isSelected
|
||||
? "text-foreground"
|
||||
: "text-muted-foreground hover:text-foreground"
|
||||
? "border-primary bg-primary/5 text-primary"
|
||||
: "border-transparent text-muted-foreground hover:bg-muted hover:text-foreground"
|
||||
)}
|
||||
>
|
||||
<input
|
||||
type="radio"
|
||||
id={`${title}-${item.value}`}
|
||||
id={item.value}
|
||||
name={title}
|
||||
value={item.value}
|
||||
checked={isSelected}
|
||||
onChange={() => handleChange(item.value)}
|
||||
className="sr-only peer"
|
||||
className="h-4 w-4 border-input text-primary focus:ring-ring focus:ring-offset-background"
|
||||
/>
|
||||
<span
|
||||
aria-hidden="true"
|
||||
className={cn(
|
||||
"h-1.5 w-1.5 rounded-full transition-colors",
|
||||
isSelected ? "bg-primary" : "bg-transparent"
|
||||
)}
|
||||
/>
|
||||
<span className="flex-1 select-none peer-focus-visible:underline">
|
||||
{item.label}
|
||||
</span>
|
||||
<span className="flex-1 select-none">{item.label}</span>
|
||||
</label>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -36,22 +36,22 @@ const Input = React.forwardRef<HTMLInputElement, InputProps>(
|
||||
return (
|
||||
<div className="flex flex-col w-full">
|
||||
{topLabel && (
|
||||
<Label className="mb-2 text-sm font-medium">{topLabel}</Label>
|
||||
<Label className="mb-2 txt-compact-medium-plus">{topLabel}</Label>
|
||||
)}
|
||||
<div className="flex relative z-0 w-full text-sm">
|
||||
<div className="flex relative z-0 w-full txt-compact-medium">
|
||||
<input
|
||||
type={inputType}
|
||||
name={name}
|
||||
placeholder=" "
|
||||
required={required}
|
||||
className="pt-4 pb-1 block w-full h-11 px-4 mt-0 bg-background border rounded-md appearance-none focus:outline-none focus:ring-0 focus:border-primary border-border hover:bg-muted"
|
||||
className="pt-4 pb-1 block w-full h-11 px-4 mt-0 bg-ui-bg-field border rounded-md appearance-none focus:outline-none focus:ring-0 focus:shadow-borders-interactive-with-active border-ui-border-base hover:bg-ui-bg-field-hover"
|
||||
{...props}
|
||||
ref={inputRef}
|
||||
/>
|
||||
<label
|
||||
htmlFor={name}
|
||||
onClick={() => inputRef.current?.focus()}
|
||||
className="flex items-center justify-center mx-3 px-1 transition-all absolute duration-300 top-3 -z-1 origin-0 text-muted-foreground"
|
||||
className="flex items-center justify-center mx-3 px-1 transition-all absolute duration-300 top-3 -z-1 origin-0 text-ui-fg-subtle"
|
||||
>
|
||||
{label}
|
||||
{required && <span className="text-rose-500">*</span>}
|
||||
@@ -60,7 +60,7 @@ const Input = React.forwardRef<HTMLInputElement, InputProps>(
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setShowPassword(!showPassword)}
|
||||
className="text-muted-foreground px-4 focus:outline-none transition-all duration-150 outline-none focus:text-foreground absolute right-0 top-3"
|
||||
className="text-ui-fg-subtle px-4 focus:outline-none transition-all duration-150 outline-none focus:text-ui-fg-base absolute right-0 top-3"
|
||||
>
|
||||
{showPassword ? <Eye /> : <EyeOff />}
|
||||
</button>
|
||||
|
||||
@@ -1,57 +1,25 @@
|
||||
import { HttpTypes } from "@medusajs/types"
|
||||
|
||||
type ConfigurationRow = { label: string; value: string }
|
||||
import { Text } from "@modules/common/components/ui"
|
||||
|
||||
type LineItemOptionsProps = {
|
||||
variant: HttpTypes.StoreProductVariant | undefined
|
||||
/** Line item metadata; `configuration` is written by the product configurator */
|
||||
metadata?: Record<string, unknown> | null
|
||||
"data-testid"?: string
|
||||
"data-value"?: HttpTypes.StoreProductVariant
|
||||
}
|
||||
|
||||
function getConfiguration(metadata?: Record<string, unknown> | null) {
|
||||
const rows = metadata?.configuration
|
||||
if (!Array.isArray(rows)) return null
|
||||
const valid = rows.filter(
|
||||
(r): r is ConfigurationRow =>
|
||||
typeof r?.label === "string" && typeof r?.value === "string"
|
||||
)
|
||||
return valid.length ? valid : null
|
||||
}
|
||||
|
||||
const LineItemOptions = ({
|
||||
variant,
|
||||
metadata,
|
||||
"data-testid": dataTestid,
|
||||
"data-value": dataValue,
|
||||
}: LineItemOptionsProps) => {
|
||||
const configuration = getConfiguration(metadata)
|
||||
|
||||
if (configuration) {
|
||||
return (
|
||||
<dl
|
||||
<Text
|
||||
data-testid={dataTestid}
|
||||
className="mt-0.5 space-y-0.5 text-xs text-muted-foreground"
|
||||
data-value={dataValue}
|
||||
className="inline-block txt-medium text-ui-fg-subtle w-full overflow-hidden text-ellipsis"
|
||||
>
|
||||
{configuration.map((row) => (
|
||||
<div key={`${row.label}-${row.value}`} className="flex gap-1">
|
||||
<dt>{row.label}:</dt>
|
||||
<dd className="text-foreground/80">{row.value}</dd>
|
||||
</div>
|
||||
))}
|
||||
</dl>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<span
|
||||
data-testid={dataTestid}
|
||||
data-value={dataValue ? JSON.stringify(dataValue) : undefined}
|
||||
className="inline-block w-full overflow-hidden text-ellipsis text-xs text-muted-foreground"
|
||||
>
|
||||
Varijanta: {variant?.title}
|
||||
</span>
|
||||
Variant: {variant?.title}
|
||||
</Text>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user