Merge pull request 'API Mobile: Portofolio' (#8) from mobile/29-aug-25 into staging

Reviewed-on: bip/hipmi#8
This commit is contained in:
2025-08-29 17:35:14 +08:00
4 changed files with 194 additions and 1 deletions

View File

@@ -2,6 +2,10 @@
All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
## [1.4.33](https://wibugit.wibudev.com/bip/hipmi/compare/v1.4.32...v1.4.33) (2025-08-29)
## [1.4.32](https://wibugit.wibudev.com/bip/hipmi/compare/v1.4.31...v1.4.32) (2025-08-29)
## [1.4.31](https://wibugit.wibudev.com/bip/hipmi/compare/v1.4.30...v1.4.31) (2025-08-27)
## [1.4.30](https://wibugit.wibudev.com/bip/hipmi/compare/v1.4.29...v1.4.30) (2025-08-26)

View File

@@ -1,6 +1,6 @@
{
"name": "hipmi",
"version": "1.4.31",
"version": "1.4.33",
"private": true,
"prisma": {
"seed": "bun prisma/seed.ts"

View File

@@ -0,0 +1,52 @@
import { NextResponse } from "next/server";
import { prisma } from "@/lib";
export { GET };
async function GET(request: Request, { params }: { params: { id: string } }) {
try {
const { id } = params;
const data = await prisma.portofolio.findUnique({
where: {
id: id,
},
include: {
Profile: {
include: {
User: true,
},
},
MasterBidangBisnis: true,
Portofolio_MediaSosial: 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) {
return NextResponse.json(
{
success: false,
message: "API Error Get Data Potofolio",
reason: (error as Error).message,
},
{ status: 500 }
);
}
}

View File

@@ -0,0 +1,137 @@
import { prisma } from "@/lib";
import { NextResponse } from "next/server";
export { GET, POST };
async function GET(request: Request, { params }: { params: { id: string } }) {
try {
const { searchParams } = new URL(request.url);
const id = searchParams.get("id");
const data = await prisma.portofolio.findMany({
orderBy: {
createdAt: "desc",
},
where: {
profileId: id,
active: 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) {
return NextResponse.json(
{
success: false,
message: "API Error Get Data Potofolio",
reason: (error as Error).message,
},
{ status: 500 }
);
}
}
async function POST(request: Request) {
try {
const { data } = await request.json();
const createPortofolio = await prisma.portofolio.create({
data: {
profileId: data.id,
id_Portofolio: "Porto" + Date.now().toString(),
namaBisnis: data.namaBisnis,
deskripsi: data.deskripsi,
tlpn: data.tlpn,
alamatKantor: data.alamatKantor,
masterBidangBisnisId: data.masterBidangBisnisId,
logoId: data.fileId || "",
},
});
// 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 }
// );
// }
// }
// if (!createPortofolio)
// return NextResponse.json(
// {
// success: false,
// message: "Gagal membuat portofolio",
// },
// { status: 400 }
// );
const createMedsos = await prisma.portofolio_MediaSosial.create({
data: {
portofolioId: createPortofolio.id,
facebook: data?.facebook,
instagram: data?.instagram,
tiktok: data?.tiktok,
twitter: data?.twitter,
youtube: data?.youtube,
},
});
if (!createMedsos)
return NextResponse.json(
{
success: false,
message: "Gagal menambahkan medsos",
},
{ status: 400 }
);
return NextResponse.json(
{
success: true,
message: "Berhasil mendapatkan data",
data: createPortofolio,
},
{ status: 200 }
);
} catch (error) {
return NextResponse.json(
{
success: false,
message: "API Error Post Data",
reason: (error as Error).message,
},
{ status: 500 }
);
}
}