Update Versi 1.5.27 #32
@@ -3,38 +3,50 @@ 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,
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
try {
|
||||
const data = await prisma.businessMaps.findMany({
|
||||
where: {
|
||||
isActive: true,
|
||||
Portofolio: {
|
||||
NOT: {
|
||||
logoId: null,
|
||||
},
|
||||
},
|
||||
},
|
||||
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
|
||||
}))
|
||||
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 });
|
||||
}
|
||||
}
|
||||
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 }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,10 +35,10 @@ export function ComponentMap_DetailData({
|
||||
const [openModal, setOpenModal] = useState(false);
|
||||
|
||||
useShallowEffect(() => {
|
||||
onLoadData(setData, setDataUser);
|
||||
}, [setData, setDataUser]);
|
||||
onLoadData();
|
||||
}, []);
|
||||
|
||||
async function onLoadData(setData: any, setDataUser: any) {
|
||||
async function onLoadData() {
|
||||
const res: any = await map_funGetOneById({ mapId: mapId });
|
||||
setData(res);
|
||||
setDataUser(res.Author);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"use client";
|
||||
import { APIs } from "@/lib";
|
||||
import { AccentColor } from "@/app_modules/_global/color/color_pallet";
|
||||
import ComponentGlobal_IsEmptyData from "@/app_modules/_global/component/is_empty_data";
|
||||
import { APIs } from "@/lib";
|
||||
import { Avatar, Loader, Stack } from "@mantine/core";
|
||||
import { useShallowEffect } from "@mantine/hooks";
|
||||
import "mapbox-gl/dist/mapbox-gl.css";
|
||||
@@ -64,7 +64,7 @@ export function UiMap_MapBoxViewNew({ mapboxToken, }: { mapboxToken: string }) {
|
||||
}}
|
||||
attributionControl={false}
|
||||
>
|
||||
{data.map((e, i) => (
|
||||
{data?.map((e, i) => (
|
||||
<Stack key={i}>
|
||||
<Marker
|
||||
style={{
|
||||
|
||||
Reference in New Issue
Block a user