fix
Desc: - Perubahan minor Issue: Di server master bidang bisnis tidak terpanggil
This commit is contained in:
@@ -1,16 +1,17 @@
|
||||
import { myConsole } from "@/app/fun/my_console";
|
||||
import { CreatePortofolio } from "@/app_modules/katalog/portofolio";
|
||||
import { getBidangBisnis } from "@/app_modules/katalog/portofolio/fun/get_list_bidang_bisnis";
|
||||
import { getBidangBisnis } from "@/app_modules/katalog/portofolio/fun/get_bidang_bisnis";
|
||||
import { getProfile } from "@/app_modules/katalog/profile";
|
||||
|
||||
export default async function Page() {
|
||||
const bidangBisnis = await getBidangBisnis();
|
||||
const bidangBisnis = await getBidangBisnis()
|
||||
const id = await getProfile();
|
||||
const profileId = id?.id;
|
||||
// console.log(bidangBisnis)
|
||||
|
||||
return (
|
||||
<>
|
||||
<CreatePortofolio data={bidangBisnis} profileId={profileId} />
|
||||
<CreatePortofolio bidangBisnis={bidangBisnis as any} profileId={profileId} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
9
src/app/dev/portofolio/main/[id]/layout.tsx
Normal file
9
src/app/dev/portofolio/main/[id]/layout.tsx
Normal file
@@ -0,0 +1,9 @@
|
||||
import { PortofolioLayout } from "@/app_modules/katalog/portofolio";
|
||||
|
||||
export default async function Layout({ children }: { children: any }) {
|
||||
return (
|
||||
<>
|
||||
<PortofolioLayout>{children}</PortofolioLayout>
|
||||
</>
|
||||
);
|
||||
}
|
||||
15
src/app/dev/portofolio/main/[id]/page.tsx
Normal file
15
src/app/dev/portofolio/main/[id]/page.tsx
Normal file
@@ -0,0 +1,15 @@
|
||||
import { ViewPortofolio } from "@/app_modules/katalog/portofolio";
|
||||
import { getOnePortofolio } from "@/app_modules/katalog/portofolio/fun/get_one_portofolio";
|
||||
|
||||
export default async function Page({params}: {params: {id: string}}) {
|
||||
|
||||
const getPorto = await getOnePortofolio(params.id)
|
||||
// console.log(getPorto)
|
||||
|
||||
return (
|
||||
<>
|
||||
{/* {JSON.stringify(getPorto)} */}
|
||||
<ViewPortofolio dataPorto={getPorto as any} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -2,22 +2,28 @@
|
||||
|
||||
import { Header, Group, ActionIcon, Text } from "@mantine/core";
|
||||
import { IconArrowLeft } from "@tabler/icons-react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import React from "react";
|
||||
|
||||
export default function headerTransparent({
|
||||
icon1,
|
||||
export default function HeaderTransparent({
|
||||
route,
|
||||
icon2,
|
||||
title,
|
||||
}: {
|
||||
icon1: React.ReactNode;
|
||||
icon2: React.ReactNode;
|
||||
route: any;
|
||||
icon2: any;
|
||||
title: string;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
return (
|
||||
<>
|
||||
|
||||
<Header height={50} px={"sm"}>
|
||||
<Group position="apart" h={50}>
|
||||
{icon1}
|
||||
<ActionIcon variant="transparent" onClick={() => router.push(route)}>
|
||||
<IconArrowLeft />
|
||||
</ActionIcon>
|
||||
|
||||
<Text>{title}</Text>
|
||||
{icon2}
|
||||
</Group>
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import headerTransparent from "./component/header_transparent";
|
||||
import HeaderTransparent from "./component/header_transparent";
|
||||
|
||||
export {headerTransparent}
|
||||
export {HeaderTransparent as headerTransparent}
|
||||
@@ -4,7 +4,7 @@ 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 }) {
|
||||
export default function CreatePortofolioLayout({ children }: { children: any }) {
|
||||
const router = useRouter();
|
||||
return (
|
||||
<>
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
import { myConsole } from "@/app/fun/my_console";
|
||||
import { ApiHipmi } from "@/app/lib/api";
|
||||
import { Warna } from "@/app/lib/warna";
|
||||
import { BIDANG_BISNIS } from "@/app_modules/models/portofolio";
|
||||
import { Button, Select, Stack, TextInput, Title } from "@mantine/core";
|
||||
import _ from "lodash";
|
||||
import { useRouter } from "next/navigation";
|
||||
@@ -10,10 +11,10 @@ import { useState } from "react";
|
||||
import toast from "react-simple-toasts";
|
||||
|
||||
export default function CreatePortofolio({
|
||||
data,
|
||||
bidangBisnis,
|
||||
profileId,
|
||||
}: {
|
||||
data: any;
|
||||
bidangBisnis: BIDANG_BISNIS;
|
||||
profileId: any;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
@@ -46,7 +47,7 @@ export default function CreatePortofolio({
|
||||
})
|
||||
.then((res) => res.json())
|
||||
.then((val) => {
|
||||
myConsole(val)
|
||||
myConsole(val);
|
||||
if (val.status == 201) {
|
||||
toast("Berhasil disimpan");
|
||||
return router.push("/dev/katalog/view");
|
||||
@@ -58,6 +59,7 @@ export default function CreatePortofolio({
|
||||
|
||||
return (
|
||||
<>
|
||||
{/* {JSON.stringify(bidangBisnis)} */}
|
||||
|
||||
<Stack px={"sm"}>
|
||||
<TextInput
|
||||
@@ -71,7 +73,10 @@ export default function CreatePortofolio({
|
||||
/>
|
||||
<Select
|
||||
label="Bidang Bisnis"
|
||||
data={_.map(data).map((e: any) => ({ label: e.name, value: e.id }))}
|
||||
data={_.map(bidangBisnis as any).map((e : any) => ({
|
||||
value: e.id,
|
||||
label: e.name,
|
||||
}))}
|
||||
onChange={(val) => {
|
||||
setValue({
|
||||
...value,
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
import toast from "react-simple-toasts";
|
||||
import { funGetListPortofolio } from "./get_list_portofolio";
|
||||
|
||||
/**
|
||||
*
|
||||
* @param id - profileId
|
||||
* @returns load list portofolio by Id
|
||||
*/
|
||||
export async function loadListPortofolio(id: string) {
|
||||
if (id === null) {
|
||||
return toast("Id null");
|
||||
} else {
|
||||
const data = await funGetListPortofolio(id).then((res) => res);
|
||||
return data
|
||||
}
|
||||
}
|
||||
29
src/app_modules/katalog/portofolio/fun/get_one_portofolio.ts
Normal file
29
src/app_modules/katalog/portofolio/fun/get_one_portofolio.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
|
||||
export async function getOnePortofolio(id: string) {
|
||||
// console.log(id)
|
||||
const data = await prisma.katalog.findUnique({
|
||||
where: {
|
||||
id: id,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
namaBisnis: true,
|
||||
alamatKantor: true,
|
||||
deskripssi: true,
|
||||
tlpn: true,
|
||||
active: true,
|
||||
MasterBidangBisnis: {
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
active: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
return data
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
import CreatePortofolio from "./create/view";
|
||||
import PortofolioLayout from "./create/layout";
|
||||
import CreatePortofolioLayout from "./create/layout";
|
||||
import ListPortofolioView from "./list_view/view";
|
||||
import PortofolioLayout from "./main/layout";
|
||||
import ViewPortofolio from "./main/view";
|
||||
|
||||
export {CreatePortofolio, PortofolioLayout, ListPortofolioView}
|
||||
export {CreatePortofolio, CreatePortofolioLayout, ListPortofolioView, PortofolioLayout, ViewPortofolio}
|
||||
@@ -11,14 +11,15 @@ import { gs_ListPortofolio } from "../state/global_state";
|
||||
import { myConsole } from "@/app/fun/my_console";
|
||||
import { getProfile } from "../../profile";
|
||||
import { LIST_PORTOFOLIO } from "@/app_modules/models/portofolio";
|
||||
import { useRouter } from "next/navigation";
|
||||
|
||||
export default function ListPortofolioView({
|
||||
listPorto,
|
||||
}: {
|
||||
listPorto: LIST_PORTOFOLIO;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [porto, setPorto] = useState(listPorto);
|
||||
|
||||
return (
|
||||
<>
|
||||
{/* <pre>{JSON.stringify(porto, null, 2)}</pre> */}
|
||||
@@ -32,7 +33,14 @@ export default function ListPortofolioView({
|
||||
<>
|
||||
{" "}
|
||||
{_.map(porto as any).map((e: any) => (
|
||||
<Paper key={e.id} h={50} bg={"gray"} my={"md"}>
|
||||
<Paper
|
||||
key={e.id}
|
||||
h={50}
|
||||
bg={"gray"}
|
||||
my={"md"}
|
||||
radius={50}
|
||||
onClick={() => router.push(`/dev/portofolio/main/${e.id}/`)}
|
||||
>
|
||||
<Grid h={50} align="center" px={"md"}>
|
||||
<Grid.Col span={10}>
|
||||
<Text fw={"bold"}>{e.namaBisnis}</Text>
|
||||
|
||||
33
src/app_modules/katalog/portofolio/main/layout.tsx
Normal file
33
src/app_modules/katalog/portofolio/main/layout.tsx
Normal file
@@ -0,0 +1,33 @@
|
||||
"use client";
|
||||
|
||||
import { ActionIcon, AppShell } from "@mantine/core";
|
||||
import HeaderTransparent from "../../component/header_transparent";
|
||||
|
||||
import { useRouter } from "next/navigation";
|
||||
import { IconArrowLeft, IconEdit } from "@tabler/icons-react";
|
||||
|
||||
export default function PortofolioLayout({ children }: { children: any }) {
|
||||
const router = useRouter();
|
||||
return (
|
||||
<>
|
||||
<AppShell
|
||||
header={
|
||||
<HeaderTransparent
|
||||
route={"/dev/katalog/view"}
|
||||
title="Portofolio"
|
||||
icon2={
|
||||
<ActionIcon
|
||||
variant="transparent"
|
||||
onClick={() => router.push("/dev/portofolio/edit")}
|
||||
>
|
||||
<IconEdit />
|
||||
</ActionIcon>
|
||||
}
|
||||
/>
|
||||
}
|
||||
>
|
||||
{children}
|
||||
</AppShell>
|
||||
</>
|
||||
);
|
||||
}
|
||||
41
src/app_modules/katalog/portofolio/main/view.tsx
Normal file
41
src/app_modules/katalog/portofolio/main/view.tsx
Normal file
@@ -0,0 +1,41 @@
|
||||
"use client";
|
||||
|
||||
import { Warna } from "@/app/lib/warna";
|
||||
import { GET_ONE_PORTOFOLIO } from "@/app_modules/models/portofolio";
|
||||
import { Box, Button, Center, Text, Title } from "@mantine/core";
|
||||
import { IconTrash } from "@tabler/icons-react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
|
||||
export default function ViewPortofolio({
|
||||
dataPorto,
|
||||
}: {
|
||||
dataPorto: GET_ONE_PORTOFOLIO;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [porto, setPorto] = useState(dataPorto);
|
||||
|
||||
|
||||
|
||||
|
||||
return (
|
||||
<>
|
||||
<Box>
|
||||
<Text>{porto.namaBisnis}</Text>
|
||||
<Text>{porto.alamatKantor}</Text>
|
||||
<Text>+{porto.tlpn}</Text>
|
||||
<Text>{porto.deskripssi}</Text>
|
||||
<Text>{porto.MasterBidangBisnis.name}</Text>
|
||||
</Box>
|
||||
<Center mt={"md"}>
|
||||
<Button bg={"red"} color="red" w={300}
|
||||
onClick={() => {
|
||||
|
||||
}}
|
||||
>
|
||||
<IconTrash />
|
||||
</Button>{" "}
|
||||
</Center>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,9 +1,25 @@
|
||||
export interface LIST_PORTOFOLIO {
|
||||
id: string;
|
||||
namaBisnis: string;
|
||||
alamatKantor: string;
|
||||
tlpn: string;
|
||||
deskripssi: string;
|
||||
masterBidangBisnisId: string;
|
||||
active: boolean;
|
||||
}
|
||||
id: string;
|
||||
namaBisnis: string;
|
||||
alamatKantor: string;
|
||||
tlpn: string;
|
||||
deskripssi: string;
|
||||
masterBidangBisnisId: string;
|
||||
active: boolean;
|
||||
}
|
||||
|
||||
export interface BIDANG_BISNIS {
|
||||
id: string;
|
||||
name: string;
|
||||
active: boolean;
|
||||
}
|
||||
|
||||
export interface GET_ONE_PORTOFOLIO {
|
||||
id: string;
|
||||
namaBisnis: string;
|
||||
alamatKantor: string;
|
||||
deskripssi: string;
|
||||
tlpn: string;
|
||||
active: boolean;
|
||||
MasterBidangBisnis: BIDANG_BISNIS;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user