diff --git a/public/job/15634b64-db59-43ef-ad49-e6f4e9dd1329.jpg b/public/job/15634b64-db59-43ef-ad49-e6f4e9dd1329.jpg new file mode 100644 index 00000000..4204a23e Binary files /dev/null and b/public/job/15634b64-db59-43ef-ad49-e6f4e9dd1329.jpg differ diff --git a/src/app/api/job/gambar/[id]/route.ts b/src/app/api/job/gambar/[id]/route.ts index 63757e43..0df462d1 100644 --- a/src/app/api/job/gambar/[id]/route.ts +++ b/src/app/api/job/gambar/[id]/route.ts @@ -1,6 +1,8 @@ import prisma from "@/app/lib/prisma"; import fs from "fs"; import { NextRequest, NextResponse } from "next/server"; +import path from "path"; +const root = process.cwd(); export async function GET( req: NextRequest, @@ -15,15 +17,17 @@ export async function GET( }, }); - if (!fs.existsSync(`./public/job/${get?.url}`)) { - const notFile = fs.readFileSync("./public/aset/global/no-file.png"); + if (!fs.existsSync(path.join(root, `public/job/${get?.url}`))) { + const notFile = fs.readFileSync( + path.join(root, "public/aset/global/no-file.png") + ); return new NextResponse(notFile, { headers: { "Content-Type": "image/png", }, }); } - const file = fs.readFileSync(`./public/job/${get?.url}`); + const file = fs.readFileSync(path.join(root, `public/job/${get?.url}`)); return new NextResponse(file, { headers: { "Content-Type": "image/png", diff --git a/src/app_modules/admin/map/fun/fun_get_one_by_id.ts b/src/app_modules/admin/map/fun/fun_get_one_by_id.ts index 854c6ba2..bcb7f7c7 100644 --- a/src/app_modules/admin/map/fun/fun_get_one_by_id.ts +++ b/src/app_modules/admin/map/fun/fun_get_one_by_id.ts @@ -8,8 +8,9 @@ export async function adminMap_funGetOneById({ mapId }: { mapId: string }) { id: mapId, }, include: { + ImageMap: true, + ImagePin: true, Author: true, - Images: true, Portofolio: { include: { MasterBidangBisnis: { diff --git a/src/app_modules/job/fun/create/fun_create.ts b/src/app_modules/job/fun/create/fun_create.ts index aa0a3ae7..491eabb8 100644 --- a/src/app_modules/job/fun/create/fun_create.ts +++ b/src/app_modules/job/fun/create/fun_create.ts @@ -7,6 +7,8 @@ import { v4 } from "uuid"; import fs from "fs"; import { revalidatePath } from "next/cache"; import { MODEL_JOB } from "../../model/interface"; +import path from "path"; +const root = process.cwd(); export async function Job_funCreate(req: MODEL_JOB, file: FormData) { const authorId = await user_getOneUserId(); @@ -30,7 +32,10 @@ export async function Job_funCreate(req: MODEL_JOB, file: FormData) { if (!upload) return { status: 400, message: "Gagal upload gambar" }; const uploadFolder = Buffer.from(await dataImage.arrayBuffer()); - fs.writeFileSync(`./public/job/${upload.url}`, uploadFolder); + fs.writeFileSync( + path.join(root, `public/job/${upload.url}`), + uploadFolder + ); const createDataWithImg = await prisma.job.create({ data: { title: req.title, diff --git a/src/app_modules/map/fun/create/fun_create_pin.ts b/src/app_modules/map/fun/create/fun_create_pin.ts index ae19ddf7..f68aa22b 100644 --- a/src/app_modules/map/fun/create/fun_create_pin.ts +++ b/src/app_modules/map/fun/create/fun_create_pin.ts @@ -38,7 +38,7 @@ export async function map_funCreatePin({ data }: { data: any }) { namePin: data.namePin, portofolioId: data?.portofolioId, authorId: authorId, - imagesId: uploadImage.id, + imagesMapId: uploadImage.id, }, }); diff --git a/src/app_modules/map/fun/edit/fun_edit_map.ts b/src/app_modules/map/fun/edit/fun_edit_map.ts index bb556cf8..1c09b93e 100644 --- a/src/app_modules/map/fun/edit/fun_edit_map.ts +++ b/src/app_modules/map/fun/edit/fun_edit_map.ts @@ -47,7 +47,7 @@ export async function map_funEditMap({ latitude: data.latitude, longitude: data.longitude, namePin: data.namePin, - imagesId: uploadImage.id, + imagesMapId: uploadImage.id, }, }); diff --git a/src/app_modules/map/fun/get/fun_get_one_by_id.ts b/src/app_modules/map/fun/get/fun_get_one_by_id.ts index 9318ac74..d1455b64 100644 --- a/src/app_modules/map/fun/get/fun_get_one_by_id.ts +++ b/src/app_modules/map/fun/get/fun_get_one_by_id.ts @@ -28,7 +28,7 @@ export async function map_funGetOneById({ mapId }: { mapId: string }) { latitude: true, longitude: true, authorId: true, - imagesId: true, + imagesMapId: true, Portofolio: { select: { id: true, diff --git a/src/app_modules/map/fun/get/fun_get_one_by_portofolio_id.ts b/src/app_modules/map/fun/get/fun_get_one_by_portofolio_id.ts index 59bd0df8..3c5cc618 100644 --- a/src/app_modules/map/fun/get/fun_get_one_by_portofolio_id.ts +++ b/src/app_modules/map/fun/get/fun_get_one_by_portofolio_id.ts @@ -16,7 +16,7 @@ export async function map_funGetOneByPortofolioId({ namePin: true, latitude: true, longitude: true, - imagesId: true, + imagesMapId: true, }, });