Merge pull request #139 from bipproduction/notifikasi/donasi
Fix: Cookies & Donasi notifikasi
This commit is contained in:
@@ -2,6 +2,15 @@
|
|||||||
|
|
||||||
All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
|
All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
|
||||||
|
|
||||||
|
## [1.2.4](https://github.com/bipproduction/hipmi/compare/v1.2.3...v1.2.4) (2024-11-25)
|
||||||
|
|
||||||
|
## [1.2.3](https://github.com/bipproduction/hipmi/compare/v1.2.2...v1.2.3) (2024-11-25)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* Middlerawe/7 ([13c855f](https://github.com/bipproduction/hipmi/commit/13c855f2f64212857cb6c143f135d2fe160d9ee9))
|
||||||
|
|
||||||
## [1.2.2](https://github.com/bipproduction/hipmi/compare/v1.2.1...v1.2.2) (2024-11-21)
|
## [1.2.2](https://github.com/bipproduction/hipmi/compare/v1.2.1...v1.2.2) (2024-11-21)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hipmi",
|
"name": "hipmi",
|
||||||
"version": "1.2.2",
|
"version": "1.2.4",
|
||||||
"private": true,
|
"private": true,
|
||||||
"prisma": {
|
"prisma": {
|
||||||
"seed": "npx tsx prisma/seed.ts --yes"
|
"seed": "npx tsx prisma/seed.ts --yes"
|
||||||
|
|||||||
13
src/app/(user)/login/page.tsx
Normal file
13
src/app/(user)/login/page.tsx
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import { funCheckCookies } from "@/app_modules/_global/fun/get/fun_check_cookies";
|
||||||
|
import { Login } from "@/app_modules/auth";
|
||||||
|
import versionUpdate from "../../../../package.json";
|
||||||
|
|
||||||
|
export default async function Page() {
|
||||||
|
const version = versionUpdate.version;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Login version={version} />
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
8
src/app/(user)/register/[id]/page.tsx
Normal file
8
src/app/(user)/register/[id]/page.tsx
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
import { Register } from "@/app_modules/auth";
|
||||||
|
import { auth_getCodeOtpByNumber } from "@/app_modules/auth/fun/get_kode_otp_by_id";
|
||||||
|
|
||||||
|
export default async function Page({ params }: { params: { id: string } }) {
|
||||||
|
let otpId = params.id;
|
||||||
|
const dataOtp = await auth_getCodeOtpByNumber({ kodeId: otpId });
|
||||||
|
return <Register dataOtp={dataOtp} />;
|
||||||
|
}
|
||||||
9
src/app/(user)/validasi/[id]/page.tsx
Normal file
9
src/app/(user)/validasi/[id]/page.tsx
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
import { Validasi } from "@/app_modules/auth";
|
||||||
|
import { auth_getCodeOtpByNumber } from "@/app_modules/auth/fun/get_kode_otp_by_id";
|
||||||
|
|
||||||
|
export default async function Page({ params }: { params: { id: string } }) {
|
||||||
|
let kodeId = params.id;
|
||||||
|
const dataOtp = await auth_getCodeOtpByNumber({ kodeId: kodeId });
|
||||||
|
|
||||||
|
return <Validasi dataOtp={dataOtp as any} />;
|
||||||
|
}
|
||||||
@@ -1,9 +1,15 @@
|
|||||||
import { Login } from "@/app_modules/auth";
|
import { Login } from "@/app_modules/auth";
|
||||||
import versionUpdate from "../../../../../package.json";
|
import versionUpdate from "../../../../../package.json";
|
||||||
|
import { funCheckCookies } from "@/app_modules/_global/fun/get/fun_check_cookies";
|
||||||
|
import { redirect } from "next/navigation";
|
||||||
|
|
||||||
export default async function Page() {
|
export default async function Page() {
|
||||||
const version = versionUpdate.version;
|
const version = versionUpdate.version;
|
||||||
|
|
||||||
|
const checkCookies = await funCheckCookies();
|
||||||
|
console.log(checkCookies, "ini halaman login");
|
||||||
|
if (!checkCookies) return redirect("/");
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Login version={version} />
|
<Login version={version} />
|
||||||
|
|||||||
@@ -1,12 +1,9 @@
|
|||||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
|
||||||
import { SplashScreen } from "@/app_modules/auth";
|
import { SplashScreen } from "@/app_modules/auth";
|
||||||
|
|
||||||
export default async function PageSplash() {
|
export default async function PageSplash() {
|
||||||
const userLoginId = await funGetUserIdByToken();
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<SplashScreen userLoginId={userLoginId} />
|
<SplashScreen checkCookies/>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
import { Validasi } from "@/app_modules/auth";
|
import { Validasi } from "@/app_modules/auth";
|
||||||
import { auth_getCodeOtpByNumber } from "@/app_modules/auth/fun/get_kode_otp_by_id";
|
import { auth_getCodeOtpByNumber } from "@/app_modules/auth/fun/get_kode_otp_by_id";
|
||||||
import { redirect } from "next/navigation";
|
|
||||||
import { RouterAuth } from "@/app/lib/router_hipmi/router_auth";
|
|
||||||
|
|
||||||
export default async function Page({ params }: { params: { id: string } }) {
|
export default async function Page({ params }: { params: { id: string } }) {
|
||||||
let kodeId = params.id;
|
let kodeId = params.id;
|
||||||
const dataOtp = await auth_getCodeOtpByNumber({ kodeId: kodeId });
|
const dataOtp = await auth_getCodeOtpByNumber({ kodeId: kodeId });
|
||||||
// if (dataOtp === null) return redirect(RouterAuth.login);
|
|
||||||
|
|
||||||
return <Validasi dataOtp={dataOtp as any} />;
|
return <Validasi dataOtp={dataOtp as any} />;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,21 @@
|
|||||||
|
import { RouterAdminDashboard } from "@/app/lib/router_hipmi/router_admin";
|
||||||
|
import { RouterHome } from "@/app/lib/router_hipmi/router_home";
|
||||||
|
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||||
|
import { funGlobal_getUserById } from "@/app_modules/_global/fun/get/fun_get_user_by_id";
|
||||||
import { CheckCookies_UiView } from "@/app_modules/check_cookies";
|
import { CheckCookies_UiView } from "@/app_modules/check_cookies";
|
||||||
|
import { redirect } from "next/navigation";
|
||||||
|
|
||||||
export default function Page() {
|
export default async function Page() {
|
||||||
return <CheckCookies_UiView />;
|
const userLoginId = await funGetUserIdByToken();
|
||||||
|
const dataUser = await funGlobal_getUserById({ userId: userLoginId });
|
||||||
|
|
||||||
|
if (dataUser?.masterUserRoleId === "1") {
|
||||||
|
return redirect(RouterHome.main_home);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dataUser?.masterUserRoleId !== "1") {
|
||||||
|
return redirect(RouterAdminDashboard.splash_admin);
|
||||||
|
}
|
||||||
|
|
||||||
|
// return <CheckCookies_UiView />;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,27 +1,24 @@
|
|||||||
import { RouterAdminDashboard } from "@/app/lib/router_hipmi/router_admin";
|
|
||||||
import { RouterHome } from "@/app/lib/router_hipmi/router_home";
|
|
||||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||||
import { HomeView } from "@/app_modules/home";
|
import { HomeView } from "@/app_modules/home";
|
||||||
import { user_getOneByUserId } from "@/app_modules/home/fun/get/get_one_user_by_id";
|
import { user_getOneByUserId } from "@/app_modules/home/fun/get/get_one_user_by_id";
|
||||||
import { job_getTwoForHomeView } from "@/app_modules/job/fun/get/get_two_for_home_view";
|
import { job_getTwoForHomeView } from "@/app_modules/job/fun/get/get_two_for_home_view";
|
||||||
import notifikasi_countUserNotifikasi from "@/app_modules/notifikasi/fun/count/fun_count_by_id";
|
import notifikasi_countUserNotifikasi from "@/app_modules/notifikasi/fun/count/fun_count_by_id";
|
||||||
import { redirect } from "next/navigation";
|
|
||||||
|
|
||||||
export default async function Page() {
|
export default async function Page() {
|
||||||
const userLoginId = await funGetUserIdByToken();
|
const userLoginId = await funGetUserIdByToken();
|
||||||
|
|
||||||
const dataUser = await user_getOneByUserId(userLoginId as string);
|
const dataUser = await user_getOneByUserId(userLoginId as string);
|
||||||
const dataJob = await job_getTwoForHomeView();
|
const dataJob = await job_getTwoForHomeView();
|
||||||
|
|
||||||
if (dataUser?.active === false) {
|
|
||||||
return redirect(RouterHome.home_user_non_active);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dataUser?.masterUserRoleId === "2" || dataUser?.masterUserRoleId === "3")
|
|
||||||
return redirect(RouterAdminDashboard.splash_admin);
|
|
||||||
|
|
||||||
const countNotifikasi = await notifikasi_countUserNotifikasi();
|
const countNotifikasi = await notifikasi_countUserNotifikasi();
|
||||||
|
|
||||||
|
// console.log(userLoginId, "ini di home");
|
||||||
|
// console.log(dataUser, "ini di home");
|
||||||
|
|
||||||
|
// if (dataUser?.active === false) {
|
||||||
|
// return redirect(RouterHome.home_user_non_active);
|
||||||
|
// }
|
||||||
|
// if (dataUser?.masterUserRoleId === "2" || dataUser?.masterUserRoleId === "3")
|
||||||
|
// return redirect(RouterAdminDashboard.splash_admin);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<HomeView
|
<HomeView
|
||||||
|
|||||||
@@ -1,11 +1,38 @@
|
|||||||
"use client";
|
|
||||||
import { CheckCookies_UiLayout } from "@/app_modules/check_cookies";
|
import { CheckCookies_UiLayout } from "@/app_modules/check_cookies";
|
||||||
|
import { RealtimeProvider } from "../lib";
|
||||||
|
import { funCheckCookies } from "@/app_modules/_global/fun/get/fun_check_cookies";
|
||||||
|
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||||
|
import { ServerEnv } from "../lib/server_env";
|
||||||
|
import { funGlobal_getUserById } from "@/app_modules/_global/fun/get/fun_get_user_by_id";
|
||||||
|
import { RouterHome } from "../lib/router_hipmi/router_home";
|
||||||
|
import { RouterAdminDashboard } from "../lib/router_hipmi/router_admin";
|
||||||
|
import { redirect } from "next/navigation";
|
||||||
|
|
||||||
|
export default async function Layout({
|
||||||
|
children,
|
||||||
|
}: {
|
||||||
|
children: React.ReactNode;
|
||||||
|
}) {
|
||||||
|
const checkCookies = await funCheckCookies();
|
||||||
|
if (!checkCookies) return redirect("/");
|
||||||
|
|
||||||
|
const userLoginId = await funGetUserIdByToken();
|
||||||
|
const WIBU_REALTIME_TOKEN = process.env.NEXT_PUBLIC_WIBU_REALTIME_TOKEN;
|
||||||
|
// console.log(WIBU_REALTIME_TOKEN, "check cookies di layout dalam");
|
||||||
|
|
||||||
export default function Layout({ children }: { children: React.ReactNode }) {
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
<RealtimeProvider
|
||||||
|
userLoginId={userLoginId as string}
|
||||||
|
WIBU_REALTIME_TOKEN={
|
||||||
|
ServerEnv.value?.NEXT_PUBLIC_WIBU_REALTIME_TOKEN as string
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
|
||||||
{children}
|
{children}
|
||||||
{/* <CheckCookies_UiLayout>{children}</CheckCookies_UiLayout> */}
|
{/* <CheckCookies_UiLayout dataUser={dataUser as any}>
|
||||||
|
{children}
|
||||||
|
</CheckCookies_UiLayout> */}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,16 +2,16 @@ import { RouterHome } from "@/app/lib/router_hipmi/router_home";
|
|||||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||||
import { Home_UserNonActive } from "@/app_modules/home";
|
import { Home_UserNonActive } from "@/app_modules/home";
|
||||||
import { user_getOneByUserId } from "@/app_modules/home/fun/get/get_one_user_by_id";
|
import { user_getOneByUserId } from "@/app_modules/home/fun/get/get_one_user_by_id";
|
||||||
import { redirect } from "next/navigation";
|
// import { redirect } from "next/navigation";
|
||||||
|
|
||||||
export default async function Page() {
|
export default async function Page() {
|
||||||
const userLoginId = await funGetUserIdByToken();
|
const userLoginId = await funGetUserIdByToken();
|
||||||
|
|
||||||
const dataUser = await user_getOneByUserId(userLoginId as string);
|
const dataUser = await user_getOneByUserId(userLoginId as string);
|
||||||
|
|
||||||
if (dataUser?.active === true) {
|
// if (dataUser?.active === true) {
|
||||||
return redirect(RouterHome.main_home);
|
// return redirect(RouterHome.main_home);
|
||||||
}
|
// }
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||||
import { CheckCookies_UiView } from "@/app_modules/check_cookies";
|
|
||||||
import { LayoutVote_DetailSemuaRiwayat } from "@/app_modules/vote";
|
import { LayoutVote_DetailSemuaRiwayat } from "@/app_modules/vote";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
@@ -12,9 +11,7 @@ export default async function Layout({
|
|||||||
}) {
|
}) {
|
||||||
const votingId = params.id;
|
const votingId = params.id;
|
||||||
const userLoginId = await funGetUserIdByToken();
|
const userLoginId = await funGetUserIdByToken();
|
||||||
|
|
||||||
if (!userLoginId) return <CheckCookies_UiView />;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<LayoutVote_DetailSemuaRiwayat
|
<LayoutVote_DetailSemuaRiwayat
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ import dotenv from "dotenv";
|
|||||||
import { ServerEnv } from "./lib/server_env";
|
import { ServerEnv } from "./lib/server_env";
|
||||||
import { RealtimeProvider } from "./lib";
|
import { RealtimeProvider } from "./lib";
|
||||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||||
|
import { funCheckCookies } from "@/app_modules/_global/fun/get/fun_check_cookies";
|
||||||
|
import { redirect } from "next/navigation";
|
||||||
dotenv.config({
|
dotenv.config({
|
||||||
path: ".env",
|
path: ".env",
|
||||||
});
|
});
|
||||||
@@ -18,6 +20,8 @@ const Client_KEY = process.env.Client_KEY!;
|
|||||||
const Server_KEY = process.env.Server_KEY!;
|
const Server_KEY = process.env.Server_KEY!;
|
||||||
const MAPBOX_TOKEN = process.env.MAPBOX_TOKEN!;
|
const MAPBOX_TOKEN = process.env.MAPBOX_TOKEN!;
|
||||||
const WS_APIKEY = process.env.WS_APIKEY!;
|
const WS_APIKEY = process.env.WS_APIKEY!;
|
||||||
|
const NEXT_PUBLIC_WIBU_REALTIME_TOKEN =
|
||||||
|
process.env.NEXT_PUBLIC_WIBU_REALTIME_TOKEN!;
|
||||||
|
|
||||||
if (!DATABASE_URL) throw new Error("Require DATABASE_URL");
|
if (!DATABASE_URL) throw new Error("Require DATABASE_URL");
|
||||||
if (!WIBU_PWD) throw new Error("Require WIBU_PWD");
|
if (!WIBU_PWD) throw new Error("Require WIBU_PWD");
|
||||||
@@ -25,6 +29,8 @@ if (!Client_KEY) throw new Error("Require Client_KEY");
|
|||||||
if (!Server_KEY) throw new Error("Require Server_KEY");
|
if (!Server_KEY) throw new Error("Require Server_KEY");
|
||||||
if (!MAPBOX_TOKEN) throw new Error("Require MAPBOX_TOKEN");
|
if (!MAPBOX_TOKEN) throw new Error("Require MAPBOX_TOKEN");
|
||||||
if (!WS_APIKEY) throw new Error("Require WS_APIKEY");
|
if (!WS_APIKEY) throw new Error("Require WS_APIKEY");
|
||||||
|
if (!NEXT_PUBLIC_WIBU_REALTIME_TOKEN)
|
||||||
|
throw new Error("Require NEXT_PUBLIC_WIBU_REALTIME_TOKEN");
|
||||||
|
|
||||||
const envObject = {
|
const envObject = {
|
||||||
DATABASE_URL,
|
DATABASE_URL,
|
||||||
@@ -33,6 +39,7 @@ const envObject = {
|
|||||||
Server_KEY,
|
Server_KEY,
|
||||||
MAPBOX_TOKEN,
|
MAPBOX_TOKEN,
|
||||||
WS_APIKEY,
|
WS_APIKEY,
|
||||||
|
NEXT_PUBLIC_WIBU_REALTIME_TOKEN,
|
||||||
};
|
};
|
||||||
ServerEnv.set(envObject);
|
ServerEnv.set(envObject);
|
||||||
|
|
||||||
@@ -41,15 +48,22 @@ export default async function RootLayout({
|
|||||||
}: {
|
}: {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
}) {
|
}) {
|
||||||
// if (!token) return <>Require Token Storage</>;
|
if (!token) return <>Require Token Storage</>;
|
||||||
const userLoginId = await funGetUserIdByToken();
|
// const userLoginId = await funGetUserIdByToken();
|
||||||
|
// const WIBU_REALTIME_TOKEN = process.env.NEXT_PUBLIC_WIBU_REALTIME_TOKEN;
|
||||||
|
// console.log(WIBU_REALTIME_TOKEN, "WIBU_REALTIME_TOKEN");
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<RootStyleRegistry>
|
<RootStyleRegistry>
|
||||||
{/* <MqttLoader />
|
{/* <MqttLoader /> */}
|
||||||
<TokenProvider token={token} envObject={envObject} /> */}
|
<TokenProvider token={token} envObject={envObject} />
|
||||||
<RealtimeProvider userLoginId={userLoginId as string} />
|
{/* <RealtimeProvider
|
||||||
|
userLoginId={userLoginId as string}
|
||||||
|
WIBU_REALTIME_TOKEN={
|
||||||
|
ServerEnv.value?.NEXT_PUBLIC_WIBU_REALTIME_TOKEN as string
|
||||||
|
}
|
||||||
|
/> */}
|
||||||
{children}
|
{children}
|
||||||
</RootStyleRegistry>
|
</RootStyleRegistry>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -16,6 +16,10 @@ import {
|
|||||||
IRealtimeData,
|
IRealtimeData,
|
||||||
} from "./global_state";
|
} from "./global_state";
|
||||||
|
|
||||||
|
// const WIBU_REALTIME_TOKEN: string | undefined =
|
||||||
|
// process.env.NEXT_PUBLIC_WIBU_REALTIME_TOKEN;
|
||||||
|
|
||||||
|
// Pasang tipe data di package WibuRealtime sebagai type adata setData
|
||||||
export type TypeNotification = {
|
export type TypeNotification = {
|
||||||
type: "message" | "notification" | "trigger";
|
type: "message" | "notification" | "trigger";
|
||||||
pushNotificationTo: "ADMIN" | "USER";
|
pushNotificationTo: "ADMIN" | "USER";
|
||||||
@@ -23,12 +27,12 @@ export type TypeNotification = {
|
|||||||
userLoginId?: string;
|
userLoginId?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
const WIBU_REALTIME_TOKEN: string | undefined =
|
|
||||||
process.env.NEXT_PUBLIC_WIBU_REALTIME_TOKEN;
|
|
||||||
export default function RealtimeProvider({
|
export default function RealtimeProvider({
|
||||||
userLoginId,
|
userLoginId,
|
||||||
|
WIBU_REALTIME_TOKEN,
|
||||||
}: {
|
}: {
|
||||||
userLoginId: string;
|
userLoginId: string;
|
||||||
|
WIBU_REALTIME_TOKEN: string;
|
||||||
}) {
|
}) {
|
||||||
const [dataRealtime, setDataRealtime] = useAtom(gs_realtimeData);
|
const [dataRealtime, setDataRealtime] = useAtom(gs_realtimeData);
|
||||||
const [newAdminNtf, setNewAdminNtf] = useAtom(gs_admin_ntf);
|
const [newAdminNtf, setNewAdminNtf] = useAtom(gs_admin_ntf);
|
||||||
@@ -58,9 +62,11 @@ export default function RealtimeProvider({
|
|||||||
);
|
);
|
||||||
|
|
||||||
useShallowEffect(() => {
|
useShallowEffect(() => {
|
||||||
if (WIBU_REALTIME_TOKEN === undefined) return alert("gak dapet key");
|
// if (WIBU_REALTIME_TOKEN === undefined) return alert("gak dapet key");
|
||||||
try {
|
try {
|
||||||
WibuRealtime.init({
|
WibuRealtime.init({
|
||||||
|
project: "hipmi",
|
||||||
|
WIBU_REALTIME_TOKEN: WIBU_REALTIME_TOKEN,
|
||||||
onData(data: TypeNotification) {
|
onData(data: TypeNotification) {
|
||||||
if (
|
if (
|
||||||
data.type == "notification" &&
|
data.type == "notification" &&
|
||||||
@@ -154,12 +160,9 @@ export default function RealtimeProvider({
|
|||||||
}
|
}
|
||||||
// ---------------------- VOTING ------------------------- //
|
// ---------------------- VOTING ------------------------- //
|
||||||
},
|
},
|
||||||
|
|
||||||
project: "hipmi",
|
|
||||||
WIBU_REALTIME_TOKEN: WIBU_REALTIME_TOKEN,
|
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
alert("error realtime");
|
console.log(error);
|
||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ type ENV = {
|
|||||||
Server_KEY: string;
|
Server_KEY: string;
|
||||||
MAPBOX_TOKEN: string;
|
MAPBOX_TOKEN: string;
|
||||||
WS_APIKEY: string;
|
WS_APIKEY: string;
|
||||||
|
NEXT_PUBLIC_WIBU_REALTIME_TOKEN: string;
|
||||||
};
|
};
|
||||||
export class ServerEnv {
|
export class ServerEnv {
|
||||||
static value: ENV | null = null;
|
static value: ENV | null = null;
|
||||||
|
|||||||
@@ -1,5 +1,24 @@
|
|||||||
|
import { funCheckCookies } from "@/app_modules/_global/fun/get/fun_check_cookies";
|
||||||
import PageSplash from "./dev/auth/splash/page";
|
import PageSplash from "./dev/auth/splash/page";
|
||||||
|
import { redirect } from "next/navigation";
|
||||||
|
import { Login, SplashScreen } from "@/app_modules/auth";
|
||||||
|
import { RouterAuth } from "./lib/router_hipmi/router_auth";
|
||||||
|
import versionUpdate from "../../package.json";
|
||||||
|
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||||
|
import { funGlobal_getUserById } from "@/app_modules/_global/fun/get/fun_get_user_by_id";
|
||||||
|
import { RouterHome } from "./lib/router_hipmi/router_home";
|
||||||
|
import { RouterAdminDashboard } from "./lib/router_hipmi/router_admin";
|
||||||
|
|
||||||
export default async function Page() {
|
export default async function Page() {
|
||||||
return <PageSplash/>
|
const version = versionUpdate.version;
|
||||||
|
|
||||||
|
const checkCookies = await funCheckCookies();
|
||||||
|
// console.log(checkCookies, "ini check cookies di page awal");
|
||||||
|
if (checkCookies) return redirect("/dev/check-cookies");
|
||||||
|
return redirect("/login");
|
||||||
|
// const WIBU_REALTIME_TOKEN = process.env.NEXT_PUBLIC_WIBU_REALTIME_TOKEN;
|
||||||
|
|
||||||
|
// return <Login version={version} />;
|
||||||
|
// return <SplashScreen checkCookies={checkCookies} />;
|
||||||
|
return <PageSplash />;
|
||||||
}
|
}
|
||||||
|
|||||||
28
src/app_modules/_global/fun/get/fun_check_cookies.ts
Normal file
28
src/app_modules/_global/fun/get/fun_check_cookies.ts
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
"use server";
|
||||||
|
|
||||||
|
import { ServerEnv } from "@/app/lib/server_env";
|
||||||
|
import { unsealData } from "iron-session";
|
||||||
|
import _ from "lodash";
|
||||||
|
import { cookies } from "next/headers";
|
||||||
|
|
||||||
|
export async function funCheckCookies() {
|
||||||
|
const c = cookies().get("mySession");
|
||||||
|
|
||||||
|
if (!c || !c?.value || _.isEmpty(c?.value) || _.isUndefined(c?.value)) {
|
||||||
|
// console.log("return pertama");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const token = JSON.parse(
|
||||||
|
await unsealData(c?.value as string, {
|
||||||
|
password: ServerEnv.value?.WIBU_PWD as string,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
if (_.isEmpty(token)) {
|
||||||
|
// console.log("return kedua");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
@@ -1,17 +1,26 @@
|
|||||||
"use server";
|
"use server";
|
||||||
|
|
||||||
import prisma from "@/app/lib/prisma";
|
import { ServerEnv } from "@/app/lib/server_env";
|
||||||
|
import { unsealData } from "iron-session";
|
||||||
import { cookies } from "next/headers";
|
import { cookies } from "next/headers";
|
||||||
|
|
||||||
export async function funGetUserIdByToken() {
|
export async function funGetUserIdByToken() {
|
||||||
const c = cookies().get("mySession");
|
const c = cookies().get("mySession");
|
||||||
const token = c?.value
|
|
||||||
const cekToken = await prisma.userSession.findFirst({
|
|
||||||
where: {
|
|
||||||
token: token,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
if (cekToken === null) return null
|
const token = JSON.parse(
|
||||||
return cekToken.userId;
|
await unsealData(c?.value as string, {
|
||||||
|
password: process.env.WIBU_PWD as string,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
return token.id;
|
||||||
|
// const token = c?.value
|
||||||
|
// const cekToken = await prisma.userSession.findFirst({
|
||||||
|
// where: {
|
||||||
|
// token: token,
|
||||||
|
// },
|
||||||
|
// });
|
||||||
|
|
||||||
|
// if (cekToken === null) return null
|
||||||
|
// return cekToken.userId;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
|
import { ServerEnv } from "@/app/lib/server_env";
|
||||||
import { TokenStorage } from "@/app/lib/token";
|
import { TokenStorage } from "@/app/lib/token";
|
||||||
|
import { envs } from "@/lib/envs";
|
||||||
|
|
||||||
export async function funGlobal_UploadToStorage({
|
export async function funGlobal_UploadToStorage({
|
||||||
file,
|
file,
|
||||||
@@ -7,7 +9,7 @@ export async function funGlobal_UploadToStorage({
|
|||||||
file: File;
|
file: File;
|
||||||
dirId: string;
|
dirId: string;
|
||||||
}) {
|
}) {
|
||||||
if (!file) console.log("Tidak ada file");
|
const Env_WS_APIKEY = TokenStorage.value;
|
||||||
|
|
||||||
const allowedMimeTypes = [
|
const allowedMimeTypes = [
|
||||||
"image/png",
|
"image/png",
|
||||||
@@ -35,7 +37,7 @@ export async function funGlobal_UploadToStorage({
|
|||||||
method: "POST",
|
method: "POST",
|
||||||
body: formData,
|
body: formData,
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${TokenStorage.value}`,
|
Authorization: `Bearer ${Env_WS_APIKEY}`,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -52,4 +54,6 @@ export async function funGlobal_UploadToStorage({
|
|||||||
console.error("Error:", error);
|
console.error("Error:", error);
|
||||||
return { success: false, data: {} };
|
return { success: false, data: {} };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return { success: false, data: { id: "" } };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,14 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import {
|
import { Divider, Grid, Group, Paper, Stack, Text, Title } from "@mantine/core";
|
||||||
Divider,
|
|
||||||
Grid,
|
|
||||||
Group,
|
|
||||||
Paper,
|
|
||||||
Stack,
|
|
||||||
Text,
|
|
||||||
Title
|
|
||||||
} from "@mantine/core";
|
|
||||||
|
|
||||||
|
export default function AdminMain({
|
||||||
export default function AdminMain({countUser, countPorto}: {countUser: number, countPorto: number} ) {
|
countUser,
|
||||||
|
countPorto,
|
||||||
|
}: {
|
||||||
|
countUser: number;
|
||||||
|
countPorto: number;
|
||||||
|
}) {
|
||||||
const listBox = [
|
const listBox = [
|
||||||
{
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
@@ -34,21 +31,11 @@ export default function AdminMain({countUser, countPorto}: {countUser: number, c
|
|||||||
<Stack spacing={"sm"}>
|
<Stack spacing={"sm"}>
|
||||||
<Title>Main Dashboard</Title>
|
<Title>Main Dashboard</Title>
|
||||||
<Divider mb={"md"} />
|
<Divider mb={"md"} />
|
||||||
{/* <Stack align="center" justify="center" h={"80vh"}>
|
|
||||||
<Title>Cooming Soon !!</Title>
|
|
||||||
</Stack> */}
|
|
||||||
|
|
||||||
<Grid>
|
<Grid>
|
||||||
{listBox.map((e) => (
|
{listBox.map((e) => (
|
||||||
<Grid.Col md={4} lg={4} key={e.id}>
|
<Grid.Col md={4} lg={4} key={e.id}>
|
||||||
<Paper
|
<Paper withBorder shadow="md" radius="md" p="md">
|
||||||
withBorder
|
|
||||||
// bg={`${e.color}.2`}
|
|
||||||
shadow="md"
|
|
||||||
radius="md"
|
|
||||||
p="md"
|
|
||||||
// sx={{ borderColor: e.color, borderStyle: "solid" }}
|
|
||||||
>
|
|
||||||
<Group position="center">
|
<Group position="center">
|
||||||
<Stack align="center" spacing={0}>
|
<Stack align="center" spacing={0}>
|
||||||
<Text>{e.name}</Text>
|
<Text>{e.name}</Text>
|
||||||
@@ -67,41 +54,3 @@ export default function AdminMain({countUser, countPorto}: {countUser: number, c
|
|||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// const PieChart = () => {
|
|
||||||
// const option: echarts.EChartsOption = {
|
|
||||||
// title: {},
|
|
||||||
// tooltip: {
|
|
||||||
// trigger: "item",
|
|
||||||
// },
|
|
||||||
// legend: {
|
|
||||||
// top: "bottom",
|
|
||||||
// },
|
|
||||||
// series: [
|
|
||||||
// {
|
|
||||||
// name: "Anggota Partai",
|
|
||||||
// type: "pie",
|
|
||||||
// bottom: "40",
|
|
||||||
// data: [
|
|
||||||
// { value: 10, name: "Laki-Laki" },
|
|
||||||
// { value: 20, name: "Perempuan" },
|
|
||||||
// ],
|
|
||||||
// },
|
|
||||||
// ],
|
|
||||||
// };
|
|
||||||
|
|
||||||
// return (
|
|
||||||
// <>
|
|
||||||
// <Box
|
|
||||||
// sx={{
|
|
||||||
// backgroundColor: "gray",
|
|
||||||
// }}
|
|
||||||
// >
|
|
||||||
// <Text ta={"center"} fz={20} fw={700}>
|
|
||||||
// Jenis Kelamin
|
|
||||||
// </Text>
|
|
||||||
// <EChartsReact style={{ height: 300 }} option={option} />
|
|
||||||
// </Box>
|
|
||||||
// </>
|
|
||||||
// );
|
|
||||||
// };
|
|
||||||
|
|||||||
@@ -32,7 +32,8 @@ export default function Login({ version }: { version: string }) {
|
|||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
ComponentGlobal_NotifikasiBerhasil(res.message, 2000);
|
ComponentGlobal_NotifikasiBerhasil(res.message, 2000);
|
||||||
router.push(RouterAuth.validasi + res.kodeId, { scroll: false });
|
// router.push(RouterAuth.validasi + res.kodeId, { scroll: false });
|
||||||
|
router.push("/validasi/" + res.kodeId, { scroll: false });
|
||||||
} else {
|
} else {
|
||||||
ComponentGlobal_NotifikasiPeringatan(res.message);
|
ComponentGlobal_NotifikasiPeringatan(res.message);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ export default function Component_Logout() {
|
|||||||
const res = await auth_Logout();
|
const res = await auth_Logout();
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||||
router.push(RouterAuth.login, { scroll: false });
|
router.push("/login", { scroll: false });
|
||||||
} else {
|
} else {
|
||||||
ComponentGlobal_NotifikasiPeringatan(res.message);
|
ComponentGlobal_NotifikasiPeringatan(res.message);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,26 +1,56 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
|
import { RouterAdminDashboard } from "@/app/lib/router_hipmi/router_admin";
|
||||||
import { RouterAuth } from "@/app/lib/router_hipmi/router_auth";
|
import { RouterAuth } from "@/app/lib/router_hipmi/router_auth";
|
||||||
import { RouterHome } from "@/app/lib/router_hipmi/router_home";
|
import { RouterHome } from "@/app/lib/router_hipmi/router_home";
|
||||||
|
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||||
|
import { funGlobal_getUserById } from "@/app_modules/_global/fun/get/fun_get_user_by_id";
|
||||||
|
import { MODEL_USER } from "@/app_modules/home/model/interface";
|
||||||
import { Avatar, BackgroundImage, Center, Image, Stack } from "@mantine/core";
|
import { Avatar, BackgroundImage, Center, Image, Stack } from "@mantine/core";
|
||||||
import { useShallowEffect } from "@mantine/hooks";
|
import { useShallowEffect } from "@mantine/hooks";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
|
|
||||||
export default function SplashScreen({ userLoginId }: { userLoginId: any }) {
|
export default function SplashScreen({
|
||||||
|
checkCookies,
|
||||||
|
}: {
|
||||||
|
checkCookies: boolean;
|
||||||
|
}) {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
useShallowEffect(() => {
|
useShallowEffect(() => {
|
||||||
if (!userLoginId) {
|
// if (!checkCookies) return router.push(RouterAuth.login, { scroll: false });
|
||||||
setTimeout(() => {
|
// onCheckUser();
|
||||||
return router.push(RouterAuth.login, { scroll: false });
|
|
||||||
}, 1000);
|
// setTimeout(() => {
|
||||||
} else {
|
// router.push(RouterAuth.login, { scroll: false });
|
||||||
setTimeout(() => {
|
// }, 1000);
|
||||||
return router.push(RouterHome.main_home, { scroll: false });
|
// if (!userLoginId) {
|
||||||
}, 1000);
|
// setTimeout(() => {
|
||||||
}
|
// router.push(RouterAuth.login, { scroll: false });
|
||||||
|
// }, 1000);
|
||||||
|
// } else {
|
||||||
|
// dataUser.masterUserRoleId === "1"
|
||||||
|
// ? setTimeout(() => {
|
||||||
|
// return router.push(RouterHome.main_home, { scroll: false });
|
||||||
|
// }, 1000)
|
||||||
|
// : setTimeout(() => {
|
||||||
|
// return router.push(RouterAdminDashboard.splash_admin, {
|
||||||
|
// scroll: false,
|
||||||
|
// });
|
||||||
|
// }, 1000);
|
||||||
|
// }
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
// async function onCheckUser() {
|
||||||
|
// const userLoginId = await funGetUserIdByToken();
|
||||||
|
// const dataUser = await funGlobal_getUserById({ userId: userLoginId });
|
||||||
|
|
||||||
|
// if (dataUser?.masterUserRoleId == "1")
|
||||||
|
// return router.push(RouterHome.main_home);
|
||||||
|
|
||||||
|
// return router.push(RouterAdminDashboard.splash_admin);
|
||||||
|
// }
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<BackgroundImage
|
<BackgroundImage
|
||||||
|
|||||||
@@ -3,27 +3,40 @@
|
|||||||
import { RouterAuth } from "@/app/lib/router_hipmi/router_auth";
|
import { RouterAuth } from "@/app/lib/router_hipmi/router_auth";
|
||||||
import { useShallowEffect } from "@mantine/hooks";
|
import { useShallowEffect } from "@mantine/hooks";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
|
import { MODEL_USER } from "../home/model/interface";
|
||||||
|
import { RouterHome } from "@/app/lib/router_hipmi/router_home";
|
||||||
|
import { RouterAdminDashboard } from "@/app/lib/router_hipmi/router_admin";
|
||||||
|
|
||||||
export function CheckCookies_UiLayout({
|
export function CheckCookies_UiLayout({
|
||||||
children,
|
children,
|
||||||
|
dataUser,
|
||||||
}: {
|
}: {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
|
dataUser: MODEL_USER;
|
||||||
}) {
|
}) {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
useShallowEffect(() => {
|
// useShallowEffect(() => {
|
||||||
onCheckCookies();
|
// onCheckCookies();
|
||||||
}, []);
|
// }, []);
|
||||||
|
|
||||||
async function onCheckCookies() {
|
// async function onCheckCookies() {
|
||||||
const cek = await fetch("/api/check-cookies");
|
// const cek = await fetch("/api/check-cookies");
|
||||||
|
|
||||||
const result = await cek.json();
|
// const result = await cek.json();
|
||||||
|
|
||||||
if (result.success === false) {
|
// if (result.success === false) {
|
||||||
router.push(RouterAuth.login, { scroll: false });
|
// router.push(RouterAuth.login, { scroll: false });
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
// if (dataUser.masterUserRoleId === "1") {
|
||||||
|
// router.push(RouterHome.main_home, { scroll: false });
|
||||||
|
// }
|
||||||
|
|
||||||
|
// if (dataUser.masterUserRoleId !== "1") {
|
||||||
|
// router.push(RouterAdminDashboard.splash_admin, { scroll: false });
|
||||||
|
// }
|
||||||
|
|
||||||
return children;
|
return children;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,8 @@ import { useState } from "react";
|
|||||||
import { Donasi_funCreate } from "../fun/create/fun_create_donasi";
|
import { Donasi_funCreate } from "../fun/create/fun_create_donasi";
|
||||||
import { gs_donasi_hot_menu, gs_donasi_tabs_posting } from "../global_state";
|
import { gs_donasi_hot_menu, gs_donasi_tabs_posting } from "../global_state";
|
||||||
import { MODEL_DONASI_TEMPORARY } from "../model/interface";
|
import { MODEL_DONASI_TEMPORARY } from "../model/interface";
|
||||||
|
import { IRealtimeData } from "@/app/lib/global_state";
|
||||||
|
import { WibuRealtime } from "wibu-pkg";
|
||||||
|
|
||||||
export default function CreateCeritaPenggalangDonasi({
|
export default function CreateCeritaPenggalangDonasi({
|
||||||
dataTemporary,
|
dataTemporary,
|
||||||
@@ -90,7 +92,16 @@ export default function CreateCeritaPenggalangDonasi({
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (res.status === 201) {
|
if (res.status === 201) {
|
||||||
const dataNotif: any = {
|
// const dataNotif: any = {
|
||||||
|
// appId: res.data?.id as any,
|
||||||
|
// status: res.data?.DonasiMaster_Status?.name as any,
|
||||||
|
// userId: res.data?.authorId as any,
|
||||||
|
// pesan: res.data?.title as any,
|
||||||
|
// kategoriApp: "DONASI",
|
||||||
|
// title: "Donasi baru",
|
||||||
|
// };
|
||||||
|
|
||||||
|
const dataNotifikasi: IRealtimeData = {
|
||||||
appId: res.data?.id as any,
|
appId: res.data?.id as any,
|
||||||
status: res.data?.DonasiMaster_Status?.name as any,
|
status: res.data?.DonasiMaster_Status?.name as any,
|
||||||
userId: res.data?.authorId as any,
|
userId: res.data?.authorId as any,
|
||||||
@@ -100,16 +111,25 @@ export default function CreateCeritaPenggalangDonasi({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const notif = await notifikasiToAdmin_funCreate({
|
const notif = await notifikasiToAdmin_funCreate({
|
||||||
data: dataNotif as any,
|
data: dataNotifikasi as any,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (notif.status === 201) {
|
if (notif.status === 201) {
|
||||||
mqtt_client.publish(
|
// mqtt_client.publish(
|
||||||
"ADMIN",
|
// "ADMIN",
|
||||||
JSON.stringify({
|
// JSON.stringify({
|
||||||
count: 1,
|
// count: 1,
|
||||||
})
|
// })
|
||||||
);
|
// );
|
||||||
|
|
||||||
|
WibuRealtime.setData({
|
||||||
|
type: "notification",
|
||||||
|
pushNotificationTo: "ADMIN",
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
setDonasiHotMenu(1);
|
setDonasiHotMenu(1);
|
||||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||||
router.push(RouterDonasi.status_galang_dana({ id: "2" }), {
|
router.push(RouterDonasi.status_galang_dana({ id: "2" }), {
|
||||||
|
|||||||
@@ -5,14 +5,14 @@ import { ServerEnv } from "@/app/lib/server_env";
|
|||||||
import { unsealData } from "iron-session";
|
import { unsealData } from "iron-session";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import { cookies } from "next/headers";
|
import { cookies } from "next/headers";
|
||||||
import { redirect } from "next/navigation";
|
|
||||||
|
|
||||||
export async function user_funGetOneUserId(): Promise<string | null> {
|
export async function user_funGetOneUserId(): Promise<string | null> {
|
||||||
try {
|
try {
|
||||||
const kukis = cookies();
|
const kukis = cookies();
|
||||||
const c = kukis.get("mySession");
|
const c = kukis.get("mySession");
|
||||||
if (!c || !c?.value || _.isEmpty(c?.value) || _.isUndefined(c?.value))
|
// if (!c || !c?.value || _.isEmpty(c?.value) || _.isUndefined(c?.value))
|
||||||
return redirect(RouterAuth.login);
|
// return re-di-re-ct(RouterAuth.login);
|
||||||
|
|
||||||
const token = JSON.parse(
|
const token = JSON.parse(
|
||||||
await unsealData(c?.value as string, {
|
await unsealData(c?.value as string, {
|
||||||
|
|||||||
@@ -49,6 +49,8 @@ export default function HomeView({
|
|||||||
onLoad(loadNotif);
|
onLoad(loadNotif);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// console.log(dataUser, "dipage")
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<UIGlobal_LayoutTamplate
|
<UIGlobal_LayoutTamplate
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import { WibuRealtime } from "wibu-pkg";
|
|||||||
import { job_funCreateNoFile, job_funCreateWithFile } from "../../fun";
|
import { job_funCreateNoFile, job_funCreateWithFile } from "../../fun";
|
||||||
import { gs_job_hot_menu } from "../../global_state";
|
import { gs_job_hot_menu } from "../../global_state";
|
||||||
import { MODEL_JOB } from "../../model/interface";
|
import { MODEL_JOB } from "../../model/interface";
|
||||||
|
import { envs } from "@/lib/envs";
|
||||||
|
|
||||||
function Job_ComponentButtonSaveCreate({
|
function Job_ComponentButtonSaveCreate({
|
||||||
value,
|
value,
|
||||||
|
|||||||
@@ -1,21 +0,0 @@
|
|||||||
import _ from "lodash";
|
|
||||||
import { NextRequest, NextResponse } from "next/server";
|
|
||||||
|
|
||||||
// This function can be marked `async` if using `await` inside
|
|
||||||
export function middleware(request: NextRequest) {
|
|
||||||
let cookies = request.cookies.get("mySession");
|
|
||||||
console.log(cookies);
|
|
||||||
|
|
||||||
if (
|
|
||||||
!cookies ||
|
|
||||||
!cookies?.value ||
|
|
||||||
_.isEmpty(cookies?.value) ||
|
|
||||||
_.isUndefined(cookies?.value)
|
|
||||||
) {
|
|
||||||
return NextResponse.redirect(new URL("/dev/auth/login", request.url));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export const config = {
|
|
||||||
matcher: ["/((?!_next|static|favicon.ico|manifest).*)"],
|
|
||||||
};
|
|
||||||
28
src/middleware.txt
Normal file
28
src/middleware.txt
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||||
|
import { user_getOneByUserId } from "@/app_modules/home/fun/get/get_one_user_by_id";
|
||||||
|
import { unsealData } from "iron-session";
|
||||||
|
import _ from "lodash";
|
||||||
|
import { NextResponse } from "next/server";
|
||||||
|
import type { NextRequest } from "next/server";
|
||||||
|
import { RouterHome } from "./app/lib/router_hipmi/router_home";
|
||||||
|
|
||||||
|
|
||||||
|
// This function can be marked `async` if using `await` inside
|
||||||
|
export function middleware(request: NextRequest) {
|
||||||
|
let c = request.cookies.get("mySession");
|
||||||
|
|
||||||
|
if (!c || !c?.value || _.isEmpty(c?.value) || _.isUndefined(c?.value)) {
|
||||||
|
console.log("tidak ada user middleware");
|
||||||
|
|
||||||
|
|
||||||
|
// return NextResponse.redirect(new URL("/dev/auth/login", request.url));
|
||||||
|
// return NextResponse.redirect(new URL(RouterAuth.login, request.url));
|
||||||
|
} else {
|
||||||
|
console.log("ada user middleware");
|
||||||
|
return NextResponse.redirect(new URL(RouterHome.main_home, request.url));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const config = {
|
||||||
|
matcher: ["/((?!_next|static|favicon.ico|manifest).*)"],
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user