upd: map
Deskripsi; - error url get di api - api pada bussines map No Issues
This commit is contained in:
@@ -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
|
||||
|
||||
76
src/app/api/new/map/[id]/route.ts
Normal file
76
src/app/api/new/map/[id]/route.ts
Normal 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 });
|
||||
}
|
||||
}
|
||||
40
src/app/api/new/map/route.ts
Normal file
40
src/app/api/new/map/route.ts
Normal 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 });
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import { prisma } from "@/app/lib";
|
||||
import { NextResponse } from "next/server";
|
||||
import fs from "fs";
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user