diff --git a/src/app/api/mobile/portofolio/[id]/route.ts b/src/app/api/mobile/portofolio/[id]/route.ts index b4e317b6..c94e7bc2 100644 --- a/src/app/api/mobile/portofolio/[id]/route.ts +++ b/src/app/api/mobile/portofolio/[id]/route.ts @@ -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, }, }); diff --git a/src/app/api/mobile/portofolio/route.ts b/src/app/api/mobile/portofolio/route.ts index e5f2cf07..b542f341 100644 --- a/src/app/api/mobile/portofolio/route.ts +++ b/src/app/api/mobile/portofolio/route.ts @@ -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: {