fix: update quotes route to use checkAuth, fix zod type errors

Replace getCurrentUser import with checkAuth in quotes API route.
Fix z.coerce.number() type mismatch with zodResolver in calculator
forms by using z.number() directly.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
mikl0s 2026-02-22 22:01:36 +00:00
parent 3816e5e2e8
commit 3a54ba40d3
3 changed files with 9 additions and 9 deletions

View file

@ -1,11 +1,11 @@
import { NextRequest, NextResponse } from "next/server"
import { getAllQuotes, updateQuoteStatus, type QuoteStatus } from "@/lib/db"
import { getCurrentUser } from "@/lib/auth"
import { checkAuth } from "@/lib/auth"
export async function GET() {
try {
const user = await getCurrentUser()
if (!user) {
const { authenticated } = await checkAuth()
if (!authenticated) {
return NextResponse.json({ error: "Ikke autoriseret" }, { status: 401 })
}
@ -18,8 +18,8 @@ export async function GET() {
export async function PATCH(request: NextRequest) {
try {
const user = await getCurrentUser()
if (!user) {
const { authenticated } = await checkAuth()
if (!authenticated) {
return NextResponse.json({ error: "Ikke autoriseret" }, { status: 401 })
}

View file

@ -37,11 +37,11 @@ const formSchema = z.object({
.length(4, "Postnummer skal være 4 cifre")
.refine(validateDanishPostalCode, "Ugyldigt dansk postnummer"),
address: z.string().optional(),
area: z.coerce
area: z
.number()
.min(CONSTRAINTS.MIN_AREA, `Minimum areal er ${CONSTRAINTS.MIN_AREA}`)
.max(CONSTRAINTS.MAX_AREA, `Maximum areal er ${CONSTRAINTS.MAX_AREA}`),
height: z.coerce
height: z
.number()
.min(CONSTRAINTS.MIN_HEIGHT, `Minimum højde er ${CONSTRAINTS.MIN_HEIGHT} cm`)
.max(CONSTRAINTS.MAX_HEIGHT, `Maximum højde er ${CONSTRAINTS.MAX_HEIGHT} cm`),

View file

@ -37,11 +37,11 @@ const formSchema = z.object({
.length(4, "Postnummer skal være 4 cifre")
.refine(validateDanishPostalCode, "Vi dækker desværre ikke dette område"),
address: z.string().optional(),
area: z.coerce
area: z
.number()
.min(CONSTRAINTS.MIN_AREA, `Minimum ${CONSTRAINTS.MIN_AREA}`)
.max(CONSTRAINTS.MAX_AREA, `Maximum ${CONSTRAINTS.MAX_AREA}`),
height: z.coerce
height: z
.number()
.min(CONSTRAINTS.MIN_HEIGHT, `Minimum ${CONSTRAINTS.MIN_HEIGHT} cm`)
.max(CONSTRAINTS.MAX_HEIGHT, `Maximum ${CONSTRAINTS.MAX_HEIGHT} cm`),