Refactor product page and improve type safety in Footer and Header components

- Updated the product page to filter size options, ensuring only string types are included.
- Modified Footer and Header components to allow nullable types for phone, email, whatsapp, and footerText properties.
- Enhanced Dockerfile to optimize dependency installation and build process using Turbo for improved performance.
This commit is contained in:
Maxim Snesarev 2026-04-02 22:39:37 +03:00
parent 07685f5409
commit 1c5cb18d30
4 changed files with 23 additions and 23 deletions

View File

@ -109,7 +109,7 @@ export default async function ProductPage({ params }: ProductPageProps) {
});
const sizeOptions: string[] = Array.isArray(product.sizeOptions)
? product.sizeOptions
? product.sizeOptions.filter((s): s is string => typeof s === "string")
: [];
const specs: { label: string; value: string }[] = [];

View File

@ -4,10 +4,10 @@ import config from "@payload-config";
export async function Footer() {
let settings: {
phone?: string;
email?: string;
whatsapp?: string;
footerText?: string;
phone?: string | null;
email?: string | null;
whatsapp?: string | null;
footerText?: string | null;
} = {};
try {
const payload = await getPayload({ config });

View File

@ -4,7 +4,7 @@ import config from "@payload-config";
import { MobileMenu } from "./MobileMenu";
export async function Header() {
let settings: { phone?: string } = {};
let settings: { phone?: string | null } = {};
try {
const payload = await getPayload({ config });
settings = await payload.findGlobal({ slug: "site-settings" });

View File

@ -1,24 +1,24 @@
FROM node:22-alpine AS base
RUN apk add --no-cache libc6-compat
RUN corepack enable && corepack prepare pnpm@10 --activate
WORKDIR /app
# Install dependencies
FROM base AS deps
COPY pnpm-lock.yaml pnpm-workspace.yaml package.json ./
COPY apps/web/package.json apps/web/package.json
COPY packages/shared/package.json packages/shared/package.json
COPY packages/tsconfig/package.json packages/tsconfig/package.json
COPY packages/eslint-config/package.json packages/eslint-config/package.json
# Prune the monorepo for only the packages @advdoors/web needs
FROM base AS pruner
RUN pnpm add -g turbo@^2
COPY . .
RUN turbo prune @advdoors/web --docker
# Install dependencies using the pruned lockfile (cached unless deps change)
FROM base AS builder
COPY --from=pruner /app/out/json/ .
COPY --from=pruner /app/out/pnpm-lock.yaml ./pnpm-lock.yaml
RUN pnpm install --frozen-lockfile
# Build
FROM base AS builder
COPY --from=deps /app/node_modules ./node_modules
COPY --from=deps /app/apps/web/node_modules ./apps/web/node_modules
COPY --from=deps /app/packages ./packages
COPY . .
# Copy pruned source and build via Turbo
COPY --from=pruner /app/out/full/ .
ENV NEXT_TELEMETRY_DISABLED=1
RUN pnpm --filter @advdoors/web build
RUN pnpm turbo build --filter=@advdoors/web
# Production
FROM base AS runner
@ -28,9 +28,9 @@ ENV NEXT_TELEMETRY_DISABLED=1
RUN addgroup --system --gid 1001 nodejs && \
adduser --system --uid 1001 nextjs
COPY --from=builder /app/apps/web/.next/standalone ./
COPY --from=builder /app/apps/web/.next/static ./apps/web/.next/static
COPY --from=builder /app/apps/web/public ./apps/web/public
COPY --from=builder --chown=nextjs:nodejs /app/apps/web/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/apps/web/.next/static ./apps/web/.next/static
COPY --from=builder --chown=nextjs:nodejs /app/apps/web/public ./apps/web/public
USER nextjs
EXPOSE 3000