Portofolio

#feat
- Create porto
- Edit Porto
- Upload gambar background profile
- List user
- Search user
## No issuue
This commit is contained in:
2024-01-19 14:16:16 +08:00
parent 01da30bdb5
commit 5f4337333a
175 changed files with 3451 additions and 1017 deletions

View File

@@ -1,25 +0,0 @@
"use server";
import prisma from "@/app/lib/prisma";
import { getConfig } from "@/bin/config";
import { unsealData } from "iron-session";
import { cookies } from "next/headers";
import fs from "fs";
import yaml from "yaml";
const config = yaml.parse(fs.readFileSync("config.yaml").toString());
/**
* @returns token(id and username)
*/
export async function getToken() {
const c = cookies().get("ssn");
const token = await unsealData(c?.value as string, {
password: await config.server.password,
});
const data = JSON.parse(token as any)
return data;
}

View File

@@ -0,0 +1,17 @@
"use server";
import prisma from "@/app/lib/prisma";
export async function User_getOneById(userId: string) {
const data = await prisma.user.findFirst({
where: {
id: userId,
},
select: {
id: true,
Profile: true,
},
});
return data;
}

View File

@@ -1,4 +1,4 @@
import HomeView from "./view";
import HomeLayout from "./layout";
import { getToken } from "./api/api-get-token";
export {HomeView, HomeLayout, getToken}
export {HomeView, HomeLayout}

View File

@@ -1,10 +1,59 @@
"use client";
import { ActionIcon, AppShell, Flex, Group, Header, Text } from "@mantine/core";
import {
ActionIcon,
AppShell,
Avatar,
Center,
Flex,
Footer,
Grid,
Group,
Header,
SimpleGrid,
Stack,
Text,
ThemeIcon,
} from "@mantine/core";
import { HomeView } from ".";
import { IconUserSearch, IconAward, IconQrcode } from "@tabler/icons-react";
import {
IconUserSearch,
IconAward,
IconQrcode,
IconUserCircle,
} from "@tabler/icons-react";
import { Logout } from "../auth";
import { RouterProfile } from "@/app/lib/router_hipmi/router_katalog";
import { MODEL_USER } from "./model/interface";
import React, { useState } from "react";
import { useRouter } from "next/navigation";
import { ComponentGlobal_NotifikasiPeringatan } from "../component_global/notif_global/notifikasi_peringatan";
import { ComponentGlobal_NotifikasiBerhasil } from "../component_global/notif_global/notifikasi_berhasil";
import { RouterUserSearch } from "@/app/lib/router_hipmi/router_user_search";
export default function HomeLayout({
dataUser,
children,
}: {
dataUser: MODEL_USER;
children: React.ReactNode;
}) {
const router = useRouter();
const [user, setUser] = useState(dataUser);
const listFooter = [
{
id: 1,
name: "Temukan user",
icon: <IconUserSearch />,
link: ``,
},
{
id: 2,
name: "Profile",
icon: <IconUserCircle />,
link: RouterProfile.katalog,
},
];
export default function HomeLayout({ children }: { children: any }) {
return (
<>
<AppShell
@@ -12,9 +61,6 @@ export default function HomeLayout({ children }: { children: any }) {
<Header height={50} bg={"dark"}>
<Group position="apart" align="center" h={50} p={"sm"}>
<Group spacing={"sm"}>
<ActionIcon>
<IconUserSearch />
</ActionIcon>
<ActionIcon>
<IconAward />
</ActionIcon>
@@ -26,12 +72,57 @@ export default function HomeLayout({ children }: { children: any }) {
<ActionIcon>
<IconQrcode />
</ActionIcon>
<Logout />
</Group>
</Group>
</Header>
}
footer={
<Footer height={70} bg={"dark"}>
<Grid p={"xs"}>
<Grid.Col
span={"auto"}
onClick={() => {
if (user.Profile === null) {
ComponentGlobal_NotifikasiPeringatan("Lengkapi Profile");
} else {
// router.push(RouterProfile.katalog + `${user.Profile.id}`);
router.push(RouterUserSearch.main)
}
}}
>
<Stack align="center" spacing={0}>
<ActionIcon variant={"transparent"}>
<IconUserSearch color="white" />
</ActionIcon>
<Text fz={"xs"} c={"white"}>
Temukan pengguna
</Text>
</Stack>
</Grid.Col>
<Grid.Col
span={"auto"}
onClick={() => {
if (user.Profile === null) {
router.push(RouterProfile.create + `${user.id}`);
} else {
router.push(RouterProfile.katalog + `${user.Profile.id}`);
}
}}
>
<Stack align="center" spacing={0}>
<ActionIcon variant={"transparent"}>
{user.Profile === null ? <IconUserCircle color="white" /> : <Avatar radius={"xl"} size={20} src={RouterProfile.api_foto_profile + `${user.Profile.imagesId}`}/>}
</ActionIcon>
<Text fz={"xs"} c={"white"}>
Profile
</Text>
</Stack>
</Grid.Col>
</Grid>
</Footer>
}
>
{children}
</AppShell>
</>

View File

@@ -1,4 +1,6 @@
export interface MODEL_AUTHOR {
import { MODEL_PROFILE } from "@/app_modules/katalog/profile/model/interface";
export interface MODEL_USER {
id: string;
username: string;
nomor: string;
@@ -6,4 +8,6 @@ export interface MODEL_AUTHOR {
createdAt: Date;
updatedAt: Date;
masterUserRoleId: string;
Profile: MODEL_PROFILE
}

View File

@@ -1,4 +1,6 @@
export interface MODEL_User_profile {
import { MODEL_IMAGES } from "@/app_modules/models/interface";
export interface MODEL_PROFILE_OLD {
id: string;
username: string;
nomor: string;
@@ -8,8 +10,11 @@ export interface MODEL_User_profile {
email: string;
jenisKelamin: string;
name: string;
imagesId: string
ImageProfile: {
url: string;
} | null;
} | null;
}
imagesBackgroundId: string,
ImagesBackground: MODEL_IMAGES
}
}

View File

@@ -13,11 +13,6 @@ import {
ThemeIcon,
Title,
} from "@mantine/core";
import { Logout } from "../auth";
import { useState } from "react";
import { ApiHipmi } from "@/app/lib/api";
import { useShallowEffect } from "@mantine/hooks";
import { getToken } from "./api/api-get-token";
import {
IconAffiliate,
@@ -32,40 +27,28 @@ import {
} from "@tabler/icons-react";
import toast from "react-simple-toasts";
import { getProfile } from "../katalog/profile";
import { useRouter } from "next/navigation";
import { useAtom } from "jotai";
import { gs_token } from "./state/global_state";
import { loadDataProfile } from "../katalog/profile/fun/fun_get_profile";
import {
gs_fotoProfile,
gs_profile,
} from "../katalog/profile/state/global_state";
import { gs_ListPortofolio } from "../katalog/portofolio/state/global_state";
import { myConsole } from "@/app/fun/my_console";
import { getFotoProfile } from "../katalog/profile/api/get-foto-profile";
import { funGetUserProfile } from "../fun/get_user_profile";
import { MODEL_User_profile } from "./models/user_profile";
import { MODEL_PROFILE_OLD } from "./model/user_profile";
import AppNotif from "../notif";
// export const dynamic = "force-dynamic"
// export const revalidate = 0
export default function HomeView({ user }: { user: MODEL_User_profile }) {
export default function HomeView() {
const router = useRouter();
const [stateUser, setStateUser] = useState(user);
// const [stateUser, setStateUser] = useState(user);
const listHalaman = [
{
id: 1,
name: "Forums",
icon: <IconMessages size={50} />,
link: "",
name: "Crowd Funding",
icon: <IconHeartHandshake size={50} />,
link: `/dev/crowd/splash`,
},
{
id: 2,
name: "Project Collaboration",
icon: <IconAffiliate size={50} />,
name: "Event",
icon: <IconPresentation size={50} />,
link: "",
},
{
@@ -76,15 +59,15 @@ export default function HomeView({ user }: { user: MODEL_User_profile }) {
},
{
id: 4,
name: "Event",
icon: <IconPresentation size={50} />,
name: "Project Collaboration",
icon: <IconAffiliate size={50} />,
link: "",
},
{
id: 5,
name: "Crowd Funding",
icon: <IconHeartHandshake size={50} />,
link: `/dev/crowd/splash`,
name: "Forums",
icon: <IconMessages size={50} />,
link: "",
},
{
id: 6,
@@ -109,7 +92,7 @@ export default function HomeView({ user }: { user: MODEL_User_profile }) {
return (
<>
<Box>
<Flex align={"center"} gap={"sm"}>
{/* <Flex align={"center"} gap={"sm"}>
<ActionIcon
size={30}
variant="transparent"
@@ -128,7 +111,7 @@ export default function HomeView({ user }: { user: MODEL_User_profile }) {
Welcome to ,{" "}
{stateUser.username ? stateUser.username : <Loader size={"xs"} />}
</Text>
</Flex>
</Flex> */}
<Paper bg={"dark"} radius={5} my={"xs"}>
<Image alt="logo" src={"/aset/investasi/home-hipmi.png"} />