diff --git a/CHANGELOG.md b/CHANGELOG.md
index c094971c..c54941f0 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,17 @@
All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
+## [1.2.39](https://github.com/bipproduction/hipmi/compare/v1.2.38...v1.2.39) (2025-01-12)
+
+## [1.2.38](https://github.com/bipproduction/hipmi/compare/v1.2.37...v1.2.38) (2025-01-03)
+
+
+### Bug Fixes
+
+* user ([215accb](https://github.com/bipproduction/hipmi/commit/215accbcaa989e43f43dfc5f400d5411013f4ef3))
+
+## [1.2.37](https://github.com/bipproduction/hipmi/compare/v1.2.36...v1.2.37) (2025-01-02)
+
## [1.2.36](https://github.com/bipproduction/hipmi/compare/v1.2.35...v1.2.36) (2024-12-30)
## [1.2.35](https://github.com/bipproduction/hipmi/compare/v1.2.34...v1.2.35) (2024-12-27)
diff --git a/bun.lockb b/bun.lockb
index d9e86731..8d2a8fec 100755
Binary files a/bun.lockb and b/bun.lockb differ
diff --git a/package.json b/package.json
index 273e1449..ded3f924 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "hipmi",
- "version": "1.2.36",
+ "version": "1.2.39",
"private": true,
"prisma": {
"seed": "npx tsx prisma/seed.ts --yes"
@@ -87,6 +87,7 @@
"react-quill": "^2.0.0",
"react-responsive-carousel": "^3.2.23",
"react-toastify": "^9.1.3",
+ "sharp": "^0.33.5",
"socket.io-client": "^4.7.2",
"tailwindcss": "3.3.3",
"ts-node": "^10.9.2",
diff --git a/prisma/migrations/20250108154615_new_database/migration.sql b/prisma/migrations/20250108154615_new_database/migration.sql
new file mode 100644
index 00000000..3476e5af
--- /dev/null
+++ b/prisma/migrations/20250108154615_new_database/migration.sql
@@ -0,0 +1,198 @@
+/*
+ Warnings:
+
+ - You are about to drop the column `imagesId` on the `Job` table. All the data in the column will be lost.
+ - You are about to drop the column `active` on the `MasterBank` table. All the data in the column will be lost.
+ - You are about to drop the column `name` on the `MasterBank` table. All the data in the column will be lost.
+ - You are about to drop the column `imagesBackgroundId` on the `Profile` table. All the data in the column will be lost.
+ - You are about to drop the column `imagesId` on the `Profile` table. All the data in the column will be lost.
+ - You are about to drop the `ImagesBackground` table. If the table is not empty, all the data it contains will be lost.
+ - Added the required column `namaAkun` to the `MasterBank` table without a default value. This is not possible if the table is not empty.
+ - Added the required column `namaBank` to the `MasterBank` table without a default value. This is not possible if the table is not empty.
+
+*/
+-- DropForeignKey
+ALTER TABLE "Job" DROP CONSTRAINT "Job_imagesId_fkey";
+
+-- DropForeignKey
+ALTER TABLE "Notifikasi" DROP CONSTRAINT "NotifikasiAdmin";
+
+-- DropForeignKey
+ALTER TABLE "Notifikasi" DROP CONSTRAINT "NotifikasiUser";
+
+-- DropForeignKey
+ALTER TABLE "Portofolio" DROP CONSTRAINT "Portofolio_logoId_fkey";
+
+-- DropForeignKey
+ALTER TABLE "Profile" DROP CONSTRAINT "Profile_imagesBackgroundId_fkey";
+
+-- DropForeignKey
+ALTER TABLE "Profile" DROP CONSTRAINT "Profile_imagesId_fkey";
+
+-- DropIndex
+DROP INDEX "Profile_imagesBackgroundId_key";
+
+-- DropIndex
+DROP INDEX "Profile_imagesId_key";
+
+-- AlterTable
+ALTER TABLE "BeritaInvestasi" ADD COLUMN "imageId" TEXT;
+
+-- AlterTable
+ALTER TABLE "DokumenInvestasi" ADD COLUMN "fileId" TEXT,
+ALTER COLUMN "url" DROP NOT NULL;
+
+-- AlterTable
+ALTER TABLE "Donasi" ADD COLUMN "imageId" TEXT;
+
+-- AlterTable
+ALTER TABLE "Donasi_Cerita" ADD COLUMN "imageId" TEXT;
+
+-- AlterTable
+ALTER TABLE "Donasi_Invoice" ADD COLUMN "imageId" TEXT;
+
+-- AlterTable
+ALTER TABLE "Donasi_Kabar" ADD COLUMN "imageId" TEXT;
+
+-- AlterTable
+ALTER TABLE "Donasi_PencairanDana" ADD COLUMN "imageId" TEXT;
+
+-- AlterTable
+ALTER TABLE "Donasi_TemporaryCreate" ADD COLUMN "imageId" TEXT;
+
+-- AlterTable
+ALTER TABLE "Event" ADD COLUMN "isArsip" BOOLEAN DEFAULT false,
+ADD COLUMN "tanggalSelesai" TIMESTAMP(3),
+ALTER COLUMN "tanggal" DROP NOT NULL;
+
+-- AlterTable
+ALTER TABLE "Event_Peserta" ADD COLUMN "isPresent" BOOLEAN NOT NULL DEFAULT false;
+
+-- AlterTable
+ALTER TABLE "Investasi" ADD COLUMN "imageId" TEXT,
+ADD COLUMN "prospektusFileId" TEXT;
+
+-- AlterTable
+ALTER TABLE "Job" DROP COLUMN "imagesId",
+ADD COLUMN "imageId" TEXT;
+
+-- AlterTable
+ALTER TABLE "MasterBank" DROP COLUMN "active",
+DROP COLUMN "name",
+ADD COLUMN "isActive" BOOLEAN NOT NULL DEFAULT true,
+ADD COLUMN "namaAkun" TEXT NOT NULL,
+ADD COLUMN "namaBank" TEXT NOT NULL;
+
+-- AlterTable
+ALTER TABLE "Notifikasi" ALTER COLUMN "userId" DROP NOT NULL,
+ALTER COLUMN "adminId" DROP NOT NULL;
+
+-- AlterTable
+ALTER TABLE "Profile" DROP COLUMN "imagesBackgroundId",
+DROP COLUMN "imagesId",
+ADD COLUMN "imageBackgroundId" TEXT,
+ADD COLUMN "imageId" TEXT;
+
+-- AlterTable
+ALTER TABLE "ProspektusInvestasi" ADD COLUMN "fileId" TEXT,
+ADD COLUMN "title" TEXT;
+
+-- AlterTable
+ALTER TABLE "User" ALTER COLUMN "active" SET DEFAULT false;
+
+-- AlterTable
+ALTER TABLE "UserSession" ALTER COLUMN "expires" DROP NOT NULL;
+
+-- AlterTable
+ALTER TABLE "Voting" ADD COLUMN "isArsip" BOOLEAN NOT NULL DEFAULT false;
+
+-- DropTable
+DROP TABLE "ImagesBackground";
+
+-- CreateTable
+CREATE TABLE "Investasi_Invoice" (
+ "id" TEXT NOT NULL,
+ "isActive" BOOLEAN NOT NULL DEFAULT true,
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ "updatedAt" TIMESTAMP(3) NOT NULL,
+ "nominal" TEXT NOT NULL,
+ "lembarTerbeli" TEXT NOT NULL,
+ "investasiId" TEXT,
+ "masterBankId" TEXT,
+ "statusInvoiceId" TEXT,
+ "authorId" TEXT,
+ "imagesId" TEXT,
+ "imageId" TEXT,
+
+ CONSTRAINT "Investasi_Invoice_pkey" PRIMARY KEY ("id")
+);
+
+-- CreateTable
+CREATE TABLE "InvestasiMaster_StatusInvoice" (
+ "id" TEXT NOT NULL,
+ "name" TEXT NOT NULL,
+ "isActive" BOOLEAN NOT NULL DEFAULT true,
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ "updatedAt" TIMESTAMP(3) NOT NULL,
+
+ CONSTRAINT "InvestasiMaster_StatusInvoice_pkey" PRIMARY KEY ("id")
+);
+
+-- CreateTable
+CREATE TABLE "BusinessMaps" (
+ "id" TEXT NOT NULL,
+ "isActive" BOOLEAN NOT NULL DEFAULT true,
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ "updatedAt" TIMESTAMP(3) NOT NULL,
+ "namePin" TEXT NOT NULL,
+ "latitude" DOUBLE PRECISION NOT NULL,
+ "longitude" DOUBLE PRECISION NOT NULL,
+ "authorId" TEXT,
+ "portofolioId" TEXT,
+ "imageId" TEXT,
+ "pinId" TEXT,
+
+ CONSTRAINT "BusinessMaps_pkey" PRIMARY KEY ("id")
+);
+
+-- CreateTable
+CREATE TABLE "MasterKategoriApp" (
+ "id" TEXT NOT NULL,
+ "isActive" BOOLEAN NOT NULL DEFAULT true,
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ "updatedAt" TIMESTAMP(3) NOT NULL,
+ "name" TEXT NOT NULL,
+ "value" TEXT,
+
+ CONSTRAINT "MasterKategoriApp_pkey" PRIMARY KEY ("id")
+);
+
+-- CreateIndex
+CREATE UNIQUE INDEX "BusinessMaps_portofolioId_key" ON "BusinessMaps"("portofolioId");
+
+-- AddForeignKey
+ALTER TABLE "Investasi_Invoice" ADD CONSTRAINT "Investasi_Invoice_investasiId_fkey" FOREIGN KEY ("investasiId") REFERENCES "Investasi"("id") ON DELETE SET NULL ON UPDATE CASCADE;
+
+-- AddForeignKey
+ALTER TABLE "Investasi_Invoice" ADD CONSTRAINT "Investasi_Invoice_masterBankId_fkey" FOREIGN KEY ("masterBankId") REFERENCES "MasterBank"("id") ON DELETE SET NULL ON UPDATE CASCADE;
+
+-- AddForeignKey
+ALTER TABLE "Investasi_Invoice" ADD CONSTRAINT "Investasi_Invoice_statusInvoiceId_fkey" FOREIGN KEY ("statusInvoiceId") REFERENCES "InvestasiMaster_StatusInvoice"("id") ON DELETE SET NULL ON UPDATE CASCADE;
+
+-- AddForeignKey
+ALTER TABLE "Investasi_Invoice" ADD CONSTRAINT "Investasi_Invoice_authorId_fkey" FOREIGN KEY ("authorId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
+
+-- AddForeignKey
+ALTER TABLE "Investasi_Invoice" ADD CONSTRAINT "Investasi_Invoice_imagesId_fkey" FOREIGN KEY ("imagesId") REFERENCES "Images"("id") ON DELETE SET NULL ON UPDATE CASCADE;
+
+-- AddForeignKey
+ALTER TABLE "Notifikasi" ADD CONSTRAINT "NotifikasiUser" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
+
+-- AddForeignKey
+ALTER TABLE "Notifikasi" ADD CONSTRAINT "NotifikasiAdmin" FOREIGN KEY ("adminId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
+
+-- AddForeignKey
+ALTER TABLE "BusinessMaps" ADD CONSTRAINT "BusinessMaps_authorId_fkey" FOREIGN KEY ("authorId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
+
+-- AddForeignKey
+ALTER TABLE "BusinessMaps" ADD CONSTRAINT "BusinessMaps_portofolioId_fkey" FOREIGN KEY ("portofolioId") REFERENCES "Portofolio"("id") ON DELETE SET NULL ON UPDATE CASCADE;
diff --git a/src/app/(user)/waiting-room/page.tsx b/src/app/(user)/waiting-room/page.tsx
index abb6e4d0..8d19813d 100644
--- a/src/app/(user)/waiting-room/page.tsx
+++ b/src/app/(user)/waiting-room/page.tsx
@@ -1,19 +1,12 @@
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
-import { funGlobal_checkActivationUseById } from "@/app_modules/_global/fun/get/fun_check_activation_use_by_id";
import WaitingRoom_View from "@/app_modules/waiting_room/view";
export default async function Page() {
const userLoginId = await funGetUserIdByToken();
- const activationUser = await funGlobal_checkActivationUseById({
- userId: userLoginId as string,
- });
return (
<>
-
+
>
);
}
diff --git a/src/app/api/auth/login/route.ts b/src/app/api/auth/login/route.ts
index 97c36643..871e8f3f 100644
--- a/src/app/api/auth/login/route.ts
+++ b/src/app/api/auth/login/route.ts
@@ -1,5 +1,6 @@
import { prisma } from "@/app/lib";
import { randomOTP } from "@/app_modules/auth/fun/rondom_otp";
+import backendLogger from "@/util/backendLogger";
import { NextResponse } from "next/server";
export async function POST(req: Request) {
@@ -17,12 +18,13 @@ export async function POST(req: Request) {
);
const sendWa = await res.json();
+
if (sendWa.status !== "success")
return NextResponse.json(
{ success: false, message: "Nomor Whatsapp Tidak Aktif" },
{ status: 400 }
);
-
+
const createOtpId = await prisma.kodeOtp.create({
data: {
nomor: nomor,
@@ -45,14 +47,14 @@ export async function POST(req: Request) {
{ status: 200 }
);
} catch (error) {
- console.log(error);
-
+ backendLogger.log("Error Login", error);
return NextResponse.json(
- { success: false, message: "Server Whatsapp Error !! " },
+ { success: false, message: error as Error },
{ status: 500 }
);
}
}
+
return NextResponse.json(
{ success: false, message: "Method Not Allowed" },
{ status: 405 }
diff --git a/src/app/api/auth/register/route.ts b/src/app/api/auth/register/route.ts
index c307d724..53f83014 100644
--- a/src/app/api/auth/register/route.ts
+++ b/src/app/api/auth/register/route.ts
@@ -1,5 +1,6 @@
import { sessionCreate } from "@/app/auth/_lib/session_create";
import prisma from "@/app/lib/prisma";
+import backendLogger from "@/util/backendLogger";
import { NextResponse } from "next/server";
export async function POST(req: Request) {
@@ -23,7 +24,7 @@ export async function POST(req: Request) {
data: {
username: data.username,
nomor: data.nomor,
- active: true,
+ active: false,
},
});
@@ -38,7 +39,15 @@ export async function POST(req: Request) {
{ status: 200 }
);
} catch (error) {
- console.log(error);
+ backendLogger.log("Error registrasi:", error);
+ return NextResponse.json(
+ {
+ success: false,
+ message: "Server Error",
+ reason: (error as Error).message,
+ },
+ { status: 500 }
+ );
}
}
diff --git a/src/app/api/auth/validasi/route.ts b/src/app/api/auth/validasi/route.ts
index 69c64a8c..c8c2e9ea 100644
--- a/src/app/api/auth/validasi/route.ts
+++ b/src/app/api/auth/validasi/route.ts
@@ -1,5 +1,6 @@
import { sessionCreate } from "@/app/auth/_lib/session_create";
import prisma from "@/app/lib/prisma";
+import backendLogger from "@/util/backendLogger";
import { NextResponse } from "next/server";
export async function POST(req: Request) {
@@ -42,7 +43,15 @@ export async function POST(req: Request) {
{ status: 200 }
);
} catch (error) {
- console.log(error);
+ backendLogger.log("Error Validasi:", error);
+ return NextResponse.json(
+ {
+ success: false,
+ message: "Server Error",
+ reason: (error as Error).message,
+ },
+ { status: 500 }
+ );
}
}
return NextResponse.json(
diff --git a/src/app/api/collaboration/[id]/route.ts b/src/app/api/collaboration/[id]/route.ts
new file mode 100644
index 00000000..3abcd9ce
--- /dev/null
+++ b/src/app/api/collaboration/[id]/route.ts
@@ -0,0 +1,113 @@
+import { prisma } from "@/app/lib";
+import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
+import backendLogger from "@/util/backendLogger";
+import { NextResponse } from "next/server";
+
+export const dynamic = "force-dynamic";
+
+export async function GET(
+ request: Request,
+ context: { params: { id: string } }
+) {
+ try {
+ let fixData;
+ const { id } = context.params;
+ const { searchParams } = new URL(request.url);
+ const kategori = searchParams.get("kategori");
+ const page = searchParams.get("page");
+ const takeData = 10;
+ const dataSkip = Number(page) * takeData - takeData;
+
+ // Buatkan api untuk list partisipasi
+
+ const userLoginId = await funGetUserIdByToken();
+
+ if (userLoginId == null) {
+ return NextResponse.json(
+ {
+ success: false,
+ message: "Gagal mendapatkan data, user id tidak ada",
+ },
+ { status: 500 }
+ );
+ }
+
+ if (kategori == "detail") {
+ fixData = await prisma.projectCollaboration.findFirst({
+ where: {
+ id: id,
+ },
+ select: {
+ id: true,
+ isActive: true,
+ title: true,
+ lokasi: true,
+ purpose: true,
+ benefit: true,
+ createdAt: true,
+ // jumlah_partisipan: true,
+ Author: {
+ select: {
+ id: true,
+ Profile: true,
+ },
+ },
+ ProjectCollaborationMaster_Industri: true,
+ ProjectCollaboration_Partisipasi: {
+ where: {
+ isActive: true,
+ },
+ },
+ },
+ });
+ } else if (kategori == "list_partisipan") {
+ fixData = await prisma.projectCollaboration_Partisipasi.findMany({
+ take: takeData,
+ skip: dataSkip,
+ where: {
+ projectCollaborationId: id,
+ isActive: true,
+ },
+ select: {
+ id: true,
+ User: {
+ select: {
+ id: true,
+ Profile: true,
+ },
+ },
+ deskripsi_diri: true,
+ },
+ });
+ } else if (kategori == "cek_partisipasi") {
+ const cek = await prisma.projectCollaboration_Partisipasi.findFirst({
+ where: {
+ projectCollaborationId: id,
+ userId: userLoginId,
+ },
+ });
+
+ if (cek === null) {
+ fixData = false;
+ } else {
+ fixData = true;
+ }
+ }
+
+ return NextResponse.json(
+ { success: true, message: "Berhasil mendapatkan data", data: fixData },
+ { status: 200 }
+ );
+ } catch (error) {
+ backendLogger.error("Error get collaboration by id", error);
+
+ return NextResponse.json(
+ {
+ success: false,
+ message: "Gagal mendapatkan data",
+ reason: (error as Error).message,
+ },
+ { status: 500 }
+ );
+ }
+}
diff --git a/src/app/api/collaboration/get/route.ts b/src/app/api/collaboration/get/route.ts
new file mode 100644
index 00000000..d0e21f1c
--- /dev/null
+++ b/src/app/api/collaboration/get/route.ts
@@ -0,0 +1,176 @@
+import { prisma } from "@/app/lib";
+import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
+import backendLogger from "@/util/backendLogger";
+import { NextResponse } from "next/server";
+
+export const dynamic = "force-dynamic";
+
+export async function GET(request: Request) {
+ try {
+ let fixData;
+
+ const { searchParams } = new URL(request.url);
+ const kategori = searchParams.get("kategori");
+ const page = searchParams.get("page");
+
+ const takeData = 5;
+ const skipData = page ? Number(page) * takeData - takeData : 0;
+
+ const userLoginId = await funGetUserIdByToken();
+
+ if (userLoginId == null) {
+ return NextResponse.json(
+ {
+ success: false,
+ message: "Gagal mendapatkan data, user id tidak ada",
+ },
+ { status: 500 }
+ );
+ }
+
+ if (kategori == "beranda") {
+ fixData = await prisma.projectCollaboration.findMany({
+ take: takeData,
+ skip: skipData,
+ orderBy: {
+ createdAt: "desc",
+ },
+ where: {
+ projectCollaborationMaster_StatusId: 1,
+ isActive: true,
+ },
+ select: {
+ id: true,
+ isActive: true,
+ title: true,
+ lokasi: true,
+ purpose: true,
+ benefit: true,
+ Author: {
+ select: {
+ id: true,
+ Profile: true,
+ },
+ },
+ ProjectCollaborationMaster_Industri: true,
+ ProjectCollaboration_Partisipasi: {
+ where: {
+ isActive: true,
+ },
+ },
+ },
+ });
+ } else if (kategori == "partisipasi") {
+ fixData = await prisma.projectCollaboration_Partisipasi.findMany({
+ take: takeData,
+ skip: skipData,
+ orderBy: {
+ createdAt: "desc",
+ },
+ where: {
+ userId: userLoginId,
+ isActive: true,
+ AND: {
+ ProjectCollaboration: {
+ isActive: true,
+ },
+ },
+ },
+ select: {
+ id: true,
+ isActive: true,
+ ProjectCollaboration: {
+ select: {
+ id: true,
+ isActive: true,
+ title: true,
+ lokasi: true,
+ purpose: true,
+ benefit: true,
+ Author: {
+ select: {
+ id: true,
+ Profile: true,
+ },
+ },
+ ProjectCollaborationMaster_Industri: true,
+ ProjectCollaboration_Partisipasi: {
+ where: {
+ isActive: true,
+ },
+ },
+ },
+ },
+ },
+ });
+ } else if (kategori == "proyeksaya") {
+ fixData = await prisma.projectCollaboration.findMany({
+ take: takeData,
+ skip: skipData,
+ orderBy: { createdAt: "desc" },
+ where: { userId: userLoginId, isActive: true },
+ select: {
+ id: true,
+ isActive: true,
+ title: true,
+ lokasi: true,
+ purpose: true,
+ benefit: true,
+ // jumlah_partisipan: true,
+ Author: {
+ select: {
+ id: true,
+ Profile: true,
+ },
+ },
+ ProjectCollaborationMaster_Industri: true,
+ ProjectCollaboration_Partisipasi: {
+ where: {
+ isActive: true,
+ },
+ },
+ },
+ });
+ } else if (kategori == "grup") {
+ fixData = await prisma.projectCollaboration_AnggotaRoomChat.findMany({
+ take: takeData,
+ skip: skipData,
+ orderBy: {
+ createdAt: "desc",
+ },
+ where: {
+ userId: userLoginId as string,
+ },
+ select: {
+ ProjectCollaboration_RoomChat: {
+ select: {
+ id: true,
+ name: true,
+ isActive: true,
+ ProjectCollaboration_AnggotaRoomChat: {
+ select: {
+ User: true,
+ },
+ },
+ },
+ },
+ },
+ });
+ }
+
+ return NextResponse.json(
+ { success: true, message: "Berhasil mendapatkan data", data: fixData },
+ { status: 200 }
+ );
+ } catch (error) {
+ backendLogger.error("Error get collaboration: ", error);
+ return NextResponse.json(
+ {
+ success: false,
+ message: "Gagal mendapatkan data",
+ reason: (error as Error).message,
+ },
+ { status: 500 }
+ );
+ }
+}
diff --git a/src/app/api/collaboration/group/[id]/route.ts b/src/app/api/collaboration/group/[id]/route.ts
new file mode 100644
index 00000000..83b64866
--- /dev/null
+++ b/src/app/api/collaboration/group/[id]/route.ts
@@ -0,0 +1,82 @@
+import { prisma } from "@/app/lib";
+import backendLogger from "@/util/backendLogger";
+import { NextResponse } from "next/server";
+
+export const dynamic = "force-dynamic";
+
+export async function GET(
+ request: Request,
+ context: { params: { id: string } }
+) {
+ try {
+ let fixData;
+ const { id } = context.params;
+ const { searchParams } = new URL(request.url);
+ const kategori = searchParams.get("kategori");
+ const page = searchParams.get("page");
+ const takeData = 10;
+ const skipData = Number(page) * takeData - takeData;
+
+ // data room { id, grup_name}
+ if (kategori == "detail") {
+ fixData = await prisma.projectCollaboration_RoomChat.findFirst({
+ where: {
+ id: id,
+ },
+ select: {
+ id: true,
+ name: true,
+ },
+ });
+ } else if (kategori == "info_group") {
+ fixData = await prisma.projectCollaboration_RoomChat.findFirst({
+ where: {
+ id: id,
+ },
+ select: {
+ id: true,
+ name: true,
+ ProjectCollaboration: {
+ select: {
+ id: true,
+ isActive: true,
+ title: true,
+ lokasi: true,
+ purpose: true,
+ benefit: true,
+ createdAt: true,
+ ProjectCollaborationMaster_Industri: true,
+ },
+ },
+ ProjectCollaboration_AnggotaRoomChat: {
+ select: {
+ User: {
+ select: {
+ id: true,
+ Profile: {
+ select: {
+ id: true,
+ name: true,
+ imageId: true,
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ });
+ }
+
+ return NextResponse.json(
+ { success: true, message: "Berhasil mendapatkan data", data: fixData },
+ { status: 200 }
+ );
+ } catch (error) {
+ backendLogger.error("Gagal mendapatkan data", error);
+ return NextResponse.json(
+ { success: false, message: "Gagal mendapatkan data" },
+ { status: 500 }
+ );
+ }
+}
diff --git a/src/app/api/get-cookie/route.ts b/src/app/api/get-cookie/route.ts
new file mode 100644
index 00000000..8b4959b8
--- /dev/null
+++ b/src/app/api/get-cookie/route.ts
@@ -0,0 +1,15 @@
+import { cookies } from 'next/headers'
+import { NextResponse } from 'next/server';
+
+export const dynamic = "force-dynamic";
+export async function GET(request: Request) {
+ try {
+ const cookiesKey = process.env.NEXT_PUBLIC_BASE_SESSION_KEY!
+ const cookieStore = cookies();
+ const hipmiKey = cookieStore.get(cookiesKey)?.value || '';
+ return NextResponse.json({ token: hipmiKey });
+ } catch (error) {
+ console.error(error);
+ return NextResponse.json({ error }, { status: 500 });
+ }
+}
\ No newline at end of file
diff --git a/src/app/api/image/delete/route.ts b/src/app/api/image/delete/route.ts
index a38d0e37..42d360e3 100644
--- a/src/app/api/image/delete/route.ts
+++ b/src/app/api/image/delete/route.ts
@@ -25,9 +25,7 @@ export async function DELETE(req: Request) {
backendLogger.info("Server status code: " + res.status);
const data = await res.json();
if (res.ok) {
- backendLogger.info(
- `Success delete ${keyOfDirectory}`
- );
+ backendLogger.info(`Success delete ${keyOfDirectory}`);
return NextResponse.json({ success: true });
} else {
const errorText = await res.json();
diff --git a/src/app/api/image/upload/route.ts b/src/app/api/image/upload/route.ts
index a1004088..bf558db0 100644
--- a/src/app/api/image/upload/route.ts
+++ b/src/app/api/image/upload/route.ts
@@ -1,8 +1,13 @@
import { funGetDirectoryNameByValue } from "@/app_modules/_global/fun/get";
import backendLogger from "@/util/backendLogger";
import { NextResponse } from "next/server";
+import sharp from "sharp";
export async function POST(request: Request) {
+ let fixFormData;
const formData = await request.formData();
+ const file: any = formData.get("file");
+ const mimeType = file.type;
+ console.log("MIME Type:", mimeType);
const valueOfDir = formData.get("dirId");
const keyOfDirectory = await funGetDirectoryNameByValue({
@@ -11,9 +16,33 @@ export async function POST(request: Request) {
if (request.method === "POST") {
try {
+ if (mimeType != "application/pdf") {
+ // Resize ukuran
+ const imageBuffer = await file.arrayBuffer();
+ const resize = await sharp(imageBuffer).resize(2000).toBuffer();
+
+ // Convert buffer ke Blob
+ const blob = new Blob([resize], { type: file.type });
+
+ // Convert Blob ke File
+ const resizedFile = new File([blob], file.name, {
+ type: file.type,
+ lastModified: new Date().getTime(),
+ });
+
+ // Buat FormData baru
+ const newFormData = new FormData();
+ newFormData.append("file", resizedFile);
+ newFormData.append("dirId", formData.get("dirId") as string);
+
+ fixFormData = newFormData;
+ } else {
+ fixFormData = formData;
+ }
+
const res = await fetch("https://wibu-storage.wibudev.com/api/upload", {
method: "POST",
- body: formData,
+ body: fixFormData,
headers: {
Authorization: `Bearer ${process.env.WS_APIKEY}`,
},
diff --git a/src/app/api/new/home/route.ts b/src/app/api/new/home/route.ts
index bdb110d8..7ef3a890 100644
--- a/src/app/api/new/home/route.ts
+++ b/src/app/api/new/home/route.ts
@@ -43,7 +43,7 @@ export async function GET(request: Request) {
where: {
id: userLoginId,
},
- select: {
+ include: {
Profile: {
select: {
id: true,
diff --git a/src/app/api/new/investasi/route.ts b/src/app/api/new/investasi/route.ts
index ea13150c..3f7a3592 100644
--- a/src/app/api/new/investasi/route.ts
+++ b/src/app/api/new/investasi/route.ts
@@ -14,7 +14,8 @@ export async function GET(request: Request) {
const kategori = searchParams.get("cat")
const status = searchParams.get("status")
const page = searchParams.get("page")
- const dataSkip = Number(page) * 5 - 5;
+ const dataTake = 10
+ const dataSkip = Number(page) * dataTake - dataTake;
if (kategori == "bursa") {
const data = await prisma.investasi.findMany({
@@ -61,7 +62,7 @@ export async function GET(request: Request) {
// cek data yang lewat
// klo ada, update status
const dataAwal = await prisma.investasi.findMany({
- take: 5,
+ take: dataTake,
skip: dataSkip,
orderBy: [
{
@@ -100,28 +101,28 @@ export async function GET(request: Request) {
}
const data = await prisma.investasi.findMany({
- take: 5,
- skip: dataSkip,
- orderBy: {
- updatedAt: "desc",
- },
- where: {
- authorId: userLoginId,
- masterStatusInvestasiId: status,
- },
- select: {
- id: true,
- title: true,
- targetDana: true,
- imageId: true,
- countDown: true,
- updatedAt: true,
- MasterPencarianInvestor: {
- select: {
- name: true
- }
- }
- }
+ take: dataTake,
+ skip: dataSkip,
+ orderBy: {
+ updatedAt: "desc",
+ },
+ where: {
+ authorId: userLoginId,
+ masterStatusInvestasiId: status,
+ },
+ select: {
+ id: true,
+ title: true,
+ targetDana: true,
+ imageId: true,
+ countDown: true,
+ updatedAt: true,
+ MasterPencarianInvestor: {
+ select: {
+ name: true,
+ },
+ },
+ },
});
dataFix = data.map((v: any) => ({
diff --git a/src/app/api/new/portofolio/[id]/route.ts b/src/app/api/new/portofolio/[id]/route.ts
index 747cabd0..24a7497f 100644
--- a/src/app/api/new/portofolio/[id]/route.ts
+++ b/src/app/api/new/portofolio/[id]/route.ts
@@ -1,173 +1,234 @@
-import { prisma } from "@/app/lib";
+import { DIRECTORY_ID, prisma } from "@/app/lib";
import { NextResponse } from "next/server";
import fs from "fs";
+import { funGlobal_DeleteFileById } from "@/app_modules/_global/fun";
+import { apiDeleteImageById } from "@/app_modules/_global/lib/api_image";
+import backendLogger from "@/util/backendLogger";
export const dynamic = "force-dynamic";
-
-
// GET ONE DATA PORTOFOLIO BY ID PORTOFOLIO
-export async function GET(request: Request, context: { params: { id: string } }) {
- try {
- let dataFix
- const { id } = context.params;
- const { searchParams } = new URL(request.url);
- const kategori = searchParams.get('cat');
+export async function GET(
+ request: Request,
+ context: { params: { id: string } }
+) {
+ try {
+ let dataFix;
+ const { id } = context.params;
+ const { searchParams } = new URL(request.url);
+ const kategori = searchParams.get("cat");
- if (kategori == "bisnis") {
- const data = await prisma.portofolio.findUnique({
- where: {
- id: id,
- },
+ if (kategori == "bisnis") {
+ const data = await prisma.portofolio.findUnique({
+ where: {
+ id: id,
+ },
+ select: {
+ id_Portofolio: true,
+ namaBisnis: true,
+ alamatKantor: true,
+ tlpn: true,
+ deskripsi: true,
+ logoId: true,
+ MasterBidangBisnis: {
select: {
- id_Portofolio: true,
- namaBisnis: true,
- alamatKantor: true,
- tlpn: true,
- deskripsi: true,
- logoId: true,
- MasterBidangBisnis: {
- select: {
- name: true
- }
- },
- Profile: {
- select: {
- userId: true
- }
- }
- }
- });
-
- dataFix = {
- id_Portofolio: data?.id_Portofolio,
- namaBisnis: data?.namaBisnis,
- alamatKantor: data?.alamatKantor,
- tlpn: data?.tlpn,
- deskripsi: data?.deskripsi,
- logoId: data?.logoId,
- bidangBisnis: data?.MasterBidangBisnis?.name,
- authorId: data?.Profile?.userId
- }
-
- } else if (kategori == "lokasi") {
- const data = await prisma.portofolio.findUnique({
- where: {
- id: id,
+ name: true,
},
+ },
+ Profile: {
select: {
- logoId: true,
- BusinessMaps: {
- select: {
- id: true,
- namePin: true,
- latitude: true,
- longitude: true,
- imageId: true,
- pinId: true
- }
- }
- }
- });
-
- dataFix = {
- mapId: data?.BusinessMaps?.id,
- logoId: data?.logoId,
- namePin: data?.BusinessMaps?.namePin,
- latitude: data?.BusinessMaps?.latitude,
- longitude: data?.BusinessMaps?.longitude,
- imageId: data?.BusinessMaps?.imageId,
- pinId: data?.BusinessMaps?.pinId
- }
-
- } else if (kategori == "sosmed") {
- const data = await prisma.portofolio.findUnique({
- where: {
- id: id,
+ userId: true,
},
+ },
+ },
+ });
+
+ dataFix = {
+ id_Portofolio: data?.id_Portofolio,
+ namaBisnis: data?.namaBisnis,
+ alamatKantor: data?.alamatKantor,
+ tlpn: data?.tlpn,
+ deskripsi: data?.deskripsi,
+ logoId: data?.logoId,
+ bidangBisnis: data?.MasterBidangBisnis?.name,
+ authorId: data?.Profile?.userId,
+ };
+ } else if (kategori == "lokasi") {
+ const data = await prisma.portofolio.findUnique({
+ where: {
+ id: id,
+ },
+ select: {
+ logoId: true,
+ BusinessMaps: {
select: {
- Portofolio_MediaSosial: {
- select: {
- facebook: true,
- twitter: true,
- instagram: true,
- tiktok: true,
- youtube: true
- }
- }
- }
- });
+ id: true,
+ namePin: true,
+ latitude: true,
+ longitude: true,
+ imageId: true,
+ pinId: true,
+ },
+ },
+ },
+ });
- dataFix = {
- facebook: data?.Portofolio_MediaSosial?.facebook,
- twitter: data?.Portofolio_MediaSosial?.twitter,
- instagram: data?.Portofolio_MediaSosial?.instagram,
- tiktok: data?.Portofolio_MediaSosial?.tiktok,
- youtube: data?.Portofolio_MediaSosial?.youtube
- }
- }
+ dataFix = {
+ mapId: data?.BusinessMaps?.id,
+ logoId: data?.logoId,
+ namePin: data?.BusinessMaps?.namePin,
+ latitude: data?.BusinessMaps?.latitude,
+ longitude: data?.BusinessMaps?.longitude,
+ imageId: data?.BusinessMaps?.imageId,
+ pinId: data?.BusinessMaps?.pinId,
+ };
+ } else if (kategori == "sosmed") {
+ const data = await prisma.portofolio.findUnique({
+ where: {
+ id: id,
+ },
+ select: {
+ Portofolio_MediaSosial: {
+ select: {
+ facebook: true,
+ twitter: true,
+ instagram: true,
+ tiktok: true,
+ youtube: true,
+ },
+ },
+ },
+ });
- return NextResponse.json({ success: true, message: "Berhasil mendapatkan data", data: dataFix }, { status: 200 });
+ dataFix = {
+ facebook: data?.Portofolio_MediaSosial?.facebook,
+ twitter: data?.Portofolio_MediaSosial?.twitter,
+ instagram: data?.Portofolio_MediaSosial?.instagram,
+ tiktok: data?.Portofolio_MediaSosial?.tiktok,
+ youtube: data?.Portofolio_MediaSosial?.youtube,
+ };
+ }
- } catch (error) {
- console.error(error);
- return NextResponse.json({ success: false, message: "Gagal mendapatkan data, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
- }
+ return NextResponse.json(
+ { success: true, message: "Berhasil mendapatkan data", data: dataFix },
+ { status: 200 }
+ );
+ } catch (error) {
+ console.error(error);
+ return NextResponse.json(
+ {
+ success: false,
+ message: "Gagal mendapatkan data, coba lagi nanti (error: 500)",
+ reason: (error as Error).message,
+ },
+ { status: 500 }
+ );
+ }
}
// DELETE ONE DATA PORTOFOLIO
-export async function DELETE(request: Request, context: { params: { id: string } }) {
- try {
- const { id } = context.params
+export async function DELETE(
+ request: Request,
+ context: { params: { id: string } }
+) {
+ try {
+ const { id } = context.params;
- const data = await prisma.portofolio.findUnique({
- where: {
- id: id
- }
- })
+ const data = await prisma.portofolio.findUnique({
+ where: {
+ id: id,
+ },
+ include: {
+ BusinessMaps: {
+ select: {
+ pinId: true,
+ imageId: true,
+ },
+ },
+ },
+ });
- const findLogo = await prisma.images.findFirst({
- where: {
- id: String(data?.logoId),
- },
- select: {
- id: true,
- url: true,
- },
- });
+ try {
+ const id = data?.logoId;
+ const deleteLogo = await fetch(
+ `https://wibu-storage.wibudev.com/api/files/${id}/delete`,
+ {
+ method: "DELETE",
+ headers: {
+ Authorization: `Bearer ${process.env.WS_APIKEY}`,
+ },
+ }
+ );
- if (findLogo) {
- fs.unlinkSync(`./public/portofolio/logo/${findLogo.url}`)
- const deleteLogo = await prisma.images.delete({
- where: {
- id: String(findLogo?.id),
- },
- });
+ if (deleteLogo.ok) {
+ backendLogger.info(`Success delete logo`);
}
+ if (data?.BusinessMaps?.pinId != null) {
+ const pinId = data?.BusinessMaps?.pinId;
+ const deletePin = await fetch(
+ `https://wibu-storage.wibudev.com/api/files/${pinId}/delete`,
+ {
+ method: "DELETE",
+ headers: {
+ Authorization: `Bearer ${process.env.WS_APIKEY}`,
+ },
+ }
+ );
+ if (deletePin.ok) {
+ backendLogger.info(`Success delete pin`);
+ }
- const deletePortoMedsos = await prisma.portofolio_MediaSosial.delete({
- where: {
- portofolioId: id,
- },
- });
+ const imageId = data?.BusinessMaps?.imageId;
+ const deleteImage = await fetch(
+ `https://wibu-storage.wibudev.com/api/files/${imageId}/delete`,
+ {
+ method: "DELETE",
+ headers: {
+ Authorization: `Bearer ${process.env.WS_APIKEY}`,
+ },
+ }
+ );
- const deleteMap = await prisma.businessMaps.delete({
- where: {
- portofolioId: id
- }
- })
+ if (deleteImage.ok) {
+ backendLogger.info(`Success delete image`);
+ }
+ }
+ } catch (error) {
+ backendLogger.error("Error delete logo", error);
+ }
- const deletePortofolio = await prisma.portofolio.delete({
- where: {
- id: id,
- },
- });
+ const deletePortoMedsos = await prisma.portofolio_MediaSosial.delete({
+ where: {
+ portofolioId: id,
+ },
+ });
- return NextResponse.json({ success: true, message: "Berhasil menghapus data" }, { status: 200 });
+ const deleteMap = await prisma.businessMaps.delete({
+ where: {
+ portofolioId: id,
+ },
+ });
- } catch (error) {
- console.error(error);
- return NextResponse.json({ success: false, message: "Gagal menghapus data, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
- }
-}
\ No newline at end of file
+ const deletePortofolio = await prisma.portofolio.delete({
+ where: {
+ id: id,
+ },
+ });
+
+ return NextResponse.json(
+ { success: true, message: "Berhasil menghapus data" },
+ { status: 200 }
+ );
+ } catch (error) {
+ console.error(error);
+ return NextResponse.json(
+ {
+ success: false,
+ message: "Gagal menghapus data, coba lagi nanti (error: 500)",
+ reason: (error as Error).message,
+ },
+ { status: 500 }
+ );
+ }
+}
diff --git a/src/app/api/user-validate/route.ts b/src/app/api/user-validate/route.ts
new file mode 100644
index 00000000..8842f6f1
--- /dev/null
+++ b/src/app/api/user-validate/route.ts
@@ -0,0 +1,33 @@
+import { decrypt } from "@/app/auth/_lib/decrypt";
+import { prisma } from "@/app/lib";
+import { cookies } from 'next/headers'
+import { NextRequest, NextResponse } from "next/server";
+
+export const dynamic = "force-dynamic";
+
+export async function GET(req: NextRequest) {
+ const token = req.headers.get('Authorization')?.split(' ')[1];
+
+ const decripted = await decrypt({
+ token: token!,
+ encodedKey: process.env.NEXT_PUBLIC_BASE_TOKEN_KEY!
+ })
+
+ if (!decripted) {
+ return NextResponse.json({
+ success: false,
+ message: "Unauthorized"
+ }, { status: 401 })
+ }
+
+ const user = await prisma.user.findUnique({
+ where: {
+ id: decripted.id
+ }
+ })
+ return NextResponse.json({
+ success: true,
+ message: "Berhasil mendapatkan data",
+ data: user
+ })
+}
\ No newline at end of file
diff --git a/src/app/api/user/activation/route.ts b/src/app/api/user/activation/route.ts
new file mode 100644
index 00000000..965e1805
--- /dev/null
+++ b/src/app/api/user/activation/route.ts
@@ -0,0 +1,53 @@
+import { prisma } from "@/app/lib";
+import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
+import backendLogger from "@/util/backendLogger";
+import { NextResponse } from "next/server";
+
+export const dynamic = "force-dynamic";
+
+export async function GET(request: Request) {
+ try {
+ let fixData
+ const userLoginId = await funGetUserIdByToken();
+
+ if (userLoginId == null) {
+ return NextResponse.json(
+ {
+ success: false,
+ message: "Gagal mendapatkan data, user id tidak ada",
+ },
+ { status: 500 }
+ );
+ }
+
+ const activationUser = await prisma.user.findFirst({
+ where: {
+ id: userLoginId,
+ },
+ select: {
+ active: true,
+ },
+ });
+
+ fixData = activationUser?.active
+
+ return NextResponse.json(
+ {
+ success: true,
+ message: "Berhasil mendapatkan data",
+ data: fixData,
+ },
+ { status: 200 }
+ );
+ } catch (error) {
+ backendLogger.error("Error get activation user: ", error);
+ return NextResponse.json(
+ {
+ success: false,
+ message: "Gagal mendapatkan data",
+ reason: (error as Error).message,
+ },
+ { status: 500 }
+ );
+ }
+}
diff --git a/src/app/api/user/get-cookies/route.ts b/src/app/api/user/get-cookies/route.ts
new file mode 100644
index 00000000..f59b5fe8
--- /dev/null
+++ b/src/app/api/user/get-cookies/route.ts
@@ -0,0 +1,24 @@
+import { decrypt } from "@/app/auth/_lib/decrypt";
+import _ from "lodash";
+import { cookies } from "next/headers";
+import { NextResponse } from "next/server";
+
+export const dynamic = "force-dynamic";
+
+export async function GET() {
+ // const data = await req.text();
+ // console.log(data);
+ const c = cookies().get(process.env.NEXT_PUBLIC_BASE_SESSION_KEY!);
+
+ if (!c || !c?.value || _.isEmpty(c?.value) || _.isUndefined(c?.value)) {
+ return NextResponse.json({ status: 401, message: "Unauthorized" });
+ }
+
+ const token = c.value;
+ const dataUser = await decrypt({
+ token: token,
+ encodedKey: process.env.NEXT_PUBLIC_BASE_TOKEN_KEY!,
+ });
+
+ return NextResponse.json({ status: 200, message: "OK", data: dataUser });
+}
diff --git a/src/app/api/user/route.ts b/src/app/api/user/route.ts
index 258227c5..1ae5f208 100644
--- a/src/app/api/user/route.ts
+++ b/src/app/api/user/route.ts
@@ -1,11 +1,12 @@
+
import { decrypt } from "@/app/auth/_lib/decrypt";
import _ from "lodash";
import { cookies } from "next/headers";
import { NextResponse } from "next/server";
+export const dynamic = "force-dynamic";
+
export async function GET() {
- // const data = await req.text();
- // console.log(data);
const c = cookies().get(process.env.NEXT_PUBLIC_BASE_SESSION_KEY!);
if (!c || !c?.value || _.isEmpty(c?.value) || _.isUndefined(c?.value)) {
@@ -18,5 +19,7 @@ export async function GET() {
encodedKey: process.env.NEXT_PUBLIC_BASE_TOKEN_KEY!,
});
- return NextResponse.json({ status: 200, message: "OK", data: dataUser });
+ const id = dataUser?.id
+
+ return NextResponse.json({ status: 200, message: "OK", data: id });
}
diff --git a/src/app/api/validasi/route.ts b/src/app/api/validation/route.ts
similarity index 99%
rename from src/app/api/validasi/route.ts
rename to src/app/api/validation/route.ts
index 4562aa95..ba9c6587 100644
--- a/src/app/api/validasi/route.ts
+++ b/src/app/api/validation/route.ts
@@ -1,9 +1,11 @@
+
import { NextResponse } from "next/server";
+
export async function GET(req: Request) {
const auth = req.headers.get("Authorization");
const token = auth?.split(" ")[1];
if (!token) return NextResponse.json({ success: false }, { status: 401 });
- return NextResponse.json({ success: true });
+ return NextResponse.json({ success: true });
}
diff --git a/src/app/dev/colab/detail/group/[id]/page.tsx b/src/app/dev/colab/detail/group/[id]/page.tsx
index d93ed4f9..ebd48b78 100644
--- a/src/app/dev/colab/detail/group/[id]/page.tsx
+++ b/src/app/dev/colab/detail/group/[id]/page.tsx
@@ -15,6 +15,8 @@ export default async function Page({ params }: { params: { id: string } }) {
"ProjectCollaboration",
"ProjectCollaboration_AnggotaRoomChat",
]);
+
+
let listMsg = await colab_getMessageByRoomId({ roomId: roomId, page: 1 });
const dataUserLogin = await user_getOneByUserId(userLoginId as string);
diff --git a/src/app/dev/colab/detail/info-grup/[id]/page.tsx b/src/app/dev/colab/detail/info-grup/[id]/page.tsx
index 375df71c..d4001193 100644
--- a/src/app/dev/colab/detail/info-grup/[id]/page.tsx
+++ b/src/app/dev/colab/detail/info-grup/[id]/page.tsx
@@ -1,14 +1,9 @@
-import prisma from "@/app/lib/prisma";
import { Colab_DetailInfoGrup } from "@/app_modules/colab";
-import colab_getListAnggotaByRoomId from "@/app_modules/colab/fun/get/room_chat/get_list_anggota_by_room_id";
-
-export default async function Page({ params }: { params: { id: string } }) {
- let roomId = params.id;
- const dataRoom = await colab_getListAnggotaByRoomId(roomId);
+export default async function Page() {
return (
<>
-
+
>
);
}
diff --git a/src/app/dev/colab/detail/main_detail/[id]/page.tsx b/src/app/dev/colab/detail/main_detail/[id]/page.tsx
index 9d3958da..5d8311ca 100644
--- a/src/app/dev/colab/detail/main_detail/[id]/page.tsx
+++ b/src/app/dev/colab/detail/main_detail/[id]/page.tsx
@@ -1,24 +1,13 @@
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
import { Colab_MainDetail } from "@/app_modules/colab";
-import colab_funCekPartisipasiById from "@/app_modules/colab/fun/get/cek_partisipasi_by_user_id";
-import colab_getListPartisipanByColabId from "@/app_modules/colab/fun/get/get_list_partisipan_by_id";
-import colab_getOneCollaborationById from "@/app_modules/colab/fun/get/get_one_by_id";
-export default async function Page({ params }: { params: { id: string } }) {
- let colabId = params.id;
+export default async function Page() {
const userLoginId = await funGetUserIdByToken();
- const dataColab = await colab_getOneCollaborationById(colabId);
- const listPartisipan = await colab_getListPartisipanByColabId(colabId);
- const cekPartisipan = await colab_funCekPartisipasiById(colabId);
-
return (
<>
>
);
diff --git a/src/app/dev/colab/detail/proyek/partisipasi/[id]/layout.tsx b/src/app/dev/colab/detail/proyek/partisipasi/[id]/layout.tsx
index 2d9fef0e..e7cdc81a 100644
--- a/src/app/dev/colab/detail/proyek/partisipasi/[id]/layout.tsx
+++ b/src/app/dev/colab/detail/proyek/partisipasi/[id]/layout.tsx
@@ -3,7 +3,9 @@ import { LayoutColab_DetailPartisipasiProyek } from "@/app_modules/colab";
export default async function Layout({ children }: { children: any }) {
return (
<>
- {children}
+
+ {children}
+
>
);
}
diff --git a/src/app/dev/colab/detail/proyek/partisipasi/[id]/page.tsx b/src/app/dev/colab/detail/proyek/partisipasi/[id]/page.tsx
index 68b18d99..323e5439 100644
--- a/src/app/dev/colab/detail/proyek/partisipasi/[id]/page.tsx
+++ b/src/app/dev/colab/detail/proyek/partisipasi/[id]/page.tsx
@@ -1,18 +1,9 @@
import { Colab_DetailPartisipasiProyek } from "@/app_modules/colab";
-import colab_getListPartisipanByColabId from "@/app_modules/colab/fun/get/get_list_partisipan_by_id";
-import colab_getOneCollaborationById from "@/app_modules/colab/fun/get/get_one_by_id";
-
-export default async function Page({params}: {params: {id: string}}) {
- const colabId = params.id
- const dataColab = await colab_getOneCollaborationById(colabId)
- const listPartisipan = await colab_getListPartisipanByColabId(colabId)
+export default async function Page() {
return (
<>
-
+
>
);
}
diff --git a/src/app/dev/colab/detail/proyek/saya/[id]/layout.tsx b/src/app/dev/colab/detail/proyek/saya/[id]/layout.tsx
index d7c38cc1..1b84d85b 100644
--- a/src/app/dev/colab/detail/proyek/saya/[id]/layout.tsx
+++ b/src/app/dev/colab/detail/proyek/saya/[id]/layout.tsx
@@ -3,19 +3,12 @@ import React from "react";
export default async function Layout({
children,
- params,
}: {
children: React.ReactNode;
- params: { id: string };
}) {
- let colabId = params.id;
-
-
return (
<>
-
- {children}
-
+ {children}
>
);
}
diff --git a/src/app/dev/colab/detail/proyek/saya/[id]/page.tsx b/src/app/dev/colab/detail/proyek/saya/[id]/page.tsx
index 2c5d724f..e1527440 100644
--- a/src/app/dev/colab/detail/proyek/saya/[id]/page.tsx
+++ b/src/app/dev/colab/detail/proyek/saya/[id]/page.tsx
@@ -1,19 +1,9 @@
import { Colab_DetailProyekSaya } from "@/app_modules/colab";
-import colab_getListPartisipanByColabId from "@/app_modules/colab/fun/get/get_list_partisipan_by_id";
-import colab_getOneCollaborationById from "@/app_modules/colab/fun/get/get_one_by_id";
-
-export default async function Page({ params }: { params: { id: string } }) {
- const colabId = params.id;
- const dataColab = await colab_getOneCollaborationById(colabId);
- const listPartisipan = await colab_getListPartisipanByColabId(colabId);
+export default async function Page() {
return (
<>
- {/*
{JSON.stringify(listPartisipan, null,2)} */}
-
+
>
);
}
diff --git a/src/app/dev/colab/main/beranda/page.tsx b/src/app/dev/colab/main/beranda/page.tsx
index c5143fa7..97b20f59 100644
--- a/src/app/dev/colab/main/beranda/page.tsx
+++ b/src/app/dev/colab/main/beranda/page.tsx
@@ -1,14 +1,12 @@
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
import { Colab_Beranda } from "@/app_modules/colab";
-import colab_getListAllProyek from "@/app_modules/colab/fun/get/get_list_all_proyek";
export default async function Page() {
- const listData = await colab_getListAllProyek({ page: 1 });
const userLoginId = await funGetUserIdByToken();
return (
<>
-
+
>
);
}
diff --git a/src/app/dev/colab/main/grup/page.tsx b/src/app/dev/colab/main/grup/page.tsx
index 2d9237a9..d6069ea9 100644
--- a/src/app/dev/colab/main/grup/page.tsx
+++ b/src/app/dev/colab/main/grup/page.tsx
@@ -1,12 +1,10 @@
-import colab_getListRoomChatByAuthorId from "@/app_modules/colab/fun/get/room_chat/get_list_room_by_author_id";
import Colab_GrupDiskus from "@/app_modules/colab/main/grup";
export default async function Page() {
- const listRoom = await colab_getListRoomChatByAuthorId({page: 1});
-
+ // const listRoom = await colab_getListRoomChatByAuthorId({page: 1});
return (
<>
-
+
>
);
}
diff --git a/src/app/dev/colab/main/proyek/page.tsx b/src/app/dev/colab/main/proyek/page.tsx
index abb00e7e..9b4e35ee 100644
--- a/src/app/dev/colab/main/proyek/page.tsx
+++ b/src/app/dev/colab/main/proyek/page.tsx
@@ -1,17 +1,12 @@
import { Colab_Proyek } from "@/app_modules/colab";
-import colab_getListPartisipasiProyekByAuthorId from "@/app_modules/colab/fun/get/pasrtisipan/get_list_partisipasi_proyek_by_author_id";
-import colab_getListAllProyekSayaByAuthorId from "@/app_modules/colab/fun/get/pasrtisipan/get_list_proyek_saya_by_author_id";
export default async function Page() {
- const listPartisipasiProyek = await colab_getListPartisipasiProyekByAuthorId({page: 1})
- const listProyekSaya = await colab_getListAllProyekSayaByAuthorId({page: 1})
+ // const listPartisipasiProyek = await colab_getListPartisipasiProyekByAuthorId({page: 1})
+ // const listProyekSaya = await colab_getListAllProyekSayaByAuthorId({page: 1})
return (
<>
-
+
>
);
}
diff --git a/src/app/dev/donasi/detail/draft/[id]/page.tsx b/src/app/dev/donasi/detail/draft/[id]/page.tsx
index f15353f6..c251cc42 100644
--- a/src/app/dev/donasi/detail/draft/[id]/page.tsx
+++ b/src/app/dev/donasi/detail/draft/[id]/page.tsx
@@ -4,6 +4,7 @@ import { Donasi_getOneById } from "@/app_modules/donasi/fun/get/get_one_donasi_b
export default async function Page({ params }: { params: { id: string } }) {
const donasiId = params.id
const dataDonasi = await Donasi_getOneById(donasiId);
+
return (
<>
diff --git a/src/app/dev/katalog/[id]/layout.tsx b/src/app/dev/katalog/[id]/layout.tsx
index 98b718f6..79911004 100644
--- a/src/app/dev/katalog/[id]/layout.tsx
+++ b/src/app/dev/katalog/[id]/layout.tsx
@@ -1,24 +1,12 @@
+import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
import { LayoutKatalogNew } from "@/app_modules/katalog/main";
-export default async function Layout({ children, params, }: { children: any; params: { id: string } }) {
- // const profileId = params.id;
- // const dataProfile = await Profile_getOneProfileAndUserById(profileId);
- // const authorId = dataProfile?.userId;
-
- // const userLoginId = await funGetUserIdByToken();
- // const userRoleId = dataProfile?.User?.masterUserRoleId;
+export default async function Layout({ children }: { children: any }) {
+ const userLoginId = await funGetUserIdByToken();
return (
<>
- {/*
- {children}
- */}
- {children}
+ {children}
>
);
}
diff --git a/src/app/dev/katalog/[id]/page.tsx b/src/app/dev/katalog/[id]/page.tsx
index 98ab33e3..997d4b80 100644
--- a/src/app/dev/katalog/[id]/page.tsx
+++ b/src/app/dev/katalog/[id]/page.tsx
@@ -1,20 +1,8 @@
import { ViewKatalogNew } from "@/app_modules/katalog";
-export default async function Page({ params }: { params: { id: string } }) {
- // let profileId = params.id;
- // const userLoginId = await funGetUserIdByToken();
-
- // const listPorto = await funGetListPortofolio(profileId);
- // const dataProfile = await Profile_getOneProfileAndUserById(profileId);
-
+export default async function Page() {
return (
<>
- {/* */}
-
>
);
diff --git a/src/app/dev/portofolio/daftar-portofolio/[id]/page.tsx b/src/app/dev/portofolio/daftar-portofolio/[id]/page.tsx
index 2252757b..5b2146ad 100644
--- a/src/app/dev/portofolio/daftar-portofolio/[id]/page.tsx
+++ b/src/app/dev/portofolio/daftar-portofolio/[id]/page.tsx
@@ -1,16 +1,8 @@
import { ListDetailPortofolioNew } from "@/app_modules/katalog/portofolio";
-export default async function Page({ params }: { params: { id: string } }) {
- // const profileId = params.id;
- // const dataPortofolio = await portofolio_funGetAllDaftarByid({
- // profileId,
- // page: 1,
- // });
-
-
+export default async function Page() {
return (
<>
- {/* */}
>
);
diff --git a/src/app/dev/portofolio/main/[id]/layout.tsx b/src/app/dev/portofolio/main/[id]/layout.tsx
index 1be53c84..b6c68e76 100644
--- a/src/app/dev/portofolio/main/[id]/layout.tsx
+++ b/src/app/dev/portofolio/main/[id]/layout.tsx
@@ -1,20 +1,14 @@
+import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
import { PortofolioLayoutNew } from "@/app_modules/katalog/portofolio";
-export default async function Layout({ children, params, }: { children: any; params: { id: string }; }) {
- // let portoId = params.id;
- // const getPorto = await portofolio_getOneById(portoId);
- // const userLoginId = await funGetUserIdByToken();
+export default async function Layout({ children, }: { children: any; }) {
+ const userLoginId = await funGetUserIdByToken();
return (
<>
- {/*
+
{children}
- */}
- {children}
+
>
);
}
diff --git a/src/app/dev/portofolio/main/[id]/page.tsx b/src/app/dev/portofolio/main/[id]/page.tsx
index ab45a811..741c8aff 100644
--- a/src/app/dev/portofolio/main/[id]/page.tsx
+++ b/src/app/dev/portofolio/main/[id]/page.tsx
@@ -1,19 +1,16 @@
+import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
import { Portofolio_UiDetailNew } from "@/app_modules/katalog/portofolio";
const mapboxToken = process.env.MAPBOX_TOKEN!;
-export default async function Page({ params }: { params: { id: string } }) {
- // const portofolioId = params.id;
- // const dataPortofolio = await portofolio_getOneById(portofolioId);
- // const userLoginId = await funGetUserIdByToken();
+export default async function Page() {
+ const userLoginId = await funGetUserIdByToken()
return (
<>
- {/* */}
-
+ userLoginId={userLoginId}
+ />
>
);
}
diff --git a/src/app/dev/vote/detail/kontribusi/[id]/page.tsx b/src/app/dev/vote/detail/kontribusi/[id]/page.tsx
index d42fc576..06ad3e1d 100644
--- a/src/app/dev/vote/detail/kontribusi/[id]/page.tsx
+++ b/src/app/dev/vote/detail/kontribusi/[id]/page.tsx
@@ -1,13 +1,9 @@
import { Vote_DetailKontribusi } from "@/app_modules/vote";
-import { voting_funGetOneVotingbyId } from "@/app_modules/vote/fun/get/fun_get_one_by_id";
-
-export default async function Page({ params }: { params: { id: string } }) {
- let voteId = params.id;
- const dataVote = await voting_funGetOneVotingbyId(voteId);
+export default async function Page() {
return (
<>
-
+
>
);
}
diff --git a/src/app/dev/vote/detail/main/[id]/page.tsx b/src/app/dev/vote/detail/main/[id]/page.tsx
index 19084182..b26b402a 100644
--- a/src/app/dev/vote/detail/main/[id]/page.tsx
+++ b/src/app/dev/vote/detail/main/[id]/page.tsx
@@ -2,7 +2,6 @@ import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
import { Vote_MainDetail } from "@/app_modules/vote";
export default async function Page({ params }: { params: { id: string } }) {
- const voteId = params.id;
const userLoginId = await funGetUserIdByToken();
return (
<>
diff --git a/src/app/dev/vote/detail/semua_riwayat/[id]/page.tsx b/src/app/dev/vote/detail/semua_riwayat/[id]/page.tsx
index 6d943acd..e4637b7d 100644
--- a/src/app/dev/vote/detail/semua_riwayat/[id]/page.tsx
+++ b/src/app/dev/vote/detail/semua_riwayat/[id]/page.tsx
@@ -1,19 +1,9 @@
import { Vote_DetailSemuaRiwayat } from "@/app_modules/vote";
-import { Vote_getListKontributorById } from "@/app_modules/vote/fun/get/get_list_kontributor_by_id";
-import { Vote_getOnePublishbyId } from "@/app_modules/vote/fun/get/get_one_publish_by_id";
-
-
-export default async function Page({params}: {params: {id: string}}) {
- let voteId = params.id
- const dataVote = await Vote_getOnePublishbyId(voteId)
- const listKontributor = await Vote_getListKontributorById(voteId)
+export default async function Page() {
return (
<>
-
+
>
);
}
diff --git a/src/app/lib/global_state.ts b/src/app/lib/global_state.ts
index d8792fc0..4efaf286 100644
--- a/src/app/lib/global_state.ts
+++ b/src/app/lib/global_state.ts
@@ -19,27 +19,30 @@ export type ITypeStatusNotifikasi =
| "Menunggu"
| "Gagal";
-
/**
* @param kategoriApp | "JOB", "VOTING", "EVENT", "DONASI", "INVESTASI", "COLLABORATION", "FORUM"
* @type string
*/
export type IRealtimeData = {
status?: ITypeStatusNotifikasi;
- appId: string;
+ appId?: string;
userId: string;
- pesan: string;
- title: string;
- kategoriApp:
+ pesan?: string;
+ title?: string;
+ kategoriApp?:
| "JOB"
| "VOTING"
| "EVENT"
| "DONASI"
| "INVESTASI"
| "COLLABORATION"
- | "FORUM";
+ | "FORUM"
+ | "ACCESS"; // Untuk trigger akses user
};
+// Access User
+export const gs_access_user = atom(false);
+
export const gs_realtimeData = atom(null);
export const gs_admin_ntf = atom(0);
export const gs_user_ntf = atom(0);
@@ -63,4 +66,4 @@ export const gs_donasiTriggerBeranda = atom(false);
// investasi
export const gs_adminInvestasi_triggerReview = atom(false);
-export const gs_investasiTriggerBeranda = atom(false);
\ No newline at end of file
+export const gs_investasiTriggerBeranda = atom(false);
diff --git a/src/app/lib/id-derectory.ts b/src/app/lib/id-derectory.ts
index dc430470..f2c1303f 100644
--- a/src/app/lib/id-derectory.ts
+++ b/src/app/lib/id-derectory.ts
@@ -1,6 +1,6 @@
const DIRECTORY_ID = {
- profile_foto: "cm0x93rgo000jbp5tj8baoaus",
- profile_background: "cm0x93ze8000lbp5t1a8uc9wl",
+ profile_foto: "cm5ni43ub001pxpug0qw4p11e",
+ profile_background: "cm5ni4hnq001l12p9gpagxgtv",
portofolio_logo: "cm0yjl6ug000310njwmk6j0tx",
map_pin: "cm0yjq8up000710njv5klra32",
map_image: "cm0yjqnxl000910njplqho07w",
diff --git a/src/app/lib/realtime_provider.tsx b/src/app/lib/realtime_provider.tsx
index 6ae944d7..d85d0186 100644
--- a/src/app/lib/realtime_provider.tsx
+++ b/src/app/lib/realtime_provider.tsx
@@ -4,6 +4,7 @@ import { useShallowEffect } from "@mantine/hooks";
import { useAtom } from "jotai";
import { WibuRealtime } from "wibu-pkg";
import {
+ gs_access_user,
gs_admin_ntf,
gs_adminDonasi_triggerReview,
gs_adminEvent_triggerReview,
@@ -31,6 +32,9 @@ export type TypeNotification = {
userId?: string;
};
+// Tambahkan flag global untuk mencegah inisialisasi ulang
+let isWibuRealtimeInitialized = false;
+
export default function RealtimeProvider({
userId,
WIBU_REALTIME_TOKEN,
@@ -42,6 +46,9 @@ export default function RealtimeProvider({
const [newAdminNtf, setNewAdminNtf] = useAtom(gs_admin_ntf);
const [newUserNtf, setNewUserNtf] = useAtom(gs_user_ntf);
+ // ACCESS USER
+ const [isAccessUser, setIsAccessUser] = useAtom(gs_access_user);
+
// JOB
const [isTriggerJobBeranda, setIsTriggerJobBeranda] =
useAtom(gs_jobTiggerBeranda);
@@ -83,152 +90,168 @@ export default function RealtimeProvider({
useShallowEffect(() => {
try {
- WibuRealtime.init({
- project: "hipmi",
- WIBU_REALTIME_TOKEN: WIBU_REALTIME_TOKEN,
- onData(data: TypeNotification) {
- if (
- data.type == "notification" &&
- data.pushNotificationTo == "ADMIN"
- ) {
- setNewAdminNtf((e) => e + 1);
- }
+ if (!isWibuRealtimeInitialized) {
+ WibuRealtime.init({
+ project: "hipmi",
+ WIBU_REALTIME_TOKEN: WIBU_REALTIME_TOKEN,
+ onData(data: TypeNotification) {
+ // Notifikasi ke admin
+ if (
+ data.type == "notification" &&
+ data.pushNotificationTo == "ADMIN"
+ ) {
+ setNewAdminNtf((e) => e + 1);
+ }
- // Notifikasi ke semua user , yang datanya di acc admin
- if (
- data.type == "notification" &&
- data.pushNotificationTo == "USER" &&
- data.dataMessage?.userId == userId
- ) {
- setNewUserNtf((e) => e + 1);
- setDataRealtime(data.dataMessage as any);
- }
+ // trigger access
+ if (
+ data.type == "trigger" &&
+ data.pushNotificationTo == "USER" &&
+ data.dataMessage?.kategoriApp == "ACCESS" &&
+ data.dataMessage?.userId == userId
+ ) {
+ setIsAccessUser(data.dataMessage.status as any);
+ }
- // ---------------------- JOB ------------------------- //
- if (
- data.type == "trigger" &&
- data.pushNotificationTo == "ADMIN" &&
- data.dataMessage?.kategoriApp == "JOB"
- ) {
- setIsAdminJob_TriggerReview(true);
- }
+ // Notifikasi ke semua user , yang datanya di acc admin
+ if (
+ data.type == "notification" &&
+ data.pushNotificationTo == "USER" &&
+ data.dataMessage?.userId == userId
+ ) {
+ setNewUserNtf((e) => e + 1);
+ setDataRealtime(data.dataMessage as any);
+ }
- if (
- data.type == "trigger" &&
- data.pushNotificationTo == "USER" &&
- data.dataMessage?.kategoriApp == "JOB" &&
- data.dataMessage.status == "Publish"
- ) {
- setIsTriggerJobBeranda(true);
- }
- // ---------------------- JOB ------------------------- //
+ // ---------------------- JOB ------------------------- //
+ if (
+ data.type == "trigger" &&
+ data.pushNotificationTo == "ADMIN" &&
+ data.dataMessage?.kategoriApp == "JOB"
+ ) {
+ setIsAdminJob_TriggerReview(true);
+ }
- // ---------------------- EVENT ------------------------- //
- if (
- data.type == "trigger" &&
- data.pushNotificationTo == "ADMIN" &&
- data.dataMessage?.kategoriApp == "EVENT"
- ) {
- setIsAdminEvent_TriggerReview(true);
- }
+ if (
+ data.type == "trigger" &&
+ data.pushNotificationTo == "USER" &&
+ data.dataMessage?.kategoriApp == "JOB" &&
+ data.dataMessage.status == "Publish"
+ ) {
+ setIsTriggerJobBeranda(true);
+ }
+ // ---------------------- JOB ------------------------- //
- if (
- data.type == "trigger" &&
- data.pushNotificationTo == "USER" &&
- data.dataMessage?.kategoriApp == "EVENT" &&
- data.dataMessage.status == "Publish"
- ) {
- setIsTriggerEventBeranda(true);
- }
+ // ---------------------- EVENT ------------------------- //
+ if (
+ data.type == "trigger" &&
+ data.pushNotificationTo == "ADMIN" &&
+ data.dataMessage?.kategoriApp == "EVENT"
+ ) {
+ setIsAdminEvent_TriggerReview(true);
+ }
- if (
- data.type == "notification" &&
- data.pushNotificationTo == "USER" &&
- data.dataMessage?.status == "Peserta Event" &&
- userId !== data.dataMessage?.userId
- ) {
- setNewUserNtf((e) => e + 1);
- }
- // ---------------------- EVENT ------------------------- //
+ if (
+ data.type == "trigger" &&
+ data.pushNotificationTo == "USER" &&
+ data.dataMessage?.kategoriApp == "EVENT" &&
+ data.dataMessage.status == "Publish"
+ ) {
+ setIsTriggerEventBeranda(true);
+ }
- // ---------------------- VOTING ------------------------- //
- if (
- data.type == "trigger" &&
- data.pushNotificationTo == "ADMIN" &&
- data.dataMessage?.kategoriApp == "VOTING"
- ) {
- setIsAdminVoting_TriggerReview(true);
- }
+ if (
+ data.type == "notification" &&
+ data.pushNotificationTo == "USER" &&
+ data.dataMessage?.status == "Peserta Event" &&
+ userId !== data.dataMessage?.userId
+ ) {
+ setNewUserNtf((e) => e + 1);
+ }
+ // ---------------------- EVENT ------------------------- //
- if (
- data.type == "trigger" &&
- data.pushNotificationTo == "USER" &&
- data.dataMessage?.kategoriApp == "VOTING" &&
- data.dataMessage.status == "Publish"
- ) {
- setIsTriggerVotingBeranda(true);
- }
+ // ---------------------- VOTING ------------------------- //
+ if (
+ data.type == "trigger" &&
+ data.pushNotificationTo == "ADMIN" &&
+ data.dataMessage?.kategoriApp == "VOTING"
+ ) {
+ setIsAdminVoting_TriggerReview(true);
+ }
- if (
- data.type == "notification" &&
- data.pushNotificationTo == "USER" &&
- data.dataMessage?.status == "Voting Masuk" &&
- userId !== data.dataMessage?.userId
- ) {
- setNewUserNtf((e) => e + 1);
- }
- // ---------------------- VOTING ------------------------- //
+ if (
+ data.type == "trigger" &&
+ data.pushNotificationTo == "USER" &&
+ data.dataMessage?.kategoriApp == "VOTING" &&
+ data.dataMessage.status == "Publish"
+ ) {
+ setIsTriggerVotingBeranda(true);
+ }
- // ---------------------- DONASI ------------------------- //
- if (
- data.type == "trigger" &&
- data.pushNotificationTo == "ADMIN" &&
- data.dataMessage?.kategoriApp == "DONASI"
- ) {
- setIsAdminDonasi_TriggerReview(true);
- }
+ if (
+ data.type == "notification" &&
+ data.pushNotificationTo == "USER" &&
+ data.dataMessage?.status == "Voting Masuk" &&
+ userId !== data.dataMessage?.userId
+ ) {
+ setNewUserNtf((e) => e + 1);
+ }
+ // ---------------------- VOTING ------------------------- //
- if (
- data.type == "trigger" &&
- data.pushNotificationTo == "USER" &&
- data.dataMessage?.kategoriApp == "DONASI" &&
- data.dataMessage.status == "Publish"
- ) {
- setIsTriggerDonasiBeranda(true);
- }
+ // ---------------------- DONASI ------------------------- //
+ if (
+ data.type == "trigger" &&
+ data.pushNotificationTo == "ADMIN" &&
+ data.dataMessage?.kategoriApp == "DONASI"
+ ) {
+ setIsAdminDonasi_TriggerReview(true);
+ }
- // if (
- // data.type == "notification" &&
- // data.pushNotificationTo == "ADMIN" &&
- // data.dataMessage?.status == "Menunggu" &&
- // userId !== data.dataMessage?.userId
- // ) {
+ if (
+ data.type == "trigger" &&
+ data.pushNotificationTo == "USER" &&
+ data.dataMessage?.kategoriApp == "DONASI" &&
+ data.dataMessage.status == "Publish"
+ ) {
+ setIsTriggerDonasiBeranda(true);
+ }
- // }
- // ---------------------- DONASI ------------------------- //
+ // if (
+ // data.type == "notification" &&
+ // data.pushNotificationTo == "ADMIN" &&
+ // data.dataMessage?.status == "Menunggu" &&
+ // userId !== data.dataMessage?.userId
+ // ) {
- // ---------------------- INVESTASI ------------------------- //
+ // }
+ // ---------------------- DONASI ------------------------- //
- if (
- data.type == "trigger" &&
- data.pushNotificationTo == "ADMIN" &&
- data.dataMessage?.kategoriApp == "INVESTASI"
- ) {
- setIsAdminInvestasi_TriggerReview(true);
- }
+ // ---------------------- INVESTASI ------------------------- //
- if (
- data.type == "trigger" &&
- data.pushNotificationTo == "USER" &&
- data.dataMessage?.kategoriApp == "INVESTASI" &&
- data.dataMessage.status == "Publish"
- ) {
- setIsTriggerInvestasiBeranda(true);
- }
+ if (
+ data.type == "trigger" &&
+ data.pushNotificationTo == "ADMIN" &&
+ data.dataMessage?.kategoriApp == "INVESTASI"
+ ) {
+ setIsAdminInvestasi_TriggerReview(true);
+ }
- // ---------------------- INVESTASI ------------------------- //
- },
- });
+ if (
+ data.type == "trigger" &&
+ data.pushNotificationTo == "USER" &&
+ data.dataMessage?.kategoriApp == "INVESTASI" &&
+ data.dataMessage.status == "Publish"
+ ) {
+ setIsTriggerInvestasiBeranda(true);
+ }
+
+ // ---------------------- INVESTASI ------------------------- //
+ },
+ });
+
+ // Tandai bahwa WibuRealtime telah diinisialisasi
+ isWibuRealtimeInitialized = true;
+ }
} catch (error) {
console.log("Error Realtime:", error);
}
diff --git a/src/app/lib/router_hipmi/router_investasi.ts b/src/app/lib/router_hipmi/router_investasi.ts
index 7d185e12..6eec841f 100644
--- a/src/app/lib/router_hipmi/router_investasi.ts
+++ b/src/app/lib/router_hipmi/router_investasi.ts
@@ -8,8 +8,8 @@ export const NEW_RouterInvestasi = {
* @param param status id | 1: Publish, 2: Review, 3: Draft, 4: Reject
* @type string
*/
- portofolio: ({ id }: { id: "1" | "2" | "3" | "4" }) =>
- `/dev/investasi/main/portofolio/${id}`,
+ portofolio: ({ id }: { id: "1" | "2" | "3" | "4" }) => `/dev/investasi/main/portofolio/${id}`,
+ // portofolio: ({ id }: { id?: string }) => `/dev/investasi/main/portofolio/${id}`,
// TRANSAKSI
pembelian: "/dev/investasi/transaksi/pembelian/",
diff --git a/src/app/zCoba/skeleton/page.tsx b/src/app/zCoba/skeleton/page.tsx
index a25e6542..a5b62d10 100644
--- a/src/app/zCoba/skeleton/page.tsx
+++ b/src/app/zCoba/skeleton/page.tsx
@@ -5,7 +5,8 @@ import {
UIGlobal_LayoutHeaderTamplate,
UIGlobal_LayoutTamplate,
} from "@/app_modules/_global/ui";
-import { Center, Grid, Group, Skeleton, Stack } from "@mantine/core";
+import { Button, Grid, Skeleton, Stack } from "@mantine/core";
+import Link from "next/link";
export default function Voting_ComponentSkeletonViewPuh() {
return (
@@ -13,8 +14,44 @@ export default function Voting_ComponentSkeletonViewPuh() {
}
>
+
+
+
+
+
+ {Array.from(new Array(2)).map((e, i) => (
+
+
+
+
+
+
+
+
+ ))}
+
+
+
+ {/*
@@ -23,12 +60,35 @@ export default function Voting_ComponentSkeletonViewPuh() {
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+ */}
{/*
diff --git a/src/app/zCoba/upload/fun_upload.ts b/src/app/zCoba/upload/fun_upload.ts
new file mode 100644
index 00000000..baa3e4e2
--- /dev/null
+++ b/src/app/zCoba/upload/fun_upload.ts
@@ -0,0 +1,52 @@
+"use server";
+
+import _ from "lodash";
+// import { v4 } from "uuid";
+import fs from "fs";
+import sharp from "sharp";
+
+export default async function fun_upload({
+ file,
+ dirId,
+}: {
+ file: File;
+ dirId: string;
+}) {
+ // const file: any = formData.get("file");
+ // const fName = file.name;
+ // const fileSize = file.size;
+
+ // // Convert ke KB
+ // const fileSizeInKB = fileSize / 1024;
+
+ // // Convert ke MB
+ // const fileSizeInMB = fileSize / (1024 * 1024);
+
+ // console.log(`Ukuran file dalam bytes: ${fileSize}`);
+ // console.log(`Ukuran file dalam KB: ${fileSizeInKB.toFixed(2)} KB`);
+ // console.log(`Ukuran file dalam MB: ${fileSizeInMB.toFixed(2)} MB`);
+
+ const imageBuffer = await file.arrayBuffer();
+ const resize = await sharp(imageBuffer).resize(2000).toBuffer();
+
+ const newFile = Buffer.from(resize);
+ console.log("file new",newFile);
+ // fs.writeFileSync(`./public/upload/${fName}`, upFolder as any);
+
+ const formData = new FormData();
+ formData.append("file", file);
+ formData.append("dirId", dirId);
+
+ // const upload = await fetch("/api/image/upload", {
+ // method: "POST",
+ // body: formData,
+ // });
+
+ // const res = await upload.json();
+
+ // if (upload.ok) {
+ // return { success: true, data: res.data, message: res.message };
+ // } else {
+ // return { success: false, data: {}, message: res.message };
+ // }
+}
diff --git a/src/app/zCoba/upload/page.tsx b/src/app/zCoba/upload/page.tsx
new file mode 100644
index 00000000..26b6bfdc
--- /dev/null
+++ b/src/app/zCoba/upload/page.tsx
@@ -0,0 +1,137 @@
+"use client";
+
+import { MainColor } from "@/app_modules/_global/color";
+import { ComponentGlobal_BoxUploadImage } from "@/app_modules/_global/component";
+import { MAX_SIZE } from "@/app_modules/_global/lib";
+import { PemberitahuanMaksimalFile } from "@/app_modules/_global/lib/max_size";
+import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global";
+import {
+ UIGlobal_LayoutHeaderTamplate,
+ UIGlobal_LayoutTamplate,
+} from "@/app_modules/_global/ui";
+import { clientLogger } from "@/util/clientLogger";
+import {
+ AspectRatio,
+ Button,
+ Center,
+ FileButton,
+ Image,
+ Stack,
+} from "@mantine/core";
+import { IconImageInPicture, IconUpload } from "@tabler/icons-react";
+import { useState } from "react";
+import fun_upload from "./fun_upload";
+import { funGlobal_UploadToStorage } from "@/app_modules/_global/fun";
+
+export default function Page() {
+ return (
+ <>
+ }
+ >
+
+
+ >
+ );
+}
+
+function Upload() {
+ const [file, setFile] = useState(null);
+ const [image, setImage] = useState(null);
+ const [isLoading, setLoading] = useState(false);
+
+ async function onUpload() {
+ if (!file) return alert("File Kosong");
+ try {
+ setLoading(true);
+ const formData = new FormData();
+ formData.append("file", file as File);
+
+ const uploadPhoto = await funGlobal_UploadToStorage({
+ file: file,
+ dirId: "cm5ohsepe002bq4nlxeejhg7q",
+ });
+
+ if (uploadPhoto.success) {
+ setLoading(false);
+ alert("berhasil upload");
+ console.log("uploadPhoto", uploadPhoto);
+ } else {
+ setLoading(false);
+ console.log("gagal upload", uploadPhoto);
+ }
+ } catch (error) {
+ console.error("Error upload img:", error);
+ }
+ }
+
+ return (
+ <>
+
+
+ {image ? (
+
+
+
+ ) : (
+
+
+
+ )}
+
+
+
+ {
+ try {
+ const buffer = URL.createObjectURL(
+ new Blob([new Uint8Array(await files.arrayBuffer())])
+ );
+
+ // if (files.size > MAX_SIZE) {
+ // ComponentGlobal_NotifikasiPeringatan(
+ // PemberitahuanMaksimalFile
+ // );
+ // return;
+ // } else {
+
+ // }
+
+ console.log("ini buffer", buffer);
+
+ setFile(files);
+ setImage(buffer);
+ } catch (error) {
+ clientLogger.error("Upload error:", error);
+ }
+ }}
+ accept="image/png,image/jpeg"
+ >
+ {(props) => (
+ }
+ bg={MainColor.yellow}
+ color="yellow"
+ c={"black"}
+ >
+ Upload
+
+ )}
+
+
+
+
+
+ >
+ );
+}
diff --git a/src/app_modules/_global/button/comp_button_upload_photo.tsx b/src/app_modules/_global/button/comp_button_upload_photo.tsx
index 378e7126..fa1185d0 100644
--- a/src/app_modules/_global/button/comp_button_upload_photo.tsx
+++ b/src/app_modules/_global/button/comp_button_upload_photo.tsx
@@ -1,12 +1,10 @@
"use client";
+import { clientLogger } from "@/util/clientLogger";
import { Button, FileButton } from "@mantine/core";
import { IconCamera } from "@tabler/icons-react";
+import { useState } from "react";
import { MainColor } from "../color";
-import { MAX_SIZE } from "../lib";
-import { PemberitahuanMaksimalFile } from "../lib/max_size";
-import { ComponentGlobal_NotifikasiPeringatan } from "../notif_global";
-import { clientLogger } from "@/util/clientLogger";
export function ComponentGlobal_ButtonUploadFileImage({
onSetFile,
@@ -15,22 +13,27 @@ export function ComponentGlobal_ButtonUploadFileImage({
onSetFile: File | any;
onSetImage: any | null;
}) {
+ const [isLoading, setIsLoading] = useState(false);
+
return (
{
try {
+ setIsLoading(true);
const buffer = URL.createObjectURL(
new Blob([new Uint8Array(await files.arrayBuffer())])
);
- if (files.size > MAX_SIZE) {
- ComponentGlobal_NotifikasiPeringatan(PemberitahuanMaksimalFile);
- return;
- } else {
- onSetFile(files);
- onSetImage(buffer);
- }
+ // if (files.size > MAX_SIZE) {
+ // ComponentGlobal_NotifikasiPeringatan(PemberitahuanMaksimalFile);
+ // return;
+ // } else {
+ // }
+ onSetFile(files);
+ onSetImage(buffer);
+ setIsLoading(false);
} catch (error) {
+ setIsLoading(false);
clientLogger.error("Upload error:", error);
}
}}
@@ -39,6 +42,8 @@ export function ComponentGlobal_ButtonUploadFileImage({
{(props) => (
}
bg={MainColor.yellow}
diff --git a/src/app_modules/_global/color/color_pallet.ts b/src/app_modules/_global/color/color_pallet.ts
index 6b417815..658e509e 100644
--- a/src/app_modules/_global/color/color_pallet.ts
+++ b/src/app_modules/_global/color/color_pallet.ts
@@ -3,8 +3,10 @@ export const MainColor = {
darkblue: "#001D3D",
yellow: "#E1B525",
white: "#D4D0D0",
- red: "#C74E4E",
- orange: "#E58958"
+ red: "#FF4B4C",
+ orange: "#FF7043",
+ green: "#4CAF4F",
+ login: "#EDEBEBFF"
};
export const AccentColor = {
@@ -13,7 +15,11 @@ export const AccentColor = {
blue: "#00447D",
softblue: "#007CBA",
skyblue: "#00BFFF",
- yellow: "#E1B525",
+ yellow: "#F8A824",
+ white: "#FEFFFE"
+
};
//yellow: "#FFC300"
//yellow: "#FFD60A"
+// white: "#FEFFFE"
+
diff --git a/src/app_modules/_global/component/comp_avatar_and_username.tsx b/src/app_modules/_global/component/comp_avatar_and_username.tsx
index 22ffc8b8..b1176b21 100644
--- a/src/app_modules/_global/component/comp_avatar_and_username.tsx
+++ b/src/app_modules/_global/component/comp_avatar_and_username.tsx
@@ -47,7 +47,7 @@ export function ComponentGlobal_AvatarAndUsername({
onClick={() => onCheckProfile()}
>
{visible ? (
-
+
) : (
@@ -63,7 +63,7 @@ export function ComponentGlobal_AvatarAndUsername({
onCheckProfile()}
>
diff --git a/src/app_modules/_global/component/comp_card_box_and_background.tsx b/src/app_modules/_global/component/comp_card_box_and_background.tsx
index c3064edd..7d724c24 100644
--- a/src/app_modules/_global/component/comp_card_box_and_background.tsx
+++ b/src/app_modules/_global/component/comp_card_box_and_background.tsx
@@ -1,7 +1,21 @@
-import { AccentColor } from "@/app_modules/_global/color";
+import { AccentColor, MainColor } from "@/app_modules/_global/color";
import { Card } from "@mantine/core";
import React from "react";
+/**
+ * ComponentGlobal_CardStyles
+ *
+ * A React component that renders a customizable card element.
+ *
+ * Props:
+ * - children (React.ReactNode): Content to be displayed inside the card.
+ * - backgroundColor (string, optional): Background color of the card. Defaults to AccentColor.darkblue.
+ * - border (string, optional): Border color of the card. Defaults to AccentColor.blue.
+ * - marginBottom (string | number, optional): Margin below the card. Defaults to "15px".
+ * - height (string | number, optional): Height of the card. Defaults to "auto".
+ * - color (string, optional): Text color inside the card. Defaults to MainColor.white.
+ * - onClickHandler (React.MouseEventHandler, optional): Function to handle click events on the card.
+ */
export function ComponentGlobal_CardStyles({
children,
backgroundColor,
@@ -30,7 +44,7 @@ export function ComponentGlobal_CardStyles({
paddingInline: "16px",
paddingBlock: "16px",
borderRadius: "10px",
- color: color ? color : "white",
+ color: color ? color : MainColor.white,
height: height ? height : "auto",
marginBottom: marginBottom ? marginBottom : "15px",
}}
diff --git a/src/app_modules/_global/component/comp_load_image_landscape.tsx b/src/app_modules/_global/component/comp_load_image_landscape.tsx
index b121dc99..d8d1f9bb 100644
--- a/src/app_modules/_global/component/comp_load_image_landscape.tsx
+++ b/src/app_modules/_global/component/comp_load_image_landscape.tsx
@@ -3,10 +3,12 @@
import { APIs } from "@/app/lib";
import { pathAssetImage } from "@/app/lib/path_asset_image";
import { RouterImagePreview } from "@/app/lib";
-import { Center, Image, Skeleton } from "@mantine/core";
+import { Center, Image } from "@mantine/core";
import { useShallowEffect } from "@mantine/hooks";
import { useRouter } from "next/navigation";
import { useState } from "react";
+import { MainColor } from "../color";
+import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
export function ComponentGlobal_LoadImageLandscape({
fileId,
@@ -34,12 +36,12 @@ export function ComponentGlobal_LoadImageLandscape({
}
}
- if (isImage === null) return ;
+ if (isImage === null) return ;
if (!isImage)
return (
<>
-
+
{new Intl.NumberFormat("id-ID", { maximumFractionDigits: 10 }).format(
@@ -43,6 +44,9 @@ export default function ComponentGlobal_TampilanAngkaRatusan({
{textAfter}
diff --git a/src/app_modules/_global/component/comp_tampilan_rupiah.tsx b/src/app_modules/_global/component/comp_tampilan_rupiah.tsx
index 9271882f..e5baf1a3 100644
--- a/src/app_modules/_global/component/comp_tampilan_rupiah.tsx
+++ b/src/app_modules/_global/component/comp_tampilan_rupiah.tsx
@@ -1,4 +1,5 @@
import { Text } from "@mantine/core";
+import { MainColor } from "../color";
export default function ComponentGlobal_TampilanRupiah({
nominal,
@@ -17,7 +18,7 @@ export default function ComponentGlobal_TampilanRupiah({
fw={fontWeight ? fontWeight : "bold"}
fz={fontSize ? fontSize : "md"}
style={{
- color: color ? color : "white",
+ color: color ? color : MainColor.white,
}}
>
Rp.{" "}
diff --git a/src/app_modules/_global/fun/delete/fun_delete_file_by_id.tsx b/src/app_modules/_global/fun/delete/fun_delete_file_by_id.tsx
index cb3d48be..27e9c8a0 100644
--- a/src/app_modules/_global/fun/delete/fun_delete_file_by_id.tsx
+++ b/src/app_modules/_global/fun/delete/fun_delete_file_by_id.tsx
@@ -22,29 +22,7 @@ export async function funGlobal_DeleteFileById({
return { success: false, message: data.message };
}
} catch (error) {
- console.error("Upload error:", error);
+ clientLogger.error("Upload error:", error);
return { success: false, message: "An unexpected error occurred" };
}
- // try {
- // const res = await fetch(
- // `https://wibu-storage.wibudev.com/api/files/${fileId}/delete`,
- // {
- // method: "DELETE",
- // headers: {
- // Authorization: `Bearer ${process.env.WS_APIKEY}`,
- // },
- // }
- // );
-
- // if (res.ok) {
- // const hasil = await res.json();
- // return { success: true, message: "File berhasil dihapus" };
- // } else {
- // const errorText = await res.json();
- // return { success: false, message: errorText.message };
- // }
- // } catch (error) {
- // console.error("Upload error:", error);
- // return { success: false, message: "An unexpected error occurred" };
- // }
}
diff --git a/src/app_modules/_global/fun/get/fun_get_user_id_by_token.ts b/src/app_modules/_global/fun/get/fun_get_user_id_by_token.ts
index 799c46c4..cfbdb1e2 100644
--- a/src/app_modules/_global/fun/get/fun_get_user_id_by_token.ts
+++ b/src/app_modules/_global/fun/get/fun_get_user_id_by_token.ts
@@ -1,6 +1,5 @@
"use server";
-import { jwtVerify } from "jose";
import { cookies } from "next/headers";
import { decrypt } from "../../../../app/auth/_lib/decrypt";
@@ -16,21 +15,3 @@ export async function funGetUserIdByToken() {
return cekUser?.id;
}
-// async function decrypt({
-// token,
-// encodedKey,
-// }: {
-// token: string;
-// encodedKey: string;
-// }): Promise | null> {
-// try {
-// const enc = new TextEncoder().encode(encodedKey);
-// const { payload } = await jwtVerify(token, enc, {
-// algorithms: ["HS256"],
-// });
-// return (payload.user as Record) || null;
-// } catch (error) {
-// console.error("Gagal verifikasi session", error);
-// return null;
-// }
-// }
diff --git a/src/app_modules/_global/fun/upload/fun_upload_to_storage.ts b/src/app_modules/_global/fun/upload/fun_upload_to_storage.ts
index 4af61f50..8df2359c 100644
--- a/src/app_modules/_global/fun/upload/fun_upload_to_storage.ts
+++ b/src/app_modules/_global/fun/upload/fun_upload_to_storage.ts
@@ -10,6 +10,10 @@ export async function funGlobal_UploadToStorage({
const Env_WS_APIKEY = TokenStorage.value;
const allowedMimeTypes = [
+ "image/heif", // Format HEIF standar
+ "image/heic", // Format HEIF untuk container HEIC
+ "image/heif-sequence", // Untuk sequence/animasi HEIF
+ "image/heic-sequence", // Untuk sequence/animasi HEIC
"image/png",
"image/jpeg",
"image/gif",
diff --git a/src/app_modules/_global/lib/api_image.ts b/src/app_modules/_global/lib/api_image.ts
new file mode 100644
index 00000000..23e35b78
--- /dev/null
+++ b/src/app_modules/_global/lib/api_image.ts
@@ -0,0 +1,16 @@
+export const apiDeleteImageById = async ({
+ fileId,
+ dirId,
+}: {
+ fileId: string;
+ dirId?: string;
+}) => {
+ const response = await fetch(`/api/image/delete`, {
+ method: "DELETE",
+ body: JSON.stringify({ fileId, dirId }),
+ });
+
+ console.log("delete api =>", await response.json());
+
+ return await response.json().catch(() => null);
+};
diff --git a/src/app_modules/_global/lib/api_user.ts b/src/app_modules/_global/lib/api_user.ts
new file mode 100644
index 00000000..b21ad919
--- /dev/null
+++ b/src/app_modules/_global/lib/api_user.ts
@@ -0,0 +1,39 @@
+export const apiGetUserId = async () => {
+ const { token } = await fetch("/api/get-cookie").then((res) => res.json());
+ if (!token) return await token.json().catch(() => null);
+
+ const response = await fetch(`/api/user`, {
+ headers: {
+ "Content-Type": "application/json",
+ Accept: "application/json",
+ "Access-Control-Allow-Origin": "*",
+ Authorization: `Bearer ${token}`,
+ },
+ });
+
+ console.log("Ini di pemanggilan API",await response.json());
+
+ if (!response.ok) return null;
+ const data: Record = await response.json();
+ return data;
+};
+
+export const apiGetCookiesUser = async () => {
+ const response = await fetch(`/api/user/get`);
+ return await response.json().catch(() => null);
+};
+
+export const apiGetACtivationUser = async () => {
+ const { token } = await fetch("/api/get-cookie").then((res) => res.json());
+ if (!token) return await token.json().catch(() => null);
+
+ const response = await fetch(`/api/user/activation`, {
+ headers: {
+ "Content-Type": "application/json",
+ Accept: "application/json",
+ "Access-Control-Allow-Origin": "*",
+ Authorization: `Bearer ${token}`,
+ },
+ });
+ return await response.json().catch(() => null);
+};
diff --git a/src/app_modules/_global/ui/ui_drawer.tsx b/src/app_modules/_global/ui/ui_drawer.tsx
index b1f51ef3..fad1cd9d 100644
--- a/src/app_modules/_global/ui/ui_drawer.tsx
+++ b/src/app_modules/_global/ui/ui_drawer.tsx
@@ -64,7 +64,7 @@ export default function UIGlobal_Drawer({
borderRight: `1px solid ${AccentColor.blue}`,
borderLeft: `1px solid ${AccentColor.blue}`,
borderRadius: "20px 20px 0px 0px",
- color: "white",
+ color: MainColor.white,
paddingBottom: "5%",
},
}}
@@ -86,7 +86,7 @@ export default function UIGlobal_Drawer({
>
{/* PAKE LOADING */}
{/* {isLoading && e?.id === pageId ? (
diff --git a/src/app_modules/admin/developer/index.tsx b/src/app_modules/admin/developer/index.tsx
index eb0bf165..481e636f 100644
--- a/src/app_modules/admin/developer/index.tsx
+++ b/src/app_modules/admin/developer/index.tsx
@@ -44,7 +44,7 @@ export default function AdminDeveloper({
return (
<>
-
+
{/*
- Table User NEW
+ Table User
}
radius={"xl"}
@@ -256,6 +256,10 @@ function NewTableAdmin({
search: isSearch,
page: isChoosePage,
});
+
+
+
+
setDataAdmin(loadData.data);
setNPage(loadData.nPage);
const loadDataUser = await adminDeveloper_funGetListAllUser({ page: 1 });
diff --git a/src/app_modules/admin/new_list_page.tsx b/src/app_modules/admin/new_list_page.tsx
index b9ab8119..ae940513 100644
--- a/src/app_modules/admin/new_list_page.tsx
+++ b/src/app_modules/admin/new_list_page.tsx
@@ -297,10 +297,10 @@ export const newListAdminPage = [
child: [],
},
- // Developer
+ // Developer | Super Admin
{
- id: "Developer",
- name: "Developer",
+ id: "Super Admin",
+ name: "Super Admin",
path: RouterAdminDeveloper.main,
icon: ,
child: [],
diff --git a/src/app_modules/admin/user-access/fun/edit/fun_edit_access.ts b/src/app_modules/admin/user-access/fun/edit/fun_edit_access.ts
index a8a9dc15..46e4703d 100644
--- a/src/app_modules/admin/user-access/fun/edit/fun_edit_access.ts
+++ b/src/app_modules/admin/user-access/fun/edit/fun_edit_access.ts
@@ -1,11 +1,14 @@
"use server";
import prisma from "@/app/lib/prisma";
+import backendLogger from "@/util/backendLogger";
import { revalidatePath } from "next/cache";
+import { headers } from "next/headers";
export default async function adminUserAccess_funEditAccess(
userId: string,
- value: boolean
+ value: boolean,
+ nomor?: string
) {
const updt = await prisma.user.update({
where: {
@@ -16,6 +19,31 @@ export default async function adminUserAccess_funEditAccess(
},
});
+ const headersList = headers();
+ const host = headersList.get("host");
+ const protocol = headersList.get("x-forwarded-proto") || "http";
+ const path = headersList.get("x-invoke-path");
+ const baseUrl = `${protocol}://${host}`;
+ // const fullUrl = `${protocol}://${host}${path}`;
+
+ if (value === true) {
+ const message = `Hallo rekan HIPMI, Anda telah diberikan akses ke HIPMI Apps. Silakan mulai jelajahi fitur-fitur yang tersedia melalui link berikut: ${baseUrl}`;
+ const encodedMessage = encodeURIComponent(message);
+
+ const res = await fetch(
+ `https://wa.wibudev.com/code?nom=${nomor}&text=${encodedMessage}
+ `
+ );
+
+ if (!res.ok) {
+ backendLogger.error("Error send message", res);
+ }
+
+ const result = await res.json();
+
+ backendLogger.info("Success send message", result);
+ }
+
if (!updt) return { status: 400, message: "Update gagal" };
revalidatePath("/dev/admin/user-access");
return { status: 200, message: "Update berhasil" };
diff --git a/src/app_modules/admin/user-access/view/index.tsx b/src/app_modules/admin/user-access/view/index.tsx
index 06c97ad4..9a23c1e4 100644
--- a/src/app_modules/admin/user-access/view/index.tsx
+++ b/src/app_modules/admin/user-access/view/index.tsx
@@ -1,6 +1,9 @@
"use client";
+import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
+import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
import { MODEL_USER } from "@/app_modules/home/model/interface";
+import { clientLogger } from "@/util/clientLogger";
import {
Button,
Center,
@@ -14,48 +17,83 @@ import {
Title,
} from "@mantine/core";
import { IconSearch } from "@tabler/icons-react";
-import adminUserAccess_funEditAccess from "../fun/edit/fun_edit_access";
import { useState } from "react";
+import adminUserAccess_funEditAccess from "../fun/edit/fun_edit_access";
import adminUserAccess_getListUser from "../fun/get/get_list_all_user";
-import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
-import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
+import { WibuRealtime } from "wibu-pkg";
+import { gs_access_user, IRealtimeData } from "@/app/lib/global_state";
+import { useAtom } from "jotai";
export default function AdminUserAccess_View({ listUser }: { listUser: any }) {
const [data, setData] = useState(listUser.data);
const [isActivePage, setActivePage] = useState(1);
const [isNPage, setNPage] = useState(listUser.nPage);
const [isSearch, setSearch] = useState("");
+ const [isLoadingAccess, setIsLoadingAccess] = useState(false);
+ const [isLoadingDelete, setIsLoadingDelete] = useState(false);
+ const [userId, setUserId] = useState("");
- async function onAccess(id: string) {
- await adminUserAccess_funEditAccess(id, true).then(async (res) => {
- if (res.status === 200) {
- const value = await adminUserAccess_getListUser({
- page: 1,
- search: isSearch,
- });
- setData(value.data as any);
- setNPage(value.nPage);
- ComponentGlobal_NotifikasiBerhasil(res.message);
- } else {
- ComponentGlobal_NotifikasiGagal(res.message);
- }
- });
+ async function onAccess(id: string, nomor: string) {
+ try {
+ setUserId(id);
+ setIsLoadingAccess(true);
+ await adminUserAccess_funEditAccess(id, true, nomor).then(async (res) => {
+ if (res.status === 200) {
+ const value = await adminUserAccess_getListUser({
+ page: 1,
+ search: isSearch,
+ });
+ setData(value.data as any);
+ setNPage(value.nPage);
+
+ const dataNotifikasi: IRealtimeData = {
+ status: true as any,
+ userId: id,
+ kategoriApp: "ACCESS",
+ };
+
+ WibuRealtime.setData({
+ type: "trigger",
+ pushNotificationTo: "USER",
+ dataMessage: dataNotifikasi,
+ });
+
+ ComponentGlobal_NotifikasiBerhasil(res.message);
+ } else {
+ ComponentGlobal_NotifikasiGagal(res.message);
+ }
+ });
+ } catch (error) {
+ clientLogger.error("Error grand access", error);
+ } finally {
+ setIsLoadingAccess(false);
+ setUserId("");
+ }
}
- async function onDelAccess(id: string) {
- await adminUserAccess_funEditAccess(id, false).then(async (res) => {
- if (res.status === 200) {
- const value = await adminUserAccess_getListUser({
- page: 1,
- search: isSearch,
- });
- setData(value.data as any);
- setNPage(value.nPage);
- ComponentGlobal_NotifikasiBerhasil(res.message);
- } else {
- ComponentGlobal_NotifikasiGagal(res.message);
- }
- });
+ async function onDelete(id: string) {
+ try {
+ setUserId(id);
+ setIsLoadingDelete(true);
+ await adminUserAccess_funEditAccess(id, false).then(async (res) => {
+ if (res.status === 200) {
+ const value = await adminUserAccess_getListUser({
+ page: 1,
+ search: isSearch,
+ });
+ setData(value.data as any);
+ setNPage(value.nPage);
+ ComponentGlobal_NotifikasiBerhasil(res.message);
+ } else {
+ ComponentGlobal_NotifikasiGagal(res.message);
+ }
+ });
+ } catch (error) {
+ clientLogger.error("Error delete access", error);
+ } finally {
+ setIsLoadingDelete(false);
+ setUserId("");
+ }
}
async function onSearch(s: any) {
@@ -91,22 +129,26 @@ export default function AdminUserAccess_View({ listUser }: { listUser: any }) {
{e.active === false ? (
) : (
- {
setInputOtp(val);
}}
diff --git a/src/app_modules/colab/_lib/api_collaboration.ts b/src/app_modules/colab/_lib/api_collaboration.ts
new file mode 100644
index 00000000..1c6b0d26
--- /dev/null
+++ b/src/app_modules/colab/_lib/api_collaboration.ts
@@ -0,0 +1,43 @@
+export const apiGetAllCollaboration = async ({
+ kategori,
+ page,
+}: {
+ kategori: "beranda" | "partisipasi" | "proyeksaya" | "grup";
+ page: string;
+}) => {
+ const respone = await fetch(
+ `/api/collaboration/get?kategori=${kategori}&page=${page}`
+ );
+ return await respone.json().catch(() => null);
+};
+
+export const apiGetOneCollaborationById = async ({
+ id,
+ kategori,
+ page,
+}: {
+ id: string;
+ kategori: "detail" | "list_partisipan" | "cek_partisipasi";
+ page?: string;
+}) => {
+ const respone = await fetch(
+ `/api/collaboration/${id}?kategori=${kategori}&page=${page}`
+ );
+ return await respone.json().catch(() => null);
+};
+
+export const apiGetDataGroupById = async ({
+ id,
+ kategori,
+ page,
+}: {
+ id: string;
+ kategori: "detail" | "info_group"
+ page?: string;
+}) => {
+ const respone = await fetch(
+ `/api/collaboration/group/${id}?kategori=${kategori}&page=${page}`
+ );
+
+ return await respone.json().catch(() => null)
+}
\ No newline at end of file
diff --git a/src/app_modules/colab/component/card_view/card_section_data.tsx b/src/app_modules/colab/component/card_view/card_section_data.tsx
index c527562d..66255d8e 100644
--- a/src/app_modules/colab/component/card_view/card_section_data.tsx
+++ b/src/app_modules/colab/component/card_view/card_section_data.tsx
@@ -40,15 +40,15 @@ export default function ComponentColab_CardSectionData({
-
+
Industri
- :
+ :
-
+
{data?.ProjectCollaborationMaster_Industri.name
? data?.ProjectCollaborationMaster_Industri?.name
: "Industri"}
@@ -58,25 +58,25 @@ export default function ComponentColab_CardSectionData({
-
+
Lokasi
- :
+ :
-
+
{data?.lokasi ? data?.lokasi : "Lokasi dari proyek"}
-
+
Tujuan proyek
-
+
{data?.purpose
? data?.purpose
: "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Maiores odio nihil in animi expedita, suscipit excepturi pariatur totam esse officiis enim cumque. Quidem, facere aliquam. Sunt laboriosam incidunt iste amet"}
diff --git a/src/app_modules/colab/component/card_view/card_section_jumlah_partisipan.tsx b/src/app_modules/colab/component/card_view/card_section_jumlah_partisipan.tsx
index 404e7f04..9c241cc7 100644
--- a/src/app_modules/colab/component/card_view/card_section_jumlah_partisipan.tsx
+++ b/src/app_modules/colab/component/card_view/card_section_jumlah_partisipan.tsx
@@ -1,5 +1,6 @@
"use client";
+import { MainColor } from "@/app_modules/_global/color";
import { Card, Center, Divider, Grid, Stack, Text } from "@mantine/core";
export default function ComponentColab_JumlahPartisipan({
@@ -15,12 +16,12 @@ export default function ComponentColab_JumlahPartisipan({
-
+
{jumlah?.length ? jumlah?.length : 0}
-
+
Partisipan
diff --git a/src/app_modules/colab/component/card_view/crad_grup.tsx b/src/app_modules/colab/component/card_view/crad_grup.tsx
index 5b405b30..be945eb3 100644
--- a/src/app_modules/colab/component/card_view/crad_grup.tsx
+++ b/src/app_modules/colab/component/card_view/crad_grup.tsx
@@ -1,5 +1,5 @@
import { RouterColab } from "@/app/lib/router_hipmi/router_colab";
-import { AccentColor } from "@/app_modules/_global/color/color_pallet";
+import { AccentColor, MainColor } from "@/app_modules/_global/color/color_pallet";
import ComponentGlobal_Loader from "@/app_modules/_global/component/loader";
import { Paper, Grid, Stack, Center, Loader, Text } from "@mantine/core";
import { IconChevronRight } from "@tabler/icons-react";
@@ -17,7 +17,7 @@ export function ComponentColab_CardGrup({ data }: { data: any }) {
style={{
border: `2px solid ${AccentColor.blue}`,
backgroundColor: AccentColor.darkblue,
- color: "white",
+ color: MainColor.white,
borderRadius: "10px",
marginBottom: "20px",
padding: "15px",
@@ -37,7 +37,7 @@ export function ComponentColab_CardGrup({ data }: { data: any }) {
{data?.ProjectCollaboration_RoomChat?.name}
-
+
{
data?.ProjectCollaboration_RoomChat
?.ProjectCollaboration_AnggotaRoomChat.length
@@ -51,7 +51,7 @@ export function ComponentColab_CardGrup({ data }: { data: any }) {
{data?.ProjectCollaboration_RoomChat?.id === idRoom ? (
) : (
-
+
)}
diff --git a/src/app_modules/colab/component/detail/detail_data.tsx b/src/app_modules/colab/component/detail/detail_data.tsx
index 30158c00..e2f2f12a 100644
--- a/src/app_modules/colab/component/detail/detail_data.tsx
+++ b/src/app_modules/colab/component/detail/detail_data.tsx
@@ -19,15 +19,15 @@ export default function ComponentColab_DetailData({
-
+
Industri
- :
+ :
-
+
{data?.ProjectCollaborationMaster_Industri.name
? data.ProjectCollaborationMaster_Industri.name
: "Industri"}
@@ -37,31 +37,31 @@ export default function ComponentColab_DetailData({
-
+
Lokasi
- :
+ :
-
+
{data?.lokasi ? data.lokasi : " Lokasi dari proyek"}
-
+
Tujuan proyek
- {data?.purpose ? data?.purpose : "-"}
+ {data?.purpose ? data?.purpose : "-"}
-
+
Keuntungan
- {data?.benefit ? data?.benefit : "-"}
+ {data?.benefit ? data?.benefit : "-"}
diff --git a/src/app_modules/colab/component/detail/list_partisipasi_user.tsx b/src/app_modules/colab/component/detail/list_partisipasi_user.tsx
index 94a65e62..609d4f58 100644
--- a/src/app_modules/colab/component/detail/list_partisipasi_user.tsx
+++ b/src/app_modules/colab/component/detail/list_partisipasi_user.tsx
@@ -4,9 +4,14 @@ import {
AccentColor,
MainColor,
} from "@/app_modules/_global/color/color_pallet";
+import { ComponentGlobal_CardStyles } from "@/app_modules/_global/component";
import ComponentGlobal_InputCountDown from "@/app_modules/_global/component/input_countdown";
+import ComponentGlobal_IsEmptyData from "@/app_modules/_global/component/is_empty_data";
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
+import notifikasiToUser_funCreate from "@/app_modules/notifikasi/fun/create/create_notif_to_user";
+import { clientLogger } from "@/util/clientLogger";
+import mqtt_client from "@/util/mqtt_client";
import {
ActionIcon,
Box,
@@ -14,83 +19,219 @@ import {
Center,
Drawer,
Group,
- Paper,
- ScrollArea,
+ Loader,
Stack,
Text,
Textarea,
Title,
} from "@mantine/core";
-import { useDisclosure } from "@mantine/hooks";
+import { useDisclosure, useShallowEffect } from "@mantine/hooks";
import { IconX } from "@tabler/icons-react";
+import _ from "lodash";
+import { ScrollOnly } from "next-scroll-loader";
+import { useParams } from "next/navigation";
import { useState } from "react";
+import { apiGetOneCollaborationById } from "../../_lib/api_collaboration";
import colab_funCreatePartisipan from "../../fun/create/fun_create_partisipan_by_user_id";
-import colab_getListPartisipanByColabId from "../../fun/get/get_list_partisipan_by_id";
import { MODEL_COLLABORATION_PARTISIPASI } from "../../model/interface";
+import { Collaboration_SkeletonListPrtisipanIsUser } from "../skeleton_view";
import ComponentColab_AuthorNameOnListPartisipan from "./header_author_list_partisipan";
-import notifikasiToUser_funCreate from "@/app_modules/notifikasi/fun/create/create_notif_to_user";
-import mqtt_client from "@/util/mqtt_client";
export default function ComponentColab_DetailListPartisipasiUser({
- listPartisipan,
userLoginId,
authorId,
- colabId,
- cekPartisipan,
}: {
- listPartisipan?: MODEL_COLLABORATION_PARTISIPASI[];
userLoginId?: string;
authorId?: string;
- colabId?: string;
- cekPartisipan?: boolean;
}) {
- const [apply, setApply] = useState(false);
- const [data, setData] = useState(listPartisipan);
+ const params = useParams<{ id: string }>();
+ const [data, setData] = useState(
+ null
+ );
+ const [isPartisipan, setCekPartisipan] = useState(null);
+
+ const [activePage, setActivePage] = useState(1);
const [opened, { open, close }] = useDisclosure(false);
const [deskripsi, setDeskripsi] = useState("");
+ const [isLoading, setIsLoading] = useState(false);
- async function onJoin() {
- const res = await colab_funCreatePartisipan(
- colabId as any,
- userLoginId as any,
- deskripsi
- );
- if (res.status === 201) {
- const dataNotif = {
- appId: res?.data?.ProjectCollaboration?.id,
- userId: res?.data?.ProjectCollaboration?.userId,
- pesan: res?.data?.ProjectCollaboration?.title,
- status: "Partisipan Project",
- kategoriApp: "COLLABORATION",
- title: "Partisipan baru telah bergabung !",
- };
+ useShallowEffect(() => {
+ onLoadDataPartisipan();
+ }, []);
- const createNotifikasi = await notifikasiToUser_funCreate({
- data: dataNotif as any,
+ async function onLoadDataPartisipan() {
+ try {
+ const respone = await apiGetOneCollaborationById({
+ id: params.id,
+ kategori: "list_partisipan",
+ page: `${activePage}`,
});
- if (createNotifikasi.status === 201) {
- mqtt_client.publish(
- "USER",
- JSON.stringify({
- userId: dataNotif.userId,
- count: 1,
- })
- );
+ if (respone) {
+ setData(respone.data);
}
-
- const resList = await colab_getListPartisipanByColabId(colabId as any);
- setApply(true);
- close();
- setData(resList as any);
- ComponentGlobal_NotifikasiBerhasil(res.message);
- } else {
- ComponentGlobal_NotifikasiGagal(res.message);
+ } catch (error) {
+ clientLogger.error("Error get list partisipan", error);
}
}
+ useShallowEffect(() => {
+ onCheckPartisipasi();
+ }, []);
+
+ async function onCheckPartisipasi() {
+ try {
+ const respone = await apiGetOneCollaborationById({
+ id: params.id,
+ kategori: "cek_partisipasi",
+ });
+
+ if (respone) {
+ setCekPartisipan(respone.data);
+ }
+ } catch (error) {
+ clientLogger.error("Error cek partisipasi", error);
+ }
+ }
+
+ async function onJoin() {
+ try {
+ setIsLoading(true);
+ const res = await colab_funCreatePartisipan({
+ id: params.id,
+ deskripsi: deskripsi,
+ });
+
+ if (res.status === 201) {
+ // const dataNotif = {
+ // appId: res?.data?.ProjectCollaboration?.id,
+ // userId: res?.data?.ProjectCollaboration?.userId,
+ // pesan: res?.data?.ProjectCollaboration?.title,
+ // status: "Partisipan Project",
+ // kategoriApp: "COLLABORATION",
+ // title: "Partisipan baru telah bergabung !",
+ // };
+
+ // const createNotifikasi = await notifikasiToUser_funCreate({
+ // data: dataNotif as any,
+ // });
+
+ // if (createNotifikasi.status === 201) {
+ // mqtt_client.publish(
+ // "USER",
+ // JSON.stringify({
+ // userId: dataNotif.userId,
+ // count: 1,
+ // })
+ // );
+ // }
+
+ const respone = await apiGetOneCollaborationById({
+ id: params.id,
+ kategori: "list_partisipan",
+ page: `${activePage}`,
+ });
+
+ if (respone) {
+ setData(respone.data);
+ }
+
+ const cekPartisipan = await apiGetOneCollaborationById({
+ id: params.id,
+ kategori: "cek_partisipasi",
+ });
+
+ if (cekPartisipan) {
+ setCekPartisipan(cekPartisipan);
+ }
+
+ close();
+ ComponentGlobal_NotifikasiBerhasil(res.message);
+ } else {
+ ComponentGlobal_NotifikasiGagal(res.message);
+ }
+ } catch (error) {
+ clientLogger.error("Error create partisipan", error);
+ } finally {
+ setIsLoading(false);
+ }
+ }
+
+ if (_.isNull(data) || _.isNull(isPartisipan)) {
+ return ;
+ }
+
return (
<>
+
+ {userLoginId !== authorId && (
+
+
+
+ )}
+
+ {_.isEmpty(data) ? (
+
+
+
+ Partispasi User ({data?.length})
+
+
+
+
+ ) : (
+
+
+
+ Partispasi User ({data?.length})
+ {" "}
+
+ (
+
+
+
+ )}
+ data={data}
+ setData={setData as any}
+ moreData={async () => {
+ const respone = await apiGetOneCollaborationById({
+ id: params.id,
+ kategori: "list_partisipan",
+ page: `${activePage + 1}`,
+ });
+
+ setActivePage((val) => val + 1);
+
+ return respone.data;
+ }}
+ >
+ {(item) => (
+
+ )}
+
+
+
+
+ )}
+
+
-
-
+
-
-
- {userLoginId !== authorId ? (
-
-
-
- ) : (
- ""
- )}
-
-
-
-
- Partispasi User ({data?.length})
- {" "}
-
-
-
- {data?.length === 0 ? (
-
-
- Tidak ada partisipan
-
-
- ) : (
- data?.map((e, i) => (
-
-
-
- ))
- )}
-
-
-
-
-
-
>
);
}
diff --git a/src/app_modules/colab/component/header_author_name.tsx b/src/app_modules/colab/component/header_author_name.tsx
index 958bbeb3..315b34e4 100644
--- a/src/app_modules/colab/component/header_author_name.tsx
+++ b/src/app_modules/colab/component/header_author_name.tsx
@@ -3,6 +3,8 @@
import { ComponentGlobal_AvatarAndUsername } from "@/app_modules/_global/component";
import { Group, Stack, Text } from "@mantine/core";
import { useRouter } from "next/navigation";
+import moment from "moment";
+import "moment/locale/id";
export default function ComponentColab_AuthorNameOnHeader({
tglPublish,
@@ -19,10 +21,8 @@ export default function ComponentColab_AuthorNameOnHeader({
component={
{tglPublish ? (
-
- {new Intl.DateTimeFormat("id-ID", {
- dateStyle: "medium",
- }).format(tglPublish)}
+
+ {moment(tglPublish).locale("id").format("ll")}
) : (
""
@@ -65,7 +65,7 @@ export default function ComponentColab_AuthorNameOnHeader({
{tglPublish ? (
-
+
{new Intl.DateTimeFormat("id-ID", {
dateStyle: "medium"
diff --git a/src/app_modules/colab/component/skeleton_view.tsx b/src/app_modules/colab/component/skeleton_view.tsx
index 1061a1af..027a227d 100644
--- a/src/app_modules/colab/component/skeleton_view.tsx
+++ b/src/app_modules/colab/component/skeleton_view.tsx
@@ -1,27 +1,277 @@
-import { Skeleton, Stack } from "@mantine/core";
+import { ComponentGlobal_CardStyles } from "@/app_modules/_global/component";
+import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
+import { Center, Grid, Group, Skeleton, Stack } from "@mantine/core";
-export function Collaboration_SkeletonCreate() {
+export {
+ Collaboration_SkeletonBeranda,
+ Collaboration_SkeletonCreate,
+ Collaboration_SkeletonDetail,
+ Collaboration_SkeletonDetailInfoGroup,
+ Collaboration_SkeletonGrup,
+ Collaboration_SkeletonListPartisipan,
+ Collaboration_SkeletonListPrtisipanIsUser,
+};
+
+function Collaboration_SkeletonCreate() {
return (
<>
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
+
+
+
+
-
+
+
+ >
+ );
+}
+
+function Collaboration_SkeletonBeranda() {
+ return (
+ <>
+ {Array.from(new Array(2)).map((e, i) => (
+
+
+
+
+
+
+
+
+
+ {/*
+
+ */}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ))}
+ >
+ );
+}
+
+function Collaboration_SkeletonGrup() {
+ return (
+ <>
+ {Array.from(new Array(2)).map((e, i) => (
+
+
+
+
+
+
+
+
+
+
+ ))}
+ >
+ );
+}
+
+function Collaboration_SkeletonDetail() {
+ return (
+ <>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ >
+ );
+}
+
+function Collaboration_SkeletonListPrtisipanIsUser() {
+ return (
+ <>
+
+
+
+
+
+
+
+ {Array.from(new Array(2)).map((e, i) => (
+
+
+
+
+
+
+
+
+ ))}
+
+
+
+ >
+ );
+}
+
+function Collaboration_SkeletonListPartisipan() {
+ return (
+ <>
+
+
+
+
+
+
+
+
+
+
+ {Array.from(new Array(2)).map((e, i) => (
+
+
+
+
+
+
+
+
+ ))}
+
+
+
+ >
+ );
+}
+
+function Collaboration_SkeletonDetailInfoGroup() {
+ return (
+ <>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {Array.from(new Array(2)).map((e, i) => (
+
+
+
+
+
+
+
+
+ ))}
+
+
>
);
diff --git a/src/app_modules/colab/create/index.tsx b/src/app_modules/colab/create/index.tsx
index b28e3236..b5bb30ca 100644
--- a/src/app_modules/colab/create/index.tsx
+++ b/src/app_modules/colab/create/index.tsx
@@ -5,26 +5,22 @@ import ComponentGlobal_InputCountDown from "@/app_modules/_global/component/inpu
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 { clientLogger } from "@/util/clientLogger";
+import mqtt_client from "@/util/mqtt_client";
import {
Button,
- Center,
Select,
Stack,
TextInput,
- Textarea,
- Loader,
+ Textarea
} from "@mantine/core";
+import { useShallowEffect } from "@mantine/hooks";
import { useRouter } from "next/navigation";
import { useState } from "react";
+import { Collaboration_SkeletonCreate } from "../component";
+import { apiGetMasterCollaboration } from "../component/lib/api_collaboration";
import colab_funCreateProyek from "../fun/create/fun_create_proyek";
import { MODEL_COLLABORATION_MASTER } from "../model/interface";
-import mqtt_client from "@/util/mqtt_client";
-import { useHookstate } from "@hookstate/core";
-import { useGsCollabCreate } from "../global_state/state";
-import { useShallowEffect } from "@mantine/hooks";
-import { apiGetMasterCollaboration } from "../component/lib/api_collaboration";
-import { clientLogger } from "@/util/clientLogger";
-import { Collaboration_SkeletonCreate } from "../component";
export default function Colab_Create() {
const [value, setValue] = useState({
@@ -55,7 +51,7 @@ export default function Colab_Create() {
}
}
-
+
if (listIndustri == null) {
return (
<>
@@ -70,9 +66,9 @@ export default function Colab_Create() {
- {/* */}
-
- {/*
- minimal partisipan yang akan di pilih untuk mendiskusikan proyek
-
- }
- type="number"
- withAsterisk
- label="Jumlah Partisipan"
- placeholder={"2"}
- onChange={(val) => {
- setValue({
- ...value,
- jumlah_partisipan: val.currentTarget.value as any,
- });
- }}
- /> */}
+ />
-
+
{selectRoom?.name}
@@ -220,13 +247,15 @@ export default function Colab_GroupChatView({
radius={"xl"}
onClick={() => {
setLoadingInfo(true);
- router.push(RouterColab.info_grup + selectRoom.id, {scroll: false});
+ router.push(RouterColab.info_grup + selectRoom.id, {
+ scroll: false,
+ });
}}
>
{loadingInfo ? (
) : (
-
+
)}
@@ -351,10 +380,11 @@ export default function Colab_GroupChatView({
>
KIzRIM PESAN
*/}
-
+
)}
data={data}
- setData={setData}
+ setData={setData as any}
moreData={async () => {
- const loadData = await colab_getListAllProyek({
- page: activePage + 1,
+ const respone = await apiGetAllCollaboration({
+ kategori: "beranda",
+ page: `${activePage + 1}`,
});
setActivePage((val) => val + 1);
- return loadData;
+ return respone.data;
}}
>
{(item) => (
diff --git a/src/app_modules/colab/main/grup/index.tsx b/src/app_modules/colab/main/grup/index.tsx
index f7ccf26b..8381afd3 100644
--- a/src/app_modules/colab/main/grup/index.tsx
+++ b/src/app_modules/colab/main/grup/index.tsx
@@ -1,28 +1,51 @@
"use client";
import ComponentGlobal_IsEmptyData from "@/app_modules/_global/component/is_empty_data";
-import {
- Box,
- Center,
- Loader
-} from "@mantine/core";
+import { Box, Center, Loader, Skeleton, Stack } from "@mantine/core";
import _ from "lodash";
import { ScrollOnly } from "next-scroll-loader";
import { useState } from "react";
import { ComponentColab_CardGrup } from "../../component/card_view/crad_grup";
import colab_getListRoomChatByAuthorId from "../../fun/get/room_chat/get_list_room_by_author_id";
+import { MODEL_COLLABORATION_ANGGOTA_ROOM_CHAT } from "../../model/interface";
+import { clientLogger } from "@/util/clientLogger";
+import { useShallowEffect } from "@mantine/hooks";
+import { apiGetAllCollaboration } from "../../_lib/api_collaboration";
import {
- MODEL_COLLABORATION_ANGGOTA_ROOM_CHAT
-} from "../../model/interface";
+ Collaboration_SkeletonBeranda,
+ Collaboration_SkeletonGrup,
+} from "../../component/skeleton_view";
+import { ComponentGlobal_CardStyles } from "@/app_modules/_global/component";
-export default function Colab_GrupDiskus({
- listRoom,
-}: {
- listRoom: MODEL_COLLABORATION_ANGGOTA_ROOM_CHAT[];
-}) {
- const [data, setData] = useState(listRoom);
+export default function Colab_GrupDiskus() {
+ const [data, setData] = useState<
+ MODEL_COLLABORATION_ANGGOTA_ROOM_CHAT[] | null
+ >(null);
const [activePage, setActivePage] = useState(1);
+ useShallowEffect(() => {
+ onLoadData();
+ }, []);
+
+ async function onLoadData() {
+ try {
+ const respone = await apiGetAllCollaboration({
+ kategori: "grup",
+ page: `${activePage}`,
+ });
+
+ if (respone) {
+ setData(respone.data);
+ }
+ } catch (error) {
+ clientLogger.error("Error get grup", error);
+ }
+ }
+
+ if (_.isNull(data)) {
+ return ;
+ }
+
return (
<>
@@ -38,15 +61,16 @@ export default function Colab_GrupDiskus({
)}
data={data}
- setData={setData}
+ setData={setData as any}
moreData={async () => {
- const loadData = await colab_getListRoomChatByAuthorId({
- page: activePage + 1,
+ const respone = await apiGetAllCollaboration({
+ kategori: "grup",
+ page: `${activePage + 1}`,
});
setActivePage((val) => val + 1);
- return loadData;
+ return respone.data;
}}
>
{(item) => }
diff --git a/src/app_modules/colab/main/layout.tsx b/src/app_modules/colab/main/layout.tsx
index 03b3cd7b..8a896438 100644
--- a/src/app_modules/colab/main/layout.tsx
+++ b/src/app_modules/colab/main/layout.tsx
@@ -60,7 +60,7 @@ export default function LayoutColab_Main({
{
router.replace(e.path, { scroll: false });
setHotMenu(e.id);
@@ -69,7 +69,7 @@ export default function LayoutColab_Main({
{e.icon}
diff --git a/src/app_modules/colab/main/proyek/index.tsx b/src/app_modules/colab/main/proyek/index.tsx
index 90babe4e..0e139a06 100644
--- a/src/app_modules/colab/main/proyek/index.tsx
+++ b/src/app_modules/colab/main/proyek/index.tsx
@@ -1,25 +1,17 @@
"use client";
+import {
+ AccentColor,
+ MainColor,
+} from "@/app_modules/_global/color/color_pallet";
import { Stack, Tabs, Text } from "@mantine/core";
-import { IconBrandOffice, IconUsersGroup, IconUser } from "@tabler/icons-react";
-import { useState } from "react";
-import Colab_ProyekSaya from "./saya";
-import Colab_PartisipasiProyek from "./partisipasi";
+import { IconUser, IconUsersGroup } from "@tabler/icons-react";
import { useAtom } from "jotai";
import { gs_colab_proyek } from "../../global_state";
-import {
- MODEL_COLLABORATION,
- MODEL_COLLABORATION_PARTISIPASI,
-} from "../../model/interface";
-import { AccentColor, MainColor } from "@/app_modules/_global/color/color_pallet";
+import Colab_PartisipasiProyek from "./partisipasi";
+import Colab_ProyekSaya from "./saya";
-export default function Colab_Proyek({
- listPartisipasiUser,
- listProyekSaya,
-}: {
- listPartisipasiUser: MODEL_COLLABORATION_PARTISIPASI[];
- listProyekSaya: MODEL_COLLABORATION[];
-}) {
+export default function Colab_Proyek() {
const [activeTab, setActiveTab] = useAtom(gs_colab_proyek);
const listTabs = [
@@ -28,18 +20,14 @@ export default function Colab_Proyek({
icon: ,
label: "Partisipasi Proyek",
value: "Partisipasi",
- path: (
-
- ),
+ path: ,
},
{
id: 2,
icon: ,
label: "Proyek Saya",
value: "Saya",
- path: ,
+ path: ,
},
];
@@ -64,15 +52,15 @@ export default function Colab_Proyek({
key={e.id}
value={e.value}
fw={"bold"}
- c={"black"}
style={{
transition: "0.5s",
+ color: activeTab === e.value ? MainColor.darkblue : MainColor.black,
backgroundColor:
- activeTab === e.value ? MainColor.yellow : "white",
+ activeTab === e.value ? MainColor.yellow : MainColor.white,
border:
activeTab === e.value
? `1px solid ${AccentColor.yellow}`
- : `1px solid white`,
+ : `1px solid ${MainColor.white}`,
}}
>
diff --git a/src/app_modules/colab/main/proyek/partisipasi.tsx b/src/app_modules/colab/main/proyek/partisipasi.tsx
index 0071cd2a..49999a69 100644
--- a/src/app_modules/colab/main/proyek/partisipasi.tsx
+++ b/src/app_modules/colab/main/proyek/partisipasi.tsx
@@ -2,28 +2,51 @@
import { RouterColab } from "@/app/lib/router_hipmi/router_colab";
import ComponentGlobal_IsEmptyData from "@/app_modules/_global/component/is_empty_data";
+import { clientLogger } from "@/util/clientLogger";
import { Box, Center, Loader } from "@mantine/core";
+import { useShallowEffect } from "@mantine/hooks";
import _ from "lodash";
import { ScrollOnly } from "next-scroll-loader";
import { useState } from "react";
+import { apiGetAllCollaboration } from "../../_lib/api_collaboration";
import { ComponentColab_CardSemuaPartisipan } from "../../component/card_view/card_semua_partisipan";
-import colab_getListPartisipasiProyekByAuthorId from "../../fun/get/pasrtisipan/get_list_partisipasi_proyek_by_author_id";
+import { Collaboration_SkeletonBeranda } from "../../component/skeleton_view";
import { MODEL_COLLABORATION_PARTISIPASI } from "../../model/interface";
-export default function Colab_PartisipasiProyek({
- listPartisipasiUser,
-}: {
- listPartisipasiUser: MODEL_COLLABORATION_PARTISIPASI[];
-}) {
- const [data, setData] = useState(listPartisipasiUser);
+export default function Colab_PartisipasiProyek() {
+ const [data, setData] = useState(
+ null
+ );
const [activePage, setActivePage] = useState(1);
+ useShallowEffect(() => {
+ onLoadData();
+ }, []);
+
+ async function onLoadData() {
+ try {
+ const respone = await apiGetAllCollaboration({
+ kategori: "partisipasi",
+ page: `${activePage}`,
+ });
+
+ if (respone) {
+ setData(respone.data);
+ }
+ } catch (error) {
+ clientLogger.error("Error get partisipasi", error);
+ }
+ }
+
+ if (_.isNull(data)) {
+ return ;
+ }
+
return (
<>
{_.isEmpty(data) ? (
) : (
- // --- Main component --- //
)}
data={data}
- setData={setData}
+ setData={setData as any}
moreData={async () => {
- const loadData = await colab_getListPartisipasiProyekByAuthorId({
- page: activePage + 1,
+ const respone = await apiGetAllCollaboration({
+ kategori: "partisipasi",
+ page: `${activePage + 1}`,
});
setActivePage((val) => val + 1);
- return loadData;
+ return respone.data;
}}
>
{(item) => (
diff --git a/src/app_modules/colab/main/proyek/saya.tsx b/src/app_modules/colab/main/proyek/saya.tsx
index 419e5f3a..debc9542 100644
--- a/src/app_modules/colab/main/proyek/saya.tsx
+++ b/src/app_modules/colab/main/proyek/saya.tsx
@@ -2,29 +2,51 @@
import { RouterColab } from "@/app/lib/router_hipmi/router_colab";
import ComponentGlobal_IsEmptyData from "@/app_modules/_global/component/is_empty_data";
+import { clientLogger } from "@/util/clientLogger";
import { Box, Center, Loader } from "@mantine/core";
+import { useShallowEffect } from "@mantine/hooks";
import _ from "lodash";
import { ScrollOnly } from "next-scroll-loader";
import { useState } from "react";
+import { apiGetAllCollaboration } from "../../_lib/api_collaboration";
import { ComponentColab_CardProyekSaya } from "../../component/card_view/card_proyek_saya";
-import colab_getListAllProyekSayaByAuthorId from "../../fun/get/pasrtisipan/get_list_proyek_saya_by_author_id";
+import { Collaboration_SkeletonBeranda } from "../../component/skeleton_view";
import { MODEL_COLLABORATION } from "../../model/interface";
-export default function Colab_ProyekSaya({
- listProyekSaya,
-}: {
- listProyekSaya: MODEL_COLLABORATION[];
-}) {
- const [data, setData] = useState(listProyekSaya);
+export default function Colab_ProyekSaya() {
+ const [data, setData] = useState(null);
const [activePage, setActivePage] = useState(1);
+ useShallowEffect(() => {
+ onLoadData();
+ }, []);
+
+ async function onLoadData() {
+ try {
+ const respone = await apiGetAllCollaboration({
+ kategori: "proyeksaya",
+ page: `${activePage}`,
+ });
+
+ if (respone) {
+ setData(respone.data);
+ }
+ } catch (error) {
+ clientLogger.error("Error get proyeksaya", error);
+ }
+ }
+
+ if (_.isNull(data)) {
+ return ;
+ }
+
return (
<>
{_.isEmpty(data) ? (
) : (
// --- Main component --- //
-
+
(
@@ -33,14 +55,16 @@ export default function Colab_ProyekSaya({
)}
data={data}
- setData={setData}
+ setData={setData as any}
moreData={async () => {
- const loadData = await colab_getListAllProyekSayaByAuthorId({
- page: activePage + 1,
+ const respone = await apiGetAllCollaboration({
+ kategori: "proyeksaya",
+ page: `${activePage + 1}`,
});
+
setActivePage((val) => val + 1);
- return loadData;
+ return respone.data;
}}
>
{(item) => (
diff --git a/src/app_modules/donasi/component/button/comp_button_delete_donasi_by_id.tsx b/src/app_modules/donasi/component/button/comp_button_delete_donasi_by_id.tsx
index 6ec7bb58..572eb3d1 100644
--- a/src/app_modules/donasi/component/button/comp_button_delete_donasi_by_id.tsx
+++ b/src/app_modules/donasi/component/button/comp_button_delete_donasi_by_id.tsx
@@ -13,6 +13,8 @@ import {
import { useAtom } from "jotai";
import { gs_donasi_tabs_posting } from "../../global_state";
import { useRouter } from "next/navigation";
+import { AccentColor, MainColor } from "@/app_modules/_global/color";
+import { clientLogger } from "@/util/clientLogger";
export function Donasi_ComponentButtonDeleteDonasiById({
donasiId,
@@ -24,6 +26,7 @@ export function Donasi_ComponentButtonDeleteDonasiById({
imageId: string;
}) {
const router = useRouter();
+ const [isLoading, setLoading] = useState(false);
const [openModal, setOpenModal] = useState(false);
const [tabsPostingDonasi, setTabsPostingDonasi] = useAtom(
gs_donasi_tabs_posting
@@ -31,28 +34,35 @@ export function Donasi_ComponentButtonDeleteDonasiById({
async function onDelete() {
const del = await Donasi_funDeleteDonasiById(donasiId);
- if (del.status === 200) {
- const deleteImageDonasi = await funGlobal_DeleteFileById({
- fileId: imageId as any,
- });
+ try {
+ setLoading(true);
+ if (del.status === 200) {
+ const deleteImageDonasi = await funGlobal_DeleteFileById({
+ fileId: imageId as any,
+ });
- if (!deleteImageDonasi.success) {
- ComponentGlobal_NotifikasiPeringatan("Gagal hapus gambar ");
+ if (!deleteImageDonasi.success) {
+ ComponentGlobal_NotifikasiPeringatan("Gagal hapus gambar ");
+ }
+
+ const deleteImageCerita = await funGlobal_DeleteFileById({
+ fileId: imageCeritaId as any,
+ });
+
+ if (!deleteImageCerita.success) {
+ ComponentGlobal_NotifikasiPeringatan("Gagal hapus gambar ");
+ }
+
+ router.replace(RouterDonasi.status_galang_dana({ id: "3" }));
+ setTabsPostingDonasi("Draft");
+ ComponentGlobal_NotifikasiBerhasil(del.message);
+ } else {
+ setLoading(false);
+ ComponentGlobal_NotifikasiGagal(del.message);
}
-
- const deleteImageCerita = await funGlobal_DeleteFileById({
- fileId: imageCeritaId as any,
- });
-
- if (!deleteImageCerita.success) {
- ComponentGlobal_NotifikasiPeringatan("Gagal hapus gambar ");
- }
-
- router.replace(RouterDonasi.status_galang_dana({ id: "3" }));
- setTabsPostingDonasi("Draft");
- ComponentGlobal_NotifikasiBerhasil(del.message);
- } else {
- ComponentGlobal_NotifikasiGagal(del.message);
+ } catch (error) {
+ setLoading(false);
+ clientLogger.error("Error delete donasi", error);
}
}
@@ -60,7 +70,8 @@ export function Donasi_ComponentButtonDeleteDonasiById({
<>
+
>
);
}
diff --git a/src/app_modules/event/component/skeleton/comp_skeleton_detail.tsx b/src/app_modules/event/component/skeleton/comp_skeleton_detail.tsx
index 200491a5..2b30756c 100644
--- a/src/app_modules/event/component/skeleton/comp_skeleton_detail.tsx
+++ b/src/app_modules/event/component/skeleton/comp_skeleton_detail.tsx
@@ -1,5 +1,6 @@
import { ComponentGlobal_CardStyles } from "@/app_modules/_global/component";
-import { Stack, Center, Skeleton, Grid } from "@mantine/core";
+import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
+import { Center, Grid, Stack } from "@mantine/core";
export function Event_ComponentSkeletonDetail() {
return (
@@ -8,26 +9,26 @@ export function Event_ComponentSkeletonDetail() {
-
+
-
+
-
+
-
-
-
-
-
+
+
+
+
+
-
-
-
+
+
+
diff --git a/src/app_modules/event/create/create.tsx b/src/app_modules/event/create/create.tsx
index 33d8df4f..5dbc6cc9 100644
--- a/src/app_modules/event/create/create.tsx
+++ b/src/app_modules/event/create/create.tsx
@@ -78,6 +78,9 @@ export default function Event_Create({
},
input: {
backgroundColor: MainColor.white,
+ },
+ dropdown: {
+ backgroundColor: MainColor.white,
}
}}
withAsterisk
diff --git a/src/app_modules/event/detail/draft/index.tsx b/src/app_modules/event/detail/draft/index.tsx
index 88a97a31..bdf8f4b5 100644
--- a/src/app_modules/event/detail/draft/index.tsx
+++ b/src/app_modules/event/detail/draft/index.tsx
@@ -18,6 +18,8 @@ import ComponentEvent_DetailData from "../../component/detail/detail_data";
import { Event_funDeleteById } from "../../fun/delete/fun_delete";
import { Event_funEditStatusById } from "../../fun/edit/fun_edit_status_by_id";
import { MODEL_EVENT } from "../../model/interface";
+import { AccentColor, MainColor } from "@/app_modules/_global/color";
+import { clientLogger } from "@/util/clientLogger";
export default function Event_DetailDraft({
dataEvent,
@@ -67,12 +69,18 @@ function ButtonAction({
async function onDelete() {
const res = await Event_funDeleteById(eventId);
- if (res.status === 200) {
- router.back();
- ComponentGlobal_NotifikasiBerhasil(res.message, 2000);
+ try {
setLoadingDelete(true);
- } else {
- ComponentGlobal_NotifikasiGagal(res.message);
+ if (res.status === 200) {
+ router.back();
+ ComponentGlobal_NotifikasiBerhasil(res.message, 2000);
+ } else {
+ setLoadingDelete(false);
+ ComponentGlobal_NotifikasiGagal(res.message);
+ }
+ } catch (error) {
+ setLoadingDelete(false);
+ clientLogger.error("Error delete event", error);
}
}
@@ -125,7 +133,8 @@ function ButtonAction({
{
setOpenModal1(true);
}}
@@ -134,7 +143,8 @@ function ButtonAction({
{
setOpenModal2(true);
}}
@@ -149,19 +159,20 @@ function ButtonAction({
opened={openModal1}
close={() => setOpenModal1(false)}
buttonKiri={
- setOpenModal1(false)}>
+ setOpenModal1(false)}>
Batal
}
buttonKanan={
{
onAjukan();
}}
- color="yellow"
+ c={MainColor.darkblue}
>
Ajukan
@@ -174,7 +185,7 @@ function ButtonAction({
opened={openModal2}
close={() => setOpenModal2(false)}
buttonKiri={
- setOpenModal2(false)}>
+ setOpenModal2(false)}>
Batal
}
@@ -186,7 +197,8 @@ function ButtonAction({
onClick={() => {
onDelete();
}}
- color="red"
+ style={{ backgroundColor: MainColor.red }}
+ c={AccentColor.white}
>
Hapus
diff --git a/src/app_modules/event/detail/main_detail/index.tsx b/src/app_modules/event/detail/main_detail/index.tsx
index 3438ba1a..70768a65 100644
--- a/src/app_modules/event/detail/main_detail/index.tsx
+++ b/src/app_modules/event/detail/main_detail/index.tsx
@@ -4,8 +4,9 @@ import { API_RouteEvent } from "@/app/lib/api_user_router/route_api_event";
import { IRealtimeData } from "@/app/lib/global_state";
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
+import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
import notifikasiToUser_funCreate from "@/app_modules/notifikasi/fun/create/create_notif_to_user";
-import { Button, Skeleton, Stack } from "@mantine/core";
+import { Button, Stack } from "@mantine/core";
import { useShallowEffect } from "@mantine/hooks";
import { useState } from "react";
import { WibuRealtime } from "wibu-pkg";
@@ -14,6 +15,8 @@ import ComponentEvent_ListPeserta from "../../component/detail/list_peserta";
import { Event_countTotalPesertaById } from "../../fun/count/count_total_peserta_by_id";
import { Event_funJoinEvent } from "../../fun/create/fun_join_event";
import { Event_getListPesertaById } from "../../fun/get/get_list_peserta_by_id";
+import { AccentColor, MainColor } from "@/app_modules/_global/color";
+import { clientLogger } from "@/util/clientLogger";
export default function Event_DetailMain({
userLoginId,
@@ -49,17 +52,18 @@ export default function Event_DetailMain({
/>
{isJoinSuccess == null ? (
-
+
) : isJoinSuccess ? (
Anda Telah Ikut Serta
) : (
{
onJoin(
userLoginId,
@@ -101,40 +105,46 @@ async function onJoin(
const userLoginId = userId;
- const res = await Event_funJoinEvent(body as any);
- if (res.status === 200) {
- const resPeserta = await Event_getListPesertaById(eventId);
- setIsNewPeserta(true);
-
- const resTotal = await Event_countTotalPesertaById(eventId);
- setTotal(resTotal);
-
- if (userLoginId !== res.data?.Event?.authorId) {
- const dataNotifikasi: IRealtimeData = {
- appId: res?.data?.Event?.id as any,
- status: "Peserta Event" as any,
- userId: res.data?.Event?.authorId as any,
- pesan: res.data?.Event?.title as any,
- kategoriApp: "EVENT",
- title: "Peserta baru event anda !",
- };
-
- const createNotifikasi = await notifikasiToUser_funCreate({
- data: dataNotifikasi as any,
- });
-
- if (createNotifikasi.status === 201) {
- WibuRealtime.setData({
- type: "notification",
- pushNotificationTo: "USER",
- dataMessage: dataNotifikasi,
- });
- }
- }
- setIsJoinSuccess(true);
+ try {
setLoading(true);
- ComponentGlobal_NotifikasiBerhasil(res.message, 2000);
- } else {
- ComponentGlobal_NotifikasiGagal(res.message);
+ const res = await Event_funJoinEvent(body as any);
+ if (res.status === 200) {
+ const resPeserta = await Event_getListPesertaById(eventId);
+ setIsNewPeserta(true);
+
+ const resTotal = await Event_countTotalPesertaById(eventId);
+ setTotal(resTotal);
+
+ if (userLoginId !== res.data?.Event?.authorId) {
+ const dataNotifikasi: IRealtimeData = {
+ appId: res?.data?.Event?.id as any,
+ status: "Peserta Event" as any,
+ userId: res.data?.Event?.authorId as any,
+ pesan: res.data?.Event?.title as any,
+ kategoriApp: "EVENT",
+ title: "Peserta baru event anda !",
+ };
+
+ const createNotifikasi = await notifikasiToUser_funCreate({
+ data: dataNotifikasi as any,
+ });
+
+ if (createNotifikasi.status === 201) {
+ WibuRealtime.setData({
+ type: "notification",
+ pushNotificationTo: "USER",
+ dataMessage: dataNotifikasi,
+ });
+ }
+ }
+ setIsJoinSuccess(true);
+ ComponentGlobal_NotifikasiBerhasil(res.message, 2000);
+ } else {
+ setLoading(false);
+ ComponentGlobal_NotifikasiGagal(res.message);
+ }
+ } catch (error) {
+ setLoading(false);
+ clientLogger.error("Error join event", error);
}
}
diff --git a/src/app_modules/event/detail/reject/index.tsx b/src/app_modules/event/detail/reject/index.tsx
index 6e25c05b..1df2f049 100644
--- a/src/app_modules/event/detail/reject/index.tsx
+++ b/src/app_modules/event/detail/reject/index.tsx
@@ -13,6 +13,8 @@ import ComponentEvent_DetailData from "../../component/detail/detail_data";
import { Event_funDeleteById } from "../../fun/delete/fun_delete";
import { Event_funEditStatusById } from "../../fun/edit/fun_edit_status_by_id";
import { MODEL_EVENT } from "../../model/interface";
+import { AccentColor, MainColor } from "@/app_modules/_global/color";
+import { clientLogger } from "@/util/clientLogger";
export default function Event_DetailReject({
dataEvent,
@@ -20,6 +22,7 @@ export default function Event_DetailReject({
dataEvent: MODEL_EVENT;
}) {
const [data, setData] = useState(dataEvent);
+
return (
<>
@@ -31,18 +34,58 @@ export default function Event_DetailReject({
);
}
-function ButtonAction({ eventId }: { eventId: string }) {
+
+function ButtonAction({ eventId, }: { eventId: string }) {
const router = useRouter();
const [openModal1, setOpenModal1] = useState(false);
const [openModal2, setOpenModal2] = useState(false);
+ const [isLoading, setLoading] = useState(false);
+ const [isLoading2, setLoading2] = useState(false);
+ async function onUpdate(router: AppRouterInstance, eventId: string, setLoading: any) {
+ await Event_funEditStatusById("3", eventId).then((res) => {
+ try {
+ setLoading(true);
+ if (res.status === 200) {
+ ComponentGlobal_NotifikasiBerhasil(res.message);
+ router.push(RouterEvent.status({ id: "3" }));
+ } else {
+ setLoading(false);
+ ComponentGlobal_NotifikasiGagal(res.message);
+ }
+ } catch (error) {
+ setLoading(false);
+ clientLogger.error("Error update event", error);
+ }
+
+ });
+ }
+
+ async function onDelete(router: AppRouterInstance, eventId: string, setLoading2: any) {
+ const res = await Event_funDeleteById(eventId);
+ try {
+ setLoading2(true);
+ if (res.status === 200) {
+ ComponentGlobal_NotifikasiBerhasil(res.message, 2000);
+ router.back();
+ } else {
+ setLoading2(false);
+ ComponentGlobal_NotifikasiGagal(res.message);
+ }
+ } catch (error) {
+ setLoading2(false);
+ clientLogger.error("Error delete event", error);
+ }
+ }
+
return (
<>
{
setOpenModal1(true);
}}
@@ -50,9 +93,10 @@ function ButtonAction({ eventId }: { eventId: string }) {
Edit Kembali
setOpenModal2(true)}
>
Hapus
@@ -65,17 +109,19 @@ function ButtonAction({ eventId }: { eventId: string }) {
opened={openModal1}
close={() => setOpenModal1(false)}
buttonKiri={
- setOpenModal1(false)}>
+ setOpenModal1(false)}>
Batal
}
buttonKanan={
{
- onUpdate(router, eventId);
- setOpenModal1(false);
+ onUpdate(router, eventId, setLoading);
}}
>
Edit
@@ -89,17 +135,19 @@ function ButtonAction({ eventId }: { eventId: string }) {
opened={openModal2}
close={() => setOpenModal2(false)}
buttonKiri={
- setOpenModal2(false)}>
+ setOpenModal2(false)}>
Batal
}
buttonKanan={
{
- onDelete(router, eventId);
- setOpenModal2(false);
+ onDelete(router, eventId, setLoading2);
}}
>
Hapus
@@ -110,23 +158,3 @@ function ButtonAction({ eventId }: { eventId: string }) {
);
}
-async function onUpdate(router: AppRouterInstance, eventId: string) {
- await Event_funEditStatusById("3", eventId).then((res) => {
- if (res.status === 200) {
- ComponentGlobal_NotifikasiBerhasil(res.message);
- router.push(RouterEvent.status({ id: "3" }));
- } else {
- ComponentGlobal_NotifikasiGagal(res.message);
- }
- });
-}
-
-async function onDelete(router: AppRouterInstance, eventId: string) {
- const res = await Event_funDeleteById(eventId);
- if (res.status === 200) {
- ComponentGlobal_NotifikasiBerhasil(res.message, 2000);
- router.back();
- } else {
- ComponentGlobal_NotifikasiGagal(res.message);
- }
-}
diff --git a/src/app_modules/event/detail/review/index.tsx b/src/app_modules/event/detail/review/index.tsx
index 5088dd33..8a927d81 100644
--- a/src/app_modules/event/detail/review/index.tsx
+++ b/src/app_modules/event/detail/review/index.tsx
@@ -17,6 +17,7 @@ import { IRealtimeData } from "@/app/lib/global_state";
import { WibuRealtime } from "wibu-pkg";
import { event_checkStatus } from "../../fun/get/fun_check_status_by_id";
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global";
+import { AccentColor, MainColor } from "@/app_modules/_global/color";
export default function Event_DetailReview({
dataEvent,
@@ -39,7 +40,7 @@ function ButtonAction({ eventId }: { eventId: string }) {
const [openModal, setOpenModal] = useState(false);
return (
<>
- setOpenModal(true)}>
+ setOpenModal(true)}>
Batalkan Review
@@ -48,16 +49,17 @@ function ButtonAction({ eventId }: { eventId: string }) {
opened={openModal}
close={() => setOpenModal(false)}
buttonKiri={
- setOpenModal(false)}>
+ setOpenModal(false)}>
Batal
}
buttonKanan={
onClick(router, eventId, setLoading)}
>
Simpan
diff --git a/src/app_modules/event/edit/index.tsx b/src/app_modules/event/edit/index.tsx
index ec0884a4..86b13683 100644
--- a/src/app_modules/event/edit/index.tsx
+++ b/src/app_modules/event/edit/index.tsx
@@ -24,6 +24,7 @@ import { useState } from "react";
import { Event_funEditById } from "../fun/edit/fun_edit_by_id";
import { MODEL_EVENT } from "../model/interface";
import ComponentEvent_ErrorMaximalInput from "../component/error_maksimal_input";
+import { clientLogger } from "@/util/clientLogger";
export default function Event_Edit({
dataEvent,
@@ -50,8 +51,14 @@ export default function Event_Edit({
{
return moment(date).diff(Date.now(), "days") < 0;
@@ -174,8 +202,14 @@ export default function Event_Edit({
{
return moment(date).diff(Date.now(), "days") < 0;
@@ -216,8 +250,14 @@ export default function Event_Edit({
@@ -281,14 +321,19 @@ async function onUpdate(
if (_.values(value).includes(""))
return ComponentGlobal_NotifikasiPeringatan("Lengkapi Data");
- const res = await Event_funEditById(value);
- setLoading(true);
+ try {
+ setLoading(true);
+ const res = await Event_funEditById(value);
if (res.status === 200) {
ComponentGlobal_NotifikasiBerhasil(res.message);
router.back();
- setLoading(false);
} else {
+ setLoading(false);
ComponentGlobal_NotifikasiGagal(res.message);
}
+ } catch (error) {
+ setLoading(false);
+ clientLogger.error("Error update event", error);
+ }
}
diff --git a/src/app_modules/event/main/status_page/index.tsx b/src/app_modules/event/main/status_page/index.tsx
index ed467f03..ff340db2 100644
--- a/src/app_modules/event/main/status_page/index.tsx
+++ b/src/app_modules/event/main/status_page/index.tsx
@@ -57,15 +57,15 @@ export default function Event_StatusPage({
key={e.id}
value={e.id}
fw={"bold"}
- c={"black"}
style={{
transition: "0.5s",
+ color: changeStatus === e.id ? MainColor.darkblue : MainColor.black,
backgroundColor:
changeStatus === e.id ? MainColor.yellow : MainColor.white,
border:
changeStatus === e.id
? `1px solid ${AccentColor.yellow}`
- : `1px solid white`,
+ : `1px solid ${MainColor.white}`,
}}
>
{e.name}
diff --git a/src/app_modules/home/component/body_home.tsx b/src/app_modules/home/component/body_home.tsx
index 41ebcb52..9ecff402 100644
--- a/src/app_modules/home/component/body_home.tsx
+++ b/src/app_modules/home/component/body_home.tsx
@@ -2,14 +2,16 @@ import { RouterProfile } from "@/app/lib/router_hipmi/router_katalog";
import { AccentColor, MainColor } from "@/app_modules/_global/color";
import ComponentGlobal_IsEmptyData from "@/app_modules/_global/component/is_empty_data";
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global";
+import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
import {
ActionIcon,
Box,
+ Flex,
+ Grid,
Group,
Image,
Paper,
SimpleGrid,
- Skeleton,
Stack,
Text,
} from "@mantine/core";
@@ -20,11 +22,12 @@ import { useRouter } from "next/navigation";
import { useState } from "react";
import { apiGetDataHome } from "../fun/get/api_home";
import { listMenuHomeBody, menuHomeJob } from "./list_menu_home";
+import { clientLogger } from "@/util/clientLogger";
export default function BodyHome() {
const router = useRouter();
- const [dataUser, setDataUser] = useState({});
- const [dataJob, setDataJob] = useState([]);
+ const [dataUser, setDataUser] = useState(null);
+ const [dataJob, setDataJob] = useState(null);
const [loadingJob, setLoadingJob] = useState(true);
const [loading, setLoading] = useState(true);
@@ -35,24 +38,33 @@ export default function BodyHome() {
async function cekUserLogin() {
try {
- const response = await apiGetDataHome("?cat=cek_profile");
- if (response.success) {
+ const response = await apiGetDataHome({
+ path: "?cat=cek_profile",
+ });
+
+ if (response) {
setDataUser(response.data);
}
} catch (error) {
- console.error(error);
- }
+ clientLogger.error("Error get data profile", error);
+ }
}
+
+
async function getHomeJob() {
try {
setLoadingJob(true);
- const response = await apiGetDataHome("?cat=job");
- if (response.success) {
+
+ const response = await apiGetDataHome({
+ path: "?cat=job",
+ });
+
+ if (response) {
setDataJob(response.data);
}
} catch (error) {
- console.error(error);
+ clientLogger.error("Error get data job", error);
} finally {
setLoadingJob(false);
}
@@ -60,19 +72,6 @@ export default function BodyHome() {
return (
- {/*
-
- */}
-
{
- if (
- dataUser.profile == undefined ||
- dataUser?.profile == null ||
- dataJob.length == undefined ||
- dataJob.length == null
- ) {
+ if (dataUser == null) {
return null;
} else if (
- dataUser.profile == undefined ||
- dataUser?.profile == null
+ Object.keys(dataUser).length == 0 ||
+ dataJob?.length == null
) {
router.push(RouterProfile.create, { scroll: false });
} else {
@@ -129,11 +123,11 @@ export default function BodyHome() {
{e.icon}
-
+
{e.name}
@@ -153,16 +147,11 @@ export default function BodyHome() {
>
{
- if (
- dataUser.profile == undefined ||
- dataUser?.profile == null ||
- dataJob.length == undefined ||
- dataJob.length == null
- ) {
+ if (dataUser == null) {
return null;
} else if (
- dataUser.profile == undefined ||
- dataUser?.profile == null
+ Object.keys(dataUser).length == 0 ||
+ dataJob?.length == null
) {
router.push(RouterProfile.create, { scroll: false });
} else {
@@ -180,33 +169,50 @@ export default function BodyHome() {
{menuHomeJob.icon}
-
+
{menuHomeJob.name}
{loadingJob ? (
- Array(2)
+ Array(1)
.fill(null)
.map((_, i) => (
-
-
-
+
+
+
+
+
+
+
+
+
+
))
) : _.isEmpty(dataJob) ? (
) : (
- {dataJob.map((e, i) => (
+ {dataJob?.map((e, i) => (
-
+
{e?.Author.username}
-
+
{e?.title}
diff --git a/src/app_modules/home/component/footer_home.tsx b/src/app_modules/home/component/footer_home.tsx
index 9fe2d9a1..87a6a4f2 100644
--- a/src/app_modules/home/component/footer_home.tsx
+++ b/src/app_modules/home/component/footer_home.tsx
@@ -16,10 +16,13 @@ import { useState } from "react";
import { apiGetDataHome } from "../fun/get/api_home";
import { Home_ComponentAvatarProfile } from "./comp_avatar_profile";
import { listMenuHomeFooter } from "./list_menu_home";
+import { MainColor } from "@/app_modules/_global/color";
+import { clientLogger } from "@/util/clientLogger";
+import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
export default function FooterHome() {
const router = useRouter();
- const [dataUser, setDataUser] = useState({});
+ const [dataUser, setDataUser] = useState(null);
useShallowEffect(() => {
cekUserLogin();
@@ -27,12 +30,14 @@ export default function FooterHome() {
async function cekUserLogin() {
try {
- const response = await apiGetDataHome("?cat=cek_profile");
- if (response.success) {
+ const response = await apiGetDataHome({
+ path: "?cat=cek_profile",
+ });
+ if (response) {
setDataUser(response.data);
}
} catch (error) {
- console.error(error);
+ clientLogger.error("Error get data profile", error);
}
}
@@ -46,81 +51,95 @@ export default function FooterHome() {
bottom={0}
h={"9vh"}
>
-
- {listMenuHomeFooter.map((e) => (
-
+ {dataUser == null ? (
+
+ {Array.from(new Array(4)).map((_, i) => (
+
+
+
+
+
+ ))}
+
+ ) : (
+
+ {listMenuHomeFooter.map((e) => (
+
+ {
+ if (dataUser == null) {
+ return null;
+ } else if (Object.keys(dataUser).length === 0) {
+ router.push(RouterProfile.create, { scroll: false });
+ } else {
+ if (e.link == "") {
+ ComponentGlobal_NotifikasiPeringatan("Cooming Soon");
+ } else {
+ router.push(e.link, { scroll: false });
+ }
+ }
+ }}
+ >
+
+ {e.icon}
+
+
+ {e.name}
+
+
+
+ ))}
+
+
{
if (
dataUser.profile === undefined ||
dataUser?.profile === null
- ) {
- return null;
- } else if (
- dataUser.profile === undefined ||
- dataUser?.profile === null
) {
router.push(RouterProfile.create, { scroll: false });
} else {
- if (e.link == "") {
- ComponentGlobal_NotifikasiPeringatan("Cooming Soon");
- } else {
- router.push(e.link, { scroll: false });
- }
+ router.push(
+ RouterProfile.katalogOLD + `${dataUser?.profile}`,
+ {
+ scroll: false,
+ }
+ );
}
}}
>
-
- {e.icon}
+
+ {dataUser.profile === undefined ||
+ dataUser?.profile === null ? (
+
+ ) : (
+
+ )}
-
- {e.name}
+
+ Profile
- ))}
-
-
- {
- if (
- dataUser.profile === undefined ||
- dataUser?.profile === null
- ) {
- router.push(RouterProfile.create, { scroll: false });
- } else {
- router.push(RouterProfile.katalogOLD + `${dataUser?.profile}`, {
- scroll: false,
- });
- }
- }}
- >
-
- {dataUser.profile === undefined || dataUser?.profile === null ? (
-
- ) : (
-
- )}
-
-
- Profile
-
-
-
-
+
+ )}
);
}
diff --git a/src/app_modules/home/state/global_state.ts b/src/app_modules/home/component/global_state.ts
similarity index 79%
rename from src/app_modules/home/state/global_state.ts
rename to src/app_modules/home/component/global_state.ts
index 638d7246..5b97c4ef 100644
--- a/src/app_modules/home/state/global_state.ts
+++ b/src/app_modules/home/component/global_state.ts
@@ -1,3 +1,4 @@
import { atomWithStorage } from "jotai/utils";
+import { atom } from "jotai";
export const gs_token = atomWithStorage("gs_token", null);
diff --git a/src/app_modules/home/fun/get/api_home.ts b/src/app_modules/home/fun/get/api_home.ts
index e55ec5eb..8600b3aa 100644
--- a/src/app_modules/home/fun/get/api_home.ts
+++ b/src/app_modules/home/fun/get/api_home.ts
@@ -1,4 +1,17 @@
-export const apiGetDataHome = async (path?: string) => {
- const response = await fetch(`/api/new/home${(path) ? path : ''}`)
- return await response.json().catch(() => null)
-}
\ No newline at end of file
+export const apiGetDataHome = async ({ path }: { path?: string }) => {
+ const { token } = await fetch("/api/get-cookie").then((res) => res.json());
+ if (!token) return await token.json().catch(() => null);
+
+ const response = await fetch(`/api/new/home${path ? path : ""}`, {
+ headers: {
+ "Content-Type": "application/json",
+ Accept: "application/json",
+ "Access-Control-Allow-Origin": "*",
+ Authorization: `Bearer ${token}`,
+ },
+ });
+
+ if (!response.ok) return null;
+ const data: Record = await response.json();
+ return data;
+};
diff --git a/src/app_modules/home/view_home_new.tsx b/src/app_modules/home/view_home_new.tsx
index bd5cc8cc..7673e2f2 100644
--- a/src/app_modules/home/view_home_new.tsx
+++ b/src/app_modules/home/view_home_new.tsx
@@ -17,11 +17,13 @@ import { gs_notifikasi_kategori_app } from "../notifikasi/lib";
import BodyHome from "./component/body_home";
import FooterHome from "./component/footer_home";
import { apiGetDataHome } from "./fun/get/api_home";
+import { clientLogger } from "@/util/clientLogger";
+import CustomSkeleton from "../components/CustomSkeleton";
export default function HomeViewNew() {
const [countNtf, setCountNtf] = useAtom(gs_count_ntf);
const [newUserNtf, setNewUserNtf] = useAtom(gs_user_ntf);
- const [dataUser, setDataUser] = useState({});
+ const [dataUser, setDataUser] = useState(null);
const [categoryPage, setCategoryPage] = useAtom(gs_notifikasi_kategori_app);
const router = useRouter();
@@ -48,12 +50,14 @@ export default function HomeViewNew() {
async function cekUserLogin() {
try {
- const response = await apiGetDataHome("?cat=cek_profile");
- if (response.success) {
+ const response = await apiGetDataHome({
+ path: "?cat=cek_profile",
+ });
+ if (response) {
setDataUser(response.data);
}
} catch (error) {
- console.error(error);
+ clientLogger.error("Error get data home", error);
}
}
@@ -64,61 +68,69 @@ export default function HomeViewNew() {
{
- if (
- dataUser.profile != undefined ||
- dataUser?.profile != null
- ) {
- router.push(RouterUserSearch.main, { scroll: false });
- } else {
- router.push(RouterProfile.create, { scroll: false });
- }
- }}
- >
-
-
+ dataUser == null ? (
+
+ ) : (
+ {
+ if (
+ dataUser.profile != undefined ||
+ dataUser?.profile != null
+ ) {
+ router.push(RouterUserSearch.main, { scroll: false });
+ } else {
+ router.push(RouterProfile.create, { scroll: false });
+ }
+ }}
+ >
+
+
+ )
}
customButtonRight={
- {
- if (
- dataUser.profile != undefined ||
- dataUser?.profile != null
- ) {
- setCategoryPage("Semua");
- router.push(
- RouterNotifikasi.categoryApp({ name: "semua" }),
- {
- scroll: false,
- }
- );
- } else {
- router.push(RouterProfile.create, { scroll: false });
- }
- }}
- >
- {countNtf != null && countNtf > 0 ? (
-
- {countNtf > 99 ? "99+" : countNtf}
-
+ dataUser == null ? (
+
+ ) : (
+ {
+ if (
+ dataUser.profile != undefined ||
+ dataUser?.profile != null
+ ) {
+ setCategoryPage("Semua");
+ router.push(
+ RouterNotifikasi.categoryApp({ name: "semua" }),
+ {
+ scroll: false,
+ }
+ );
+ } else {
+ router.push(RouterProfile.create, { scroll: false });
}
- >
-
-
- ) : (
-
- )}
-
+ }}
+ >
+ {countNtf != null && countNtf > 0 ? (
+
+ {countNtf > 99 ? "99+" : countNtf}
+
+ }
+ >
+
+
+ ) : (
+
+ )}
+
+ )
}
/>
}
diff --git a/src/app_modules/investasi/_component/comp_card_border_and_background.tsx b/src/app_modules/investasi/_component/comp_card_border_and_background.tsx
index a6942af2..28c496b0 100644
--- a/src/app_modules/investasi/_component/comp_card_border_and_background.tsx
+++ b/src/app_modules/investasi/_component/comp_card_border_and_background.tsx
@@ -1,4 +1,4 @@
-import { AccentColor } from "@/app_modules/_global/color";
+import { AccentColor, MainColor } from "@/app_modules/_global/color";
import { Card } from "@mantine/core";
import React from "react";
@@ -26,7 +26,7 @@ export function Investasi_ComponentStylesCard({
paddingInline: "15px",
paddingBlock: "15px",
borderRadius: "10px",
- color: "white",
+ color: MainColor.white,
marginBottom: marginBottom ? marginBottom : "0x",
}}
onClick={onClickHandler}
diff --git a/src/app_modules/investasi/_component/detail/comp_box_daftar_berita.tsx b/src/app_modules/investasi/_component/detail/comp_box_daftar_berita.tsx
index 84919ace..9ad879b3 100644
--- a/src/app_modules/investasi/_component/detail/comp_box_daftar_berita.tsx
+++ b/src/app_modules/investasi/_component/detail/comp_box_daftar_berita.tsx
@@ -2,7 +2,7 @@ import {
NEW_RouterInvestasi,
RouterInvestasi_OLD,
} from "@/app/lib/router_hipmi/router_investasi";
-import { AccentColor } from "@/app_modules/_global/color";
+import { AccentColor, MainColor } from "@/app_modules/_global/color";
import { ActionIcon, Flex, Loader, Paper, Text } from "@mantine/core";
import { IconFileDescription } from "@tabler/icons-react";
import { useRouter } from "next/navigation";
@@ -34,12 +34,12 @@ export function Investasi_ComponentBoxDaftarBerita({
}}
>
- Berita
+ Berita
{isLoading ? (
) : (
-
+
)}
diff --git a/src/app_modules/investasi/_component/detail/comp_box_daftar_dokumen.tsx b/src/app_modules/investasi/_component/detail/comp_box_daftar_dokumen.tsx
index a422ac7c..b930f4e1 100644
--- a/src/app_modules/investasi/_component/detail/comp_box_daftar_dokumen.tsx
+++ b/src/app_modules/investasi/_component/detail/comp_box_daftar_dokumen.tsx
@@ -2,7 +2,7 @@ import {
NEW_RouterInvestasi,
RouterInvestasi_OLD,
} from "@/app/lib/router_hipmi/router_investasi";
-import { AccentColor } from "@/app_modules/_global/color";
+import { AccentColor, MainColor } from "@/app_modules/_global/color";
import { ActionIcon, Flex, Loader, Paper, Text } from "@mantine/core";
import { IconFileDescription } from "@tabler/icons-react";
import { useRouter } from "next/navigation";
@@ -35,12 +35,12 @@ export function Investasi_ComponentBoxDaftarDokumen({
}}
>
- Dokumen
+ Dokumen
{isLoading ? (
) : (
-
+
)}
diff --git a/src/app_modules/investasi/_component/detail/comp_box_prospektus.tsx b/src/app_modules/investasi/_component/detail/comp_box_prospektus.tsx
index 1af7d87e..8c94af37 100644
--- a/src/app_modules/investasi/_component/detail/comp_box_prospektus.tsx
+++ b/src/app_modules/investasi/_component/detail/comp_box_prospektus.tsx
@@ -1,5 +1,5 @@
import { NEW_RouterInvestasi } from "@/app/lib/router_hipmi/router_investasi";
-import { AccentColor } from "@/app_modules/_global/color";
+import { AccentColor, MainColor } from "@/app_modules/_global/color";
import { ActionIcon, Flex, Loader, Paper, Text } from "@mantine/core";
import { IconBookDownload } from "@tabler/icons-react";
import { useRouter } from "next/navigation";
@@ -32,12 +32,12 @@ export function Investasi_ComponentBoxProspektus({
}}
>
- Prospektus
+ Prospektus
{isLoading ? (
) : (
-
+
)}
diff --git a/src/app_modules/investasi/_component/detail/comp_title_and_value_in_detail.tsx b/src/app_modules/investasi/_component/detail/comp_title_and_value_in_detail.tsx
index 3f8ca614..84e93f58 100644
--- a/src/app_modules/investasi/_component/detail/comp_title_and_value_in_detail.tsx
+++ b/src/app_modules/investasi/_component/detail/comp_title_and_value_in_detail.tsx
@@ -1,3 +1,4 @@
+import { MainColor } from "@/app_modules/_global/color";
import { Grid, Text } from "@mantine/core";
import { data } from "autoprefixer";
import React from "react";
@@ -13,7 +14,7 @@ export function Investasi_ComponentTitleAndValueInDetail({
<>
- {title}
+ {title}
:
{value}
diff --git a/src/app_modules/investasi/_component/detail/saham_saya/comp_detail_data.tsx b/src/app_modules/investasi/_component/detail/saham_saya/comp_detail_data.tsx
index 7457c457..5df62a04 100644
--- a/src/app_modules/investasi/_component/detail/saham_saya/comp_detail_data.tsx
+++ b/src/app_modules/investasi/_component/detail/saham_saya/comp_detail_data.tsx
@@ -15,6 +15,7 @@ import {
import { Investasi_ComponentBoxDaftarBerita } from "../comp_box_daftar_berita";
import { Investasi_ComponentBoxDaftarDokumen } from "../comp_box_daftar_dokumen";
import { Investasi_ComponentBoxProspektus } from "../comp_box_prospektus";
+import { MainColor } from "@/app_modules/_global/color";
export function Investasi_ComponentBoxDetailData({
data,
@@ -31,7 +32,7 @@ export function Investasi_ComponentBoxDetailData({
-
+
{data?.Investasi.title}
diff --git a/src/app_modules/investasi/_component/detail/saham_saya/comp_harga_dan_lembar.tsx b/src/app_modules/investasi/_component/detail/saham_saya/comp_harga_dan_lembar.tsx
index 5effc7a5..91a5d44f 100644
--- a/src/app_modules/investasi/_component/detail/saham_saya/comp_harga_dan_lembar.tsx
+++ b/src/app_modules/investasi/_component/detail/saham_saya/comp_harga_dan_lembar.tsx
@@ -6,6 +6,7 @@ import { Stack, Grid, Text } from "@mantine/core";
import { data } from "autoprefixer";
import { Investasi_ComponentStylesCard } from "../../comp_card_border_and_background";
import { MODEL_INVOICE_INVESTASI } from "@/app_modules/investasi/_lib/interface";
+import { MainColor } from "@/app_modules/_global/color";
export function Investasi_ComponentBoxHargaDanLembarSaham({
data,
@@ -19,7 +20,7 @@ export function Investasi_ComponentBoxHargaDanLembarSaham({
- Transaksi Saham
+ Transaksi Saham
- Saham Terbeli
+ Saham Terbeli
- Progres Saham
+ Progres Saham
diff --git a/src/app_modules/investasi/_component/main/comp_card_daftar_transaksi_new.tsx b/src/app_modules/investasi/_component/main/comp_card_daftar_transaksi_new.tsx
index 0ada112b..70b0ae09 100644
--- a/src/app_modules/investasi/_component/main/comp_card_daftar_transaksi_new.tsx
+++ b/src/app_modules/investasi/_component/main/comp_card_daftar_transaksi_new.tsx
@@ -1,5 +1,5 @@
import { NEW_RouterInvestasi } from "@/app/lib/router_hipmi/router_investasi";
-import { AccentColor } from "@/app_modules/_global/color/color_pallet";
+import { AccentColor, MainColor } from "@/app_modules/_global/color/color_pallet";
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global/notifikasi_peringatan";
import { Card, Group, Stack, Text, Title } from "@mantine/core";
import { useRouter } from "next/navigation";
@@ -48,7 +48,7 @@ export function Investasi_ComponentCardDaftarTransaksiNew({ data }: { data: IDat
backgroundColor: AccentColor.darkblue,
border: `2px solid ${AccentColor.blue}`,
borderRadius: "10px",
- color: "white",
+ color: MainColor.white,
}}
mb={"md"}
onClick={() =>
diff --git a/src/app_modules/investasi/_component/main/comp_card_saham_saya_new.tsx b/src/app_modules/investasi/_component/main/comp_card_saham_saya_new.tsx
index bfaee9d9..9e4a7f7a 100644
--- a/src/app_modules/investasi/_component/main/comp_card_saham_saya_new.tsx
+++ b/src/app_modules/investasi/_component/main/comp_card_saham_saya_new.tsx
@@ -27,12 +27,12 @@ export function Investasi_ComponentSahamSayaNew({ data }: { data: IDataSahamSaya
@@ -51,7 +51,7 @@ export function Investasi_ComponentSahamSayaNew({ data }: { data: IDataSahamSaya
backgroundColor: MainColor.yellow,
},
root: {
- backgroundColor: "whitesmoke",
+ backgroundColor: MainColor.white,
},
label: {
color: "black",
diff --git a/src/app_modules/investasi/_lib/api_interface.ts b/src/app_modules/investasi/_lib/api_interface.ts
index a1475cff..a31133b6 100644
--- a/src/app_modules/investasi/_lib/api_interface.ts
+++ b/src/app_modules/investasi/_lib/api_interface.ts
@@ -1,19 +1,64 @@
export const apiGetMasterInvestasi = async (path?: string) => {
- const response = await fetch(`/api/new/investasi/master${(path) ? path : ''}`)
- return await response.json().catch(() => null)
-}
+ const { token } = await fetch("/api/get-cookie").then((res) => res.json());
+ if (!token) return await token.json().catch(() => null);
+
+ const response = await fetch(`/api/new/investasi/master${path ? path : ""}`, {
+ headers: {
+ "Content-Type": "application/json",
+ Accept: "application/json",
+ "Access-Control-Allow-Origin": "*",
+ Authorization: `Bearer ${token}`,
+ },
+ });
+
+ return await response.json().catch(() => null);
+};
export const apiGetOneInvestasiById = async (path: string) => {
- const response = await fetch(`/api/new/investasi/${path}`)
- return await response.json().catch(() => null)
-}
+ const { token } = await fetch("/api/get-cookie").then((res) => res.json());
+ if (!token) return await token.json().catch(() => null);
+
+ const response = await fetch(`/api/new/investasi/${path}`, {
+ headers: {
+ "Content-Type": "application/json",
+ Accept: "application/json",
+ "Access-Control-Allow-Origin": "*",
+ Authorization: `Bearer ${token}`,
+ },
+ });
+ return await response.json().catch(() => null);
+};
export const apiGetAllInvestasi = async (path?: string) => {
- const response = await fetch(`/api/new/investasi${(path) ? path : ''}`)
- return await response.json().catch(() => null)
-}
+ const { token } = await fetch("/api/get-cookie").then((res) => res.json());
+ if (!token) return await token.json().catch(() => null);
+
+ const response = await fetch(`/api/new/investasi${path ? path : ""}`, {
+ headers: {
+ "Content-Type": "application/json",
+ Accept: "application/json",
+ "Access-Control-Allow-Origin": "*",
+ Authorization: `Bearer ${token}`,
+ },
+ });
+
+ return await response.json().catch(() => null);
+};
export const apiGetAllSahamSaya = async (path?: string) => {
- const response = await fetch(`/api/new/investasi/invoice${(path) ? path : ''}`)
- return await response.json().catch(() => null)
-}
\ No newline at end of file
+ const { token } = await fetch("/api/get-cookie").then((res) => res.json());
+ if (!token) return await token.json().catch(() => null);
+
+ const response = await fetch(
+ `/api/new/investasi/invoice${path ? path : ""}`,
+ {
+ headers: {
+ "Content-Type": "application/json",
+ Accept: "application/json",
+ "Access-Control-Allow-Origin": "*",
+ Authorization: `Bearer ${token}`,
+ },
+ }
+ );
+ return await response.json().catch(() => null);
+};
diff --git a/src/app_modules/investasi/_ui/detail/ui_detail_main.tsx b/src/app_modules/investasi/_ui/detail/ui_detail_main.tsx
index 94bfc7b1..c8e7d345 100644
--- a/src/app_modules/investasi/_ui/detail/ui_detail_main.tsx
+++ b/src/app_modules/investasi/_ui/detail/ui_detail_main.tsx
@@ -16,6 +16,7 @@ import {
RouterInvestasi_OLD,
} from "@/app/lib/router_hipmi/router_investasi";
import { IconDeviceIpadPlus } from "@tabler/icons-react";
+import { MainColor } from "@/app_modules/_global/color";
export function Investasi_UiDetailMain({
dataInvestasi,
@@ -54,7 +55,7 @@ export function Investasi_UiDetailMain({
variant="transparent"
onClick={() => setOpenDrawer(true)}
>
-
+
) : (
diff --git a/src/app_modules/investasi/_ui/detail/ui_detail_portofolio.tsx b/src/app_modules/investasi/_ui/detail/ui_detail_portofolio.tsx
index aae4d214..1399f467 100644
--- a/src/app_modules/investasi/_ui/detail/ui_detail_portofolio.tsx
+++ b/src/app_modules/investasi/_ui/detail/ui_detail_portofolio.tsx
@@ -23,6 +23,7 @@ import {
Investasi_ViewDetailReview,
} from "../../_view";
import ComponentGlobal_Loader from "@/app_modules/_global/component/loader";
+import { MainColor } from "@/app_modules/_global/color";
export function Investasi_UiDetailPortofolio({
dataInvestasi,
@@ -69,7 +70,7 @@ export function Investasi_UiDetailPortofolio({
variant="transparent"
onClick={() => setOpenDrawer(true)}
>
-
+
}
/>
@@ -93,7 +94,7 @@ export function Investasi_UiDetailPortofolio({
{
setPageId(e?.id);
setLoading(true);
@@ -109,7 +110,7 @@ export function Investasi_UiDetailPortofolio({
e?.icon
)}
-
+
{e?.name}
diff --git a/src/app_modules/investasi/_ui/main/ui_portofolio_new.tsx b/src/app_modules/investasi/_ui/main/ui_portofolio_new.tsx
index 05b97ad2..66bc7b56 100644
--- a/src/app_modules/investasi/_ui/main/ui_portofolio_new.tsx
+++ b/src/app_modules/investasi/_ui/main/ui_portofolio_new.tsx
@@ -60,8 +60,8 @@ export function Investasi_UiPortofolioNew() {
style={{
transition: "ease 0.5s ",
backgroundColor:
- param.id === e.id ? MainColor.yellow : AccentColor.blue,
- color: param.id === e.id ? "black" : "white",
+ param.id === e.id ? MainColor.yellow : MainColor.white,
+ color: param.id === e.id ? MainColor.darkblue : MainColor.black,
}}
>
{e.name}
diff --git a/src/app_modules/investasi/_view/detail/portofolio/view_detail_draft.tsx b/src/app_modules/investasi/_view/detail/portofolio/view_detail_draft.tsx
index 33df1681..fe2a4285 100644
--- a/src/app_modules/investasi/_view/detail/portofolio/view_detail_draft.tsx
+++ b/src/app_modules/investasi/_view/detail/portofolio/view_detail_draft.tsx
@@ -1,7 +1,7 @@
"use client";
import { NEW_RouterInvestasi } from "@/app/lib/router_hipmi/router_investasi";
-import { MainColor } from "@/app_modules/_global/color/color_pallet";
+import { AccentColor, MainColor } from "@/app_modules/_global/color/color_pallet";
import ComponentGlobal_BoxInformation from "@/app_modules/_global/component/box_information";
import { funGlobal_DeleteFileById } from "@/app_modules/_global/fun";
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
@@ -13,6 +13,7 @@ import { MODEL_INVESTASI } from "@/app_modules/investasi/_lib/interface";
import { investasi_funEditStatusById } from "@/app_modules/investasi/fun/edit/fun_edit_status_by_id";
import funDeleteInvestasi from "@/app_modules/investasi/fun/fun_delete_investasi";
import notifikasiToAdmin_funCreate from "@/app_modules/notifikasi/fun/create/create_notif_to_admin";
+import { clientLogger } from "@/util/clientLogger";
import mqtt_client from "@/util/mqtt_client";
import { Button, Group, Stack } from "@mantine/core";
import _ from "lodash";
@@ -39,72 +40,83 @@ export default function Investasi_ViewDetailDraft({
statusId: "2",
});
- if (res.status === 200) {
+ try {
setIsLoading(true);
- ComponentGlobal_NotifikasiBerhasil("Review Berhasil Diajukan");
- router.replace(NEW_RouterInvestasi.portofolio({ id: "2" }));
-
- const dataNotif = {
- appId: res.data?.id,
- userId: res.data?.authorId,
- pesan: res.data?.title,
- status: res.data?.MasterStatusInvestasi?.name,
- kategoriApp: "INVESTASI",
- title: "Mengajukan review",
- };
-
- const notif = await notifikasiToAdmin_funCreate({
- data: dataNotif as any,
- });
-
- if (notif.status === 201) {
- mqtt_client.publish("ADMIN", JSON.stringify({ count: 1 }));
+ if (res.status === 200) {
+ ComponentGlobal_NotifikasiBerhasil("Review Berhasil Diajukan");
+ router.replace(NEW_RouterInvestasi.portofolio({ id: "2" }));
+
+ const dataNotif = {
+ appId: res.data?.id,
+ userId: res.data?.authorId,
+ pesan: res.data?.title,
+ status: res.data?.MasterStatusInvestasi?.name,
+ kategoriApp: "INVESTASI",
+ title: "Mengajukan review",
+ };
+
+ const notif = await notifikasiToAdmin_funCreate({
+ data: dataNotif as any,
+ });
+
+ if (notif.status === 201) {
+ mqtt_client.publish("ADMIN", JSON.stringify({ count: 1 }));
+ }
+ } else {
+ setIsLoading(false);
+ ComponentGlobal_NotifikasiGagal(res.message);
}
- } else {
- ComponentGlobal_NotifikasiGagal(res.message);
+ } catch (error) {
+ setIsLoading(false);
+ clientLogger.error("Error update investasi", error);
}
}
async function onDelete() {
const res = await funDeleteInvestasi(data.id);
- if (res.status === 200) {
+ try {
setIsLoadingDelete(true);
-
- const delImage = await funGlobal_DeleteFileById({
- fileId: data.imageId,
- });
- if (!delImage.success) {
- ComponentAdminGlobal_NotifikasiPeringatan("Gagal hapus image ");
- }
-
- const delFileProspektus = await funGlobal_DeleteFileById({
- fileId: data.prospektusFileId,
- });
- if (!delFileProspektus.success) {
- ComponentAdminGlobal_NotifikasiPeringatan("Gagal hapus prospektus ");
- }
-
- if (!_.isEmpty(data.DokumenInvestasi)) {
- for (let i of data.DokumenInvestasi) {
- const delFileDokumen = await funGlobal_DeleteFileById({
- fileId: i.fileId,
- });
-
- if (!delFileDokumen.success) {
- ComponentAdminGlobal_NotifikasiPeringatan(
- "Gagal hapus prospektus "
- );
+ if (res.status === 200) {
+
+ const delImage = await funGlobal_DeleteFileById({
+ fileId: data.imageId,
+ });
+ if (!delImage.success) {
+ ComponentAdminGlobal_NotifikasiPeringatan("Gagal hapus image ");
+ }
+
+ const delFileProspektus = await funGlobal_DeleteFileById({
+ fileId: data.prospektusFileId,
+ });
+ if (!delFileProspektus.success) {
+ ComponentAdminGlobal_NotifikasiPeringatan("Gagal hapus prospektus ");
+ }
+
+ if (!_.isEmpty(data.DokumenInvestasi)) {
+ for (let i of data.DokumenInvestasi) {
+ const delFileDokumen = await funGlobal_DeleteFileById({
+ fileId: i.fileId,
+ });
+
+ if (!delFileDokumen.success) {
+ ComponentAdminGlobal_NotifikasiPeringatan(
+ "Gagal hapus prospektus "
+ );
+ }
}
}
+
+ ComponentGlobal_NotifikasiBerhasil(res.message);
+ setOpenModal(false);
+ router.replace(NEW_RouterInvestasi.portofolio({ id: "3" }));
+ setIsLoadingDelete(false);
+ } else {
+ ComponentGlobal_NotifikasiGagal(res.message);
+ setIsLoadingDelete(false);
}
-
- ComponentGlobal_NotifikasiBerhasil(res.message);
- setOpenModal(false);
- router.replace(NEW_RouterInvestasi.portofolio({ id: "3" }));
- setIsLoadingDelete(false);
- } else {
- ComponentGlobal_NotifikasiGagal(res.message);
+ } catch (error) {
setIsLoadingDelete(false);
+ clientLogger.error("Error delete investasi", error);
}
}
@@ -119,9 +131,8 @@ export default function Investasi_ViewDetailDraft({
setOpenModal(true)}
>
Ajukan Review
@@ -129,8 +140,8 @@ export default function Investasi_ViewDetailDraft({
setOpenModalDelete(true)}
>
Hapus
@@ -144,19 +155,21 @@ export default function Investasi_ViewDetailDraft({
close={() => setOpenModal(false)}
title={"Anda yakin ingin mengajukan review ?"}
buttonKiri={
- setOpenModal(false)}>
+ setOpenModal(false)}>
Batal
}
buttonKanan={
onChangeStatus()}
>
Simpan
@@ -170,7 +183,8 @@ export default function Investasi_ViewDetailDraft({
close={() => setOpenModalDelete(false)}
title={"Anda yakin ingin menghapus ?"}
buttonKiri={
- setOpenModalDelete(false)}>
+ setOpenModalDelete(false)}>
Batal
}
@@ -178,11 +192,12 @@ export default function Investasi_ViewDetailDraft({
{
onDelete();
}}
diff --git a/src/app_modules/investasi/_view/detail/portofolio/view_detail_publish.tsx b/src/app_modules/investasi/_view/detail/portofolio/view_detail_publish.tsx
index e13258de..c06d20cc 100644
--- a/src/app_modules/investasi/_view/detail/portofolio/view_detail_publish.tsx
+++ b/src/app_modules/investasi/_view/detail/portofolio/view_detail_publish.tsx
@@ -80,7 +80,7 @@ export default function Investasi_ViewDetailPublish({
{/* Title dan Persentase */}
-
+
{_.startCase(data.title)}
@@ -90,12 +90,12 @@ export default function Investasi_ViewDetailPublish({
{data.Investasi_Invoice.length} }
+ value={{data.Investasi_Invoice.length} }
/>
+
Rp.{" "}
{new Intl.NumberFormat("id-ID", {
maximumSignificantDigits: 20,
@@ -107,7 +107,7 @@ export default function Investasi_ViewDetailPublish({
+
Rp.{" "}
{new Intl.NumberFormat("id-ID", {
maximumSignificantDigits: 10,
@@ -117,14 +117,14 @@ export default function Investasi_ViewDetailPublish({
/>
Return Of Invesment (RoI)}
- value={{data.roi} %}
+ title={Return Of Invesment (RoI)}
+ value={{data.roi} %}
/>
+
{new Intl.NumberFormat("id-ID", {
maximumSignificantDigits: 10,
}).format(+data.totalLembar)}{" "}
@@ -136,7 +136,7 @@ export default function Investasi_ViewDetailPublish({
+
{new Intl.NumberFormat("id-ID", {
maximumSignificantDigits: 10,
}).format(+data.sisaLembar)}{" "}
@@ -147,15 +147,15 @@ export default function Investasi_ViewDetailPublish({
{data.MasterPembagianDeviden.name} Bulan }
+ value={{data.MasterPembagianDeviden.name} Bulan }
/>
{data.MasterPeriodeDeviden.name}}
+ value={{data.MasterPeriodeDeviden.name}}
/>
{data.MasterPencarianInvestor.name} Hari }
+ value={{data.MasterPencarianInvestor.name} Hari }
/>
diff --git a/src/app_modules/investasi/_view/detail/portofolio/view_detail_reject.tsx b/src/app_modules/investasi/_view/detail/portofolio/view_detail_reject.tsx
index 17f9f89a..450695df 100644
--- a/src/app_modules/investasi/_view/detail/portofolio/view_detail_reject.tsx
+++ b/src/app_modules/investasi/_view/detail/portofolio/view_detail_reject.tsx
@@ -1,6 +1,7 @@
"use client";
import { NEW_RouterInvestasi } from "@/app/lib/router_hipmi/router_investasi";
+import { AccentColor, MainColor } from "@/app_modules/_global/color";
import ComponentGlobal_BoxInformation from "@/app_modules/_global/component/box_information";
import { funGlobal_DeleteFileById } from "@/app_modules/_global/fun";
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
@@ -11,6 +12,7 @@ import { Investasi_ComponentDetailDataNonPublish } from "@/app_modules/investasi
import { MODEL_INVESTASI } from "@/app_modules/investasi/_lib/interface";
import { investasi_funEditStatusById } from "@/app_modules/investasi/fun/edit/fun_edit_status_by_id";
import funDeleteInvestasi from "@/app_modules/investasi/fun/fun_delete_investasi";
+import { clientLogger } from "@/util/clientLogger";
import { Button, Group, Stack } from "@mantine/core";
import _ from "lodash";
import { useRouter } from "next/navigation";
@@ -23,8 +25,10 @@ export default function Investasi_ViewDetailReject({
}) {
const router = useRouter();
const [data, setData] = useState(dataInvestasi);
- const [openModal, setOpenModal] = useState(false);
- const [isLoading, setLoading] = useState(false);
+ const [openModalDel, setOpenModalDel] = useState(false);
+ const [openModalEdit, setOpenModalEdit] = useState(false);
+ const [isLoadingDel, setLoadingDel] = useState(false);
+ const [isLoadingEdit, setLoadingEdit] = useState(false);
async function onAjukan() {
const res = await investasi_funEditStatusById({
@@ -32,18 +36,25 @@ export default function Investasi_ViewDetailReject({
statusId: "3",
});
- if (res.status === 200) {
- ComponentGlobal_NotifikasiBerhasil("Project Diajukan Kembali");
- router.replace(NEW_RouterInvestasi.portofolio({ id: "3" }));
- } else {
- ComponentGlobal_NotifikasiGagal("Gagal Pengajuan");
+ try {
+ setLoadingEdit(true);
+ if (res.status === 200) {
+ ComponentGlobal_NotifikasiBerhasil("Project Diajukan Kembali");
+ router.replace(NEW_RouterInvestasi.portofolio({ id: "3" }));
+ } else {
+ setLoadingEdit(false);
+ ComponentGlobal_NotifikasiGagal("Gagal Pengajuan");
+ }
+ } catch (error) {
+ setLoadingEdit(false);
+ clientLogger.error("Error ajukan kembali", error);
}
}
async function onDelete() {
const res = await funDeleteInvestasi(data.id);
if (res.status === 200) {
- setLoading(true);
+ setLoadingDel(true);
const delImage = await funGlobal_DeleteFileById({
fileId: data.imageId,
@@ -74,12 +85,12 @@ export default function Investasi_ViewDetailReject({
}
ComponentGlobal_NotifikasiBerhasil(res.message);
- setOpenModal(false);
+ setOpenModalDel(false);
router.replace(NEW_RouterInvestasi.portofolio({ id: "4" }));
- setLoading(false);
+ setLoadingDel(false);
} else {
ComponentGlobal_NotifikasiGagal(res.message);
- setLoading(false);
+ setLoadingDel(false);
}
}
@@ -88,19 +99,20 @@ export default function Investasi_ViewDetailReject({
{/* Pop up */}
setOpenModal(false)}
+ opened={openModalDel}
+ close={() => setOpenModalDel(false)}
buttonKiri={
- setOpenModal(false)}>
+ setOpenModalDel(false)}>
Batal
}
buttonKanan={
onDelete()}
>
@@ -109,6 +121,30 @@ export default function Investasi_ViewDetailReject({
}
/>
+ setOpenModalEdit(false)}
+ buttonKiri={
+ setOpenModalEdit(false)}>
+ Batal
+
+ }
+ buttonKanan={
+ onAjukan()}
+ >
+ Edit
+
+ }
+ />
+
{/* Alasan */}
@@ -119,9 +155,9 @@ export default function Investasi_ViewDetailReject({
{/* Tombol Ajukan */}
onAjukan()}
+ style={{ backgroundColor: AccentColor.yellow }}
+ onClick={() => setOpenModalEdit(true)}
+ c={MainColor.darkblue}
>
Edit Kembali
@@ -129,9 +165,9 @@ export default function Investasi_ViewDetailReject({
{/* Tombol Hapus */}
setOpenModal(true)}
+ style={{ backgroundColor: MainColor.red }}
+ c={AccentColor.white}
+ onClick={() => setOpenModalDel(true)}
>
Hapus
diff --git a/src/app_modules/investasi/_view/detail/portofolio/view_detail_review.tsx b/src/app_modules/investasi/_view/detail/portofolio/view_detail_review.tsx
index 688dde83..9a3d75e4 100644
--- a/src/app_modules/investasi/_view/detail/portofolio/view_detail_review.tsx
+++ b/src/app_modules/investasi/_view/detail/portofolio/view_detail_review.tsx
@@ -1,6 +1,7 @@
"use client";
import { NEW_RouterInvestasi } from "@/app/lib/router_hipmi/router_investasi";
+import { AccentColor, MainColor } from "@/app_modules/_global/color";
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global/notifikasi_peringatan";
import { UIGlobal_Modal } from "@/app_modules/_global/ui";
@@ -8,6 +9,7 @@ import { Investasi_ComponentDetailDataNonPublish } from "@/app_modules/investasi
import { MODEL_INVESTASI } from "@/app_modules/investasi/_lib/interface";
import { investasi_funEditStatusById } from "@/app_modules/investasi/fun/edit/fun_edit_status_by_id";
import notifikasiToAdmin_funCreate from "@/app_modules/notifikasi/fun/create/create_notif_to_admin";
+import { clientLogger } from "@/util/clientLogger";
import mqtt_client from "@/util/mqtt_client";
import { Button, Stack } from "@mantine/core";
import { useRouter } from "next/navigation";
@@ -28,31 +30,36 @@ export default function Investasi_ViewDetailReview({
investasiId: data.id,
statusId: "3",
});
- if (res.status === 200) {
+ try {
setLoading(true);
- ComponentGlobal_NotifikasiBerhasil("Review Dibatalkan");
- router.replace(NEW_RouterInvestasi.portofolio({ id: "3" }));
-
- const dataNotif = {
- appId: res.data?.id,
- userId: res.data?.authorId,
- pesan: res.data?.title,
- status: res.data?.MasterStatusInvestasi?.name,
- kategoriApp: "INVESTASI",
- title: "Membatalkan review",
- };
-
- const notif = await notifikasiToAdmin_funCreate({
- data: dataNotif as any,
- });
-
- if (notif.status === 201) {
- mqtt_client.publish("ADMIN", JSON.stringify({ count: 1 }));
+ if (res.status === 200) {
+ ComponentGlobal_NotifikasiBerhasil("Review Dibatalkan");
+ router.replace(NEW_RouterInvestasi.portofolio({ id: "3" }));
+
+ const dataNotif = {
+ appId: res.data?.id,
+ userId: res.data?.authorId,
+ pesan: res.data?.title,
+ status: res.data?.MasterStatusInvestasi?.name,
+ kategoriApp: "INVESTASI",
+ title: "Membatalkan review",
+ };
+
+ const notif = await notifikasiToAdmin_funCreate({
+ data: dataNotif as any,
+ });
+
+ if (notif.status === 201) {
+ mqtt_client.publish("ADMIN", JSON.stringify({ count: 1 }));
+ }
+ setLoading(false);
+ } else {
+ ComponentGlobal_NotifikasiPeringatan(res.message);
+ setLoading(false);
}
+ } catch (error) {
setLoading(false);
- } else {
- ComponentGlobal_NotifikasiPeringatan(res.message);
- setLoading(false);
+ clientLogger.error("Error ajukan kembali", error);
}
}
@@ -65,9 +72,10 @@ export default function Investasi_ViewDetailReview({
setOpenModal(true)}
>
Batalkan Review
@@ -80,19 +88,21 @@ export default function Investasi_ViewDetailReview({
close={() => setOpenModal(false)}
title={"Anda yakin ingin batalkan review?"}
buttonKiri={
- setOpenModal(false)}>
+ setOpenModal(false)}>
Batal
}
buttonKanan={
onChangeStatus()}
>
Simpan
diff --git a/src/app_modules/investasi/_view/edit/skeleton_edit_investasi.tsx b/src/app_modules/investasi/_view/edit/skeleton_edit_investasi.tsx
index 20a43688..d0ea1348 100644
--- a/src/app_modules/investasi/_view/edit/skeleton_edit_investasi.tsx
+++ b/src/app_modules/investasi/_view/edit/skeleton_edit_investasi.tsx
@@ -1,20 +1,21 @@
-import { Box, Skeleton, Stack } from "@mantine/core";
+import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
+import { Box, Stack } from "@mantine/core";
export default function SkeletonEditInvestasi() {
return (
<>
-
-
-
+
+
+
{[...Array(5)].map((_, index) => (
-
+
))}
-
+
diff --git a/src/app_modules/investasi/_view/edit/vew_edit_investasi_new.tsx b/src/app_modules/investasi/_view/edit/vew_edit_investasi_new.tsx
index c7cdbf0b..54f11867 100644
--- a/src/app_modules/investasi/_view/edit/vew_edit_investasi_new.tsx
+++ b/src/app_modules/investasi/_view/edit/vew_edit_investasi_new.tsx
@@ -158,8 +158,14 @@ export function Investasi_ViewEditInvestasiNew() {
Rp.}
min={0}
@@ -213,8 +225,14 @@ export function Investasi_ViewEditInvestasiNew() {
Rp.}
min={0}
@@ -258,20 +276,28 @@ export function Investasi_ViewEditInvestasiNew() {
readOnly
styles={{
label: {
- color: "white",
+ color: MainColor.white,
},
-
input: {
- backgroundColor: "whitesmoke",
+ backgroundColor: MainColor.white
},
+ required: {
+ color: MainColor.red
+ }
}}
/>
@@ -294,8 +320,17 @@ export function Investasi_ViewEditInvestasiNew() {
-
+
diff --git a/src/app_modules/investasi/_view/main/skeleton_saham_saya.tsx b/src/app_modules/investasi/_view/main/skeleton_saham_saya.tsx
index 1aada275..2334fe63 100644
--- a/src/app_modules/investasi/_view/main/skeleton_saham_saya.tsx
+++ b/src/app_modules/investasi/_view/main/skeleton_saham_saya.tsx
@@ -1,5 +1,6 @@
import { ComponentGlobal_CardStyles } from "@/app_modules/_global/component";
-import { Grid, Skeleton } from "@mantine/core";
+import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
+import { Grid } from "@mantine/core";
export default function SkeletonInvestasiSahamSaya() {
return (
@@ -8,7 +9,7 @@ export default function SkeletonInvestasiSahamSaya() {
-
+
diff --git a/src/app_modules/investasi/_view/status_transaksi/view_invoice_berhasil.tsx b/src/app_modules/investasi/_view/status_transaksi/view_invoice_berhasil.tsx
index 87317b8a..0b3a9fcf 100644
--- a/src/app_modules/investasi/_view/status_transaksi/view_invoice_berhasil.tsx
+++ b/src/app_modules/investasi/_view/status_transaksi/view_invoice_berhasil.tsx
@@ -1,6 +1,6 @@
"use client";
-import { AccentColor } from "@/app_modules/_global/color/color_pallet";
+import { AccentColor, MainColor } from "@/app_modules/_global/color/color_pallet";
import {
ComponentGlobal_LoadImage,
ComponentGlobal_TampilanRupiah,
@@ -44,7 +44,7 @@ export function Investasi_ViewTransaksiBerhasil({
padding: "15px",
cursor: "pointer",
borderRadius: "10px",
- color: "white",
+ color: MainColor.white,
}}
>
@@ -61,7 +61,7 @@ export function Investasi_ViewTransaksiBerhasil({
padding: "15px",
cursor: "pointer",
borderRadius: "10px",
- color: "white",
+ color: MainColor.white,
marginBottom: "15px",
}}
>
diff --git a/src/app_modules/investasi/_view/transaksi/view_invoice.tsx b/src/app_modules/investasi/_view/transaksi/view_invoice.tsx
index ac6855c7..22b21722 100644
--- a/src/app_modules/investasi/_view/transaksi/view_invoice.tsx
+++ b/src/app_modules/investasi/_view/transaksi/view_invoice.tsx
@@ -110,7 +110,7 @@ export function Investasi_ViewInvoice({
padding: "15px",
cursor: "pointer",
borderRadius: "10px",
- color: "white",
+ color: MainColor.white,
}}
>
Mohon transfer ke rekening dibawah
@@ -123,7 +123,7 @@ export function Investasi_ViewInvoice({
padding: "15px",
cursor: "pointer",
borderRadius: "10px",
- color: "white",
+ color: MainColor.white,
marginBottom: "15px",
}}
>
@@ -181,7 +181,7 @@ export function Investasi_ViewInvoice({
padding: "15px",
cursor: "pointer",
borderRadius: "10px",
- color: "white",
+ color: MainColor.white,
marginBottom: "15px",
}}
>
@@ -196,7 +196,7 @@ export function Investasi_ViewInvoice({
padding: "15px",
cursor: "pointer",
borderRadius: "10px",
- color: "white",
+ color: MainColor.white,
}}
>
@@ -272,7 +272,7 @@ export function Investasi_ViewInvoice({
{file ? (
-
+
Upload berhasil{" "}
@@ -280,7 +280,7 @@ export function Investasi_ViewInvoice({
) : (
-
+
Upload bukti transfer anda !
diff --git a/src/app_modules/investasi/_view/transaksi/view_metode_pembayaran.tsx b/src/app_modules/investasi/_view/transaksi/view_metode_pembayaran.tsx
index eabb3f3d..ba719598 100644
--- a/src/app_modules/investasi/_view/transaksi/view_metode_pembayaran.tsx
+++ b/src/app_modules/investasi/_view/transaksi/view_metode_pembayaran.tsx
@@ -101,19 +101,19 @@ export function Investasi_ViewMetodePembayaran({
padding: "15px",
cursor: "pointer",
borderRadius: "10px",
- color: "white",
+ color: MainColor.white,
marginBottom: "15px",
}}
>
+
{e.namaBank}
}
diff --git a/src/app_modules/investasi/_view/transaksi/view_proses_pembelian.tsx b/src/app_modules/investasi/_view/transaksi/view_proses_pembelian.tsx
index c84522bb..78aae922 100644
--- a/src/app_modules/investasi/_view/transaksi/view_proses_pembelian.tsx
+++ b/src/app_modules/investasi/_view/transaksi/view_proses_pembelian.tsx
@@ -52,8 +52,8 @@ export function Investasi_ViewProsesPembelian({
>
{/* Sisa Lembar Saham */}
- Sisa Lembar Saham
-
+ Sisa Lembar Saham
+
{new Intl.NumberFormat("id-ID", {
maximumFractionDigits: 10,
}).format(+data.sisaLembar)}{" "}
@@ -62,8 +62,8 @@ export function Investasi_ViewProsesPembelian({
{/* Harga perlembar saham */}
- Harga Perlembar
-
+ Harga Perlembar
+
Rp.{" "}
{new Intl.NumberFormat("id-ID", {
maximumFractionDigits: 10,
@@ -74,12 +74,13 @@ export function Investasi_ViewProsesPembelian({
{/* Lembar saham */}
- Jumlah Pembelian
+ Jumlah Pembelian
minimal pembelian 10 lembar
-
+
- Total Harga
+ Total Harga
-
+
Rp.{" "}
{new Intl.NumberFormat("id-ID", {
maximumFractionDigits: 10,
diff --git a/src/app_modules/investasi/_view/transaksi/view_proses_transaksi.tsx b/src/app_modules/investasi/_view/transaksi/view_proses_transaksi.tsx
index 267cea6d..6d8882f6 100644
--- a/src/app_modules/investasi/_view/transaksi/view_proses_transaksi.tsx
+++ b/src/app_modules/investasi/_view/transaksi/view_proses_transaksi.tsx
@@ -30,7 +30,7 @@ export function Investasi_ViewProsesTransaksi({
padding: "15px",
cursor: "pointer",
borderRadius: "10px",
- color: "white",
+ color: MainColor.white,
}}
>
@@ -41,13 +41,13 @@ export function Investasi_ViewProsesTransaksi({
padding: "15px",
cursor: "pointer",
borderRadius: "10px",
- color: "white",
+ color: MainColor.white,
}}
>
Admin sedang memproses transaksimu
-
+
@@ -73,7 +73,7 @@ export function Investasi_ViewProsesTransaksi({
padding: "15px",
cursor: "pointer",
borderRadius: "10px",
- color: "white",
+ color: MainColor.white,
}}
>
@@ -94,7 +94,7 @@ export function Investasi_ViewProsesTransaksi({
target="_blank"
href={`https://wa.me/+${nomorAdmin.nomor}?text=Hallo Admin , Saya ada kendala dalam proses transfer investasi !`}
>
-
+
diff --git a/src/app_modules/investasi/component/detail/card_status.tsx b/src/app_modules/investasi/component/detail/card_status.tsx
index 85b79514..2fc26c32 100644
--- a/src/app_modules/investasi/component/detail/card_status.tsx
+++ b/src/app_modules/investasi/component/detail/card_status.tsx
@@ -3,7 +3,7 @@ import { Paper, Grid, Stack, AspectRatio, Text, Image } from "@mantine/core";
import _ from "lodash";
import { MODEL_INVESTASI } from "../../_lib/interface";
-import { AccentColor } from "@/app_modules/_global/color/color_pallet";
+import { AccentColor, MainColor } from "@/app_modules/_global/color/color_pallet";
import { useRouter } from "next/navigation";
export function ComponentInvestasi_CardStatus({
@@ -23,7 +23,7 @@ export function ComponentInvestasi_CardStatus({
backgroundColor: AccentColor.darkblue,
borderRadius: "10px",
border: `2px solid ${AccentColor.blue}`,
- color: "white",
+ color: MainColor.white,
marginBottom: "15px",
}}
>
diff --git a/src/app_modules/investasi/create/view_new.tsx b/src/app_modules/investasi/create/view_new.tsx
index 98ae33be..0459787c 100644
--- a/src/app_modules/investasi/create/view_new.tsx
+++ b/src/app_modules/investasi/create/view_new.tsx
@@ -276,8 +276,14 @@ export default function InvestasiCreateNew() {
Rp.}
min={0}
@@ -331,8 +343,14 @@ export default function InvestasiCreateNew() {
Rp.}
min={0}
@@ -378,16 +396,28 @@ export default function InvestasiCreateNew() {
readOnly
styles={{
label: {
- color: "white",
+ color: MainColor.white,
},
+ required: {
+ color: MainColor.red,
+ },
+ input: {
+ backgroundColor: MainColor.white,
+ }
}}
/>
@@ -409,7 +439,16 @@ export default function InvestasiCreateNew() {
@@ -127,6 +134,36 @@ export function ComponentMap_DetailData({
+
+ {
+ setOpenModal(false);
+ }}
+ buttonKanan={
+
+
+ Lanjutkan
+
+
+ }
+ buttonKiri={
+ setOpenModal(false)}>
+ Batal
+
+ }
+ />
>
);
}
diff --git a/src/app_modules/map/lib/api_map.ts b/src/app_modules/map/lib/api_map.ts
index f0368959..feb650b5 100644
--- a/src/app_modules/map/lib/api_map.ts
+++ b/src/app_modules/map/lib/api_map.ts
@@ -1,9 +1,30 @@
export const apiGetAllMap = async (path?: string) => {
- const response = await fetch(`/api/new/map${(path) ? path : ''}`)
- return await response.json().catch(() => null)
-}
+ const { token } = await fetch("/api/get-cookie").then((res) => res.json());
+ if (!token) return await token.json().catch(() => null);
+
+ const response = await fetch(`/api/new/map${path ? path : ""}`, {
+ headers: {
+ "Content-Type": "application/json",
+ Accept: "application/json",
+ "Access-Control-Allow-Origin": "*",
+ Authorization: `Bearer ${token}`,
+ },
+ });
+ return await response.json().catch(() => null);
+};
export const apiGetOneMapById = async (path: string) => {
- const response = await fetch(`/api/new/map/${path}`);
- return await response.json().catch(() => null);
-}
+ const { token } = await fetch("/api/get-cookie").then((res) => res.json());
+ if (!token) return await token.json().catch(() => null);
+
+
+ const response = await fetch(`/api/new/map/${path}`, {
+ headers: {
+ "Content-Type": "application/json",
+ Accept: "application/json",
+ "Access-Control-Allow-Origin": "*",
+ Authorization: `Bearer ${token}`,
+ },
+ });
+ return await response.json().catch(() => null);
+};
diff --git a/src/app_modules/map/ui/ui_custom_pin.tsx b/src/app_modules/map/ui/ui_custom_pin.tsx
index d9799565..93ccb1b7 100644
--- a/src/app_modules/map/ui/ui_custom_pin.tsx
+++ b/src/app_modules/map/ui/ui_custom_pin.tsx
@@ -26,9 +26,13 @@ import { map_funCustomPinMap } from "../fun";
import { defaultMapZoom } from "../lib/default_lat_long";
import { MODEL_MAP } from "../lib/interface";
import { APIs, DIRECTORY_ID } from "@/app/lib";
-import { funGlobal_UploadToStorage } from "@/app_modules/_global/fun";
+import {
+ funGlobal_DeleteFileById,
+ funGlobal_UploadToStorage,
+} from "@/app_modules/_global/fun";
import { MAX_SIZE } from "@/app_modules/_global/lib";
import { PemberitahuanMaksimalFile } from "@/app_modules/_global/lib/max_size";
+import { clientLogger } from "@/util/clientLogger";
export function UiMap_CustomPin({
dataMap,
@@ -172,34 +176,67 @@ export function UiMap_CustomPin({
-
+
>
);
}
-function ButtonSimpan({ mapId, filePin }: { mapId: string; filePin: File }) {
+function ButtonSimpan({
+ mapId,
+ filePin,
+ fileRemoveId,
+}: {
+ mapId: string;
+ filePin: File;
+ fileRemoveId: string;
+}) {
const router = useRouter();
const [isLoading, setLoading] = useState(false);
async function onCustom() {
- const uploadFileToStorage = await funGlobal_UploadToStorage({
- file: filePin,
- dirId: DIRECTORY_ID.map_pin,
- });
+ try {
+ setLoading(true);
+ const deletePin = await funGlobal_DeleteFileById({
+ fileId: fileRemoveId,
+ dirId: DIRECTORY_ID.map_pin,
+ });
+ if (!deletePin.success) {
+ setLoading(false);
+ clientLogger.error("Error delete logo", deletePin.message);
+ }
- if (!uploadFileToStorage.success)
- return ComponentGlobal_NotifikasiPeringatan("Gagal upload gambar");
+ const uploadFileToStorage = await funGlobal_UploadToStorage({
+ file: filePin,
+ dirId: DIRECTORY_ID.map_pin,
+ });
- const res = await map_funCustomPinMap({
- mapId: mapId,
- fileId: uploadFileToStorage.data.id,
- });
- res.status === 200
- ? (ComponentGlobal_NotifikasiBerhasil(res.message),
- setLoading(true),
- router.back())
- : ComponentGlobal_NotifikasiGagal(res.message);
+ if (!uploadFileToStorage.success) {
+ setLoading(false);
+ ComponentGlobal_NotifikasiPeringatan("Gagal upload gambar");
+ return;
+ }
+
+ const res = await map_funCustomPinMap({
+ mapId: mapId,
+ fileId: uploadFileToStorage.data.id,
+ });
+
+ if (res.status === 200) {
+ ComponentGlobal_NotifikasiBerhasil(res.message);
+ router.back();
+ } else {
+ setLoading(false);
+ ComponentGlobal_NotifikasiGagal(res.message);
+ }
+ } catch (error) {
+ setLoading(false);
+ clientLogger.error("Error custom pin", error);
+ }
}
return (
diff --git a/src/app_modules/map/ui/ui_map_new.tsx b/src/app_modules/map/ui/ui_map_new.tsx
index ac27da54..b6bc6656 100644
--- a/src/app_modules/map/ui/ui_map_new.tsx
+++ b/src/app_modules/map/ui/ui_map_new.tsx
@@ -26,7 +26,7 @@ export function UiMap_MapBoxViewNew({ mapboxToken, }: { mapboxToken: string }) {
try {
setLoading(true)
const response = await apiGetAllMap()
- if (response.success) {
+ if (response) {
setData(response.data)
}
} catch (error) {
diff --git a/src/app_modules/notifikasi/component/skeleton_view.tsx b/src/app_modules/notifikasi/component/skeleton_view.tsx
index c5d8f302..57a7a664 100644
--- a/src/app_modules/notifikasi/component/skeleton_view.tsx
+++ b/src/app_modules/notifikasi/component/skeleton_view.tsx
@@ -1,25 +1,26 @@
import { ComponentGlobal_CardStyles } from "@/app_modules/_global/component";
-import { Stack, Group, Skeleton, Divider } from "@mantine/core";
+import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
+import { Divider, Group, Stack } from "@mantine/core";
export default function Notifikasi_ComponentSkeletonView() {
return (
<>
- {Array.from({ length: 10 }).map((_, i) => (
+ {Array.from({ length: 3 }).map((_, i) => (
-
-
+
+
-
-
-
-
+
+
+
+
-
-
+
+
diff --git a/src/app_modules/user/lib/api_user.ts b/src/app_modules/user/lib/api_user.ts
index 7fca1371..824744de 100644
--- a/src/app_modules/user/lib/api_user.ts
+++ b/src/app_modules/user/lib/api_user.ts
@@ -1,4 +1,19 @@
export const apiGetUserProfile = async (path?: string) => {
- const response = await fetch(`/api/new/user${(path) ? path : ''}`)
- return await response.json().catch(() => null)
+ const { token } = await fetch("/api/get-cookie").then((res) => res.json());
+ if(!token) return null
+
+ const response = await fetch(`/api/new/user${(path) ? path : ''}`, {
+ headers: {
+ 'Content-Type': 'application/json',
+ 'Accept': 'application/json',
+ 'Access-Control-Allow-Origin': '*',
+ 'Authorization': `Bearer ${token}`,
+ }
+ })
+
+ // console.log(await response.json())
+
+ if (!response.ok) return null
+ const data: Record = await response.json()
+ return data
}
\ No newline at end of file
diff --git a/src/app_modules/vote/component/card_view_publish.tsx b/src/app_modules/vote/component/card_view_publish.tsx
index bc5288a0..c955100a 100644
--- a/src/app_modules/vote/component/card_view_publish.tsx
+++ b/src/app_modules/vote/component/card_view_publish.tsx
@@ -1,6 +1,6 @@
"use client";
-import { AccentColor } from "@/app_modules/_global/color/color_pallet";
+import { AccentColor, MainColor } from "@/app_modules/_global/color/color_pallet";
import {
ComponentGlobal_AvatarAndUsername,
ComponentGlobal_CardLoadingOverlay,
@@ -66,7 +66,7 @@ export default function ComponentVote_CardViewPublish({
root: {
backgroundColor: AccentColor.blue,
border: `1px solid ${AccentColor.skyblue}`,
- color: "white",
+ color: MainColor.white,
width: "70%",
},
}}
diff --git a/src/app_modules/vote/component/card_view_status.tsx b/src/app_modules/vote/component/card_view_status.tsx
index 58fd92d0..713e9768 100644
--- a/src/app_modules/vote/component/card_view_status.tsx
+++ b/src/app_modules/vote/component/card_view_status.tsx
@@ -1,6 +1,6 @@
"use client";
-import { AccentColor } from "@/app_modules/_global/color/color_pallet";
+import { AccentColor, MainColor } from "@/app_modules/_global/color/color_pallet";
import {
ComponentGlobal_CardLoadingOverlay,
ComponentGlobal_CardStyles,
@@ -46,7 +46,7 @@ export default function ComponentVote_CardViewStatus({
root: {
backgroundColor: AccentColor.blue,
border: `1px solid ${AccentColor.skyblue}`,
- color: "white",
+ color: MainColor.white,
width: "70%",
},
}}
diff --git a/src/app_modules/vote/component/detail/comp_layout_header_detail_publish.tsx b/src/app_modules/vote/component/detail/comp_layout_header_detail_publish.tsx
index 2024bb93..dca98de4 100644
--- a/src/app_modules/vote/component/detail/comp_layout_header_detail_publish.tsx
+++ b/src/app_modules/vote/component/detail/comp_layout_header_detail_publish.tsx
@@ -1,5 +1,5 @@
import { RouterVote } from "@/app/lib/router_hipmi/router_vote";
-import { AccentColor } from "@/app_modules/_global/color";
+import { AccentColor, MainColor } from "@/app_modules/_global/color";
import ComponentGlobal_Loader from "@/app_modules/_global/component/loader";
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
@@ -26,6 +26,7 @@ import { voting_funUpdateIsArsipById } from "../../fun";
import { MODEL_VOTING } from "../../model/interface";
import { voting_funGetOneVotingbyId } from "../../fun/get/fun_get_one_by_id";
+
export function Voting_ComponentLayoutHeaderDetailPublish({
votingId,
title,
@@ -177,7 +178,7 @@ function BoxIsAuthor({
{/* Daftar Kontributor */}
{
setIsLoading(true);
router.push(RouterVote.daftar_kontributor + votingId, {
@@ -187,7 +188,7 @@ function BoxIsAuthor({
>
{isLoading ? : }
-
+
Daftar Kontributor
@@ -195,7 +196,7 @@ function BoxIsAuthor({
{/* Arsip button */}
{
onSetDrawer({
drawer: false,
@@ -206,7 +207,7 @@ function BoxIsAuthor({
>
-
+
Update Arsip
diff --git a/src/app_modules/vote/component/detail/detail_data_sebelum_publish.tsx b/src/app_modules/vote/component/detail/detail_data_sebelum_publish.tsx
index 476c2888..da48b86d 100644
--- a/src/app_modules/vote/component/detail/detail_data_sebelum_publish.tsx
+++ b/src/app_modules/vote/component/detail/detail_data_sebelum_publish.tsx
@@ -10,7 +10,7 @@ import {
} from "@mantine/core";
import { IconCircle } from "@tabler/icons-react";
import { MODEL_VOTING } from "../../model/interface";
-import { AccentColor } from "@/app_modules/_global/color/color_pallet";
+import { AccentColor, MainColor } from "@/app_modules/_global/color/color_pallet";
export default function ComponentVote_DetailDataSebelumPublish
({
@@ -26,7 +26,7 @@ export default function ComponentVote_DetailDataSebelumPublish
backgroundColor: AccentColor.darkblue,
borderRadius: "10px",
border: `2px solid ${AccentColor.blue}`,
- color: "white",
+ color: MainColor.white,
}}
>
@@ -49,7 +49,7 @@ export default function ComponentVote_DetailDataSebelumPublish
root: {
backgroundColor: AccentColor.blue,
border: `1px solid ${AccentColor.skyblue}`,
- color: "white",
+ color: MainColor.white,
width: "80%",
},
}}
diff --git a/src/app_modules/vote/component/detail/detail_data_setelah_publish.tsx b/src/app_modules/vote/component/detail/detail_data_setelah_publish.tsx
index a78d5d47..0d51f7cd 100644
--- a/src/app_modules/vote/component/detail/detail_data_setelah_publish.tsx
+++ b/src/app_modules/vote/component/detail/detail_data_setelah_publish.tsx
@@ -1,11 +1,13 @@
"use client";
-import { AccentColor } from "@/app_modules/_global/color/color_pallet";
+import { AccentColor, MainColor } from "@/app_modules/_global/color/color_pallet";
import {
ComponentGlobal_AvatarAndUsername,
ComponentGlobal_CardStyles,
} from "@/app_modules/_global/component";
import { Badge, Center, Group, Stack, Text, Title } from "@mantine/core";
import { MODEL_VOTING } from "../../model/interface";
+import moment from "moment"
+import "moment/locale/id"
export default function ComponentVote_DetailDataSetelahPublish({
data,
@@ -43,24 +45,20 @@ export default function ComponentVote_DetailDataSetelahPublish({
root: {
backgroundColor: AccentColor.blue,
border: `1px solid ${AccentColor.skyblue}`,
- color: "white",
+ color: MainColor.white,
width: "80%",
},
}}
>
-
-
- {data?.awalVote.toLocaleDateString(["id-ID"], {
- dateStyle: "medium",
- })}
-
- -
-
- {data?.akhirVote.toLocaleDateString(["id-ID"], {
- dateStyle: "medium",
- })}
-
-
+
+ {data
+ ? moment(data.awalVote).format("ll")
+ : "tgl awal voting"}{" "}
+ -{" "}
+ {data
+ ? moment(data.akhirVote).format("ll")
+ : "tgl akhir voting"}
+
diff --git a/src/app_modules/vote/component/detail/detail_hasil_voting.tsx b/src/app_modules/vote/component/detail/detail_hasil_voting.tsx
index 61a872b6..53963913 100644
--- a/src/app_modules/vote/component/detail/detail_hasil_voting.tsx
+++ b/src/app_modules/vote/component/detail/detail_hasil_voting.tsx
@@ -1,6 +1,6 @@
"use client";
-import { AccentColor } from "@/app_modules/_global/color/color_pallet";
+import { AccentColor, MainColor } from "@/app_modules/_global/color/color_pallet";
import {
Avatar,
Card,
@@ -25,7 +25,7 @@ export default function ComponentVote_HasilVoting({
backgroundColor: AccentColor.darkblue,
borderRadius: "10px",
border: `2px solid ${AccentColor.blue}`,
- color: "white",
+ color: MainColor.white,
}}
>
diff --git a/src/app_modules/vote/component/skeleton_view.tsx b/src/app_modules/vote/component/skeleton_view.tsx
index 21baff8c..5496b500 100644
--- a/src/app_modules/vote/component/skeleton_view.tsx
+++ b/src/app_modules/vote/component/skeleton_view.tsx
@@ -1,5 +1,6 @@
import { ComponentGlobal_CardStyles } from "@/app_modules/_global/component";
-import { Center, Grid, Group, Skeleton, Stack } from "@mantine/core";
+import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
+import { Center, Grid, Group, Stack } from "@mantine/core";
export {
Voting_ComponentSkeletonDetail,
@@ -17,25 +18,25 @@ function Voting_ComponentSkeletonViewPublish() {
-
+
-
+
-
-
- {/* */}
+
+
+ {/* */}
{Array.from({ length: 2 }).map((e, i) => (
-
-
+
+
))}
@@ -53,8 +54,8 @@ function Voting_ComponentSkeletonViewStatus() {
{Array.from({ length: 2 }).map((e, i) => (
-
-
+
+
))}
@@ -70,31 +71,31 @@ function Voting_ComponentSkeletonViewKontribusi() {
-
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
@@ -111,30 +112,30 @@ function Voting_ComponentSkeletonDetail() {
-
+
-
+
-
-
-
-
-
-
+
+
+
+
+
+
{/*
-
-
-
+
+
+
*/}
-
+
@@ -142,17 +143,17 @@ function Voting_ComponentSkeletonDetail() {
-
+
-
-
+
+
-
-
+
+
@@ -169,13 +170,13 @@ function Voting_ComponentSkeletonDaftarKontributor(){
-
+
-
+
-
+
diff --git a/src/app_modules/vote/create/index.tsx b/src/app_modules/vote/create/index.tsx
index da449ec6..4830f297 100644
--- a/src/app_modules/vote/create/index.tsx
+++ b/src/app_modules/vote/create/index.tsx
@@ -28,6 +28,7 @@ import { useState } from "react";
import { WibuRealtime } from "wibu-pkg";
import { Vote_funCreate } from "../fun/create/create_vote";
import { gs_vote_hotMenu } from "../global_state";
+import { clientLogger } from "@/util/clientLogger";
export default function Vote_Create() {
const router = useRouter();
@@ -69,40 +70,49 @@ export default function Vote_Create() {
// console.log("berhasil");
- const res = await Vote_funCreate(data as any, listVote);
- if (res.status === 201) {
- const dataNotifikasi: IRealtimeData = {
- appId: res.data?.id as any,
- status: res.data?.Voting_Status?.name as any,
- userId: res.data?.authorId as any,
- pesan: res.data?.title as any,
- kategoriApp: "VOTING",
- title: "Voting baru",
- };
+ try {
+ setIsLoading(true);
+ const res = await Vote_funCreate(data as any, listVote);
+ if (res.status === 201) {
+ const dataNotifikasi: IRealtimeData = {
+ appId: res.data?.id as any,
+ status: res.data?.Voting_Status?.name as any,
+ userId: res.data?.authorId as any,
+ pesan: res.data?.title as any,
+ kategoriApp: "VOTING",
+ title: "Voting baru",
+ };
- const notif = await notifikasiToAdmin_funCreate({
- data: dataNotifikasi as any,
- });
-
- if (notif.status === 201) {
- WibuRealtime.setData({
- type: "notification",
- pushNotificationTo: "ADMIN",
+ const notif = await notifikasiToAdmin_funCreate({
+ data: dataNotifikasi as any,
});
- WibuRealtime.setData({
- type: "trigger",
- pushNotificationTo: "ADMIN",
- dataMessage: dataNotifikasi,
- });
+ if (notif.status === 201) {
+ WibuRealtime.setData({
+ type: "notification",
+ pushNotificationTo: "ADMIN",
+ });
- setHotMenu(2);
- router.replace(RouterVote.status({ id: "2" }));
- ComponentGlobal_NotifikasiBerhasil(res.message);
- setIsLoading(true);
+ WibuRealtime.setData({
+ type: "trigger",
+ pushNotificationTo: "ADMIN",
+ dataMessage: dataNotifikasi,
+ });
+
+ setHotMenu(2);
+ router.replace(RouterVote.status({ id: "2" }));
+ ComponentGlobal_NotifikasiBerhasil(res.message);
+
+ }
+ } else {
+ setIsLoading(false);
+ ComponentGlobal_NotifikasiGagal(res.message);
}
- } else {
- ComponentGlobal_NotifikasiGagal(res.message);
+
+ } catch (error) {
+ setIsLoading(false);
+ clientLogger.error("Error create voting", error);
+
}
}
@@ -113,8 +123,14 @@ export default function Vote_Create() {
-
+
Daftar Pilihan
@@ -192,8 +220,14 @@ export default function Vote_Create() {
e.value).includes("")
+ !data.deskripsi ||
+ !data.awalVote ||
+ !data.akhirVote ||
+ listVote.map((e, i) => e.value).includes("")
? true
: false
}
diff --git a/src/app_modules/vote/detail/draft/index.tsx b/src/app_modules/vote/detail/draft/index.tsx
index b5374cd7..18e28f09 100644
--- a/src/app_modules/vote/detail/draft/index.tsx
+++ b/src/app_modules/vote/detail/draft/index.tsx
@@ -1,7 +1,7 @@
"use client";
import { RouterVote } from "@/app/lib/router_hipmi/router_vote";
-import { MainColor } from "@/app_modules/_global/color/color_pallet";
+import { AccentColor, MainColor } from "@/app_modules/_global/color/color_pallet";
import ComponentGlobal_BoxInformation from "@/app_modules/_global/component/box_information";
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
@@ -22,6 +22,7 @@ import { WibuRealtime } from "wibu-pkg";
import { useShallowEffect } from "@mantine/hooks";
import { voting_funGetOneVotingbyId } from "../../fun/get/fun_get_one_by_id";
import _ from "lodash";
+import { clientLogger } from "@/util/clientLogger";
export default function Vote_DetailDraft({
dataVote,
@@ -109,12 +110,19 @@ function ButtonAction({
async function onDelete() {
await Vote_funDeleteById(voteId).then((res) => {
- if (res.status === 200) {
- setOpenModal2(false);
- ComponentGlobal_NotifikasiBerhasil("Berhasil Hapus Vote", 2000);
- router.replace(RouterVote.status({ id: "3" }));
- } else {
- ComponentGlobal_NotifikasiGagal(res.message);
+ try {
+ setIsLoading(true);
+ if (res.status === 200) {
+ setOpenModal2(false);
+ ComponentGlobal_NotifikasiBerhasil("Berhasil Hapus Vote", 2000);
+ router.replace(RouterVote.status({ id: "3" }));
+ } else {
+ setIsLoading(false);
+ ComponentGlobal_NotifikasiGagal(res.message);
+ }
+ } catch (error) {
+ setIsLoading(false);
+ clientLogger.error("Error delete vote", error);
}
});
}
@@ -124,8 +132,8 @@ function ButtonAction({
{
setOpenModal1(true);
}}
@@ -134,7 +142,8 @@ function ButtonAction({
{
setOpenModal2(true);
}}
@@ -154,6 +163,7 @@ function ButtonAction({
onClick={() => {
setOpenModal1(false);
}}
+ style={{ backgroundColor: AccentColor.blue}} c={AccentColor.white}
>
Batal
@@ -166,8 +176,8 @@ function ButtonAction({
onClick={() => {
onUpdate();
}}
- color="yellow"
- bg={MainColor.yellow}
+ c={MainColor.darkblue}
+ style={{ backgroundColor: AccentColor.yellow }}
>
Ajukan
@@ -181,6 +191,7 @@ function ButtonAction({
close={() => setOpenModal2(false)}
buttonKiri={
{
setOpenModal2(false);
@@ -192,6 +203,8 @@ function ButtonAction({
buttonKanan={
{
onDelete();
}}
diff --git a/src/app_modules/vote/detail/kontribusi/index.tsx b/src/app_modules/vote/detail/kontribusi/index.tsx
index 037d7abb..ed654821 100644
--- a/src/app_modules/vote/detail/kontribusi/index.tsx
+++ b/src/app_modules/vote/detail/kontribusi/index.tsx
@@ -1,25 +1,123 @@
"use client";
+import { AccentColor } from "@/app_modules/_global/color";
import {
- Stack
-} from "@mantine/core";
-import ComponentVote_DetailDataSetelahPublish from "../../component/detail/detail_data_setelah_publish";
+ ComponentGlobal_AvatarAndUsername,
+ ComponentGlobal_CardStyles,
+} from "@/app_modules/_global/component";
+import { clientLogger } from "@/util/clientLogger";
+import { Badge, Center, Stack, Text, Title } from "@mantine/core";
+import { useShallowEffect } from "@mantine/hooks";
+import _ from "lodash";
+import moment from "moment";
+import { useParams } from "next/navigation";
+import { useState } from "react";
+import {
+ apiGetHasilVotingById,
+ apiGetOneVotingById,
+} from "../../_lib/api_voting";
import ComponentVote_HasilVoting from "../../component/detail/detail_hasil_voting";
+import { Voting_ComponentSkeletonDetail } from "../../component/skeleton_view";
import { MODEL_VOTING } from "../../model/interface";
+import ComponentVote_DetailDataSetelahPublish from "../../component/detail/detail_data_setelah_publish";
+
+export default function Vote_DetailKontribusi() {
+ const params = useParams<{ id: string }>();
+ const [data, setData] = useState(null);
+ const [hasil, setHasil] = useState(null);
+
+ useShallowEffect(() => {
+ onLoadData();
+ onLoadHasil();
+ }, []);
+
+ async function onLoadData() {
+ try {
+ const respone = await apiGetOneVotingById({
+ id: params.id,
+ });
+
+ if (respone) {
+ setData(respone.data);
+ }
+ } catch (error) {
+ clientLogger.error("Error get data detail", error);
+ }
+ }
+
+ async function onLoadHasil() {
+ try {
+ const respone = await apiGetHasilVotingById({
+ id: params.id,
+ });
+
+ if (respone) {
+ setHasil(respone.data);
+ }
+ } catch (error) {
+ clientLogger.error("Error get data hasil voting", error);
+ }
+ }
+
+ if (_.isNull(data) && _.isNull(hasil)) {
+ return (
+ <>
+
+ >
+ );
+ }
-export default function Vote_DetailKontribusi({
- dataVote,
-}: {
- dataVote: MODEL_VOTING;
-}) {
return (
<>
-
+
+ {/*
+
+
+
+
+
+ {data?.title}
+
+
+ {data?.deskripsi}
+
+
+
+
+ Batas Voting
+
+
+
+ {data
+ ? moment(data.awalVote).format("ll")
+ : "tgl awal voting"}{" "}
+ -{" "}
+ {data
+ ? moment(data.akhirVote).format("ll")
+ : "tgl akhir voting"}
+
+
+
+
+
+
+ */}
-
+
>
);
diff --git a/src/app_modules/vote/detail/reject/index.tsx b/src/app_modules/vote/detail/reject/index.tsx
index b2ee5f4c..b9bceb4d 100644
--- a/src/app_modules/vote/detail/reject/index.tsx
+++ b/src/app_modules/vote/detail/reject/index.tsx
@@ -14,6 +14,8 @@ import { Vote_funEditStatusByStatusId } from "../../fun/edit/fun_edit_status_by_
import { gs_vote_status } from "../../global_state";
import { MODEL_VOTING } from "../../model/interface";
import { RouterVote } from "@/app/lib/router_hipmi/router_vote";
+import { AccentColor, MainColor } from "@/app_modules/_global/color";
+import { clientLogger } from "@/util/clientLogger";
export default function Vote_DetailReject({
dataVote,
@@ -41,24 +43,37 @@ function ButtonAction({ voteId }: { voteId: string }) {
async function onUpdate() {
await Vote_funEditStatusByStatusId(voteId, "3").then((res) => {
- if (res.status === 200) {
+ try {
setIsLoading(true);
- ComponentGlobal_NotifikasiBerhasil("Berhasil Masuk Draft", 2000);
- router.replace(RouterVote.status({ id: "3" }));
- } else {
- ComponentGlobal_NotifikasiGagal(res.message);
+ if (res.status === 200) {
+ ComponentGlobal_NotifikasiBerhasil("Berhasil Masuk Draft", 2000);
+ router.replace(RouterVote.status({ id: "3" }));
+ } else {
+ setIsLoading(false);
+ ComponentGlobal_NotifikasiGagal(res.message);
+ }
+ } catch (error) {
+ setIsLoading(false);
+ clientLogger.error("Error update voting", error);
}
});
}
async function onDelete() {
await Vote_funDeleteById(voteId).then((res) => {
- if (res.status === 200) {
- setOpenModal2(false);
- ComponentGlobal_NotifikasiBerhasil("Berhasil Hapus Vote", 2000);
- router.replace(RouterVote.status({ id: "4" }));
- } else {
- ComponentGlobal_NotifikasiGagal(res.message);
+ try {
+ setIsLoading(true);
+ if (res.status === 200) {
+ setOpenModal2(false);
+ ComponentGlobal_NotifikasiBerhasil("Berhasil Hapus Vote", 2000);
+ router.replace(RouterVote.status({ id: "4" }));
+ } else {
+ setIsLoading(false);
+ ComponentGlobal_NotifikasiGagal(res.message);
+ }
+ } catch (error) {
+ setIsLoading(false);
+ clientLogger.error("Error delete vote", error);
}
});
}
@@ -68,7 +83,8 @@ function ButtonAction({ voteId }: { voteId: string }) {
{
setOpenModal1(true);
}}
@@ -77,7 +93,8 @@ function ButtonAction({ voteId }: { voteId: string }) {
{" "}
{
setOpenModal2(true);
}}
@@ -93,6 +110,8 @@ function ButtonAction({ voteId }: { voteId: string }) {
buttonKiri={
{
setOpenModal1(false);
}}
@@ -105,10 +124,11 @@ function ButtonAction({ voteId }: { voteId: string }) {
loaderPosition="center"
loading={isLoading ? true : false}
radius={"xl"}
+ style={{ backgroundColor: AccentColor.yellow }}
onClick={() => {
onUpdate();
}}
- color="orange"
+ c={MainColor.darkblue}
>
Simpan
@@ -126,12 +146,16 @@ function ButtonAction({ voteId }: { voteId: string }) {
onClick={() => {
setOpenModal2(false);
}}
+ style={{ backgroundColor: AccentColor.blue }}
+ c={AccentColor.white}
>
Batal
}
buttonKanan={
{
onDelete();
diff --git a/src/app_modules/vote/detail/review/index.tsx b/src/app_modules/vote/detail/review/index.tsx
index 32243e69..d32326e4 100644
--- a/src/app_modules/vote/detail/review/index.tsx
+++ b/src/app_modules/vote/detail/review/index.tsx
@@ -15,6 +15,7 @@ import { Vote_funEditStatusByStatusId } from "../../fun/edit/fun_edit_status_by_
import { MODEL_VOTING } from "../../model/interface";
import { voting_checkStatus } from "../../fun";
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global";
+import { AccentColor, MainColor } from "@/app_modules/_global/color";
export default function Vote_DetailReview({
dataVote,
@@ -90,7 +91,8 @@ function ButtonAction({
<>
{
setOpenModal(true);
}}
@@ -103,19 +105,19 @@ function ButtonAction({
opened={openModal}
close={() => setOpenModal(false)}
buttonKiri={
- setOpenModal(false)}>
+ setOpenModal(false)}>
Batal
}
buttonKanan={
{
onUpdate();
- console.log(statusId);
}}
>
Simpan
diff --git a/src/app_modules/vote/detail/riwayat_saya/index.tsx b/src/app_modules/vote/detail/riwayat_saya/index.tsx
index c130f3e4..6f1ab681 100644
--- a/src/app_modules/vote/detail/riwayat_saya/index.tsx
+++ b/src/app_modules/vote/detail/riwayat_saya/index.tsx
@@ -5,6 +5,16 @@ import ComponentVote_DaftarKontributorVoter from "../../component/detail/detail_
import ComponentVote_DetailDataSetelahPublish from "../../component/detail/detail_data_setelah_publish";
import ComponentVote_HasilVoting from "../../component/detail/detail_hasil_voting";
import { MODEL_VOTING } from "../../model/interface";
+import { clientLogger } from "@/util/clientLogger";
+import { useShallowEffect } from "@mantine/hooks";
+import _ from "lodash";
+import { useParams } from "next/navigation";
+import { useState } from "react";
+import {
+ apiGetOneVotingById,
+ apiGetHasilVotingById,
+} from "../../_lib/api_voting";
+import { Voting_ComponentSkeletonDetail } from "../../component/skeleton_view";
export default function Vote_DetailRiwayatSaya({
dataVote,
@@ -13,17 +23,58 @@ export default function Vote_DetailRiwayatSaya({
dataVote: MODEL_VOTING;
listKontributor: any[];
}) {
+ const params = useParams<{ id: string }>();
+ const [data, setData] = useState(null);
+ const [hasil, setHasil] = useState(null);
+
+ useShallowEffect(() => {
+ onLoadData();
+ onLoadHasil();
+ }, []);
+
+ async function onLoadData() {
+ try {
+ const respone = await apiGetOneVotingById({
+ id: params.id,
+ });
+
+ if (respone) {
+ setData(respone.data);
+ }
+ } catch (error) {
+ clientLogger.error("Error get data detail", error);
+ }
+ }
+
+ async function onLoadHasil() {
+ try {
+ const respone = await apiGetHasilVotingById({
+ id: params.id,
+ });
+
+ if (respone) {
+ setHasil(respone.data);
+ }
+ } catch (error) {
+ clientLogger.error("Error get data hasil voting", error);
+ }
+ }
+
+ if (_.isNull(data) || _.isNull(hasil)) {
+ return ;
+ }
+
return (
<>
-
-
+ {/*
+ /> */}
>
);
diff --git a/src/app_modules/vote/detail/riwayat_saya/layout.tsx b/src/app_modules/vote/detail/riwayat_saya/layout.tsx
index df66b5e0..7caf7f2f 100644
--- a/src/app_modules/vote/detail/riwayat_saya/layout.tsx
+++ b/src/app_modules/vote/detail/riwayat_saya/layout.tsx
@@ -1,21 +1,56 @@
"use client";
+import { RouterVote } from "@/app/lib/router_hipmi/router_vote";
+import { UIGlobal_Drawer } from "@/app_modules/_global/ui";
import UIGlobal_LayoutHeaderTamplate from "@/app_modules/_global/ui/ui_header_tamplate";
import UIGlobal_LayoutTamplate from "@/app_modules/_global/ui/ui_layout_tamplate";
-import React from "react";
+import { ActionIcon } from "@mantine/core";
+import { IconDotsVertical, IconUsersGroup } from "@tabler/icons-react";
+import { useParams } from "next/navigation";
+import React, { useState } from "react";
export default function LayoutVote_DetailRiwayatSaya({
children,
}: {
children: React.ReactNode;
}) {
+ const params = useParams<{ id: string }>();
+ const [openDrawer, setOpenDrawer] = useState(false);
+
return (
<>
}
+ header={
+ {
+ setOpenDrawer(true);
+ }}
+ >
+
+
+ }
+ />
+ }
>
{children}
+
+ setOpenDrawer(false)}
+ component={[
+ {
+ id: "1",
+ name: "Daftar Kontribusi",
+ icon: ,
+ path: RouterVote.daftar_kontributor + params.id,
+ },
+ ]}
+ />
>
);
}
diff --git a/src/app_modules/vote/detail/semua_riwayat/index.tsx b/src/app_modules/vote/detail/semua_riwayat/index.tsx
index 929d94aa..e9df576d 100644
--- a/src/app_modules/vote/detail/semua_riwayat/index.tsx
+++ b/src/app_modules/vote/detail/semua_riwayat/index.tsx
@@ -1,30 +1,73 @@
"use client";
+import { clientLogger } from "@/util/clientLogger";
import { Stack } from "@mantine/core";
-import ComponentVote_DetailDataTanpaVote from "../../component/detail/detail_data_tanpa_vote";
-import ComponentVote_HasilVoting from "../../component/detail/detail_hasil_voting";
-import ComponentVote_DaftarKontributorVoter from "../../component/detail/detail_daftar_kontributor";
+import { useShallowEffect } from "@mantine/hooks";
+import _ from "lodash";
+import { useParams } from "next/navigation";
+import { useState } from "react";
+import {
+ apiGetHasilVotingById,
+ apiGetOneVotingById,
+} from "../../_lib/api_voting";
import ComponentVote_DetailDataSetelahPublish from "../../component/detail/detail_data_setelah_publish";
-import { MODEL_VOTE_KONTRIBUTOR, MODEL_VOTING } from "../../model/interface";
+import ComponentVote_HasilVoting from "../../component/detail/detail_hasil_voting";
+import { Voting_ComponentSkeletonDetail } from "../../component/skeleton_view";
+import { MODEL_VOTING } from "../../model/interface";
+
+export default function Vote_DetailSemuaRiwayat() {
+ const params = useParams<{ id: string }>();
+ const [data, setData] = useState(null);
+ const [hasil, setHasil] = useState(null);
+
+ useShallowEffect(() => {
+ onLoadData();
+ onLoadHasil();
+ }, []);
+
+ async function onLoadData() {
+ try {
+ const respone = await apiGetOneVotingById({
+ id: params.id,
+ });
+
+ if (respone) {
+ setData(respone.data);
+ }
+ } catch (error) {
+ clientLogger.error("Error get data detail", error);
+ }
+ }
+
+ async function onLoadHasil() {
+ try {
+ const respone = await apiGetHasilVotingById({
+ id: params.id,
+ });
+
+ if (respone) {
+ setHasil(respone.data);
+ }
+ } catch (error) {
+ clientLogger.error("Error get data hasil voting", error);
+ }
+ }
+
+ if (_.isNull(data) || _.isNull(hasil)) {
+ return ;
+ }
-export default function Vote_DetailSemuaRiwayat({
- dataVote,
- listKontributor,
-}: {
- dataVote: MODEL_VOTING;
- listKontributor: MODEL_VOTE_KONTRIBUTOR[];
-}) {
return (
<>
-
-
+ {/*
+ /> */}
>
);
diff --git a/src/app_modules/vote/detail/semua_riwayat/layout.tsx b/src/app_modules/vote/detail/semua_riwayat/layout.tsx
index 9780dc6d..6b32f082 100644
--- a/src/app_modules/vote/detail/semua_riwayat/layout.tsx
+++ b/src/app_modules/vote/detail/semua_riwayat/layout.tsx
@@ -1,8 +1,14 @@
"use client";
+import { RouterVote } from "@/app/lib/router_hipmi/router_vote";
+import { UIGlobal_Drawer } from "@/app_modules/_global/ui";
import UIGlobal_LayoutHeaderTamplate from "@/app_modules/_global/ui/ui_header_tamplate";
import UIGlobal_LayoutTamplate from "@/app_modules/_global/ui/ui_layout_tamplate";
-import React from "react";
+import { ActionIcon } from "@mantine/core";
+import { IconDotsVertical } from "@tabler/icons-react";
+import { IconUsersGroup } from "@tabler/icons-react";
+import { IconDots } from "@tabler/icons-react";
+import React, { useState } from "react";
export default function LayoutVote_DetailSemuaRiwayat({
children,
@@ -13,13 +19,42 @@ export default function LayoutVote_DetailSemuaRiwayat({
votingId: string;
userLoginId: string;
}) {
+ const [openDrawer, setOpenDrawer] = useState(false);
+
return (
<>
}
+ header={
+ {
+ setOpenDrawer(true);
+ }}
+ >
+
+
+ }
+ />
+ }
>
{children}
+
+ setOpenDrawer(false)}
+ component={[
+ {
+ id: "1",
+ name: "Daftar Kontribusi",
+ icon: ,
+ path: RouterVote.daftar_kontributor + votingId,
+ },
+ ]}
+ />
>
);
}
diff --git a/src/app_modules/vote/edit/index.tsx b/src/app_modules/vote/edit/index.tsx
index 41ebc2d4..e3f56543 100644
--- a/src/app_modules/vote/edit/index.tsx
+++ b/src/app_modules/vote/edit/index.tsx
@@ -31,6 +31,7 @@ import {
MODEL_VOTING,
MODEL_VOTING_DAFTAR_NAMA_VOTE,
} from "../model/interface";
+import { clientLogger } from "@/util/clientLogger";
export default function Vote_Edit({
dataVote,
@@ -57,7 +58,13 @@ export default function Vote_Edit({
{
- if (res.status === 200) {
- ComponentGlobal_NotifikasiBerhasil("Berhasil Update");
- // setHotMenu(1);
- // setTabsStatus("Draft");
- router.back();
- setIsLoading(true);
- } else {
- ComponentGlobal_NotifikasiGagal(res.message);
- }
- });
+ try {
+ setIsLoading(true);
+ await Vote_funEditById(data, listVoting).then((res) => {
+ if (res.status === 200) {
+ ComponentGlobal_NotifikasiBerhasil("Berhasil Update");
+ // setHotMenu(1);
+ // setTabsStatus("Draft");
+ router.back();
+ } else {
+ setIsLoading(false);
+ ComponentGlobal_NotifikasiGagal(res.message);
+ }
+ });
+
+ } catch (error) {
+ setIsLoading(false);
+ clientLogger.error("Error update voting", error);
+ }
}
return (
diff --git a/src/app_modules/vote/main/beranda.tsx b/src/app_modules/vote/main/beranda.tsx
index a0d8e193..069e9d1c 100644
--- a/src/app_modules/vote/main/beranda.tsx
+++ b/src/app_modules/vote/main/beranda.tsx
@@ -2,7 +2,7 @@
import { gs_votingTiggerBeranda } from "@/app/lib/global_state";
import { RouterVote } from "@/app/lib/router_hipmi/router_vote";
-import { AccentColor } from "@/app_modules/_global/color";
+import { AccentColor, MainColor } from "@/app_modules/_global/color";
import ComponentGlobal_CreateButton from "@/app_modules/_global/component/button_create";
import ComponentGlobal_IsEmptyData from "@/app_modules/_global/component/is_empty_data";
import { clientLogger } from "@/util/clientLogger";
@@ -119,6 +119,7 @@ export default function Vote_Beranda() {
radius={"xl"}
placeholder="Masukan judul voting"
onChange={(val) => onSearch(val.target.value)}
+ styles={{ input: { backgroundColor: MainColor.white } }}
/>
diff --git a/src/app_modules/vote/main/layout.tsx b/src/app_modules/vote/main/layout.tsx
index fb31f83b..2f82295c 100644
--- a/src/app_modules/vote/main/layout.tsx
+++ b/src/app_modules/vote/main/layout.tsx
@@ -70,7 +70,7 @@ export default function LayoutVote_Main({
e.path === ""
? ComponentGlobal_NotifikasiPeringatan("Cooming Soon")
diff --git a/src/app_modules/vote/main/riwayat/index.tsx b/src/app_modules/vote/main/riwayat/index.tsx
index 8231546b..6ac85b19 100644
--- a/src/app_modules/vote/main/riwayat/index.tsx
+++ b/src/app_modules/vote/main/riwayat/index.tsx
@@ -60,11 +60,11 @@ export default function Vote_Riwayat() {
style={{
transition: "0.5s",
backgroundColor:
- params.id === e.id ? MainColor.yellow : "white",
+ params.id === e.id ? MainColor.yellow : MainColor.white,
border:
params.id === e.id
? `1px solid ${AccentColor.yellow}`
- : `1px solid white`,
+ : `1px solid ${MainColor.white}`,
}}
>
{e.label}
diff --git a/src/app_modules/vote/main/status/draft.tsx b/src/app_modules/vote/main/status/draft.tsx
index 7d0ab754..be70dbb6 100644
--- a/src/app_modules/vote/main/status/draft.tsx
+++ b/src/app_modules/vote/main/status/draft.tsx
@@ -69,7 +69,7 @@ export default function Vote_StatusDraft() {
{(item) => (
)}
diff --git a/src/app_modules/vote/main/status/index.tsx b/src/app_modules/vote/main/status/index.tsx
index 11a59a44..889c0b5e 100644
--- a/src/app_modules/vote/main/status/index.tsx
+++ b/src/app_modules/vote/main/status/index.tsx
@@ -64,15 +64,16 @@ export default function Vote_Status() {
key={e.id}
value={e.id}
fw={"bold"}
- c={"black"}
+
style={{
transition: "0.5s",
+ color: params.id === e.id ? MainColor.darkblue : MainColor.black,
backgroundColor:
- params.id === e.id ? MainColor.yellow : "white",
+ params.id === e.id ? MainColor.yellow : MainColor.white,
border:
params.id === e.id
? `1px solid ${AccentColor.yellow}`
- : `1px solid white`,
+ : `1px solid ${MainColor.white}`,
}}
>
{e.name}
diff --git a/src/app_modules/vote/main/status/reject.tsx b/src/app_modules/vote/main/status/reject.tsx
index c66f902c..1db98190 100644
--- a/src/app_modules/vote/main/status/reject.tsx
+++ b/src/app_modules/vote/main/status/reject.tsx
@@ -69,7 +69,7 @@ export default function Vote_StatusReject() {
{(item) => (
)}
diff --git a/src/app_modules/waiting_room/view.tsx b/src/app_modules/waiting_room/view.tsx
index 942cc0c4..d6a16ec9 100644
--- a/src/app_modules/waiting_room/view.tsx
+++ b/src/app_modules/waiting_room/view.tsx
@@ -2,28 +2,28 @@
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global";
import { UIGlobal_LayoutDefault } from "@/app_modules/_global/ui";
-import {
- Button,
- Center,
- Group,
- Skeleton,
- Stack,
- Text,
- Title,
-} from "@mantine/core";
+import { clientLogger } from "@/util/clientLogger";
+import { Button, Skeleton, Stack, Text } from "@mantine/core";
import { useShallowEffect } from "@mantine/hooks";
-import { redirect, useRouter } from "next/navigation";
+import _ from "lodash";
+import { useRouter } from "next/navigation";
import { useState } from "react";
+import { ComponentGlobal_CardStyles } from "../_global/component";
+import { apiGetACtivationUser } from "../_global/lib/api_user";
+import { gs_access_user } from "@/app/lib/global_state";
+import { useAtom } from "jotai";
+import { MainColor } from "../_global/color";
+import CustomSkeleton from "../components/CustomSkeleton";
export default function WaitingRoom_View({
- activationUser,
userLoginId,
}: {
- activationUser: boolean;
- userLoginId: string;
+ userLoginId?: string;
}) {
const router = useRouter();
const [loading, setLoading] = useState(false);
+ const [isLoadingHome, setIsLoadingHome] = useState(false);
+
async function onClickLogout() {
setLoading(true);
const res = await fetch(`/api/auth/logout?id=${userLoginId}`, {
@@ -37,71 +37,81 @@ export default function WaitingRoom_View({
}
}
- useShallowEffect(() => {
- if (activationUser == true) {
- return redirect("/");
- }
- }, [activationUser]);
+ const [isAccess, setIsAccess] = useState(null);
+ const [isAccessUser, setIsAccessUser] = useAtom(gs_access_user);
- const listhHuruf = [
- {
- huruf: "H",
- },
- {
- huruf: "I",
- },
- {
- huruf: "P",
- },
- {
- huruf: "M",
- },
- {
- huruf: "I",
- },
- ];
- const customLOader = (
-
-
- {listhHuruf.map((e, i) => (
-
-
-
- {e.huruf}
-
-
- ))}
-
-
- );
+ useShallowEffect(() => {
+ if (isAccessUser) {
+ setIsAccess(true);
+ setIsAccessUser(false);
+ }
+ }, [isAccessUser]);
+
+ useShallowEffect(() => {
+ onLoadData();
+ }, []);
+
+ async function onLoadData() {
+ try {
+ const respone = await apiGetACtivationUser();
+ if (respone) {
+ setIsAccess(respone.data);
+ }
+ } catch (error) {
+ clientLogger.error("Error get cookies user", error);
+ }
+ }
return (
<>
-
-
- {/* {customLOader} */}
-
-
-
- Anda telah berhasil mendaftar,
-
-
- Mohon menunggu konfirmansi Admin !
-
-
-
- onClickLogout()}
- >
- Keluar
-
-
-
+
+
+ {_.isNull(isAccess) ? (
+
+
+
+
+
+
+ ) : (
+
+
+
+ Permohonan akses Anda sedang dalam proses verifikasi oleh
+ admin.
+
+
+ Harap tunggu, Anda akan menerima pemberitahuan melalui
+ Whatsapp setelah disetujui.
+
+
+ {isAccess && (
+ {
+ try {
+ setIsLoadingHome(true);
+ router.replace("/", { scroll: false });
+ } catch (error) {
+ clientLogger.error("Error button to home", error);
+ } finally {
+ setIsLoadingHome(false);
+ }
+ }}
+ >
+ Home
+
+ )}
+
+ )}
+
+
>
);
diff --git a/src/middleware.ts b/src/middleware.ts
index ff423bab..f616cb2a 100644
--- a/src/middleware.ts
+++ b/src/middleware.ts
@@ -5,6 +5,8 @@ import { apies, pages } from "./lib/routes";
type MiddlewareConfig = {
apiPath: string;
loginPath: string;
+ // validasiPath: string;
+ // registarasiPath: string;
userPath: string;
publicRoutes: string[];
encodedKey: string;
@@ -16,8 +18,12 @@ type MiddlewareConfig = {
const middlewareConfig: MiddlewareConfig = {
apiPath: "/api",
loginPath: "/login",
+ // validasiPath: "/validasi",
+ // registarasiPath: "/register",
userPath: "/dev/home",
publicRoutes: [
+
+ // API
"/",
"/api/voting/*",
"/api/collaboration/*",
@@ -25,31 +31,44 @@ const middlewareConfig: MiddlewareConfig = {
"/api/logs/*",
"/api/image/*",
"/api/job/*",
- "/api/validation",
"/api/auth/*",
"/api/origin-url",
- "/api/user",
+ // "/api/user",
"/api/event/*",
+ // Akses awal
+ "/api/get-cookie",
+ "/api/user/activation",
+ "/api/user-validate",
+
+ // PAGE
"/login",
"/register",
"/validasi",
"/splash",
+ "/job-vacancy",
+ "/preview-image",
"/auth/login",
"/auth/api/login",
+ "/waiting-room",
+ "/zCoba/*",
+
+ // ASSETS
"/aset/global/main_background.png",
"/aset/logo/logo-hipmi.png",
- "/api/new/*",
],
encodedKey: process.env.NEXT_PUBLIC_BASE_TOKEN_KEY!,
sessionKey: process.env.NEXT_PUBLIC_BASE_SESSION_KEY!,
validationApiRoute: "/api/validation",
log: false,
};
+
export const middleware = async (req: NextRequest) => {
const {
apiPath,
encodedKey,
loginPath,
+ // validasiPath,
+ // registarasiPath,
publicRoutes,
sessionKey,
validationApiRoute,
@@ -64,14 +83,31 @@ export const middleware = async (req: NextRequest) => {
}
// Skip authentication for public routes
- const isPublicRoute = [...publicRoutes, loginPath, validationApiRoute].some(
- (route) => {
- const pattern = route.replace(/\*/g, ".*");
- return new RegExp(`^${pattern}$`).test(pathname);
- }
- );
+ const isPublicRoute = [
+ ...publicRoutes,
+ loginPath,
+ // validasiPath,
+ // registarasiPath,
+ ].some((route) => {
+ const pattern = route.replace(/\*/g, ".*");
+ return new RegExp(`^${pattern}$`).test(pathname);
+ });
- if (isPublicRoute) {
+ // Always protect validation endpoint
+ if (pathname === validationApiRoute) {
+ const reqToken = req.headers.get("Authorization")?.split(" ")[1];
+ if (!reqToken) {
+ return setCorsHeaders(unauthorizedResponse());
+ }
+ }
+
+ if (
+ isPublicRoute &&
+ pathname !== loginPath
+ // &&
+ // pathname !== validasiPath &&
+ // pathname !== registarasiPath
+ ) {
return setCorsHeaders(NextResponse.next());
}
@@ -79,24 +115,64 @@ export const middleware = async (req: NextRequest) => {
req.cookies.get(sessionKey)?.value ||
req.headers.get("Authorization")?.split(" ")[1];
+ // ==================== Authentication: Login, Validasi, Registrasi ==================== //
// Token verification
const user = await verifyToken({ token, encodedKey });
+ // Handle login page access
+ if (pathname === loginPath) {
+ if (user) {
+ return setCorsHeaders(NextResponse.redirect(new URL(userPath, req.url)));
+ }
+ return setCorsHeaders(NextResponse.next());
+ }
+
+ // // Handle validation page access
+ // if (pathname === validasiPath) {
+ // if (user) {
+ // return setCorsHeaders(NextResponse.redirect(new URL(userPath, req.url)));
+ // }
+ // return setCorsHeaders(NextResponse.next());
+ // }
+
+ // // Handle register page access
+ // if (pathname === registarasiPath) {
+ // if (user) {
+ // return setCorsHeaders(NextResponse.redirect(new URL(userPath, req.url)));
+ // }
+ // return setCorsHeaders(NextResponse.next());
+ // }
+
+ // Handle protected routes
if (!user) {
- if (pathname.startsWith(apiPath)) {
+ return setCorsHeaders(NextResponse.redirect(new URL(loginPath, req.url)));
+ }
+ // ==================== Authentication: Login, Validasi, Registrasi ==================== //
+
+ if (pathname.startsWith("/dev")) {
+ const userValidate = await fetch(new URL("/api/user-validate", req.url), {
+ headers: {
+ "Content-Type": "application/json",
+ Authorization: `Bearer ${token}`,
+ },
+ });
+
+ const userValidateJson = await userValidate.json();
+
+ if (!userValidateJson.data.active) {
+ return setCorsHeaders(
+ NextResponse.redirect(new URL("/waiting-room", req.url))
+ );
+ }
+ }
+
+ // Handle authenticated API requests
+ if (pathname.startsWith(apiPath)) {
+ const reqToken = req.headers.get("Authorization")?.split(" ")[1];
+ if (!reqToken) {
return setCorsHeaders(unauthorizedResponse());
}
- return setCorsHeaders(NextResponse.redirect(new URL(loginPath, req.url)));
- }
-
- // Redirect authenticated user away from login page
- if (user && pathname === loginPath) {
- return setCorsHeaders(NextResponse.redirect(new URL(userPath, req.url)));
- }
-
- if (req.nextUrl.pathname.startsWith(apiPath)) {
- const reqToken = req.headers.get("Authorization")?.split(" ")[1];
// Validate user access with external API
const validationResponse = await fetch(
new URL(validationApiRoute, req.url),
@@ -111,6 +187,8 @@ export const middleware = async (req: NextRequest) => {
if (!validationResponse.ok) {
return setCorsHeaders(unauthorizedResponse());
}
+
+ const dataJson = await validationResponse.json();
}
// Proceed with the request
diff --git a/xserver/index.html b/xserver/index.html
new file mode 100644
index 00000000..44dc9ab0
--- /dev/null
+++ b/xserver/index.html
@@ -0,0 +1,471 @@
+
+
+
+
+
+ HIPMI Feature Checklist
+
+
+
+ HIPMI Feature Checklist
+
+
+
+
+
Authentication
+
+
+
Profile
+
+
+
Portofolio
+
+
+
User Search
+
+
+
Business Map
+
+
+
Event
+
+
+
Collaboration
+
+
+
Voting
+
+
+
Investasi
+
+
+
Donasi
+
+
+
Job
+
+
+
Forum
+
+
+
+ Reset Semua Checklist
+
+
+
+