Merge pull request #220 from bipproduction/join
Intregrasi API & fix skeleton
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -34,6 +34,9 @@ yarn-error.log*
|
||||
# vercel
|
||||
.vercel
|
||||
|
||||
# logs
|
||||
/logs
|
||||
|
||||
# typescript
|
||||
*.tsbuildinfo
|
||||
next-env.d.ts
|
||||
|
||||
25
CHANGELOG.md
25
CHANGELOG.md
@@ -2,6 +2,31 @@
|
||||
|
||||
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.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)
|
||||
|
||||
## [1.2.34](https://github.com/bipproduction/hipmi/compare/v1.2.33...v1.2.34) (2024-12-24)
|
||||
|
||||
## [1.2.33](https://github.com/bipproduction/hipmi/compare/v1.2.32...v1.2.33) (2024-12-22)
|
||||
|
||||
## [1.2.32](https://github.com/bipproduction/hipmi/compare/v1.2.31...v1.2.32) (2024-12-19)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* donasi ([72b6d23](https://github.com/bipproduction/hipmi/commit/72b6d239fee3e90e812ab24192154e5e8910fccb))
|
||||
|
||||
## [1.2.31](https://github.com/bipproduction/hipmi/compare/v1.2.30...v1.2.31) (2024-12-17)
|
||||
|
||||
## [1.2.30](https://github.com/bipproduction/hipmi/compare/v1.2.29...v1.2.30) (2024-12-16)
|
||||
|
||||
## [1.2.29](https://github.com/bipproduction/hipmi/compare/v1.2.28...v1.2.29) (2024-12-13)
|
||||
|
||||
## [1.2.28](https://github.com/bipproduction/hipmi/compare/v1.2.27...v1.2.28) (2024-12-12)
|
||||
|
||||
## [1.2.27](https://github.com/bipproduction/hipmi/compare/v1.2.26...v1.2.27) (2024-12-12)
|
||||
|
||||
## [1.2.26](https://github.com/bipproduction/hipmi/compare/v1.2.25...v1.2.26) (2024-12-12)
|
||||
|
||||
## [1.2.25](https://github.com/bipproduction/hipmi/compare/v1.2.24...v1.2.25) (2024-12-12)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hipmi",
|
||||
"version": "1.2.26",
|
||||
"version": "1.2.36",
|
||||
"private": true,
|
||||
"prisma": {
|
||||
"seed": "npx tsx prisma/seed.ts --yes"
|
||||
@@ -50,6 +50,7 @@
|
||||
"autoprefixer": "10.4.14",
|
||||
"bufferutil": "^4.0.8",
|
||||
"bun": "^1.1.38",
|
||||
"date-fns": "^4.1.0",
|
||||
"dayjs": "^1.11.10",
|
||||
"dotenv": "^16.4.5",
|
||||
"echarts": "^5.4.3",
|
||||
@@ -95,6 +96,8 @@
|
||||
"wibu": "bipproduction/wibu",
|
||||
"wibu-cli": "^1.0.91",
|
||||
"wibu-pkg": "^1.0.3",
|
||||
"winston": "^3.17.0",
|
||||
"winston-daily-rotate-file": "^5.0.0",
|
||||
"yaml": "^2.3.2"
|
||||
}
|
||||
}
|
||||
|
||||
138
src/app/(admin)/logs/logs.module.css
Normal file
138
src/app/(admin)/logs/logs.module.css
Normal file
@@ -0,0 +1,138 @@
|
||||
/* app/admin/logs/logs.module.css */
|
||||
.container {
|
||||
padding: 24px;
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.title {
|
||||
font-size: 24px;
|
||||
font-weight: bold;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.filterContainer {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.select {
|
||||
padding: 8px;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 4px;
|
||||
min-width: 200px;
|
||||
}
|
||||
|
||||
.logsContainer {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.logItem {
|
||||
padding: 16px;
|
||||
border-radius: 4px;
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.errorLog {
|
||||
background-color: #fef2f2;
|
||||
}
|
||||
|
||||
.warnLog {
|
||||
background-color: #fefce8;
|
||||
}
|
||||
|
||||
.infoLog {
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
.logHeader {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.timestamp {
|
||||
font-size: 14px;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.level {
|
||||
padding: 4px 8px;
|
||||
border-radius: 4px;
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.errorLevel {
|
||||
background-color: #fee2e2;
|
||||
color: #991b1b;
|
||||
}
|
||||
|
||||
.warnLevel {
|
||||
background-color: #fef3c7;
|
||||
color: #92400e;
|
||||
}
|
||||
|
||||
.infoLevel {
|
||||
background-color: #dbeafe;
|
||||
color: #1e40af;
|
||||
}
|
||||
|
||||
.message {
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
.metadata {
|
||||
margin-top: 8px;
|
||||
padding: 8px;
|
||||
background-color: #f9fafb;
|
||||
border-radius: 4px;
|
||||
font-size: 14px;
|
||||
overflow-x: auto;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
.loading {
|
||||
text-align: center;
|
||||
padding: 24px;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.error {
|
||||
color: #dc2626;
|
||||
text-align: center;
|
||||
padding: 24px;
|
||||
}
|
||||
|
||||
/* Hover effects */
|
||||
.logItem:hover {
|
||||
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.select:hover {
|
||||
border-color: #999;
|
||||
}
|
||||
|
||||
/* Focus states */
|
||||
.select:focus {
|
||||
outline: none;
|
||||
border-color: #2563eb;
|
||||
box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
|
||||
}
|
||||
|
||||
/* Responsive adjustments */
|
||||
@media (max-width: 768px) {
|
||||
.container {
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.logHeader {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.metadata {
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
106
src/app/(admin)/logs/page.tsx
Normal file
106
src/app/(admin)/logs/page.tsx
Normal file
@@ -0,0 +1,106 @@
|
||||
// app/admin/logs/page.tsx
|
||||
"use client";
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
import { format } from "date-fns";
|
||||
import styles from "./logs.module.css";
|
||||
|
||||
interface LogEntry {
|
||||
timestamp: string;
|
||||
level: string;
|
||||
message: string;
|
||||
metadata?: any;
|
||||
}
|
||||
|
||||
export default function LogsPage() {
|
||||
const [logs, setLogs] = useState<LogEntry[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [filter, setFilter] = useState<"all" | "error" | "info" | "warn">(
|
||||
"all"
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
fetchLogs();
|
||||
}, []);
|
||||
|
||||
async function fetchLogs() {
|
||||
try {
|
||||
const response = await fetch("/api/logs/view");
|
||||
if (!response.ok) throw new Error("Failed to fetch logs");
|
||||
|
||||
const data = await response.json();
|
||||
setLogs(data.logs);
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : "Error fetching logs");
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
const filteredLogs = logs.filter((log) =>
|
||||
filter === "all" ? true : log.level === filter
|
||||
);
|
||||
|
||||
if (loading) return <div className={styles.loading}>Loading logs...</div>;
|
||||
if (error) return <div className={styles.error}>Error: {error}</div>;
|
||||
|
||||
return (
|
||||
<div className={styles.container}>
|
||||
<h1 className={styles.title}>System Logs</h1>
|
||||
|
||||
<div className={styles.filterContainer}>
|
||||
<select
|
||||
value={filter}
|
||||
onChange={(e) => setFilter(e.target.value as any)}
|
||||
className={styles.select}
|
||||
>
|
||||
<option value="all">All Logs</option>
|
||||
<option value="error">Errors</option>
|
||||
<option value="warn">Warnings</option>
|
||||
<option value="info">Info</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div className={styles.logsContainer}>
|
||||
{filteredLogs.map((log, index) => (
|
||||
<div
|
||||
key={index}
|
||||
className={`${styles.logItem} ${
|
||||
log.level === "error"
|
||||
? styles.errorLog
|
||||
: log.level === "warn"
|
||||
? styles.warnLog
|
||||
: styles.infoLog
|
||||
}`}
|
||||
>
|
||||
<div className={styles.logHeader}>
|
||||
<span className={styles.timestamp}>
|
||||
{format(new Date(log.timestamp), "yyyy-MM-dd HH:mm:ss")}
|
||||
</span>
|
||||
<span
|
||||
className={`${styles.level} ${
|
||||
log.level === "error"
|
||||
? styles.errorLevel
|
||||
: log.level === "warn"
|
||||
? styles.warnLevel
|
||||
: styles.infoLevel
|
||||
}`}
|
||||
>
|
||||
{log.level.toUpperCase()}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div className={styles.message}>{log.message}</div>
|
||||
|
||||
{log.metadata && (
|
||||
<pre className={styles.metadata}>
|
||||
{JSON.stringify(log.metadata, null, 2)}
|
||||
</pre>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
20
src/app/api/collaboration/master/route.ts
Normal file
20
src/app/api/collaboration/master/route.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
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) {
|
||||
try {
|
||||
const data = await prisma.projectCollaborationMaster_Industri.findMany({});
|
||||
return NextResponse.json(
|
||||
{ success: true, message: "Berhasil mendapatkan data", data: data },
|
||||
{ status: 200 }
|
||||
);
|
||||
} catch (error) {
|
||||
backendLogger.error("Master Collaboration:=========>", error);
|
||||
return NextResponse.json(
|
||||
{ success: false, message: "Gagal mendapatkan data" },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
53
src/app/api/image/delete/route.ts
Normal file
53
src/app/api/image/delete/route.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
import { funGetDirectoryNameByValue } from "@/app_modules/_global/fun/get";
|
||||
import backendLogger from "@/util/backendLogger";
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
export async function DELETE(req: Request) {
|
||||
const data = await req.json();
|
||||
const id = data.fileId;
|
||||
const dirId = data.dirId;
|
||||
|
||||
const keyOfDirectory = await funGetDirectoryNameByValue({
|
||||
value: dirId,
|
||||
});
|
||||
|
||||
if (req.method === "DELETE") {
|
||||
try {
|
||||
const res = await fetch(
|
||||
`https://wibu-storage.wibudev.com/api/files/${id}/delete`,
|
||||
{
|
||||
method: "DELETE",
|
||||
headers: {
|
||||
Authorization: `Bearer ${process.env.WS_APIKEY}`,
|
||||
},
|
||||
}
|
||||
);
|
||||
backendLogger.info("Server status code: " + res.status);
|
||||
const data = await res.json();
|
||||
if (res.ok) {
|
||||
backendLogger.info(
|
||||
`Success delete ${keyOfDirectory}`
|
||||
);
|
||||
return NextResponse.json({ success: true });
|
||||
} else {
|
||||
const errorText = await res.json();
|
||||
backendLogger.error(
|
||||
`Failed delete ${keyOfDirectory}: ` + errorText.message
|
||||
);
|
||||
return NextResponse.json({
|
||||
success: false,
|
||||
message: errorText.message,
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
backendLogger.error(`Delete error ${keyOfDirectory}:`, error);
|
||||
return NextResponse.json({
|
||||
success: false,
|
||||
message: "An unexpected error occurred",
|
||||
});
|
||||
}
|
||||
} else {
|
||||
backendLogger.error(`Error upload ${keyOfDirectory}: Method not allowed`);
|
||||
return NextResponse.json({ success: false, message: "Method not allowed" });
|
||||
}
|
||||
}
|
||||
58
src/app/api/image/upload/route.ts
Normal file
58
src/app/api/image/upload/route.ts
Normal file
@@ -0,0 +1,58 @@
|
||||
import { funGetDirectoryNameByValue } from "@/app_modules/_global/fun/get";
|
||||
import backendLogger from "@/util/backendLogger";
|
||||
import { NextResponse } from "next/server";
|
||||
export async function POST(request: Request) {
|
||||
const formData = await request.formData();
|
||||
|
||||
const valueOfDir = formData.get("dirId");
|
||||
const keyOfDirectory = await funGetDirectoryNameByValue({
|
||||
value: valueOfDir as string,
|
||||
});
|
||||
|
||||
if (request.method === "POST") {
|
||||
try {
|
||||
const res = await fetch("https://wibu-storage.wibudev.com/api/upload", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
headers: {
|
||||
Authorization: `Bearer ${process.env.WS_APIKEY}`,
|
||||
},
|
||||
});
|
||||
|
||||
backendLogger.info("Server status code: " + res.status);
|
||||
const dataRes = await res.json();
|
||||
|
||||
if (res.ok) {
|
||||
backendLogger.info(
|
||||
`Success upload ${keyOfDirectory}: ${JSON.stringify(dataRes.data)}`
|
||||
);
|
||||
return NextResponse.json(
|
||||
{ success: true, data: dataRes.data },
|
||||
{ status: 200 }
|
||||
);
|
||||
} else {
|
||||
const errorText = await res.text();
|
||||
backendLogger.error(`Failed upload ${keyOfDirectory}: ${errorText}`);
|
||||
return NextResponse.json(
|
||||
{ success: false, message: errorText },
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
backendLogger.error(`Error upload ${keyOfDirectory}: ${error}`);
|
||||
return NextResponse.json(
|
||||
{
|
||||
success: false,
|
||||
message: "An unexpected error occurred",
|
||||
},
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
} else {
|
||||
backendLogger.error(`Error upload ${keyOfDirectory}: Method not allowed`);
|
||||
return NextResponse.json(
|
||||
{ success: false, message: "Method not allowed" },
|
||||
{ status: 405 }
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,94 @@
|
||||
import { job_getAllListPublish } from "@/app_modules/job/fun/get/get_all_publish";
|
||||
import _ from "lodash";
|
||||
import { prisma } from "@/app/lib";
|
||||
import { NextResponse } from "next/server";
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
export async function GET(params: Request) {
|
||||
const { searchParams } = new URL(params.url);
|
||||
const page = searchParams.get("page");
|
||||
const search = searchParams.get("search");
|
||||
export async function GET(request: Request) {
|
||||
try {
|
||||
const { searchParams } = new URL(request.url);
|
||||
const search = searchParams.get("search");
|
||||
const page = searchParams.get("page");
|
||||
const dataTake = 10;
|
||||
const dataSkip = Number(page) * dataTake - dataTake;
|
||||
|
||||
const data = await job_getAllListPublish({
|
||||
page: _.toNumber(page),
|
||||
search: search as string,
|
||||
});
|
||||
if (search != "") {
|
||||
const data = await prisma.job.findMany({
|
||||
take: dataTake,
|
||||
skip: dataSkip,
|
||||
orderBy: {
|
||||
updatedAt: "desc",
|
||||
},
|
||||
where: {
|
||||
masterStatusId: "1",
|
||||
isActive: true,
|
||||
isArsip: false,
|
||||
title: {
|
||||
mode: "insensitive",
|
||||
contains: search as string,
|
||||
},
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
Author: {
|
||||
select: {
|
||||
id: true,
|
||||
username: true,
|
||||
Profile: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
return NextResponse.json({ data });
|
||||
return NextResponse.json(
|
||||
{
|
||||
success: true,
|
||||
message: "Berhasil ambil data",
|
||||
data: data,
|
||||
},
|
||||
{ status: 200 }
|
||||
);
|
||||
} else {
|
||||
const data = await prisma.job.findMany({
|
||||
take: dataTake,
|
||||
skip: dataSkip,
|
||||
orderBy: {
|
||||
updatedAt: "desc",
|
||||
},
|
||||
where: {
|
||||
masterStatusId: "1",
|
||||
isActive: true,
|
||||
isArsip: false,
|
||||
title: {
|
||||
mode: "insensitive",
|
||||
},
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
Author: {
|
||||
select: {
|
||||
id: true,
|
||||
username: true,
|
||||
Profile: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
return NextResponse.json(
|
||||
{
|
||||
success: true,
|
||||
message: "Berhasil ambil data",
|
||||
data: data,
|
||||
},
|
||||
{ status: 200 }
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return NextResponse.json({
|
||||
success: false,
|
||||
message: "Gagal ambil data",
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
71
src/app/api/logs/view/route.ts
Normal file
71
src/app/api/logs/view/route.ts
Normal file
@@ -0,0 +1,71 @@
|
||||
// app/api/logs/view/route.ts
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import fs from "fs/promises";
|
||||
import path from "path";
|
||||
|
||||
interface LogEntry {
|
||||
timestamp: string;
|
||||
level: string;
|
||||
message: string;
|
||||
metadata?: any;
|
||||
}
|
||||
|
||||
async function readLogFiles(directory: string): Promise<LogEntry[]> {
|
||||
try {
|
||||
const logPath = path.join(process.cwd(), directory);
|
||||
const files = await fs.readdir(logPath);
|
||||
const logFiles = files.filter((file) => file.endsWith(".log"));
|
||||
|
||||
const allLogs: LogEntry[] = [];
|
||||
|
||||
for (const file of logFiles) {
|
||||
const filePath = path.join(logPath, file);
|
||||
const content = await fs.readFile(filePath, "utf-8");
|
||||
|
||||
// Parse setiap baris log
|
||||
const logs = content
|
||||
.split("\n")
|
||||
.filter(Boolean)
|
||||
.map((line) => {
|
||||
try {
|
||||
return JSON.parse(line);
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.filter(Boolean);
|
||||
|
||||
allLogs.push(...logs);
|
||||
}
|
||||
|
||||
// Sort berdasarkan timestamp, terbaru di atas
|
||||
return allLogs.sort(
|
||||
(a, b) =>
|
||||
new Date(b.timestamp).getTime() - new Date(a.timestamp).getTime()
|
||||
);
|
||||
} catch (error) {
|
||||
console.error("Error reading log files:", error);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
export async function GET(request: NextRequest) {
|
||||
try {
|
||||
// Baca logs dari frontend dan backend
|
||||
const frontendLogs = await readLogFiles("logs/frontend");
|
||||
const backendLogs = await readLogFiles("logs/backend");
|
||||
|
||||
// Gabungkan dan sort semua logs
|
||||
const allLogs = [...frontendLogs, ...backendLogs].sort(
|
||||
(a, b) =>
|
||||
new Date(b.timestamp).getTime() - new Date(a.timestamp).getTime()
|
||||
);
|
||||
|
||||
return NextResponse.json({ logs: allLogs });
|
||||
} catch (error) {
|
||||
return NextResponse.json(
|
||||
{ error: "Failed to fetch logs" },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
81
src/app/api/new/donasi/[id]/route.ts
Normal file
81
src/app/api/new/donasi/[id]/route.ts
Normal file
@@ -0,0 +1,81 @@
|
||||
import { prisma } from "@/app/lib";
|
||||
import { NextResponse } from "next/server";
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
|
||||
// GET ONE DATA DONASI
|
||||
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 == "semua") {
|
||||
dataFix = await prisma.donasi.findFirst({
|
||||
where: {
|
||||
id: id
|
||||
},
|
||||
include: {
|
||||
Author: true,
|
||||
imageDonasi: true,
|
||||
CeritaDonasi: true,
|
||||
DonasiMaster_Ketegori: true,
|
||||
DonasiMaster_Durasi: true,
|
||||
DonasiMaster_Status: true,
|
||||
Donasi_Invoice: true,
|
||||
Donasi_Kabar: true,
|
||||
Donasi_PencairanDana: true,
|
||||
},
|
||||
});
|
||||
|
||||
} else if (kategori == "count") {
|
||||
dataFix = await prisma.donasi_Invoice.count({
|
||||
where: {
|
||||
donasiId: id,
|
||||
donasiMaster_StatusInvoiceId: {
|
||||
equals: "1"
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
let tampil
|
||||
if (kategori == "author") {
|
||||
tampil = {
|
||||
authorId: true,
|
||||
Author: {
|
||||
select: {
|
||||
username: true
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (kategori == "cerita") {
|
||||
tampil = {
|
||||
id: true,
|
||||
createdAt: true,
|
||||
CeritaDonasi: {
|
||||
select: {
|
||||
cerita: true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dataFix = await prisma.donasi.findFirst({
|
||||
where: {
|
||||
id: id
|
||||
},
|
||||
select: tampil
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
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 ", reason: (error as Error).message, }, { status: 500 });
|
||||
}
|
||||
}
|
||||
77
src/app/api/new/donasi/invoice/route.ts
Normal file
77
src/app/api/new/donasi/invoice/route.ts
Normal file
@@ -0,0 +1,77 @@
|
||||
import { prisma } from "@/app/lib";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
import _ from "lodash";
|
||||
import { NextResponse } from "next/server";
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
|
||||
|
||||
|
||||
// GET ALL DATA DONASI SAYA (INVOICE)
|
||||
export async function GET(request: Request) {
|
||||
try {
|
||||
const { searchParams } = new URL(request.url)
|
||||
const page = searchParams.get("page")
|
||||
const dataSkip = Number(page) * 5 - 5;
|
||||
|
||||
|
||||
const userLoginId = await funGetUserIdByToken()
|
||||
if (userLoginId == null) {
|
||||
return NextResponse.json({ success: false, message: "Gagal mendapatkan data, user id tidak ada" }, { status: 500 });
|
||||
}
|
||||
|
||||
const data = await prisma.donasi_Invoice.findMany({
|
||||
take: 5,
|
||||
skip: dataSkip,
|
||||
orderBy: {
|
||||
createdAt: "desc",
|
||||
},
|
||||
where: {
|
||||
authorId: userLoginId,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
nominal: true,
|
||||
donasiMaster_StatusInvoiceId: true,
|
||||
DonasiMaster_StatusInvoice: {
|
||||
select: {
|
||||
name: true
|
||||
}
|
||||
},
|
||||
Donasi: {
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
publishTime: true,
|
||||
progres: true,
|
||||
imageId: true,
|
||||
DonasiMaster_Durasi: {
|
||||
select: {
|
||||
name: true
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const dataFix = data.map((v: any) => ({
|
||||
..._.omit(v, ["DonasiMaster_StatusInvoice", "Donasi"]),
|
||||
nameStatusInvoice: v.DonasiMaster_StatusInvoice.name,
|
||||
donasiId: v.Donasi.id,
|
||||
title: v.Donasi.title,
|
||||
publishTime: v.Donasi.publishTime,
|
||||
progres: v.Donasi.progres,
|
||||
imageId: v.Donasi.imageId,
|
||||
durasiDonasi: v.Donasi.DonasiMaster_Durasi.name
|
||||
}))
|
||||
|
||||
|
||||
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 ", reason: (error as Error).message, }, { status: 500 });
|
||||
}
|
||||
}
|
||||
33
src/app/api/new/donasi/master/route.ts
Normal file
33
src/app/api/new/donasi/master/route.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { prisma } from "@/app/lib";
|
||||
import { NextResponse } from "next/server";
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
|
||||
// GET ALL DATA MASTER UNTUK DONASI
|
||||
export async function GET(request: Request) {
|
||||
try {
|
||||
let dataFix
|
||||
const { searchParams } = new URL(request.url)
|
||||
const kategori = searchParams.get("cat")
|
||||
|
||||
if (kategori == "kategori") {
|
||||
dataFix = await prisma.donasiMaster_Kategori.findMany({
|
||||
orderBy: {
|
||||
createdAt: "asc",
|
||||
},
|
||||
where: {
|
||||
active: true,
|
||||
}
|
||||
})
|
||||
} else if (kategori == "durasi") {
|
||||
dataFix = await prisma.donasiMaster_Durasi.findMany()
|
||||
}
|
||||
|
||||
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 ", reason: (error as Error).message, }, { status: 500 });
|
||||
}
|
||||
}
|
||||
@@ -46,23 +46,44 @@ export async function GET(request: Request) {
|
||||
..._.omit(v, ["DonasiMaster_Durasi"]),
|
||||
nameDonasiDurasi: v.DonasiMaster_Durasi.name
|
||||
}))
|
||||
} else {
|
||||
} else if (kategori == "galang-dana") {
|
||||
const userLoginId = await funGetUserIdByToken()
|
||||
if (userLoginId == null) {
|
||||
return NextResponse.json({ success: false, message: "Gagal mendapatkan data, user id tidak ada" }, { status: 500 });
|
||||
}
|
||||
|
||||
dataFix = await prisma.donasi.findMany({
|
||||
const data = await prisma.donasi.findMany({
|
||||
take: 5,
|
||||
skip: dataSkip,
|
||||
where: {
|
||||
authorId: userLoginId,
|
||||
donasiMaster_StatusDonasiId: status,
|
||||
active: true,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
imagesId: true,
|
||||
target: true,
|
||||
progres: true,
|
||||
publishTime: true,
|
||||
DonasiMaster_Durasi: {
|
||||
select: {
|
||||
name: true
|
||||
}
|
||||
},
|
||||
terkumpul: true,
|
||||
imageId: true,
|
||||
},
|
||||
orderBy: {
|
||||
updatedAt: "desc",
|
||||
},
|
||||
});
|
||||
|
||||
dataFix = data.map((v: any) => ({
|
||||
..._.omit(v, ["DonasiMaster_Durasi"]),
|
||||
nameDonasiDurasi: v.DonasiMaster_Durasi.name
|
||||
}))
|
||||
}
|
||||
|
||||
return NextResponse.json({ success: true, message: "Berhasil mendapatkan data", data: dataFix }, { status: 200 });
|
||||
|
||||
39
src/app/api/new/investasi/[id]/route.ts
Normal file
39
src/app/api/new/investasi/[id]/route.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import { prisma } from "@/app/lib";
|
||||
import { NextResponse } from "next/server";
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
|
||||
|
||||
// GET ONE DATA INVESTASI BY ID
|
||||
export async function GET(request: Request, context: { params: { id: string } }) {
|
||||
try {
|
||||
const { id } = context.params
|
||||
const data = await prisma.investasi.findUnique({
|
||||
where: {
|
||||
id: id,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
targetDana: true,
|
||||
hargaLembar: true,
|
||||
totalLembar: true,
|
||||
roi: true,
|
||||
countDown: true,
|
||||
catatan: true,
|
||||
sisaLembar: true,
|
||||
imageId: true,
|
||||
masterPencarianInvestorId: true,
|
||||
masterPeriodeDevidenId: true,
|
||||
masterPembagianDevidenId: true,
|
||||
}
|
||||
});
|
||||
|
||||
return NextResponse.json({ success: true, message: "Berhasil mendapatkan data", data }, { status: 200 });
|
||||
|
||||
}
|
||||
catch (error) {
|
||||
console.error(error);
|
||||
return NextResponse.json({ success: false, message: "Gagal mendapatkan data, coba lagi nanti ", reason: (error as Error).message, }, { status: 500 });
|
||||
}
|
||||
}
|
||||
99
src/app/api/new/investasi/invoice/route.ts
Normal file
99
src/app/api/new/investasi/invoice/route.ts
Normal file
@@ -0,0 +1,99 @@
|
||||
import { prisma } from "@/app/lib";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
import _ from "lodash";
|
||||
import { NextResponse } from "next/server";
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
|
||||
|
||||
// GET ALL DATA INVESTASI SAYA (INVOICE)
|
||||
export async function GET(request: Request) {
|
||||
try {
|
||||
let dataFix
|
||||
const { searchParams } = new URL(request.url)
|
||||
const page = searchParams.get("page")
|
||||
const dataSkip = Number(page) * 10 - 10;
|
||||
const kategori = searchParams.get("cat")
|
||||
|
||||
|
||||
const userLoginId = await funGetUserIdByToken()
|
||||
if (userLoginId == null) {
|
||||
return NextResponse.json({ success: false, message: "Gagal mendapatkan data, user id tidak ada" }, { status: 500 });
|
||||
}
|
||||
|
||||
if (kategori == "saham-saya") {
|
||||
const data = await prisma.investasi_Invoice.findMany({
|
||||
take: 10,
|
||||
skip: dataSkip,
|
||||
orderBy: {
|
||||
updatedAt: "desc",
|
||||
},
|
||||
where: {
|
||||
authorId: userLoginId,
|
||||
statusInvoiceId: "1",
|
||||
isActive: true,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
nominal: true,
|
||||
lembarTerbeli: true,
|
||||
Investasi: {
|
||||
select: {
|
||||
title: true,
|
||||
progress: true
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
dataFix = data.map((v: any) => ({
|
||||
..._.omit(v, ["Investasi"]),
|
||||
title: v.Investasi.title,
|
||||
progress: v.Investasi.progress
|
||||
}))
|
||||
|
||||
} else if (kategori == "transaksi") {
|
||||
const data = await prisma.investasi_Invoice.findMany({
|
||||
take: 10,
|
||||
skip: dataSkip,
|
||||
orderBy: {
|
||||
updatedAt: "desc",
|
||||
},
|
||||
where: {
|
||||
authorId: userLoginId,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
statusInvoiceId: true,
|
||||
nominal: true,
|
||||
createdAt: true,
|
||||
StatusInvoice: {
|
||||
select: {
|
||||
name: true
|
||||
}
|
||||
},
|
||||
Investasi: {
|
||||
select: {
|
||||
title: true
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
dataFix = data.map((v: any) => ({
|
||||
..._.omit(v, ["Investasi", "StatusInvoice"]),
|
||||
title: v.Investasi.title,
|
||||
statusInvoice: v.StatusInvoice.name
|
||||
}))
|
||||
}
|
||||
|
||||
|
||||
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 ", reason: (error as Error).message, }, { status: 500 });
|
||||
}
|
||||
}
|
||||
46
src/app/api/new/investasi/master/route.ts
Normal file
46
src/app/api/new/investasi/master/route.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import { prisma } from "@/app/lib";
|
||||
import { NextResponse } from "next/server";
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
|
||||
// GET ALL DATA MASTER UNTUK INVESTASI
|
||||
export async function GET(request: Request) {
|
||||
try {
|
||||
let dataFix
|
||||
const { searchParams } = new URL(request.url)
|
||||
const kategori = searchParams.get("cat")
|
||||
|
||||
if (kategori == "pencarian-investor") {
|
||||
dataFix = await await prisma.masterPencarianInvestor.findMany({
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
active: true,
|
||||
},
|
||||
});
|
||||
} else if (kategori == "periode-deviden") {
|
||||
dataFix = await prisma.masterPeriodeDeviden.findMany({
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
active: true,
|
||||
},
|
||||
});
|
||||
} else if (kategori == "pembagian-deviden") {
|
||||
dataFix = await prisma.masterPembagianDeviden.findMany({
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
active: true,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
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 ", reason: (error as Error).message, }, { status: 500 });
|
||||
}
|
||||
}
|
||||
144
src/app/api/new/investasi/route.ts
Normal file
144
src/app/api/new/investasi/route.ts
Normal file
@@ -0,0 +1,144 @@
|
||||
import { prisma } from "@/app/lib";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
import _ from "lodash";
|
||||
import moment from "moment";
|
||||
import { NextResponse } from "next/server";
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
|
||||
// GET ALL DATA INVESTASI
|
||||
export async function GET(request: Request) {
|
||||
try {
|
||||
let dataFix
|
||||
const { searchParams } = new URL(request.url)
|
||||
const kategori = searchParams.get("cat")
|
||||
const status = searchParams.get("status")
|
||||
const page = searchParams.get("page")
|
||||
const dataSkip = Number(page) * 5 - 5;
|
||||
|
||||
if (kategori == "bursa") {
|
||||
const data = await prisma.investasi.findMany({
|
||||
where: {
|
||||
masterStatusInvestasiId: "1",
|
||||
masterProgresInvestasiId: "1",
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
MasterPencarianInvestor: true,
|
||||
countDown: true,
|
||||
progress: true,
|
||||
},
|
||||
});
|
||||
|
||||
for (let a of data) {
|
||||
if (
|
||||
(a.MasterPencarianInvestor?.name as any) -
|
||||
moment(new Date()).diff(new Date(a.countDown as any), "days") <=
|
||||
0
|
||||
) {
|
||||
await prisma.investasi.update({
|
||||
where: {
|
||||
id: a.id,
|
||||
},
|
||||
data: {
|
||||
masterProgresInvestasiId: "3",
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if (a.progress === "100") {
|
||||
await prisma.investasi.update({
|
||||
where: {
|
||||
id: a.id,
|
||||
},
|
||||
data: {
|
||||
masterProgresInvestasiId: "2",
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// cek data yang lewat
|
||||
// klo ada, update status
|
||||
const dataAwal = await prisma.investasi.findMany({
|
||||
take: 5,
|
||||
skip: dataSkip,
|
||||
orderBy: [
|
||||
{
|
||||
masterProgresInvestasiId: "asc",
|
||||
},
|
||||
{
|
||||
countDown: "desc",
|
||||
},
|
||||
],
|
||||
where: {
|
||||
masterStatusInvestasiId: "1",
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
imageId: true,
|
||||
title: true,
|
||||
progress: true,
|
||||
countDown: true,
|
||||
MasterPencarianInvestor: {
|
||||
select: {
|
||||
name: true
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
dataFix = dataAwal.map((v: any) => ({
|
||||
..._.omit(v, ["MasterPencarianInvestor"]),
|
||||
pencarianInvestor: v.MasterPencarianInvestor.name
|
||||
}))
|
||||
|
||||
} else if (kategori == "portofolio") {
|
||||
const userLoginId = await funGetUserIdByToken()
|
||||
if (userLoginId == null) {
|
||||
return NextResponse.json({ success: false, message: "Gagal mendapatkan data, user id tidak ada" }, { status: 500 });
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
dataFix = data.map((v: any) => ({
|
||||
..._.omit(v, ["MasterPencarianInvestor"]),
|
||||
pencarianInvestor: v.MasterPencarianInvestor.name
|
||||
}))
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
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 ", reason: (error as Error).message, }, { status: 500 });
|
||||
}
|
||||
}
|
||||
28
src/app/api/notifikasi/count/route.ts
Normal file
28
src/app/api/notifikasi/count/route.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
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 {
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
const count = await prisma.notifikasi.findMany({
|
||||
where: {
|
||||
userId: userLoginId,
|
||||
isRead: false,
|
||||
userRoleId: "1",
|
||||
},
|
||||
});
|
||||
|
||||
return NextResponse.json({ success: true, data: count.length });
|
||||
} catch (error) {
|
||||
backendLogger.error("Gagal mendapatkan data count notifikasi", error);
|
||||
return NextResponse.json(
|
||||
{ success: false, message: "Gagal mendapatkan data" },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
65
src/app/api/notifikasi/get-all-by-category/route.ts
Normal file
65
src/app/api/notifikasi/get-all-by-category/route.ts
Normal file
@@ -0,0 +1,65 @@
|
||||
import { prisma } from "@/app/lib";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
import { ICategoryapp } from "@/app_modules/notifikasi/model/interface";
|
||||
import backendLogger from "@/util/backendLogger";
|
||||
import _ from "lodash";
|
||||
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 category = searchParams.get("category") as ICategoryapp;
|
||||
const page = searchParams.get("page");
|
||||
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
const fixPage = _.toNumber(page);
|
||||
const takeData = 10;
|
||||
const skipData = fixPage * takeData - takeData;
|
||||
|
||||
if (category === "Semua") {
|
||||
fixData = await prisma.notifikasi.findMany({
|
||||
take: takeData,
|
||||
skip: skipData,
|
||||
orderBy: [
|
||||
{
|
||||
isRead: "asc",
|
||||
},
|
||||
{ createdAt: "desc" },
|
||||
],
|
||||
where: {
|
||||
userId: userLoginId,
|
||||
userRoleId: "1",
|
||||
},
|
||||
});
|
||||
} else {
|
||||
fixData = await prisma.notifikasi.findMany({
|
||||
take: takeData,
|
||||
skip: skipData,
|
||||
orderBy: [
|
||||
{
|
||||
isRead: "asc",
|
||||
},
|
||||
{ createdAt: "desc" },
|
||||
],
|
||||
where: {
|
||||
userId: userLoginId,
|
||||
userRoleId: "1",
|
||||
kategoriApp: _.upperCase(category),
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
return NextResponse.json(
|
||||
{ success: true, data: fixData, message: "Berhasil mendapatkan data" },
|
||||
{ status: 200 }
|
||||
);
|
||||
} catch (error) {
|
||||
backendLogger.error("Error get data notifikasi: " + error);
|
||||
return NextResponse.json(
|
||||
{ success: false, message: "Gagal mendapatkan data" },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
35
src/app/api/notifikasi/master/route.ts
Normal file
35
src/app/api/notifikasi/master/route.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
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) {
|
||||
try {
|
||||
const data = await prisma.masterKategoriApp.findMany({
|
||||
where: {
|
||||
isActive: true,
|
||||
},
|
||||
});
|
||||
|
||||
data.unshift({
|
||||
id: "0",
|
||||
isActive: true,
|
||||
createdAt: new Date(),
|
||||
updatedAt: new Date(),
|
||||
name: "Semua",
|
||||
value: null,
|
||||
});
|
||||
|
||||
return NextResponse.json(
|
||||
{ success: true, data, message: "Berhasil mendapatkan data" },
|
||||
{ status: 200 }
|
||||
);
|
||||
} catch (error) {
|
||||
backendLogger.error("Master Notifikasi:", error);
|
||||
return NextResponse.json(
|
||||
{ success: false, message: "Gagal mendapatkan data" },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
import { NextResponse } from "next/server";
|
||||
export async function POST(request: Request) {
|
||||
const WS_APIKEY = process.env.WS_APIKEY;
|
||||
console.log(WS_APIKEY);
|
||||
|
||||
try {
|
||||
const formData = await request.formData();
|
||||
|
||||
const res = await fetch("https://wibu-storage.wibudev.com/api/upload", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
headers: {
|
||||
Authorization: `Bearer ${process.env.WS_APIKEY}`,
|
||||
},
|
||||
});
|
||||
|
||||
// if (res.ok) {
|
||||
// console.log("Berhasil");
|
||||
// const hasil = await res.json();
|
||||
// return { success: true, data: hasil.data };
|
||||
// } else {
|
||||
// const errorText = await res.text();
|
||||
// return { success: false, data: {} };
|
||||
// }
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
|
||||
// try {
|
||||
// const res = await fetch("https://wibu-storage.wibudev.com/api/upload", {
|
||||
// method: "POST",
|
||||
// body: formData,
|
||||
// headers: {
|
||||
// Authorization: `Bearer ${process.env.WS_APIKEY}`,
|
||||
// },
|
||||
// });
|
||||
|
||||
// if (res.ok) {
|
||||
// const hasil = await res.json();
|
||||
// return { success: true, data: hasil.data };
|
||||
// } else {
|
||||
// const errorText = await res.text();
|
||||
// return { success: false, data: {} };
|
||||
// }
|
||||
// } catch (error) {
|
||||
// console.error("Upload error:", error);
|
||||
// return { success: false, data: {} };
|
||||
// }
|
||||
|
||||
return NextResponse.json({ success: true });
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { jwtVerify } from "jose";
|
||||
import { decrypt } from "@/app/auth/_lib/decrypt";
|
||||
import _ from "lodash";
|
||||
import { cookies } from "next/headers";
|
||||
import { NextResponse } from "next/server";
|
||||
@@ -20,22 +20,3 @@ export async function GET() {
|
||||
|
||||
return NextResponse.json({ status: 200, message: "OK", data: dataUser });
|
||||
}
|
||||
|
||||
async function decrypt({
|
||||
token,
|
||||
encodedKey,
|
||||
}: {
|
||||
token: string;
|
||||
encodedKey: string;
|
||||
}): Promise<Record<string, any> | null> {
|
||||
try {
|
||||
const enc = new TextEncoder().encode(encodedKey);
|
||||
const { payload } = await jwtVerify(token, enc, {
|
||||
algorithms: ["HS256"],
|
||||
});
|
||||
return (payload.user as Record<string, any>) || null;
|
||||
} catch (error) {
|
||||
console.error("Gagal verifikasi session", error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
47
src/app/api/voting/[id]/route.ts
Normal file
47
src/app/api/voting/[id]/route.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
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;
|
||||
|
||||
fixData = await prisma.voting.findFirst({
|
||||
where: {
|
||||
id: id,
|
||||
},
|
||||
include: {
|
||||
Voting_DaftarNamaVote: {
|
||||
orderBy: {
|
||||
createdAt: "asc",
|
||||
},
|
||||
where: {
|
||||
isActive: true,
|
||||
},
|
||||
},
|
||||
Author: {
|
||||
select: {
|
||||
Profile: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
return NextResponse.json(
|
||||
{ success: true, message: "Berhasil mendapatkan data", data: fixData },
|
||||
{ status: 200 }
|
||||
);
|
||||
} catch (error) {
|
||||
backendLogger.error("Gagal mendapatkan data voting by id", error);
|
||||
return NextResponse.json(
|
||||
{ success: false, message: "Gagal mendapatkan data" },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
76
src/app/api/voting/check/route.ts
Normal file
76
src/app/api/voting/check/route.ts
Normal file
@@ -0,0 +1,76 @@
|
||||
import { prisma } from "@/app/lib";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
import backendLogger from "@/util/backendLogger";
|
||||
import _ from "lodash";
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
/**
|
||||
*
|
||||
* @param id | votingId
|
||||
* @param kategori | kontribusi
|
||||
* @returns
|
||||
*/
|
||||
export async function GET(request: Request) {
|
||||
try {
|
||||
let fixData;
|
||||
const { searchParams } = new URL(request.url);
|
||||
const id = searchParams.get("id");
|
||||
const kategori = searchParams.get("kategori");
|
||||
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
if (!userLoginId) {
|
||||
return NextResponse.json(
|
||||
{ success: false, message: "Gagal mendapatkan data, coba lagi nanti " },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
|
||||
if (kategori == "isKontributor") {
|
||||
const cek = await prisma.voting_Kontributor.count({
|
||||
where: {
|
||||
authorId: userLoginId,
|
||||
votingId: id,
|
||||
},
|
||||
});
|
||||
|
||||
if (cek > 0) {
|
||||
fixData = true;
|
||||
} else {
|
||||
fixData = false;
|
||||
}
|
||||
} else if (kategori == "pilihan") {
|
||||
const cekPilihan = await prisma.voting_Kontributor.findFirst({
|
||||
where: {
|
||||
authorId: userLoginId,
|
||||
votingId: id,
|
||||
},
|
||||
select: {
|
||||
Voting_DaftarNamaVote: {
|
||||
select: {
|
||||
value: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
fixData = cekPilihan?.Voting_DaftarNamaVote?.value
|
||||
}
|
||||
|
||||
return NextResponse.json(
|
||||
{ success: true, message: "Berhasil mendapatkan data", data: fixData },
|
||||
{ status: 200 }
|
||||
);
|
||||
} catch (error) {
|
||||
backendLogger.error("Error get hitung voting", error);
|
||||
return NextResponse.json(
|
||||
{
|
||||
success: false,
|
||||
message: "Gagal mendapatkan data",
|
||||
reason: (error as Error).message,
|
||||
},
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
312
src/app/api/voting/get/route.ts
Normal file
312
src/app/api/voting/get/route.ts
Normal file
@@ -0,0 +1,312 @@
|
||||
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 search = searchParams.get("search");
|
||||
const kategori = searchParams.get("kategori");
|
||||
const status = searchParams.get("status");
|
||||
const page = searchParams.get("page");
|
||||
|
||||
const takeData = 5;
|
||||
const skipData = Number(page) * 5 - 5;
|
||||
|
||||
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" && search != null && search != "") {
|
||||
fixData = await prisma.voting.findMany({
|
||||
take: takeData,
|
||||
skip: skipData,
|
||||
orderBy: {
|
||||
updatedAt: "desc",
|
||||
},
|
||||
where: {
|
||||
voting_StatusId: "1",
|
||||
isArsip: false,
|
||||
isActive: true,
|
||||
akhirVote: {
|
||||
gte: new Date(),
|
||||
},
|
||||
title: {
|
||||
contains: search,
|
||||
mode: "insensitive",
|
||||
},
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
isActive: true,
|
||||
createdAt: true,
|
||||
updatedAt: true,
|
||||
deskripsi: true,
|
||||
awalVote: true,
|
||||
akhirVote: true,
|
||||
catatan: true,
|
||||
authorId: true,
|
||||
voting_StatusId: true,
|
||||
Voting_DaftarNamaVote: {
|
||||
orderBy: {
|
||||
createdAt: "asc",
|
||||
},
|
||||
include: {
|
||||
Voting_Kontributor: {
|
||||
include: {
|
||||
Author: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Author: {
|
||||
select: {
|
||||
id: true,
|
||||
username: true,
|
||||
nomor: true,
|
||||
Profile: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
} else if (kategori == "beranda") {
|
||||
fixData = await prisma.voting.findMany({
|
||||
take: takeData,
|
||||
skip: skipData,
|
||||
orderBy: {
|
||||
updatedAt: "desc",
|
||||
},
|
||||
where: {
|
||||
voting_StatusId: "1",
|
||||
isArsip: false,
|
||||
isActive: true,
|
||||
akhirVote: {
|
||||
gte: new Date(),
|
||||
},
|
||||
title: {
|
||||
// contains: search,
|
||||
mode: "insensitive",
|
||||
},
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
isActive: true,
|
||||
createdAt: true,
|
||||
updatedAt: true,
|
||||
deskripsi: true,
|
||||
awalVote: true,
|
||||
akhirVote: true,
|
||||
catatan: true,
|
||||
authorId: true,
|
||||
voting_StatusId: true,
|
||||
Voting_DaftarNamaVote: {
|
||||
orderBy: {
|
||||
createdAt: "asc",
|
||||
},
|
||||
include: {
|
||||
Voting_Kontributor: {
|
||||
include: {
|
||||
Author: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Author: {
|
||||
select: {
|
||||
id: true,
|
||||
username: true,
|
||||
nomor: true,
|
||||
Profile: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
} else if (kategori == "status" && status == "1") {
|
||||
fixData = await prisma.voting.findMany({
|
||||
take: takeData,
|
||||
skip: skipData,
|
||||
orderBy: {
|
||||
updatedAt: "desc",
|
||||
},
|
||||
where: {
|
||||
voting_StatusId: status,
|
||||
authorId: userLoginId as string,
|
||||
isActive: true,
|
||||
akhirVote: {
|
||||
gte: new Date(),
|
||||
},
|
||||
},
|
||||
include: {
|
||||
Voting_DaftarNamaVote: {
|
||||
orderBy: {
|
||||
createdAt: "asc",
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
} else if (kategori == "status" && status != "1") {
|
||||
fixData = await prisma.voting.findMany({
|
||||
take: takeData,
|
||||
skip: skipData,
|
||||
orderBy: {
|
||||
updatedAt: "desc",
|
||||
},
|
||||
where: {
|
||||
voting_StatusId: status,
|
||||
authorId: userLoginId as string,
|
||||
isActive: true,
|
||||
},
|
||||
});
|
||||
} else if (kategori == "kontribusi") {
|
||||
fixData = await prisma.voting_Kontributor.findMany({
|
||||
take: takeData,
|
||||
skip: skipData,
|
||||
orderBy: {
|
||||
createdAt: "desc",
|
||||
},
|
||||
where: {
|
||||
authorId: userLoginId,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
Voting: {
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
isActive: true,
|
||||
awalVote: true,
|
||||
akhirVote: true,
|
||||
Voting_DaftarNamaVote: {
|
||||
orderBy: {
|
||||
createdAt: "asc",
|
||||
},
|
||||
},
|
||||
Author: {
|
||||
select: {
|
||||
Profile: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Voting_DaftarNamaVote: true,
|
||||
Author: true,
|
||||
},
|
||||
});
|
||||
} else if (kategori == "riwayat" && status == "1") {
|
||||
fixData = await prisma.voting.findMany({
|
||||
take: takeData,
|
||||
skip: skipData,
|
||||
|
||||
orderBy: {
|
||||
createdAt: "asc",
|
||||
},
|
||||
where: {
|
||||
voting_StatusId: "1",
|
||||
isActive: true,
|
||||
akhirVote: {
|
||||
lte: new Date(),
|
||||
},
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
isActive: true,
|
||||
createdAt: true,
|
||||
updatedAt: true,
|
||||
deskripsi: true,
|
||||
awalVote: true,
|
||||
akhirVote: true,
|
||||
catatan: true,
|
||||
authorId: true,
|
||||
voting_StatusId: true,
|
||||
Voting_DaftarNamaVote: {
|
||||
orderBy: {
|
||||
createdAt: "asc",
|
||||
},
|
||||
},
|
||||
Author: {
|
||||
select: {
|
||||
id: true,
|
||||
username: true,
|
||||
nomor: true,
|
||||
Profile: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
} else if (kategori == "riwayat" && status == "2") {
|
||||
fixData = await prisma.voting.findMany({
|
||||
take: takeData,
|
||||
skip: skipData,
|
||||
|
||||
orderBy: {
|
||||
createdAt: "asc",
|
||||
},
|
||||
where: {
|
||||
voting_StatusId: "1",
|
||||
authorId: userLoginId as string,
|
||||
isActive: true,
|
||||
akhirVote: {
|
||||
lte: new Date(),
|
||||
},
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
isActive: true,
|
||||
createdAt: true,
|
||||
updatedAt: true,
|
||||
deskripsi: true,
|
||||
awalVote: true,
|
||||
akhirVote: true,
|
||||
catatan: true,
|
||||
authorId: true,
|
||||
voting_StatusId: true,
|
||||
Voting_DaftarNamaVote: {
|
||||
orderBy: {
|
||||
createdAt: "asc",
|
||||
},
|
||||
},
|
||||
Author: {
|
||||
select: {
|
||||
id: true,
|
||||
username: true,
|
||||
nomor: true,
|
||||
Profile: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
return NextResponse.json(
|
||||
{ success: true, message: "Berhasil mendapatkan data", data: fixData },
|
||||
{ status: 200 }
|
||||
);
|
||||
} catch (error) {
|
||||
backendLogger.error("Error get voting: ", error);
|
||||
return NextResponse.json(
|
||||
{
|
||||
success: false,
|
||||
message: "Gagal mendapatkan data",
|
||||
reason: (error as Error).message,
|
||||
},
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
30
src/app/api/voting/hasil/route.ts
Normal file
30
src/app/api/voting/hasil/route.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
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) {
|
||||
try {
|
||||
let fixData;
|
||||
const { searchParams } = new URL(request.url);
|
||||
const id = searchParams.get("id");
|
||||
|
||||
fixData = await prisma.voting_DaftarNamaVote.findMany({
|
||||
where: {
|
||||
votingId: id,
|
||||
},
|
||||
});
|
||||
|
||||
return NextResponse.json(
|
||||
{ success: true, message: "Berhasil mendapatkan data", data: fixData },
|
||||
{ status: 200 }
|
||||
);
|
||||
} catch (error) {
|
||||
backendLogger.error(error);
|
||||
return NextResponse.json(
|
||||
{ success: false, message: "Gagal mendapatkan data" },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
46
src/app/api/voting/kontributor/route.ts
Normal file
46
src/app/api/voting/kontributor/route.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
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) {
|
||||
try {
|
||||
let fixData;
|
||||
const { searchParams } = new URL(request.url);
|
||||
const id = searchParams.get("id");
|
||||
const page = searchParams.get("page");
|
||||
const takeData = 10;
|
||||
const dataSkip = Number(page) * takeData - takeData;
|
||||
fixData = await prisma.voting_Kontributor.findMany({
|
||||
// take: takeData,
|
||||
// skip: dataSkip,
|
||||
orderBy: {
|
||||
createdAt: "desc",
|
||||
},
|
||||
where: {
|
||||
votingId: id,
|
||||
},
|
||||
include: {
|
||||
Author: {
|
||||
include: {
|
||||
Profile: true,
|
||||
},
|
||||
},
|
||||
Voting_DaftarNamaVote: {
|
||||
select: {
|
||||
value: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
return NextResponse.json({ success: true, data: fixData }, { status: 200 });
|
||||
} catch (error) {
|
||||
backendLogger.error(error);
|
||||
return NextResponse.json(
|
||||
{ success: false, reason: (error as Error).message || (error as Error) },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
22
src/app/api/voting/master/route.ts
Normal file
22
src/app/api/voting/master/route.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { prisma } from "@/app/lib";
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
export async function GET(request: Request) {
|
||||
try {
|
||||
const data = await prisma.voting_Status.findMany();
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
message: "Berhasil mendapatkan data",
|
||||
data: data,
|
||||
});
|
||||
} catch (error) {
|
||||
return NextResponse.json(
|
||||
{
|
||||
success: false,
|
||||
message: "Gagal mendapatkan data",
|
||||
reason: (error as Error).message,
|
||||
},
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,21 +1,9 @@
|
||||
import { HomeViewNew } from "@/app_modules/home";
|
||||
import notifikasi_countUserNotifikasi from "@/app_modules/notifikasi/fun/count/fun_count_by_id";
|
||||
|
||||
export default async function PageHome() {
|
||||
// const userLoginId = await funGetUserIdByToken();
|
||||
// const dataUser = await user_getOneByUserId(userLoginId as string);
|
||||
// const dataJob = await job_getTwoForHomeView();
|
||||
const countNotifikasi = await notifikasi_countUserNotifikasi();
|
||||
|
||||
|
||||
return (
|
||||
<>
|
||||
{/* <HomeView
|
||||
dataUser={dataUser as any}
|
||||
dataJob={dataJob as any}
|
||||
countNotifikasi={countNotifikasi}
|
||||
/> */}
|
||||
<HomeViewNew countNotifikasi={countNotifikasi} />
|
||||
<HomeViewNew />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
import { Admin_TablePublishInvestasi } from "@/app_modules/admin/investasi";
|
||||
import Admin_funGetAllInvestasi from "@/app_modules/admin/investasi/fun/get_all_investasi";
|
||||
|
||||
export default async function Page() {
|
||||
const listInvestasi = await Admin_funGetAllInvestasi();
|
||||
|
||||
return<>
|
||||
<Admin_TablePublishInvestasi dataInvestsi={listInvestasi as any}/>
|
||||
</>
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
import { Admin_TableRejectInvestasi } from "@/app_modules/admin/investasi";
|
||||
import Admin_funGetAllInvestasi from "@/app_modules/admin/investasi/fun/get_all_investasi";
|
||||
|
||||
export default async function Page() {
|
||||
const dataInvestsi = await Admin_funGetAllInvestasi()
|
||||
return <>
|
||||
<Admin_TableRejectInvestasi dataInvestsi={dataInvestsi as any}/>
|
||||
|
||||
</>
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
import { Admin_TableReviewInvestasi } from "@/app_modules/admin/investasi";
|
||||
import Admin_funGetAllInvestasi from "@/app_modules/admin/investasi/fun/get_all_investasi";
|
||||
|
||||
export default async function Page() {
|
||||
const dataInvestsi = await Admin_funGetAllInvestasi()
|
||||
return <>
|
||||
<Admin_TableReviewInvestasi dataInvestsi={dataInvestsi as any}/>
|
||||
</>
|
||||
}
|
||||
@@ -1,12 +1,9 @@
|
||||
import { Colab_Create } from "@/app_modules/colab";
|
||||
import colab_funGetMasterIndustri from "@/app_modules/colab/fun/master/fun_get_master_industri";
|
||||
|
||||
export default async function Page() {
|
||||
const listIndustri = await colab_funGetMasterIndustri();
|
||||
|
||||
return (
|
||||
<>
|
||||
<Colab_Create listIndustri={listIndustri as any} />
|
||||
<Colab_Create />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
import { CreateDonasi } from "@/app_modules/donasi";
|
||||
import {
|
||||
Donasi_getMasterDurasi,
|
||||
Donasi_getMasterKategori,
|
||||
} from "@/app_modules/donasi/fun";
|
||||
import { CreateDonasiNew } from "@/app_modules/donasi";
|
||||
|
||||
|
||||
export default async function Page() {
|
||||
const masterKategori = await Donasi_getMasterKategori();
|
||||
const masterDurasi = await Donasi_getMasterDurasi();
|
||||
// const masterKategori = await Donasi_getMasterKategori();
|
||||
// const masterDurasi = await Donasi_getMasterDurasi();
|
||||
|
||||
return (
|
||||
<CreateDonasi masterKategori={masterKategori} masterDurasi={masterDurasi} />
|
||||
// <CreateDonasi masterKategori={masterKategori} masterDurasi={masterDurasi} />
|
||||
<CreateDonasiNew />
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,29 +1,25 @@
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
import { LayoutDetailMainDonasi } from "@/app_modules/donasi";
|
||||
import { Donasi_getOneById } from "@/app_modules/donasi/fun/get/get_one_donasi_by_id";
|
||||
import { LayoutDetailMainDonasiNew } from "@/app_modules/donasi";
|
||||
import React from "react";
|
||||
|
||||
export default async function Layout({
|
||||
children,
|
||||
params,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
params: { id: string };
|
||||
}) {
|
||||
const donasiId = params.id;
|
||||
const getData = await Donasi_getOneById(donasiId);
|
||||
const authorId = getData?.authorId;
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
export default async function Layout({ children, params, }: { children: React.ReactNode; params: { id: string }; }) {
|
||||
// const donasiId = params.id;
|
||||
// const getData = await Donasi_getOneById(donasiId);
|
||||
// const authorId = getData?.authorId;
|
||||
// const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
return (
|
||||
<>
|
||||
<LayoutDetailMainDonasi
|
||||
{/* <LayoutDetailMainDonasi
|
||||
donasiId={donasiId}
|
||||
authorId={authorId as any}
|
||||
userLoginId={userLoginId as string}
|
||||
>
|
||||
{children}
|
||||
</LayoutDetailMainDonasi>
|
||||
</LayoutDetailMainDonasi> */}
|
||||
|
||||
<LayoutDetailMainDonasiNew>
|
||||
{children}
|
||||
</LayoutDetailMainDonasiNew>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,22 +1,20 @@
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
import { DetailMainDonasi } from "@/app_modules/donasi";
|
||||
import { Donasi_getCountDonatur } from "@/app_modules/donasi/fun/count/get_count_donatur";
|
||||
import { Donasi_getOneById } from "@/app_modules/donasi/fun/get/get_one_donasi_by_id";
|
||||
import DetailMainDonasiNew from "@/app_modules/donasi/detail/detail_main/index_new";
|
||||
|
||||
export default async function Page({ params }: { params: { id: string } }) {
|
||||
let donasiId = params.id;
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
// let donasiId = params.id;
|
||||
// const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
const dataDonasi = await Donasi_getOneById(donasiId);
|
||||
const countDonatur = await Donasi_getCountDonatur(donasiId);
|
||||
// const dataDonasi = await Donasi_getOneById(donasiId);
|
||||
// const countDonatur = await Donasi_getCountDonatur(donasiId);
|
||||
|
||||
return (
|
||||
<>
|
||||
<DetailMainDonasi
|
||||
{/* <DetailMainDonasi
|
||||
dataDonasi={dataDonasi as any}
|
||||
countDonatur={countDonatur}
|
||||
userLoginId={userLoginId as string}
|
||||
/>
|
||||
/> */}
|
||||
<DetailMainDonasiNew />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
import { EditDonasi } from "@/app_modules/donasi";
|
||||
import { EditDonasi, EditDonasiNew } from "@/app_modules/donasi";
|
||||
import { Donasi_getMasterDurasi, Donasi_getMasterKategori } from "@/app_modules/donasi/fun";
|
||||
import { Donasi_getOneById } from "@/app_modules/donasi/fun/get/get_one_donasi_by_id";
|
||||
|
||||
export default async function Page({params}: {params: {id: string}}) {
|
||||
const dataDonasi = await Donasi_getOneById(params.id)
|
||||
const masterKategori = await Donasi_getMasterKategori()
|
||||
const masterDurasi = await Donasi_getMasterDurasi()
|
||||
export default async function Page({ params }: { params: { id: string } }) {
|
||||
// const dataDonasi = await Donasi_getOneById(params.id)
|
||||
// const masterKategori = await Donasi_getMasterKategori()
|
||||
// const masterDurasi = await Donasi_getMasterDurasi()
|
||||
|
||||
return (
|
||||
<>
|
||||
<EditDonasi dataDonasi={dataDonasi as any} masterKategori={masterKategori} masterDurasi={masterDurasi} />
|
||||
{/* <EditDonasi dataDonasi={dataDonasi as any} masterKategori={masterKategori} masterDurasi={masterDurasi} /> */}
|
||||
<EditDonasiNew />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
import { DonasiSayaDonasi } from "@/app_modules/donasi";
|
||||
import { donasi_funGetAllInvoiceByAuthorId } from "@/app_modules/donasi/fun/get/get_all_invoice_by_author_id";
|
||||
import DonasiSayaNew from "@/app_modules/donasi/main/donasi_saya_new";
|
||||
|
||||
export default async function Page() {
|
||||
const listInvoice = await donasi_funGetAllInvoiceByAuthorId({ page: 1 });
|
||||
// const listInvoice = await donasi_funGetAllInvoiceByAuthorId({ page: 1 });
|
||||
|
||||
return <DonasiSayaDonasi listInvoice={listInvoice as any} />;
|
||||
return (
|
||||
<>
|
||||
{/* <DonasiSayaDonasi listInvoice={listInvoice as any} />; */}
|
||||
<DonasiSayaNew />
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,27 +1,23 @@
|
||||
import { GalangDanaDonasiNew, PostingDonasi } from "@/app_modules/donasi";
|
||||
import { donasi_funGetAllStatusById } from "@/app_modules/donasi/fun";
|
||||
import { donasi_funMasterStatusDonasi } from "@/app_modules/donasi/fun/master/get_status_donasi";
|
||||
import { GalangDanaDonasiNew } from "@/app_modules/donasi";
|
||||
|
||||
export default async function Page({ params }: { params: { id: string } }) {
|
||||
const statusId = params.id;
|
||||
// const statusId = params.id;
|
||||
|
||||
const listStatus = await donasi_funMasterStatusDonasi();
|
||||
const dataDonasi = await donasi_funGetAllStatusById({
|
||||
page: 1,
|
||||
statusId: statusId,
|
||||
});
|
||||
// const listStatus = await donasi_funMasterStatusDonasi();
|
||||
// const dataDonasi = await donasi_funGetAllStatusById({
|
||||
// page: 1,
|
||||
// statusId: statusId,
|
||||
// });
|
||||
|
||||
return (
|
||||
<>
|
||||
<PostingDonasi
|
||||
{/* <PostingDonasi
|
||||
statusId={statusId}
|
||||
dataStatus={dataDonasi}
|
||||
listStatus={listStatus}
|
||||
/>
|
||||
/> */}
|
||||
|
||||
|
||||
{/* NANTI AJA LANJUT -- KEJAR TAYANG :) */}
|
||||
{/* <GalangDanaDonasiNew listStatus={listStatus}/> */}
|
||||
<GalangDanaDonasiNew />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { newFunGetUserId } from "@/app/lib/new_fun_user_id";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
import { Event_Create } from "@/app_modules/event";
|
||||
import { Event_getMasterTipeAcara } from "@/app_modules/event/fun/master/get_tipe_acara";
|
||||
|
||||
export default async function Page() {
|
||||
const userLoginId = await newFunGetUserId();
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
const listTipeAcara = await Event_getMasterTipeAcara();
|
||||
|
||||
return (
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { newFunGetUserId } from "@/app/lib/new_fun_user_id";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
import { Event_DetailMain } from "@/app_modules/event";
|
||||
import { Event_countTotalPesertaById } from "@/app_modules/event/fun/count/count_total_peserta_by_id";
|
||||
|
||||
export default async function Page({ params }: { params: { id: string } }) {
|
||||
let eventId = params.id;
|
||||
const userLoginId = await newFunGetUserId();
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
const totalPeserta = await Event_countTotalPesertaById(eventId);
|
||||
|
||||
return (
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { newFunGetUserId } from "@/app/lib/new_fun_user_id";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
import Ui_Konfirmasi from "@/app_modules/event/_ui/konfirmasi";
|
||||
|
||||
export default async function Page({
|
||||
@@ -7,7 +7,7 @@ export default async function Page({
|
||||
params: Promise<{ id: string }>;
|
||||
}) {
|
||||
const eventId = (await params).id;
|
||||
const userLoginId = await newFunGetUserId();
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
return (
|
||||
<>
|
||||
|
||||
@@ -1,23 +1,9 @@
|
||||
import { InvestasiCreate } from "@/app_modules/investasi";
|
||||
import getPembagianDeviden from "@/app_modules/investasi/fun/master/get_pembagian_deviden";
|
||||
import getPencarianInvestor from "@/app_modules/investasi/fun/master/get_pencarian_investor";
|
||||
import getPeriodeDeviden from "@/app_modules/investasi/fun/master/get_periode_deviden";
|
||||
import getStatusInvestasi from "@/app_modules/investasi/fun/master/get_status_investasi";
|
||||
import { InvestasiCreateNew } from "@/app_modules/investasi";
|
||||
|
||||
export default async function Page() {
|
||||
|
||||
const pencarianInvestor = await getPencarianInvestor();
|
||||
const periodeDeviden = await getPeriodeDeviden();
|
||||
const pembagianDeviden = await getPembagianDeviden();
|
||||
const statusInvestasi = await getStatusInvestasi();
|
||||
|
||||
return (
|
||||
<>
|
||||
<InvestasiCreate
|
||||
pencarianInvestor={pencarianInvestor as any}
|
||||
periodeDeviden={periodeDeviden as any}
|
||||
pembagianDeviden={pembagianDeviden as any}
|
||||
/>
|
||||
<InvestasiCreateNew />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,39 +1,39 @@
|
||||
import { investasi_funGetOneInvestasiById } from "@/app_modules/investasi/_fun";
|
||||
import { Investasi_UiEditInvestasi } from "@/app_modules/investasi/_ui";
|
||||
import { Investasi_UiEditInvestasi, Investasi_UiEditInvestasiNew } from "@/app_modules/investasi/_ui";
|
||||
import getPembagianDeviden from "@/app_modules/investasi/fun/master/get_pembagian_deviden";
|
||||
import getPencarianInvestor from "@/app_modules/investasi/fun/master/get_pencarian_investor";
|
||||
import getPeriodeDeviden from "@/app_modules/investasi/fun/master/get_periode_deviden";
|
||||
import _ from "lodash";
|
||||
|
||||
export default async function Page({ params }: { params: { id: string } }) {
|
||||
const investasiId = params.id;
|
||||
// console.log(investasiId);
|
||||
// const investasiId = params.id;
|
||||
|
||||
const allData = await investasi_funGetOneInvestasiById({ investasiId });
|
||||
const dataInvestasi = _.omit(allData, [
|
||||
"BeritaInvestasi",
|
||||
"DokumenInvestasi",
|
||||
"MasterPembagianDeviden",
|
||||
"MasterPencarianInvestor",
|
||||
"MasterProgresInvestasi",
|
||||
"MasterStatusInvestasi",
|
||||
"ProspektusInvestasi",
|
||||
"MasterPeriodeDeviden",
|
||||
"author",
|
||||
]);
|
||||
// const allData = await investasi_funGetOneInvestasiById({ investasiId });
|
||||
// const dataInvestasi = _.omit(allData, [
|
||||
// "BeritaInvestasi",
|
||||
// "DokumenInvestasi",
|
||||
// "MasterPembagianDeviden",
|
||||
// "MasterPencarianInvestor",
|
||||
// "MasterProgresInvestasi",
|
||||
// "MasterStatusInvestasi",
|
||||
// "ProspektusInvestasi",
|
||||
// "MasterPeriodeDeviden",
|
||||
// "author",
|
||||
// ]);
|
||||
|
||||
const listPencarian = await getPencarianInvestor();
|
||||
const listPeriode = await getPeriodeDeviden();
|
||||
const listPembagian = await getPembagianDeviden();
|
||||
// const listPencarian = await getPencarianInvestor();
|
||||
// const listPeriode = await getPeriodeDeviden();
|
||||
// const listPembagian = await getPembagianDeviden();
|
||||
|
||||
return (
|
||||
<>
|
||||
<Investasi_UiEditInvestasi
|
||||
{/* <Investasi_UiEditInvestasi
|
||||
dataInvestasi={dataInvestasi}
|
||||
pembagianDeviden={listPembagian}
|
||||
pencarianInvestor={listPencarian}
|
||||
periodeDeviden={listPeriode}
|
||||
/>
|
||||
/> */}
|
||||
<Investasi_UiEditInvestasiNew />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { Investasi_UiBeranda } from "@/app_modules/investasi/_ui";
|
||||
import { investasi_funGetAllPublish } from "@/app_modules/investasi/fun/get_all_investasi";
|
||||
import { Investasi_ViewBerandaNew } from "@/app_modules/investasi/_ui";
|
||||
|
||||
export default async function Page() {
|
||||
const allData = await investasi_funGetAllPublish({ page: 1 });
|
||||
// const allData = await investasi_funGetAllPublish({ page: 1 });
|
||||
|
||||
return (
|
||||
<>
|
||||
<Investasi_UiBeranda dataInvestasi={allData as any} />
|
||||
{/* <Investasi_UiBeranda dataInvestasi={allData as any} /> */}
|
||||
<Investasi_ViewBerandaNew />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,22 +1,21 @@
|
||||
import { investasi_funGetPortofolioByStatusId } from "@/app_modules/investasi/_fun";
|
||||
import { Investasi_UiPortofolio } from "@/app_modules/investasi/_ui";
|
||||
import getStatusInvestasi from "@/app_modules/investasi/fun/master/get_status_investasi";
|
||||
import { Investasi_UiPortofolioNew } from "@/app_modules/investasi/_ui";
|
||||
|
||||
export default async function Page({ params }: { params: { id: string } }) {
|
||||
const statusId = params.id;
|
||||
const listStatus = await getStatusInvestasi();
|
||||
const dataPortofolio = await investasi_funGetPortofolioByStatusId({
|
||||
page: 1,
|
||||
statusId: statusId,
|
||||
});
|
||||
// const statusId = params.id;
|
||||
// const listStatus = await getStatusInvestasi();
|
||||
// const dataPortofolio = await investasi_funGetPortofolioByStatusId({
|
||||
// page: 1,
|
||||
// statusId: statusId,
|
||||
// });
|
||||
|
||||
return (
|
||||
<>
|
||||
<Investasi_UiPortofolio
|
||||
{/* <Investasi_UiPortofolio
|
||||
statusId={statusId}
|
||||
listStatus={listStatus as any}
|
||||
dataPortofolio={dataPortofolio as any}
|
||||
/>
|
||||
/> */}
|
||||
<Investasi_UiPortofolioNew />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { investasi_funGetSuccessTransactionById } from "@/app_modules/investasi/_fun";
|
||||
import { Investasi_UiSahamSaya } from "@/app_modules/investasi/_ui";
|
||||
import { Investasi_ViewSahamSayaNew } from "@/app_modules/investasi/_view/main/view_saham_saya_new";
|
||||
|
||||
export default async function Page() {
|
||||
const dataSaham = await investasi_funGetSuccessTransactionById({ page: 1 });
|
||||
// const dataSaham = await investasi_funGetSuccessTransactionById({ page: 1 });
|
||||
|
||||
return (
|
||||
<>
|
||||
{/* <InvestasiSahamTerbeli listTransaksi={listTransaksi as any} /> */}
|
||||
<Investasi_UiSahamSaya dataSaham={dataSaham as any} />
|
||||
{/* <Investasi_UiSahamSaya dataSaham={dataSaham as any} /> */}
|
||||
<Investasi_ViewSahamSayaNew />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import getMaster_StatusTransaksiInvestasi from "@/app_modules/investasi/fun/mast
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
import { investasi_funGetTransaksiByUserId } from "@/app_modules/investasi/_fun";
|
||||
import { Investasi_UiDaftarTransaksi } from "@/app_modules/investasi/_ui";
|
||||
import { Investasi_ViewDaftarTransaksiNew } from "@/app_modules/investasi/_view/main/view_transaksi_new";
|
||||
|
||||
export default async function Page() {
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
@@ -22,7 +23,8 @@ export default async function Page() {
|
||||
statusTransaksi={statusTransaksi as any}
|
||||
listTransaksi={listTransaksi as any}
|
||||
/> */}
|
||||
<Investasi_UiDaftarTransaksi dataTransaksi={dataTransaksi} />
|
||||
{/* <Investasi_UiDaftarTransaksi dataTransaksi={dataTransaksi} /> */}
|
||||
<Investasi_ViewDaftarTransaksiNew/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { funGlobal_getAllBank } from "@/app_modules/_global/fun/get/fun_get_all_bank";
|
||||
import { Investasi_UiMetodePembayaran } from "@/app_modules/investasi/_ui";
|
||||
import getMaster_NamaBank from "@/app_modules/investasi/fun/master/get_nama_bank";
|
||||
|
||||
export default async function Page({ params }: { params: { id: string } }) {
|
||||
const investasiId = params.id;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
import { RealtimeProvider } from "../lib";
|
||||
import { newFunGetUserId } from "../lib/new_fun_user_id";
|
||||
import { ServerEnv } from "../lib/server_env";
|
||||
|
||||
export default async function Layout({
|
||||
@@ -7,9 +7,13 @@ export default async function Layout({
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
}) {
|
||||
|
||||
const userId = await funGetUserIdByToken();
|
||||
|
||||
return (
|
||||
<>
|
||||
<RealtimeProvider
|
||||
userId={userId}
|
||||
WIBU_REALTIME_TOKEN={
|
||||
ServerEnv.value?.NEXT_PUBLIC_WIBU_REALTIME_TOKEN as string
|
||||
}
|
||||
|
||||
@@ -1,17 +1,9 @@
|
||||
import {
|
||||
Notifikasi_UiCollaboration
|
||||
} from "@/app_modules/notifikasi/_ui";
|
||||
import notifikasi_getByUserId from "@/app_modules/notifikasi/fun/get/get_notifiaksi_by_id";
|
||||
import { Notifikasi_UiMain } from "@/app_modules/notifikasi/_ui";
|
||||
|
||||
export default async function Page() {
|
||||
const listNotifikasi = await notifikasi_getByUserId({
|
||||
page: 1,
|
||||
kategoriApp: "Collaboration",
|
||||
});
|
||||
|
||||
return (
|
||||
<>
|
||||
<Notifikasi_UiCollaboration listNotifikasi={listNotifikasi} />
|
||||
<Notifikasi_UiMain />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,15 +1,9 @@
|
||||
import { Notifikasi_UiDonasi } from "@/app_modules/notifikasi/_ui";
|
||||
import notifikasi_getByUserId from "@/app_modules/notifikasi/fun/get/get_notifiaksi_by_id";
|
||||
import { Notifikasi_UiMain } from "@/app_modules/notifikasi/_ui";
|
||||
|
||||
export default async function Page() {
|
||||
const listNotifikasi = await notifikasi_getByUserId({
|
||||
page: 1,
|
||||
kategoriApp: "Donasi",
|
||||
});
|
||||
|
||||
return (
|
||||
<>
|
||||
<Notifikasi_UiDonasi listNotifikasi={listNotifikasi} />
|
||||
<Notifikasi_UiMain />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,15 +1,9 @@
|
||||
import { Notifikasi_UiEvent } from "@/app_modules/notifikasi/_ui";
|
||||
import notifikasi_getByUserId from "@/app_modules/notifikasi/fun/get/get_notifiaksi_by_id";
|
||||
import Notifikasi_UiMain from "@/app_modules/notifikasi/_ui/ui_notifikasi";
|
||||
|
||||
export default async function Page() {
|
||||
const listNotifikasi = await notifikasi_getByUserId({
|
||||
page: 1,
|
||||
kategoriApp: "Event",
|
||||
});
|
||||
|
||||
return (
|
||||
<>
|
||||
<Notifikasi_UiEvent listNotifikasi={listNotifikasi} />
|
||||
<Notifikasi_UiMain />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,15 +1,9 @@
|
||||
import { Notifikasi_UiForum } from "@/app_modules/notifikasi/_ui";
|
||||
import notifikasi_getByUserId from "@/app_modules/notifikasi/fun/get/get_notifiaksi_by_id";
|
||||
import { Notifikasi_UiMain } from "@/app_modules/notifikasi/_ui";
|
||||
|
||||
export default async function Page() {
|
||||
const listNotifikasi = await notifikasi_getByUserId({
|
||||
page: 1,
|
||||
kategoriApp: "Forum",
|
||||
});
|
||||
|
||||
return (
|
||||
<>
|
||||
<Notifikasi_UiForum listNotifikasi={listNotifikasi} />
|
||||
<Notifikasi_UiMain />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,15 +1,9 @@
|
||||
import { Notifikasi_UiDonasi, Notifikasi_UiInvestasi } from "@/app_modules/notifikasi/_ui";
|
||||
import notifikasi_getByUserId from "@/app_modules/notifikasi/fun/get/get_notifiaksi_by_id";
|
||||
import { Notifikasi_UiMain } from "@/app_modules/notifikasi/_ui";
|
||||
|
||||
export default async function Page() {
|
||||
const listNotifikasi = await notifikasi_getByUserId({
|
||||
page: 1,
|
||||
kategoriApp: "Investasi",
|
||||
});
|
||||
|
||||
return (
|
||||
<>
|
||||
<Notifikasi_UiInvestasi listNotifikasi={listNotifikasi} />
|
||||
<Notifikasi_UiMain />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,15 +1,9 @@
|
||||
import { Notifikasi_UiJob } from "@/app_modules/notifikasi/_ui";
|
||||
import notifikasi_getByUserId from "@/app_modules/notifikasi/fun/get/get_notifiaksi_by_id";
|
||||
import { Notifikasi_UiMain } from "@/app_modules/notifikasi/_ui";
|
||||
|
||||
export default async function Page() {
|
||||
const listNotifikasi = await notifikasi_getByUserId({
|
||||
page: 1,
|
||||
kategoriApp: "Job",
|
||||
});
|
||||
|
||||
return (
|
||||
<>
|
||||
<Notifikasi_UiJob listNotifikasi={listNotifikasi} />
|
||||
<Notifikasi_UiMain />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,19 +1,15 @@
|
||||
import { UIGlobal_LayoutHeaderTamplate } from "@/app_modules/_global/ui";
|
||||
import { Notifikasi_UiNewLayout } from "@/app_modules/notifikasi/_ui";
|
||||
import { notifikasi_funGetKategoriApp } from "@/app_modules/notifikasi/fun/get/fun_get_kategori_app";
|
||||
|
||||
export default async function Layout({
|
||||
children,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
}) {
|
||||
const masterKategori = await notifikasi_funGetKategoriApp();
|
||||
|
||||
return (
|
||||
<>
|
||||
<Notifikasi_UiNewLayout
|
||||
header={<UIGlobal_LayoutHeaderTamplate title="Notifikasi" />}
|
||||
masterKategori={masterKategori}
|
||||
>
|
||||
{children}
|
||||
</Notifikasi_UiNewLayout>
|
||||
|
||||
@@ -1,15 +1,9 @@
|
||||
import { Notifikasi_UiAll } from "@/app_modules/notifikasi/_ui";
|
||||
import notifikasi_getByUserId from "@/app_modules/notifikasi/fun/get/get_notifiaksi_by_id";
|
||||
import { Notifikasi_UiMain } from "@/app_modules/notifikasi/_ui";
|
||||
|
||||
export default async function Page() {
|
||||
const listNotifikasi = await notifikasi_getByUserId({
|
||||
page: 1,
|
||||
kategoriApp: "Semua",
|
||||
});
|
||||
|
||||
return (
|
||||
<>
|
||||
<Notifikasi_UiAll listNotifikasi={listNotifikasi} />
|
||||
<Notifikasi_UiMain />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,15 +1,9 @@
|
||||
import { Notifikasi_UiVoting } from "@/app_modules/notifikasi/_ui";
|
||||
import notifikasi_getByUserId from "@/app_modules/notifikasi/fun/get/get_notifiaksi_by_id";
|
||||
import { Notifikasi_UiMain } from "@/app_modules/notifikasi/_ui";
|
||||
|
||||
export default async function Page() {
|
||||
const listNotifikasi = await notifikasi_getByUserId({
|
||||
page: 1,
|
||||
kategoriApp: "Voting",
|
||||
});
|
||||
|
||||
return (
|
||||
<>
|
||||
<Notifikasi_UiVoting listNotifikasi={listNotifikasi} />
|
||||
<Notifikasi_UiMain />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
import { Voting_UiDetailKontributorVoting } from "@/app_modules/vote/_ui";
|
||||
import { Vote_getListKontributorById } from "@/app_modules/vote/fun/get/get_list_kontributor_by_id";
|
||||
|
||||
export default async function Page({ params }: { params: { id: string } }) {
|
||||
const votingId = params.id;
|
||||
const listKontributor = await Vote_getListKontributorById(votingId);
|
||||
|
||||
export default async function Page() {
|
||||
return (
|
||||
<>
|
||||
<Voting_UiDetailKontributorVoting listKontributor={listKontributor} />
|
||||
<Voting_UiDetailKontributorVoting />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,29 +1,12 @@
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
import { Vote_MainDetail } from "@/app_modules/vote";
|
||||
import { Vote_cekKontributorById } from "@/app_modules/vote/fun/get/cek_kontributor_by_id";
|
||||
import { voting_funGetOneVotingbyId } from "@/app_modules/vote/fun/get/fun_get_one_by_id";
|
||||
import { Vote_getHasilVoteById } from "@/app_modules/vote/fun/get/get_list_hasil_by_id";
|
||||
import { Vote_getListKontributorById } from "@/app_modules/vote/fun/get/get_list_kontributor_by_id";
|
||||
import { Vote_getOnePilihanVotingByUserId } from "@/app_modules/vote/fun/get/get_one_pilihan_voting_by_user_id";
|
||||
|
||||
export default async function Page({ params }: { params: { id: string } }) {
|
||||
const voteId = params.id;
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
const dataVote = await voting_funGetOneVotingbyId(voteId);
|
||||
const hasilVoting = await Vote_getHasilVoteById(voteId as any);
|
||||
const isKontributor = await Vote_cekKontributorById(voteId);
|
||||
const pilihanKontributor = await Vote_getOnePilihanVotingByUserId(voteId);
|
||||
const listKontributor = await Vote_getListKontributorById(voteId);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Vote_MainDetail
|
||||
dataVote={dataVote as any}
|
||||
hasilVoting={hasilVoting}
|
||||
isKontributor={isKontributor}
|
||||
pilihanKontributor={pilihanKontributor as any}
|
||||
listKontributor={listKontributor as any}
|
||||
userLoginId={userLoginId as string}
|
||||
/>
|
||||
</>
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
import { Vote_Beranda } from "@/app_modules/vote";
|
||||
import { vote_getAllListPublish } from "@/app_modules/vote/fun/get/get_all_list_publish";
|
||||
|
||||
export default async function Page() {
|
||||
const dataVote = await vote_getAllListPublish({ page: 1 });
|
||||
|
||||
return (
|
||||
<>
|
||||
<Vote_Beranda dataVote={dataVote as any} />
|
||||
<Vote_Beranda />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
import { Vote_Kontribusi } from "@/app_modules/vote";
|
||||
import { vote_getAllListKontribusiByAuthorId } from "@/app_modules/vote/fun/get/get_list_kontribusi_by_author_id";
|
||||
|
||||
export default async function Page() {
|
||||
const dataKontribusi = await vote_getAllListKontribusiByAuthorId({ page: 1 });
|
||||
return (
|
||||
<>
|
||||
<Vote_Kontribusi dataKontribusi={dataKontribusi as any} />
|
||||
<Vote_Kontribusi />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,41 +1,9 @@
|
||||
import { Vote_Riwayat } from "@/app_modules/vote";
|
||||
import { vote_getAllListRiwayat } from "@/app_modules/vote/fun/get/get_all_list_riwayat";
|
||||
import { Vote_getAllListRiwayatSaya as vote_getAllListRiwayatSaya } from "@/app_modules/vote/fun/get/get_all_list_riwayat_saya";
|
||||
|
||||
export default async function Page({ params }: { params: { id: string } }) {
|
||||
let statusRiwayatId = params.id;
|
||||
|
||||
const listRiwayat = await vote_getAllListRiwayat({ page: 1 });
|
||||
const listRiwayatSaya = await vote_getAllListRiwayatSaya({ page: 1 });
|
||||
|
||||
if (statusRiwayatId == "1") {
|
||||
return (
|
||||
<>
|
||||
<Vote_Riwayat
|
||||
riwayatId={statusRiwayatId}
|
||||
listRiwayat={listRiwayat as any}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
if (statusRiwayatId == "2") {
|
||||
return (
|
||||
<>
|
||||
<Vote_Riwayat
|
||||
riwayatId={statusRiwayatId}
|
||||
listRiwayatSaya={listRiwayatSaya as any}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
// return (
|
||||
// <>
|
||||
// <Vote_Riwayat
|
||||
// riwayatId={statusRiwayatId}
|
||||
// listRiwayat={listRiwayat as any}
|
||||
// listRiwayatSaya={listRiwayatSaya as any}
|
||||
// />
|
||||
// </>
|
||||
// );
|
||||
return (
|
||||
<>
|
||||
<Vote_Riwayat />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,25 +1,9 @@
|
||||
import { Vote_Status } from "@/app_modules/vote";
|
||||
import {
|
||||
vote_funGetAllByStatusId,
|
||||
voting_getMasterStatus,
|
||||
} from "@/app_modules/vote/fun";
|
||||
|
||||
export default async function Page({ params }: { params: { id: string } }) {
|
||||
const statusId = params.id;
|
||||
|
||||
const listStatus = await voting_getMasterStatus();
|
||||
const dataVoting = await vote_funGetAllByStatusId({
|
||||
page: 1,
|
||||
statusId: statusId,
|
||||
});
|
||||
|
||||
export default async function Page() {
|
||||
return (
|
||||
<>
|
||||
<Vote_Status
|
||||
statusId={statusId}
|
||||
dataVoting={dataVoting as any}
|
||||
listStatus={listStatus as any}
|
||||
/>
|
||||
<Vote_Status />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
15
src/app/lib/api_user_router/route_api_notifikasi.ts
Normal file
15
src/app/lib/api_user_router/route_api_notifikasi.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { ICategoryapp } from "@/app_modules/notifikasi/model/interface";
|
||||
|
||||
export const API_RouteNotifikasi = {
|
||||
get_all_by_category: ({
|
||||
category,
|
||||
page,
|
||||
}: {
|
||||
category: ICategoryapp;
|
||||
page: number;
|
||||
}) => `/api/notifikasi/get-all-by-category?category=${category}&page=${page}`,
|
||||
|
||||
get_master_kategori: () => `/api/notifikasi/master`,
|
||||
|
||||
get_count_by_id: () => `/api/notifikasi/count`,
|
||||
};
|
||||
@@ -13,12 +13,13 @@ export type ITypeStatusNotifikasi =
|
||||
| "Peserta Event"
|
||||
// VOTING
|
||||
| "Voting Masuk"
|
||||
// DONASI
|
||||
// DONASI & INVESTASI
|
||||
| "Berhasil"
|
||||
| "Proses"
|
||||
| "Menunggu"
|
||||
| "Gagal";
|
||||
|
||||
|
||||
/**
|
||||
* @param kategoriApp | "JOB", "VOTING", "EVENT", "DONASI", "INVESTASI", "COLLABORATION", "FORUM"
|
||||
* @type string
|
||||
@@ -42,7 +43,7 @@ export type IRealtimeData = {
|
||||
export const gs_realtimeData = atom<IRealtimeData | null>(null);
|
||||
export const gs_admin_ntf = atom<number>(0);
|
||||
export const gs_user_ntf = atom<number>(0);
|
||||
export const gs_count_ntf = atom<number>(0);
|
||||
export const gs_count_ntf = atom<number | null>(null);
|
||||
|
||||
// job
|
||||
export const gs_adminJob_triggerReview = atom<boolean>(false);
|
||||
@@ -59,3 +60,7 @@ export const gs_votingTiggerBeranda = atom<boolean>(false);
|
||||
// donasi
|
||||
export const gs_adminDonasi_triggerReview = atom<boolean>(false);
|
||||
export const gs_donasiTriggerBeranda = atom<boolean>(false);
|
||||
|
||||
// investasi
|
||||
export const gs_adminInvestasi_triggerReview = atom<boolean>(false);
|
||||
export const gs_investasiTriggerBeranda = atom<boolean>(false);
|
||||
@@ -1,21 +1,28 @@
|
||||
"use server"
|
||||
"use server";
|
||||
|
||||
import _ from "lodash";
|
||||
import { cookies } from "next/headers";
|
||||
import { decrypt } from "../auth/_lib/decrypt";
|
||||
import backendLogger from "@/util/backendLogger";
|
||||
|
||||
export async function newFunGetUserId() {
|
||||
const c = cookies().get(process.env.NEXT_PUBLIC_BASE_SESSION_KEY!);
|
||||
try {
|
||||
const key = process.env.NEXT_PUBLIC_BASE_SESSION_KEY;
|
||||
const c = cookies().get("hipmi-key");
|
||||
|
||||
if (!c || !c?.value || _.isEmpty(c?.value) || _.isUndefined(c?.value)) {
|
||||
if (!c || !c?.value || _.isEmpty(c?.value) || _.isUndefined(c?.value)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const token = c.value;
|
||||
const dataUser = await decrypt({
|
||||
token: token,
|
||||
encodedKey: process.env.NEXT_PUBLIC_BASE_TOKEN_KEY!,
|
||||
});
|
||||
|
||||
return dataUser?.id;
|
||||
} catch (error) {
|
||||
backendLogger.log("Gagal mendapatkan user id", error);
|
||||
return null;
|
||||
}
|
||||
|
||||
const token = c.value;
|
||||
const dataUser = await decrypt({
|
||||
token: token,
|
||||
encodedKey: process.env.NEXT_PUBLIC_BASE_TOKEN_KEY!,
|
||||
});
|
||||
|
||||
return dataUser?.id;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,28 +1,30 @@
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
import { PrismaClient } from "@prisma/client";
|
||||
|
||||
// Singleton PrismaClient untuk pengembangan
|
||||
const globalForPrisma = globalThis as unknown as {
|
||||
__prisma__: PrismaClient | undefined;
|
||||
};
|
||||
|
||||
export const prisma = globalForPrisma.__prisma__ ?? new PrismaClient({
|
||||
// log: process.env.NODE_ENV === 'development' ? ['query', 'info', 'warn', 'error'] : [],
|
||||
});
|
||||
export const prisma =
|
||||
globalForPrisma.__prisma__ ??
|
||||
new PrismaClient({
|
||||
// log: process.env.NODE_ENV === 'development' ? ['query', 'info', 'warn', 'error'] : [],
|
||||
});
|
||||
|
||||
// Gunakan PrismaClient yang sama jika sudah ada
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
if (process.env.NODE_ENV !== "production") {
|
||||
if (!globalForPrisma.__prisma__) {
|
||||
console.log('PrismaClient initialized in development mode');
|
||||
console.log("PrismaClient initialized in development mode");
|
||||
}
|
||||
globalForPrisma.__prisma__ = prisma;
|
||||
}
|
||||
|
||||
process.on('SIGINT', async () => {
|
||||
console.log('Disconnecting PrismaClient...');
|
||||
await prisma.$disconnect();
|
||||
process.on("SIGINT", async () => {
|
||||
console.log("Disconnecting PrismaClient...");
|
||||
await prisma.$disconnect();3
|
||||
process.exit(0);
|
||||
});
|
||||
|
||||
// console.log('==> Test prisma');
|
||||
// console.log("==> Test prisma");
|
||||
|
||||
export default prisma;
|
||||
|
||||
@@ -7,18 +7,18 @@ import {
|
||||
gs_admin_ntf,
|
||||
gs_adminDonasi_triggerReview,
|
||||
gs_adminEvent_triggerReview,
|
||||
gs_adminInvestasi_triggerReview,
|
||||
gs_adminJob_triggerReview,
|
||||
gs_adminVoting_triggerReview,
|
||||
gs_donasiTriggerBeranda,
|
||||
gs_eventTriggerBeranda,
|
||||
gs_investasiTriggerBeranda,
|
||||
gs_jobTiggerBeranda,
|
||||
gs_realtimeData,
|
||||
gs_user_ntf,
|
||||
gs_votingTiggerBeranda,
|
||||
IRealtimeData,
|
||||
} from "./global_state";
|
||||
import { newFunGetUserId } from "./new_fun_user_id";
|
||||
import { useState } from "react";
|
||||
|
||||
// const WIBU_REALTIME_TOKEN: string | undefined =
|
||||
// process.env.NEXT_PUBLIC_WIBU_REALTIME_TOKEN;
|
||||
@@ -28,15 +28,16 @@ export type TypeNotification = {
|
||||
type: "message" | "notification" | "trigger";
|
||||
pushNotificationTo: "ADMIN" | "USER";
|
||||
dataMessage?: IRealtimeData;
|
||||
userLoginId?: string;
|
||||
userId?: string;
|
||||
};
|
||||
|
||||
export default function RealtimeProvider({
|
||||
userId,
|
||||
WIBU_REALTIME_TOKEN,
|
||||
}: {
|
||||
userId: string;
|
||||
WIBU_REALTIME_TOKEN: string;
|
||||
}) {
|
||||
const [userLoginId, setUserLoginId] = useState("");
|
||||
const [dataRealtime, setDataRealtime] = useAtom(gs_realtimeData);
|
||||
const [newAdminNtf, setNewAdminNtf] = useAtom(gs_admin_ntf);
|
||||
const [newUserNtf, setNewUserNtf] = useAtom(gs_user_ntf);
|
||||
@@ -72,15 +73,15 @@ export default function RealtimeProvider({
|
||||
gs_donasiTriggerBeranda
|
||||
);
|
||||
|
||||
async function loadUserId() {
|
||||
const userId = await newFunGetUserId();
|
||||
// INVESTASI
|
||||
const [isAdminInvestasi_TriggerReview, setIsAdminInvestasi_TriggerReview] =
|
||||
useAtom(gs_adminInvestasi_triggerReview);
|
||||
|
||||
setUserLoginId(userId as string);
|
||||
}
|
||||
const [isTriggerInvestasiBeranda, setIsTriggerInvestasiBeranda] = useAtom(
|
||||
gs_investasiTriggerBeranda
|
||||
);
|
||||
|
||||
useShallowEffect(() => {
|
||||
loadUserId();
|
||||
|
||||
try {
|
||||
WibuRealtime.init({
|
||||
project: "hipmi",
|
||||
@@ -97,7 +98,7 @@ export default function RealtimeProvider({
|
||||
if (
|
||||
data.type == "notification" &&
|
||||
data.pushNotificationTo == "USER" &&
|
||||
data.dataMessage?.userId == userLoginId
|
||||
data.dataMessage?.userId == userId
|
||||
) {
|
||||
setNewUserNtf((e) => e + 1);
|
||||
setDataRealtime(data.dataMessage as any);
|
||||
@@ -144,7 +145,7 @@ export default function RealtimeProvider({
|
||||
data.type == "notification" &&
|
||||
data.pushNotificationTo == "USER" &&
|
||||
data.dataMessage?.status == "Peserta Event" &&
|
||||
userLoginId !== data.dataMessage?.userId
|
||||
userId !== data.dataMessage?.userId
|
||||
) {
|
||||
setNewUserNtf((e) => e + 1);
|
||||
}
|
||||
@@ -172,7 +173,7 @@ export default function RealtimeProvider({
|
||||
data.type == "notification" &&
|
||||
data.pushNotificationTo == "USER" &&
|
||||
data.dataMessage?.status == "Voting Masuk" &&
|
||||
userLoginId !== data.dataMessage?.userId
|
||||
userId !== data.dataMessage?.userId
|
||||
) {
|
||||
setNewUserNtf((e) => e + 1);
|
||||
}
|
||||
@@ -200,16 +201,36 @@ export default function RealtimeProvider({
|
||||
// data.type == "notification" &&
|
||||
// data.pushNotificationTo == "ADMIN" &&
|
||||
// data.dataMessage?.status == "Menunggu" &&
|
||||
// userLoginId !== data.dataMessage?.userId
|
||||
// userId !== data.dataMessage?.userId
|
||||
// ) {
|
||||
// console.log("yes");
|
||||
// }
|
||||
|
||||
// }
|
||||
// ---------------------- DONASI ------------------------- //
|
||||
|
||||
// ---------------------- INVESTASI ------------------------- //
|
||||
|
||||
if (
|
||||
data.type == "trigger" &&
|
||||
data.pushNotificationTo == "ADMIN" &&
|
||||
data.dataMessage?.kategoriApp == "INVESTASI"
|
||||
) {
|
||||
setIsAdminInvestasi_TriggerReview(true);
|
||||
}
|
||||
|
||||
if (
|
||||
data.type == "trigger" &&
|
||||
data.pushNotificationTo == "USER" &&
|
||||
data.dataMessage?.kategoriApp == "INVESTASI" &&
|
||||
data.dataMessage.status == "Publish"
|
||||
) {
|
||||
setIsTriggerInvestasiBeranda(true);
|
||||
}
|
||||
|
||||
// ---------------------- INVESTASI ------------------------- //
|
||||
},
|
||||
});
|
||||
} catch (error) {
|
||||
console.log("Error!:", error);
|
||||
console.log("Error Realtime:", error);
|
||||
}
|
||||
}, []);
|
||||
|
||||
|
||||
@@ -5,11 +5,11 @@ import { useShallowEffect } from "@mantine/hooks";
|
||||
import { useRouter } from "next/navigation";
|
||||
|
||||
export default function Page() {
|
||||
const router = useRouter()
|
||||
const router = useRouter();
|
||||
useShallowEffect(() => {
|
||||
setTimeout(() => {
|
||||
// window.location.replace("/dev/home");
|
||||
router.replace("/dev/home");
|
||||
router.replace("/dev/home", { scroll: false });
|
||||
}, 1000);
|
||||
}, []);
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { MainColor } from "@/app_modules/_global/color";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
import Coba_TestLoading from "@/app_modules/zCoba";
|
||||
import {
|
||||
Avatar,
|
||||
Button,
|
||||
@@ -14,97 +12,48 @@ import {
|
||||
import { IconCamera } from "@tabler/icons-react";
|
||||
import { useState } from "react";
|
||||
import { DIRECTORY_ID } from "../lib";
|
||||
import { TokenStorage } from "../lib/token";
|
||||
import { envs } from "@/lib/envs";
|
||||
|
||||
export default function Page() {
|
||||
const [filePP, setFilePP] = useState<File | null>(null);
|
||||
const [imgPP, setImgPP] = useState<any | null>();
|
||||
|
||||
async function onSave() {
|
||||
const body = {
|
||||
file: filePP,
|
||||
dirId: DIRECTORY_ID.profile_foto,
|
||||
};
|
||||
|
||||
const token =
|
||||
"QWERTYUIOPLKJHGFDSAZXCVBNMQAZWSXEDCRFVTGBYHNUJMIKOLPPOIUYTREWQLKJHGFDSAMNBVCXZlghvftyguhijknhbgvcfytguu8okjnhbgvfty7u8oilkjnhgvtygu7u8ojilnkhbgvhujnkhghvjhukjnhb";
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("file", filePP as any);
|
||||
|
||||
const res = await fetch("/api/upload", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
});
|
||||
|
||||
console.log(await res.json());
|
||||
}
|
||||
const [data, setData] = useState({
|
||||
name: "bagas",
|
||||
hobi: [
|
||||
{
|
||||
id: "1",
|
||||
name: "mancing",
|
||||
},
|
||||
{
|
||||
id: "2",
|
||||
name: "game",
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
return (
|
||||
<>
|
||||
<Stack>
|
||||
<Center>
|
||||
{imgPP ? (
|
||||
<Paper shadow="lg" radius={"100%"}>
|
||||
<Avatar
|
||||
color={"cyan"}
|
||||
sx={{
|
||||
borderStyle: "solid",
|
||||
borderColor: "gray",
|
||||
borderWidth: "0.5px",
|
||||
}}
|
||||
src={imgPP ? imgPP : "/aset/global/avatar.png"}
|
||||
size={150}
|
||||
radius={"100%"}
|
||||
/>
|
||||
</Paper>
|
||||
) : (
|
||||
<Paper shadow="lg" radius={"100%"}>
|
||||
<Avatar
|
||||
variant="light"
|
||||
color="blue"
|
||||
size={150}
|
||||
radius={"100%"}
|
||||
sx={{
|
||||
borderStyle: "solid",
|
||||
borderColor: MainColor.darkblue,
|
||||
borderWidth: "0.5px",
|
||||
}}
|
||||
/>
|
||||
</Paper>
|
||||
)}
|
||||
</Center>
|
||||
<Stack align="center" justify="center" h={"100vh"}>
|
||||
<pre>{JSON.stringify(data, null, 2)}</pre>
|
||||
|
||||
<FileButton
|
||||
onChange={async (files: any | null) => {
|
||||
try {
|
||||
const buffer = URL.createObjectURL(
|
||||
new Blob([new Uint8Array(await files.arrayBuffer())])
|
||||
);
|
||||
setImgPP(buffer);
|
||||
setFilePP(files);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
<Button
|
||||
onClick={() => {
|
||||
const newData = [
|
||||
{
|
||||
id: "1",
|
||||
name: "sepedah",
|
||||
},
|
||||
{
|
||||
id: "2",
|
||||
name: "berenang",
|
||||
},
|
||||
];
|
||||
|
||||
setData({
|
||||
...data,
|
||||
hobi: newData,
|
||||
});
|
||||
}}
|
||||
accept="image/png,image/jpeg"
|
||||
>
|
||||
{(props) => (
|
||||
<Button
|
||||
{...props}
|
||||
radius={"xl"}
|
||||
leftIcon={<IconCamera />}
|
||||
bg={MainColor.yellow}
|
||||
color="yellow"
|
||||
c={"black"}
|
||||
>
|
||||
Upload
|
||||
</Button>
|
||||
)}
|
||||
</FileButton>
|
||||
|
||||
<Button onClick={() => onSave()}>Upload</Button>
|
||||
Ganti
|
||||
</Button>
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
|
||||
55
src/app/zCoba/skeleton/page.tsx
Normal file
55
src/app/zCoba/skeleton/page.tsx
Normal file
@@ -0,0 +1,55 @@
|
||||
"use client";
|
||||
|
||||
import { ComponentGlobal_CardStyles } from "@/app_modules/_global/component";
|
||||
import {
|
||||
UIGlobal_LayoutHeaderTamplate,
|
||||
UIGlobal_LayoutTamplate,
|
||||
} from "@/app_modules/_global/ui";
|
||||
import { Center, Grid, Group, Skeleton, Stack } from "@mantine/core";
|
||||
|
||||
export default function Voting_ComponentSkeletonViewPuh() {
|
||||
return (
|
||||
<>
|
||||
<UIGlobal_LayoutTamplate
|
||||
header={<UIGlobal_LayoutHeaderTamplate title="Skeleton Maker" />}
|
||||
>
|
||||
<Stack>
|
||||
<ComponentGlobal_CardStyles marginBottom={"0"}>
|
||||
<Stack spacing={"xl"}>
|
||||
<Grid align="center" gutter={"md"}>
|
||||
<Grid.Col span={"content"}>
|
||||
<Skeleton circle height={40} />
|
||||
</Grid.Col>
|
||||
<Grid.Col span={3}>
|
||||
<Skeleton height={20} w={150} />
|
||||
</Grid.Col>
|
||||
<Grid.Col span={3} offset={3}>
|
||||
<Skeleton height={20} w={150} />
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
</Stack>
|
||||
</ComponentGlobal_CardStyles>
|
||||
|
||||
{/* <ComponentGlobal_CardStyles>
|
||||
<Stack>
|
||||
<Center>
|
||||
<Skeleton h={20} w={"30%"} />
|
||||
</Center>
|
||||
|
||||
<Group position="center" spacing={50}>
|
||||
<Stack align="center">
|
||||
<Skeleton circle height={70} />
|
||||
<Skeleton height={20} w={50} />
|
||||
</Stack>
|
||||
<Stack align="center">
|
||||
<Skeleton circle height={70} />
|
||||
<Skeleton height={20} w={50} />
|
||||
</Stack>
|
||||
</Group>
|
||||
</Stack>
|
||||
</ComponentGlobal_CardStyles> */}
|
||||
</Stack>
|
||||
</UIGlobal_LayoutTamplate>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
"use client";
|
||||
import {
|
||||
gs_admin_ntf,
|
||||
gs_realtimeData,
|
||||
IRealtimeData,
|
||||
} from "@/app/lib/global_state";
|
||||
import { Button, Stack } from "@mantine/core";
|
||||
import { useShallowEffect } from "@mantine/hooks";
|
||||
import { useAtom } from "jotai";
|
||||
import { WibuRealtime } from "wibu-pkg";
|
||||
import { v4 } from "uuid";
|
||||
import { useState } from "react";
|
||||
const angka = 10;
|
||||
export default function Page() {
|
||||
const [dataRealtime, setDataRealtime] = useAtom(gs_realtimeData);
|
||||
const [adminNtf, setAdminNtf] = useAtom(gs_admin_ntf);
|
||||
const [notif, setNotif] = useState(angka);
|
||||
|
||||
useShallowEffect(() => {
|
||||
if (adminNtf) {
|
||||
setNotif((e) => e + 1);
|
||||
}
|
||||
}, [adminNtf]);
|
||||
|
||||
async function onSend() {
|
||||
const newData: IRealtimeData = {
|
||||
appId: v4(),
|
||||
status: "Publish",
|
||||
userId: "user1",
|
||||
pesan: "apa kabar",
|
||||
title: "coba",
|
||||
kategoriApp: "INVESTASI",
|
||||
};
|
||||
|
||||
WibuRealtime.setData({
|
||||
type: "message",
|
||||
pushNotificationTo: "USER",
|
||||
dataMessage: newData,
|
||||
});
|
||||
}
|
||||
|
||||
return (
|
||||
<Stack p={"md"} align="center" justify="center" h={"80vh"}>
|
||||
{notif}
|
||||
<Button
|
||||
onClick={() => {
|
||||
onSend();
|
||||
}}
|
||||
>
|
||||
Dari test 1
|
||||
</Button>
|
||||
</Stack>
|
||||
);
|
||||
}
|
||||
@@ -6,6 +6,7 @@ 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,
|
||||
@@ -24,12 +25,13 @@ export function ComponentGlobal_ButtonUploadFileImage({
|
||||
|
||||
if (files.size > MAX_SIZE) {
|
||||
ComponentGlobal_NotifikasiPeringatan(PemberitahuanMaksimalFile);
|
||||
return;
|
||||
} else {
|
||||
onSetFile(files);
|
||||
onSetImage(buffer);
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
clientLogger.error("Upload error:", error);
|
||||
}
|
||||
}}
|
||||
accept="image/png,image/jpeg"
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
export const MainColor = {
|
||||
black: "#202020",
|
||||
darkblue: "#001D3D",
|
||||
yellow: "#FFC300",
|
||||
yellow: "#E1B525",
|
||||
white: "#D4D0D0",
|
||||
red: "#C74E4E",
|
||||
orange: "#E58958"
|
||||
};
|
||||
|
||||
export const AccentColor = {
|
||||
@@ -10,5 +13,7 @@ export const AccentColor = {
|
||||
blue: "#00447D",
|
||||
softblue: "#007CBA",
|
||||
skyblue: "#00BFFF",
|
||||
yellow: "#FFD60A",
|
||||
yellow: "#E1B525",
|
||||
};
|
||||
//yellow: "#FFC300"
|
||||
//yellow: "#FFD60A"
|
||||
|
||||
@@ -31,7 +31,7 @@ export default function ComponentGlobal_BoxInformation({
|
||||
>
|
||||
* Report
|
||||
</Text>
|
||||
<Text fz={fonsize ? fonsize : 12} c={"white"}>
|
||||
<Text fz={fonsize ? fonsize : 12} c={MainColor.white}>
|
||||
{informasi}
|
||||
</Text>
|
||||
</Stack>
|
||||
@@ -39,7 +39,7 @@ export default function ComponentGlobal_BoxInformation({
|
||||
<Group>
|
||||
<Text fz={fonsize ? fonsize : 12} c={"red"} fw={"bold"}>
|
||||
*{" "}
|
||||
<Text span inherit c={"white"} fw={"normal"}>
|
||||
<Text span inherit c={MainColor.white} fw={"normal"}>
|
||||
{informasi}
|
||||
</Text>
|
||||
</Text>
|
||||
|
||||
@@ -40,11 +40,15 @@ export default function ComponentGlobal_CreateButton({
|
||||
router.push(path);
|
||||
}}
|
||||
>
|
||||
{isLoading ? (
|
||||
{/* PAKE LOADING */}
|
||||
{/* {isLoading ? (
|
||||
<Loader color={AccentColor.blue} size={25} />
|
||||
) : (
|
||||
<IconPencilPlus color="white" />
|
||||
)}
|
||||
)} */}
|
||||
|
||||
{/* GA PAKE LOADING */}
|
||||
<IconPencilPlus color={MainColor.white} />
|
||||
</ActionIcon>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -9,6 +9,7 @@ import ComponentGlobal_Loader from "./loader";
|
||||
import { funGlobal_CheckProfile } from "../fun/get";
|
||||
import { RouterProfile } from "@/app/lib/router_hipmi/router_katalog";
|
||||
import { ComponentGlobal_NotifikasiPeringatan } from "../notif_global";
|
||||
import { MainColor } from "../color";
|
||||
|
||||
type IFontSize = "xs" | "sm" | "md" | "lg" | "xl";
|
||||
export function ComponentGlobal_AvatarAndUsername({
|
||||
@@ -60,6 +61,7 @@ export function ComponentGlobal_AvatarAndUsername({
|
||||
<Grid.Col span={"auto"} style={{ minHeight: 50 }}>
|
||||
<Stack justify="center" h={30}>
|
||||
<Text
|
||||
c={MainColor.white}
|
||||
fw={"bold"}
|
||||
fz={fontSize ? fontSize : "sm"}
|
||||
lineClamp={1}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { ComponentGlobal_CardStyles } from "@/app_modules/_global/component";
|
||||
import { Box } from "@mantine/core";
|
||||
import { MainColor } from "../color";
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -28,6 +29,7 @@ export function ComponentGlobal_BoxUploadImage({
|
||||
height: "100%",
|
||||
borderStyle: "dashed",
|
||||
borderRadius: "5px",
|
||||
borderColor: MainColor.white,
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
|
||||
@@ -1,24 +1,50 @@
|
||||
export async function funGlobal_DeleteFileById({ fileId }: { fileId: string }) {
|
||||
try {
|
||||
const res = await fetch(
|
||||
`https://wibu-storage.wibudev.com/api/files/${fileId}/delete`,
|
||||
{
|
||||
method: "DELETE",
|
||||
headers: {
|
||||
Authorization: `Bearer ${process.env.WS_APIKEY}`,
|
||||
},
|
||||
}
|
||||
);
|
||||
import { clientLogger } from "@/util/clientLogger";
|
||||
|
||||
if (res.ok) {
|
||||
const hasil = await res.json();
|
||||
return { success: true };
|
||||
export async function funGlobal_DeleteFileById({
|
||||
fileId,
|
||||
dirId,
|
||||
}: {
|
||||
fileId: string;
|
||||
dirId?: string;
|
||||
}) {
|
||||
try {
|
||||
const res = await fetch("/api/image/delete", {
|
||||
method: "DELETE",
|
||||
body: JSON.stringify({ fileId, dirId }),
|
||||
});
|
||||
|
||||
const data = await res.json();
|
||||
|
||||
if (data.success) {
|
||||
clientLogger.info(`File ${fileId} deleted successfully`);
|
||||
return { success: true, message: "File berhasil dihapus" };
|
||||
} else {
|
||||
const errorText = await res.json();
|
||||
return { success: false };
|
||||
return { success: false, message: data.message };
|
||||
}
|
||||
} catch (error) {
|
||||
return { success: false };
|
||||
console.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" };
|
||||
// }
|
||||
}
|
||||
|
||||
11
src/app_modules/_global/fun/get/fun_get_directory_name.ts
Normal file
11
src/app_modules/_global/fun/get/fun_get_directory_name.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { DIRECTORY_ID } from "@/app/lib";
|
||||
|
||||
export async function funGetDirectoryNameByValue({
|
||||
value,
|
||||
}: {
|
||||
value?: string | null;
|
||||
}) {
|
||||
if (!value) return null;
|
||||
const object: any = DIRECTORY_ID;
|
||||
return Object.keys(object).find((key) => object[key] === value);
|
||||
}
|
||||
@@ -1,56 +1,36 @@
|
||||
"use server";
|
||||
|
||||
import { prisma } from "@/app/lib";
|
||||
import { ServerEnv } from "@/app/lib/server_env";
|
||||
import { unsealData } from "iron-session";
|
||||
import { jwtVerify } from "jose";
|
||||
import { cookies } from "next/headers";
|
||||
import { decrypt } from "../../../../app/auth/_lib/decrypt";
|
||||
|
||||
export async function funGetUserIdByToken() {
|
||||
const SESSION_KEY = process.env.NEXT_PUBLIC_BASE_SESSION_KEY!;
|
||||
// console.log("SESSION_KEY", SESSION_KEY);
|
||||
const c = cookies().get("hipmi-key");
|
||||
const c = cookies().get(SESSION_KEY);
|
||||
|
||||
const cekUser = await decrypt({
|
||||
token: c?.value as string,
|
||||
encodedKey: process.env.NEXT_PUBLIC_BASE_TOKEN_KEY!,
|
||||
});
|
||||
|
||||
// console.log("userid" , cekUser?.id)
|
||||
|
||||
// const token = JSON.parse(
|
||||
// await unsealData(c?.value as string, {
|
||||
// password: process.env.WIBU_PWD as string,
|
||||
// })
|
||||
// );
|
||||
// return token.id;
|
||||
|
||||
// const token = c?.value;
|
||||
// const cekToken = await prisma.userSession.findFirst({
|
||||
// where: {
|
||||
// token: token,
|
||||
// },
|
||||
// });
|
||||
|
||||
// if (cekToken === null) return null
|
||||
return cekUser?.id;
|
||||
}
|
||||
|
||||
async function decrypt({
|
||||
token,
|
||||
encodedKey,
|
||||
}: {
|
||||
token: string;
|
||||
encodedKey: string;
|
||||
}): Promise<Record<string, any> | null> {
|
||||
try {
|
||||
const enc = new TextEncoder().encode(encodedKey);
|
||||
const { payload } = await jwtVerify(token, enc, {
|
||||
algorithms: ["HS256"],
|
||||
});
|
||||
return (payload.user as Record<string, any>) || null;
|
||||
} catch (error) {
|
||||
console.error("Gagal verifikasi session", error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
// async function decrypt({
|
||||
// token,
|
||||
// encodedKey,
|
||||
// }: {
|
||||
// token: string;
|
||||
// encodedKey: string;
|
||||
// }): Promise<Record<string, any> | null> {
|
||||
// try {
|
||||
// const enc = new TextEncoder().encode(encodedKey);
|
||||
// const { payload } = await jwtVerify(token, enc, {
|
||||
// algorithms: ["HS256"],
|
||||
// });
|
||||
// return (payload.user as Record<string, any>) || null;
|
||||
// } catch (error) {
|
||||
// console.error("Gagal verifikasi session", error);
|
||||
// return null;
|
||||
// }
|
||||
// }
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
import { funGlobal_CheckProfile } from "./fun_check_profile";
|
||||
import { funGetDirectoryNameByValue } from "./fun_get_directory_name";
|
||||
import { funGlobal_getNomorAdmin } from "./fun_get_nomor_admin";
|
||||
import { funGetUserIdByToken } from "./fun_get_user_id_by_token";
|
||||
import { funGlobal_getMasterKategoriApp } from "./fun_master_kategori_app";
|
||||
@@ -8,3 +8,4 @@ export { funGlobal_getMasterKategoriApp };
|
||||
export { funGlobal_getNomorAdmin };
|
||||
export { funGetUserIdByToken };
|
||||
export { funGlobal_CheckProfile };
|
||||
export { funGetDirectoryNameByValue };
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { funGlobal_DeleteFileById } from "./delete/fun_delete_file_by_id";
|
||||
import { funGlobal_UploadToStorage } from "./upload/fun_upload_to_storage";
|
||||
import { funValidasiUploadCreatedFile } from "./upload/fun_validasi_upload_created_file";
|
||||
|
||||
export { funGlobal_UploadToStorage };
|
||||
export { funGlobal_DeleteFileById };
|
||||
export { funValidasiUploadCreatedFile };
|
||||
|
||||
@@ -32,38 +32,20 @@ export async function funGlobal_UploadToStorage({
|
||||
console.error("File terlalu besar");
|
||||
return { success: false, message: "File size exceeds limit" };
|
||||
}
|
||||
|
||||
const controller = new AbortController();
|
||||
const timeoutId = setTimeout(() => controller.abort(), 30000); // Timeout 30 detik
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("file", file);
|
||||
formData.append("dirId", dirId);
|
||||
|
||||
try {
|
||||
const res = await fetch("https://wibu-storage.wibudev.com/api/upload", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
headers: {
|
||||
Authorization: `Bearer ${Env_WS_APIKEY}`,
|
||||
},
|
||||
signal: controller.signal,
|
||||
});
|
||||
const upload = await fetch("/api/image/upload", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
});
|
||||
|
||||
clearTimeout(timeoutId); // Bersihkan timeout jika selesai tepat waktu
|
||||
const res = await upload.json();
|
||||
|
||||
if (res.ok) {
|
||||
const dataRes = await res.json();
|
||||
return { success: true, data: dataRes.data };
|
||||
} else {
|
||||
const errorText = await res.text();
|
||||
console.error("Error:", errorText);
|
||||
return { success: false, message: errorText };
|
||||
}
|
||||
} catch (error) {
|
||||
clearTimeout(timeoutId); //
|
||||
|
||||
console.error("Error:", error);
|
||||
return { success: false, message: "An unexpected error occurred" };
|
||||
if (upload.ok) {
|
||||
return { success: true, data: res.data, message: res.message };
|
||||
} else {
|
||||
return { success: false, data: {}, message: res.message };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
import { clientLogger } from "@/util/clientLogger";
|
||||
import { MAX_SIZE } from "../../lib";
|
||||
import { PemberitahuanMaksimalFile } from "../../lib/max_size";
|
||||
import { ComponentGlobal_NotifikasiPeringatan } from "../../notif_global";
|
||||
import { funGlobal_DeleteFileById } from "../delete/fun_delete_file_by_id";
|
||||
import { funGlobal_UploadToStorage } from "./fun_upload_to_storage";
|
||||
|
||||
export async function funValidasiUploadCreatedFile({
|
||||
files,
|
||||
dirId,
|
||||
fileId,
|
||||
onSetFileId,
|
||||
onSetImageBuffer,
|
||||
}: {
|
||||
files: any | null;
|
||||
dirId: string;
|
||||
fileId: string;
|
||||
onSetFileId: (val: string) => void;
|
||||
onSetImageBuffer: (val: any | null) => void;
|
||||
}) {
|
||||
try {
|
||||
const buffer = URL.createObjectURL(
|
||||
new Blob([new Uint8Array(await files.arrayBuffer())])
|
||||
);
|
||||
|
||||
if (files.size > MAX_SIZE) {
|
||||
ComponentGlobal_NotifikasiPeringatan(PemberitahuanMaksimalFile);
|
||||
onSetImageBuffer(null);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (fileId != "") {
|
||||
const deleteFotoProfile = await funGlobal_DeleteFileById({
|
||||
fileId: fileId,
|
||||
dirId: dirId,
|
||||
});
|
||||
|
||||
if (!deleteFotoProfile.success) {
|
||||
console.log(
|
||||
`Client failed delete ${dirId}:` + deleteFotoProfile.message
|
||||
);
|
||||
onSetImageBuffer(null);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (deleteFotoProfile.success) {
|
||||
onSetFileId("");
|
||||
onSetImageBuffer(null);
|
||||
|
||||
const uploadPhoto = await funGlobal_UploadToStorage({
|
||||
file: files,
|
||||
dirId: dirId,
|
||||
});
|
||||
|
||||
if (!uploadPhoto.success) {
|
||||
clientLogger.error(
|
||||
`Client failed upload ${dirId}:` + uploadPhoto.message
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (uploadPhoto.success) {
|
||||
clientLogger.info(`Client success upload ${dirId}`);
|
||||
onSetFileId("");
|
||||
onSetImageBuffer(buffer);
|
||||
|
||||
return true;
|
||||
} else {
|
||||
clientLogger.error("Client failed upload foto:", uploadPhoto.message);
|
||||
ComponentGlobal_NotifikasiPeringatan(`Gagal upload ${dirId}`);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const uploadPhoto = await funGlobal_UploadToStorage({
|
||||
file: files,
|
||||
dirId: dirId,
|
||||
});
|
||||
|
||||
if (!uploadPhoto.success) {
|
||||
clientLogger.error(
|
||||
`Client failed upload ${dirId}:` + uploadPhoto.message
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (uploadPhoto.success) {
|
||||
clientLogger.info(`Client success upload ${dirId}`);
|
||||
onSetFileId("");
|
||||
onSetImageBuffer(buffer);
|
||||
|
||||
return true;
|
||||
} else {
|
||||
clientLogger.error("Client failed upload foto:", uploadPhoto.message);
|
||||
ComponentGlobal_NotifikasiPeringatan(`Gagal upload ${dirId}`);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
import { IconX } from "@tabler/icons-react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { AccentColor } from "../color/color_pallet";
|
||||
import { AccentColor, MainColor } from "../color/color_pallet";
|
||||
import ComponentGlobal_Loader from "../component/loader";
|
||||
|
||||
interface MODEL_DRAWER {
|
||||
@@ -72,7 +72,7 @@ export default function UIGlobal_Drawer({
|
||||
<Stack spacing={"xs"}>
|
||||
<Group position="right">
|
||||
<ActionIcon onClick={close} variant="transparent">
|
||||
<IconX color="white" />
|
||||
<IconX color={MainColor.white} />
|
||||
</ActionIcon>
|
||||
</Group>
|
||||
<SimpleGrid cols={component.length < 4 ? component.length : 4}>
|
||||
@@ -100,7 +100,7 @@ export default function UIGlobal_Drawer({
|
||||
{e?.icon}
|
||||
|
||||
</ActionIcon>
|
||||
<Text fz={"sm"} align="center" color="white">
|
||||
<Text fz={"sm"} align="center" color={MainColor.white}>
|
||||
{e?.name}
|
||||
</Text>
|
||||
</Stack>
|
||||
|
||||
@@ -67,7 +67,7 @@ export default function UIGlobal_LayoutHeaderTamplate({
|
||||
customButtonLeft
|
||||
) : (
|
||||
<ActionIcon
|
||||
c={"white"}
|
||||
c={MainColor.white}
|
||||
variant="transparent"
|
||||
radius={"xl"}
|
||||
onClick={() => {
|
||||
|
||||
@@ -10,18 +10,16 @@ import {
|
||||
Image,
|
||||
rem,
|
||||
ScrollArea,
|
||||
Skeleton,
|
||||
Text,
|
||||
Title,
|
||||
Skeleton
|
||||
} from "@mantine/core";
|
||||
import { useShallowEffect } from "@mantine/hooks";
|
||||
import { IconX } from "@tabler/icons-react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { MainColor } from "../color";
|
||||
import ComponentGlobal_Loader from "../component/loader";
|
||||
import UIGlobal_LayoutHeaderTamplate from "./ui_header_tamplate";
|
||||
import { UIHeader } from "./ui_layout_tamplate";
|
||||
import ComponentGlobal_Loader from "../component/loader";
|
||||
|
||||
export function UIGlobal_ImagePreview({ fileId }: { fileId: string }) {
|
||||
const router = useRouter();
|
||||
|
||||
@@ -33,7 +33,7 @@ export default function UIGlobal_Modal({
|
||||
}}
|
||||
>
|
||||
<Stack>
|
||||
<Title order={6} color="white" align="center">
|
||||
<Title order={6} color={MainColor.white} align="center">
|
||||
{title}
|
||||
</Title>
|
||||
<Group position="center">
|
||||
|
||||
@@ -2,16 +2,17 @@
|
||||
|
||||
import { Loader, Stack, ThemeIcon } from "@mantine/core";
|
||||
import UIGlobal_LayoutDefault from "./ui_layout_default";
|
||||
import { MainColor } from "../color";
|
||||
|
||||
export default function UIGlobal_SplashScreen({ icon }: { icon: any }) {
|
||||
return (
|
||||
<>
|
||||
<UIGlobal_LayoutDefault>
|
||||
<Stack h={"90vh"} align="center" justify="center" spacing={"xl"}>
|
||||
<ThemeIcon variant="transparent" size={300} c="white">
|
||||
<ThemeIcon variant="transparent" size={300} c={MainColor.white}>
|
||||
{icon}
|
||||
</ThemeIcon>
|
||||
<Loader variant="dots" color="white" />
|
||||
<Loader variant="dots" color={MainColor.white} />
|
||||
</Stack>
|
||||
</UIGlobal_LayoutDefault>
|
||||
</>
|
||||
|
||||
@@ -1,15 +1,22 @@
|
||||
"use client";
|
||||
|
||||
import { ComponentAdminGlobal_NotifikasiBerhasil } from "@/app_modules/admin/_admin_global/admin_notifikasi/notifikasi_berhasil";
|
||||
import { ComponentAdminGlobal_NotifikasiGagal } from "@/app_modules/admin/_admin_global/admin_notifikasi/notifikasi_gagal";
|
||||
import { Button, Stack } from "@mantine/core";
|
||||
import { IconBan, IconCircleCheck } from "@tabler/icons-react";
|
||||
import { useState } from "react";
|
||||
import {
|
||||
adminInvestasi_funAcceptTransaksiById,
|
||||
adminInvestasi_funGetAllTransaksiById,
|
||||
adminInvestasi_funRejectInvoiceById,
|
||||
} from "../../fun";
|
||||
import { ComponentAdminGlobal_NotifikasiBerhasil } from "@/app_modules/admin/_admin_global/admin_notifikasi/notifikasi_berhasil";
|
||||
import { ComponentAdminGlobal_NotifikasiGagal } from "@/app_modules/admin/_admin_global/admin_notifikasi/notifikasi_gagal";
|
||||
import { useState } from "react";
|
||||
import { IconCircleCheck } from "@tabler/icons-react";
|
||||
import { IconBan } from "@tabler/icons-react";
|
||||
import { MODEL_INVOICE_INVESTASI } from "@/app_modules/investasi/_lib/interface";
|
||||
import { clientLogger } from "@/util/clientLogger";
|
||||
import { IRealtimeData } from "@/app/lib/global_state";
|
||||
import {
|
||||
notifikasiToAdmin_funCreate,
|
||||
notifikasiToUser_funCreate,
|
||||
} from "@/app_modules/notifikasi/fun";
|
||||
import { WibuRealtime } from "wibu-pkg";
|
||||
|
||||
export function AdminInvestasi_ComponentButtonKonfirmasiTransaksi({
|
||||
invoiceId,
|
||||
@@ -26,47 +33,112 @@ export function AdminInvestasi_ComponentButtonKonfirmasiTransaksi({
|
||||
const [isLoadingReject, setLoadingReject] = useState(false);
|
||||
|
||||
async function onReject() {
|
||||
const res = await adminInvestasi_funRejectInvoiceById({ invoiceId });
|
||||
if (res.status == 200) {
|
||||
try {
|
||||
const dataTransaksi = await adminInvestasi_funGetAllTransaksiById({
|
||||
investasiId,
|
||||
page: 1,
|
||||
try {
|
||||
setLoadingReject(true);
|
||||
|
||||
const res = await adminInvestasi_funRejectInvoiceById({ invoiceId });
|
||||
if (res.status == 200) {
|
||||
const notifikasiInvestor: IRealtimeData = {
|
||||
appId: invoiceId as string,
|
||||
userId: res.userId as string,
|
||||
status: res.statusName as any,
|
||||
pesan: "Transaksi anda gagal, coba hubungi admin",
|
||||
kategoriApp: "INVESTASI",
|
||||
title: "Transaksi Gagal",
|
||||
};
|
||||
|
||||
const notifToInvestor = await notifikasiToUser_funCreate({
|
||||
data: notifikasiInvestor as any,
|
||||
});
|
||||
onLoadData(dataTransaksi);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
} finally {
|
||||
ComponentAdminGlobal_NotifikasiBerhasil(res.message);
|
||||
setLoadingReject(true);
|
||||
|
||||
if (notifToInvestor.status === 201) {
|
||||
WibuRealtime.setData({
|
||||
type: "notification",
|
||||
pushNotificationTo: "USER",
|
||||
dataMessage: notifikasiInvestor,
|
||||
});
|
||||
|
||||
const dataTransaksi = await adminInvestasi_funGetAllTransaksiById({
|
||||
investasiId,
|
||||
page: 1,
|
||||
});
|
||||
onLoadData(dataTransaksi);
|
||||
|
||||
ComponentAdminGlobal_NotifikasiBerhasil(res.message);
|
||||
}
|
||||
} else {
|
||||
ComponentAdminGlobal_NotifikasiGagal(res.message);
|
||||
}
|
||||
} else {
|
||||
ComponentAdminGlobal_NotifikasiGagal(res.message);
|
||||
} catch (error) {
|
||||
clientLogger.error("Error rejected investasi:", error);
|
||||
} finally {
|
||||
setLoadingReject(false);
|
||||
}
|
||||
}
|
||||
|
||||
async function onAccept() {
|
||||
const res = await adminInvestasi_funAcceptTransaksiById({
|
||||
invoiceId,
|
||||
investasiId,
|
||||
lembarTerbeli,
|
||||
});
|
||||
try {
|
||||
setLoadingAccept(true);
|
||||
const res = await adminInvestasi_funAcceptTransaksiById({
|
||||
invoiceId,
|
||||
investasiId,
|
||||
lembarTerbeli,
|
||||
});
|
||||
|
||||
if (res.status == 200) {
|
||||
const dataNotifikasi: IRealtimeData = {
|
||||
appId: investasiId,
|
||||
status: res.data?.dataInvestasi?.MasterStatusInvestasi?.name as any,
|
||||
userId: res.data?.dataInvestasi.authorId as string,
|
||||
pesan: "Cek investasi anda, Anda memiliki investor baru",
|
||||
kategoriApp: "INVESTASI",
|
||||
title: "Investor baru",
|
||||
};
|
||||
|
||||
const notif = await notifikasiToUser_funCreate({
|
||||
data: dataNotifikasi as any,
|
||||
});
|
||||
|
||||
if (notif.status === 201) {
|
||||
WibuRealtime.setData({
|
||||
type: "notification",
|
||||
pushNotificationTo: "USER",
|
||||
dataMessage: dataNotifikasi,
|
||||
});
|
||||
}
|
||||
|
||||
const notifikasiInvestor: IRealtimeData = {
|
||||
appId: res.data?.dataInvestor.id as string,
|
||||
status: "Berhasil",
|
||||
userId: res.data?.dataInvestor.authorId as string,
|
||||
pesan: "Selamat, anda telah menjadi investor baru",
|
||||
kategoriApp: "INVESTASI",
|
||||
title: "Investasi berhasil",
|
||||
};
|
||||
|
||||
const notifToInvestor = await notifikasiToUser_funCreate({
|
||||
data: notifikasiInvestor as any,
|
||||
});
|
||||
|
||||
if (notifToInvestor.status === 201) {
|
||||
WibuRealtime.setData({
|
||||
type: "notification",
|
||||
pushNotificationTo: "USER",
|
||||
dataMessage: notifikasiInvestor,
|
||||
});
|
||||
}
|
||||
|
||||
if (res.status == 200) {
|
||||
try {
|
||||
const dataTransaksi = await adminInvestasi_funGetAllTransaksiById({
|
||||
investasiId,
|
||||
page: 1,
|
||||
});
|
||||
onLoadData(dataTransaksi);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
} finally {
|
||||
ComponentAdminGlobal_NotifikasiBerhasil(res.message);
|
||||
setLoadingAccept(true);
|
||||
}
|
||||
} else {
|
||||
ComponentAdminGlobal_NotifikasiGagal(res.message);
|
||||
} catch (error) {
|
||||
clientLogger.error("Error accept invoice", error);
|
||||
} finally {
|
||||
setLoadingAccept(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,6 @@ export function AdminInvestasi_DetailPublish({
|
||||
investasiId={investasiId}
|
||||
/>
|
||||
) : null}
|
||||
{/* {selectPage == "3" ? <AdminInvestasi_ViewDaftarInvestor /> : null} */}
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -1,18 +1,14 @@
|
||||
"use client";
|
||||
|
||||
import { IRealtimeData } from "@/app/lib/global_state";
|
||||
import { MODEL_INVESTASI } from "@/app_modules/investasi/_lib/interface";
|
||||
import getOneInvestasiById from "@/app_modules/investasi/fun/get_one_investasi_by_id";
|
||||
import mqtt_client from "@/util/mqtt_client";
|
||||
import {
|
||||
Button,
|
||||
Group,
|
||||
SimpleGrid,
|
||||
Stack
|
||||
} from "@mantine/core";
|
||||
import { Button, Group, SimpleGrid, Stack } from "@mantine/core";
|
||||
import { useShallowEffect } from "@mantine/hooks";
|
||||
import _ from "lodash";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { WibuRealtime } from "wibu-pkg";
|
||||
import { Admin_ComponentModalReport } from "../../_admin_global/_component";
|
||||
import { ComponentAdminGlobal_NotifikasiBerhasil } from "../../_admin_global/admin_notifikasi/notifikasi_berhasil";
|
||||
import { ComponentAdminGlobal_NotifikasiGagal } from "../../_admin_global/admin_notifikasi/notifikasi_gagal";
|
||||
@@ -60,24 +56,25 @@ export default function AdminInvestasi_DetailReview({
|
||||
if (res.status === 200) {
|
||||
setIsLoadingReject(true);
|
||||
|
||||
const dataNotif = {
|
||||
appId: res.data?.id,
|
||||
userId: res.data?.authorId,
|
||||
pesan: res.data?.title,
|
||||
status: res.data?.MasterStatusInvestasi?.name,
|
||||
const dataNotifikasi: IRealtimeData = {
|
||||
appId: res.data?.id as string,
|
||||
userId: res.data?.authorId as string,
|
||||
pesan: res.data?.title as string,
|
||||
status: res.data?.MasterStatusInvestasi?.name as any,
|
||||
kategoriApp: "INVESTASI",
|
||||
title: "Investasi anda di tolak !",
|
||||
};
|
||||
|
||||
const notif = await adminNotifikasi_funCreateToUser({
|
||||
data: dataNotif as any,
|
||||
data: dataNotifikasi as any,
|
||||
});
|
||||
|
||||
if (notif.status === 201) {
|
||||
mqtt_client.publish(
|
||||
"USER",
|
||||
JSON.stringify({ userId: res?.data?.authorId, count: 1 })
|
||||
);
|
||||
WibuRealtime.setData({
|
||||
type: "notification",
|
||||
pushNotificationTo: "USER",
|
||||
dataMessage: dataNotifikasi,
|
||||
});
|
||||
}
|
||||
|
||||
const loadData = await getOneInvestasiById(data.id);
|
||||
@@ -100,8 +97,8 @@ export default function AdminInvestasi_DetailReview({
|
||||
progesInvestasiId: "1",
|
||||
});
|
||||
if (res.status === 200) {
|
||||
const dataNotif = {
|
||||
appId: res.data?.id,
|
||||
const dataNotifikasi: IRealtimeData = {
|
||||
appId: res.data?.id as string,
|
||||
userId: res.data?.authorId as any,
|
||||
pesan: res.data?.title as any,
|
||||
status: res.data?.MasterStatusInvestasi?.name as any,
|
||||
@@ -110,19 +107,21 @@ export default function AdminInvestasi_DetailReview({
|
||||
};
|
||||
|
||||
const notif = await adminNotifikasi_funCreateToUser({
|
||||
data: dataNotif as any,
|
||||
data: dataNotifikasi as any,
|
||||
});
|
||||
|
||||
if (notif.status === 201) {
|
||||
mqtt_client.publish(
|
||||
"USER",
|
||||
JSON.stringify({ userId: res?.data?.authorId, count: 1 })
|
||||
);
|
||||
WibuRealtime.setData({
|
||||
type: "notification",
|
||||
pushNotificationTo: "USER",
|
||||
dataMessage: dataNotifikasi,
|
||||
});
|
||||
|
||||
mqtt_client.publish(
|
||||
"Beranda_Investasi",
|
||||
JSON.stringify({ update: true })
|
||||
);
|
||||
WibuRealtime.setData({
|
||||
type: "trigger",
|
||||
pushNotificationTo: "USER",
|
||||
dataMessage: dataNotifikasi,
|
||||
});
|
||||
|
||||
const loadData = await getOneInvestasiById(data.id);
|
||||
setData(loadData as any);
|
||||
@@ -216,8 +215,6 @@ export default function AdminInvestasi_DetailReview({
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
|
||||
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -60,15 +60,26 @@ export async function adminInvestasi_funAcceptTransaksiById({
|
||||
lembarTerbeli: resultLembarTerbeli.toString(),
|
||||
progress: resultProgres,
|
||||
},
|
||||
include: {
|
||||
MasterStatusInvestasi: true,
|
||||
},
|
||||
});
|
||||
|
||||
if (!updateInvestasi)
|
||||
return { status: 400, message: "Gagal Update Data Investasi" };
|
||||
|
||||
const newData = updateInvestasi;
|
||||
|
||||
const allData = {
|
||||
dataInvestasi: updateInvestasi,
|
||||
dataInvestor: updt,
|
||||
};
|
||||
|
||||
revalidatePath(RouterAdminInvestasi.detail_publish);
|
||||
return {
|
||||
status: 200,
|
||||
message: "Update Berhasil",
|
||||
data: allData,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,9 +9,6 @@ export async function adminInvestasi_funRejectInvoiceById({
|
||||
}: {
|
||||
invoiceId: string;
|
||||
}) {
|
||||
|
||||
|
||||
|
||||
const updt = await prisma.investasi_Invoice.update({
|
||||
where: {
|
||||
id: invoiceId,
|
||||
@@ -19,12 +16,19 @@ export async function adminInvestasi_funRejectInvoiceById({
|
||||
data: {
|
||||
statusInvoiceId: "4",
|
||||
},
|
||||
select: {
|
||||
StatusInvoice: true,
|
||||
authorId: true,
|
||||
},
|
||||
});
|
||||
|
||||
if (!updt) return { status: 400, message: "Gagal Update" };
|
||||
if (!updt)
|
||||
return { status: 400, message: "Gagal Melakukan Reject", statusName: "" , userId: ""};
|
||||
revalidatePath(RouterAdminInvestasi.detail_publish);
|
||||
return {
|
||||
status: 200,
|
||||
message: "Update Berhasil",
|
||||
message: "Reject Berhasil",
|
||||
statusName: updt.StatusInvoice?.name,
|
||||
userId: updt.authorId,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,33 +1,33 @@
|
||||
"use client";
|
||||
import { RouterAdminInvestasi } from "@/app/lib/router_admin/router_admin_investasi";
|
||||
import { gs_adminInvestasi_triggerReview } from "@/app/lib/global_state";
|
||||
import { RouterAdminInvestasi_OLD } from "@/app/lib/router_hipmi/router_admin";
|
||||
import { AccentColor } from "@/app_modules/_global/color";
|
||||
import { MODEL_INVESTASI } from "@/app_modules/investasi/_lib/interface";
|
||||
import {
|
||||
Badge,
|
||||
ActionIcon,
|
||||
Box,
|
||||
ScrollArea,
|
||||
Table,
|
||||
Tooltip,
|
||||
Stack,
|
||||
Group,
|
||||
Avatar,
|
||||
Text,
|
||||
Center,
|
||||
Affix,
|
||||
Button,
|
||||
Center,
|
||||
Group,
|
||||
Pagination,
|
||||
Paper,
|
||||
rem,
|
||||
ScrollArea,
|
||||
Stack,
|
||||
Table,
|
||||
Text,
|
||||
TextInput,
|
||||
Title,
|
||||
} from "@mantine/core";
|
||||
import { IconChevronLeft, IconEdit, IconSearch } from "@tabler/icons-react";
|
||||
import { useShallowEffect } from "@mantine/hooks";
|
||||
import { IconRefresh, IconSearch } from "@tabler/icons-react";
|
||||
import { useAtom } from "jotai";
|
||||
import _ from "lodash";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import ComponentAdminGlobal_HeaderTamplate from "../../_admin_global/header_tamplate";
|
||||
import { adminInvestasi_funGetAllReview } from "../fun/get/get_all_review";
|
||||
import _ from "lodash";
|
||||
import ComponentAdminGlobal_IsEmptyData from "../../_admin_global/is_empty_data";
|
||||
import ComponentAdminGlobal_TampilanRupiahDonasi from "../../_admin_global/tampilan_rupiah";
|
||||
import { adminInvestasi_funGetAllReview } from "../fun/get/get_all_review";
|
||||
|
||||
export default function Admin_TableReviewInvestasi({
|
||||
dataInvestsi,
|
||||
@@ -53,6 +53,28 @@ function TableView({ listData }: { listData: any }) {
|
||||
const [isLoading, setLoading] = useState(false);
|
||||
const [idData, setIdData] = useState("");
|
||||
|
||||
// Realtime
|
||||
const [isAdminInvestasi_TriggerReview, setIsAdminInvestasi_TriggerReview] =
|
||||
useAtom(gs_adminInvestasi_triggerReview);
|
||||
const [isShowReload, setIsShowReload] = useState(false);
|
||||
const [isLoadingReload, setLoadingReload] = useState(false);
|
||||
|
||||
useShallowEffect(() => {
|
||||
if (isAdminInvestasi_TriggerReview) {
|
||||
setIsShowReload(false);
|
||||
setIsAdminInvestasi_TriggerReview(false)
|
||||
}
|
||||
}, [isAdminInvestasi_TriggerReview]);
|
||||
|
||||
async function onLoadData() {
|
||||
const loadData = await adminInvestasi_funGetAllReview({ page: 1 });
|
||||
setData(loadData.data as any);
|
||||
setNPage(loadData.nPage);
|
||||
setLoadingReload(false);
|
||||
setIsShowReload(false);
|
||||
setIsAdminInvestasi_TriggerReview(false);
|
||||
}
|
||||
|
||||
async function onSearch(s: string) {
|
||||
setSearch(s);
|
||||
setActivePage(1);
|
||||
@@ -151,6 +173,30 @@ function TableView({ listData }: { listData: any }) {
|
||||
<ComponentAdminGlobal_IsEmptyData />
|
||||
) : (
|
||||
<Paper p={"md"} withBorder shadow="lg" h={"80vh"}>
|
||||
{isShowReload && (
|
||||
<Paper bg={"red"} w={"50%"}>
|
||||
<Affix position={{ top: rem(200) }} w={"100%"}>
|
||||
<Center>
|
||||
<Button
|
||||
style={{
|
||||
transition: "0.5s",
|
||||
border: `1px solid ${AccentColor.skyblue}`,
|
||||
}}
|
||||
bg={AccentColor.blue}
|
||||
loaderPosition="center"
|
||||
loading={isLoadingReload}
|
||||
radius={"xl"}
|
||||
opacity={0.8}
|
||||
onClick={() => onLoadData()}
|
||||
leftIcon={<IconRefresh />}
|
||||
>
|
||||
Update Data
|
||||
</Button>
|
||||
</Center>
|
||||
</Affix>
|
||||
</Paper>
|
||||
)}
|
||||
|
||||
<ScrollArea w={"100%"} h={"90%"} offsetScrollbars>
|
||||
<Table
|
||||
verticalSpacing={"md"}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user