@@ -14,19 +14,12 @@ export default async function Layout({
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
const version = versionUpdate.version;
|
||||
|
||||
const dataUser = await funGlobal_getUserById({ userId: userLoginId });
|
||||
const dataUser = await funGlobal_getUserById({ userId: userLoginId as string});
|
||||
const listNotifikasi = await adminNotifikasi_getByUserId({page: 1});
|
||||
const countNotifikasi = await adminNotifikasi_countNotifikasi();
|
||||
|
||||
return (
|
||||
<>
|
||||
{/* <AdminLayout
|
||||
listNotif={listNotif as any}
|
||||
dataUser={dataUser as any}
|
||||
countNotifikasi={countNotifikasi}
|
||||
>
|
||||
{children}
|
||||
</AdminLayout> */}
|
||||
<Admin_NewLayout
|
||||
user={dataUser as any}
|
||||
countNotifikasi={countNotifikasi as any}
|
||||
|
||||
@@ -16,7 +16,7 @@ export default async function Page({ params }: { params: { id: string } }) {
|
||||
"ProjectCollaboration_AnggotaRoomChat",
|
||||
]);
|
||||
let listMsg = await colab_getMessageByRoomId({ roomId: roomId, page: 1 });
|
||||
const dataUserLogin = await user_getOneByUserId(userLoginId);
|
||||
const dataUserLogin = await user_getOneByUserId(userLoginId as string);
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -29,7 +29,7 @@ export default async function Page({ params }: { params: { id: string } }) {
|
||||
/> */}
|
||||
|
||||
<Colab_GroupChatView
|
||||
userLoginId={userLoginId}
|
||||
userLoginId={userLoginId as string}
|
||||
listMsg={listMsg}
|
||||
selectRoom={dataRoom as any}
|
||||
dataUserLogin={dataUserLogin as any}
|
||||
|
||||
@@ -16,7 +16,7 @@ export default async function Page({ params }: { params: { id: string } }) {
|
||||
<>
|
||||
<Colab_MainDetail
|
||||
dataColab={dataColab as any}
|
||||
userLoginId={userLoginId}
|
||||
userLoginId={userLoginId as string}
|
||||
listPartisipan={listPartisipan as any}
|
||||
cekPartisipan={cekPartisipan}
|
||||
/>
|
||||
|
||||
@@ -8,7 +8,7 @@ export default async function Page() {
|
||||
|
||||
return (
|
||||
<>
|
||||
<Colab_Beranda listData={listData as any} userLoginId={userLoginId} />
|
||||
<Colab_Beranda listData={listData as any} userLoginId={userLoginId as string} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ export default async function Page({ params }: { params: { id: string } }) {
|
||||
<>
|
||||
<CreateCeritaPenggalangDonasi
|
||||
dataTemporary={getTemporaryCreate as any}
|
||||
userId={userLoginId}
|
||||
userId={userLoginId as string}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -20,7 +20,7 @@ export default async function Layout({
|
||||
<LayoutDetailMainDonasi
|
||||
donasiId={donasiId}
|
||||
authorId={authorId as any}
|
||||
userLoginId={userLoginId}
|
||||
userLoginId={userLoginId as string}
|
||||
>
|
||||
{children}
|
||||
</LayoutDetailMainDonasi>
|
||||
|
||||
@@ -15,7 +15,7 @@ export default async function Page({ params }: { params: { id: string } }) {
|
||||
<DetailMainDonasi
|
||||
dataDonasi={dataDonasi as any}
|
||||
countDonatur={countDonatur}
|
||||
userLoginId={userLoginId}
|
||||
userLoginId={userLoginId as string}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -13,7 +13,7 @@ export default async function Page({ params }: { params: { id: string } }) {
|
||||
<DetailPublishDonasi
|
||||
dataPublish={dataPublish as any}
|
||||
countDonatur={countDonatur}
|
||||
userLoginId={userLoginId}
|
||||
userLoginId={userLoginId as string}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -12,7 +12,7 @@ export default async function Page({ params }: { params: { id: string } }) {
|
||||
<Donasi_MetodePembayaran
|
||||
listBank={listBank}
|
||||
donasiId={donasiId}
|
||||
authorId={userLoginId}
|
||||
authorId={userLoginId as string}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -7,6 +7,9 @@ export default async function Page() {
|
||||
const listTipeAcara = await Event_getMasterTipeAcara();
|
||||
|
||||
return (
|
||||
<Event_Create listTipeAcara={listTipeAcara as any} authorId={userLoginId} />
|
||||
<Event_Create
|
||||
listTipeAcara={listTipeAcara as any}
|
||||
authorId={userLoginId as string}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import { event_getOneById } from "@/app_modules/event/fun/get/get_one_by_id";
|
||||
|
||||
export default async function Page({ params }: { params: { id: string } }) {
|
||||
let eventId = params.id;
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
const userLoginId : any= await funGetUserIdByToken();
|
||||
|
||||
const dataEvent = await event_getOneById(eventId);
|
||||
const listPeserta = await Event_getListPesertaById(eventId);
|
||||
@@ -19,7 +19,7 @@ export default async function Page({ params }: { params: { id: string } }) {
|
||||
<Event_DetailMain
|
||||
dataEvent={dataEvent as any}
|
||||
listPeserta={listPeserta as any}
|
||||
userLoginId={userLoginId}
|
||||
userLoginId={userLoginId as string}
|
||||
isJoin={isJoin}
|
||||
totalPeserta={totalPeserta as any}
|
||||
/>
|
||||
|
||||
@@ -25,7 +25,7 @@ export default async function Page({ params }: { params: { id: string } }) {
|
||||
<Forum_MainDetail
|
||||
dataPosting={dataPosting as any}
|
||||
listKomentar={listKomentar as any}
|
||||
userLoginId={userLoginId}
|
||||
userLoginId={userLoginId as string}
|
||||
countKomentar={countKomentar}
|
||||
/>
|
||||
</>
|
||||
|
||||
@@ -9,7 +9,7 @@ export default async function Layout({
|
||||
children: React.ReactNode;
|
||||
}) {
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
const dataAuthor = await user_getOneByUserId(userLoginId);
|
||||
const dataAuthor = await user_getOneByUserId(userLoginId as string);
|
||||
|
||||
return (
|
||||
<>
|
||||
|
||||
@@ -8,7 +8,10 @@ export default async function Page() {
|
||||
|
||||
return (
|
||||
<>
|
||||
<Forum_Beranda listForum={listForum as any} userLoginId={userLoginId} />
|
||||
<Forum_Beranda
|
||||
listForum={listForum as any}
|
||||
userLoginId={userLoginId as string}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ export default async function Page({ params }: { params: { id: string } }) {
|
||||
<>
|
||||
<Forum_ReportKomentarLainnya
|
||||
komentarId={komentarId}
|
||||
userLoginId={userLoginId}
|
||||
userLoginId={userLoginId as string}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -9,7 +9,7 @@ export default async function Page({ params }: { params: { id: string } }) {
|
||||
<>
|
||||
<Forum_ReportPostingLainnya
|
||||
postingId={postingId}
|
||||
userLoginId={userLoginId}
|
||||
userLoginId={userLoginId as string}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -13,7 +13,7 @@ export default async function Page({ params }: { params: { id: string } }) {
|
||||
<Forum_ReportPosting
|
||||
postingId={postingId}
|
||||
listReport={listReport as any}
|
||||
userLoginId={userLoginId}
|
||||
userLoginId={userLoginId as string}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -10,7 +10,7 @@ import { redirect } from "next/navigation";
|
||||
export default async function Page() {
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
const dataUser = await user_getOneByUserId(userLoginId);
|
||||
const dataUser = await user_getOneByUserId(userLoginId as string);
|
||||
const dataJob = await job_getTwoForHomeView();
|
||||
|
||||
if (dataUser?.active === false) {
|
||||
|
||||
@@ -13,7 +13,7 @@ export default async function Page({ params }: { params: { id: string } }) {
|
||||
<>
|
||||
<Investasi_UiDetailMain
|
||||
dataInvestasi={dataInvestasi as any}
|
||||
userLoginId={userLoginId}
|
||||
userLoginId={userLoginId as string}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -14,7 +14,7 @@ export default async function Page({ params }: { params: { id: string } }) {
|
||||
<>
|
||||
<Investasi_UiDetailPortofolio
|
||||
dataInvestasi={dataPortofolio as any}
|
||||
userLoginId={userLoginId}
|
||||
userLoginId={userLoginId as string}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -9,7 +9,9 @@ export default async function Page() {
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
const statusTransaksi = await getMaster_StatusTransaksiInvestasi();
|
||||
const listTransaksi = await getListAllTransaksiById_Investasi(userLoginId);
|
||||
const listTransaksi = await getListAllTransaksiById_Investasi(
|
||||
userLoginId as string
|
||||
);
|
||||
|
||||
// NEW
|
||||
const dataTransaksi = await investasi_funGetTransaksiByUserId({ page: 1 });
|
||||
|
||||
@@ -6,7 +6,7 @@ import getOneInvestasiById from "@/app_modules/investasi/fun/get_one_investasi_b
|
||||
export default async function Page({ params }: { params: { id: string } }) {
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
const userLogin = await funGetUserProfile(userLoginId);
|
||||
const userLogin = await funGetUserProfile(userLoginId as string);
|
||||
const dataInvestasi = await getOneInvestasiById(params.id);
|
||||
|
||||
// console.log(dataInvestasi);
|
||||
|
||||
@@ -19,7 +19,7 @@ export default async function Layout({
|
||||
<>
|
||||
<KatalogLayout
|
||||
profileId={profileId}
|
||||
userLoginId={userLoginId}
|
||||
userLoginId={userLoginId as string}
|
||||
authorId={authorId as any}
|
||||
>
|
||||
{children}
|
||||
|
||||
@@ -17,7 +17,7 @@ export default async function Layout({
|
||||
<>
|
||||
<PortofolioLayout
|
||||
portoId={portoId}
|
||||
userLoginId={userLoginId}
|
||||
userLoginId={userLoginId as string}
|
||||
authorId={getPorto?.Profile?.User?.id as any}
|
||||
>
|
||||
{children}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
import { CreateProfile } from "@/app_modules/katalog/profile";
|
||||
|
||||
export default async function Page() {
|
||||
|
||||
@@ -7,7 +7,7 @@ import { redirect } from "next/navigation";
|
||||
export default async function Page() {
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
const dataUser = await user_getOneByUserId(userLoginId);
|
||||
const dataUser = await user_getOneByUserId(userLoginId as string);
|
||||
|
||||
if (dataUser?.active === true) {
|
||||
return redirect(RouterHome.main_home);
|
||||
|
||||
@@ -18,7 +18,7 @@ export default async function Layout({
|
||||
<>
|
||||
<LayoutVote_DetailKontribusi
|
||||
votingId={votingId}
|
||||
userLoginId={userLoginId}
|
||||
userLoginId={userLoginId as string}
|
||||
dataVoting={dataVoting}
|
||||
>
|
||||
{children}
|
||||
|
||||
@@ -11,14 +11,14 @@ export default async function Layout({
|
||||
params: { id: string };
|
||||
}) {
|
||||
const votingId = params.id;
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
const dataVoting = await voting_funGetOneVotingbyId(votingId);
|
||||
|
||||
return (
|
||||
<>
|
||||
<LayoutVote_MainDetail
|
||||
votingId={votingId}
|
||||
userLoginId={userLoginId}
|
||||
userLoginId={userLoginId as string}
|
||||
dataVoting={dataVoting}
|
||||
>
|
||||
{children}
|
||||
|
||||
@@ -24,7 +24,7 @@ export default async function Page({ params }: { params: { id: string } }) {
|
||||
isKontributor={isKontributor}
|
||||
pilihanKontributor={pilihanKontributor as any}
|
||||
listKontributor={listKontributor as any}
|
||||
userLoginId={userLoginId}
|
||||
userLoginId={userLoginId as string}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -19,7 +19,7 @@ export default async function Layout({
|
||||
<>
|
||||
<LayoutVote_DetailPublish
|
||||
votingId={votingId}
|
||||
userLoginId={userLoginId}
|
||||
userLoginId={userLoginId as string}
|
||||
dataVoting={dataVoting}
|
||||
>
|
||||
{children}
|
||||
|
||||
@@ -49,7 +49,7 @@ export default async function RootLayout({
|
||||
<RootStyleRegistry>
|
||||
{/* <MqttLoader />
|
||||
<TokenProvider token={token} envObject={envObject} /> */}
|
||||
<RealtimeProvider userLoginId={userLoginId} />
|
||||
<RealtimeProvider userLoginId={userLoginId as string} />
|
||||
{children}
|
||||
</RootStyleRegistry>
|
||||
);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
import Coba_TestLoading from "@/app_modules/zCoba";
|
||||
import { CobaRealtime } from "@/app_modules/zCoba/coba_realtime";
|
||||
|
||||
export default async function Page() {
|
||||
await new Promise((a, b) => {
|
||||
@@ -12,7 +11,7 @@ export default async function Page() {
|
||||
return (
|
||||
<>
|
||||
{/* <CobaRealtime userLoginId={userLoginId} /> */}
|
||||
<Coba_TestLoading userLoginId={userLoginId} />
|
||||
<Coba_TestLoading userLoginId={userLoginId as string} />
|
||||
{/* <ComponentGlobal_UI_LayoutTamplate /> */}
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
"use server";
|
||||
|
||||
import { prisma } from "@/app/lib";
|
||||
import { RouterAuth } from "@/app/lib/router_hipmi/router_auth";
|
||||
import { permanentRedirect } from "next/navigation";
|
||||
|
||||
export async function funGlobal_getUserById({ userId }: { userId: string }) {
|
||||
if (!userId) return permanentRedirect(RouterAuth.login);
|
||||
|
||||
const data = await prisma.user.findFirst({
|
||||
where: {
|
||||
id: userId,
|
||||
|
||||
@@ -1,18 +1,17 @@
|
||||
"use server";
|
||||
|
||||
import { cookies } from "next/headers";
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { redirect } from "next/navigation";
|
||||
import { RouterAuth } from "@/app/lib/router_hipmi/router_auth";
|
||||
import { cookies } from "next/headers";
|
||||
|
||||
export async function funGetUserIdByToken() {
|
||||
const c = cookies().get("ssn");
|
||||
const token = c?.value
|
||||
const cekToken = await prisma.userSession.findFirst({
|
||||
where: {
|
||||
token: c?.value,
|
||||
token: token,
|
||||
},
|
||||
});
|
||||
|
||||
if (cekToken === null) return redirect(RouterAuth.login);
|
||||
if (cekToken === null) return null
|
||||
return cekToken.userId;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,141 @@
|
||||
import { AccentColor } from "@/app_modules/_global/color";
|
||||
import { MODEL_USER } from "@/app_modules/home/model/interface";
|
||||
import { Menu, ActionIcon, Stack, Grid, Center, Text } from "@mantine/core";
|
||||
import { IconUserCircle, IconUser, IconPhone } from "@tabler/icons-react";
|
||||
import { useState } from "react";
|
||||
import Admin_Logout from "../logout";
|
||||
"use client";
|
||||
|
||||
export function Admin_ComponentButtonUserCircle({ dataUser }: { dataUser: MODEL_USER }) {
|
||||
import { RouterAuth } from "@/app/lib/router_hipmi/router_auth";
|
||||
import { Warna } from "@/app/lib/warna";
|
||||
import { AccentColor } from "@/app_modules/_global/color";
|
||||
import {
|
||||
ComponentGlobal_NotifikasiBerhasil,
|
||||
ComponentGlobal_NotifikasiPeringatan,
|
||||
} from "@/app_modules/_global/notif_global";
|
||||
import { auth_Logout } from "@/app_modules/auth/fun/fun_logout";
|
||||
import { gs_kodeId } from "@/app_modules/auth/state/state";
|
||||
import { MODEL_USER } from "@/app_modules/home/model/interface";
|
||||
import {
|
||||
ActionIcon,
|
||||
Button,
|
||||
Center,
|
||||
Divider,
|
||||
Grid,
|
||||
Group,
|
||||
Menu,
|
||||
Modal,
|
||||
Popover,
|
||||
Stack,
|
||||
Text,
|
||||
Title,
|
||||
} from "@mantine/core";
|
||||
import { IconPhone, IconUser, IconUserCircle } from "@tabler/icons-react";
|
||||
import { useAtom } from "jotai";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
|
||||
export function Admin_ComponentButtonUserCircle({
|
||||
dataUser,
|
||||
}: {
|
||||
dataUser: MODEL_USER;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [isOpenMenuUser, setOpenMenuUser] = useState(false);
|
||||
const [openPop, setOpenPop] = useState(false);
|
||||
const [openModal, setOpenModal] = useState(false);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [kodeId, setKodeId] = useAtom(gs_kodeId);
|
||||
const [loadingLogout, setLoadingLogout] = useState(false);
|
||||
|
||||
async function onClickLogout() {
|
||||
const res = await auth_Logout();
|
||||
if (res.status === 200) {
|
||||
console.log(res);
|
||||
setLoadingLogout(true);
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||
setKodeId("");
|
||||
setOpenModal(false);
|
||||
router.push(RouterAuth.login, { scroll: false });
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiPeringatan(res.message);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Popover opened={openPop} onChange={setOpenPop} position="right-end">
|
||||
<Popover.Target>
|
||||
<ActionIcon
|
||||
variant="transparent"
|
||||
onClick={() => {
|
||||
setOpenPop((o) => !o);
|
||||
}}
|
||||
>
|
||||
<IconUserCircle color="white" />
|
||||
</ActionIcon>
|
||||
</Popover.Target>
|
||||
|
||||
<Popover.Dropdown style={{ backgroundColor: AccentColor.blue }}>
|
||||
<Stack>
|
||||
<Grid>
|
||||
<Grid.Col span={2}>
|
||||
<IconUser />
|
||||
</Grid.Col>
|
||||
<Grid.Col span={"auto"}>
|
||||
<Text lineClamp={1}>{dataUser.username}</Text>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
|
||||
<Grid>
|
||||
<Grid.Col span={2}>
|
||||
<IconPhone />
|
||||
</Grid.Col>
|
||||
<Grid.Col span={"auto"}>
|
||||
<Text lineClamp={1}>+{dataUser.nomor}</Text>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
|
||||
<Divider />
|
||||
|
||||
<Center>
|
||||
<Button radius={"xl"} onClick={() => setOpenModal(true)}>
|
||||
Keluar
|
||||
</Button>
|
||||
</Center>
|
||||
</Stack>
|
||||
</Popover.Dropdown>
|
||||
</Popover>
|
||||
|
||||
<Modal
|
||||
opened={openModal}
|
||||
onClose={() => setOpenModal(false)}
|
||||
centered
|
||||
withCloseButton={false}
|
||||
closeOnClickOutside={false}
|
||||
>
|
||||
<Stack>
|
||||
<Title order={6}>Anda yakin ingin keluar ?</Title>
|
||||
<Group align="center" position="center">
|
||||
<Button
|
||||
onClick={() => {
|
||||
setOpenModal(false);
|
||||
setLoading(false);
|
||||
}}
|
||||
radius={50}
|
||||
>
|
||||
Batal
|
||||
</Button>
|
||||
<Button
|
||||
loaderPosition="center"
|
||||
loading={loadingLogout ? true : false}
|
||||
radius={50}
|
||||
bg={Warna.merah}
|
||||
color="red"
|
||||
onClick={() => onClickLogout()}
|
||||
>
|
||||
Keluar
|
||||
</Button>
|
||||
</Group>
|
||||
</Stack>
|
||||
</Modal>
|
||||
</>
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Menu
|
||||
@@ -35,41 +164,44 @@ export function Admin_ComponentButtonUserCircle({ dataUser }: { dataUser: MODEL_
|
||||
}}
|
||||
>
|
||||
<Menu.Target>
|
||||
<ActionIcon variant="transparent" onClick={() => console.log("test")}>
|
||||
<IconUserCircle color="white" />
|
||||
</ActionIcon>
|
||||
<IconUserCircle color="white" />
|
||||
{/* <ActionIcon variant="transparent">
|
||||
</ActionIcon> */}
|
||||
</Menu.Target>
|
||||
|
||||
<Menu.Dropdown>
|
||||
<Stack spacing={5} px={"xs"}>
|
||||
<Menu.Item>
|
||||
<Grid>
|
||||
<Grid.Col span={2}>
|
||||
<IconUser />
|
||||
</Grid.Col>
|
||||
<Grid.Col span={"auto"}>
|
||||
<Text lineClamp={1}>{dataUser.username}</Text>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
</Menu.Item>
|
||||
<Menu.Item>
|
||||
<Grid>
|
||||
<Grid.Col span={2}>
|
||||
<IconPhone />
|
||||
</Grid.Col>
|
||||
<Grid.Col span={"auto"}>
|
||||
<Text lineClamp={1}>+{dataUser.nomor}</Text>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
</Menu.Item>
|
||||
<Menu.Item>
|
||||
<Grid>
|
||||
<Grid.Col span={2}>
|
||||
<IconUser />
|
||||
</Grid.Col>
|
||||
<Grid.Col span={"auto"}>
|
||||
<Text lineClamp={1}>{dataUser.username}</Text>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
</Menu.Item>
|
||||
<Menu.Item>
|
||||
<Grid>
|
||||
<Grid.Col span={2}>
|
||||
<IconPhone />
|
||||
</Grid.Col>
|
||||
<Grid.Col span={"auto"}>
|
||||
<Text lineClamp={1}>+{dataUser.nomor}</Text>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
</Menu.Item>
|
||||
|
||||
<Menu.Divider />
|
||||
<Center py={"xs"}>
|
||||
<Menu.Divider />
|
||||
|
||||
<Menu.Item>
|
||||
{/* <Center py={"xs"}>
|
||||
<Admin_Logout />
|
||||
</Center>
|
||||
</Stack>
|
||||
</Center> */}
|
||||
{/* <Button>Keluar</Button> */}
|
||||
<Text>Keluar</Text>
|
||||
</Menu.Item>
|
||||
</Menu.Dropdown>
|
||||
</Menu>
|
||||
</>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,20 +26,19 @@ export default function Admin_Logout() {
|
||||
const [loadingLogout, setLoadingLogout] = useState(false);
|
||||
|
||||
async function onClickLogout() {
|
||||
await auth_Logout().then((res) => {
|
||||
if (res.status === 200) {
|
||||
setLoadingLogout(true);
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||
setKodeId("");
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiPeringatan(res.message);
|
||||
}
|
||||
});
|
||||
const res = await auth_Logout()
|
||||
if (res.status === 200) {
|
||||
setLoadingLogout(true);
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||
setKodeId("");
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiPeringatan(res.message);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Modal
|
||||
{/* <Modal
|
||||
opened={opened}
|
||||
onClose={() => setOpened(false)}
|
||||
centered
|
||||
@@ -70,7 +69,7 @@ export default function Admin_Logout() {
|
||||
</Button>
|
||||
</Group>
|
||||
</Stack>
|
||||
</Modal>
|
||||
</Modal> */}
|
||||
<ActionIcon variant="transparent">
|
||||
{loading ? (
|
||||
<Loader color="gray" />
|
||||
|
||||
@@ -33,7 +33,7 @@ export default async function adminColab_funReportProjectById({
|
||||
const updateReport = await prisma.projectCollaboration_Notifikasi.create({
|
||||
data: {
|
||||
projectCollaborationId: colabId,
|
||||
adminId: userLoginId,
|
||||
adminId: userLoginId as string,
|
||||
userId: projectUpdate.userId as any,
|
||||
note: "Project Anda Telah Direport Admin",
|
||||
},
|
||||
|
||||
@@ -11,22 +11,20 @@ export async function auth_Logout() {
|
||||
try {
|
||||
const delToken = await prisma.userSession.delete({
|
||||
where: {
|
||||
userId: userId,
|
||||
userId: userId as string,
|
||||
},
|
||||
});
|
||||
|
||||
if (!delToken) return { status: 400, message: "Gagal Hapus User Session" };
|
||||
cookies().set({
|
||||
name: "ssn",
|
||||
value: "",
|
||||
|
||||
});
|
||||
|
||||
cookies().delete({
|
||||
name: "ssn",
|
||||
});
|
||||
return { status: 200, message: "Logout Berhasil" };
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
|
||||
revalidatePath("/");
|
||||
return { status: 200, message: "Logout Berhasil" };
|
||||
return { status: 200, message: "Anda Berhasil Logout" };
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import { IconLogout } from "@tabler/icons-react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { auth_Logout } from "../fun/fun_logout";
|
||||
import { RouterAuth } from "@/app/lib/router_hipmi/router_auth";
|
||||
|
||||
export default function Component_Logout() {
|
||||
const router = useRouter();
|
||||
@@ -16,13 +17,13 @@ export default function Component_Logout() {
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
async function onClickLogout() {
|
||||
await auth_Logout().then((res) => {
|
||||
if (res.status === 200) {
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiPeringatan(res.message);
|
||||
}
|
||||
});
|
||||
const res = await auth_Logout();
|
||||
if (res.status === 200) {
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||
router.push(RouterAuth.login, { scroll: false });
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiPeringatan(res.message);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
@@ -12,14 +12,14 @@ export function CheckCookies_UiLayout({
|
||||
const router = useRouter();
|
||||
|
||||
useShallowEffect(() => {
|
||||
// onCheckCookies();
|
||||
onCheckCookies();
|
||||
}, []);
|
||||
|
||||
async function onCheckCookies() {
|
||||
const cek = await fetch("/api/check-cookies");
|
||||
console.log(cek, "ini cek");
|
||||
|
||||
const result = await cek.json();
|
||||
console.log(result, "ini result");
|
||||
|
||||
if (result.success === false) {
|
||||
router.push(RouterAuth.login, { scroll: false });
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ export default async function colab_funCreateRoomChat(
|
||||
const createForAuthor =
|
||||
await prisma.projectCollaboration_AnggotaRoomChat.create({
|
||||
data: {
|
||||
userId: userLoginId,
|
||||
userId: userLoginId as string,
|
||||
projectCollaboration_RoomChatId: createRoom.id,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -8,7 +8,7 @@ export default async function colab_CekNotifikasi() {
|
||||
|
||||
const cekNotif = await prisma.projectCollaboration_Notifikasi.findMany({
|
||||
where: {
|
||||
userId: userLoginId,
|
||||
userId: userLoginId as string,
|
||||
isRead: false,
|
||||
},
|
||||
select: {
|
||||
|
||||
@@ -11,7 +11,7 @@ export default async function colab_getListNotifikasiByUserId() {
|
||||
createdAt: "desc",
|
||||
},
|
||||
where: {
|
||||
userId: userLoginId,
|
||||
userId: userLoginId as string,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
|
||||
@@ -20,7 +20,7 @@ export default async function colab_getListRoomChatByAuthorId({
|
||||
createdAt: "desc",
|
||||
},
|
||||
where: {
|
||||
userId: userLoginId,
|
||||
userId: userLoginId as string,
|
||||
},
|
||||
select: {
|
||||
ProjectCollaboration_RoomChat: {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
|
||||
export async function user_getOneByUserId(userId: string) {
|
||||
export async function user_getOneByUserId(userId?: string) {
|
||||
const data = await prisma.user.findFirst({
|
||||
where: {
|
||||
id: userId,
|
||||
|
||||
@@ -1,102 +0,0 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { RouterInvestasi_OLD } from "@/app/lib/router_hipmi/router_investasi";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
import fs from "fs";
|
||||
import _ from "lodash";
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { v4 } from "uuid";
|
||||
import { MODEL_INVESTASI } from "../_lib/interface";
|
||||
|
||||
export async function funCreateInvestasi(
|
||||
fileGambar: FormData,
|
||||
filePdf: FormData,
|
||||
data: MODEL_INVESTASI
|
||||
) {
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
// Function upload gambar
|
||||
const gambar: any = fileGambar.get("file");
|
||||
const gambarName = gambar.name;
|
||||
const gambarExtention = _.lowerCase(gambar.name.split(".").pop());
|
||||
const gambarRandomName = v4(gambarName) + "." + gambarExtention;
|
||||
|
||||
const uploadImage = await prisma.images.create({
|
||||
data: {
|
||||
url: gambarRandomName,
|
||||
label: "INVESTASI",
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
url: true,
|
||||
},
|
||||
});
|
||||
|
||||
if (!uploadImage)
|
||||
return {
|
||||
status: 400,
|
||||
message: "Gambar Kosong",
|
||||
};
|
||||
|
||||
const upFolder = Buffer.from(await gambar.arrayBuffer());
|
||||
fs.writeFileSync(`./public/investasi/${uploadImage.url}`, upFolder);
|
||||
|
||||
const createInvest = await prisma.investasi.create({
|
||||
data: {
|
||||
authorId: userLoginId,
|
||||
title: _.startCase(data.title),
|
||||
targetDana: data.targetDana.toString(),
|
||||
hargaLembar: data.hargaLembar.toString(),
|
||||
totalLembar: data.totalLembar.toString(),
|
||||
sisaLembar: data.totalLembar.toString(),
|
||||
roi: data.roi.toString(),
|
||||
masterPembagianDevidenId: data.masterPembagianDevidenId,
|
||||
masterPeriodeDevidenId: data.masterPeriodeDevidenId,
|
||||
masterPencarianInvestorId: data.masterPencarianInvestorId,
|
||||
imagesId: uploadImage.id,
|
||||
masterStatusInvestasiId: "2",
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
authorId: true,
|
||||
MasterStatusInvestasi: {
|
||||
select: {
|
||||
name: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
if (!createInvest)
|
||||
return {
|
||||
status: 400,
|
||||
message: "Gagal Disimpan",
|
||||
};
|
||||
|
||||
// await funUploadProspektusInvestasi(filePdf, createInvest.id);
|
||||
|
||||
const file: any = filePdf.get("file");
|
||||
const fName = file.name;
|
||||
const fExt = _.lowerCase(file.name.split(".").pop());
|
||||
const fRandomName = v4(fName) + "." + fExt;
|
||||
|
||||
const createFile = await prisma.prospektusInvestasi.create({
|
||||
data: {
|
||||
investasiId: createInvest.id,
|
||||
url: fRandomName,
|
||||
},
|
||||
});
|
||||
|
||||
if (!createFile) return { status: 400, message: "Gagal Upload" };
|
||||
const uploadFile = Buffer.from(await file.arrayBuffer());
|
||||
fs.writeFileSync(`./public/file/${createFile.url}`, uploadFile);
|
||||
|
||||
revalidatePath(RouterInvestasi_OLD.main_porto);
|
||||
return {
|
||||
data: createInvest,
|
||||
status: 201,
|
||||
message: "Berhasil Disimpan",
|
||||
};
|
||||
}
|
||||
@@ -37,7 +37,7 @@ export async function userSearch_getAllUser({
|
||||
OR: [
|
||||
{
|
||||
NOT: {
|
||||
id: userLoginId,
|
||||
id: userLoginId as string,
|
||||
},
|
||||
},
|
||||
],
|
||||
|
||||
@@ -15,7 +15,7 @@ export async function Vote_funCreate(req: MODEL_VOTING, listVote: any[]) {
|
||||
deskripsi: req.deskripsi,
|
||||
awalVote: req.awalVote,
|
||||
akhirVote: req.akhirVote,
|
||||
authorId: userLoginId,
|
||||
authorId: userLoginId as string,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
|
||||
@@ -18,7 +18,7 @@ export async function Vote_getAllListRiwayatSaya({ page }: { page: number }) {
|
||||
},
|
||||
where: {
|
||||
voting_StatusId: "1",
|
||||
authorId: userLoginId,
|
||||
authorId: userLoginId as string,
|
||||
isActive: true,
|
||||
akhirVote: {
|
||||
lte: new Date(),
|
||||
|
||||
@@ -24,7 +24,7 @@ export async function vote_funGetAllByStatusId({
|
||||
},
|
||||
where: {
|
||||
voting_StatusId: "1",
|
||||
authorId: userLoginId,
|
||||
authorId: userLoginId as string,
|
||||
isActive: true,
|
||||
akhirVote: {
|
||||
gte: new Date(),
|
||||
@@ -49,7 +49,7 @@ export async function vote_funGetAllByStatusId({
|
||||
},
|
||||
where: {
|
||||
voting_StatusId: statusId,
|
||||
authorId: userLoginId,
|
||||
authorId: userLoginId as string,
|
||||
isActive: true,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -17,7 +17,7 @@ export async function vote_getAllDraft({ page }: { page: number }) {
|
||||
},
|
||||
where: {
|
||||
voting_StatusId: "3",
|
||||
authorId: userLoginId,
|
||||
authorId: userLoginId as string,
|
||||
isActive: true,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -17,7 +17,7 @@ export async function vote_getAllPublish({ page }: { page: number }) {
|
||||
},
|
||||
where: {
|
||||
voting_StatusId: "1",
|
||||
authorId: userLoginId,
|
||||
authorId: userLoginId as string,
|
||||
isActive: true,
|
||||
akhirVote: {
|
||||
gte: new Date(),
|
||||
|
||||
@@ -17,7 +17,7 @@ export async function vote_getAllReject({ page }: { page: number }) {
|
||||
},
|
||||
where: {
|
||||
voting_StatusId: "4",
|
||||
authorId: userLoginId,
|
||||
authorId: userLoginId as string,
|
||||
isActive: true,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -17,7 +17,7 @@ export async function vote_getAllReview({ page }: { page: number }) {
|
||||
},
|
||||
where: {
|
||||
voting_StatusId: "2",
|
||||
authorId: userLoginId,
|
||||
authorId: userLoginId as string,
|
||||
isActive: true,
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user