diff --git a/src/app_modules/katalog/portofolio/api/get-bidang-bisnis.ts b/src/app_modules/katalog/portofolio/api/get-bidang-bisnis.ts new file mode 100644 index 00000000..4130f24d --- /dev/null +++ b/src/app_modules/katalog/portofolio/api/get-bidang-bisnis.ts @@ -0,0 +1,9 @@ +"use server" + +import { myConsole } from "@/app/fun/my_console" +import prisma from "@/app/lib/prisma" + +export async function getBidangBisnis() { + const data = await prisma.masterBidangBisnis.findMany() + return data +} \ No newline at end of file diff --git a/src/app_modules/katalog/portofolio/api/get-portofolio.ts b/src/app_modules/katalog/portofolio/api/get-portofolio.ts new file mode 100644 index 00000000..2a775a57 --- /dev/null +++ b/src/app_modules/katalog/portofolio/api/get-portofolio.ts @@ -0,0 +1,35 @@ +"use server"; + +import { myConsole } from "@/app/fun/my_console"; +import prisma from "@/app/lib/prisma"; + +/** + * + * @param id - profileId + * @returns list portofolio by Id + */ +export default async function getListPortofolio(id: string) { + myConsole(id); + + + const data = await prisma.katalog.findMany({ + where: { + profileId: id, + }, + select: { + id: true, + namaBisnis: true, + alamatKantor: true, + tlpn: true, + deskripssi: true, + active: true, + masterBidangBisnisId: true, + }, + }); + + if (!data) { + throw new Error('Failed to fetch data') + } + + return data; +} diff --git a/src/app_modules/katalog/portofolio/create/layout.tsx b/src/app_modules/katalog/portofolio/create/layout.tsx new file mode 100644 index 00000000..e5e6e58c --- /dev/null +++ b/src/app_modules/katalog/portofolio/create/layout.tsx @@ -0,0 +1,31 @@ +"use client"; + +import { ActionIcon, AppShell, Group, Header, Text } from "@mantine/core"; +import { IconArrowLeft } from "@tabler/icons-react"; +import { useRouter } from "next/navigation"; + +export default function PortofolioLayout({ children }: { children: any }) { + const router = useRouter(); + return ( + <> + + + router.push("/dev/katalog/view")} + > + + + Buat Portofolio + + + + } + > + {children} + + + ); +} diff --git a/src/app_modules/katalog/portofolio/create/view.tsx b/src/app_modules/katalog/portofolio/create/view.tsx new file mode 100644 index 00000000..0ff7a01d --- /dev/null +++ b/src/app_modules/katalog/portofolio/create/view.tsx @@ -0,0 +1,127 @@ +"use client"; + +import { myConsole } from "@/app/fun/my_console"; +import { ApiHipmi } from "@/app/lib/api"; +import { Warna } from "@/app/lib/warna"; +import { Button, Select, Stack, TextInput, Title } from "@mantine/core"; +import _ from "lodash"; +import { useRouter } from "next/navigation"; +import { useState } from "react"; +import toast from "react-simple-toasts"; + +export default function CreatePortofolio({ + data, + profileId, +}: { + data: any; + profileId: any; +}) { + const router = useRouter(); + const [value, setValue] = useState({ + namaBisnis: "", + bidangBisnisId: "", + alamatKantor: "", + tlpn: "", + deskripssi: "", + }); + + async function onSubmit() { + const body = { + profileId: profileId, + namaBisnis: value.namaBisnis, + masterBidangBisnisId: value.bidangBisnisId, + alamatKantor: value.alamatKantor, + tlpn: value.tlpn, + deskripssi: value.deskripssi, + }; + + if (_.values(body).includes("")) return toast("Lengkapi Data"); + + await fetch(ApiHipmi.create_portofolio, { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify(body), + }) + .then((res) => res.json()) + .then((val) => { + myConsole(val) + if (val.status == 201) { + toast("Berhasil disimpan"); + return router.push("/dev/katalog/view"); + } else { + return toast("Gagal disimpa"); + } + }); + } + + return ( + <> + {/* {JSON.stringify(data)} */} + + { + setValue({ + ...value, + namaBisnis: val.target.value, + }); + }} + /> +