fix
Deskripsi: - Upload ke stroage untuk job ## Np Issuee
This commit is contained in:
24
src/app_modules/_global/component/comp_box_upload_image.tsx
Normal file
24
src/app_modules/_global/component/comp_box_upload_image.tsx
Normal file
@@ -0,0 +1,24 @@
|
||||
import { ComponentGlobal_CardStyles } from "@/app_modules/_global/component";
|
||||
import { Box } from "@mantine/core";
|
||||
|
||||
export function ComponentGlobal_BoxUploadImage({
|
||||
children,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
}) {
|
||||
return (
|
||||
<>
|
||||
<ComponentGlobal_CardStyles height={300}>
|
||||
<Box
|
||||
style={{
|
||||
height: "100%",
|
||||
borderStyle: "dashed",
|
||||
borderRadius: "5px",
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
</Box>
|
||||
</ComponentGlobal_CardStyles>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
import ComponentGlobal_BoxInformation from "./box_information";
|
||||
import ComponentGlobal_AvatarAndAuthorName from "./comp_author_name_and_avatar";
|
||||
import { ComponentGlobal_BoxUploadImage } from "./comp_box_upload_image";
|
||||
import { ComponentGlobal_CardStyles } from "./comp_card_box_and_background";
|
||||
import ComponentGlobal_CardLoadingOverlay from "./comp_loading_card";
|
||||
import ComponentGlobal_TampilanAngkaRatusan from "./comp_tampilan_angka_ratusan";
|
||||
@@ -13,3 +14,4 @@ export { ComponentGlobal_CardLoadingOverlay };
|
||||
export { ComponentGlobal_BoxInformation };
|
||||
export { ComponentGlobal_InputCountDown };
|
||||
export { ComponentGlobal_CardStyles };
|
||||
export { ComponentGlobal_BoxUploadImage };
|
||||
|
||||
@@ -28,7 +28,7 @@ export default function Admin_Logout() {
|
||||
const [loadingLogout, setLoadingLogout] = useState(false);
|
||||
|
||||
async function onClickLogout() {
|
||||
await auth_Logout(kodeId).then((res) => {
|
||||
await auth_Logout().then((res) => {
|
||||
if (res.status === 200) {
|
||||
setLoadingLogout(true);
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||
|
||||
@@ -2,10 +2,8 @@
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { RouterAdminColab } from "@/app/lib/router_admin/router_admin_colab";
|
||||
import { RouterAuth } from "@/app/lib/router_hipmi/router_auth";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { redirect } from "next/navigation";
|
||||
|
||||
export default async function adminColab_funReportProjectById({
|
||||
colabId,
|
||||
@@ -14,11 +12,7 @@ export default async function adminColab_funReportProjectById({
|
||||
colabId: string;
|
||||
report: string;
|
||||
}) {
|
||||
const authorId = await user_funGetOneUserId();
|
||||
if (!authorId) {
|
||||
redirect(RouterAuth.login);
|
||||
// return { status: 400, message: "Gagal mendapatkan authorId" };
|
||||
}
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
const projectUpdate = await prisma.projectCollaboration.update({
|
||||
where: {
|
||||
@@ -39,7 +33,7 @@ export default async function adminColab_funReportProjectById({
|
||||
const updateReport = await prisma.projectCollaboration_Notifikasi.create({
|
||||
data: {
|
||||
projectCollaborationId: colabId,
|
||||
adminId: authorId,
|
||||
adminId: userLoginId,
|
||||
userId: projectUpdate.userId as any,
|
||||
note: "Project Anda Telah Direport Admin",
|
||||
},
|
||||
|
||||
@@ -353,6 +353,11 @@ async function onPublish({
|
||||
"USER",
|
||||
JSON.stringify({ userId: publish?.data?.authorId, count: 1 })
|
||||
);
|
||||
|
||||
mqtt_client.publish(
|
||||
"Job_new_post",
|
||||
JSON.stringify({ isNewPost: true, count: 1 })
|
||||
);
|
||||
}
|
||||
|
||||
ComponentGlobal_NotifikasiBerhasil(publish.message);
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
|
||||
export default async function adminNotifikasi_countNotifikasi() {
|
||||
const adminId = await user_funGetOneUserId();
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
const data = await prisma.notifikasi.findMany({
|
||||
where: {
|
||||
adminId: adminId,
|
||||
adminId: userLoginId,
|
||||
isRead: false,
|
||||
userRoleId: "2",
|
||||
},
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
import { MODEL_NOTIFIKASI } from "@/app_modules/notifikasi/model/interface";
|
||||
|
||||
export default async function adminNotifikasi_funCreateToUser({
|
||||
@@ -9,11 +9,11 @@ export default async function adminNotifikasi_funCreateToUser({
|
||||
}: {
|
||||
data: MODEL_NOTIFIKASI;
|
||||
}) {
|
||||
const adminId = await user_funGetOneUserId();
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
const create = await prisma.notifikasi.create({
|
||||
data: {
|
||||
adminId: adminId,
|
||||
adminId: userLoginId,
|
||||
userId: data.userId,
|
||||
appId: data.appId,
|
||||
status: data.status,
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { NextRequest } from "next/server";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
|
||||
export default async function adminNotifikasi_getByUserId() {
|
||||
const adminId = await user_funGetOneUserId();
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
const data = await prisma.notifikasi.findMany({
|
||||
orderBy: [
|
||||
@@ -17,7 +16,7 @@ export default async function adminNotifikasi_getByUserId() {
|
||||
},
|
||||
],
|
||||
where: {
|
||||
adminId: adminId,
|
||||
adminId: userLoginId,
|
||||
userRoleId: "2",
|
||||
},
|
||||
});
|
||||
|
||||
@@ -17,7 +17,7 @@ export async function auth_funLogin({ nomor }: { nomor: string }) {
|
||||
|
||||
const sendWa = await res.json();
|
||||
if (sendWa.status !== "success")
|
||||
return { status: 400, message: "WA Tidak Terdaftar", nomorUser: {} };
|
||||
return { status: 400, message: "WA Tidak Terdaftar", kodeId: {} };
|
||||
|
||||
const createOtpId = await prisma.kodeOtp.create({
|
||||
data: {
|
||||
@@ -27,15 +27,15 @@ export async function auth_funLogin({ nomor }: { nomor: string }) {
|
||||
});
|
||||
|
||||
if (!createOtpId)
|
||||
return { status: 400, message: "Gagal Membuat Kode OTP", nomorUser: {} };
|
||||
return { status: 400, message: "Gagal Membuat Kode OTP", kodeId: {} };
|
||||
|
||||
return {
|
||||
status: 200,
|
||||
message: "Kode Verifikasi Dikirim",
|
||||
nomorUser: nomor,
|
||||
kodeId: createOtpId.id,
|
||||
};
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
return { status: 500, message: "Server Error !!!", nomorUser: {} };
|
||||
return { status: 500, message: "Server Error !!!", kodeId: {} };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { cookies } from "next/headers";
|
||||
|
||||
export async function auth_Logout(kodeId: string) {
|
||||
export async function auth_Logout() {
|
||||
const userId = await funGetUserIdByToken();
|
||||
|
||||
try {
|
||||
@@ -19,8 +19,7 @@ export async function auth_Logout(kodeId: string) {
|
||||
cookies().set({
|
||||
name: "ssn",
|
||||
value: "",
|
||||
maxAge: 0,
|
||||
expires: 0,
|
||||
|
||||
});
|
||||
|
||||
return { status: 200, message: "Logout Berhasil" };
|
||||
@@ -28,12 +27,6 @@ export async function auth_Logout(kodeId: string) {
|
||||
console.log(error);
|
||||
}
|
||||
|
||||
// const del = await prisma.kodeOtp.delete({
|
||||
// where: {
|
||||
// id: kodeId,
|
||||
// },
|
||||
// });
|
||||
// if (!del) return { status: 400, message: "Gagal Hapus Kode OTP Id"};
|
||||
// revalidatePath("/dev/katalog")
|
||||
revalidatePath("/");
|
||||
return { status: 200, message: "Logout Berhasil" };
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { RouterHome } from "@/app/lib/router_hipmi/router_home";
|
||||
import { sealData } from "iron-session";
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { cookies } from "next/headers";
|
||||
|
||||
export async function Auth_funRegister({
|
||||
@@ -47,15 +49,20 @@ export async function Auth_funRegister({
|
||||
// maxAge: 60 * 60 * 24 * 7,
|
||||
});
|
||||
|
||||
const createUserSession = await prisma.userSession.create({
|
||||
data: {
|
||||
token: sealToken,
|
||||
userId: create.id,
|
||||
},
|
||||
});
|
||||
try {
|
||||
const createUserSession = await prisma.userSession.create({
|
||||
data: {
|
||||
token: sealToken,
|
||||
userId: create.id,
|
||||
},
|
||||
});
|
||||
|
||||
if (!createUserSession)
|
||||
return { status: 400, message: "Gagal Membuat User Session" };
|
||||
if (!createUserSession)
|
||||
return { status: 401, message: "Gagal Membuat User Session" };
|
||||
|
||||
revalidatePath(RouterHome.main_home);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
return { status: 200, message: "Berhasil Mendaftar" };
|
||||
}
|
||||
|
||||
@@ -25,7 +25,8 @@ export async function auth_funValidasi({
|
||||
},
|
||||
});
|
||||
|
||||
if (cekUser === null) return { status: 400, message: "Nomor Belum Terdaftar" };
|
||||
if (cekUser === null)
|
||||
return { status: 400, message: "Nomor Belum Terdaftar", role: {} };
|
||||
|
||||
const sealToken = await sealData(
|
||||
JSON.stringify({
|
||||
@@ -40,10 +41,23 @@ export async function auth_funValidasi({
|
||||
cookies().set({
|
||||
name: "ssn",
|
||||
value: sealToken,
|
||||
// maxAge: 60 * 60 * 24 * 30,
|
||||
// expires: 60 * 60 * 24 * 30,
|
||||
maxAge: 60 * 60 * 24 * 30,
|
||||
});
|
||||
|
||||
const cekSessionUser = await prisma.userSession.findFirst({
|
||||
where: {
|
||||
userId: cekUser.id,
|
||||
},
|
||||
});
|
||||
|
||||
if (cekSessionUser !== null) {
|
||||
await prisma.userSession.delete({
|
||||
where: {
|
||||
userId: cekUser.id,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
try {
|
||||
const createUserSession = await prisma.userSession.create({
|
||||
data: {
|
||||
@@ -53,7 +67,7 @@ export async function auth_funValidasi({
|
||||
});
|
||||
|
||||
if (!createUserSession)
|
||||
return { status: 401, message: "Gagal Membuat User Session" };
|
||||
return { status: 401, message: "Gagal Membuat User Session", role: {} };
|
||||
|
||||
revalidatePath(RouterHome.main_home);
|
||||
} catch (error) {
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
|
||||
export async function auth_getKodeOtpById({nomor}: {nomor: string}) {
|
||||
export async function auth_getCodeOtpByNumber({kodeId}: {kodeId: string}) {
|
||||
const data = await prisma.kodeOtp.findFirst({
|
||||
where: {
|
||||
nomor: nomor,
|
||||
id: kodeId,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -28,7 +28,6 @@ import {
|
||||
|
||||
export default function Login() {
|
||||
const router = useRouter();
|
||||
const [kodeId, setKodeId] = useAtom(gs_kodeId);
|
||||
const [phone, setPhone] = useState("");
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [isError, setError] = useState(false);
|
||||
@@ -41,7 +40,7 @@ export default function Login() {
|
||||
if (res.status === 200) {
|
||||
setLoading(true);
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message, 2000);
|
||||
router.push(RouterAuth.validasi + res.nomorUser, { scroll: false });
|
||||
router.push(RouterAuth.validasi + res.kodeId, { scroll: false });
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiPeringatan(res.message);
|
||||
}
|
||||
|
||||
@@ -6,23 +6,19 @@ import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/noti
|
||||
import UIGlobal_Modal from "@/app_modules/_global/ui/ui_modal";
|
||||
import { ActionIcon, Button, Stack, Text } from "@mantine/core";
|
||||
import { IconLogout } from "@tabler/icons-react";
|
||||
import { useAtom } from "jotai";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { auth_Logout } from "../fun/fun_logout";
|
||||
import { gs_kodeId } from "../state/state";
|
||||
|
||||
export default function Component_Logout() {
|
||||
const router = useRouter();
|
||||
const [opened, setOpened] = useState(false);
|
||||
const [kodeId, setKodeId] = useAtom(gs_kodeId);
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
async function onClickLogout() {
|
||||
await auth_Logout(kodeId).then((res) => {
|
||||
await auth_Logout().then((res) => {
|
||||
if (res.status === 200) {
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||
setKodeId("");
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiPeringatan(res.message);
|
||||
}
|
||||
|
||||
@@ -61,10 +61,20 @@ export default function Validasi({ dataOtp }: { dataOtp: any }) {
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiPeringatan(resAktivasi.message);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
|
||||
if (res.status === 400) {
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||
router.push(RouterAuth.register + dataOtp.id, { scroll: false });
|
||||
}
|
||||
|
||||
if (res.status === 401) {
|
||||
const resAktivasi = await auth_funDeleteAktivasiKodeOtpById(dataOtp.id);
|
||||
if (resAktivasi.status === 200) {
|
||||
ComponentGlobal_NotifikasiPeringatan(res.message);
|
||||
router.push(RouterAuth.login, { scroll: false });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
@@ -12,16 +12,16 @@ export function CheckCookies_UiLayout({
|
||||
const router = useRouter();
|
||||
|
||||
useShallowEffect(() => {
|
||||
// onCheckCookies();
|
||||
onCheckCookies();
|
||||
}, []);
|
||||
|
||||
// async function onCheckCookies() {
|
||||
// const cek = await fetch("/api/check-cookies");
|
||||
// const result = await cek.json();
|
||||
// if (result.success === false) {
|
||||
// router.push(RouterAuth.login);
|
||||
// }
|
||||
// }
|
||||
async function onCheckCookies() {
|
||||
const cek = await fetch("/api/check-cookies");
|
||||
const result = await cek.json();
|
||||
if (result.success === false) {
|
||||
router.push(RouterAuth.login);
|
||||
}
|
||||
}
|
||||
|
||||
return <>{children}</>;
|
||||
}
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { MODEL_COLLABORATION } from "../../model/interface";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { RouterColab } from "@/app/lib/router_hipmi/router_colab";
|
||||
import _ from "lodash";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { MODEL_COLLABORATION } from "../../model/interface";
|
||||
|
||||
export default async function colab_funCreateProyek(
|
||||
value: MODEL_COLLABORATION
|
||||
) {
|
||||
const AuthorId = await user_funGetOneUserId();
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
const data = await prisma.projectCollaboration.create({
|
||||
data: {
|
||||
@@ -20,7 +19,7 @@ export default async function colab_funCreateProyek(
|
||||
benefit: value.benefit,
|
||||
projectCollaborationMaster_IndustriId:
|
||||
value.projectCollaborationMaster_IndustriId,
|
||||
userId: AuthorId,
|
||||
userId: userLoginId,
|
||||
// jumlah_partisipan: + value.jumlah_partisipan,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,25 +1,19 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { RouterAuth } from "@/app/lib/router_hipmi/router_auth";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { redirect } from "next/navigation";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
|
||||
export default async function colab_funCreateRoomChat(
|
||||
nameRoom: string,
|
||||
value: any[],
|
||||
colabId: string
|
||||
) {
|
||||
const authorId = await user_funGetOneUserId();
|
||||
if (!authorId) {
|
||||
redirect(RouterAuth.login);
|
||||
// return { status: 400, message: "Gagal mendapatkan authorId" };
|
||||
}
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
const createRoom = await prisma.projectCollaboration_RoomChat.create({
|
||||
data: {
|
||||
name: nameRoom,
|
||||
userId: authorId,
|
||||
userId: userLoginId,
|
||||
projectCollaborationId: colabId,
|
||||
},
|
||||
});
|
||||
@@ -57,7 +51,7 @@ export default async function colab_funCreateRoomChat(
|
||||
const createForAuthor =
|
||||
await prisma.projectCollaboration_AnggotaRoomChat.create({
|
||||
data: {
|
||||
userId: authorId,
|
||||
userId: userLoginId,
|
||||
projectCollaboration_RoomChatId: createRoom.id,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -2,14 +2,15 @@
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { RouterColab } from "@/app/lib/router_hipmi/router_colab";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
import { revalidatePath } from "next/cache";
|
||||
|
||||
export default async function colab_funCreateMessageByUserId(
|
||||
message: string,
|
||||
roomId: string
|
||||
) {
|
||||
const userLoginId = await user_funGetOneUserId();
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
const msg = await prisma.projectCollaboration_Message.create({
|
||||
data: {
|
||||
userId: userLoginId,
|
||||
|
||||
@@ -1,20 +1,14 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { RouterAuth } from "@/app/lib/router_hipmi/router_auth";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { redirect } from "next/navigation";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
|
||||
export default async function colab_CekNotifikasi() {
|
||||
const authorId = await user_funGetOneUserId();
|
||||
if (!authorId) {
|
||||
redirect(RouterAuth.login);
|
||||
// return { status: 400, message: "Gagal mendapatkan authorId" };
|
||||
}
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
const cekNotif = await prisma.projectCollaboration_Notifikasi.findMany({
|
||||
where: {
|
||||
userId: authorId,
|
||||
userId: userLoginId,
|
||||
isRead: false,
|
||||
},
|
||||
select: {
|
||||
|
||||
@@ -1,22 +1,21 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
|
||||
export default async function colab_funCekPartisipasiById(colabId: string) {
|
||||
const UserLoginId = await user_funGetOneUserId();
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
const cek = await prisma.projectCollaboration_Partisipasi.findFirst({
|
||||
where: {
|
||||
projectCollaborationId: colabId,
|
||||
userId: UserLoginId,
|
||||
userId: userLoginId,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
if (cek === null) {
|
||||
return (false);
|
||||
return false;
|
||||
} else {
|
||||
return (true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
|
||||
export default async function colab_getListByStatusId(statusId: number) {
|
||||
const AuthorId = await user_funGetOneUserId();
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
const data = await prisma.projectCollaboration.findMany({
|
||||
where: {
|
||||
userId: AuthorId,
|
||||
userId: userLoginId,
|
||||
projectCollaborationMaster_StatusId: statusId,
|
||||
},
|
||||
select: {
|
||||
|
||||
@@ -1,26 +1,20 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { RouterAuth } from "@/app/lib/router_hipmi/router_auth";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { redirect } from "next/navigation";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
|
||||
export default async function colab_getListNotifikasiByUserId() {
|
||||
const authorId = await user_funGetOneUserId();
|
||||
if (!authorId) {
|
||||
redirect(RouterAuth.login);
|
||||
// return { status: 400, message: "Gagal mendapatkan authorId" };
|
||||
}
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
const get = await prisma.projectCollaboration_Notifikasi.findMany({
|
||||
orderBy: {
|
||||
createdAt: "desc",
|
||||
createdAt: "desc",
|
||||
},
|
||||
where: {
|
||||
userId: authorId,
|
||||
userId: userLoginId,
|
||||
},
|
||||
select: {
|
||||
id:true,
|
||||
id: true,
|
||||
createdAt: true,
|
||||
isRead: true,
|
||||
note: true,
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
|
||||
export default async function colab_getListPartisipasiProyekByAuthorId({
|
||||
page,
|
||||
}: {
|
||||
page: number;
|
||||
}) {
|
||||
const authorId = await user_funGetOneUserId();
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
const takeData = 5;
|
||||
const skipData = page * takeData - takeData;
|
||||
@@ -20,7 +20,7 @@ export default async function colab_getListPartisipasiProyekByAuthorId({
|
||||
createdAt: "desc",
|
||||
},
|
||||
where: {
|
||||
userId: authorId,
|
||||
userId: userLoginId,
|
||||
isActive: true,
|
||||
AND: {
|
||||
ProjectCollaboration: {
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
|
||||
export default async function colab_getListAllProyekSayaByAuthorId({
|
||||
page,
|
||||
}: {
|
||||
page: number;
|
||||
}) {
|
||||
const authorId = await user_funGetOneUserId();
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
const takeData = 5;
|
||||
const skipData = page * takeData - takeData;
|
||||
@@ -17,7 +17,7 @@ export default async function colab_getListAllProyekSayaByAuthorId({
|
||||
take: takeData,
|
||||
skip: skipData,
|
||||
orderBy: { createdAt: "desc" },
|
||||
where: { userId: authorId, isActive: true },
|
||||
where: { userId: userLoginId, isActive: true },
|
||||
select: {
|
||||
id: true,
|
||||
isActive: true,
|
||||
|
||||
@@ -1,20 +1,15 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { RouterAuth } from "@/app/lib/router_hipmi/router_auth";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { redirect } from "next/navigation";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
|
||||
export default async function colab_getListRoomChatByAuthorId({
|
||||
page,
|
||||
}: {
|
||||
page: number;
|
||||
}) {
|
||||
const authorId = await user_funGetOneUserId();
|
||||
if (!authorId) {
|
||||
redirect(RouterAuth.login);
|
||||
// return { status: 400, message: "Gagal mendapatkan authorId" };
|
||||
}
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
const takeData = 10;
|
||||
const skipData = page * takeData - takeData;
|
||||
|
||||
@@ -25,7 +20,7 @@ export default async function colab_getListRoomChatByAuthorId({
|
||||
createdAt: "desc",
|
||||
},
|
||||
where: {
|
||||
userId: authorId,
|
||||
userId: userLoginId,
|
||||
},
|
||||
select: {
|
||||
ProjectCollaboration_RoomChat: {
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
|
||||
export async function donasi_funGetAllInvoiceByAuthorId({
|
||||
page,
|
||||
}: {
|
||||
page: number;
|
||||
}) {
|
||||
const authorId = await user_funGetOneUserId();
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
const takeData = 5;
|
||||
const skipData = page * takeData - takeData;
|
||||
|
||||
@@ -19,7 +20,7 @@ export async function donasi_funGetAllInvoiceByAuthorId({
|
||||
createdAt: "desc",
|
||||
},
|
||||
where: {
|
||||
authorId: authorId,
|
||||
authorId: userLoginId,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
|
||||
export async function donasi_funGetAllStatusDraft({ page }: { page: number }) {
|
||||
const authorId = await user_funGetOneUserId();
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
const takeData = 5;
|
||||
const skipData = page * takeData - takeData;
|
||||
|
||||
@@ -15,10 +16,10 @@ export async function donasi_funGetAllStatusDraft({ page }: { page: number }) {
|
||||
updatedAt: "desc",
|
||||
},
|
||||
where: {
|
||||
authorId: authorId,
|
||||
authorId: userLoginId,
|
||||
donasiMaster_StatusDonasiId: "3",
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
|
||||
export async function donasi_funGetAllStatusPublish({
|
||||
page,
|
||||
}: {
|
||||
page: number;
|
||||
}) {
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
export async function donasi_funGetAllStatusPublish({ page }: { page: number }) {
|
||||
const authorId = await user_funGetOneUserId();
|
||||
const takeData = 5;
|
||||
const skipData = page * takeData - takeData;
|
||||
|
||||
|
||||
const data = await prisma.donasi.findMany({
|
||||
take: takeData,
|
||||
skip: skipData,
|
||||
@@ -16,7 +20,7 @@ export async function donasi_funGetAllStatusPublish({ page }: { page: number })
|
||||
publishTime: "desc",
|
||||
},
|
||||
where: {
|
||||
authorId: authorId,
|
||||
authorId: userLoginId,
|
||||
donasiMaster_StatusDonasiId: "1",
|
||||
active: true,
|
||||
},
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
|
||||
export async function donasi_funGetAllStatusReject({ page }: { page: number }) {
|
||||
const authorId = await user_funGetOneUserId();
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
const takeData = 5;
|
||||
const skipData = page * takeData - takeData;
|
||||
|
||||
@@ -15,7 +16,7 @@ export async function donasi_funGetAllStatusReject({ page }: { page: number }) {
|
||||
updatedAt: "desc",
|
||||
},
|
||||
where: {
|
||||
authorId: authorId,
|
||||
authorId: userLoginId,
|
||||
donasiMaster_StatusDonasiId: "4",
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,24 +1,25 @@
|
||||
"use server"
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
|
||||
export async function donasi_funGetAllStatusReview({page}: {page: number}) {
|
||||
const authorId = await user_funGetOneUserId();
|
||||
const takeData = 5;
|
||||
const skipData = page * takeData - takeData;
|
||||
export async function donasi_funGetAllStatusReview({ page }: { page: number }) {
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
const data = await prisma.donasi.findMany({
|
||||
take: takeData,
|
||||
skip: skipData,
|
||||
orderBy: {
|
||||
updatedAt: "desc",
|
||||
},
|
||||
where: {
|
||||
authorId: authorId,
|
||||
donasiMaster_StatusDonasiId: "2",
|
||||
},
|
||||
});
|
||||
const takeData = 5;
|
||||
const skipData = page * takeData - takeData;
|
||||
|
||||
return data;
|
||||
}
|
||||
const data = await prisma.donasi.findMany({
|
||||
take: takeData,
|
||||
skip: skipData,
|
||||
orderBy: {
|
||||
updatedAt: "desc",
|
||||
},
|
||||
where: {
|
||||
authorId: userLoginId,
|
||||
donasiMaster_StatusDonasiId: "2",
|
||||
},
|
||||
});
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
|
||||
export async function event_getListKontibusiByUserId({page}: {page: number}) {
|
||||
const userLoginId = await user_funGetOneUserId();
|
||||
export async function event_getListKontibusiByUserId({
|
||||
page,
|
||||
}: {
|
||||
page: number;
|
||||
}) {
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
const takeData = 10;
|
||||
const skipData = page * takeData - takeData;
|
||||
@@ -41,8 +45,8 @@ export async function event_getListKontibusiByUserId({page}: {page: number}) {
|
||||
userId: true,
|
||||
User: {
|
||||
select: {
|
||||
Profile: true
|
||||
}
|
||||
Profile: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -50,7 +54,7 @@ export async function event_getListKontibusiByUserId({page}: {page: number}) {
|
||||
},
|
||||
},
|
||||
});
|
||||
// console.log(data);
|
||||
// console.log(data);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import _ from "lodash";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
|
||||
export async function event_getListRiwayatSaya({page}: {page: number}) {
|
||||
const authorId = await user_funGetOneUserId();
|
||||
export async function event_getListRiwayatSaya({ page }: { page: number }) {
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
const takeData = 10;
|
||||
const skipData = page * takeData - takeData;
|
||||
|
||||
|
||||
const data = await prisma.event.findMany({
|
||||
take: takeData,
|
||||
skip: skipData,
|
||||
@@ -18,7 +16,7 @@ export async function event_getListRiwayatSaya({page}: {page: number}) {
|
||||
tanggal: "desc",
|
||||
},
|
||||
where: {
|
||||
authorId: authorId,
|
||||
authorId: userLoginId,
|
||||
eventMaster_StatusId: "1",
|
||||
tanggal: {
|
||||
lte: new Date(),
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
|
||||
export async function event_getAllDraft({ page }: { page: number }) {
|
||||
const authorId = await user_funGetOneUserId();
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
const takeData = 10;
|
||||
const skipData = page * takeData - takeData;
|
||||
|
||||
@@ -17,7 +18,7 @@ export async function event_getAllDraft({ page }: { page: number }) {
|
||||
where: {
|
||||
active: true,
|
||||
eventMaster_StatusId: "3",
|
||||
authorId: authorId,
|
||||
authorId: userLoginId,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
|
||||
export async function event_getAllReject({ page }: { page: number }) {
|
||||
const authorId = await user_funGetOneUserId();
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
const takeData = 10;
|
||||
const skipData = page * takeData - takeData;
|
||||
|
||||
@@ -17,7 +18,7 @@ export async function event_getAllReject({ page }: { page: number }) {
|
||||
where: {
|
||||
active: true,
|
||||
eventMaster_StatusId: "4",
|
||||
authorId: authorId,
|
||||
authorId: userLoginId,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
|
||||
export async function event_getAllReview({ page }: { page: number }) {
|
||||
const authorId = await user_funGetOneUserId();
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
const takeData = 10;
|
||||
const skipData = page * takeData - takeData;
|
||||
|
||||
@@ -17,7 +18,7 @@ export async function event_getAllReview({ page }: { page: number }) {
|
||||
where: {
|
||||
active: true,
|
||||
eventMaster_StatusId: "2",
|
||||
authorId: authorId,
|
||||
authorId: userLoginId,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
|
||||
export async function event_funGetAllStatusPublish({ page }: { page: number }) {
|
||||
const authorId = await user_funGetOneUserId();
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
const takeData = 10;
|
||||
const skipData = page * takeData - takeData;
|
||||
|
||||
@@ -17,7 +18,7 @@ export async function event_funGetAllStatusPublish({ page }: { page: number }) {
|
||||
where: {
|
||||
active: true,
|
||||
eventMaster_StatusId: "1",
|
||||
authorId: authorId,
|
||||
authorId: userLoginId,
|
||||
tanggal: {
|
||||
gte: new Date(),
|
||||
},
|
||||
|
||||
@@ -3,38 +3,30 @@
|
||||
import { RouterForum } from "@/app/lib/router_hipmi/router_forum";
|
||||
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
|
||||
import {
|
||||
Drawer,
|
||||
Stack,
|
||||
Grid,
|
||||
Button,
|
||||
Modal,
|
||||
Title,
|
||||
Group,
|
||||
ActionIcon,
|
||||
Text,
|
||||
Box,
|
||||
Center,
|
||||
Button,
|
||||
Drawer,
|
||||
Grid,
|
||||
Group,
|
||||
Loader,
|
||||
Modal,
|
||||
Stack,
|
||||
Text,
|
||||
Title,
|
||||
} from "@mantine/core";
|
||||
import { useDisclosure, useShallowEffect } from "@mantine/hooks";
|
||||
import { IconTrash, IconEdit, IconFlag3, IconDots } from "@tabler/icons-react";
|
||||
import { useDisclosure } from "@mantine/hooks";
|
||||
import { IconDots, IconFlag3, IconTrash } from "@tabler/icons-react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
|
||||
import { createStyles } from "@mantine/core";
|
||||
import ComponentGlobal_V2_LoadingPage from "@/app_modules/_global/loading_page_v2";
|
||||
import { useAtom } from "jotai";
|
||||
import { gs_forum_loading_edit_posting } from "../../global_state";
|
||||
import ComponentForum_LoadingDrawer from "../loading_drawer";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { forum_funDeletePostingById } from "../../fun/delete/fun_delete_posting_by_id";
|
||||
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
|
||||
import { forum_funDeleteKomentarById } from "../../fun/delete/fun_delete_komentar_by_id";
|
||||
import { forum_funGetAllKomentarById } from "../../fun/get/get_all_komentar_by_id";
|
||||
import {
|
||||
AccentColor,
|
||||
MainColor,
|
||||
} from "@/app_modules/_global/color/color_pallet";
|
||||
import ComponentGlobal_V2_LoadingPage from "@/app_modules/_global/loading_page_v2";
|
||||
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
|
||||
import { forum_funDeleteKomentarById } from "../../fun/delete/fun_delete_komentar_by_id";
|
||||
import { forum_funGetAllKomentarById } from "../../fun/get/get_all_komentar_by_id";
|
||||
|
||||
export default function ComponentForum_KomentarButtonMore({
|
||||
userId,
|
||||
@@ -200,7 +192,9 @@ function ButtonDelete({
|
||||
return (
|
||||
<>
|
||||
<Stack>
|
||||
<Title order={6} c="white">Yakin menghapus komentar ini ?</Title>
|
||||
<Title order={6} c="white">
|
||||
Yakin menghapus komentar ini ?
|
||||
</Title>
|
||||
<Group position="center">
|
||||
<Button radius={"xl"} onClick={() => setOpenDel(false)}>
|
||||
Batal
|
||||
|
||||
@@ -3,39 +3,32 @@
|
||||
import { RouterForum } from "@/app/lib/router_hipmi/router_forum";
|
||||
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
|
||||
import {
|
||||
Drawer,
|
||||
Stack,
|
||||
Grid,
|
||||
Button,
|
||||
Modal,
|
||||
Title,
|
||||
Group,
|
||||
ActionIcon,
|
||||
Text,
|
||||
Box,
|
||||
Center,
|
||||
Button,
|
||||
Drawer,
|
||||
Grid,
|
||||
Group,
|
||||
Loader,
|
||||
Modal,
|
||||
Stack,
|
||||
Text,
|
||||
Title,
|
||||
} from "@mantine/core";
|
||||
import { useDisclosure, useShallowEffect } from "@mantine/hooks";
|
||||
import { useDisclosure } from "@mantine/hooks";
|
||||
import {
|
||||
IconTrash,
|
||||
IconDots,
|
||||
IconEdit,
|
||||
IconFlag3,
|
||||
IconDots,
|
||||
IconSquareRoundedX,
|
||||
IconTrash,
|
||||
} from "@tabler/icons-react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
|
||||
import { createStyles } from "@mantine/core";
|
||||
import ComponentGlobal_V2_LoadingPage from "@/app_modules/_global/loading_page_v2";
|
||||
import { useAtom } from "jotai";
|
||||
import { gs_forum_loading_edit_posting } from "../../global_state";
|
||||
import ComponentForum_LoadingDrawer from "../loading_drawer";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { forum_funDeletePostingById } from "../../fun/delete/fun_delete_posting_by_id";
|
||||
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
|
||||
import { IconSquareCheck } from "@tabler/icons-react";
|
||||
import { forum_funDeletePostingById } from "../../fun/delete/fun_delete_posting_by_id";
|
||||
import { forum_funEditStatusPostingById } from "../../fun/edit/fun_edit_status_posting_by_id";
|
||||
|
||||
export default function ComponentForum_DetailMoreButton({
|
||||
|
||||
@@ -3,39 +3,30 @@
|
||||
import { RouterForum } from "@/app/lib/router_hipmi/router_forum";
|
||||
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
|
||||
import {
|
||||
Drawer,
|
||||
Stack,
|
||||
Grid,
|
||||
Button,
|
||||
Modal,
|
||||
Title,
|
||||
Group,
|
||||
ActionIcon,
|
||||
Text,
|
||||
Box,
|
||||
Center,
|
||||
Button,
|
||||
Drawer,
|
||||
Grid,
|
||||
Group,
|
||||
Loader,
|
||||
Modal,
|
||||
Stack,
|
||||
Text,
|
||||
Title,
|
||||
} from "@mantine/core";
|
||||
import { useDisclosure, useShallowEffect } from "@mantine/hooks";
|
||||
import { useDisclosure } from "@mantine/hooks";
|
||||
import {
|
||||
IconTrash,
|
||||
IconDots,
|
||||
IconEdit,
|
||||
IconFlag3,
|
||||
IconDots,
|
||||
IconSquareRoundedX,
|
||||
IconSquareCheck,
|
||||
IconSquareRoundedX,
|
||||
IconTrash,
|
||||
} from "@tabler/icons-react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
|
||||
import { createStyles } from "@mantine/core";
|
||||
import ComponentGlobal_V2_LoadingPage from "@/app_modules/_global/loading_page_v2";
|
||||
import { useAtom } from "jotai";
|
||||
import { gs_forum_loading_edit_posting } from "../../global_state";
|
||||
import ComponentForum_LoadingDrawer from "../loading_drawer";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { forum_funDeletePostingById } from "../../fun/delete/fun_delete_posting_by_id";
|
||||
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
|
||||
import { forum_funDeletePostingById } from "../../fun/delete/fun_delete_posting_by_id";
|
||||
import { forum_funEditStatusPostingById } from "../../fun/edit/fun_edit_status_posting_by_id";
|
||||
import { forum_getListAllPosting } from "../../fun/get/get_list_all_posting";
|
||||
import { forum_getAllPostingByAuhtorId } from "../../fun/get/get_list_posting_by_author_id";
|
||||
@@ -277,9 +268,10 @@ function ButtonStatus({
|
||||
async (res) => {
|
||||
if (res.status === 200) {
|
||||
if (userLoginId === authorId) {
|
||||
await forum_getAllPostingByAuhtorId({authorId: authorId, page: 1}).then((val: any) =>
|
||||
setData(val)
|
||||
);
|
||||
await forum_getAllPostingByAuhtorId({
|
||||
authorId: authorId,
|
||||
page: 1,
|
||||
}).then((val: any) => setData(val));
|
||||
} else {
|
||||
await forum_getListAllPosting().then((val) => setData(val as any));
|
||||
}
|
||||
@@ -299,9 +291,10 @@ function ButtonStatus({
|
||||
async (res) => {
|
||||
if (res.status === 200) {
|
||||
if (userLoginId === authorId) {
|
||||
await forum_getAllPostingByAuhtorId({authorId: authorId, page: 1}).then((val: any) =>
|
||||
setData(val)
|
||||
);
|
||||
await forum_getAllPostingByAuhtorId({
|
||||
authorId: authorId,
|
||||
page: 1,
|
||||
}).then((val: any) => setData(val));
|
||||
} else {
|
||||
await forum_getListAllPosting().then((val) => setData(val as any));
|
||||
}
|
||||
|
||||
@@ -1,17 +1,14 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
|
||||
export async function forum_countPostingByAuthorId(authorId: string) {
|
||||
|
||||
|
||||
const data = await prisma.forum_Posting.count({
|
||||
where: {
|
||||
authorId: authorId,
|
||||
isActive: true
|
||||
isActive: true,
|
||||
},
|
||||
});
|
||||
|
||||
return data
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
import { revalidatePath } from "next/cache";
|
||||
|
||||
export async function forum_funCreate(value: string) {
|
||||
const AuthorId = await user_funGetOneUserId();
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
const create = await prisma.forum_Posting.create({
|
||||
data: {
|
||||
diskusi: value,
|
||||
authorId: AuthorId,
|
||||
forumMaster_StatusPostingId: 1
|
||||
authorId: userLoginId,
|
||||
forumMaster_StatusPostingId: 1,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
import { revalidatePath } from "next/cache";
|
||||
|
||||
export async function forum_funCreateKomentar(
|
||||
postingId: string,
|
||||
komentar: string
|
||||
) {
|
||||
const authorId = await user_funGetOneUserId();
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
const create = await prisma.forum_Komentar.create({
|
||||
data: {
|
||||
komentar: komentar,
|
||||
forum_PostingId: postingId,
|
||||
authorId: authorId,
|
||||
authorId: userLoginId,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
|
||||
export async function forum_funCreateReportKomentar({
|
||||
komentarId,
|
||||
@@ -10,19 +10,12 @@ export async function forum_funCreateReportKomentar({
|
||||
komentarId: string;
|
||||
kategoriId: any;
|
||||
}) {
|
||||
const authorId = await user_funGetOneUserId();
|
||||
// console.log(kategoriId);
|
||||
|
||||
// const cekId = await prisma.forumMaster_KategoriReport.findFirst({
|
||||
// where: {
|
||||
// title: kategoriId,
|
||||
// },
|
||||
// });
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
try {
|
||||
const createReport = await prisma.forum_ReportKomentar.create({
|
||||
data: {
|
||||
userId: authorId,
|
||||
userId: userLoginId,
|
||||
forumMaster_KategoriReportId: kategoriId,
|
||||
forum_KomentarId: komentarId,
|
||||
},
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
|
||||
export async function forum_funCreateReportKomentarLainnya(
|
||||
komentarId: string,
|
||||
deskripsi: string
|
||||
) {
|
||||
const authorId = await user_funGetOneUserId();
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
const create = await prisma.forum_ReportKomentar.create({
|
||||
data: {
|
||||
forum_KomentarId: komentarId,
|
||||
deskripsi: deskripsi,
|
||||
userId: authorId,
|
||||
userId: userLoginId,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
|
||||
|
||||
export async function forum_funCreateReportPosting({
|
||||
postingId,
|
||||
@@ -11,11 +11,12 @@ export async function forum_funCreateReportPosting({
|
||||
postingId: string;
|
||||
kategoriId: number;
|
||||
}) {
|
||||
const authorId = await user_funGetOneUserId();
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
|
||||
const createReport = await prisma.forum_ReportPosting.create({
|
||||
data: {
|
||||
userId: authorId,
|
||||
userId: userLoginId,
|
||||
forum_PostingId: postingId,
|
||||
forumMaster_KategoriReportId: kategoriId,
|
||||
},
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
|
||||
|
||||
export async function forum_funCreateReportPostingLainnya(
|
||||
postingId: string,
|
||||
deskripsi: string
|
||||
) {
|
||||
const authorId = await user_funGetOneUserId();
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
const create = await prisma.forum_ReportPosting.create({
|
||||
data: {
|
||||
forum_PostingId: postingId,
|
||||
deskripsi: deskripsi,
|
||||
userId: authorId,
|
||||
userId: userLoginId,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import _ from "lodash";
|
||||
|
||||
export async function forum_getAllPostingByAuhtorId({
|
||||
authorId,
|
||||
|
||||
@@ -37,10 +37,6 @@ export default function Forum_Beranda({
|
||||
const [data, setData] = useState<MODEL_FORUM_POSTING[]>(listForum);
|
||||
const [activePage, setActivePage] = useState(1);
|
||||
const [isSearch, setIsSearch] = useState("");
|
||||
|
||||
const [loadingCreate, setLoadingCreate] = useState(false);
|
||||
|
||||
//
|
||||
const [isNewPost, setIsNewPost] = useState(false);
|
||||
const [countNewPost, setCountNewPost] = useState(0);
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ export async function user_funGetOneUserId(): Promise<string | null> {
|
||||
|
||||
return token.id;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1 @@
|
||||
import { user_funGetOneUserId } from "./get_user_token";
|
||||
|
||||
export { user_funGetOneUserId };
|
||||
// Export di sini
|
||||
@@ -1,7 +1,7 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
|
||||
interface Model_Invoice_Masuk {
|
||||
total: number;
|
||||
@@ -14,14 +14,14 @@ export async function investasi_funCreateInvoice({
|
||||
}: {
|
||||
data: Model_Invoice_Masuk;
|
||||
}) {
|
||||
const authorId = await user_funGetOneUserId();
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
const create = await prisma.investasi_Invoice.create({
|
||||
data: {
|
||||
nominal: "" + data.total,
|
||||
lembarTerbeli: "" + data.jumlah ,
|
||||
lembarTerbeli: "" + data.jumlah,
|
||||
masterBankId: data.pilihBank,
|
||||
authorId: authorId,
|
||||
authorId: userLoginId,
|
||||
investasiId: data.investasiId,
|
||||
statusInvoiceId: "3",
|
||||
},
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
|
||||
export async function investasi_funGetAllPublishByUserId({
|
||||
page,
|
||||
}: {
|
||||
page: number;
|
||||
}) {
|
||||
const authorId = await user_funGetOneUserId();
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
const takeData = 10;
|
||||
const skipData = page * takeData - takeData;
|
||||
|
||||
@@ -19,7 +20,7 @@ export async function investasi_funGetAllPublishByUserId({
|
||||
countDown: "desc",
|
||||
},
|
||||
where: {
|
||||
authorId: authorId,
|
||||
authorId: userLoginId,
|
||||
masterStatusInvestasiId: "1",
|
||||
},
|
||||
include: {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
|
||||
export async function investasi_funGetAllInvestasiNonPublishByUserId({
|
||||
page,
|
||||
@@ -10,7 +10,8 @@ export async function investasi_funGetAllInvestasiNonPublishByUserId({
|
||||
page: number;
|
||||
statusId: string;
|
||||
}) {
|
||||
const authorId = await user_funGetOneUserId();
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
const takeData = 10;
|
||||
const skipData = page * takeData - takeData;
|
||||
|
||||
@@ -21,7 +22,7 @@ export async function investasi_funGetAllInvestasiNonPublishByUserId({
|
||||
updatedAt: "desc",
|
||||
},
|
||||
where: {
|
||||
authorId: authorId,
|
||||
authorId: userLoginId,
|
||||
masterStatusInvestasiId: statusId,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
|
||||
export async function investasi_funGetTransaksiByUserId({
|
||||
page,
|
||||
}: {
|
||||
page: number;
|
||||
}) {
|
||||
const authorId = await user_funGetOneUserId();
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
const takeData = 10;
|
||||
const skipData = page * takeData - takeData;
|
||||
|
||||
@@ -19,7 +20,7 @@ export async function investasi_funGetTransaksiByUserId({
|
||||
updatedAt: "desc",
|
||||
},
|
||||
where: {
|
||||
authorId: authorId,
|
||||
authorId: userLoginId,
|
||||
},
|
||||
include: {
|
||||
Investasi: true,
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
|
||||
export async function investasi_funGetSuccessTransactionById({
|
||||
page,
|
||||
}: {
|
||||
page: number;
|
||||
}) {
|
||||
const authorId = await user_funGetOneUserId();
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
const takeData = 10;
|
||||
const skipData = page * takeData - takeData;
|
||||
|
||||
@@ -19,7 +20,7 @@ export async function investasi_funGetSuccessTransactionById({
|
||||
updatedAt: "desc",
|
||||
},
|
||||
where: {
|
||||
authorId: authorId,
|
||||
authorId: userLoginId,
|
||||
statusInvoiceId: "1",
|
||||
isActive: true,
|
||||
},
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import _ from "lodash";
|
||||
import { v4 } from "uuid";
|
||||
import fs from "fs";
|
||||
import { revalidatePath } from "next/cache";
|
||||
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";
|
||||
import funUploadProspektusInvestasi from "./fun_upload_prospek";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global";
|
||||
|
||||
export async function funCreateInvestasi(
|
||||
fileGambar: FormData,
|
||||
filePdf: FormData,
|
||||
data: MODEL_INVESTASI
|
||||
) {
|
||||
const authorId = await user_funGetOneUserId();
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
// Function upload gambar
|
||||
const gambar: any = fileGambar.get("file");
|
||||
const gambarName = gambar.name;
|
||||
@@ -44,7 +44,7 @@ export async function funCreateInvestasi(
|
||||
|
||||
const createInvest = await prisma.investasi.create({
|
||||
data: {
|
||||
authorId: authorId,
|
||||
authorId: userLoginId,
|
||||
title: _.startCase(data.title),
|
||||
targetDana: data.targetDana.toString(),
|
||||
hargaLembar: data.hargaLembar.toString(),
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
import { AccentColor } from "@/app_modules/_global/color";
|
||||
import { job_getAllListPublish } from "@/app_modules/job/fun/get/get_all_publish";
|
||||
import { Center, Button, Affix, rem } from "@mantine/core";
|
||||
import { useWindowScroll } from "@mantine/hooks";
|
||||
import { useState } from "react";
|
||||
|
||||
export function Job_ComponentButtonUpdateBeranda({
|
||||
onSetData,
|
||||
onSetIsNewPost,
|
||||
}: {
|
||||
onSetData: (val: any) => void;
|
||||
onSetIsNewPost: (val: any) => void;
|
||||
}) {
|
||||
const [scroll, scrollTo] = useWindowScroll();
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
|
||||
async function onLoadData() {
|
||||
const loadData = await job_getAllListPublish({ page: 1 });
|
||||
|
||||
if (loadData) {
|
||||
onSetData(loadData);
|
||||
onSetIsNewPost(false);
|
||||
setIsLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Affix position={{ top: rem(100) }} w={"100%"}>
|
||||
<Center>
|
||||
<Button
|
||||
style={{
|
||||
transition: "0.5s",
|
||||
border: `1px solid ${AccentColor.skyblue}`,
|
||||
}}
|
||||
bg={AccentColor.blue}
|
||||
loaderPosition="center"
|
||||
loading={isLoading ? true : false}
|
||||
radius={"xl"}
|
||||
opacity={scroll.y > 0 ? 0.5 : 0.8}
|
||||
onClick={() => onLoadData()}
|
||||
>
|
||||
Update beranda
|
||||
</Button>
|
||||
</Center>
|
||||
</Affix>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -15,7 +15,7 @@ import { MODEL_JOB } from "../../model/interface";
|
||||
import { funGlobal_UploadToStorage } from "@/app_modules/_global/fun";
|
||||
import { DIRECTORY_ID } from "@/app/lib";
|
||||
|
||||
export function Job_ComponentButtonUpdate({
|
||||
export function Job_ComponentButtonUpdateData({
|
||||
value,
|
||||
file,
|
||||
}: {
|
||||
@@ -48,6 +48,7 @@ export function Job_ComponentButtonUpdate({
|
||||
|
||||
const updateWithFile = await job_EditById({
|
||||
data: value,
|
||||
fileId: uploadFile.data.id,
|
||||
});
|
||||
if (updateWithFile.status !== 200)
|
||||
return ComponentGlobal_NotifikasiGagal(updateWithFile.message);
|
||||
@@ -1,66 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { RouterJob } from "@/app/lib/router_hipmi/router_job";
|
||||
import { AccentColor } from "@/app_modules/_global/color/color_pallet";
|
||||
import { Affix, rem, ActionIcon, Loader, Box } from "@mantine/core";
|
||||
import { IconPencilPlus } from "@tabler/icons-react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
|
||||
export default function ComponentJob_CreateButton() {
|
||||
const router = useRouter();
|
||||
const [isLoading, setLoading] = useState(false);
|
||||
|
||||
return (
|
||||
<>
|
||||
<ActionIcon
|
||||
variant="transparent"
|
||||
radius={"xl"}
|
||||
size={"xl"}
|
||||
style={{
|
||||
position: "absolute",
|
||||
zIndex: 1,
|
||||
bottom: 100,
|
||||
right: 30,
|
||||
transition: "0.5s",
|
||||
border: `1px solid ${AccentColor.skyblue}`,
|
||||
backgroundColor: AccentColor.blue,
|
||||
padding: 3,
|
||||
}}
|
||||
onClick={() => {
|
||||
setLoading(true);
|
||||
router.push(RouterJob.create);
|
||||
}}
|
||||
>
|
||||
{isLoading ? (
|
||||
<Loader color={AccentColor.yellow} size={25} />
|
||||
) : (
|
||||
<IconPencilPlus color="white" />
|
||||
)}
|
||||
</ActionIcon>
|
||||
|
||||
{/* <Affix withinPortal position={{ bottom: 150, right: 30 }}>
|
||||
<ActionIcon
|
||||
style={{
|
||||
transition: "0.5s",
|
||||
border: `1px solid ${AccentColor.skyblue}`,
|
||||
}}
|
||||
bg={AccentColor.blue}
|
||||
size={"xl"}
|
||||
radius={"xl"}
|
||||
variant="transparent"
|
||||
onClick={() => {
|
||||
setLoading(true);
|
||||
router.push(RouterJob.create);
|
||||
}}
|
||||
>
|
||||
{isLoading ? (
|
||||
<Loader color={AccentColor.yellow} size={25} />
|
||||
) : (
|
||||
<IconPencilPlus color="white" />
|
||||
)}
|
||||
</ActionIcon>
|
||||
</Affix> */}
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
import Job_ComponentButtonSaveCreate from "./button/comp_button_save_create";
|
||||
import { Job_ComponentButtonUpdate } from "./button/comp_button_update";
|
||||
import { Job_ComponentButtonUpdateBeranda } from "./button/comp_button_update_beranda";
|
||||
import { Job_ComponentButtonUpdateData } from "./button/comp_button_update_data";
|
||||
import { Job_ComponentBoxUploadImage } from "./detail/comp_box_upload_image";
|
||||
|
||||
export { Job_ComponentButtonSaveCreate };
|
||||
export { Job_ComponentBoxUploadImage };
|
||||
export { Job_ComponentButtonUpdate };
|
||||
export { Job_ComponentButtonUpdateData as Job_ComponentButtonUpdate };
|
||||
export { Job_ComponentButtonUpdateBeranda };
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
import {
|
||||
AspectRatio,
|
||||
Box,
|
||||
Button,
|
||||
Center,
|
||||
FileButton,
|
||||
@@ -29,13 +28,11 @@ import {
|
||||
|
||||
import {
|
||||
ComponentGlobal_BoxInformation,
|
||||
ComponentGlobal_BoxUploadImage,
|
||||
ComponentGlobal_CardStyles,
|
||||
ComponentGlobal_InputCountDown,
|
||||
} from "@/app_modules/_global/component";
|
||||
import {
|
||||
Job_ComponentBoxUploadImage,
|
||||
Job_ComponentButtonSaveCreate,
|
||||
} from "../component";
|
||||
import { Job_ComponentButtonSaveCreate } from "../component";
|
||||
import { defaultDeskripsi, defaultSyarat } from "../component/default_value";
|
||||
|
||||
export default function Job_Create() {
|
||||
@@ -57,7 +54,7 @@ export default function Job_Create() {
|
||||
<ComponentGlobal_BoxInformation informasi="Poster atau gambar lowongan kerja bersifat opsional, tidak wajib untuk dimasukkan dan upload lah gambar yang sesuai dengan deskripsi lowongan kerja. " />
|
||||
|
||||
<Stack spacing={"xs"}>
|
||||
<Job_ComponentBoxUploadImage>
|
||||
<ComponentGlobal_BoxUploadImage>
|
||||
{img ? (
|
||||
<AspectRatio ratio={1 / 1} mah={265} mx={"auto"}>
|
||||
<Image
|
||||
@@ -75,7 +72,7 @@ export default function Job_Create() {
|
||||
</Text>
|
||||
</Stack>
|
||||
)}
|
||||
</Job_ComponentBoxUploadImage>
|
||||
</ComponentGlobal_BoxUploadImage>
|
||||
|
||||
<Center>
|
||||
<FileButton
|
||||
|
||||
@@ -1,53 +1,35 @@
|
||||
"use client";
|
||||
|
||||
import { RouterJob } from "@/app/lib/router_hipmi/router_job";
|
||||
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
|
||||
import {
|
||||
AspectRatio,
|
||||
Button,
|
||||
Center,
|
||||
FileButton,
|
||||
Group,
|
||||
Image,
|
||||
Loader,
|
||||
Modal,
|
||||
Paper,
|
||||
Stack,
|
||||
Text,
|
||||
TextInput,
|
||||
Title,
|
||||
TextInput
|
||||
} from "@mantine/core";
|
||||
import {
|
||||
useDisclosure,
|
||||
useShallowEffect,
|
||||
useWindowScroll,
|
||||
} from "@mantine/hooks";
|
||||
import { IconCamera, IconUpload } from "@tabler/icons-react";
|
||||
import { useAtom } from "jotai";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { gs_job_hot_menu, gs_job_status } from "../global_state";
|
||||
import { MODEL_JOB } from "../model/interface";
|
||||
|
||||
import { APIs } from "@/app/lib";
|
||||
import {
|
||||
AccentColor,
|
||||
MainColor,
|
||||
} from "@/app_modules/_global/color/color_pallet";
|
||||
import { ComponentGlobal_BoxUploadImage, ComponentGlobal_CardStyles } from "@/app_modules/_global/component";
|
||||
import ComponentGlobal_InputCountDown from "@/app_modules/_global/component/input_countdown";
|
||||
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
|
||||
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global/notifikasi_peringatan";
|
||||
import dynamic from "next/dynamic";
|
||||
import { job_EditById } from "../fun/edit/fun_edit_by_id";
|
||||
import "react-quill/dist/quill.snow.css";
|
||||
import { Job_ComponentBoxUploadImage, Job_ComponentButtonUpdate } from "../component";
|
||||
const ReactQuill = dynamic(
|
||||
() => {
|
||||
return import("react-quill");
|
||||
},
|
||||
{ ssr: false }
|
||||
);
|
||||
import "react-quill/dist/quill.snow.css";
|
||||
import { Job_ComponentBoxUploadImage, Job_ComponentButtonUpdate } from "../component";
|
||||
import { APIs } from "@/app/lib";
|
||||
import { ComponentGlobal_CardStyles } from "@/app_modules/_global/component";
|
||||
|
||||
export default function Job_Edit({ dataJob }: { dataJob: MODEL_JOB }) {
|
||||
const [value, setValue] = useState(dataJob);
|
||||
@@ -63,7 +45,7 @@ export default function Job_Edit({ dataJob }: { dataJob: MODEL_JOB }) {
|
||||
<>
|
||||
<Stack>
|
||||
<Stack spacing={"xs"}>
|
||||
<Job_ComponentBoxUploadImage>
|
||||
<ComponentGlobal_BoxUploadImage>
|
||||
{value.imageId ? (
|
||||
<AspectRatio ratio={1 / 1} mah={265} mx={"auto"}>
|
||||
<Image
|
||||
@@ -81,7 +63,7 @@ export default function Job_Edit({ dataJob }: { dataJob: MODEL_JOB }) {
|
||||
</Text>
|
||||
</Stack>
|
||||
)}
|
||||
</Job_ComponentBoxUploadImage>
|
||||
</ComponentGlobal_BoxUploadImage>
|
||||
|
||||
<Center>
|
||||
<FileButton
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
"use server";
|
||||
|
||||
import { prisma } from "@/app/lib";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { MODEL_JOB } from "../../model/interface";
|
||||
|
||||
export async function job_funCreateNoFile({ data }: { data: MODEL_JOB }) {
|
||||
const authorId = await user_funGetOneUserId();
|
||||
const authorId = await funGetUserIdByToken();
|
||||
|
||||
const createNoImage = await prisma.job.create({
|
||||
data: {
|
||||
|
||||
@@ -1,15 +1,9 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import _ from "lodash";
|
||||
import { v4 } from "uuid";
|
||||
import fs from "fs";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { MODEL_JOB } from "../../model/interface";
|
||||
import path from "path";
|
||||
import { funGlobal_UploadToStorage } from "@/app_modules/_global/fun";
|
||||
import { DIRECTORY_ID } from "@/app/lib";
|
||||
|
||||
export async function job_funCreateWithFile({
|
||||
data,
|
||||
@@ -18,15 +12,14 @@ export async function job_funCreateWithFile({
|
||||
data: MODEL_JOB;
|
||||
fileId: string;
|
||||
}) {
|
||||
const authorId = await user_funGetOneUserId();
|
||||
console.log(authorId);
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
const createDataWithoutImg = await prisma.job.create({
|
||||
data: {
|
||||
title: data.title,
|
||||
content: data.content,
|
||||
deskripsi: data.deskripsi,
|
||||
authorId: authorId,
|
||||
authorId: userLoginId,
|
||||
imageId: fileId,
|
||||
},
|
||||
select: {
|
||||
|
||||
@@ -1,21 +1,18 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import _ from "lodash";
|
||||
import { v4 } from "uuid";
|
||||
import fs from "fs";
|
||||
import { MODEL_JOB } from "../../model/interface";
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { RouterJob } from "@/app/lib/router_hipmi/router_job";
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { MODEL_JOB } from "../../model/interface";
|
||||
|
||||
export async function job_EditById({
|
||||
data,
|
||||
imageId,
|
||||
fileId,
|
||||
}: {
|
||||
data: MODEL_JOB;
|
||||
imageId?: string;
|
||||
fileId?: string;
|
||||
}) {
|
||||
if (imageId == undefined) {
|
||||
if (fileId == undefined) {
|
||||
const updt = await prisma.job.update({
|
||||
where: {
|
||||
id: data.id,
|
||||
@@ -28,7 +25,7 @@ export async function job_EditById({
|
||||
});
|
||||
if (!updt) return { status: 400, message: "Gagal Update" };
|
||||
revalidatePath(RouterJob.status);
|
||||
|
||||
|
||||
return {
|
||||
status: 200,
|
||||
message: "Berhasil Update",
|
||||
@@ -42,7 +39,7 @@ export async function job_EditById({
|
||||
title: data.title,
|
||||
content: data.content,
|
||||
deskripsi: data.deskripsi,
|
||||
imageId: imageId,
|
||||
imageId: fileId,
|
||||
},
|
||||
});
|
||||
if (!updtWithFile) return { status: 400, message: "Gagal Update" };
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
|
||||
export async function job_getAllArsipById({page}: {page: number}) {
|
||||
|
||||
const authorId = await user_funGetOneUserId();
|
||||
export async function job_getAllArsipById({ page }: { page: number }) {
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
const takeData = 10;
|
||||
const skipData = page * takeData - takeData;
|
||||
@@ -17,7 +16,7 @@ export async function job_getAllArsipById({page}: {page: number}) {
|
||||
updatedAt: "desc",
|
||||
},
|
||||
where: {
|
||||
authorId: authorId,
|
||||
authorId: userLoginId,
|
||||
isArsip: true,
|
||||
isActive: true,
|
||||
},
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
|
||||
export async function job_getAllListPublish({
|
||||
page,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
|
||||
export default async function job_getAllStatusDraft({
|
||||
page,
|
||||
@@ -11,7 +11,8 @@ export default async function job_getAllStatusDraft({
|
||||
const takeData = 10;
|
||||
const skipData = page * takeData - takeData;
|
||||
|
||||
const authorId = await user_funGetOneUserId();
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
const data = await prisma.job.findMany({
|
||||
take: takeData,
|
||||
skip: skipData,
|
||||
@@ -20,7 +21,7 @@ export default async function job_getAllStatusDraft({
|
||||
},
|
||||
where: {
|
||||
masterStatusId: "3",
|
||||
authorId: authorId,
|
||||
authorId: userLoginId,
|
||||
isActive: true,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
|
||||
export default async function job_getAllStatusPublish({
|
||||
page,
|
||||
@@ -11,7 +11,8 @@ export default async function job_getAllStatusPublish({
|
||||
const takeData = 10;
|
||||
const skipData = page * takeData - takeData;
|
||||
|
||||
const authorId = await user_funGetOneUserId();
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
const data = await prisma.job.findMany({
|
||||
take: takeData,
|
||||
skip: skipData,
|
||||
@@ -20,7 +21,7 @@ export default async function job_getAllStatusPublish({
|
||||
},
|
||||
where: {
|
||||
masterStatusId: "1",
|
||||
authorId: authorId,
|
||||
authorId: userLoginId,
|
||||
isActive: true,
|
||||
isArsip: false,
|
||||
},
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
|
||||
export default async function job_getAllStatusReject({
|
||||
page,
|
||||
}: {
|
||||
page: number;
|
||||
}) {
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
const takeData = 10;
|
||||
const skipData = page * takeData - takeData;
|
||||
|
||||
const authorId = await user_funGetOneUserId();
|
||||
const data = await prisma.job.findMany({
|
||||
take: takeData,
|
||||
skip: skipData,
|
||||
@@ -20,7 +20,7 @@ export default async function job_getAllStatusReject({
|
||||
},
|
||||
where: {
|
||||
masterStatusId: "4",
|
||||
authorId: authorId,
|
||||
authorId: userLoginId,
|
||||
isActive: true,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
|
||||
export default async function job_getAllStatusReview({
|
||||
page,
|
||||
}: {
|
||||
page: number;
|
||||
}) {
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
const takeData = 10;
|
||||
const skipData = page * takeData - takeData;
|
||||
|
||||
const authorId = await user_funGetOneUserId();
|
||||
const data = await prisma.job.findMany({
|
||||
take: takeData,
|
||||
skip: skipData,
|
||||
@@ -20,7 +20,7 @@ export default async function job_getAllStatusReview({
|
||||
},
|
||||
where: {
|
||||
masterStatusId: "2",
|
||||
authorId: authorId,
|
||||
authorId: userLoginId,
|
||||
isActive: true,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -3,7 +3,15 @@
|
||||
import { RouterJob } from "@/app/lib/router_hipmi/router_job";
|
||||
import ComponentGlobal_CreateButton from "@/app_modules/_global/component/button_create";
|
||||
import ComponentGlobal_IsEmptyData from "@/app_modules/_global/component/is_empty_data";
|
||||
import { Center, Loader, Stack, TextInput } from "@mantine/core";
|
||||
import {
|
||||
Affix,
|
||||
Button,
|
||||
Center,
|
||||
Loader,
|
||||
rem,
|
||||
Stack,
|
||||
TextInput,
|
||||
} from "@mantine/core";
|
||||
import { IconSearch } from "@tabler/icons-react";
|
||||
import _ from "lodash";
|
||||
import { ScrollOnly } from "next-scroll-loader";
|
||||
@@ -11,11 +19,15 @@ import { useState } from "react";
|
||||
import ComponentJob_BerandaCardView from "../../component/beranda/card_view";
|
||||
import { job_getAllListPublish } from "../../fun/get/get_all_publish";
|
||||
import { MODEL_JOB } from "../../model/interface";
|
||||
import { useShallowEffect } from "@mantine/hooks";
|
||||
import mqtt_client from "@/util/mqtt_client";
|
||||
import { Job_ComponentButtonUpdateBeranda } from "../../component";
|
||||
|
||||
export function Job_UiBeranda({ listData }: { listData: MODEL_JOB[] }) {
|
||||
const [data, setData] = useState(listData);
|
||||
const [activePage, setActivePage] = useState(1);
|
||||
const [isSearch, setIsSearch] = useState("");
|
||||
const [isNewPost, setIsNewPost] = useState(false);
|
||||
|
||||
async function onSearch(text: string) {
|
||||
setIsSearch(text);
|
||||
@@ -27,21 +39,45 @@ export function Job_UiBeranda({ listData }: { listData: MODEL_JOB[] }) {
|
||||
setActivePage(1);
|
||||
}
|
||||
|
||||
useShallowEffect(() => {
|
||||
onLoadNewData({
|
||||
onLoad(val) {
|
||||
setData(val);
|
||||
},
|
||||
});
|
||||
|
||||
mqtt_client.subscribe("Job_new_post");
|
||||
mqtt_client.on("message", (topic, message) => {
|
||||
if (topic === "Job_new_post") {
|
||||
setIsNewPost(true);
|
||||
}
|
||||
});
|
||||
}, [setIsNewPost, setData]);
|
||||
|
||||
async function onLoadNewData({ onLoad }: { onLoad: (val: any) => void }) {
|
||||
const loadData = await job_getAllListPublish({ page: 1 });
|
||||
onLoad(loadData);
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Stack my={1} spacing={30}>
|
||||
{/* <ComponentJob_CreateButton /> */}
|
||||
<ComponentGlobal_CreateButton path={RouterJob.create}/>
|
||||
{isNewPost && (
|
||||
<Job_ComponentButtonUpdateBeranda
|
||||
onSetIsNewPost={(val) => setIsNewPost(val)}
|
||||
onSetData={(val) => setData(val)}
|
||||
/>
|
||||
)}
|
||||
<ComponentGlobal_CreateButton path={RouterJob.create} />
|
||||
|
||||
<TextInput
|
||||
|
||||
style={{
|
||||
position: "sticky",
|
||||
top: 0,
|
||||
zIndex: 99,
|
||||
}}
|
||||
radius={"xl"}
|
||||
icon={<IconSearch/>}
|
||||
icon={<IconSearch />}
|
||||
placeholder="Pekerjaan apa yang anda cari ?"
|
||||
onChange={(val) => {
|
||||
onSearch(val.currentTarget.value);
|
||||
|
||||
0
src/app_modules/katalog/component/index.ts
Normal file
0
src/app_modules/katalog/component/index.ts
Normal file
@@ -0,0 +1,83 @@
|
||||
import { RouterMap } from "@/app/lib/router_hipmi/router_map";
|
||||
import { MainColor } from "@/app_modules/_global/color";
|
||||
import {
|
||||
ComponentGlobal_NotifikasiGagal,
|
||||
ComponentGlobal_NotifikasiPeringatan,
|
||||
} from "@/app_modules/_global/notif_global";
|
||||
import { MODEL_PORTOFOLIO_OLD } from "@/app_modules/model_global/portofolio";
|
||||
import { Button } from "@mantine/core";
|
||||
import _ from "lodash";
|
||||
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import funCreatePortofolio from "../../fun/fun_create_portofolio";
|
||||
|
||||
export function Portofolio_ComponentButtonSelanjutnya({
|
||||
profileId,
|
||||
dataPorto,
|
||||
file,
|
||||
dataMedsos,
|
||||
setIsFile,
|
||||
}: {
|
||||
profileId: string;
|
||||
dataPorto: MODEL_PORTOFOLIO_OLD;
|
||||
file: FormData;
|
||||
dataMedsos: any;
|
||||
setIsFile: any;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
async function onSubmit() {
|
||||
const porto = {
|
||||
namaBisnis: dataPorto.namaBisnis,
|
||||
masterBidangBisnisId: dataPorto.masterBidangBisnisId,
|
||||
alamatKantor: dataPorto.alamatKantor,
|
||||
tlpn: dataPorto.tlpn,
|
||||
deskripsi: dataPorto.deskripsi,
|
||||
};
|
||||
|
||||
if (_.values(porto).includes(""))
|
||||
return ComponentGlobal_NotifikasiPeringatan("Lengkapi Data");
|
||||
if (file === null) {
|
||||
setIsFile(true);
|
||||
return null;
|
||||
}
|
||||
|
||||
const gambar = new FormData();
|
||||
gambar.append("file", file as any);
|
||||
|
||||
const res = await funCreatePortofolio(
|
||||
profileId,
|
||||
porto as any,
|
||||
gambar,
|
||||
dataMedsos
|
||||
);
|
||||
if (res.status === 201) {
|
||||
setLoading(true);
|
||||
// ComponentGlobal_NotifikasiBerhasil("Berhasil disimpan");
|
||||
router.replace(RouterMap.create + res.id, { scroll: false });
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal("Gagal disimpan");
|
||||
}
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<Button
|
||||
disabled={_.values(dataPorto).includes("") || file === null}
|
||||
mt={"md"}
|
||||
radius={50}
|
||||
loading={loading ? true : false}
|
||||
loaderPosition="center"
|
||||
onClick={() => {
|
||||
onSubmit();
|
||||
}}
|
||||
bg={MainColor.yellow}
|
||||
color="yellow"
|
||||
c={"black"}
|
||||
>
|
||||
Selanjutnya
|
||||
</Button>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1 +1,4 @@
|
||||
import { Portofolio_ComponentButtonSelanjutnya } from "./button/comp_button_selanjutnya";
|
||||
|
||||
export { ComponentPortofolio_DetailDataMap } from "./detail_data_drawer_map";
|
||||
export { Portofolio_ComponentButtonSelanjutnya };
|
||||
|
||||
@@ -34,6 +34,8 @@ import { AppRouterInstance } from "next/dist/shared/lib/app-router-context.share
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import funCreatePortofolio from "../fun/fun_create_portofolio";
|
||||
import { Portofolio_ComponentButtonSelanjutnya } from "../component";
|
||||
import { ComponentGlobal_BoxUploadImage } from "@/app_modules/_global/component";
|
||||
|
||||
export default function CreatePortofolio({
|
||||
bidangBisnis,
|
||||
@@ -42,9 +44,7 @@ export default function CreatePortofolio({
|
||||
bidangBisnis: BIDANG_BISNIS_OLD;
|
||||
profileId: any;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [value, setValue] = useState({
|
||||
const [dataPortofolio, setDataPortofolio] = useState({
|
||||
namaBisnis: "",
|
||||
masterBidangBisnisId: "",
|
||||
alamatKantor: "",
|
||||
@@ -52,7 +52,7 @@ export default function CreatePortofolio({
|
||||
deskripsi: "",
|
||||
});
|
||||
|
||||
const [medsos, setMedsos] = useState({
|
||||
const [dataMedsos, setDataMedsos] = useState({
|
||||
facebook: "",
|
||||
twitter: "",
|
||||
instagram: "",
|
||||
@@ -82,8 +82,8 @@ export default function CreatePortofolio({
|
||||
placeholder="Nama bisnis"
|
||||
maxLength={100}
|
||||
onChange={(val) => {
|
||||
setValue({
|
||||
...value,
|
||||
setDataPortofolio({
|
||||
...dataPortofolio,
|
||||
namaBisnis: _.startCase(val.target.value),
|
||||
});
|
||||
}}
|
||||
@@ -102,8 +102,8 @@ export default function CreatePortofolio({
|
||||
label: e.name,
|
||||
}))}
|
||||
onChange={(val) => {
|
||||
setValue({
|
||||
...value,
|
||||
setDataPortofolio({
|
||||
...dataPortofolio,
|
||||
masterBidangBisnisId: val as any,
|
||||
});
|
||||
}}
|
||||
@@ -119,8 +119,8 @@ export default function CreatePortofolio({
|
||||
placeholder="Alamat bisnis"
|
||||
maxLength={100}
|
||||
onChange={(val) => {
|
||||
setValue({
|
||||
...value,
|
||||
setDataPortofolio({
|
||||
...dataPortofolio,
|
||||
alamatKantor: val.target.value,
|
||||
});
|
||||
}}
|
||||
@@ -136,8 +136,8 @@ export default function CreatePortofolio({
|
||||
placeholder="Nomor telepon "
|
||||
type="number"
|
||||
onChange={(val) => {
|
||||
setValue({
|
||||
...value,
|
||||
setDataPortofolio({
|
||||
...dataPortofolio,
|
||||
tlpn: val.target.value,
|
||||
});
|
||||
}}
|
||||
@@ -157,15 +157,15 @@ export default function CreatePortofolio({
|
||||
label="Deskripsi"
|
||||
placeholder="Deskripsi singkat mengenai usaha"
|
||||
onChange={(val) => {
|
||||
setValue({
|
||||
...value,
|
||||
setDataPortofolio({
|
||||
...dataPortofolio,
|
||||
deskripsi: val.target.value,
|
||||
});
|
||||
}}
|
||||
/>
|
||||
<ComponentGlobal_InputCountDown
|
||||
maxInput={300}
|
||||
lengthInput={value.deskripsi.length}
|
||||
lengthInput={dataPortofolio.deskripsi.length}
|
||||
/>
|
||||
</Stack>
|
||||
</Stack>
|
||||
@@ -182,52 +182,25 @@ export default function CreatePortofolio({
|
||||
|
||||
{isFile ? <ComponentGlobal_ErrorInput text="Upload gambar" /> : ""} */}
|
||||
|
||||
{img ? (
|
||||
<AspectRatio ratio={1 / 1} mah={300}>
|
||||
<Paper
|
||||
style={{
|
||||
border: `2px solid ${AccentColor.blue}`,
|
||||
backgroundColor: AccentColor.darkblue,
|
||||
padding: "10px",
|
||||
borderRadius: "10px",
|
||||
}}
|
||||
>
|
||||
<ComponentGlobal_BoxUploadImage>
|
||||
{img ? (
|
||||
<AspectRatio ratio={1 / 1} mah={265} mx={"auto"}>
|
||||
<Image
|
||||
radius={"sm"}
|
||||
style={{ maxHeight: 250, margin: "auto", padding: "5px" }}
|
||||
alt="Foto"
|
||||
src={img ? img : "/aset/no-img.png"}
|
||||
maw={200}
|
||||
height={250}
|
||||
src={img}
|
||||
/>
|
||||
</Paper>
|
||||
</AspectRatio>
|
||||
) : (
|
||||
<AspectRatio ratio={1 / 1} mah={300}>
|
||||
<Paper
|
||||
style={{
|
||||
border: `2px solid ${AccentColor.blue}`,
|
||||
backgroundColor: AccentColor.darkblue,
|
||||
padding: "10px",
|
||||
borderRadius: "10px",
|
||||
}}
|
||||
>
|
||||
<Box
|
||||
h={250}
|
||||
w={200}
|
||||
style={{
|
||||
color: "white",
|
||||
}}
|
||||
>
|
||||
<Stack spacing={5} justify="center" align="center" h={"100%"}>
|
||||
<Title order={3}>Upload Logo Bisnis</Title>
|
||||
<Text fs={"italic"} fz={10} align="center">
|
||||
Masukan logo bisnis anda untuk ditampilkan dalam
|
||||
portofolio
|
||||
</Text>
|
||||
</Stack>
|
||||
</Box>
|
||||
</Paper>
|
||||
</AspectRatio>
|
||||
)}
|
||||
</AspectRatio>
|
||||
) : (
|
||||
<Stack spacing={5} justify="center" align="center" h={"100%"}>
|
||||
<Title order={3}>Upload Logo Bisnis</Title>
|
||||
<Text fs={"italic"} fz={10} align="center">
|
||||
Masukan logo bisnis anda untuk ditampilkan dalam portofolio
|
||||
</Text>
|
||||
</Stack>
|
||||
)}
|
||||
</ComponentGlobal_BoxUploadImage>
|
||||
|
||||
<Center>
|
||||
<FileButton
|
||||
@@ -280,8 +253,8 @@ export default function CreatePortofolio({
|
||||
maxLength={100}
|
||||
placeholder="Facebook"
|
||||
onChange={(val) => {
|
||||
setMedsos({
|
||||
...medsos,
|
||||
setDataMedsos({
|
||||
...dataMedsos,
|
||||
facebook: val.target.value,
|
||||
});
|
||||
}}
|
||||
@@ -296,8 +269,8 @@ export default function CreatePortofolio({
|
||||
maxLength={100}
|
||||
placeholder="Instagram"
|
||||
onChange={(val) => {
|
||||
setMedsos({
|
||||
...medsos,
|
||||
setDataMedsos({
|
||||
...dataMedsos,
|
||||
instagram: val.target.value,
|
||||
});
|
||||
}}
|
||||
@@ -312,8 +285,8 @@ export default function CreatePortofolio({
|
||||
maxLength={100}
|
||||
placeholder="Tiktok"
|
||||
onChange={(val) => {
|
||||
setMedsos({
|
||||
...medsos,
|
||||
setDataMedsos({
|
||||
...dataMedsos,
|
||||
tiktok: val.target.value,
|
||||
});
|
||||
}}
|
||||
@@ -328,8 +301,8 @@ export default function CreatePortofolio({
|
||||
maxLength={100}
|
||||
placeholder="Twitter"
|
||||
onChange={(val) => {
|
||||
setMedsos({
|
||||
...medsos,
|
||||
setDataMedsos({
|
||||
...dataMedsos,
|
||||
twitter: val.target.value,
|
||||
});
|
||||
}}
|
||||
@@ -344,82 +317,24 @@ export default function CreatePortofolio({
|
||||
maxLength={100}
|
||||
placeholder="Youtube"
|
||||
onChange={(val) => {
|
||||
setMedsos({
|
||||
...medsos,
|
||||
setDataMedsos({
|
||||
...dataMedsos,
|
||||
youtube: val.target.value,
|
||||
});
|
||||
}}
|
||||
/>
|
||||
</Stack>
|
||||
|
||||
<Button
|
||||
disabled={_.values(value).includes("") || file === null}
|
||||
mt={"md"}
|
||||
radius={50}
|
||||
loading={loading ? true : false}
|
||||
loaderPosition="center"
|
||||
onClick={() => {
|
||||
onSubmit(
|
||||
router,
|
||||
profileId,
|
||||
value as any,
|
||||
file,
|
||||
medsos,
|
||||
setLoading,
|
||||
setIsFile
|
||||
);
|
||||
}}
|
||||
bg={MainColor.yellow}
|
||||
color="yellow"
|
||||
c={"black"}
|
||||
>
|
||||
Selanjutnya
|
||||
</Button>
|
||||
<Portofolio_ComponentButtonSelanjutnya
|
||||
dataPorto={dataPortofolio as any}
|
||||
dataMedsos={dataMedsos}
|
||||
file={file}
|
||||
profileId={profileId}
|
||||
setIsFile={setIsFile}
|
||||
/>
|
||||
</Stack>
|
||||
|
||||
{/* <pre> {JSON.stringify(bidangBisnis, null, 2)}</pre> */}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
async function onSubmit(
|
||||
router: AppRouterInstance,
|
||||
profileId: string,
|
||||
dataPorto: MODEL_PORTOFOLIO_OLD,
|
||||
file: FormData,
|
||||
dataMedsos: any,
|
||||
setLoading: any,
|
||||
setIsFile: any
|
||||
) {
|
||||
const porto = {
|
||||
namaBisnis: dataPorto.namaBisnis,
|
||||
masterBidangBisnisId: dataPorto.masterBidangBisnisId,
|
||||
alamatKantor: dataPorto.alamatKantor,
|
||||
tlpn: dataPorto.tlpn,
|
||||
deskripsi: dataPorto.deskripsi,
|
||||
};
|
||||
|
||||
if (_.values(porto).includes(""))
|
||||
return ComponentGlobal_NotifikasiPeringatan("Lengkapi Data");
|
||||
if (file === null) {
|
||||
setIsFile(true);
|
||||
return null;
|
||||
}
|
||||
|
||||
const gambar = new FormData();
|
||||
gambar.append("file", file as any);
|
||||
|
||||
const res = await funCreatePortofolio(
|
||||
profileId,
|
||||
porto as any,
|
||||
gambar,
|
||||
dataMedsos
|
||||
);
|
||||
if (res.status === 201) {
|
||||
setLoading(true);
|
||||
// ComponentGlobal_NotifikasiBerhasil("Berhasil disimpan");
|
||||
router.replace(RouterMap.create + res.id , {scroll: false});
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal("Gagal disimpan");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
"use client"
|
||||
|
||||
import { RouterHome } from "@/app/lib/router_hipmi/router_home";
|
||||
import { MainColor, AccentColor } from "@/app_modules/_global/color";
|
||||
import { ComponentGlobal_NotifikasiPeringatan, ComponentGlobal_NotifikasiBerhasil, ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global";
|
||||
import { validRegex } from "@/app_modules/katalog/component/regular_expressions";
|
||||
import { Button } from "@mantine/core";
|
||||
import _ from "lodash";
|
||||
|
||||
import { useState } from "react";
|
||||
import funCreateNewProfile from "../../fun/fun_create_profile";
|
||||
import { MODEL_PROFILE } from "../../model/interface";
|
||||
import { useRouter } from "next/navigation";
|
||||
|
||||
export function Profile_ComponentCreateNewProfile({
|
||||
value,
|
||||
userLoginId,
|
||||
filePP,
|
||||
fileBg,
|
||||
}: {
|
||||
value: MODEL_PROFILE;
|
||||
userLoginId: string;
|
||||
filePP: FormData;
|
||||
fileBg: FormData;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
async function onSubmit() {
|
||||
const body = {
|
||||
userId: userLoginId,
|
||||
name: value.name,
|
||||
email: value.email,
|
||||
alamat: value.alamat,
|
||||
jenisKelamin: value.jenisKelamin,
|
||||
};
|
||||
if (_.values(body).includes(""))
|
||||
return ComponentGlobal_NotifikasiPeringatan("Lengkapi Data");
|
||||
if (!body.email.match(validRegex)) return null;
|
||||
|
||||
const gambarPP = new FormData();
|
||||
gambarPP.append("filePP", filePP as any);
|
||||
|
||||
const gambarBG = new FormData();
|
||||
gambarBG.append("fileBG", fileBg as any);
|
||||
|
||||
if (!gambarPP)
|
||||
return ComponentGlobal_NotifikasiPeringatan("Lengkapi foto profile");
|
||||
if (!gambarBG)
|
||||
return ComponentGlobal_NotifikasiPeringatan(
|
||||
"Lengkapi background profile"
|
||||
);
|
||||
|
||||
await funCreateNewProfile(body as any, gambarPP, gambarBG).then((res) => {
|
||||
if (res.status === 201) {
|
||||
setLoading(true);
|
||||
ComponentGlobal_NotifikasiBerhasil("Berhasil Membuat Profile", 3000);
|
||||
router.push(RouterHome.main_home);
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Button
|
||||
loading={loading ? true : false}
|
||||
loaderPosition="center"
|
||||
mt={"md"}
|
||||
radius={50}
|
||||
bg={MainColor.yellow}
|
||||
color="yellow"
|
||||
onClick={() => {
|
||||
onSubmit();
|
||||
}}
|
||||
style={{
|
||||
border: `2px solid ${AccentColor.yellow}`,
|
||||
color: "black",
|
||||
}}
|
||||
>
|
||||
Simpan
|
||||
</Button>
|
||||
</>
|
||||
);
|
||||
}
|
||||
3
src/app_modules/katalog/profile/_component/index.ts
Normal file
3
src/app_modules/katalog/profile/_component/index.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import { Profile_ComponentCreateNewProfile } from "./button/comp_create_new_profile";
|
||||
|
||||
export {Profile_ComponentCreateNewProfile}
|
||||
@@ -1,14 +1,11 @@
|
||||
"use client";
|
||||
|
||||
import { RouterHome } from "@/app/lib/router_hipmi/router_home";
|
||||
import ComponentGlobal_BoxInformation from "@/app_modules/_global/component/box_information";
|
||||
import {
|
||||
AccentColor,
|
||||
MainColor,
|
||||
} from "@/app_modules/_global/color/color_pallet";
|
||||
import ComponentGlobal_BoxInformation from "@/app_modules/_global/component/box_information";
|
||||
import ComponentGlobal_ErrorInput from "@/app_modules/_global/component/error_input";
|
||||
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
|
||||
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
|
||||
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global/notifikasi_peringatan";
|
||||
import {
|
||||
AspectRatio,
|
||||
@@ -25,14 +22,16 @@ import {
|
||||
TextInput,
|
||||
} from "@mantine/core";
|
||||
import { IconAt, IconCamera, IconUpload } from "@tabler/icons-react";
|
||||
import _ from "lodash";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { validRegex } from "../../component/regular_expressions";
|
||||
import funCreateNewProfile from "../fun/fun_create_profile";
|
||||
import { MODEL_PROFILE } from "../model/interface";
|
||||
import { Profile_ComponentCreateNewProfile } from "../_component";
|
||||
import { ComponentGlobal_BoxUploadImage } from "@/app_modules/_global/component";
|
||||
|
||||
export default function CreateProfile({ userId }: { userId: any }) {
|
||||
export default function CreateProfile({
|
||||
userLoginId,
|
||||
}: {
|
||||
userLoginId: string;
|
||||
}) {
|
||||
const [filePP, setFilePP] = useState<File | null>(null);
|
||||
const [imgPP, setImgPP] = useState<any | null>();
|
||||
const [fileBG, setFileBG] = useState<File | null>(null);
|
||||
@@ -47,14 +46,16 @@ export default function CreateProfile({ userId }: { userId: any }) {
|
||||
|
||||
return (
|
||||
<>
|
||||
<Stack px={"sm"} spacing={"xl"}>
|
||||
<Stack px={"sm"} spacing={40}>
|
||||
<Box>
|
||||
<Stack>
|
||||
<Stack spacing={"xs"}>
|
||||
<ComponentGlobal_BoxInformation informasi="Upload foto profile anda." />
|
||||
<Center>
|
||||
{imgPP ? (
|
||||
<Paper shadow="lg" radius={"100%"}>
|
||||
<Avatar
|
||||
|
||||
color={"cyan"}
|
||||
sx={{
|
||||
borderStyle: "solid",
|
||||
borderColor: "gray",
|
||||
@@ -68,11 +69,13 @@ export default function CreateProfile({ userId }: { userId: any }) {
|
||||
) : (
|
||||
<Paper shadow="lg" radius={"100%"}>
|
||||
<Avatar
|
||||
variant="light"
|
||||
color="blue"
|
||||
size={150}
|
||||
radius={"100%"}
|
||||
sx={{
|
||||
borderStyle: "solid",
|
||||
borderColor: "gray",
|
||||
borderColor: MainColor.darkblue,
|
||||
borderWidth: "0.5px",
|
||||
}}
|
||||
/>
|
||||
@@ -119,22 +122,20 @@ export default function CreateProfile({ userId }: { userId: any }) {
|
||||
</Box>
|
||||
|
||||
<Box>
|
||||
<Stack>
|
||||
<Stack spacing={"xs"}>
|
||||
<ComponentGlobal_BoxInformation informasi="Upload foto latar belakang profile anda." />
|
||||
<AspectRatio ratio={16 / 9}>
|
||||
<Paper radius={"md"} withBorder shadow="lg" bg={"gray.2"}>
|
||||
{imgBG ? (
|
||||
<Image alt="Foto" src={imgBG ? imgBG : "/aset/no-img.png"} />
|
||||
) : (
|
||||
<Stack align="center">
|
||||
<IconUpload color="gray" />
|
||||
<Text fz={"xs"} c={"gray"}>
|
||||
Upload Background
|
||||
</Text>
|
||||
</Stack>
|
||||
)}
|
||||
</Paper>
|
||||
</AspectRatio>
|
||||
<ComponentGlobal_BoxUploadImage>
|
||||
{imgBG ? (
|
||||
<Image alt="Foto" src={imgBG ? imgBG : "/aset/no-img.png"} />
|
||||
) : (
|
||||
<Stack justify="center" align="center" h={"100%"}>
|
||||
<IconUpload color="white" />
|
||||
<Text fz={"xs"} c={"white"}>
|
||||
Upload Background
|
||||
</Text>
|
||||
</Stack>
|
||||
)}
|
||||
</ComponentGlobal_BoxUploadImage>
|
||||
|
||||
<Center>
|
||||
<FileButton
|
||||
@@ -251,9 +252,9 @@ export default function CreateProfile({ userId }: { userId: any }) {
|
||||
}}
|
||||
/>
|
||||
|
||||
<ButtonAction
|
||||
<Profile_ComponentCreateNewProfile
|
||||
value={value as any}
|
||||
userId={userId}
|
||||
userLoginId={userLoginId}
|
||||
filePP={filePP as any}
|
||||
fileBg={fileBG as any}
|
||||
/>
|
||||
@@ -262,76 +263,3 @@ export default function CreateProfile({ userId }: { userId: any }) {
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function ButtonAction({
|
||||
value,
|
||||
userId,
|
||||
filePP,
|
||||
fileBg,
|
||||
}: {
|
||||
value: MODEL_PROFILE;
|
||||
userId: string;
|
||||
filePP: FormData;
|
||||
fileBg: FormData;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
async function onSubmit() {
|
||||
const body = {
|
||||
userId: userId,
|
||||
name: value.name,
|
||||
email: value.email,
|
||||
alamat: value.alamat,
|
||||
jenisKelamin: value.jenisKelamin,
|
||||
};
|
||||
if (_.values(body).includes(""))
|
||||
return ComponentGlobal_NotifikasiPeringatan("Lengkapi Data");
|
||||
if (!body.email.match(validRegex)) return null;
|
||||
|
||||
const gambarPP = new FormData();
|
||||
gambarPP.append("filePP", filePP as any);
|
||||
|
||||
const gambarBG = new FormData();
|
||||
gambarBG.append("fileBG", fileBg as any);
|
||||
|
||||
if (!gambarPP)
|
||||
return ComponentGlobal_NotifikasiPeringatan("Lengkapi foto profile");
|
||||
if (!gambarBG)
|
||||
return ComponentGlobal_NotifikasiPeringatan(
|
||||
"Lengkapi background profile"
|
||||
);
|
||||
|
||||
await funCreateNewProfile(body as any, gambarPP, gambarBG).then((res) => {
|
||||
if (res.status === 201) {
|
||||
setLoading(true);
|
||||
ComponentGlobal_NotifikasiBerhasil("Berhasil Membuat Profile", 3000);
|
||||
router.push(RouterHome.main_home, { scroll: false });
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Button
|
||||
loading={loading ? true : false}
|
||||
loaderPosition="center"
|
||||
mt={"md"}
|
||||
radius={50}
|
||||
bg={MainColor.yellow}
|
||||
color="yellow"
|
||||
onClick={() => {
|
||||
onSubmit();
|
||||
}}
|
||||
style={{
|
||||
border: `2px solid ${AccentColor.yellow}`,
|
||||
color: "black",
|
||||
}}
|
||||
>
|
||||
Simpan
|
||||
</Button>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { RouterMap } from "@/app/lib/router_hipmi/router_map";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
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 fs from "fs";
|
||||
|
||||
export async function map_funCreatePin({ data }: { data: any }) {
|
||||
const authorId = await user_funGetOneUserId();
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
const gambar: any = data.gambar.get("file");
|
||||
const fileName = gambar.name;
|
||||
@@ -37,7 +37,7 @@ export async function map_funCreatePin({ data }: { data: any }) {
|
||||
longitude: data.long,
|
||||
namePin: data.namePin,
|
||||
portofolioId: data?.portofolioId,
|
||||
authorId: authorId,
|
||||
authorId: userLoginId,
|
||||
imageMapId: uploadImage.id,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
|
||||
export default async function notifikasi_countUserNotifikasi() {
|
||||
const userId = await user_funGetOneUserId();
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
const count = await prisma.notifikasi.findMany({
|
||||
where: {
|
||||
userId: userId,
|
||||
userId: userLoginId,
|
||||
isRead: false,
|
||||
userRoleId: "1"
|
||||
userRoleId: "1",
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
import _ from "lodash";
|
||||
|
||||
export default async function notifikasi_getByUserId({
|
||||
@@ -11,7 +11,7 @@ export default async function notifikasi_getByUserId({
|
||||
page: number;
|
||||
kategoriApp?: string;
|
||||
}) {
|
||||
const userId = await user_funGetOneUserId();
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
const takeData = 10;
|
||||
const skipData = page * takeData - takeData;
|
||||
|
||||
@@ -26,7 +26,7 @@ export default async function notifikasi_getByUserId({
|
||||
{ createdAt: "desc" },
|
||||
],
|
||||
where: {
|
||||
userId: userId,
|
||||
userId: userLoginId,
|
||||
userRoleId: "1",
|
||||
},
|
||||
});
|
||||
@@ -44,7 +44,7 @@ export default async function notifikasi_getByUserId({
|
||||
{ createdAt: "desc" },
|
||||
],
|
||||
where: {
|
||||
userId: userId,
|
||||
userId: userLoginId,
|
||||
userRoleId: "1",
|
||||
kategoriApp: _.upperCase(kategoriApp),
|
||||
},
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { RouterAuth } from "@/app/lib/router_hipmi/router_auth";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { redirect } from "next/navigation";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
|
||||
export async function userSearch_getAllUser({
|
||||
page,
|
||||
@@ -12,11 +10,7 @@ export async function userSearch_getAllUser({
|
||||
page: number;
|
||||
search?: string;
|
||||
}) {
|
||||
const authorId = await user_funGetOneUserId();
|
||||
if (!authorId) {
|
||||
redirect(RouterAuth.login);
|
||||
// return { status: 400, message: "Gagal mendapatkan authorId" };
|
||||
}
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
const takeData = 20;
|
||||
const skipData = page * takeData - takeData;
|
||||
@@ -40,7 +34,7 @@ export async function userSearch_getAllUser({
|
||||
OR: [
|
||||
{
|
||||
NOT: {
|
||||
id: authorId,
|
||||
id: userLoginId,
|
||||
},
|
||||
},
|
||||
],
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
import { revalidatePath } from "next/cache";
|
||||
|
||||
export async function Vote_funCreateHasil(
|
||||
pilihanVotingId: string,
|
||||
votingId: string
|
||||
) {
|
||||
const authorId = await user_funGetOneUserId();
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
const get = await prisma.voting_DaftarNamaVote.findFirst({
|
||||
where: {
|
||||
@@ -36,7 +36,7 @@ export async function Vote_funCreateHasil(
|
||||
data: {
|
||||
voting_DaftarNamaVoteId: pilihanVotingId,
|
||||
votingId: votingId,
|
||||
authorId: authorId,
|
||||
authorId: userLoginId,
|
||||
},
|
||||
select: {
|
||||
Voting: {
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
import { revalidatePath } from "next/cache";
|
||||
|
||||
export async function Vote_funCreatePilihanVotingById(
|
||||
namaVotingId: string,
|
||||
votingId: string
|
||||
) {
|
||||
const authorId = await user_funGetOneUserId();
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
const create = await prisma.voting_Kontributor.create({
|
||||
data: {
|
||||
voting_DaftarNamaVoteId: namaVotingId,
|
||||
votingId: votingId,
|
||||
authorId: authorId,
|
||||
authorId: userLoginId,
|
||||
},
|
||||
});
|
||||
|
||||
if(!create) return {status: 400, message: "Gagal Voting"}
|
||||
if (!create) return { status: 400, message: "Gagal Voting" };
|
||||
revalidatePath("/dev/vote/detail/main/");
|
||||
return {status: 201, message: "Berhasil Voting"}
|
||||
return { status: 201, message: "Berhasil Voting" };
|
||||
}
|
||||
|
||||
@@ -1,19 +1,13 @@
|
||||
"use server";
|
||||
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { MODEL_VOTING } from "../../model/interface";
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
import _ from "lodash";
|
||||
import { RouterAuth } from "@/app/lib/router_hipmi/router_auth";
|
||||
import { redirect } from "next/navigation";
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { MODEL_VOTING } from "../../model/interface";
|
||||
|
||||
export async function Vote_funCreate(req: MODEL_VOTING, listVote: any[]) {
|
||||
const authorId = await user_funGetOneUserId();
|
||||
if (!authorId) {
|
||||
redirect(RouterAuth.login);
|
||||
// return { status: 400, message: "Gagal mendapatkan authorId" };
|
||||
}
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
const create = await prisma.voting.create({
|
||||
data: {
|
||||
@@ -21,7 +15,7 @@ export async function Vote_funCreate(req: MODEL_VOTING, listVote: any[]) {
|
||||
deskripsi: req.deskripsi,
|
||||
awalVote: req.awalVote,
|
||||
akhirVote: req.akhirVote,
|
||||
authorId: authorId,
|
||||
authorId: userLoginId,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
|
||||
export async function Vote_cekKontributorById(votingId: string) {
|
||||
const UserId = await user_funGetOneUserId()
|
||||
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
const cek = await prisma.voting_Kontributor.count({
|
||||
where: {
|
||||
authorId: UserId,
|
||||
authorId: userLoginId,
|
||||
votingId: votingId,
|
||||
},
|
||||
});
|
||||
|
||||
if (cek > 0) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
if (cek > 0) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
|
||||
export async function vote_getAllListPublish({
|
||||
page,
|
||||
|
||||
@@ -1,16 +1,11 @@
|
||||
"use server";
|
||||
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { RouterAuth } from "@/app/lib/router_hipmi/router_auth";
|
||||
import { redirect } from "next/navigation";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
|
||||
export async function Vote_getAllListRiwayatSaya({ page }: { page: number }) {
|
||||
const authorId = await user_funGetOneUserId();
|
||||
if (!authorId) {
|
||||
redirect(RouterAuth.login);
|
||||
// return { status: 400, message: "Gagal mendapatkan authorId" };
|
||||
}
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
const takeData = 5;
|
||||
const skipData = page * takeData - takeData;
|
||||
|
||||
@@ -23,7 +18,7 @@ export async function Vote_getAllListRiwayatSaya({ page }: { page: number }) {
|
||||
},
|
||||
where: {
|
||||
voting_StatusId: "1",
|
||||
authorId: authorId,
|
||||
authorId: userLoginId,
|
||||
isActive: true,
|
||||
akhirVote: {
|
||||
lte: new Date(),
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
|
||||
export async function vote_getAllListKontribusiByAuthorId({
|
||||
page,
|
||||
}: {
|
||||
page: number;
|
||||
}) {
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
const takeData = 5;
|
||||
const skipData = page * takeData - takeData;
|
||||
|
||||
const authorId = await user_funGetOneUserId();
|
||||
const data = await prisma.voting_Kontributor.findMany({
|
||||
take: takeData,
|
||||
skip: skipData,
|
||||
@@ -19,7 +19,7 @@ export async function vote_getAllListKontribusiByAuthorId({
|
||||
createdAt: "asc",
|
||||
},
|
||||
where: {
|
||||
authorId: authorId,
|
||||
authorId: userLoginId,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
|
||||
export async function Vote_getOnePilihanVotingByUserId(votingId: string) {
|
||||
const userId = await user_funGetOneUserId();
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
const get = await prisma.voting_Kontributor.findFirst({
|
||||
where: {
|
||||
authorId: userId,
|
||||
authorId: userLoginId,
|
||||
votingId: votingId,
|
||||
},
|
||||
select: {
|
||||
|
||||
@@ -1,16 +1,11 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { RouterAuth } from "@/app/lib/router_hipmi/router_auth";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { redirect } from "next/navigation";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
|
||||
export async function vote_getAllDraft({ page }: { page: number }) {
|
||||
const authorId = await user_funGetOneUserId();
|
||||
if (!authorId) {
|
||||
redirect(RouterAuth.login);
|
||||
// return { status: 400, message: "Gagal mendapatkan authorId" };
|
||||
}
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
const takeData = 10;
|
||||
const skipData = page * takeData - takeData;
|
||||
|
||||
@@ -22,7 +17,7 @@ export async function vote_getAllDraft({ page }: { page: number }) {
|
||||
},
|
||||
where: {
|
||||
voting_StatusId: "3",
|
||||
authorId: authorId,
|
||||
authorId: userLoginId,
|
||||
isActive: true,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,16 +1,10 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { RouterAuth } from "@/app/lib/router_hipmi/router_auth";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { redirect } from "next/navigation";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
|
||||
export async function vote_getAllPublish({ page }: { page: number }) {
|
||||
const authorId = await user_funGetOneUserId();
|
||||
if (!authorId) {
|
||||
redirect(RouterAuth.login);
|
||||
// return { status: 400, message: "Gagal mendapatkan authorId" };
|
||||
}
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
const takeData = 5;
|
||||
const skipData = page * takeData - takeData;
|
||||
@@ -23,7 +17,7 @@ export async function vote_getAllPublish({ page }: { page: number }) {
|
||||
},
|
||||
where: {
|
||||
voting_StatusId: "1",
|
||||
authorId: authorId,
|
||||
authorId: userLoginId,
|
||||
isActive: true,
|
||||
akhirVote: {
|
||||
gte: new Date(),
|
||||
|
||||
@@ -1,16 +1,10 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { RouterAuth } from "@/app/lib/router_hipmi/router_auth";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { redirect } from "next/navigation";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
|
||||
export async function vote_getAllReject({ page }: { page: number }) {
|
||||
const authorId = await user_funGetOneUserId();
|
||||
if (!authorId) {
|
||||
redirect(RouterAuth.login);
|
||||
// return { status: 400, message: "Gagal mendapatkan authorId" };
|
||||
}
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
const takeData = 10;
|
||||
const skipData = page * takeData - takeData;
|
||||
@@ -23,7 +17,7 @@ export async function vote_getAllReject({ page }: { page: number }) {
|
||||
},
|
||||
where: {
|
||||
voting_StatusId: "4",
|
||||
authorId: authorId,
|
||||
authorId: userLoginId,
|
||||
isActive: true,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,16 +1,10 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { RouterAuth } from "@/app/lib/router_hipmi/router_auth";
|
||||
import { user_funGetOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { redirect } from "next/navigation";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
|
||||
export async function vote_getAllReview({ page }: { page: number }) {
|
||||
const authorId = await user_funGetOneUserId();
|
||||
if (!authorId) {
|
||||
redirect(RouterAuth.login);
|
||||
// return { status: 400, message: "Gagal mendapatkan authorId" };
|
||||
}
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
const takeData = 10;
|
||||
const skipData = page * takeData - takeData;
|
||||
@@ -23,7 +17,7 @@ export async function vote_getAllReview({ page }: { page: number }) {
|
||||
},
|
||||
where: {
|
||||
voting_StatusId: "2",
|
||||
authorId: authorId,
|
||||
authorId: userLoginId,
|
||||
isActive: true,
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user