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 { myConsole } from "@/app/fun/my_console";
|
||||||
import { CreatePortofolio } from "@/app_modules/katalog/portofolio";
|
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";
|
import { getProfile } from "@/app_modules/katalog/profile";
|
||||||
|
|
||||||
export default async function Page() {
|
export default async function Page() {
|
||||||
const bidangBisnis = await getBidangBisnis();
|
const bidangBisnis = await getBidangBisnis()
|
||||||
const id = await getProfile();
|
const id = await getProfile();
|
||||||
const profileId = id?.id;
|
const profileId = id?.id;
|
||||||
|
// console.log(bidangBisnis)
|
||||||
|
|
||||||
return (
|
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 { Header, Group, ActionIcon, Text } from "@mantine/core";
|
||||||
import { IconArrowLeft } from "@tabler/icons-react";
|
import { IconArrowLeft } from "@tabler/icons-react";
|
||||||
|
import { useRouter } from "next/navigation";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
export default function headerTransparent({
|
export default function HeaderTransparent({
|
||||||
icon1,
|
route,
|
||||||
icon2,
|
icon2,
|
||||||
title,
|
title,
|
||||||
}: {
|
}: {
|
||||||
icon1: React.ReactNode;
|
route: any;
|
||||||
icon2: React.ReactNode;
|
icon2: any;
|
||||||
title: string;
|
title: string;
|
||||||
}) {
|
}) {
|
||||||
|
const router = useRouter();
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|
||||||
<Header height={50} px={"sm"}>
|
<Header height={50} px={"sm"}>
|
||||||
<Group position="apart" h={50}>
|
<Group position="apart" h={50}>
|
||||||
{icon1}
|
<ActionIcon variant="transparent" onClick={() => router.push(route)}>
|
||||||
|
<IconArrowLeft />
|
||||||
|
</ActionIcon>
|
||||||
|
|
||||||
<Text>{title}</Text>
|
<Text>{title}</Text>
|
||||||
{icon2}
|
{icon2}
|
||||||
</Group>
|
</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 { IconArrowLeft } from "@tabler/icons-react";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
|
|
||||||
export default function PortofolioLayout({ children }: { children: any }) {
|
export default function CreatePortofolioLayout({ children }: { children: any }) {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
import { myConsole } from "@/app/fun/my_console";
|
import { myConsole } from "@/app/fun/my_console";
|
||||||
import { ApiHipmi } from "@/app/lib/api";
|
import { ApiHipmi } from "@/app/lib/api";
|
||||||
import { Warna } from "@/app/lib/warna";
|
import { Warna } from "@/app/lib/warna";
|
||||||
|
import { BIDANG_BISNIS } from "@/app_modules/models/portofolio";
|
||||||
import { Button, Select, Stack, TextInput, Title } from "@mantine/core";
|
import { Button, Select, Stack, TextInput, Title } from "@mantine/core";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
@@ -10,10 +11,10 @@ import { useState } from "react";
|
|||||||
import toast from "react-simple-toasts";
|
import toast from "react-simple-toasts";
|
||||||
|
|
||||||
export default function CreatePortofolio({
|
export default function CreatePortofolio({
|
||||||
data,
|
bidangBisnis,
|
||||||
profileId,
|
profileId,
|
||||||
}: {
|
}: {
|
||||||
data: any;
|
bidangBisnis: BIDANG_BISNIS;
|
||||||
profileId: any;
|
profileId: any;
|
||||||
}) {
|
}) {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
@@ -46,7 +47,7 @@ export default function CreatePortofolio({
|
|||||||
})
|
})
|
||||||
.then((res) => res.json())
|
.then((res) => res.json())
|
||||||
.then((val) => {
|
.then((val) => {
|
||||||
myConsole(val)
|
myConsole(val);
|
||||||
if (val.status == 201) {
|
if (val.status == 201) {
|
||||||
toast("Berhasil disimpan");
|
toast("Berhasil disimpan");
|
||||||
return router.push("/dev/katalog/view");
|
return router.push("/dev/katalog/view");
|
||||||
@@ -58,6 +59,7 @@ export default function CreatePortofolio({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
{/* {JSON.stringify(bidangBisnis)} */}
|
||||||
|
|
||||||
<Stack px={"sm"}>
|
<Stack px={"sm"}>
|
||||||
<TextInput
|
<TextInput
|
||||||
@@ -71,7 +73,10 @@ export default function CreatePortofolio({
|
|||||||
/>
|
/>
|
||||||
<Select
|
<Select
|
||||||
label="Bidang Bisnis"
|
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) => {
|
onChange={(val) => {
|
||||||
setValue({
|
setValue({
|
||||||
...value,
|
...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 CreatePortofolio from "./create/view";
|
||||||
import PortofolioLayout from "./create/layout";
|
import CreatePortofolioLayout from "./create/layout";
|
||||||
import ListPortofolioView from "./list_view/view";
|
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 { myConsole } from "@/app/fun/my_console";
|
||||||
import { getProfile } from "../../profile";
|
import { getProfile } from "../../profile";
|
||||||
import { LIST_PORTOFOLIO } from "@/app_modules/models/portofolio";
|
import { LIST_PORTOFOLIO } from "@/app_modules/models/portofolio";
|
||||||
|
import { useRouter } from "next/navigation";
|
||||||
|
|
||||||
export default function ListPortofolioView({
|
export default function ListPortofolioView({
|
||||||
listPorto,
|
listPorto,
|
||||||
}: {
|
}: {
|
||||||
listPorto: LIST_PORTOFOLIO;
|
listPorto: LIST_PORTOFOLIO;
|
||||||
}) {
|
}) {
|
||||||
|
const router = useRouter();
|
||||||
const [porto, setPorto] = useState(listPorto);
|
const [porto, setPorto] = useState(listPorto);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{/* <pre>{JSON.stringify(porto, null, 2)}</pre> */}
|
{/* <pre>{JSON.stringify(porto, null, 2)}</pre> */}
|
||||||
@@ -32,7 +33,14 @@ export default function ListPortofolioView({
|
|||||||
<>
|
<>
|
||||||
{" "}
|
{" "}
|
||||||
{_.map(porto as any).map((e: any) => (
|
{_.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 h={50} align="center" px={"md"}>
|
||||||
<Grid.Col span={10}>
|
<Grid.Col span={10}>
|
||||||
<Text fw={"bold"}>{e.namaBisnis}</Text>
|
<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 {
|
export interface LIST_PORTOFOLIO {
|
||||||
id: string;
|
id: string;
|
||||||
namaBisnis: string;
|
namaBisnis: string;
|
||||||
alamatKantor: string;
|
alamatKantor: string;
|
||||||
tlpn: string;
|
tlpn: string;
|
||||||
deskripssi: string;
|
deskripssi: string;
|
||||||
masterBidangBisnisId: string;
|
masterBidangBisnisId: string;
|
||||||
active: boolean;
|
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