fix
Desc: - Perubahan minor
This commit is contained in:
@@ -44,18 +44,19 @@ model UserSession {
|
||||
}
|
||||
|
||||
model Profile {
|
||||
id String @id @default(cuid())
|
||||
id String @id @default(cuid())
|
||||
name String
|
||||
email String @unique
|
||||
email String @unique
|
||||
alamat String
|
||||
jenisKelamin String
|
||||
active Boolean @default(true)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @default(now()) @updatedAt
|
||||
User User? @relation(fields: [userId], references: [id])
|
||||
userId String? @unique
|
||||
ImageProfile Images? @relation(fields: [imagesId], references: [id])
|
||||
imagesId String? @unique
|
||||
active Boolean @default(true)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @default(now()) @updatedAt
|
||||
User User? @relation(fields: [userId], references: [id])
|
||||
userId String? @unique
|
||||
ImageProfile Images? @relation(fields: [imagesId], references: [id])
|
||||
imagesId String? @unique
|
||||
Katalog Katalog[]
|
||||
}
|
||||
|
||||
model Images {
|
||||
@@ -66,3 +67,27 @@ model Images {
|
||||
updatedAt DateTime @default(now()) @updatedAt
|
||||
Profile Profile?
|
||||
}
|
||||
|
||||
model Katalog {
|
||||
id String @id @default(cuid())
|
||||
namaBisnis String
|
||||
alamatKantor String
|
||||
tlpn String
|
||||
deskripssi String
|
||||
active Boolean @default(true)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @default(now()) @updatedAt
|
||||
Profile Profile? @relation(fields: [profileId], references: [id])
|
||||
profileId String?
|
||||
MasterBidangBisnis MasterBidangBisnis @relation(fields: [masterBidangBisnisId], references: [id])
|
||||
masterBidangBisnisId String
|
||||
}
|
||||
|
||||
model MasterBidangBisnis {
|
||||
id String @id
|
||||
name String
|
||||
active Boolean @default(true)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @default(now()) @updatedAt
|
||||
Katalog Katalog[]
|
||||
}
|
||||
|
||||
BIN
public/img/a92db9b4-33c1-41a0-882e-ae82a5dc0534.png
Normal file
BIN
public/img/a92db9b4-33c1-41a0-882e-ae82a5dc0534.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 103 KiB |
BIN
public/img/fee57417-24f2-425d-99d7-18a7ec5e4b37.png
Normal file
BIN
public/img/fee57417-24f2-425d-99d7-18a7ec5e4b37.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 103 KiB |
25
src/app/api/portofolio/create/route.ts
Normal file
25
src/app/api/portofolio/create/route.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { myConsole } from "@/app/fun/my_console";
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
export async function POST(req: Request) {
|
||||
if (req.method === "POST") {
|
||||
const body = await req.json();
|
||||
// myConsole(body);
|
||||
|
||||
const data = await prisma.katalog.create({
|
||||
data: {
|
||||
profileId: body.profileId,
|
||||
namaBisnis: body.namaBisnis,
|
||||
alamatKantor: body.alamatKantor,
|
||||
tlpn: body.tlpn,
|
||||
deskripssi: body.deskripssi,
|
||||
masterBidangBisnisId: body.masterBidangBisnisId,
|
||||
},
|
||||
});
|
||||
console.log(data)
|
||||
|
||||
return NextResponse.json({ status: 201, success: true });
|
||||
}
|
||||
return NextResponse.json({ success: false });
|
||||
}
|
||||
@@ -1,12 +1,14 @@
|
||||
import { loadListPortofolio } from "@/app_modules/katalog/portofolio/fun/fun_get_all_portofolio";
|
||||
import { getProfile } from "@/app_modules/katalog/profile";
|
||||
import { KatalogView } from "@/app_modules/katalog/view";
|
||||
|
||||
export default async function Page() {
|
||||
const data = await getProfile();
|
||||
const listPorto = await loadListPortofolio(data?.id as string)
|
||||
return (
|
||||
<>
|
||||
{/* {JSON.stringify(data)} */}
|
||||
<KatalogView data={data} />
|
||||
<KatalogView data={data} porto={listPorto} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
export function myConsole(value: any) {
|
||||
const onData = false
|
||||
const onData = true
|
||||
if (onData) {
|
||||
console.log(value);
|
||||
}
|
||||
|
||||
@@ -11,4 +11,7 @@ export const ApiHipmi = {
|
||||
create_profile: "/api/profile/create",
|
||||
edit_profile: "/api/profile/edit",
|
||||
get_foto: "/api/profile/foto/",
|
||||
|
||||
//Portofolio
|
||||
create_portofolio: "/api/portofolio/create",
|
||||
};
|
||||
|
||||
@@ -36,6 +36,7 @@ import { useAtom } from "jotai";
|
||||
import { gs_token } from "./state/global_state";
|
||||
import { loadDataProfile } from "../katalog/profile/fun/fun_get_profile";
|
||||
import { gs_profile } from "../katalog/profile/state/global_state";
|
||||
import { loadListPortofolio } from "../katalog/portofolio/fun/fun_get_all_portofolio";
|
||||
|
||||
const listHalaman = [
|
||||
{
|
||||
@@ -98,6 +99,11 @@ export default function HomeView() {
|
||||
loadDataProfile(setProfile);
|
||||
}, []);
|
||||
|
||||
// const [listPorto, setListPorto] = useState<any | null>(null);
|
||||
// useShallowEffect(() => {
|
||||
// loadListPortofolio(profile?.id).then((res) => setListPorto(res));
|
||||
// }, [profile?.id]);
|
||||
|
||||
return (
|
||||
<>
|
||||
{/* <pre>{JSON.stringify(profile, null, 2)}</pre> */}
|
||||
|
||||
@@ -4,7 +4,8 @@ import { getProfile } from "./api/get-profile";
|
||||
import EditProfileLayout from "./edit/layout";
|
||||
import EditProfileView from "./edit/view";
|
||||
import UploadFotoProfile from "./upload/view";
|
||||
import UploadFotoProfileLayout from "./upload/layout";
|
||||
import UploadFotoProfileLayout from "./upload/layout"
|
||||
import ProfileView from "./view/view";
|
||||
|
||||
export {
|
||||
ProfileLayout,
|
||||
@@ -14,4 +15,5 @@ export {
|
||||
EditProfileLayout,
|
||||
UploadFotoProfile,
|
||||
UploadFotoProfileLayout,
|
||||
ProfileView
|
||||
};
|
||||
|
||||
192
src/app_modules/katalog/profile/view/view.tsx
Normal file
192
src/app_modules/katalog/profile/view/view.tsx
Normal file
@@ -0,0 +1,192 @@
|
||||
"use client";
|
||||
|
||||
import { Warna } from "@/app/lib/warna";
|
||||
import {
|
||||
ActionIcon,
|
||||
BackgroundImage,
|
||||
Box,
|
||||
Center,
|
||||
Flex,
|
||||
Grid,
|
||||
Group,
|
||||
Image,
|
||||
Paper,
|
||||
Text,
|
||||
} from "@mantine/core";
|
||||
import { useShallowEffect } from "@mantine/hooks";
|
||||
import {
|
||||
IconAddressBook,
|
||||
IconCamera,
|
||||
IconEditCircle,
|
||||
IconGenderFemale,
|
||||
IconGenderMale,
|
||||
IconHome,
|
||||
IconMail,
|
||||
} from "@tabler/icons-react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { myConsole } from "@/app/fun/my_console";
|
||||
import { useAtom } from "jotai";
|
||||
import { ApiHipmi } from "@/app/lib/api";
|
||||
import { loadDataProfile } from "../fun/fun_get_profile";
|
||||
import { getFotoProfile } from "../api/get-foto-profile";
|
||||
|
||||
export default function ProfileView({data}: {data: any}) {
|
||||
const router = useRouter();
|
||||
|
||||
//Get data profile
|
||||
const [profile, setProfile] = useState(data);
|
||||
useShallowEffect(() => {
|
||||
loadDataProfile(setProfile);
|
||||
}, []);
|
||||
|
||||
const [foto, setFoto] = useState<any | null>(null);
|
||||
useShallowEffect(() => {
|
||||
if (profile?.imagesId === undefined || profile?.imagesId === null) {
|
||||
myConsole("Waiting data");
|
||||
} else {
|
||||
getFotoProfile(profile.imagesId).then((res) => setFoto(res?.url));
|
||||
}
|
||||
myConsole(profile?.imagesId);
|
||||
}, [profile?.imagesId]);
|
||||
|
||||
return (
|
||||
<>
|
||||
{/* {JSON.stringify(data)} */}
|
||||
{/* Background dan foto */}
|
||||
<Box>
|
||||
<Paper bg={"gray"} p={"md"}>
|
||||
<Image alt="" src={"/aset/logo.png"} />
|
||||
</Paper>
|
||||
<Center>
|
||||
{foto ? (
|
||||
<Image
|
||||
radius={50}
|
||||
alt=""
|
||||
src={ApiHipmi.get_foto + `${foto}`}
|
||||
height={100}
|
||||
width={100}
|
||||
sx={{
|
||||
position: "absolute",
|
||||
marginBottom: 10,
|
||||
paddingBottom: 10,
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
<Image
|
||||
radius={50}
|
||||
alt=""
|
||||
src={"/aset/avatar.png"}
|
||||
height={100}
|
||||
width={100}
|
||||
sx={{
|
||||
position: "absolute",
|
||||
marginBottom: 10,
|
||||
paddingBottom: 10,
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</Center>
|
||||
<Center>
|
||||
<ActionIcon
|
||||
mr={-70}
|
||||
mt={10}
|
||||
variant="transparent"
|
||||
bg={"gray"}
|
||||
radius={50}
|
||||
onClick={() => router.push("/dev/katalog/profile/upload")}
|
||||
sx={{ position: "relative" }}
|
||||
>
|
||||
<IconCamera color="black" size={20} />
|
||||
</ActionIcon>
|
||||
</Center>
|
||||
</Box>
|
||||
|
||||
{/* Username dan Nama */}
|
||||
<Group position="apart">
|
||||
<Flex direction={"column"} mt={"lg"}>
|
||||
<Text fz={"lg"} fw={"bold"}>
|
||||
{profile?.name}
|
||||
</Text>
|
||||
<Text fz={"xs"}>@{profile?.User?.username}</Text>
|
||||
</Flex>
|
||||
<ActionIcon
|
||||
variant="transparent"
|
||||
onClick={() => {
|
||||
router.push("/dev/katalog/profile/edit");
|
||||
}}
|
||||
>
|
||||
<IconEditCircle color={Warna.hijau_muda} size={20} />
|
||||
</ActionIcon>
|
||||
</Group>
|
||||
|
||||
{/* Info user: nomor, email dll */}
|
||||
<Flex direction={"column"} pt={"lg"}>
|
||||
<Grid>
|
||||
<Grid.Col span={"content"}>
|
||||
<IconAddressBook />
|
||||
</Grid.Col>
|
||||
<Grid.Col span={"auto"}>
|
||||
<Text>
|
||||
{" "}
|
||||
<Text>+{profile?.User.nomor}</Text>
|
||||
</Text>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
|
||||
<Grid>
|
||||
<Grid.Col span={"content"}>
|
||||
<IconMail />
|
||||
</Grid.Col>
|
||||
<Grid.Col span={"auto"}>
|
||||
<Text>
|
||||
{" "}
|
||||
<Text> {profile?.email}</Text>
|
||||
</Text>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
|
||||
<Grid>
|
||||
<Grid.Col span={"content"}>
|
||||
<IconHome />
|
||||
</Grid.Col>
|
||||
<Grid.Col span={"auto"}>
|
||||
<Text> {profile?.alamat}</Text>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
|
||||
{(() => {
|
||||
if (profile?.jenisKelamin === "Laki - laki") {
|
||||
return (
|
||||
<>
|
||||
<Grid>
|
||||
<Grid.Col span={"content"}>
|
||||
<IconGenderMale />
|
||||
</Grid.Col>
|
||||
<Grid.Col span={"auto"}>
|
||||
<Text> {profile?.jenisKelamin}</Text>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
</>
|
||||
);
|
||||
} else {
|
||||
return (
|
||||
<>
|
||||
<Grid>
|
||||
<Grid.Col span={"content"}>
|
||||
<IconGenderFemale />
|
||||
</Grid.Col>
|
||||
<Grid.Col span={"auto"}>
|
||||
<Text> {profile?.jenisKelamin}</Text>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
</>
|
||||
);
|
||||
}
|
||||
})()}
|
||||
</Flex>
|
||||
|
||||
{/* <pre>{JSON.stringify(profile, null, 2)}</pre> */}
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -25,7 +25,7 @@ export default function KatalogLayout({ children }: { children: any }) {
|
||||
Katalog
|
||||
</Text>
|
||||
<Group spacing={"sm"}>
|
||||
<ActionIcon>
|
||||
<ActionIcon variant="transparent" onClick={() => router.push("/dev/katalog/portofolio/create")}>
|
||||
<IconPencilPlus />
|
||||
</ActionIcon>
|
||||
{/* <Logout /> */}
|
||||
|
||||
@@ -25,169 +25,21 @@ import {
|
||||
} from "@tabler/icons-react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { getProfile } from "../profile";
|
||||
import { ProfileView, getProfile } from "../profile";
|
||||
import { gs_profile } from "../profile/state/global_state";
|
||||
import { myConsole } from "@/app/fun/my_console";
|
||||
import { useAtom } from "jotai";
|
||||
import { loadDataProfile } from "../profile/fun/fun_get_profile";
|
||||
import { getFotoProfile } from "../profile/api/get-foto-profile";
|
||||
import { ApiHipmi } from "@/app/lib/api";
|
||||
import { PortofolioView } from "../portofolio";
|
||||
|
||||
export default function KatalogView({data}: {data: any}) {
|
||||
const router = useRouter();
|
||||
|
||||
//Get data profile
|
||||
const [profile, setProfile] = useState(data)
|
||||
useShallowEffect(() => {
|
||||
loadDataProfile(setProfile);
|
||||
}, []);
|
||||
|
||||
const [foto, setFoto] = useState<any | null>(null);
|
||||
useShallowEffect(() => {
|
||||
if (profile?.imagesId === undefined || profile?.imagesId === null) {
|
||||
myConsole("Waiting data");
|
||||
} else {
|
||||
getFotoProfile(profile.imagesId).then((res) => setFoto(res?.url));
|
||||
}
|
||||
myConsole(profile?.imagesId);
|
||||
}, [profile?.imagesId]);
|
||||
|
||||
export default function KatalogView({ data, porto }: { data: any, porto: any }) {
|
||||
return (
|
||||
<>
|
||||
{/* Background dan foto */}
|
||||
<Box>
|
||||
<Paper bg={"gray"} p={"md"}>
|
||||
<Image alt="" src={"/aset/logo.png"} />
|
||||
</Paper>
|
||||
<Center>
|
||||
{foto ? (
|
||||
<Image
|
||||
radius={50}
|
||||
alt=""
|
||||
src={ApiHipmi.get_foto + `${foto}`}
|
||||
height={100}
|
||||
width={100}
|
||||
sx={{
|
||||
position: "absolute",
|
||||
marginBottom: 10,
|
||||
paddingBottom: 10,
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
<Image
|
||||
radius={50}
|
||||
alt=""
|
||||
src={"/aset/avatar.png"}
|
||||
height={100}
|
||||
width={100}
|
||||
sx={{
|
||||
position: "absolute",
|
||||
marginBottom: 10,
|
||||
paddingBottom: 10,
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</Center>
|
||||
<Center>
|
||||
<ActionIcon
|
||||
mr={-70}
|
||||
mt={10}
|
||||
variant="transparent"
|
||||
bg={"gray"}
|
||||
radius={50}
|
||||
onClick={() => router.push("/dev/katalog/profile/upload")}
|
||||
sx={{ position: "relative" }}
|
||||
>
|
||||
<IconCamera color="black" size={20} />
|
||||
</ActionIcon>
|
||||
</Center>
|
||||
</Box>
|
||||
|
||||
{/* Username dan Nama */}
|
||||
<Group position="apart">
|
||||
<Flex direction={"column"} mt={"lg"}>
|
||||
<Text fz={"lg"} fw={"bold"}>
|
||||
{profile?.name}
|
||||
</Text>
|
||||
<Text fz={"xs"}>@{profile?.User?.username}</Text>
|
||||
</Flex>
|
||||
<ActionIcon
|
||||
variant="transparent"
|
||||
onClick={() => {
|
||||
router.push("/dev/katalog/profile/edit");
|
||||
}}
|
||||
>
|
||||
<IconEditCircle color={Warna.hijau_muda} size={20} />
|
||||
</ActionIcon>
|
||||
</Group>
|
||||
|
||||
{/* Info user: nomor, email dll */}
|
||||
<Flex direction={"column"} pt={"lg"}>
|
||||
<Grid>
|
||||
<Grid.Col span={"content"}>
|
||||
<IconAddressBook />
|
||||
</Grid.Col>
|
||||
<Grid.Col span={"auto"}>
|
||||
<Text>
|
||||
{" "}
|
||||
<Text>+{profile?.User.nomor}</Text>
|
||||
</Text>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
|
||||
<Grid>
|
||||
<Grid.Col span={"content"}>
|
||||
<IconMail />
|
||||
</Grid.Col>
|
||||
<Grid.Col span={"auto"}>
|
||||
<Text>
|
||||
{" "}
|
||||
<Text> {profile?.email}</Text>
|
||||
</Text>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
|
||||
<Grid>
|
||||
<Grid.Col span={"content"}>
|
||||
<IconHome />
|
||||
</Grid.Col>
|
||||
<Grid.Col span={"auto"}>
|
||||
<Text> {profile?.alamat}</Text>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
|
||||
{(() => {
|
||||
if (profile?.jenisKelamin === "Laki - laki") {
|
||||
return (
|
||||
<>
|
||||
<Grid>
|
||||
<Grid.Col span={"content"}>
|
||||
<IconGenderMale />
|
||||
</Grid.Col>
|
||||
<Grid.Col span={"auto"}>
|
||||
<Text> {profile?.jenisKelamin}</Text>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
</>
|
||||
);
|
||||
} else {
|
||||
return (
|
||||
<>
|
||||
<Grid>
|
||||
<Grid.Col span={"content"}>
|
||||
<IconGenderFemale />
|
||||
</Grid.Col>
|
||||
<Grid.Col span={"auto"}>
|
||||
<Text> {profile?.jenisKelamin}</Text>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
</>
|
||||
);
|
||||
}
|
||||
})()}
|
||||
</Flex>
|
||||
|
||||
{/* <pre>{JSON.stringify(profile, null, 2)}</pre> */}
|
||||
<ProfileView data={data} />
|
||||
<PortofolioView profileId={data.id} porto={porto}/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user