admin管理员组

文章数量:1123048

I am getting error during build time:

My prisma database schema code is pasted below:

generator client {
    provider = "prisma-client-js"
    binaryTargets = ["native", "linux-musl-openssl-3.0.x"]
}

datasource db {
    provider = "postgresql"
    url = env("DATABASE_URL")
}

enum ReportStatus {
    PENDING
    IN_PROGRESS
    RESOLVED
    DISMISSED
}

enum ReportType {
    EMERGENCY
    NON_EMERGENCY
}

enum Role {
    ADMIN
    MODERATOR
    USER
}

model Report {
    id          String  @id    @default(cuid())
    reportId    String  @unique
    type        ReportType
    title       String
    description String
    reportType  String
    location    String?
    latitude    String?
    longitude   String?
    image       String?
    status      ReportStatus   @default(PENDING)
    createdAt   DateTime       @default(now())
    updatedAt   DateTime       @default(now())
    @@index([reportId])
}

model User {
    id          Int     @id @default(autoincrement())
    email       String  @unique
    name        String
    password    String
    role        Role    @default(USER)
}


And the code for app/api/reports/create/route.ts pasted below:

import { NextResponse } from "next/server";
import db from "@/lib/prisma";
import { ReportType } from "@prisma/client";

export async function POST(request:Request) {
    try {
        const {
          reportId,
          type,
          specificType,
          title,
          description,
          location,
          latitude,
          longitude,
          image,
          status,
        } = await request.json();

        const report = await db.report.create({
          data: {
            reportId,
            type: type as ReportType,
            title,
            description,
            reportType: specificType,
            location,
            latitude: latitude || null,
            longitude: longitude || null,
            image: image || null,
            status: status || "PENDING",
          },
        });

        return NextResponse.json({
          success: true,
          reportId: report.reportId,
          message: "Report submitted successfully",
        });
    } catch (error) {
        console.error("Error creating report:", error);
        return NextResponse.json(
          {
            success: false,
            error: "Failed to submit report",
          },
          { status: 500 }
        );
    }
}

How to resolve the issue??

Don't understand what's the actual error, this is my first time working with prisma. Is the schema declared in a wrong way or any other mistake I made in the code, help me to find it out.

本文标签: typescriptType error Module 39quotprismaclientquot39 has no exported member 39ReportType39Stack Overflow