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:
parent
07685f5409
commit
1c5cb18d30
@ -109,7 +109,7 @@ export default async function ProductPage({ params }: ProductPageProps) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const sizeOptions: string[] = Array.isArray(product.sizeOptions)
|
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 }[] = [];
|
const specs: { label: string; value: string }[] = [];
|
||||||
|
|||||||
@ -4,10 +4,10 @@ import config from "@payload-config";
|
|||||||
|
|
||||||
export async function Footer() {
|
export async function Footer() {
|
||||||
let settings: {
|
let settings: {
|
||||||
phone?: string;
|
phone?: string | null;
|
||||||
email?: string;
|
email?: string | null;
|
||||||
whatsapp?: string;
|
whatsapp?: string | null;
|
||||||
footerText?: string;
|
footerText?: string | null;
|
||||||
} = {};
|
} = {};
|
||||||
try {
|
try {
|
||||||
const payload = await getPayload({ config });
|
const payload = await getPayload({ config });
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import config from "@payload-config";
|
|||||||
import { MobileMenu } from "./MobileMenu";
|
import { MobileMenu } from "./MobileMenu";
|
||||||
|
|
||||||
export async function Header() {
|
export async function Header() {
|
||||||
let settings: { phone?: string } = {};
|
let settings: { phone?: string | null } = {};
|
||||||
try {
|
try {
|
||||||
const payload = await getPayload({ config });
|
const payload = await getPayload({ config });
|
||||||
settings = await payload.findGlobal({ slug: "site-settings" });
|
settings = await payload.findGlobal({ slug: "site-settings" });
|
||||||
|
|||||||
@ -1,24 +1,24 @@
|
|||||||
FROM node:22-alpine AS base
|
FROM node:22-alpine AS base
|
||||||
|
RUN apk add --no-cache libc6-compat
|
||||||
RUN corepack enable && corepack prepare pnpm@10 --activate
|
RUN corepack enable && corepack prepare pnpm@10 --activate
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Install dependencies
|
# Prune the monorepo for only the packages @advdoors/web needs
|
||||||
FROM base AS deps
|
FROM base AS pruner
|
||||||
COPY pnpm-lock.yaml pnpm-workspace.yaml package.json ./
|
RUN pnpm add -g turbo@^2
|
||||||
COPY apps/web/package.json apps/web/package.json
|
COPY . .
|
||||||
COPY packages/shared/package.json packages/shared/package.json
|
RUN turbo prune @advdoors/web --docker
|
||||||
COPY packages/tsconfig/package.json packages/tsconfig/package.json
|
|
||||||
COPY packages/eslint-config/package.json packages/eslint-config/package.json
|
# 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
|
RUN pnpm install --frozen-lockfile
|
||||||
|
|
||||||
# Build
|
# Copy pruned source and build via Turbo
|
||||||
FROM base AS builder
|
COPY --from=pruner /app/out/full/ .
|
||||||
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 . .
|
|
||||||
ENV NEXT_TELEMETRY_DISABLED=1
|
ENV NEXT_TELEMETRY_DISABLED=1
|
||||||
RUN pnpm --filter @advdoors/web build
|
RUN pnpm turbo build --filter=@advdoors/web
|
||||||
|
|
||||||
# Production
|
# Production
|
||||||
FROM base AS runner
|
FROM base AS runner
|
||||||
@ -28,9 +28,9 @@ ENV NEXT_TELEMETRY_DISABLED=1
|
|||||||
RUN addgroup --system --gid 1001 nodejs && \
|
RUN addgroup --system --gid 1001 nodejs && \
|
||||||
adduser --system --uid 1001 nextjs
|
adduser --system --uid 1001 nextjs
|
||||||
|
|
||||||
COPY --from=builder /app/apps/web/.next/standalone ./
|
COPY --from=builder --chown=nextjs:nodejs /app/apps/web/.next/standalone ./
|
||||||
COPY --from=builder /app/apps/web/.next/static ./apps/web/.next/static
|
COPY --from=builder --chown=nextjs:nodejs /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/public ./apps/web/public
|
||||||
|
|
||||||
USER nextjs
|
USER nextjs
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user