API Mobile:

Fix:
- api/mobile/portofolio/route.ts
- api/mobile/portofolio/[id]/route.ts

### No issue
This commit is contained in:
2025-09-02 18:31:04 +08:00
parent 41bf7ce45c
commit af7f4e0027
2 changed files with 71 additions and 34 deletions

View File

@@ -11,14 +11,49 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
where: {
id: id,
},
include: {
select: {
id: true,
id_Portofolio: true,
namaBisnis: true,
alamatKantor: true,
tlpn: true,
deskripsi: true,
logoId: true,
masterBidangBisnisId: true,
Profile: {
include: {
User: true,
select: {
userId: true,
}
},
MasterBidangBisnis: {
select: {
id: true,
name: true,
active: true,
},
},
Portofolio_MediaSosial: {
select: {
id: true,
facebook: true,
instagram: true,
tiktok: true,
twitter: true,
youtube: true,
},
},
Portofolio_BidangDanSubBidangBisnis: {
select: {
id: true,
MasterSubBidangBisnis: {
select: {
id: true,
name: true,
masterBidangBisnisId: true,
},
},
},
},
MasterBidangBisnis: true,
Portofolio_MediaSosial: true,
},
});

View File

@@ -51,6 +51,8 @@ async function POST(request: Request) {
try {
const { data } = await request.json();
console.log("DATA >>", data);
const createPortofolio = await prisma.portofolio.create({
data: {
profileId: data.id,
@@ -64,37 +66,37 @@ async function POST(request: Request) {
},
});
// if (data.subBidang.length > 0 || data.subBidang.map((item: any) => item.id !== "")) {
// for (let i of data.subBidang) {
// const createSubBidang =
// await prisma.portofolio_BidangDanSubBidangBisnis.create({
// data: {
// portofolioId: createPortofolio.id,
// masterBidangBisnisId: data.masterBidangBisnisId,
// masterSubBidangBisnisId: i.id,
// },
// });
if (data.subBidang.length > 0 || data.subBidang.map((item: any) => item.id !== "")) {
for (let i of data.subBidang) {
const createSubBidang =
await prisma.portofolio_BidangDanSubBidangBisnis.create({
data: {
portofolioId: createPortofolio.id,
masterBidangBisnisId: data.masterBidangBisnisId,
masterSubBidangBisnisId: i.id,
},
});
// console.log("CREATE SUB BIDANG >>", createSubBidang);
// if (!createSubBidang)
// return NextResponse.json(
// {
// success: false,
// message: "Gagal membuat sub bidang bisnis",
// },
// { status: 400 }
// );
// }
// }
console.log("CREATE SUB BIDANG >>", createSubBidang);
if (!createSubBidang)
return NextResponse.json(
{
success: false,
message: "Gagal membuat sub bidang bisnis",
},
{ status: 400 }
);
}
}
// if (!createPortofolio)
// return NextResponse.json(
// {
// success: false,
// message: "Gagal membuat portofolio",
// },
// { status: 400 }
// );
if (!createPortofolio)
return NextResponse.json(
{
success: false,
message: "Gagal membuat portofolio",
},
{ status: 400 }
);
const createMedsos = await prisma.portofolio_MediaSosial.create({
data: {