## Deskripsi:
- Edit map
- Sinkronisasi dengan data portofolio
### No Issue
This commit is contained in:
2024-08-15 17:46:13 +08:00
parent 059cbe6b0f
commit 34031355fe
59 changed files with 1410 additions and 342 deletions

View File

@@ -10,11 +10,9 @@ import yaml from "yaml";
const config = yaml.parse(fs.readFileSync("config.yaml").toString());
export async function POST(req: Request) {
if (req.method === "POST") {
const body = await req.json();
const data = await prisma.user.findUnique({
where: {
nomor: body.nomor,
@@ -27,7 +25,7 @@ export async function POST(req: Request) {
},
});
myConsole(data)
myConsole(data);
if (!data) return NextResponse.json({ status: 404 });
@@ -38,7 +36,7 @@ export async function POST(req: Request) {
username: data.username,
}),
{
password: (await config.server.password),
password: await config.server.password,
}
);
@@ -48,7 +46,7 @@ export async function POST(req: Request) {
maxAge: 60 * 60 * 24 * 7,
});
revalidatePath("/dev/home")
revalidatePath("/dev/home");
return NextResponse.json({ status: 200, data });
}

View File

@@ -0,0 +1,32 @@
import prisma from "@/app/lib/prisma";
import fs from "fs";
import { NextRequest, NextResponse } from "next/server";
export async function GET(
req: NextRequest,
{ params }: { params: { id: string } }
) {
const get = await prisma.images.findUnique({
where: {
id: params.id,
},
select: {
url: true,
},
});
if (!fs.existsSync(`./public/map/${get?.url}`)) {
const notFile = fs.readFileSync("./public/aset/global/no_img.png");
return new NextResponse(notFile, {
headers: {
"Content-Type": "image/png",
},
});
}
const file = fs.readFileSync(`./public/map/${get?.url}`);
return new NextResponse(file, {
headers: {
"Content-Type": "image/png",
},
});
}

View File

@@ -0,0 +1,10 @@
import { Map_CreateNewPin } from "@/app_modules/map/view";
export default async function Page({ params }: { params: { id: string } }) {
let portofolioId = params.id;
return (
<>
<Map_CreateNewPin portofolioId={portofolioId}/>
</>
);
}

View File

@@ -1,9 +0,0 @@
import { Map_CreateNewPin } from "@/app_modules/map/view";
export default async function Page() {
return (
<>
<Map_CreateNewPin />
</>
);
}

View File

@@ -0,0 +1,13 @@
import { map_funGetOneByPortofolioId } from "@/app_modules/map/fun/get/fun_get_one_by_portofolio_id";
import { Map_EditPin } from "@/app_modules/map/view";
export default async function Page({ params }: { params: { id: string } }) {
const portofolioId = params.id;
const dataMap = await map_funGetOneByPortofolioId({portofolioId: portofolioId})
return (
<>
<Map_EditPin portofolioId={portofolioId} dataMap={dataMap} />
</>
);
}

View File

@@ -1,17 +1,20 @@
import ComponentGlobal_IsEmptyData from "@/app_modules/_global/component/is_empty_data";
import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token";
import { ViewPortofolio } from "@/app_modules/katalog/portofolio";
import { portofolio_getOneById } from "@/app_modules/katalog/portofolio/fun/get/get_one_portofolio";
const mapboxToken = process.env.MAPBOX_TOKEN!;
export default async function Page({ params }: { params: { id: string } }) {
const getPorto = await portofolio_getOneById(params.id);
const userLoginId = await user_getOneUserId();
return (
<>
{/* {JSON.stringify(getPorto)} */}
{/* <pre style={{ color: "white" }}>{JSON.stringify(getPorto, null, 2)}</pre> */}
<ViewPortofolio
dataPorto={getPorto as any}
userLoginId={userLoginId as any}
mapboxToken={mapboxToken}
/>
</>
);

View File

@@ -1,5 +1,10 @@
export const RouterMap = {
// api
api_foto: "/api/map/",
// main
splash: "/dev/map/splash",
main_view: "/dev/map/main",
create: "/dev/map/create",
create: "/dev/map/create/",
edit: "/dev/map/edit/",
};