Deskripsi;
- error url get di api
- api pada bussines map

No Issues
This commit is contained in:
amel
2024-12-09 12:02:01 +08:00
parent 1f40f06285
commit 8e4615e256
13 changed files with 497 additions and 5 deletions

View File

@@ -1,6 +1,7 @@
import { prisma } from "@/app/lib";
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
import { NextResponse } from "next/server";
export const dynamic = "force-dynamic";
// GET DATA HOME

View File

@@ -0,0 +1,76 @@
import { prisma } from "@/app/lib";
import { NextResponse } from "next/server";
export const dynamic = "force-dynamic";
export async function GET(request: Request, context: { params: { id: string } }) {
try {
const { id } = context.params
const data = await prisma.businessMaps.findUnique({
where: {
id: id,
},
select: {
namePin: true,
latitude: true,
longitude: true,
pinId: true,
imageId: true,
Author: {
select: {
Profile: {
select: {
id: true,
name: true,
imageId: true,
}
}
}
},
Portofolio: {
select: {
id: true,
alamatKantor: true,
tlpn: true,
deskripsi: true,
namaBisnis: true,
MasterBidangBisnis: {
select: {
name: true,
},
},
},
},
}
});
const dataLokasi = {
namePin: data?.namePin,
latitude: data?.latitude,
longitude: data?.longitude,
pinId: data?.pinId,
imageId: data?.imageId,
}
const dataAuthor = {
id: data?.Author?.Profile?.id,
name: data?.Author?.Profile?.name,
imageId: data?.Author?.Profile?.imageId,
}
const dataBisnis = {
id: data?.Portofolio?.id,
alamatKantor: data?.Portofolio?.alamatKantor,
tlpn: data?.Portofolio?.tlpn,
deskripsi: data?.Portofolio?.deskripsi,
namaBisnis: data?.Portofolio?.namaBisnis,
bidangBisnis: data?.Portofolio?.MasterBidangBisnis?.name,
}
return NextResponse.json({ success: true, message: "Berhasil mendapatkan data", dataLokasi, dataAuthor, dataBisnis }, { status: 200 });
}
catch (error) {
console.error(error);
return NextResponse.json({ success: false, message: "Gagal mendapatkan data, coba lagi nanti ", reason: (error as Error).message, }, { status: 500 });
}
}

View File

@@ -0,0 +1,40 @@
import { prisma } from "@/app/lib";
import _ from "lodash";
import { NextResponse } from "next/server";
export const dynamic = "force-dynamic";
// GET ALL DATA MAP
export async function GET(request: Request) {
try {
const data = await prisma.businessMaps.findMany({
where: {
isActive: true,
},
select: {
id: true,
namePin: true,
latitude: true,
longitude: true,
pinId: true,
Portofolio: {
select: {
logoId: true,
}
}
}
});
const dataFix = data.map((v: any) => ({
..._.omit(v, ["Portofolio"]),
logoId: v.Portofolio.logoId
}))
return NextResponse.json({ success: true, message: "Berhasil mendapatkan data", data: dataFix }, { status: 200 });
}
catch (error) {
console.error(error);
return NextResponse.json({ success: false, message: "Gagal mendapatkan data, coba lagi nanti ", reason: (error as Error).message, }, { status: 500 });
}
}

View File

@@ -1,6 +1,7 @@
import { prisma } from "@/app/lib";
import { NextResponse } from "next/server";
import fs from "fs";
export const dynamic = "force-dynamic";

View File

@@ -1,5 +1,6 @@
import { prisma } from "@/app/lib";
import { NextResponse } from "next/server";
export const dynamic = "force-dynamic";
// GET ALL DATA PORTOFOLIO BY PROFILE ID

View File

@@ -1,5 +1,6 @@
import { prisma } from "@/app/lib";
import { NextResponse } from "next/server";
export const dynamic = "force-dynamic";
// GET ONE DATA USER PROFILE BY PROFILE ID