fix portofolio

deskripsi:
- edit data portofolio
This commit is contained in:
2025-02-12 17:07:59 +08:00
parent dbeab7aa22
commit 94a1ccd6d7
8 changed files with 410 additions and 191 deletions

View File

@@ -1,7 +1,131 @@
import { prisma } from "@/lib";
import backendLogger from "@/util/backendLogger";
import { NextResponse } from "next/server";
export { POST };
export { GET, POST, PUT };
async function GET(request: Request, { params }: { params: { id: string } }) {
try {
const { id } = params;
const data = await prisma.portofolio.findUnique({
where: {
id: id,
},
include: {
MasterBidangBisnis: {
select: {
id: true,
name: true,
active: true,
},
},
Portofolio_MediaSosial: true,
Profile: {
select: {
userId: true,
User: {
select: {
id: true,
},
},
},
},
BusinessMaps: {
include: {
Author: true,
},
},
},
});
if (!data)
return NextResponse.json(
{
success: false,
message: "Data tidak ditemukan",
},
{ status: 404 }
);
return NextResponse.json(
{
success: true,
message: "Berhasil mendapatkan data",
data: data,
},
{ status: 200 }
);
} catch (error) {
backendLogger.error("API Error Get Data Portofolio", error);
return NextResponse.json(
{
success: false,
message: "API Error Get Data Potofolio",
reason: (error as Error).message,
},
{ status: 500 }
);
}
}
async function PUT(request: Request, { params }: { params: { id: string } }) {
if (request.method !== "PUT") {
return NextResponse.json(
{
success: false,
message: "Method not allowed",
},
{ status: 405 }
);
}
try {
const { id } = params;
const { data } = await request.json();
const udpateData = await prisma.portofolio.update({
where: {
id: id,
},
data: {
namaBisnis: data.namaBisnis,
alamatKantor: data.alamatKantor,
tlpn: data.tlpn,
deskripsi: data.deskripsi,
masterBidangBisnisId: data.masterBidangBisnisId,
},
});
if (!udpateData)
return NextResponse.json(
{
success: false,
message: "Gagal update data",
},
{ status: 400 }
);
return NextResponse.json(
{
success: true,
message: "Berhasil mendapatkan data",
data: udpateData,
},
{ status: 200 }
);
} catch (error) {
return NextResponse.json(
{
success: false,
message: "Error update data",
reason: (error as Error).message,
},
{ status: 500 }
);
}
}
async function POST(request: Request, { params }: { params: { id: string } }) {
if (request.method !== "POST") {

View File

@@ -18,7 +18,7 @@ export default async function Page({ params }: { params: { id: string } }) {
return (
<>
<Portofolio_EditDataBisnis dataPorto={dataPorto as any} listBidang={listBidang as any} />
<Portofolio_EditDataBisnis />
</>
);
}

View File

@@ -5,6 +5,7 @@ import {
UIGlobal_LayoutHeaderTamplate,
UIGlobal_LayoutTamplate,
} from "@/app_modules/_global/ui";
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
import { Button, Grid, Skeleton, Stack } from "@mantine/core";
import Link from "next/link";
@@ -14,100 +15,12 @@ export default function Voting_ComponentSkeletonViewPuh() {
<UIGlobal_LayoutTamplate
header={<UIGlobal_LayoutHeaderTamplate title="Skeleton Maker" />}
>
<Button
>
<Link
color="white"
style={{
color: "white",
textDecoration: "none",
}}
target="_blank"
href={
"https://wa.me/+6281339158911?text=Hallo , Apa boleh saya minta informasi tentang DariBaliMice?"
}
>
{" "}
Kirim
</Link>
</Button>
<Stack>
<ComponentGlobal_CardStyles marginBottom={"0"}>
<Stack>
<Skeleton h={20} w={100} />
{Array.from(new Array(2)).map((e, i) => (
<Grid align="center" gutter={"md"} key={i}>
<Grid.Col span={"content"}>
<Skeleton circle height={40} />
</Grid.Col>
<Grid.Col span={3}>
<Skeleton height={20} w={150} />
</Grid.Col>
</Grid>
))}
</Stack>
</ComponentGlobal_CardStyles>
{/* <ComponentGlobal_CardStyles marginBottom={"0"}>
<Stack spacing={"xl"}>
<Grid align="center" gutter={"md"}>
<Grid.Col span={"content"}>
<Skeleton circle height={40} />
</Grid.Col>
<Grid.Col span={3}>
<Skeleton height={20} w={150} />
</Grid.Col>
</Grid>
<Center>
<Skeleton height={15} w={200} />
</Center>
<Grid align="center" gutter={"md"}>
<Grid.Col span={"content"}>
<Skeleton h={15} w={70} />
</Grid.Col>
<Grid.Col span={3}>
<Skeleton height={15} w={200} />
</Grid.Col>
</Grid>
<Grid align="center" gutter={"md"}>
<Grid.Col span={"content"}>
<Skeleton h={15} w={70} />
</Grid.Col>
<Grid.Col span={3}>
<Skeleton height={15} w={200} />
</Grid.Col>
</Grid>
<Skeleton height={15} w={100} />
<Skeleton height={15} w={"100%"} />
<Skeleton height={15} w={100} />
<Skeleton height={15} w={"100%"} />
</Stack>
</ComponentGlobal_CardStyles> */}
{/* <ComponentGlobal_CardStyles>
<Stack>
<Center>
<Skeleton h={20} w={"30%"} />
</Center>
<Group position="center" spacing={50}>
<Stack align="center">
<Skeleton circle height={70} />
<Skeleton height={20} w={50} />
</Stack>
<Stack align="center">
<Skeleton circle height={70} />
<Skeleton height={20} w={50} />
</Stack>
</Group>
</Stack>
</ComponentGlobal_CardStyles> */}
<Stack spacing={"xl"} p={"sm"}>
{Array.from({ length: 4 }).map((_, i) => (
<CustomSkeleton key={i} height={50} width={"100%"} />
))}
<CustomSkeleton height={100} width={"100%"} />
<CustomSkeleton radius="xl" height={50} width={"100%"} />
</Stack>
</UIGlobal_LayoutTamplate>
</>