@@ -1,6 +1,4 @@
|
|||||||
import {
|
import { Notifikasi_UiCollaboration } from "@/app_modules/notifikasi/_ui";
|
||||||
Notifikasi_UiCollaboration
|
|
||||||
} from "@/app_modules/notifikasi/_ui";
|
|
||||||
import notifikasi_getByUserId from "@/app_modules/notifikasi/fun/get/get_notifiaksi_by_id";
|
import notifikasi_getByUserId from "@/app_modules/notifikasi/fun/get/get_notifiaksi_by_id";
|
||||||
|
|
||||||
export default async function Page() {
|
export default async function Page() {
|
||||||
|
|||||||
@@ -1,28 +1,30 @@
|
|||||||
import { PrismaClient } from '@prisma/client';
|
import { PrismaClient } from "@prisma/client";
|
||||||
|
|
||||||
// Singleton PrismaClient untuk pengembangan
|
// Singleton PrismaClient untuk pengembangan
|
||||||
const globalForPrisma = globalThis as unknown as {
|
const globalForPrisma = globalThis as unknown as {
|
||||||
__prisma__: PrismaClient | undefined;
|
__prisma__: PrismaClient | undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const prisma = globalForPrisma.__prisma__ ?? new PrismaClient({
|
export const prisma =
|
||||||
// log: process.env.NODE_ENV === 'development' ? ['query', 'info', 'warn', 'error'] : [],
|
globalForPrisma.__prisma__ ??
|
||||||
});
|
new PrismaClient({
|
||||||
|
// log: process.env.NODE_ENV === 'development' ? ['query', 'info', 'warn', 'error'] : [],
|
||||||
|
});
|
||||||
|
|
||||||
// Gunakan PrismaClient yang sama jika sudah ada
|
// Gunakan PrismaClient yang sama jika sudah ada
|
||||||
if (process.env.NODE_ENV !== 'production') {
|
if (process.env.NODE_ENV !== "production") {
|
||||||
if (!globalForPrisma.__prisma__) {
|
if (!globalForPrisma.__prisma__) {
|
||||||
console.log('PrismaClient initialized in development mode');
|
console.log("PrismaClient initialized in development mode");
|
||||||
}
|
}
|
||||||
globalForPrisma.__prisma__ = prisma;
|
globalForPrisma.__prisma__ = prisma;
|
||||||
}
|
}
|
||||||
|
|
||||||
process.on('SIGINT', async () => {
|
process.on("SIGINT", async () => {
|
||||||
console.log('Disconnecting PrismaClient...');
|
console.log("Disconnecting PrismaClient...");
|
||||||
await prisma.$disconnect();
|
await prisma.$disconnect();3
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
// console.log('==> Test prisma');
|
console.log("==> Test prisma");
|
||||||
|
|
||||||
export default prisma;
|
export default prisma;
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { MainColor } from "../color";
|
|||||||
import { MAX_SIZE } from "../lib";
|
import { MAX_SIZE } from "../lib";
|
||||||
import { PemberitahuanMaksimalFile } from "../lib/max_size";
|
import { PemberitahuanMaksimalFile } from "../lib/max_size";
|
||||||
import { ComponentGlobal_NotifikasiPeringatan } from "../notif_global";
|
import { ComponentGlobal_NotifikasiPeringatan } from "../notif_global";
|
||||||
|
import { clientLogger } from "@/util/clientLogger";
|
||||||
|
|
||||||
export function ComponentGlobal_ButtonUploadFileImage({
|
export function ComponentGlobal_ButtonUploadFileImage({
|
||||||
onSetFile,
|
onSetFile,
|
||||||
@@ -30,7 +31,7 @@ export function ComponentGlobal_ButtonUploadFileImage({
|
|||||||
onSetImage(buffer);
|
onSetImage(buffer);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
clientLogger.error("Upload error:", error);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
accept="image/png,image/jpeg"
|
accept="image/png,image/jpeg"
|
||||||
|
|||||||
@@ -65,13 +65,13 @@ export default function Register() {
|
|||||||
const result = await res.json();
|
const result = await res.json();
|
||||||
|
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
localStorage.removeItem("hipmi_auth_code_id");
|
|
||||||
ComponentGlobal_NotifikasiBerhasil(result.message);
|
ComponentGlobal_NotifikasiBerhasil(result.message);
|
||||||
router.push("/dev/home", { scroll: false });
|
localStorage.removeItem("hipmi_auth_code_id");
|
||||||
|
|
||||||
await auth_funDeleteAktivasiKodeOtpByNomor({
|
await auth_funDeleteAktivasiKodeOtpByNomor({
|
||||||
nomor: data.nomor,
|
nomor: data.nomor,
|
||||||
});
|
});
|
||||||
|
router.push("/dev/home", { scroll: false });
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res.status === 400) {
|
if (res.status === 400) {
|
||||||
|
|||||||
@@ -59,11 +59,7 @@ export default function Validasi() {
|
|||||||
}
|
}
|
||||||
}, [triggerOtp]);
|
}, [triggerOtp]);
|
||||||
|
|
||||||
async function onCheckAuthCode({
|
async function onCheckAuthCode({ kodeId }: { kodeId: string }) {
|
||||||
kodeId,
|
|
||||||
}: {
|
|
||||||
kodeId: string;
|
|
||||||
}) {
|
|
||||||
const res = await fetch(`/api/auth/check?id=${kodeId}`);
|
const res = await fetch(`/api/auth/check?id=${kodeId}`);
|
||||||
const result = await res.json();
|
const result = await res.json();
|
||||||
|
|
||||||
@@ -97,37 +93,40 @@ export default function Validasi() {
|
|||||||
|
|
||||||
const result = await res.json();
|
const result = await res.json();
|
||||||
|
|
||||||
if (res.status === 200) {
|
if (res.status === 200 && result.roleId == "1") {
|
||||||
|
ComponentGlobal_NotifikasiBerhasil(result.message);
|
||||||
localStorage.removeItem("hipmi_auth_code_id");
|
localStorage.removeItem("hipmi_auth_code_id");
|
||||||
|
|
||||||
if (result.roleId === "1") {
|
|
||||||
ComponentGlobal_NotifikasiBerhasil(result.message);
|
|
||||||
router.push(RouterHome.main_home, { scroll: false });
|
|
||||||
// if (result.active === true) {
|
|
||||||
// } else {
|
|
||||||
// ComponentGlobal_NotifikasiBerhasil(result.message);
|
|
||||||
// router.push("/waiting-room", { scroll: false });
|
|
||||||
// }
|
|
||||||
} else {
|
|
||||||
ComponentGlobal_NotifikasiBerhasil("Admin Logged in");
|
|
||||||
router.push(RouterAdminDashboard.splash_admin, { scroll: false });
|
|
||||||
}
|
|
||||||
|
|
||||||
await auth_funDeleteAktivasiKodeOtpByNomor({
|
await auth_funDeleteAktivasiKodeOtpByNomor({
|
||||||
nomor: data.nomor,
|
nomor: data.nomor,
|
||||||
});
|
});
|
||||||
|
router.push(RouterHome.main_home, { scroll: false });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (res.status === 200 && result.roleId != "1") {
|
||||||
|
ComponentGlobal_NotifikasiBerhasil("Admin Logged in");
|
||||||
|
localStorage.removeItem("hipmi_auth_code_id");
|
||||||
|
await auth_funDeleteAktivasiKodeOtpByNomor({
|
||||||
|
nomor: data.nomor,
|
||||||
|
});
|
||||||
|
router.push(RouterAdminDashboard.splash_admin, { scroll: false });
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res.status === 404) {
|
if (res.status === 404) {
|
||||||
ComponentGlobal_NotifikasiBerhasil(result.message);
|
|
||||||
router.push("/register", { scroll: false });
|
router.push("/register", { scroll: false });
|
||||||
|
ComponentGlobal_NotifikasiBerhasil(result.message);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res.status === 400) {
|
if (res.status === 400) {
|
||||||
ComponentGlobal_NotifikasiPeringatan(result.message);
|
ComponentGlobal_NotifikasiPeringatan(result.message);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,47 +1,71 @@
|
|||||||
|
import { DIRECTORY_ID } from "@/app/lib";
|
||||||
import { MainColor } from "@/app_modules/_global/color";
|
import { MainColor } from "@/app_modules/_global/color";
|
||||||
|
import {
|
||||||
|
funGlobal_DeleteFileById,
|
||||||
|
funGlobal_UploadToStorage,
|
||||||
|
} from "@/app_modules/_global/fun";
|
||||||
import {
|
import {
|
||||||
ComponentGlobal_NotifikasiBerhasil,
|
ComponentGlobal_NotifikasiBerhasil,
|
||||||
ComponentGlobal_NotifikasiGagal,
|
ComponentGlobal_NotifikasiGagal,
|
||||||
ComponentGlobal_NotifikasiPeringatan,
|
ComponentGlobal_NotifikasiPeringatan,
|
||||||
} from "@/app_modules/_global/notif_global";
|
} from "@/app_modules/_global/notif_global";
|
||||||
|
import { clientLogger } from "@/util/clientLogger";
|
||||||
import { Box, Button } from "@mantine/core";
|
import { Box, Button } from "@mantine/core";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { profile_funUpdateBackground } from "../../fun/update/fun_update_background";
|
import { profile_funUpdateBackground } from "../../fun/update/fun_update_background";
|
||||||
import { DIRECTORY_ID } from "@/app/lib";
|
|
||||||
import { funGlobal_UploadToStorage } from "@/app_modules/_global/fun";
|
|
||||||
|
|
||||||
export function Profile_ComponentButtonUpdateBackgroundProfile({
|
export function Profile_ComponentButtonUpdateBackgroundProfile({
|
||||||
profileId,
|
|
||||||
file,
|
file,
|
||||||
|
profileId,
|
||||||
|
fileId,
|
||||||
}: {
|
}: {
|
||||||
profileId: string;
|
|
||||||
file: File;
|
file: File;
|
||||||
|
profileId: string;
|
||||||
|
fileId: string;
|
||||||
}) {
|
}) {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
async function onUpdate() {
|
async function onUpdate() {
|
||||||
setLoading(true);
|
try {
|
||||||
const uploadFile = await funGlobal_UploadToStorage({
|
|
||||||
file: file,
|
|
||||||
dirId: DIRECTORY_ID.profile_background,
|
|
||||||
});
|
|
||||||
if (!uploadFile.success) {
|
|
||||||
setLoading(false);
|
|
||||||
return ComponentGlobal_NotifikasiPeringatan("Gagal upload foto profile");
|
|
||||||
}
|
|
||||||
|
|
||||||
const res = await profile_funUpdateBackground({
|
|
||||||
profileId: profileId,
|
|
||||||
fileId: uploadFile.data.id,
|
|
||||||
});
|
|
||||||
if (res.status === 200) {
|
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
const deletePhoto = await funGlobal_DeleteFileById({
|
||||||
router.back();
|
fileId: fileId,
|
||||||
} else {
|
dirId: DIRECTORY_ID.profile_background,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!deletePhoto.success) {
|
||||||
|
ComponentGlobal_NotifikasiPeringatan("Gagal update background");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const uploadFile = await funGlobal_UploadToStorage({
|
||||||
|
file: file,
|
||||||
|
dirId: DIRECTORY_ID.profile_background,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!uploadFile.success) {
|
||||||
|
setLoading(false);
|
||||||
|
return ComponentGlobal_NotifikasiPeringatan(
|
||||||
|
"Gagal upload background"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const res = await profile_funUpdateBackground({
|
||||||
|
profileId: profileId,
|
||||||
|
fileId: uploadFile.data.id,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (res.status === 200) {
|
||||||
|
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||||
|
router.back();
|
||||||
|
} else {
|
||||||
|
ComponentGlobal_NotifikasiGagal(res.message);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
clientLogger.error("Error upload background", error);
|
||||||
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
ComponentGlobal_NotifikasiGagal(res.message);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,40 +10,62 @@ import { Box, Button, Center } from "@mantine/core";
|
|||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { profile_funUpdatePhoto } from "../../fun";
|
import { profile_funUpdatePhoto } from "../../fun";
|
||||||
import { funGlobal_UploadToStorage } from "@/app_modules/_global/fun";
|
import {
|
||||||
|
funGlobal_DeleteFileById,
|
||||||
|
funGlobal_UploadToStorage,
|
||||||
|
} from "@/app_modules/_global/fun";
|
||||||
import { DIRECTORY_ID } from "@/app/lib";
|
import { DIRECTORY_ID } from "@/app/lib";
|
||||||
|
import { clientLogger } from "@/util/clientLogger";
|
||||||
|
|
||||||
export function Profile_ComponentButtonUpdatePhotoProfile({
|
export function Profile_ComponentButtonUpdatePhotoProfile({
|
||||||
file,
|
file,
|
||||||
profileId,
|
profileId,
|
||||||
|
fileId,
|
||||||
}: {
|
}: {
|
||||||
file: File;
|
file: File;
|
||||||
profileId: string;
|
profileId: string;
|
||||||
|
fileId: string;
|
||||||
}) {
|
}) {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [isLoading, setLoading] = useState(false);
|
const [isLoading, setLoading] = useState(false);
|
||||||
async function onUpdate() {
|
async function onUpdate() {
|
||||||
setLoading(true);
|
try {
|
||||||
const uploadPhoto = await funGlobal_UploadToStorage({
|
|
||||||
file: file,
|
|
||||||
dirId: DIRECTORY_ID.profile_foto,
|
|
||||||
});
|
|
||||||
if (!uploadPhoto.success) {
|
|
||||||
setLoading(false);
|
|
||||||
return ComponentGlobal_NotifikasiPeringatan("Gagal upload foto profile");
|
|
||||||
}
|
|
||||||
|
|
||||||
const res = await profile_funUpdatePhoto({
|
|
||||||
fileId: uploadPhoto.data.id,
|
|
||||||
profileId: profileId,
|
|
||||||
});
|
|
||||||
if (res.status === 200) {
|
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
const deletePhoto = await funGlobal_DeleteFileById({
|
||||||
router.back();
|
fileId: fileId,
|
||||||
} else {
|
dirId: DIRECTORY_ID.profile_foto,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!deletePhoto.success) {
|
||||||
|
ComponentGlobal_NotifikasiPeringatan("Gagal update foto profile");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const uploadPhoto = await funGlobal_UploadToStorage({
|
||||||
|
file: file,
|
||||||
|
dirId: DIRECTORY_ID.profile_foto,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!uploadPhoto.success) {
|
||||||
|
ComponentGlobal_NotifikasiPeringatan("Gagal upload foto profile");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const res = await profile_funUpdatePhoto({
|
||||||
|
fileId: uploadPhoto.data.id,
|
||||||
|
profileId: profileId,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (res.status === 200) {
|
||||||
|
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||||
|
router.back();
|
||||||
|
} else {
|
||||||
|
ComponentGlobal_NotifikasiGagal(res.message);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
clientLogger.error("Error update photo profile", error);
|
||||||
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
ComponentGlobal_NotifikasiGagal(res.message);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ export default function Profile_UpdateFotoBackground({
|
|||||||
<Profile_ComponentButtonUpdateBackgroundProfile
|
<Profile_ComponentButtonUpdateBackgroundProfile
|
||||||
file={file as any}
|
file={file as any}
|
||||||
profileId={profile.id}
|
profileId={profile.id}
|
||||||
|
fileId={profile.imageBackgroundId as string}
|
||||||
/>
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ export default function UploadFotoProfile({
|
|||||||
<Profile_ComponentButtonUpdatePhotoProfile
|
<Profile_ComponentButtonUpdatePhotoProfile
|
||||||
file={file as any}
|
file={file as any}
|
||||||
profileId={profile.id}
|
profileId={profile.id}
|
||||||
|
fileId={profile.imageId as string}
|
||||||
/>
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
</>
|
</>
|
||||||
|
|||||||
Reference in New Issue
Block a user