Compare commits
52 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0eb31073b7 | |||
| d33296d23b | |||
| f7d05783c7 | |||
| 0f4abea990 | |||
| a03c1fa575 | |||
| fe457cd2d4 | |||
| 73cbf3640a | |||
| dc6fa562cc | |||
| 4fd7bb4a17 | |||
| b2305a35a6 | |||
| cbfd105134 | |||
| 3e6c94d77f | |||
| a6c9182a01 | |||
| 453aa0a4ec | |||
| fe37cce13e | |||
| ee05d0c71f | |||
| f8319b9ab5 | |||
| 2c1d74973b | |||
| 04c2e0d580 | |||
|
|
6dba07baac | ||
| b76c7a4b1c | |||
| 240f6eb7c2 | |||
| f64ae42825 | |||
| df5d1aad48 | |||
| 82e69309a1 | |||
| a6588818b5 | |||
| f65f9b7834 | |||
| 36b9248ed7 | |||
| a2c5f053da | |||
| bedc0cc88b | |||
| a9fbd544e5 | |||
| 9afd741d4f | |||
| 817919f8f7 | |||
| 90031e23ef | |||
| 596ebd2ff4 | |||
| aa700523ca | |||
| 236ab4d4a4 | |||
| eaa7692359 | |||
| d51ce346e6 | |||
| 91f4bb6c9e | |||
| 1fe0001994 | |||
| b82a283731 | |||
| 6d7d0fd07e | |||
| bc80bb3441 | |||
| 8ab94b9c86 | |||
| 6e37b18e42 | |||
| a6db03d0b4 | |||
| c550a4e922 | |||
| 2431a3fa3e | |||
| 1ed0da8c7d | |||
| e15a5d796d | |||
| 836ebfaef0 |
56
.env.example
Normal file
56
.env.example
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
# ==============================
|
||||||
|
# Database
|
||||||
|
# ==============================
|
||||||
|
# Connection pool settings untuk mencegah connection exhaustion:
|
||||||
|
# - connection_limit=10: Maksimal 10 koneksi per Prisma Client instance
|
||||||
|
# - pool_timeout=20: Timeout menunggu koneksi tersedia (detik)
|
||||||
|
# - connect_timeout=10: Timeout untuk membuat koneksi baru (detik)
|
||||||
|
DATABASE_URL="postgresql://user:password@localhost:5432/dbname?connection_limit=10&pool_timeout=20&connect_timeout=10"
|
||||||
|
|
||||||
|
# ==============================
|
||||||
|
# Auth / Session
|
||||||
|
# ==============================
|
||||||
|
WIBU_PWD="your_wibu_password"
|
||||||
|
NEXT_PUBLIC_BASE_TOKEN_KEY="your_token_key"
|
||||||
|
NEXT_PUBLIC_BASE_SESSION_KEY="your_session_key"
|
||||||
|
|
||||||
|
# ==============================
|
||||||
|
# Payment Gateway (Midtrans)
|
||||||
|
# ==============================
|
||||||
|
Client_KEY="your_midtrans_client_key"
|
||||||
|
Server_KEY="your_midtrans_server_key"
|
||||||
|
|
||||||
|
# ==============================
|
||||||
|
# Maps
|
||||||
|
# ==============================
|
||||||
|
MAPBOX_TOKEN="your_mapbox_token"
|
||||||
|
|
||||||
|
# ==============================
|
||||||
|
# Realtime (WebSocket)
|
||||||
|
# ==============================
|
||||||
|
WS_APIKEY="your_ws_api_key"
|
||||||
|
NEXT_PUBLIC_WIBU_REALTIME_TOKEN="your_realtime_token"
|
||||||
|
|
||||||
|
# ==============================
|
||||||
|
# Email (Resend)
|
||||||
|
# ==============================
|
||||||
|
RESEND_APIKEY="your_resend_api_key"
|
||||||
|
|
||||||
|
# ==============================
|
||||||
|
# WhatsApp
|
||||||
|
# ==============================
|
||||||
|
WA_SERVER_TOKEN="your_wa_server_token"
|
||||||
|
|
||||||
|
# ==============================
|
||||||
|
# Firebase Admin (Push Notification)
|
||||||
|
# ==============================
|
||||||
|
FIREBASE_ADMIN_PROJECT_ID="your_firebase_project_id"
|
||||||
|
FIREBASE_ADMIN_CLIENT_EMAIL="your_firebase_client_email@project.iam.gserviceaccount.com"
|
||||||
|
# Private key: salin dari service account JSON, ganti newline dengan \n
|
||||||
|
FIREBASE_ADMIN_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\nYOUR_PRIVATE_KEY_HERE\n-----END PRIVATE KEY-----\n"
|
||||||
|
|
||||||
|
# ==============================
|
||||||
|
# App
|
||||||
|
# ==============================
|
||||||
|
NEXT_PUBLIC_API_URL="http://localhost:3000"
|
||||||
|
LOG_LEVEL="info"
|
||||||
72
.github/workflows/publish.yml
vendored
Normal file
72
.github/workflows/publish.yml
vendored
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
name: Publish Docker to GHCR
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
environment:
|
||||||
|
description: "Target environment"
|
||||||
|
required: true
|
||||||
|
type: choice
|
||||||
|
options:
|
||||||
|
- production
|
||||||
|
- staging
|
||||||
|
tag:
|
||||||
|
description: "Image tag (e.g. v1.0.0)"
|
||||||
|
required: true
|
||||||
|
|
||||||
|
env:
|
||||||
|
REGISTRY: ghcr.io
|
||||||
|
IMAGE_NAME: ${{ github.repository }}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
publish:
|
||||||
|
name: Build & Push to GHCR (${{ github.event.inputs.environment }})
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
packages: write
|
||||||
|
steps:
|
||||||
|
- name: Free disk space
|
||||||
|
run: |
|
||||||
|
sudo rm -rf /usr/share/dotnet
|
||||||
|
sudo rm -rf /usr/local/lib/android
|
||||||
|
sudo rm -rf /opt/ghc
|
||||||
|
sudo rm -rf /opt/hostedtoolcache/CodeQL
|
||||||
|
sudo docker image prune --all --force
|
||||||
|
df -h
|
||||||
|
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v3
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Log in to GitHub Container Registry
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: ${{ env.REGISTRY }}
|
||||||
|
username: ${{ github.actor }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Generate image metadata
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@v5
|
||||||
|
with:
|
||||||
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||||
|
tags: |
|
||||||
|
type=raw,value=${{ github.event.inputs.environment }}-${{ github.event.inputs.tag }}
|
||||||
|
type=raw,value=${{ github.event.inputs.environment }}-latest
|
||||||
|
|
||||||
|
- name: Build and push Docker image
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: ./Dockerfile
|
||||||
|
push: true
|
||||||
|
platforms: linux/amd64
|
||||||
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
no-cache: true
|
||||||
31
CHANGELOG.md
31
CHANGELOG.md
@@ -2,6 +2,37 @@
|
|||||||
|
|
||||||
All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
|
All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
|
||||||
|
|
||||||
|
## [1.7.2](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.7.1...v1.7.2) (2026-03-13)
|
||||||
|
|
||||||
|
## [1.7.1](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.7.0...v1.7.1) (2026-03-11)
|
||||||
|
|
||||||
|
## [1.7.0](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.6.9...v1.7.0) (2026-03-10)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* Tambahkan deep link handler untuk event confirmation ([73cbf36](https://wibugit.wibudev.com/wibu/hipmi/commit/73cbf3640ac795995e15448b24408b179d2a46d2))
|
||||||
|
|
||||||
|
## [1.6.9](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.6.8...v1.6.9) (2026-03-06)
|
||||||
|
|
||||||
|
## [1.6.8](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.6.7...v1.6.8) (2026-03-05)
|
||||||
|
|
||||||
|
## [1.6.7](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.6.6...v1.6.7) (2026-03-04)
|
||||||
|
|
||||||
|
## [1.6.6](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.6.5...v1.6.6) (2026-03-03)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* prisma connection exhaustion & firebase lazy init ([6dba07b](https://wibugit.wibudev.com/wibu/hipmi/commit/6dba07baac6a3ef7d264c13e378a905002401e1b))
|
||||||
|
|
||||||
|
## [1.6.5](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.6.4...v1.6.5) (2026-03-03)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* error koneksi Prisma - DATABASE_URL tidak loaded di ([a658881](https://wibugit.wibudev.com/wibu/hipmi/commit/a6588818b5d8018b3a634e0ae0846e309569d370))
|
||||||
|
|
||||||
## [1.6.4](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.6.3...v1.6.4) (2026-03-03)
|
## [1.6.4](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.6.3...v1.6.4) (2026-03-03)
|
||||||
|
|
||||||
## [1.6.3](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.6.2...v1.6.3) (2026-03-03)
|
## [1.6.3](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.6.2...v1.6.3) (2026-03-03)
|
||||||
|
|||||||
68
Dockerfile
Normal file
68
Dockerfile
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
# ==============================
|
||||||
|
# Stage 1: Builder
|
||||||
|
# ==============================
|
||||||
|
FROM oven/bun:1-debian AS builder
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
|
libc6 \
|
||||||
|
git \
|
||||||
|
openssl \
|
||||||
|
ca-certificates \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
COPY package.json bun.lockb* ./
|
||||||
|
|
||||||
|
ENV SHARP_IGNORE_GLOBAL_LIBVIPS=1
|
||||||
|
ENV NEXT_TELEMETRY_DISABLED=1
|
||||||
|
ENV NODE_OPTIONS="--max-old-space-size=4096"
|
||||||
|
|
||||||
|
RUN bun install --frozen-lockfile
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
RUN cp .env.example .env || true
|
||||||
|
|
||||||
|
ENV PRISMA_CLI_BINARY_TARGETS=debian-openssl-3.0.x
|
||||||
|
RUN bunx prisma generate
|
||||||
|
|
||||||
|
RUN bun run build
|
||||||
|
|
||||||
|
# ==============================
|
||||||
|
# Stage 2: Runner (Production)
|
||||||
|
# ==============================
|
||||||
|
FROM oven/bun:1-debian AS runner
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
ENV NODE_ENV=production
|
||||||
|
ENV NEXT_TELEMETRY_DISABLED=1
|
||||||
|
ENV PRISMA_CLI_BINARY_TARGETS=debian-openssl-3.0.x
|
||||||
|
|
||||||
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
|
openssl \
|
||||||
|
ca-certificates \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
RUN groupadd --system --gid 1001 nodejs \
|
||||||
|
&& useradd --system --uid 1001 --gid nodejs nextjs
|
||||||
|
|
||||||
|
COPY --from=builder /app/node_modules ./node_modules
|
||||||
|
COPY --from=builder /app/.next ./.next
|
||||||
|
COPY --from=builder /app/public ./public
|
||||||
|
COPY --from=builder /app/package.json ./package.json
|
||||||
|
COPY --from=builder /app/prisma ./prisma
|
||||||
|
COPY --from=builder /app/src ./src
|
||||||
|
COPY --from=builder /app/next.config.js ./next.config.js
|
||||||
|
COPY --from=builder /app/tsconfig.json ./tsconfig.json
|
||||||
|
|
||||||
|
RUN chown -R nextjs:nodejs /app
|
||||||
|
|
||||||
|
USER nextjs
|
||||||
|
|
||||||
|
EXPOSE 3000
|
||||||
|
|
||||||
|
ENV PORT=3000
|
||||||
|
ENV HOSTNAME="0.0.0.0"
|
||||||
|
|
||||||
|
CMD ["bun", "start"]
|
||||||
64
QWEN.md
64
QWEN.md
@@ -120,14 +120,6 @@ The team follows a structured Git workflow:
|
|||||||
- `style`: Styling changes
|
- `style`: Styling changes
|
||||||
- `perf`: Performance improvements
|
- `perf`: Performance improvements
|
||||||
|
|
||||||
### Code Standards
|
|
||||||
- TypeScript with strict mode enabled
|
|
||||||
- Component header comments with file description, creator, date
|
|
||||||
- Function comments with parameter and return value descriptions
|
|
||||||
- Custom type interface comments
|
|
||||||
- Error handling comments
|
|
||||||
- Complex logic comments
|
|
||||||
|
|
||||||
### Commit Message Format
|
### Commit Message Format
|
||||||
```
|
```
|
||||||
type: Short description
|
type: Short description
|
||||||
@@ -140,6 +132,62 @@ Body:
|
|||||||
References: #issue-number
|
References: #issue-number
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**Example:**
|
||||||
|
```
|
||||||
|
feat: Tambahkan fitur kalkulator
|
||||||
|
|
||||||
|
Deskripsi:
|
||||||
|
- Menambahkan fungsi penambahan, pengurangan, perkalian, dan pembagian
|
||||||
|
- Memperbolehkan pengguna untuk memasukkan dua angka dan melakukan operasi matematika
|
||||||
|
|
||||||
|
Fixes #12
|
||||||
|
```
|
||||||
|
|
||||||
|
### Code Standards
|
||||||
|
- TypeScript with strict mode enabled
|
||||||
|
- Component header comments with file description, creator, date
|
||||||
|
- Function comments with parameter and return value descriptions
|
||||||
|
- Custom type interface comments
|
||||||
|
- Error handling comments
|
||||||
|
- Complex logic comments
|
||||||
|
|
||||||
|
### Comment Standards
|
||||||
|
|
||||||
|
**File Header:**
|
||||||
|
```typescript
|
||||||
|
/**
|
||||||
|
* Nama File: app.ts
|
||||||
|
* Deskripsi: Ini adalah file utama aplikasi.
|
||||||
|
* Pembuat: John Doe
|
||||||
|
* Tanggal: 27 Juli 2023
|
||||||
|
*/
|
||||||
|
```
|
||||||
|
|
||||||
|
**Function Comments:**
|
||||||
|
```typescript
|
||||||
|
/**
|
||||||
|
* Fungsi untuk menambahkan dua angka.
|
||||||
|
* @param {number} a - Angka pertama.
|
||||||
|
* @param {number} b - Angka kedua.
|
||||||
|
* @returns {number} Hasil penjumlahan a dan b.
|
||||||
|
*/
|
||||||
|
function addNumbers(a: number, b: number): number {
|
||||||
|
return a + b;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**Custom Type Comments:**
|
||||||
|
```typescript
|
||||||
|
/**
|
||||||
|
* Interface untuk merepresentasikan informasi pelanggan.
|
||||||
|
*/
|
||||||
|
interface Customer {
|
||||||
|
id: number; // ID pelanggan
|
||||||
|
name: string; // Nama pelanggan
|
||||||
|
age?: number; // Umur pelanggan (opsional)
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## Project Structure
|
## Project Structure
|
||||||
|
|
||||||
### Main Directories
|
### Main Directories
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
import { fileURLToPath } from "url";
|
|
||||||
import { dirname } from "path"; // Pastikan `dirname` diimpor
|
|
||||||
import { FlatCompat } from "@eslint/eslintrc";
|
|
||||||
|
|
||||||
const __filename = fileURLToPath(import.meta.url);
|
|
||||||
const __dirname = dirname(__filename);
|
|
||||||
|
|
||||||
const compat = new FlatCompat({
|
|
||||||
baseDirectory: __dirname,
|
|
||||||
});
|
|
||||||
|
|
||||||
const eslintConfig = [
|
|
||||||
...compat.extends("next/core-web-vitals", "next/typescript"),
|
|
||||||
];
|
|
||||||
|
|
||||||
export default eslintConfig;
|
|
||||||
@@ -1,35 +1,36 @@
|
|||||||
/** @type {import('next').NextConfig} */
|
/** @type {import('next').NextConfig} */
|
||||||
const nextConfig = {
|
const nextConfig = {
|
||||||
reactStrictMode: false,
|
reactStrictMode: false,
|
||||||
|
output: "standalone",
|
||||||
|
eslint: { ignoreDuringBuilds: true },
|
||||||
|
typescript: { ignoreBuildErrors: true },
|
||||||
experimental: {
|
experimental: {
|
||||||
serverActions: true,
|
serverActions: true,
|
||||||
serverComponentsExternalPackages: ['@prisma/client'],
|
serverComponentsExternalPackages: ["@prisma/client", ".prisma/client"],
|
||||||
},
|
|
||||||
output: "standalone",
|
|
||||||
staticPageGenerationTimeout: 180, // tingkatkan menjadi 3 menit
|
|
||||||
eslint: {
|
|
||||||
ignoreDuringBuilds: true,
|
|
||||||
},
|
},
|
||||||
webpack: (config, { isServer }) => {
|
webpack: (config, { isServer }) => {
|
||||||
if (isServer) {
|
if (isServer) {
|
||||||
config.externals = config.externals || [];
|
config.externals = config.externals || [];
|
||||||
config.externals.push('@prisma/client');
|
config.externals.push("@prisma/client");
|
||||||
|
config.externals.push(".prisma/client");
|
||||||
}
|
}
|
||||||
return config;
|
return config;
|
||||||
},
|
},
|
||||||
// async headers() {
|
|
||||||
// return [
|
async headers() {
|
||||||
// {
|
return [
|
||||||
// source: "/(.*)",
|
{
|
||||||
// headers: [
|
source: "/.well-known/:path*",
|
||||||
// {
|
headers: [
|
||||||
// key: "Cache-Control",
|
{ key: "Content-Type", value: "application/json" },
|
||||||
// value: "no-store, max-age=0",
|
{
|
||||||
// },
|
key: "Cache-Control",
|
||||||
// ],
|
value: "no-cache, no-store, must-revalidate",
|
||||||
// },
|
},
|
||||||
// ];
|
],
|
||||||
// },
|
},
|
||||||
|
];
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = nextConfig;
|
module.exports = nextConfig;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hipmi",
|
"name": "hipmi",
|
||||||
"version": "1.6.4",
|
"version": "1.7.2",
|
||||||
"private": true,
|
"private": true,
|
||||||
"prisma": {
|
"prisma": {
|
||||||
"seed": "bun prisma/seed.ts"
|
"seed": "bun prisma/seed.ts"
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
generator client {
|
generator client {
|
||||||
provider = "prisma-client-js"
|
provider = "prisma-client-js"
|
||||||
engineType = "binary"
|
engineType = "binary"
|
||||||
binaryTargets = ["native"]
|
binaryTargets = ["native", "debian-openssl-3.0.x", "linux-musl-openssl-3.0.x"]
|
||||||
}
|
}
|
||||||
|
|
||||||
datasource db {
|
datasource db {
|
||||||
|
|||||||
@@ -13,6 +13,6 @@ import { generate_seeder } from "./../src/app_modules/_global/fun/generate_seede
|
|||||||
console.error("<< error seeder", e);
|
console.error("<< error seeder", e);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
})
|
})
|
||||||
.finally(async () => {
|
// .finally(async () => {
|
||||||
await prisma.$disconnect();
|
// await prisma.$disconnect();
|
||||||
});
|
// });
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
[{
|
[
|
||||||
"relation": ["delegate_permission/common.handle_all_urls"],
|
{
|
||||||
"target": {
|
"relation": ["delegate_permission/common.handle_all_urls"],
|
||||||
"namespace": "android_app",
|
"target": {
|
||||||
"package_name": "com.bip.hipmimobileapp",
|
"namespace": "android_app",
|
||||||
"sha256_cert_fingerprints": ["CFF8431520BFAE665025B68138774A4E64AA6338D2DF6C7D900A71F0551FFD2D"]
|
"package_name": "com.bip.hipmimobileapp",
|
||||||
|
"sha256_cert_fingerprints": ["CFF8431520BFAE665025B68138774A4E64AA6338D2DF6C7D900A71F0551FFD2D"]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}]
|
]
|
||||||
@@ -38,4 +38,23 @@ if (fs.existsSync(prismaClientSrc)) {
|
|||||||
console.warn('⚠ @prisma/client not found, skipping...');
|
console.warn('⚠ @prisma/client not found, skipping...');
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('✅ Postbuild script completed!');
|
// Copy .env file jika ada (untuk production)
|
||||||
|
const envSrc = path.join(__dirname, '../.env');
|
||||||
|
const envDest = path.join(standaloneDir, '.env');
|
||||||
|
if (fs.existsSync(envSrc)) {
|
||||||
|
fs.copyFileSync(envSrc, envDest);
|
||||||
|
// console.log('✓ .env file copied to standalone output');
|
||||||
|
} else {
|
||||||
|
// console.warn('⚠ .env file not found, skipping...');
|
||||||
|
console.warn(' Pastikan DATABASE_URL di-set di system environment server!');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Copy .env-local file jika ada (opsional)
|
||||||
|
const envLocalSrc = path.join(__dirname, '../.env-local');
|
||||||
|
const envLocalDest = path.join(standaloneDir, '.env-local');
|
||||||
|
if (fs.existsSync(envLocalSrc)) {
|
||||||
|
fs.copyFileSync(envLocalSrc, envLocalDest);
|
||||||
|
// console.log('✓ .env-local file copied to standalone output');
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('✅ Build script completed!');
|
||||||
186
src/app/(event-confirmation)/event/[id]/confirmation/route.ts
Normal file
186
src/app/(event-confirmation)/event/[id]/confirmation/route.ts
Normal file
@@ -0,0 +1,186 @@
|
|||||||
|
/**
|
||||||
|
* Route Handler untuk Deep Link Event Confirmation
|
||||||
|
* File: app/event/[id]/confirmation/route.ts
|
||||||
|
* Deskripsi: Handle GET request untuk deep link event confirmation dengan redirect ke mobile app
|
||||||
|
* Pembuat: Assistant
|
||||||
|
* Tanggal: 9 Maret 2026
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { url } from "inspector";
|
||||||
|
import { NextRequest, NextResponse } from "next/server";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Detect platform dari User Agent string
|
||||||
|
* @param userAgent - User Agent string dari request
|
||||||
|
* @returns Platform type: 'ios', 'android', atau 'web'
|
||||||
|
*/
|
||||||
|
function detectPlatform(userAgent: string | null): "ios" | "android" | "web" {
|
||||||
|
if (!userAgent) {
|
||||||
|
return "web";
|
||||||
|
}
|
||||||
|
|
||||||
|
const lowerUA = userAgent.toLowerCase();
|
||||||
|
|
||||||
|
// Detect iOS devices
|
||||||
|
if (
|
||||||
|
/iphone|ipad|ipod/.test(lowerUA) ||
|
||||||
|
(lowerUA.includes("mac") && (("ontouchend" in {}) as any))
|
||||||
|
) {
|
||||||
|
return "ios";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Detect Android devices
|
||||||
|
if (/android/.test(lowerUA)) {
|
||||||
|
return "android";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Default to web
|
||||||
|
return "web";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build custom scheme URL untuk mobile app
|
||||||
|
* @param eventId - Event ID dari URL
|
||||||
|
* @param userId - User ID dari query parameter
|
||||||
|
* @param platform - Platform yang terdetect
|
||||||
|
* @returns Custom scheme URL
|
||||||
|
*/
|
||||||
|
function buildCustomSchemeUrl(
|
||||||
|
eventId: string,
|
||||||
|
userId: string | null,
|
||||||
|
platform: "ios" | "android" | "web",
|
||||||
|
): string {
|
||||||
|
const baseUrl = "hipmimobile://event";
|
||||||
|
const url = `${baseUrl}/${eventId}/confirmation${userId ? `?userId=${userId}` : ""}`;
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get base URL dari environment
|
||||||
|
*/
|
||||||
|
function getBaseUrl(): string {
|
||||||
|
const env = process.env.NEXT_PUBLIC_ENV || "development";
|
||||||
|
|
||||||
|
if (env === "production") {
|
||||||
|
return "https://hipmi.muku.id";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (env === "staging") {
|
||||||
|
return "https://cld-dkr-hipmi-stg.wibudev.com";
|
||||||
|
}
|
||||||
|
|
||||||
|
return "http://localhost:3000";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle GET request untuk deep link
|
||||||
|
* @param request - Next.js request object
|
||||||
|
* @returns Redirect ke mobile app atau JSON response untuk debugging
|
||||||
|
*/
|
||||||
|
export async function GET(
|
||||||
|
request: NextRequest,
|
||||||
|
{ params }: { params: { id: string } },
|
||||||
|
) {
|
||||||
|
try {
|
||||||
|
// Parse query parameters
|
||||||
|
const searchParams = request.nextUrl.searchParams;
|
||||||
|
const eventId = params.id;
|
||||||
|
const userId = searchParams.get("userId") || null;
|
||||||
|
const userAgent = request.headers.get("user-agent") || "";
|
||||||
|
|
||||||
|
// Detect platform
|
||||||
|
const platform = detectPlatform(userAgent);
|
||||||
|
|
||||||
|
// Log untuk tracking
|
||||||
|
console.log("[Deep Link] Event Confirmation Received:", {
|
||||||
|
eventId,
|
||||||
|
userId,
|
||||||
|
platform,
|
||||||
|
userAgent:
|
||||||
|
userAgent.substring(0, 100) + (userAgent.length > 100 ? "..." : ""),
|
||||||
|
timestamp: new Date().toISOString(),
|
||||||
|
url: request.url,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Build custom scheme URL untuk redirect
|
||||||
|
const customSchemeUrl = buildCustomSchemeUrl(eventId, userId, platform);
|
||||||
|
|
||||||
|
// Redirect ke mobile app untuk iOS dan Android
|
||||||
|
if (platform === "ios" || platform === "android") {
|
||||||
|
console.log("[Deep Link] Redirecting to mobile app:", customSchemeUrl);
|
||||||
|
|
||||||
|
// Redirect ke custom scheme URL
|
||||||
|
return NextResponse.redirect(customSchemeUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("[Deep Link] Environment:", process.env.NEXT_PUBLIC_ENV);
|
||||||
|
console.log("[Deep Link] Base URL:", getBaseUrl());
|
||||||
|
console.log("[Deep Link] Request:", {
|
||||||
|
eventId,
|
||||||
|
userId,
|
||||||
|
platform,
|
||||||
|
url: request.url,
|
||||||
|
timestamp: new Date().toISOString(),
|
||||||
|
});
|
||||||
|
|
||||||
|
// Untuk web/desktop, tampilkan JSON response untuk debugging
|
||||||
|
const responseData = {
|
||||||
|
success: true,
|
||||||
|
message: "Deep link received - Web fallback",
|
||||||
|
data: {
|
||||||
|
eventId,
|
||||||
|
userId,
|
||||||
|
platform,
|
||||||
|
userAgent,
|
||||||
|
timestamp: new Date().toISOString(),
|
||||||
|
url: request.url,
|
||||||
|
customSchemeUrl,
|
||||||
|
note: "This is a web fallback. Mobile users will be redirected to the app.",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
return NextResponse.json(responseData, {
|
||||||
|
status: 200,
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"Access-Control-Allow-Origin": "*",
|
||||||
|
"Access-Control-Allow-Methods": "GET, OPTIONS",
|
||||||
|
"Access-Control-Allow-Headers": "Content-Type",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error("[Deep Link] Error processing request:", error);
|
||||||
|
|
||||||
|
return NextResponse.json(
|
||||||
|
{
|
||||||
|
success: false,
|
||||||
|
message: "Error processing deep link",
|
||||||
|
error: error instanceof Error ? error.message : "Unknown error",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
status: 500,
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"Access-Control-Allow-Origin": "*",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle OPTIONS request untuk CORS preflight
|
||||||
|
*/
|
||||||
|
export async function OPTIONS() {
|
||||||
|
return NextResponse.json(
|
||||||
|
{},
|
||||||
|
{
|
||||||
|
status: 200,
|
||||||
|
headers: {
|
||||||
|
"Access-Control-Allow-Origin": "*",
|
||||||
|
"Access-Control-Allow-Methods": "GET, OPTIONS",
|
||||||
|
"Access-Control-Allow-Headers": "Content-Type",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
|
import { withRetry } from "@/lib/prisma-retry";
|
||||||
import { prisma } from "@/lib";
|
import { prisma } from "@/lib";
|
||||||
|
|
||||||
export const dynamic = "force-dynamic";
|
export const dynamic = "force-dynamic";
|
||||||
@@ -16,13 +17,25 @@ export async function GET(request: Request) {
|
|||||||
const { searchParams } = new URL(request.url);
|
const { searchParams } = new URL(request.url);
|
||||||
const userId = searchParams.get("id");
|
const userId = searchParams.get("id");
|
||||||
|
|
||||||
const data = await prisma.notifikasi.count({
|
if (!userId) {
|
||||||
where: {
|
return NextResponse.json(
|
||||||
adminId: userId,
|
{ success: false, message: "User ID is required" },
|
||||||
userRoleId: "2",
|
{ status: 400 }
|
||||||
isRead: false,
|
);
|
||||||
},
|
}
|
||||||
});
|
|
||||||
|
const data = await withRetry(
|
||||||
|
() =>
|
||||||
|
prisma.notifikasi.count({
|
||||||
|
where: {
|
||||||
|
adminId: userId,
|
||||||
|
userRoleId: "2",
|
||||||
|
isRead: false,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
undefined,
|
||||||
|
"countAdminNotifications"
|
||||||
|
);
|
||||||
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{
|
{
|
||||||
@@ -33,7 +46,25 @@ export async function GET(request: Request) {
|
|||||||
{ status: 200 }
|
{ status: 200 }
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
const errorMsg = error instanceof Error ? error.message : "Unknown error";
|
||||||
console.error("Error get count notifikasi", error);
|
console.error("Error get count notifikasi", error);
|
||||||
|
|
||||||
|
// Check if it's a database connection error
|
||||||
|
if (
|
||||||
|
errorMsg.includes("Prisma") ||
|
||||||
|
errorMsg.includes("database") ||
|
||||||
|
errorMsg.includes("connection")
|
||||||
|
) {
|
||||||
|
return NextResponse.json(
|
||||||
|
{
|
||||||
|
success: false,
|
||||||
|
message: "Database connection error. Please try again.",
|
||||||
|
data: null,
|
||||||
|
},
|
||||||
|
{ status: 503 }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{
|
{
|
||||||
success: false,
|
success: false,
|
||||||
|
|||||||
@@ -50,7 +50,5 @@ async function DELETE(
|
|||||||
},
|
},
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
);
|
);
|
||||||
} finally {
|
|
||||||
await prisma.$disconnect();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { withRetry } from "@/lib/prisma-retry";
|
||||||
import { prisma } from "@/lib";
|
import { prisma } from "@/lib";
|
||||||
import { randomOTP } from "@/app_modules/auth/fun/rondom_otp";
|
import { randomOTP } from "@/app_modules/auth/fun/rondom_otp";
|
||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
@@ -9,11 +10,26 @@ export async function POST(req: Request) {
|
|||||||
const body = await req.json();
|
const body = await req.json();
|
||||||
const { nomor } = body;
|
const { nomor } = body;
|
||||||
|
|
||||||
const user = await prisma.user.findUnique({
|
if (!nomor) {
|
||||||
where: {
|
return NextResponse.json(
|
||||||
nomor: nomor,
|
{
|
||||||
},
|
success: false,
|
||||||
});
|
message: "Nomor telepon diperlukan",
|
||||||
|
status: 400,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const user = await withRetry(
|
||||||
|
() =>
|
||||||
|
prisma.user.findUnique({
|
||||||
|
where: {
|
||||||
|
nomor: nomor,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
undefined,
|
||||||
|
"findUserByNomor"
|
||||||
|
);
|
||||||
|
|
||||||
if (!user)
|
if (!user)
|
||||||
return NextResponse.json({
|
return NextResponse.json({
|
||||||
@@ -22,12 +38,17 @@ export async function POST(req: Request) {
|
|||||||
status: 404,
|
status: 404,
|
||||||
});
|
});
|
||||||
|
|
||||||
const createOtpId = await prisma.kodeOtp.create({
|
const createOtpId = await withRetry(
|
||||||
data: {
|
() =>
|
||||||
nomor: nomor,
|
prisma.kodeOtp.create({
|
||||||
otp: codeOtp,
|
data: {
|
||||||
},
|
nomor: nomor,
|
||||||
});
|
otp: codeOtp,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
undefined,
|
||||||
|
"createOTP"
|
||||||
|
);
|
||||||
|
|
||||||
if (!createOtpId)
|
if (!createOtpId)
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
@@ -59,6 +80,25 @@ export async function POST(req: Request) {
|
|||||||
{ status: 200 },
|
{ status: 200 },
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
const errorMsg = error instanceof Error ? error.message : "Unknown error";
|
||||||
|
console.error("Mobile login error:", error);
|
||||||
|
|
||||||
|
// Check if it's a database connection error
|
||||||
|
if (
|
||||||
|
errorMsg.includes("Prisma") ||
|
||||||
|
errorMsg.includes("database") ||
|
||||||
|
errorMsg.includes("connection")
|
||||||
|
) {
|
||||||
|
return NextResponse.json(
|
||||||
|
{
|
||||||
|
success: false,
|
||||||
|
message: "Database connection error. Please try again.",
|
||||||
|
status: 503,
|
||||||
|
},
|
||||||
|
{ status: 503 }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{
|
{
|
||||||
success: false,
|
success: false,
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
import { sessionCreate } from "@/app/(auth)/_lib/session_create";
|
import { sessionCreate } from "@/app/(auth)/_lib/session_create";
|
||||||
import prisma from "@/lib/prisma";
|
import prisma from "@/lib/prisma";
|
||||||
import backendLogger from "@/util/backendLogger";
|
|
||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validasi OTP untuk login mobile
|
||||||
|
* @param req - Request dengan body { nomor: string, code: string }
|
||||||
|
* @returns Response dengan token jika OTP valid
|
||||||
|
*/
|
||||||
export async function POST(req: Request) {
|
export async function POST(req: Request) {
|
||||||
if (req.method !== "POST") {
|
if (req.method !== "POST") {
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
@@ -12,8 +16,21 @@ export async function POST(req: Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { nomor } = await req.json();
|
const { nomor, code } = await req.json();
|
||||||
|
|
||||||
|
// Validasi input: nomor dan code wajib ada
|
||||||
|
if (!nomor || !code) {
|
||||||
|
return NextResponse.json(
|
||||||
|
{ success: false, message: "Nomor dan kode OTP wajib diisi" },
|
||||||
|
{ status: 400 }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Special case untuk Apple Review: nomor 6282340374412 dengan code "1234" selalu valid
|
||||||
|
const isAppleReviewNumber = nomor === "6282340374412";
|
||||||
|
const isAppleReviewCode = code === "1234";
|
||||||
|
|
||||||
|
// Cek user berdasarkan nomor
|
||||||
const dataUser = await prisma.user.findUnique({
|
const dataUser = await prisma.user.findUnique({
|
||||||
where: {
|
where: {
|
||||||
nomor: nomor,
|
nomor: nomor,
|
||||||
@@ -28,11 +45,92 @@ export async function POST(req: Request) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (dataUser == null)
|
if (dataUser == null) {
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ success: false, message: "Nomor Belum Terdaftar" },
|
{ success: false, message: "Nomor Belum Terdaftar" },
|
||||||
{ status: 200 }
|
{ status: 200 }
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validasi OTP (skip untuk Apple Review number di production)
|
||||||
|
let otpValid = false;
|
||||||
|
|
||||||
|
if (isAppleReviewNumber && isAppleReviewCode) {
|
||||||
|
// Special case: Apple Review number dengan code "1234" selalu valid
|
||||||
|
otpValid = true;
|
||||||
|
console.log("Apple Review login bypass untuk nomor: " + nomor);
|
||||||
|
} else {
|
||||||
|
// Normal flow: validasi OTP dari database
|
||||||
|
const otpRecord = await prisma.kodeOtp.findFirst({
|
||||||
|
where: {
|
||||||
|
nomor: nomor,
|
||||||
|
isActive: true,
|
||||||
|
},
|
||||||
|
orderBy: {
|
||||||
|
createdAt: "desc",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!otpRecord) {
|
||||||
|
return NextResponse.json(
|
||||||
|
{ success: false, message: "Kode OTP tidak ditemukan" },
|
||||||
|
{ status: 400 }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cek expired OTP (5 menit dari createdAt)
|
||||||
|
const now = new Date();
|
||||||
|
const otpCreatedAt = new Date(otpRecord.createdAt);
|
||||||
|
const expiredTime = new Date(otpCreatedAt.getTime() + 5 * 60 * 1000); // 5 menit
|
||||||
|
|
||||||
|
if (now > expiredTime) {
|
||||||
|
// OTP sudah expired, update isActive menjadi false
|
||||||
|
await prisma.kodeOtp.updateMany({
|
||||||
|
where: {
|
||||||
|
nomor: nomor,
|
||||||
|
isActive: true,
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
isActive: false,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
return NextResponse.json(
|
||||||
|
{ success: false, message: "Kode OTP sudah kadaluarsa" },
|
||||||
|
{ status: 400 }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validasi code OTP
|
||||||
|
const inputCode = parseInt(code);
|
||||||
|
if (isNaN(inputCode) || inputCode !== otpRecord.otp) {
|
||||||
|
return NextResponse.json(
|
||||||
|
{ success: false, message: "Kode OTP tidak valid" },
|
||||||
|
{ status: 400 }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
otpValid = true;
|
||||||
|
|
||||||
|
// Nonaktifkan OTP yang sudah digunakan
|
||||||
|
await prisma.kodeOtp.updateMany({
|
||||||
|
where: {
|
||||||
|
nomor: nomor,
|
||||||
|
isActive: true,
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
isActive: false,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generate token jika OTP valid
|
||||||
|
if (!otpValid) {
|
||||||
|
return NextResponse.json(
|
||||||
|
{ success: false, message: "Validasi OTP gagal" },
|
||||||
|
{ status: 400 }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const token = await sessionCreate({
|
const token = await sessionCreate({
|
||||||
sessionKey: process.env.NEXT_PUBLIC_BASE_SESSION_KEY!,
|
sessionKey: process.env.NEXT_PUBLIC_BASE_SESSION_KEY!,
|
||||||
@@ -46,6 +144,7 @@ export async function POST(req: Request) {
|
|||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Buat response dengan token dalam cookie
|
// Buat response dengan token dalam cookie
|
||||||
const response = NextResponse.json(
|
const response = NextResponse.json(
|
||||||
{
|
{
|
||||||
@@ -69,7 +168,7 @@ export async function POST(req: Request) {
|
|||||||
|
|
||||||
return response;
|
return response;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
backendLogger.log("API Error or Server Error", error);
|
console.log("API Error or Server Error", error);
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{
|
{
|
||||||
success: false,
|
success: false,
|
||||||
|
|||||||
@@ -64,7 +64,5 @@ export async function POST(req: Request) {
|
|||||||
},
|
},
|
||||||
{ status: 500 },
|
{ status: 500 },
|
||||||
);
|
);
|
||||||
} finally {
|
|
||||||
await prisma.$disconnect();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,7 +42,5 @@ export async function GET(
|
|||||||
{ success: false, message: "Gagal mendapatkan data" },
|
{ success: false, message: "Gagal mendapatkan data" },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
);
|
);
|
||||||
} finally {
|
|
||||||
await prisma.$disconnect();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,13 +30,11 @@ export async function GET(request: Request) {
|
|||||||
fixData = false;
|
fixData = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
await prisma.$disconnect();
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ success: true, message: "Success get data", data: fixData },
|
{ success: true, message: "Success get data", data: fixData },
|
||||||
{ status: 200 }
|
{ status: 200 }
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
await prisma.$disconnect();
|
|
||||||
backendLogger.error("Error get data detail event:", error);
|
backendLogger.error("Error get data detail event:", error);
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -41,13 +41,11 @@ export async function POST(
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
await prisma.$disconnect();
|
|
||||||
return NextResponse.json({
|
return NextResponse.json({
|
||||||
success: true,
|
success: true,
|
||||||
message: "Success create sponsor",
|
message: "Success create sponsor",
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
await prisma.$disconnect();
|
|
||||||
backendLogger.error("Error create sponsor event", error);
|
backendLogger.error("Error create sponsor event", error);
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ success: false, message: "Failed create sponsor" },
|
{ success: false, message: "Failed create sponsor" },
|
||||||
@@ -100,7 +98,5 @@ export async function GET(
|
|||||||
},
|
},
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
);
|
);
|
||||||
} finally {
|
|
||||||
await prisma.$disconnect();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,7 +58,6 @@ export async function GET(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
await prisma.$disconnect();
|
|
||||||
return NextResponse.json({
|
return NextResponse.json({
|
||||||
success: true,
|
success: true,
|
||||||
message: "Success create sponsor",
|
message: "Success create sponsor",
|
||||||
@@ -66,7 +65,6 @@ export async function GET(
|
|||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
backendLogger.error("Error get sponsor event", error);
|
backendLogger.error("Error get sponsor event", error);
|
||||||
await prisma.$disconnect();
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{
|
{
|
||||||
success: false,
|
success: false,
|
||||||
|
|||||||
@@ -33,7 +33,5 @@ export async function GET(request: Request) {
|
|||||||
},
|
},
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
);
|
);
|
||||||
} finally {
|
|
||||||
await prisma.$disconnect();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,5 @@ export async function GET(request: Request) {
|
|||||||
},
|
},
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
);
|
);
|
||||||
} finally {
|
|
||||||
await prisma.$disconnect();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,13 +21,11 @@ export async function GET(request: Request) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
await prisma.$disconnect();
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ success: true, message: "Berhasil mendapatkan data", data: res },
|
{ success: true, message: "Berhasil mendapatkan data", data: res },
|
||||||
{ status: 200 }
|
{ status: 200 }
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
await prisma.$disconnect();
|
|
||||||
backendLogger.error("Error Get Master Status Transaksi >>", error);
|
backendLogger.error("Error Get Master Status Transaksi >>", error);
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
|
import prisma from "@/lib/prisma"
|
||||||
|
|
||||||
export async function GET(
|
export async function GET(
|
||||||
request: Request,
|
request: Request,
|
||||||
|
|||||||
@@ -28,7 +28,5 @@ async function GET() {
|
|||||||
},
|
},
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
);
|
);
|
||||||
} finally {
|
|
||||||
await prisma.$disconnect();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { withRetry } from "@/lib/prisma-retry";
|
||||||
import { prisma } from "@/lib";
|
import { prisma } from "@/lib";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import { NextRequest, NextResponse } from "next/server";
|
import { NextRequest, NextResponse } from "next/server";
|
||||||
@@ -22,28 +23,38 @@ export async function GET(
|
|||||||
let fixData;
|
let fixData;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const data = await prisma.notifikasi.findMany({
|
const data = await withRetry(
|
||||||
take: page ? takeData : undefined,
|
() =>
|
||||||
skip: page ? skipData : undefined,
|
prisma.notifikasi.findMany({
|
||||||
orderBy: {
|
take: page ? takeData : undefined,
|
||||||
createdAt: "desc",
|
skip: page ? skipData : undefined,
|
||||||
},
|
orderBy: {
|
||||||
where: {
|
createdAt: "desc",
|
||||||
recipientId: id,
|
},
|
||||||
kategoriApp: fixCategory,
|
where: {
|
||||||
},
|
recipientId: id,
|
||||||
});
|
kategoriApp: fixCategory,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
undefined,
|
||||||
|
"getNotifications"
|
||||||
|
);
|
||||||
|
|
||||||
// Jika pagination digunakan, ambil juga total count untuk informasi
|
// Jika pagination digunakan, ambil juga total count untuk informasi
|
||||||
let totalCount;
|
let totalCount;
|
||||||
let totalPages;
|
let totalPages;
|
||||||
if (page) {
|
if (page) {
|
||||||
totalCount = await prisma.notifikasi.count({
|
totalCount = await withRetry(
|
||||||
where: {
|
() =>
|
||||||
recipientId: id,
|
prisma.notifikasi.count({
|
||||||
kategoriApp: fixCategory,
|
where: {
|
||||||
},
|
recipientId: id,
|
||||||
});
|
kategoriApp: fixCategory,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
undefined,
|
||||||
|
"countNotifications"
|
||||||
|
);
|
||||||
totalPages = Math.ceil(totalCount / takeData);
|
totalPages = Math.ceil(totalCount / takeData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,8 +80,23 @@ export async function GET(
|
|||||||
|
|
||||||
return NextResponse.json(response);
|
return NextResponse.json(response);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
const errorMsg = error instanceof Error ? error.message : "Unknown error";
|
||||||
|
console.error("Error getting notifications:", error);
|
||||||
|
|
||||||
|
// Check if it's a database connection error
|
||||||
|
if (
|
||||||
|
errorMsg.includes("Prisma") ||
|
||||||
|
errorMsg.includes("database") ||
|
||||||
|
errorMsg.includes("connection")
|
||||||
|
) {
|
||||||
|
return NextResponse.json(
|
||||||
|
{ error: "Database connection error. Please try again." },
|
||||||
|
{ status: 503 }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: (error as Error).message },
|
{ error: errorMsg },
|
||||||
{ status: 500 },
|
{ status: 500 },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { withRetry } from "@/lib/prisma-retry";
|
||||||
import { prisma } from "@/lib";
|
import { prisma } from "@/lib";
|
||||||
import { NextRequest, NextResponse } from "next/server";
|
import { NextRequest, NextResponse } from "next/server";
|
||||||
|
|
||||||
@@ -9,12 +10,24 @@ export async function GET(
|
|||||||
console.log("User ID:", id);
|
console.log("User ID:", id);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const data = await prisma.notifikasi.count({
|
if (!id) {
|
||||||
where: {
|
return NextResponse.json({
|
||||||
recipientId: id,
|
success: false,
|
||||||
isRead: false,
|
message: "User ID is required",
|
||||||
},
|
});
|
||||||
});
|
}
|
||||||
|
|
||||||
|
const data = await withRetry(
|
||||||
|
() =>
|
||||||
|
prisma.notifikasi.count({
|
||||||
|
where: {
|
||||||
|
recipientId: id,
|
||||||
|
isRead: false,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
undefined,
|
||||||
|
"countUnreadNotifications"
|
||||||
|
);
|
||||||
|
|
||||||
console.log("List Notification >>", data);
|
console.log("List Notification >>", data);
|
||||||
|
|
||||||
@@ -23,6 +36,21 @@ export async function GET(
|
|||||||
data: data,
|
data: data,
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
const errorMsg = error instanceof Error ? error.message : "Unknown error";
|
||||||
|
console.error("Error getting unread count:", error);
|
||||||
|
|
||||||
|
// Check if it's a database connection error
|
||||||
|
if (
|
||||||
|
errorMsg.includes("Prisma") ||
|
||||||
|
errorMsg.includes("database") ||
|
||||||
|
errorMsg.includes("connection")
|
||||||
|
) {
|
||||||
|
return NextResponse.json({
|
||||||
|
success: false,
|
||||||
|
message: "Database connection error. Please try again.",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return NextResponse.json({
|
return NextResponse.json({
|
||||||
success: false,
|
success: false,
|
||||||
message: "Failed to get unread count",
|
message: "Failed to get unread count",
|
||||||
|
|||||||
@@ -131,7 +131,5 @@ async function PUT(request: Request, { params }: { params: { id: string } }) {
|
|||||||
},
|
},
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
);
|
);
|
||||||
} finally {
|
|
||||||
await prisma.$disconnect();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,7 +40,5 @@ export async function GET(request: Request) {
|
|||||||
status: 500,
|
status: 500,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
} finally {
|
|
||||||
await prisma.$disconnect();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,18 +27,18 @@ export async function GET(request: Request) {
|
|||||||
NOT: {
|
NOT: {
|
||||||
Profile: null,
|
Profile: null,
|
||||||
},
|
},
|
||||||
OR: [
|
// OR: [
|
||||||
{
|
// {
|
||||||
MasterUserRole: {
|
// MasterUserRole: {
|
||||||
name: "User",
|
// name: "User",
|
||||||
},
|
// },
|
||||||
},
|
// },
|
||||||
{
|
// {
|
||||||
MasterUserRole: {
|
// MasterUserRole: {
|
||||||
name: "Admin",
|
// name: "Admin",
|
||||||
},
|
// },
|
||||||
},
|
// },
|
||||||
],
|
// ],
|
||||||
},
|
},
|
||||||
include: {
|
include: {
|
||||||
Profile: {
|
Profile: {
|
||||||
|
|||||||
@@ -78,7 +78,5 @@ export async function GET(request: Request) {
|
|||||||
},
|
},
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
);
|
);
|
||||||
} finally {
|
|
||||||
await prisma.$disconnect();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,14 +49,11 @@ export async function GET(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
await prisma.$disconnect();
|
|
||||||
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ success: true, message: "Success get data news", data: fixData },
|
{ success: true, message: "Success get data news", data: fixData },
|
||||||
{ status: 200 }
|
{ status: 200 }
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
await prisma.$disconnect();
|
|
||||||
backendLogger.error("Error get data news", error);
|
backendLogger.error("Error get data news", error);
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -36,8 +36,6 @@ export async function GET(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
await prisma.$disconnect();
|
|
||||||
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ success: true, message: "Success get data document", data: fixData },
|
{ success: true, message: "Success get data document", data: fixData },
|
||||||
{ status: 200 }
|
{ status: 200 }
|
||||||
|
|||||||
@@ -104,7 +104,5 @@ async function PUT(request: Request) {
|
|||||||
},
|
},
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
);
|
);
|
||||||
} finally {
|
|
||||||
await prisma.$disconnect();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,7 +77,5 @@ async function POST(request: Request) {
|
|||||||
},
|
},
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
);
|
);
|
||||||
} finally {
|
|
||||||
await prisma.$disconnect();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { decrypt } from "@/app/(auth)/_lib/decrypt";
|
import { decrypt } from "@/app/(auth)/_lib/decrypt";
|
||||||
|
import { withRetry } from "@/lib/prisma-retry";
|
||||||
import { prisma } from "@/lib";
|
import { prisma } from "@/lib";
|
||||||
import { cookies } from "next/headers";
|
import { cookies } from "next/headers";
|
||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
@@ -43,11 +44,16 @@ export async function GET(req: Request) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const user = await prisma.user.findUnique({
|
const user = await withRetry(
|
||||||
where: {
|
() =>
|
||||||
id: decrypted.id,
|
prisma.user.findUnique({
|
||||||
},
|
where: {
|
||||||
});
|
id: decrypted.id,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
undefined,
|
||||||
|
"validateUser"
|
||||||
|
);
|
||||||
|
|
||||||
if (!user) {
|
if (!user) {
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
@@ -76,15 +82,46 @@ export async function GET(req: Request) {
|
|||||||
data: user,
|
data: user,
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error in user validation:", error);
|
const errorMsg = error instanceof Error ? error.message : "Unknown error";
|
||||||
|
const errorStack = error instanceof Error ? error.stack : "No stack";
|
||||||
|
|
||||||
|
// Log detailed error for debugging
|
||||||
|
console.error("❌ [USER-VALIDATE] Error:", errorMsg);
|
||||||
|
console.error("❌ [USER-VALIDATE] Stack:", errorStack);
|
||||||
|
console.error("❌ [USER-VALIDATE] Time:", new Date().toISOString());
|
||||||
|
|
||||||
|
// Check if it's a database connection error
|
||||||
|
if (
|
||||||
|
errorMsg.includes("Prisma") ||
|
||||||
|
errorMsg.includes("database") ||
|
||||||
|
errorMsg.includes("connection")
|
||||||
|
) {
|
||||||
|
console.error(
|
||||||
|
"❌ [USER-VALIDATE] Database connection error detected!"
|
||||||
|
);
|
||||||
|
console.error(
|
||||||
|
"❌ [USER-VALIDATE] DATABASE_URL exists:",
|
||||||
|
!!process.env.DATABASE_URL
|
||||||
|
);
|
||||||
|
|
||||||
|
return NextResponse.json(
|
||||||
|
{
|
||||||
|
success: false,
|
||||||
|
message: "Database connection error. Please try again.",
|
||||||
|
error: process.env.NODE_ENV === "development" ? errorMsg : "Internal server error",
|
||||||
|
},
|
||||||
|
{ status: 503 }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{
|
{
|
||||||
success: false,
|
success: false,
|
||||||
message: "Terjadi kesalahan pada server",
|
message: "Terjadi kesalahan pada server",
|
||||||
|
error:
|
||||||
|
process.env.NODE_ENV === "development" ? errorMsg : "Internal server error",
|
||||||
},
|
},
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// Removed prisma.$disconnect() from here to prevent connection pool exhaustion
|
|
||||||
// Prisma connections are handled globally and shouldn't be disconnected on each request
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -125,7 +125,5 @@ export async function GET(request: Request) {
|
|||||||
status: 500,
|
status: 500,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
} finally {
|
|
||||||
await prisma.$disconnect();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +0,0 @@
|
|||||||
import ClientLayout from "./v2_coba_tamplate";
|
|
||||||
import ViewV2 from "./v2_view";
|
|
||||||
|
|
||||||
export default async function Page() {
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<ViewV2 />
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,127 +0,0 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import { AccentColor, MainColor } from "@/app_modules/_global/color";
|
|
||||||
import {
|
|
||||||
listMenuHomeBody,
|
|
||||||
menuHomeJob,
|
|
||||||
} from "@/app_modules/home/component/list_menu_home";
|
|
||||||
import {
|
|
||||||
ActionIcon,
|
|
||||||
Box,
|
|
||||||
Group,
|
|
||||||
Image,
|
|
||||||
Paper,
|
|
||||||
SimpleGrid,
|
|
||||||
Stack,
|
|
||||||
Text
|
|
||||||
} from "@mantine/core";
|
|
||||||
import { IconUserSearch } from "@tabler/icons-react";
|
|
||||||
|
|
||||||
export function Test_Children() {
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<Box>
|
|
||||||
<Image
|
|
||||||
height={140}
|
|
||||||
fit={"cover"}
|
|
||||||
alt="logo"
|
|
||||||
src={"/aset/home/home-hipmi-new.png"}
|
|
||||||
styles={{
|
|
||||||
imageWrapper: {
|
|
||||||
border: `2px solid ${AccentColor.blue}`,
|
|
||||||
borderRadius: "10px 10px 10px 10px",
|
|
||||||
},
|
|
||||||
image: {
|
|
||||||
borderRadius: "8px 8px 8px 8px",
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{Array.from(new Array(2)).map((e, i) => (
|
|
||||||
<Stack my={"sm"} key={i}>
|
|
||||||
<SimpleGrid cols={2} spacing="md">
|
|
||||||
{listMenuHomeBody.map((e, i) => (
|
|
||||||
<Paper
|
|
||||||
key={e.id}
|
|
||||||
h={150}
|
|
||||||
bg={MainColor.darkblue}
|
|
||||||
style={{
|
|
||||||
borderRadius: "10px 10px 10px 10px",
|
|
||||||
border: `2px solid ${AccentColor.blue}`,
|
|
||||||
}}
|
|
||||||
onClick={() => {}}
|
|
||||||
>
|
|
||||||
<Stack align="center" justify="center" h={"100%"}>
|
|
||||||
<ActionIcon
|
|
||||||
size={50}
|
|
||||||
variant="transparent"
|
|
||||||
c={e.link == "" ? "gray.3" : MainColor.white}
|
|
||||||
>
|
|
||||||
{e.icon}
|
|
||||||
</ActionIcon>
|
|
||||||
<Text
|
|
||||||
c={e.link == "" ? "gray.3" : MainColor.white}
|
|
||||||
fz={"xs"}
|
|
||||||
>
|
|
||||||
{e.name}
|
|
||||||
</Text>
|
|
||||||
</Stack>
|
|
||||||
</Paper>
|
|
||||||
))}
|
|
||||||
</SimpleGrid>
|
|
||||||
|
|
||||||
{/* Job View */}
|
|
||||||
<Paper
|
|
||||||
p={"md"}
|
|
||||||
w={"100%"}
|
|
||||||
bg={MainColor.darkblue}
|
|
||||||
style={{
|
|
||||||
borderRadius: "10px 10px 10px 10px",
|
|
||||||
border: `2px solid ${AccentColor.blue}`,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Stack onClick={() => {}}>
|
|
||||||
<Group>
|
|
||||||
<ActionIcon
|
|
||||||
variant="transparent"
|
|
||||||
size={40}
|
|
||||||
c={menuHomeJob.link == "" ? "gray.3" : MainColor.white}
|
|
||||||
>
|
|
||||||
{menuHomeJob.icon}
|
|
||||||
</ActionIcon>
|
|
||||||
<Text c={menuHomeJob.link == "" ? "gray.3" : MainColor.white}>
|
|
||||||
{menuHomeJob.name}
|
|
||||||
</Text>
|
|
||||||
</Group>
|
|
||||||
<SimpleGrid cols={2} spacing="md">
|
|
||||||
{Array.from({ length: 2 }).map((e, i) => (
|
|
||||||
<Stack key={i}>
|
|
||||||
<Group spacing={"xs"}>
|
|
||||||
<Stack h={"100%"} align="center" justify="flex-start">
|
|
||||||
<IconUserSearch size={20} color={MainColor.white} />
|
|
||||||
</Stack>
|
|
||||||
<Stack spacing={0} w={"60%"}>
|
|
||||||
<Text
|
|
||||||
lineClamp={1}
|
|
||||||
fz={"sm"}
|
|
||||||
c={MainColor.yellow}
|
|
||||||
fw={"bold"}
|
|
||||||
>
|
|
||||||
nama {i}
|
|
||||||
</Text>
|
|
||||||
<Text fz={"sm"} c={MainColor.white} lineClamp={2}>
|
|
||||||
judulnya {i}
|
|
||||||
</Text>
|
|
||||||
</Stack>
|
|
||||||
</Group>
|
|
||||||
</Stack>
|
|
||||||
))}
|
|
||||||
</SimpleGrid>
|
|
||||||
</Stack>
|
|
||||||
</Paper>
|
|
||||||
</Stack>
|
|
||||||
))}
|
|
||||||
</Box>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,75 +0,0 @@
|
|||||||
"use client"
|
|
||||||
|
|
||||||
import { MainColor } from "@/app_modules/_global/color";
|
|
||||||
import { listMenuHomeFooter } from "@/app_modules/home";
|
|
||||||
import {
|
|
||||||
ActionIcon,
|
|
||||||
Box,
|
|
||||||
Center,
|
|
||||||
SimpleGrid,
|
|
||||||
Stack,
|
|
||||||
Text,
|
|
||||||
} from "@mantine/core";
|
|
||||||
import { IconUserCircle } from "@tabler/icons-react";
|
|
||||||
import { useRouter } from "next/navigation";
|
|
||||||
|
|
||||||
export default function Test_FooterHome() {
|
|
||||||
const router = useRouter();
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Box
|
|
||||||
style={{
|
|
||||||
zIndex: 99,
|
|
||||||
borderRadius: "20px 20px 0px 0px",
|
|
||||||
}}
|
|
||||||
w={"100%"}
|
|
||||||
bottom={0}
|
|
||||||
h={"9vh"}
|
|
||||||
>
|
|
||||||
<SimpleGrid cols={listMenuHomeFooter.length + 1}>
|
|
||||||
{listMenuHomeFooter.map((e) => (
|
|
||||||
<Center h={"9vh"} key={e.id}>
|
|
||||||
<Stack
|
|
||||||
align="center"
|
|
||||||
spacing={0}
|
|
||||||
onClick={() => {
|
|
||||||
console.log("test")
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<ActionIcon
|
|
||||||
radius={"xl"}
|
|
||||||
c={e.link === "" ? "gray" : MainColor.white}
|
|
||||||
variant="transparent"
|
|
||||||
>
|
|
||||||
{e.icon}
|
|
||||||
</ActionIcon>
|
|
||||||
<Text
|
|
||||||
lineClamp={1}
|
|
||||||
c={e.link === "" ? "gray" : MainColor.white}
|
|
||||||
fz={12}
|
|
||||||
>
|
|
||||||
{e.name}
|
|
||||||
</Text>
|
|
||||||
</Stack>
|
|
||||||
</Center>
|
|
||||||
))}
|
|
||||||
|
|
||||||
<Center h={"9vh"}>
|
|
||||||
<Stack align="center" spacing={2}>
|
|
||||||
<ActionIcon
|
|
||||||
variant={"transparent"}
|
|
||||||
onClick={() =>
|
|
||||||
console.log("test")
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<IconUserCircle color="white" />
|
|
||||||
</ActionIcon>
|
|
||||||
<Text fz={10} c={MainColor.white}>
|
|
||||||
Profile
|
|
||||||
</Text>
|
|
||||||
</Stack>
|
|
||||||
</Center>
|
|
||||||
</SimpleGrid>
|
|
||||||
</Box>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,130 +0,0 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import { AccentColor, MainColor } from "@/app_modules/_global/color";
|
|
||||||
import {
|
|
||||||
Header,
|
|
||||||
Group,
|
|
||||||
ActionIcon,
|
|
||||||
Text,
|
|
||||||
Title,
|
|
||||||
Box,
|
|
||||||
Loader,
|
|
||||||
} from "@mantine/core";
|
|
||||||
import { IconArrowLeft, IconChevronLeft } from "@tabler/icons-react";
|
|
||||||
import { useRouter } from "next/navigation";
|
|
||||||
import React, { useState } from "react";
|
|
||||||
|
|
||||||
|
|
||||||
export default function Test_LayoutHeaderTamplate({
|
|
||||||
title,
|
|
||||||
posotion,
|
|
||||||
// left button
|
|
||||||
hideButtonLeft,
|
|
||||||
iconLeft,
|
|
||||||
routerLeft,
|
|
||||||
customButtonLeft,
|
|
||||||
// right button
|
|
||||||
iconRight,
|
|
||||||
routerRight,
|
|
||||||
customButtonRight,
|
|
||||||
backgroundColor,
|
|
||||||
}: {
|
|
||||||
title: string;
|
|
||||||
posotion?: any;
|
|
||||||
// left button
|
|
||||||
hideButtonLeft?: boolean;
|
|
||||||
iconLeft?: any;
|
|
||||||
routerLeft?: any;
|
|
||||||
customButtonLeft?: React.ReactNode;
|
|
||||||
// right button
|
|
||||||
iconRight?: any;
|
|
||||||
routerRight?: any;
|
|
||||||
customButtonRight?: React.ReactNode;
|
|
||||||
backgroundColor?: string;
|
|
||||||
}) {
|
|
||||||
const router = useRouter();
|
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
|
||||||
const [isRightLoading, setRightLoading] = useState(false);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<Box
|
|
||||||
h={"8vh"}
|
|
||||||
// w={"100%"}
|
|
||||||
// pos={"sticky"}
|
|
||||||
// top={0}
|
|
||||||
// style={{
|
|
||||||
// zIndex: 10,
|
|
||||||
// }}
|
|
||||||
sx={{
|
|
||||||
borderStyle: "none",
|
|
||||||
}}
|
|
||||||
bg={backgroundColor ? backgroundColor : MainColor.darkblue}
|
|
||||||
>
|
|
||||||
<Group h={"100%"} position={posotion ? posotion : "apart"} px={"md"}>
|
|
||||||
{hideButtonLeft ? (
|
|
||||||
<ActionIcon disabled variant="transparent"></ActionIcon>
|
|
||||||
) : customButtonLeft ? (
|
|
||||||
customButtonLeft
|
|
||||||
) : (
|
|
||||||
<ActionIcon
|
|
||||||
c={MainColor.white}
|
|
||||||
variant="transparent"
|
|
||||||
radius={"xl"}
|
|
||||||
onClick={() => {
|
|
||||||
setIsLoading(true);
|
|
||||||
routerLeft === undefined
|
|
||||||
? router.back()
|
|
||||||
: router.push(routerLeft, { scroll: false });
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{/* PAKE LOADING SAAT KLIK BACK */}
|
|
||||||
{/* {isLoading ? (
|
|
||||||
<Loader color={AccentColor.yellow} size={20} />
|
|
||||||
) : iconLeft ? (
|
|
||||||
iconLeft
|
|
||||||
) : (
|
|
||||||
<IconChevronLeft />
|
|
||||||
)} */}
|
|
||||||
|
|
||||||
|
|
||||||
{/* GA PAKE LOADING SAAT KLIK BACK */}
|
|
||||||
{iconLeft ? (
|
|
||||||
iconLeft
|
|
||||||
) : (
|
|
||||||
<IconChevronLeft />
|
|
||||||
)}
|
|
||||||
</ActionIcon>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<Title order={5} c={MainColor.yellow}>
|
|
||||||
{title}
|
|
||||||
</Title>
|
|
||||||
|
|
||||||
{customButtonRight ? (
|
|
||||||
customButtonRight
|
|
||||||
) : iconRight === undefined ? (
|
|
||||||
<ActionIcon disabled variant="transparent"></ActionIcon>
|
|
||||||
) : routerRight === undefined ? (
|
|
||||||
<Box>{iconRight}</Box>
|
|
||||||
) : (
|
|
||||||
<ActionIcon
|
|
||||||
c={"white"}
|
|
||||||
variant="transparent"
|
|
||||||
onClick={() => {
|
|
||||||
setRightLoading(true);
|
|
||||||
router.push(routerRight);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{isRightLoading ? (
|
|
||||||
<Loader color={AccentColor.yellow} size={20} />
|
|
||||||
) : (
|
|
||||||
iconRight
|
|
||||||
)}
|
|
||||||
</ActionIcon>
|
|
||||||
)}
|
|
||||||
</Group>
|
|
||||||
</Box>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,127 +0,0 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import { AccentColor, MainColor } from "@/app_modules/_global/color";
|
|
||||||
import {
|
|
||||||
BackgroundImage,
|
|
||||||
Box,
|
|
||||||
Container,
|
|
||||||
rem,
|
|
||||||
ScrollArea,
|
|
||||||
} from "@mantine/core";
|
|
||||||
|
|
||||||
export function Test_Tamplate({
|
|
||||||
children,
|
|
||||||
header,
|
|
||||||
footer,
|
|
||||||
}: {
|
|
||||||
children: React.ReactNode;
|
|
||||||
header: React.ReactNode;
|
|
||||||
footer?: React.ReactNode;
|
|
||||||
}) {
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<Box
|
|
||||||
w={"100%"}
|
|
||||||
h={"100%"}
|
|
||||||
style={{
|
|
||||||
backgroundColor: MainColor.black,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Container mih={"100vh"} p={0} size={rem(500)} bg={MainColor.green}>
|
|
||||||
{/* <BackgroundImage
|
|
||||||
src={"/aset/global/main_background.png"}
|
|
||||||
h={"100vh"}
|
|
||||||
// style={{ position: "relative" }}
|
|
||||||
> */}
|
|
||||||
<TestHeader header={header} />
|
|
||||||
|
|
||||||
<TestChildren footer={footer}>{children}</TestChildren>
|
|
||||||
|
|
||||||
<TestFooter footer={footer} />
|
|
||||||
{/* </BackgroundImage> */}
|
|
||||||
</Container>
|
|
||||||
</Box>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function TestHeader({ header }: { header: React.ReactNode }) {
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<Box
|
|
||||||
h={"8vh"}
|
|
||||||
style={{
|
|
||||||
zIndex: 10,
|
|
||||||
alignContent: "center",
|
|
||||||
}}
|
|
||||||
w={"100%"}
|
|
||||||
pos={"sticky"}
|
|
||||||
top={0}
|
|
||||||
>
|
|
||||||
{header}
|
|
||||||
</Box>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function TestChildren({
|
|
||||||
children,
|
|
||||||
footer,
|
|
||||||
}: {
|
|
||||||
children: React.ReactNode;
|
|
||||||
footer: React.ReactNode;
|
|
||||||
}) {
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<Box
|
|
||||||
style={{ zIndex: 0 }}
|
|
||||||
px={"md"}
|
|
||||||
h={footer ? "82vh" : "92vh"}
|
|
||||||
>
|
|
||||||
{children}
|
|
||||||
</Box>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function TestFooter({ footer }: { footer: React.ReactNode }) {
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
{footer ? (
|
|
||||||
<Box
|
|
||||||
// w dihilangkan kalau relative
|
|
||||||
w={"100%"}
|
|
||||||
style={{
|
|
||||||
// position: "relative",
|
|
||||||
position: "fixed",
|
|
||||||
bottom: 0,
|
|
||||||
height: "10vh",
|
|
||||||
zIndex: 10,
|
|
||||||
borderRadius: "20px 20px 0px 0px",
|
|
||||||
borderTop: `2px solid ${AccentColor.blue}`,
|
|
||||||
borderRight: `1px solid ${AccentColor.blue}`,
|
|
||||||
borderLeft: `1px solid ${AccentColor.blue}`,
|
|
||||||
// maxWidth dihilangkan kalau relative
|
|
||||||
maxWidth: rem(500),
|
|
||||||
}}
|
|
||||||
bg={AccentColor.darkblue}
|
|
||||||
>
|
|
||||||
<Box
|
|
||||||
h={"100%"}
|
|
||||||
// maw dihilangkan kalau relative
|
|
||||||
maw={rem(500)}
|
|
||||||
style={{
|
|
||||||
borderRadius: "20px 20px 0px 0px",
|
|
||||||
width: "100%",
|
|
||||||
}}
|
|
||||||
// pos={"absolute"}
|
|
||||||
>
|
|
||||||
{footer}
|
|
||||||
</Box>
|
|
||||||
</Box>
|
|
||||||
) : (
|
|
||||||
""
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import { Box, ScrollArea } from "@mantine/core";
|
|
||||||
|
|
||||||
export function V2_Children({
|
|
||||||
children,
|
|
||||||
height,
|
|
||||||
}: {
|
|
||||||
children: React.ReactNode;
|
|
||||||
height?: number;
|
|
||||||
}) {
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<Box
|
|
||||||
style={{ zIndex: 0 }}
|
|
||||||
px={"md"}
|
|
||||||
h={height ? "82vh" : "92vh"}
|
|
||||||
pos={"static"}
|
|
||||||
>
|
|
||||||
{children}
|
|
||||||
{/* <ScrollArea h={"100%"} px={"md"} bg={"cyan"}>
|
|
||||||
</ScrollArea> */}
|
|
||||||
</Box>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,159 +0,0 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import { AccentColor, MainColor } from "@/app_modules/_global/color";
|
|
||||||
import {
|
|
||||||
ActionIcon,
|
|
||||||
BackgroundImage, // Import BackgroundImage dari Mantine
|
|
||||||
Box,
|
|
||||||
Button,
|
|
||||||
Container,
|
|
||||||
Group,
|
|
||||||
Text,
|
|
||||||
Title,
|
|
||||||
} from "@mantine/core";
|
|
||||||
import { useDisclosure, useShallowEffect } from "@mantine/hooks";
|
|
||||||
import { createStyles } from "@mantine/styles";
|
|
||||||
import { IconBell, IconSearch } from "@tabler/icons-react";
|
|
||||||
import { ReactNode, useEffect, useState } from "react";
|
|
||||||
|
|
||||||
// Styling langsung didefinisikan di dalam komponen
|
|
||||||
const useStyles = createStyles((theme) => ({
|
|
||||||
pageContainer: {
|
|
||||||
display: "flex",
|
|
||||||
flexDirection: "column",
|
|
||||||
minHeight: "100dvh", // dynamic viewport height untuk mobile
|
|
||||||
width: "100%",
|
|
||||||
maxWidth: "500px", // Batasi lebar maksimum
|
|
||||||
margin: "0 auto", // Pusatkan layout
|
|
||||||
boxShadow: "0 0 10px rgba(0, 0, 0, 0.1)", // Tambahkan shadow untuk efek mobile-like
|
|
||||||
backgroundColor: MainColor.darkblue, // Warna latar belakang fallback
|
|
||||||
|
|
||||||
[`@media (max-width: 768px)`]: {
|
|
||||||
maxWidth: "100%", // Pada layar mobile, gunakan lebar penuh
|
|
||||||
boxShadow: "none", // Hilangkan shadow pada mobile
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
header: {
|
|
||||||
position: "sticky",
|
|
||||||
top: 0,
|
|
||||||
width: "100%",
|
|
||||||
maxWidth: "500px", // Batasi lebar header sesuai container
|
|
||||||
margin: "0 auto", // Pusatkan header
|
|
||||||
backgroundColor: MainColor.darkblue,
|
|
||||||
boxShadow: "0 1px 3px rgba(0, 0, 0, 0.1)",
|
|
||||||
zIndex: 1000, // Pastikan z-index tinggi
|
|
||||||
transition: "all 0.3s ease",
|
|
||||||
color: MainColor.yellow,
|
|
||||||
},
|
|
||||||
|
|
||||||
scrolled: {
|
|
||||||
boxShadow: "0 2px 8px rgba(0, 0, 0, 0.15)",
|
|
||||||
},
|
|
||||||
|
|
||||||
headerContainer: {
|
|
||||||
height: "8vh",
|
|
||||||
display: "flex",
|
|
||||||
alignItems: "center",
|
|
||||||
padding: "0 16px", // Padding untuk mobile view
|
|
||||||
|
|
||||||
[`@media (max-width: 768px)`]: {
|
|
||||||
height: "8vh",
|
|
||||||
},
|
|
||||||
borderBottom: `1px solid ${AccentColor.blue}`,
|
|
||||||
borderBottomLeftRadius: "10px",
|
|
||||||
borderBottomRightRadius: "10px",
|
|
||||||
},
|
|
||||||
|
|
||||||
content: {
|
|
||||||
flex: 1,
|
|
||||||
width: "100%",
|
|
||||||
overflowY: "auto", // Izinkan scrolling pada konten
|
|
||||||
paddingBottom: "15vh", // Sesuaikan dengan tinggi footer
|
|
||||||
},
|
|
||||||
|
|
||||||
footer: {
|
|
||||||
width: "100%",
|
|
||||||
backgroundColor: MainColor.darkblue,
|
|
||||||
borderTop: `1px solid ${AccentColor.blue}`,
|
|
||||||
height: "10vh", // Tinggi footer
|
|
||||||
display: "flex",
|
|
||||||
alignItems: "center",
|
|
||||||
justifyContent: "center",
|
|
||||||
position: "fixed",
|
|
||||||
bottom: 0,
|
|
||||||
left: "50%", // Pusatkan footer
|
|
||||||
transform: "translateX(-50%)", // Pusatkan footer
|
|
||||||
maxWidth: "500px", // Batasi lebar footer
|
|
||||||
color: MainColor.white,
|
|
||||||
borderTopLeftRadius: "10px",
|
|
||||||
borderTopRightRadius: "10px",
|
|
||||||
},
|
|
||||||
}));
|
|
||||||
|
|
||||||
interface ClientLayoutProps {
|
|
||||||
children: ReactNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function ClientLayout({ children }: ClientLayoutProps) {
|
|
||||||
const [scrolled, setScrolled] = useState<boolean>(false);
|
|
||||||
const { classes, cx } = useStyles();
|
|
||||||
|
|
||||||
// Effect untuk mendeteksi scroll
|
|
||||||
useEffect(() => {
|
|
||||||
function handleScroll() {
|
|
||||||
if (window.scrollY > 10) {
|
|
||||||
setScrolled(true);
|
|
||||||
} else {
|
|
||||||
setScrolled(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
window.addEventListener("scroll", handleScroll);
|
|
||||||
return () => window.removeEventListener("scroll", handleScroll);
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Box className={classes.pageContainer}>
|
|
||||||
{/* Header - tetap di atas */}
|
|
||||||
<Box
|
|
||||||
className={cx(classes.header, { [classes.scrolled]: scrolled })}
|
|
||||||
component="header"
|
|
||||||
>
|
|
||||||
<Container size="xl" className={classes.headerContainer}>
|
|
||||||
<Group position="apart" w={"100%"}>
|
|
||||||
<ActionIcon>
|
|
||||||
<IconSearch />
|
|
||||||
</ActionIcon>
|
|
||||||
<Title order={4}>Home Test</Title>
|
|
||||||
<ActionIcon>
|
|
||||||
<IconBell />
|
|
||||||
</ActionIcon>
|
|
||||||
</Group>
|
|
||||||
</Container>
|
|
||||||
</Box>
|
|
||||||
|
|
||||||
{/* Konten utama - bisa di-scroll */}
|
|
||||||
<Box className={classes.content}>
|
|
||||||
<Container>{children}</Container>
|
|
||||||
</Box>
|
|
||||||
|
|
||||||
{/* Footer - tetap di bawah */}
|
|
||||||
<Box className={classes.footer} component="footer">
|
|
||||||
<Container size="xl">
|
|
||||||
<Group position="apart" py="md">
|
|
||||||
<Text size="sm">© 2025 Nama Perusahaan</Text>
|
|
||||||
<Group spacing="xs">
|
|
||||||
<Button variant="subtle" size="xs">
|
|
||||||
Privasi
|
|
||||||
</Button>
|
|
||||||
<Button variant="subtle" size="xs">
|
|
||||||
Syarat
|
|
||||||
</Button>
|
|
||||||
</Group>
|
|
||||||
</Group>
|
|
||||||
</Container>
|
|
||||||
</Box>
|
|
||||||
</Box>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import { MainColor } from "@/app_modules/_global/color";
|
|
||||||
import { ActionIcon, Box, Group, Title } from "@mantine/core";
|
|
||||||
import { IconBell, IconChevronLeft } from "@tabler/icons-react";
|
|
||||||
|
|
||||||
export function V2_Header() {
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<Box
|
|
||||||
h={"8vh"}
|
|
||||||
style={{
|
|
||||||
zIndex: 10,
|
|
||||||
alignContent: "center",
|
|
||||||
}}
|
|
||||||
w={"100%"}
|
|
||||||
pos={"sticky"}
|
|
||||||
top={0}
|
|
||||||
bg={MainColor.darkblue}
|
|
||||||
>
|
|
||||||
<Group h={"100%"} position={"apart"} px={"md"}>
|
|
||||||
<ActionIcon
|
|
||||||
c={MainColor.white}
|
|
||||||
variant="transparent"
|
|
||||||
radius={"xl"}
|
|
||||||
onClick={() => {}}
|
|
||||||
>
|
|
||||||
<IconChevronLeft />
|
|
||||||
</ActionIcon>
|
|
||||||
|
|
||||||
<Title order={5} c={MainColor.yellow}>
|
|
||||||
Test Tamplate
|
|
||||||
</Title>
|
|
||||||
|
|
||||||
<ActionIcon c={"white"} variant="transparent" onClick={() => {}}>
|
|
||||||
<IconBell />
|
|
||||||
</ActionIcon>
|
|
||||||
</Group>
|
|
||||||
</Box>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,127 +0,0 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import { AccentColor, MainColor } from "@/app_modules/_global/color";
|
|
||||||
import {
|
|
||||||
listMenuHomeBody,
|
|
||||||
menuHomeJob,
|
|
||||||
} from "@/app_modules/home/component/list_menu_home";
|
|
||||||
import {
|
|
||||||
Box,
|
|
||||||
Stack,
|
|
||||||
SimpleGrid,
|
|
||||||
Paper,
|
|
||||||
ActionIcon,
|
|
||||||
Group,
|
|
||||||
Image,
|
|
||||||
Text,
|
|
||||||
} from "@mantine/core";
|
|
||||||
import { IconUserSearch } from "@tabler/icons-react";
|
|
||||||
|
|
||||||
export function V2_HomeView() {
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<Box>
|
|
||||||
<Image
|
|
||||||
height={140}
|
|
||||||
fit={"cover"}
|
|
||||||
alt="logo"
|
|
||||||
src={"/aset/home/home-hipmi-new.png"}
|
|
||||||
styles={{
|
|
||||||
imageWrapper: {
|
|
||||||
border: `2px solid ${AccentColor.blue}`,
|
|
||||||
borderRadius: "10px 10px 10px 10px",
|
|
||||||
},
|
|
||||||
image: {
|
|
||||||
borderRadius: "8px 8px 8px 8px",
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{Array.from(new Array(2)).map((e, i) => (
|
|
||||||
<Stack my={"sm"} key={i}>
|
|
||||||
<SimpleGrid cols={2} spacing="md">
|
|
||||||
{listMenuHomeBody.map((e, i) => (
|
|
||||||
<Paper
|
|
||||||
key={e.id}
|
|
||||||
h={150}
|
|
||||||
bg={MainColor.darkblue}
|
|
||||||
style={{
|
|
||||||
borderRadius: "10px 10px 10px 10px",
|
|
||||||
border: `2px solid ${AccentColor.blue}`,
|
|
||||||
}}
|
|
||||||
onClick={() => {}}
|
|
||||||
>
|
|
||||||
<Stack align="center" justify="center" h={"100%"}>
|
|
||||||
<ActionIcon
|
|
||||||
size={50}
|
|
||||||
variant="transparent"
|
|
||||||
c={e.link == "" ? "gray.3" : MainColor.white}
|
|
||||||
>
|
|
||||||
{e.icon}
|
|
||||||
</ActionIcon>
|
|
||||||
<Text
|
|
||||||
c={e.link == "" ? "gray.3" : MainColor.white}
|
|
||||||
fz={"xs"}
|
|
||||||
>
|
|
||||||
{e.name}
|
|
||||||
</Text>
|
|
||||||
</Stack>
|
|
||||||
</Paper>
|
|
||||||
))}
|
|
||||||
</SimpleGrid>
|
|
||||||
|
|
||||||
{/* Job View */}
|
|
||||||
<Paper
|
|
||||||
p={"md"}
|
|
||||||
w={"100%"}
|
|
||||||
bg={MainColor.darkblue}
|
|
||||||
style={{
|
|
||||||
borderRadius: "10px 10px 10px 10px",
|
|
||||||
border: `2px solid ${AccentColor.blue}`,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Stack onClick={() => {}}>
|
|
||||||
<Group>
|
|
||||||
<ActionIcon
|
|
||||||
variant="transparent"
|
|
||||||
size={40}
|
|
||||||
c={menuHomeJob.link == "" ? "gray.3" : MainColor.white}
|
|
||||||
>
|
|
||||||
{menuHomeJob.icon}
|
|
||||||
</ActionIcon>
|
|
||||||
<Text c={menuHomeJob.link == "" ? "gray.3" : MainColor.white}>
|
|
||||||
{menuHomeJob.name}
|
|
||||||
</Text>
|
|
||||||
</Group>
|
|
||||||
<SimpleGrid cols={2} spacing="md">
|
|
||||||
{Array.from({ length: 2 }).map((e, i) => (
|
|
||||||
<Stack key={i}>
|
|
||||||
<Group spacing={"xs"}>
|
|
||||||
<Stack h={"100%"} align="center" justify="flex-start">
|
|
||||||
<IconUserSearch size={20} color={MainColor.white} />
|
|
||||||
</Stack>
|
|
||||||
<Stack spacing={0} w={"60%"}>
|
|
||||||
<Text
|
|
||||||
lineClamp={1}
|
|
||||||
fz={"sm"}
|
|
||||||
c={MainColor.yellow}
|
|
||||||
fw={"bold"}
|
|
||||||
>
|
|
||||||
nama {i}
|
|
||||||
</Text>
|
|
||||||
<Text fz={"sm"} c={MainColor.white} lineClamp={2}>
|
|
||||||
judulnya {i}
|
|
||||||
</Text>
|
|
||||||
</Stack>
|
|
||||||
</Group>
|
|
||||||
</Stack>
|
|
||||||
))}
|
|
||||||
</SimpleGrid>
|
|
||||||
</Stack>
|
|
||||||
</Paper>
|
|
||||||
</Stack>
|
|
||||||
))}
|
|
||||||
</Box>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,117 +0,0 @@
|
|||||||
// app/page.tsx
|
|
||||||
"use client";
|
|
||||||
|
|
||||||
import {
|
|
||||||
Badge,
|
|
||||||
Box,
|
|
||||||
Button,
|
|
||||||
Card,
|
|
||||||
Group,
|
|
||||||
Image,
|
|
||||||
Paper,
|
|
||||||
Stack,
|
|
||||||
Text,
|
|
||||||
Title,
|
|
||||||
} from "@mantine/core";
|
|
||||||
import ClientLayout from "./v2_coba_tamplate";
|
|
||||||
|
|
||||||
export default function ViewV2() {
|
|
||||||
return (
|
|
||||||
<ClientLayout>
|
|
||||||
<Stack spacing="xl" c={"white"}>
|
|
||||||
<Title order={1} ta="center" my="lg" size="h2">
|
|
||||||
Selamat Datang
|
|
||||||
</Title>
|
|
||||||
|
|
||||||
<Text size="md" ta="center" mb="lg">
|
|
||||||
Aplikasi dengan layout yang dioptimalkan untuk tampilan mobile
|
|
||||||
</Text>
|
|
||||||
|
|
||||||
<Stack spacing="md">
|
|
||||||
{[...Array(5)].map((_, index) => (
|
|
||||||
<Card
|
|
||||||
opacity={0.3}
|
|
||||||
key={index}
|
|
||||||
shadow="sm"
|
|
||||||
padding="md"
|
|
||||||
radius="md"
|
|
||||||
withBorder
|
|
||||||
>
|
|
||||||
<Card.Section>
|
|
||||||
<Image
|
|
||||||
src={`/api/placeholder/400/200`}
|
|
||||||
height={160}
|
|
||||||
alt={`Produk ${index + 1}`}
|
|
||||||
/>
|
|
||||||
</Card.Section>
|
|
||||||
|
|
||||||
<Group position="apart" mt="md" mb="xs">
|
|
||||||
<Text fw={500}>Produk {index + 1}</Text>
|
|
||||||
<Badge color="blue" variant="light">
|
|
||||||
Baru
|
|
||||||
</Badge>
|
|
||||||
</Group>
|
|
||||||
|
|
||||||
<Text size="sm" color="dimmed" lineClamp={2}>
|
|
||||||
Deskripsi produk yang singkat dan padat untuk tampilan mobile.
|
|
||||||
Fokus pada informasi penting saja.
|
|
||||||
</Text>
|
|
||||||
|
|
||||||
<Button
|
|
||||||
variant="light"
|
|
||||||
color="blue"
|
|
||||||
fullWidth
|
|
||||||
mt="md"
|
|
||||||
radius="md"
|
|
||||||
>
|
|
||||||
Lihat Detail
|
|
||||||
</Button>
|
|
||||||
</Card>
|
|
||||||
))}
|
|
||||||
</Stack>
|
|
||||||
|
|
||||||
<Stack spacing="md">
|
|
||||||
{[...Array(5)].map((_, index) => (
|
|
||||||
<Box key={index} mb="xl" h="100px" bg={"gray"}>
|
|
||||||
Test
|
|
||||||
</Box>
|
|
||||||
))}
|
|
||||||
</Stack>
|
|
||||||
|
|
||||||
{[...Array(5)].map((_, index) => (
|
|
||||||
<div
|
|
||||||
key={index}
|
|
||||||
style={{
|
|
||||||
backgroundColor: "gray",
|
|
||||||
marginBottom: "15px",
|
|
||||||
height: "100px",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Test
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
|
|
||||||
<Paper
|
|
||||||
shadow="md"
|
|
||||||
p="md"
|
|
||||||
withBorder
|
|
||||||
radius="md"
|
|
||||||
style={{
|
|
||||||
backgroundImage: "linear-gradient(45deg, #228be6, #4c6ef5)",
|
|
||||||
color: "white",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Text fw={700} size="lg" ta="center">
|
|
||||||
Promo Spesial
|
|
||||||
</Text>
|
|
||||||
<Text ta="center" my="sm">
|
|
||||||
Dapatkan diskon 20% untuk pembelian pertama
|
|
||||||
</Text>
|
|
||||||
<Button variant="white" color="blue" fullWidth>
|
|
||||||
Klaim Sekarang
|
|
||||||
</Button>
|
|
||||||
</Paper>
|
|
||||||
</Stack>
|
|
||||||
</ClientLayout>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,60 +0,0 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import { MainColor } from "@/app_modules/_global/color";
|
|
||||||
import {
|
|
||||||
Avatar,
|
|
||||||
Button,
|
|
||||||
Center,
|
|
||||||
FileButton,
|
|
||||||
Paper,
|
|
||||||
Stack,
|
|
||||||
} from "@mantine/core";
|
|
||||||
import { IconCamera } from "@tabler/icons-react";
|
|
||||||
import { useState } from "react";
|
|
||||||
import { DIRECTORY_ID } from "../../lib";
|
|
||||||
|
|
||||||
export default function Page() {
|
|
||||||
const [data, setData] = useState({
|
|
||||||
name: "bagas",
|
|
||||||
hobi: [
|
|
||||||
{
|
|
||||||
id: "1",
|
|
||||||
name: "mancing",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "2",
|
|
||||||
name: "game",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<Stack align="center" justify="center" h={"100vh"}>
|
|
||||||
<pre>{JSON.stringify(data, null, 2)}</pre>
|
|
||||||
|
|
||||||
<Button
|
|
||||||
onClick={() => {
|
|
||||||
const newData = [
|
|
||||||
{
|
|
||||||
id: "1",
|
|
||||||
name: "sepedah",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "2",
|
|
||||||
name: "berenang",
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
setData({
|
|
||||||
...data,
|
|
||||||
hobi: newData,
|
|
||||||
});
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Ganti
|
|
||||||
</Button>
|
|
||||||
</Stack>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import { Button } from "@mantine/core";
|
|
||||||
|
|
||||||
interface DownloadButtonProps {
|
|
||||||
fileUrl: string;
|
|
||||||
fileName: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function Coba() {
|
|
||||||
const fileUrl =
|
|
||||||
"https://wibu-storage.wibudev.com/api/pdf-to-image?url=https://wibu-storage.wibudev.com/api/files/cm7liew81000t3y8ax1v6yo02";
|
|
||||||
const fileName = "example.pdf"; // Nama file yang akan diunduh
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
<h1>Download File Example</h1>
|
|
||||||
<DownloadButton fileUrl={fileUrl} fileName={fileName} />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function DownloadButton({ fileUrl, fileName }: DownloadButtonProps) {
|
|
||||||
const handleDownloadFromAPI = async () => {
|
|
||||||
try {
|
|
||||||
const response = await fetch("https://wibu-storage.wibudev.com/api/files/cm7liew81000t3y8ax1v6yo02")
|
|
||||||
const blob = await response.blob(); // Konversi respons ke Blob
|
|
||||||
const url = window.URL.createObjectURL(blob); // Buat URL untuk Blob
|
|
||||||
const link = document.createElement("a");
|
|
||||||
link.href = url;
|
|
||||||
link.download = "generated-file.pdf"; // Nama file yang akan diunduh
|
|
||||||
document.body.appendChild(link);
|
|
||||||
link.click();
|
|
||||||
document.body.removeChild(link);
|
|
||||||
window.URL.revokeObjectURL(url); // Bersihkan URL
|
|
||||||
} catch (error) {
|
|
||||||
console.error("Error downloading file:", error);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Button onClick={handleDownloadFromAPI} variant="outline" color="blue">
|
|
||||||
Download File
|
|
||||||
</Button>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
import Coba from "./_view";
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
async function Page() {
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<Coba />
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default Page;
|
|
||||||
@@ -1,79 +0,0 @@
|
|||||||
/* eslint-disable react-hooks/exhaustive-deps */
|
|
||||||
import React, { useState, useEffect } from "react";
|
|
||||||
|
|
||||||
// Tipe untuk data item (sesuaikan sesuai API kamu)
|
|
||||||
interface Item {
|
|
||||||
id: number;
|
|
||||||
name: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Props komponen
|
|
||||||
interface InfiniteScrollProps<T> {
|
|
||||||
fetchFunction: (page: number) => Promise<T[]>;
|
|
||||||
renderItem: (item: T) => React.ReactNode;
|
|
||||||
itemsPerPage?: number;
|
|
||||||
threshold?: number; // Jarak dari bawah halaman untuk memicu load
|
|
||||||
}
|
|
||||||
|
|
||||||
const InfiniteScroll = <T,>({
|
|
||||||
fetchFunction,
|
|
||||||
renderItem,
|
|
||||||
itemsPerPage = 10,
|
|
||||||
threshold = 50,
|
|
||||||
}: InfiniteScrollProps<T>) => {
|
|
||||||
const [items, setItems] = useState<T[]>([]);
|
|
||||||
const [hasMore, setHasMore] = useState(true);
|
|
||||||
const [page, setPage] = useState(1);
|
|
||||||
|
|
||||||
// Load data awal
|
|
||||||
useEffect(() => {
|
|
||||||
const loadInitialData = async () => {
|
|
||||||
const data = await fetchFunction(page);
|
|
||||||
if (data.length === 0) setHasMore(false);
|
|
||||||
setItems(data);
|
|
||||||
};
|
|
||||||
|
|
||||||
loadInitialData();
|
|
||||||
}, [fetchFunction, page]);
|
|
||||||
|
|
||||||
// Handle scroll event
|
|
||||||
useEffect(() => {
|
|
||||||
const handleScroll = () => {
|
|
||||||
const isBottom =
|
|
||||||
window.innerHeight + window.scrollY >=
|
|
||||||
document.body.offsetHeight - threshold;
|
|
||||||
|
|
||||||
if (isBottom && hasMore) {
|
|
||||||
loadMoreItems();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
window.addEventListener("scroll", handleScroll);
|
|
||||||
return () => window.removeEventListener("scroll", handleScroll);
|
|
||||||
}, [hasMore, threshold]);
|
|
||||||
|
|
||||||
const loadMoreItems = async () => {
|
|
||||||
const nextPage = page + 1;
|
|
||||||
const newItems = await fetchFunction(nextPage);
|
|
||||||
|
|
||||||
if (newItems.length === 0) {
|
|
||||||
setHasMore(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
setItems((prev) => [...prev, ...newItems]);
|
|
||||||
setPage(nextPage);
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div >
|
|
||||||
<ul>
|
|
||||||
{items.map((item, index) => (
|
|
||||||
<li key={index}>{renderItem(item)}</li>
|
|
||||||
))}
|
|
||||||
</ul>
|
|
||||||
{!hasMore && <p>🎉 Semua data telah dimuat.</p>}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default InfiniteScroll;
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
"use client"
|
|
||||||
|
|
||||||
import React, { useState } from "react";
|
|
||||||
import InfiniteScroll from "./_comp/ui_scroll";
|
|
||||||
import { apiGetMessageByRoomId } from "@/app_modules/colab/_lib/api_collaboration";
|
|
||||||
import { ChatMessage } from "@/app/dev/(user)/colab/_comp/interface";
|
|
||||||
|
|
||||||
// Definisikan tipe data
|
|
||||||
interface User {
|
|
||||||
id: number;
|
|
||||||
name: string;
|
|
||||||
email: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Komponen App
|
|
||||||
function App() {
|
|
||||||
const [data, setData] = useState<ChatMessage[]>([]);
|
|
||||||
// Simulasi API call
|
|
||||||
const fetchUsers = async (page: number): Promise<ChatMessage[]> => {
|
|
||||||
const response = await apiGetMessageByRoomId({
|
|
||||||
id: "cmb5x31dt0001tl7y7vj26pfy",
|
|
||||||
});
|
|
||||||
setData(response.data);
|
|
||||||
return response.data;
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div style={{ padding: "20px" }}>
|
|
||||||
<h1>Infinite Scroll with TypeScript</h1>
|
|
||||||
<InfiniteScroll<ChatMessage>
|
|
||||||
fetchFunction={fetchUsers}
|
|
||||||
itemsPerPage={10}
|
|
||||||
threshold={100}
|
|
||||||
renderItem={(item) => (
|
|
||||||
<div style={{ marginBottom: "10px" }}>
|
|
||||||
<strong>{item.User?.Profile?.name}</strong> - {item.message}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default App;
|
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import { ComponentGlobal_CardStyles } from "@/app_modules/_global/component";
|
|
||||||
import {
|
|
||||||
UIGlobal_LayoutHeaderTamplate,
|
|
||||||
UIGlobal_LayoutTamplate,
|
|
||||||
} from "@/app_modules/_global/ui";
|
|
||||||
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
|
|
||||||
import { Button, Center, Grid, Group, Skeleton, Stack } from "@mantine/core";
|
|
||||||
import Link from "next/link";
|
|
||||||
|
|
||||||
export default function Voting_ComponentSkeletonViewPuh() {
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<UIGlobal_LayoutTamplate
|
|
||||||
header={<UIGlobal_LayoutHeaderTamplate title="Skeleton Maker" />}
|
|
||||||
>
|
|
||||||
<Stack>
|
|
||||||
<CustomSkeleton height={300} width={"100%"} />
|
|
||||||
<Center>
|
|
||||||
<CustomSkeleton height={40} radius={"xl"} width={"50%"} />
|
|
||||||
</Center>
|
|
||||||
<CustomSkeleton height={500} width={"100%"} />
|
|
||||||
<CustomSkeleton height={40} radius={"xl"} width={"100%"} />
|
|
||||||
</Stack>
|
|
||||||
|
|
||||||
{/* <Grid align="center">
|
|
||||||
<Grid.Col span={2}>
|
|
||||||
<CustomSkeleton height={40} width={40} circle />
|
|
||||||
</Grid.Col>
|
|
||||||
<Grid.Col span={4}>
|
|
||||||
<CustomSkeleton height={20} width={"100%"} />
|
|
||||||
</Grid.Col>
|
|
||||||
<Grid.Col span={3} offset={3}>
|
|
||||||
<Group position="right">
|
|
||||||
<CustomSkeleton height={20} width={"50%"} />
|
|
||||||
</Group>
|
|
||||||
</Grid.Col>
|
|
||||||
</Grid>
|
|
||||||
|
|
||||||
<Stack>
|
|
||||||
<CustomSkeleton height={20} width={"100%"} radius={"xl"} />
|
|
||||||
<CustomSkeleton height={20} width={"100%"} radius={"xl"} />
|
|
||||||
</Stack> */}
|
|
||||||
|
|
||||||
{/* <Stack spacing={"xl"} p={"sm"}>
|
|
||||||
{Array.from({ length: 4 }).map((_, i) => (
|
|
||||||
<CustomSkeleton key={i} height={50} width={"100%"} />
|
|
||||||
))}
|
|
||||||
<CustomSkeleton height={100} width={"100%"} />
|
|
||||||
<CustomSkeleton radius="xl" height={50} width={"100%"} />
|
|
||||||
</Stack> */}
|
|
||||||
</UIGlobal_LayoutTamplate>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
"use client";
|
|
||||||
import { gs_realtimeData, IRealtimeData } from "@/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";
|
|
||||||
|
|
||||||
export default function Page() {
|
|
||||||
const [dataRealtime, setDataRealtime] = useAtom(gs_realtimeData);
|
|
||||||
|
|
||||||
useShallowEffect(() => {
|
|
||||||
console.log(
|
|
||||||
dataRealtime?.userId == "user2"
|
|
||||||
? console.log("")
|
|
||||||
: console.log(dataRealtime)
|
|
||||||
);
|
|
||||||
}, [dataRealtime]);
|
|
||||||
|
|
||||||
async function onSend() {
|
|
||||||
const newData: IRealtimeData = {
|
|
||||||
appId: v4(),
|
|
||||||
status: "Publish",
|
|
||||||
userId: "user2",
|
|
||||||
pesan: "apa kabar",
|
|
||||||
title: "coba",
|
|
||||||
kategoriApp: "INVESTASI",
|
|
||||||
};
|
|
||||||
|
|
||||||
WibuRealtime.setData({
|
|
||||||
type: "notification",
|
|
||||||
pushNotificationTo: "ADMIN",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Stack p={"md"} align="center" justify="center" h={"80vh"}>
|
|
||||||
<Button
|
|
||||||
onClick={() => {
|
|
||||||
onSend();
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Dari test 2 cuma notif
|
|
||||||
</Button>
|
|
||||||
</Stack>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,140 +0,0 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import { useEditor, EditorContent } from "@tiptap/react";
|
|
||||||
import StarterKit from "@tiptap/starter-kit";
|
|
||||||
import Image from "@tiptap/extension-image";
|
|
||||||
import { useState } from "react";
|
|
||||||
import {
|
|
||||||
Box,
|
|
||||||
Button,
|
|
||||||
Group,
|
|
||||||
Image as MantineImage,
|
|
||||||
Stack,
|
|
||||||
Text,
|
|
||||||
} from "@mantine/core";
|
|
||||||
import Underline from "@tiptap/extension-underline";
|
|
||||||
import { MainColor } from "@/app_modules/_global/color";
|
|
||||||
|
|
||||||
const listStiker = [
|
|
||||||
{
|
|
||||||
id: 2,
|
|
||||||
name: "stiker2",
|
|
||||||
url: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQN9AKmsBY4yqdn3GueJJEVPJbfmf853gDL4cN8uc9eqsCTiJ1fzhcpywzVP68NCJEA5NQ&usqp=CAU",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 3,
|
|
||||||
name: "stiker3",
|
|
||||||
url: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcS2lkV3ZiQ8m-OELSui2JGVy80vnh1cyRUV7NrgFNluPVVs2HUAyCHwCMAKGe2s5jk2sn8&usqp=CAU",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 4,
|
|
||||||
name: "stiker4",
|
|
||||||
url: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQHy9ZdsPc6dHgVTl5yIGpRJ-KtpTIsXA2_kbfO1Oc-pv_f7CNKGxhO56RjKujE3xCyb9k&usqp=CAU",
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
export default function RichTextWithStickers() {
|
|
||||||
const [chat, setChat] = useState<string[]>([]);
|
|
||||||
|
|
||||||
const editor = useEditor({
|
|
||||||
extensions: [
|
|
||||||
StarterKit, // Sudah include Bold, Italic, dll
|
|
||||||
Underline, // Tambahan untuk underline
|
|
||||||
Image,
|
|
||||||
],
|
|
||||||
content: "",
|
|
||||||
});
|
|
||||||
|
|
||||||
const insertSticker = (url: string) => {
|
|
||||||
editor?.chain().focus().setImage({ src: url }).run();
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Stack p="md">
|
|
||||||
<Text fw={700}>Tiptap Editor dengan Stiker Inline</Text>
|
|
||||||
|
|
||||||
<Box
|
|
||||||
style={{
|
|
||||||
border: "1px solid #ccc",
|
|
||||||
borderRadius: 4,
|
|
||||||
padding: 8,
|
|
||||||
minHeight: 150,
|
|
||||||
backgroundColor: MainColor.white,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Group spacing="xs" mb="sm">
|
|
||||||
<Button
|
|
||||||
variant="default"
|
|
||||||
onClick={() => editor?.chain().focus().toggleBold().run()}
|
|
||||||
>
|
|
||||||
B
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
variant="default"
|
|
||||||
onClick={() => editor?.chain().focus().toggleItalic().run()}
|
|
||||||
>
|
|
||||||
I
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
variant="default"
|
|
||||||
onClick={() => editor?.chain().focus().toggleUnderline().run()}
|
|
||||||
>
|
|
||||||
U
|
|
||||||
</Button>
|
|
||||||
</Group>
|
|
||||||
<EditorContent
|
|
||||||
editor={editor}
|
|
||||||
style={{
|
|
||||||
backgroundColor: "white",
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</Box>
|
|
||||||
|
|
||||||
<Button
|
|
||||||
mt="sm"
|
|
||||||
onClick={() => {
|
|
||||||
if (editor) {
|
|
||||||
setChat((prev) => [...prev, editor.getHTML()]);
|
|
||||||
editor.commands.clearContent();
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Kirim
|
|
||||||
</Button>
|
|
||||||
|
|
||||||
<Group>
|
|
||||||
{listStiker.map((item) => (
|
|
||||||
<Box
|
|
||||||
key={item.id}
|
|
||||||
component="button"
|
|
||||||
onClick={() => insertSticker(item.url)}
|
|
||||||
style={{
|
|
||||||
border: "none",
|
|
||||||
background: "transparent",
|
|
||||||
cursor: "pointer",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<MantineImage
|
|
||||||
w={30}
|
|
||||||
h={30}
|
|
||||||
src={item.url}
|
|
||||||
alt={item.name}
|
|
||||||
styles={{
|
|
||||||
image: {
|
|
||||||
width: 30,
|
|
||||||
height: 30,
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</Box>
|
|
||||||
))}
|
|
||||||
</Group>
|
|
||||||
|
|
||||||
{/* <Stack mt="lg" p="md" bg="gray.1">
|
|
||||||
{chat.map((item, index) => (
|
|
||||||
<Box key={index} dangerouslySetInnerHTML={{ __html: item }} />
|
|
||||||
))}
|
|
||||||
</Stack> */}
|
|
||||||
</Stack>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,210 +0,0 @@
|
|||||||
"use client";
|
|
||||||
import React, { useState, useEffect } from "react";
|
|
||||||
import {
|
|
||||||
Box,
|
|
||||||
Button,
|
|
||||||
Group,
|
|
||||||
Image,
|
|
||||||
Paper,
|
|
||||||
ScrollArea,
|
|
||||||
SimpleGrid,
|
|
||||||
Stack,
|
|
||||||
Text,
|
|
||||||
Tooltip,
|
|
||||||
Modal,
|
|
||||||
} from "@mantine/core";
|
|
||||||
import { useDisclosure } from "@mantine/hooks";
|
|
||||||
import dynamic from "next/dynamic";
|
|
||||||
import { MainColor } from "@/app_modules/_global/color";
|
|
||||||
import { listStiker } from "@/app_modules/_global/lib/stiker";
|
|
||||||
|
|
||||||
// Dynamic import ReactQuill dengan SSR disabled
|
|
||||||
const ReactQuill = dynamic(
|
|
||||||
async () => {
|
|
||||||
const { default: RQ } = await import("react-quill");
|
|
||||||
// Tidak perlu import CSS dengan import statement
|
|
||||||
return function comp({ forwardedRef, ...props }: any) {
|
|
||||||
return <RQ ref={forwardedRef} {...props} />;
|
|
||||||
};
|
|
||||||
},
|
|
||||||
{ ssr: false, loading: () => <p>Loading Editor...</p> }
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
type ChatItem = {
|
|
||||||
content: string; // HTML content including text and stickers
|
|
||||||
};
|
|
||||||
|
|
||||||
export default function Page() {
|
|
||||||
const [editorContent, setEditorContent] = useState("");
|
|
||||||
const [chat, setChat] = useState<ChatItem[]>([]);
|
|
||||||
const [opened, { open, close }] = useDisclosure(false);
|
|
||||||
const quillRef = React.useRef<any>(null);
|
|
||||||
const [quillLoaded, setQuillLoaded] = useState(false);
|
|
||||||
|
|
||||||
// Load CSS on client-side only
|
|
||||||
useEffect(() => {
|
|
||||||
// Add Quill CSS via <link> tag
|
|
||||||
const link = document.createElement("link");
|
|
||||||
link.href = "https://cdn.quilljs.com/1.3.6/quill.snow.css";
|
|
||||||
link.rel = "stylesheet";
|
|
||||||
document.head.appendChild(link);
|
|
||||||
|
|
||||||
// Add custom style for stickers inside Quill editor
|
|
||||||
const style = document.createElement("style");
|
|
||||||
style.textContent = `
|
|
||||||
.ql-editor img {
|
|
||||||
max-width: 100px !important;
|
|
||||||
max-height: 100px !important;
|
|
||||||
}
|
|
||||||
.chat-content img {
|
|
||||||
max-width: 70px !important;
|
|
||||||
max-height: 70px !important;
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
document.head.appendChild(style);
|
|
||||||
|
|
||||||
setQuillLoaded(true);
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
// Clean up when component unmounts
|
|
||||||
document.head.removeChild(link);
|
|
||||||
document.head.removeChild(style);
|
|
||||||
};
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
// Custom toolbar options for ReactQuill
|
|
||||||
const modules = {
|
|
||||||
toolbar: [
|
|
||||||
[{ header: [1, 2, false] }],
|
|
||||||
["bold", "italic", "underline", "strike", "blockquote"],
|
|
||||||
[{ list: "ordered" }, { list: "bullet" }],
|
|
||||||
["link", "image"],
|
|
||||||
["clean"],
|
|
||||||
],
|
|
||||||
};
|
|
||||||
|
|
||||||
const formats = [
|
|
||||||
"header",
|
|
||||||
"bold",
|
|
||||||
"italic",
|
|
||||||
"underline",
|
|
||||||
"strike",
|
|
||||||
"blockquote",
|
|
||||||
"list",
|
|
||||||
"bullet",
|
|
||||||
"link",
|
|
||||||
"image",
|
|
||||||
];
|
|
||||||
|
|
||||||
const insertSticker = (stickerUrl: string) => {
|
|
||||||
if (!quillRef.current) return;
|
|
||||||
|
|
||||||
const quill = quillRef.current.getEditor();
|
|
||||||
const range = quill.getSelection(true);
|
|
||||||
|
|
||||||
// Custom image insertion with size
|
|
||||||
// Use custom blot or HTML string with size attributes
|
|
||||||
const stickerHtml = `<img src="${stickerUrl}" alt="sticker" style="width: 40px; height: 40px;">`;
|
|
||||||
|
|
||||||
// Insert HTML at cursor position
|
|
||||||
quill.clipboard.dangerouslyPasteHTML(range.index, stickerHtml);
|
|
||||||
|
|
||||||
// Move cursor after inserted sticker
|
|
||||||
quill.setSelection(range.index + 1, 0);
|
|
||||||
|
|
||||||
// Focus back on editor
|
|
||||||
quill.focus();
|
|
||||||
|
|
||||||
// Close sticker modal
|
|
||||||
close();
|
|
||||||
};
|
|
||||||
|
|
||||||
// Function to send message
|
|
||||||
const sendMessage = () => {
|
|
||||||
if (editorContent.trim() !== "") {
|
|
||||||
setChat((prev) => [...prev, { content: editorContent }]);
|
|
||||||
setEditorContent(""); // Clear after sending
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Stack p={"md"} spacing="md">
|
|
||||||
<SimpleGrid cols={2}>
|
|
||||||
<Stack bg={"gray.1"} h={560} p="md">
|
|
||||||
<Stack>
|
|
||||||
<ScrollArea>
|
|
||||||
{chat.map((item, index) => (
|
|
||||||
<Box key={index} mb="md">
|
|
||||||
<div
|
|
||||||
className="chat-content"
|
|
||||||
dangerouslySetInnerHTML={{ __html: item.content }}
|
|
||||||
/>
|
|
||||||
</Box>
|
|
||||||
))}
|
|
||||||
</ScrollArea>
|
|
||||||
</Stack>
|
|
||||||
</Stack>
|
|
||||||
<Paper withBorder p="md">
|
|
||||||
<Text size="sm" weight={500} mb="xs">
|
|
||||||
Chat Preview Data:
|
|
||||||
</Text>
|
|
||||||
<ScrollArea h={520}>
|
|
||||||
<pre style={{ whiteSpace: "pre-wrap" }}>
|
|
||||||
{JSON.stringify(chat, null, 2)}
|
|
||||||
</pre>
|
|
||||||
</ScrollArea>
|
|
||||||
</Paper>
|
|
||||||
</SimpleGrid>
|
|
||||||
|
|
||||||
<Box w="100%" maw={800}>
|
|
||||||
<Box mb="xs" bg={MainColor.white}>
|
|
||||||
{quillLoaded && (
|
|
||||||
<ReactQuill
|
|
||||||
forwardedRef={quillRef}
|
|
||||||
theme="snow"
|
|
||||||
value={editorContent}
|
|
||||||
onChange={setEditorContent}
|
|
||||||
modules={modules}
|
|
||||||
formats={formats}
|
|
||||||
placeholder="Ketik pesan di sini atau tambahkan stiker..."
|
|
||||||
style={{
|
|
||||||
height: 120,
|
|
||||||
marginBottom: 40,
|
|
||||||
backgroundColor: MainColor.white,
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</Box>
|
|
||||||
|
|
||||||
<Group position="apart">
|
|
||||||
<Button variant="outline" onClick={open} color="blue">
|
|
||||||
Tambah Stiker
|
|
||||||
</Button>
|
|
||||||
|
|
||||||
<Button onClick={sendMessage}>Kirim Pesan</Button>
|
|
||||||
</Group>
|
|
||||||
</Box>
|
|
||||||
|
|
||||||
{/* Sticker Modal */}
|
|
||||||
<Modal opened={opened} onClose={close} title="Pilih Stiker" size="md">
|
|
||||||
<SimpleGrid cols={3} spacing="md">
|
|
||||||
{listStiker.map((item) => (
|
|
||||||
<Box key={item.id}>
|
|
||||||
<Tooltip label={item.name}>
|
|
||||||
<Image
|
|
||||||
src={item.url}
|
|
||||||
height={100}
|
|
||||||
width={100}
|
|
||||||
alt={item.name}
|
|
||||||
style={{ cursor: "pointer" }}
|
|
||||||
onClick={() => insertSticker(item.url)}
|
|
||||||
/>
|
|
||||||
</Tooltip>
|
|
||||||
</Box>
|
|
||||||
))}
|
|
||||||
</SimpleGrid>
|
|
||||||
</Modal>
|
|
||||||
</Stack>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,133 +0,0 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import { MainColor } from "@/app_modules/_global/color";
|
|
||||||
import { ComponentGlobal_BoxUploadImage } from "@/app_modules/_global/component";
|
|
||||||
import { funGlobal_UploadToStorage } from "@/app_modules/_global/fun";
|
|
||||||
import {
|
|
||||||
UIGlobal_LayoutHeaderTamplate,
|
|
||||||
UIGlobal_LayoutTamplate,
|
|
||||||
} from "@/app_modules/_global/ui";
|
|
||||||
import { clientLogger } from "@/util/clientLogger";
|
|
||||||
import {
|
|
||||||
AspectRatio,
|
|
||||||
Button,
|
|
||||||
Center,
|
|
||||||
FileButton,
|
|
||||||
Image,
|
|
||||||
Stack,
|
|
||||||
} from "@mantine/core";
|
|
||||||
import { IconImageInPicture, IconUpload } from "@tabler/icons-react";
|
|
||||||
import { useState } from "react";
|
|
||||||
|
|
||||||
export default function Page() {
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<UIGlobal_LayoutTamplate
|
|
||||||
header={<UIGlobal_LayoutHeaderTamplate title="Upload" />}
|
|
||||||
>
|
|
||||||
<Upload />
|
|
||||||
</UIGlobal_LayoutTamplate>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function Upload() {
|
|
||||||
const [file, setFile] = useState<File | null>(null);
|
|
||||||
const [image, setImage] = useState<any | null>(null);
|
|
||||||
const [isLoading, setLoading] = useState(false);
|
|
||||||
|
|
||||||
async function onUpload() {
|
|
||||||
if (!file) return alert("File Kosong");
|
|
||||||
try {
|
|
||||||
setLoading(true);
|
|
||||||
const formData = new FormData();
|
|
||||||
formData.append("file", file as File);
|
|
||||||
|
|
||||||
const uploadPhoto = await funGlobal_UploadToStorage({
|
|
||||||
file: file,
|
|
||||||
dirId: "cm5ohsepe002bq4nlxeejhg7q",
|
|
||||||
});
|
|
||||||
|
|
||||||
if (uploadPhoto.success) {
|
|
||||||
setLoading(false);
|
|
||||||
alert("berhasil upload");
|
|
||||||
console.log("uploadPhoto", uploadPhoto);
|
|
||||||
} else {
|
|
||||||
setLoading(false);
|
|
||||||
console.log("gagal upload", uploadPhoto);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error("Error upload img:", error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<Stack>
|
|
||||||
<ComponentGlobal_BoxUploadImage>
|
|
||||||
{image ? (
|
|
||||||
<AspectRatio ratio={1 / 1} mt={5} maw={300} mx={"auto"}>
|
|
||||||
<Image style={{ maxHeight: 250 }} alt="Avatar" src={image} />
|
|
||||||
</AspectRatio>
|
|
||||||
) : (
|
|
||||||
<Center h={"100%"}>
|
|
||||||
<IconImageInPicture size={50} />
|
|
||||||
</Center>
|
|
||||||
)}
|
|
||||||
</ComponentGlobal_BoxUploadImage>
|
|
||||||
|
|
||||||
<Center>
|
|
||||||
<FileButton
|
|
||||||
onChange={async (files: any | null) => {
|
|
||||||
try {
|
|
||||||
const buffer = URL.createObjectURL(
|
|
||||||
new Blob([new Uint8Array(await files.arrayBuffer())])
|
|
||||||
);
|
|
||||||
|
|
||||||
// if (files.size > MAX_SIZE) {
|
|
||||||
// ComponentGlobal_NotifikasiPeringatan(
|
|
||||||
// PemberitahuanMaksimalFile
|
|
||||||
// );
|
|
||||||
// return;
|
|
||||||
// } else {
|
|
||||||
|
|
||||||
// }
|
|
||||||
|
|
||||||
console.log("ini buffer", buffer);
|
|
||||||
|
|
||||||
setFile(files);
|
|
||||||
setImage(buffer);
|
|
||||||
} catch (error) {
|
|
||||||
clientLogger.error("Upload error:", error);
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
accept="image/png,image/jpeg"
|
|
||||||
>
|
|
||||||
{(props) => (
|
|
||||||
<Button
|
|
||||||
{...props}
|
|
||||||
radius={"sm"}
|
|
||||||
leftIcon={<IconUpload />}
|
|
||||||
bg={MainColor.yellow}
|
|
||||||
color="yellow"
|
|
||||||
c={"black"}
|
|
||||||
>
|
|
||||||
Upload
|
|
||||||
</Button>
|
|
||||||
)}
|
|
||||||
</FileButton>
|
|
||||||
</Center>
|
|
||||||
|
|
||||||
<Button
|
|
||||||
loaderPosition="center"
|
|
||||||
loading={isLoading}
|
|
||||||
onClick={() => {
|
|
||||||
onUpload();
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Simpan
|
|
||||||
</Button>
|
|
||||||
</Stack>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
"use client";
|
|
||||||
import { Stack } from "@mantine/core";
|
|
||||||
import useSwr from "swr";
|
|
||||||
|
|
||||||
const fether = (url: string) =>
|
|
||||||
fetch("https://jsonplaceholder.typicode.com" + url, {
|
|
||||||
cache: "force-cache",
|
|
||||||
next: {
|
|
||||||
revalidate: 60,
|
|
||||||
},
|
|
||||||
}).then((res) => res.json());
|
|
||||||
|
|
||||||
export default function LoadDataContoh() {
|
|
||||||
const { data, isLoading, error, mutate, isValidating } = useSwr(
|
|
||||||
"/posts/1",
|
|
||||||
fether,
|
|
||||||
{
|
|
||||||
revalidateOnFocus: false,
|
|
||||||
revalidateOnReconnect: false,
|
|
||||||
refreshInterval: 1000,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
return (
|
|
||||||
<Stack>
|
|
||||||
{isLoading && <div>Loading...</div>}
|
|
||||||
LoadDataContoh
|
|
||||||
{JSON.stringify(data, null, 2)}
|
|
||||||
</Stack>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
async function getDataExample() {
|
|
||||||
const res = await fetch("https://jsonplaceholder.typicode.com/posts", {
|
|
||||||
next: {
|
|
||||||
revalidate: 60,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
return res.json();
|
|
||||||
}
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
import { Suspense } from "react";
|
|
||||||
import LoadDataContoh from "./LoadDataContoh";
|
|
||||||
|
|
||||||
const listMenu = [
|
|
||||||
{
|
|
||||||
name: "Dashboard",
|
|
||||||
url: "/dashboard",
|
|
||||||
icon: "dashboard",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Event",
|
|
||||||
url: "/event",
|
|
||||||
icon: "event",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Donasi",
|
|
||||||
url: "/donasi",
|
|
||||||
icon: "donasi",
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
const fether = async (url: string) =>
|
|
||||||
fetch("https://jsonplaceholder.typicode.com" + url, {
|
|
||||||
next: {
|
|
||||||
revalidate: 2,
|
|
||||||
},
|
|
||||||
}).then(async (res) => {
|
|
||||||
const data = await res.json();
|
|
||||||
// console.log(data);
|
|
||||||
return data;
|
|
||||||
});
|
|
||||||
|
|
||||||
export default async function Page() {
|
|
||||||
const data = await fether("/posts/1");
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
{listMenu.map((item) => {
|
|
||||||
return (
|
|
||||||
<div key={item.name}>
|
|
||||||
<a href={item.url}>{item.name}</a>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
{/* <LoadDataContoh /> */}
|
|
||||||
<Suspense fallback={<div>Loading...</div>}>
|
|
||||||
{JSON.stringify(data, null, 2)}
|
|
||||||
</Suspense>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -669,10 +669,8 @@ const limit = pLimit(1);
|
|||||||
export async function generate_seeder() {
|
export async function generate_seeder() {
|
||||||
try {
|
try {
|
||||||
await Promise.all(listSeederQueue.map((fn) => limit(fn)));
|
await Promise.all(listSeederQueue.map((fn) => limit(fn)));
|
||||||
await prisma.$disconnect();
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("error generate seeder", error);
|
console.error("error generate seeder", error);
|
||||||
await prisma.$disconnect();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return { status: 200, success: true };
|
return { status: 200, success: true };
|
||||||
|
|||||||
@@ -37,6 +37,5 @@ export async function AdminDonasi_getOneById(id: string) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
await prisma.$disconnect();
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,12 +33,10 @@ export async function AdminDonasi_funUpdateStatusPublish(
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (!data) {
|
if (!data) {
|
||||||
await prisma.$disconnect();
|
|
||||||
return { status: 400, message: "Data tidak ditemukan" };
|
return { status: 400, message: "Data tidak ditemukan" };
|
||||||
}
|
}
|
||||||
|
|
||||||
revalidatePath(RouterAdminDonasi.table_review);
|
revalidatePath(RouterAdminDonasi.table_review);
|
||||||
await prisma.$disconnect();
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
data: data,
|
data: data,
|
||||||
|
|||||||
@@ -36,12 +36,10 @@ export default async function adminNotifikasi_funCreateToAllUser({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (!create) {
|
if (!create) {
|
||||||
await prisma.$disconnect();
|
|
||||||
return { status: 400, message: "Gagal mengirim notifikasi" };
|
return { status: 400, message: "Gagal mengirim notifikasi" };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await prisma.$disconnect();
|
|
||||||
return {
|
return {
|
||||||
status: 201,
|
status: 201,
|
||||||
message: "Berhasil mengirim notifikasi",
|
message: "Berhasil mengirim notifikasi",
|
||||||
|
|||||||
@@ -25,10 +25,8 @@ export default async function adminNotifikasi_funCreateToUser({
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (!create) {
|
if (!create) {
|
||||||
await prisma.$disconnect();
|
|
||||||
return { status: 400, message: "Gagal mengirim notifikasi" };
|
return { status: 400, message: "Gagal mengirim notifikasi" };
|
||||||
}
|
}
|
||||||
|
|
||||||
await prisma.$disconnect();
|
|
||||||
return { status: 201, message: "Berhasil mengirim notifikasi" };
|
return { status: 201, message: "Berhasil mengirim notifikasi" };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,9 +9,6 @@ export async function donasi_checkStatus({ id }: { id: string }) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
await prisma.$disconnect();
|
|
||||||
|
|
||||||
|
|
||||||
if (checkStatus?.donasiMaster_StatusDonasiId == "2") return true;
|
if (checkStatus?.donasiMaster_StatusDonasiId == "2") return true;
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|||||||
@@ -7,23 +7,22 @@ const sendCodeOtp = async ({
|
|||||||
codeOtp?: string;
|
codeOtp?: string;
|
||||||
newMessage?: string;
|
newMessage?: string;
|
||||||
}) => {
|
}) => {
|
||||||
const msg = newMessage || `HIPMI - Kode ini bersifat RAHASIA dan JANGAN DI BAGIKAN KEPADA SIAPAPUN, termasuk anggota ataupun pengurus HIPMI lainnya.\n\n>> Kode OTP anda: ${codeOtp}.`;
|
const msg =
|
||||||
const enCode = encodeURIComponent(msg);
|
newMessage ||
|
||||||
const res = await fetch(
|
`HIPMI - Kode ini bersifat RAHASIA dan JANGAN DI BAGIKAN KEPADA SIAPAPUN, termasuk anggota ataupun pengurus HIPMI lainnya.\n\n>> Kode OTP anda: ${codeOtp}.`;
|
||||||
`https://cld-dkr-prod-wajs-server.wibudev.com/api/wa/code?nom=${nomor}&text=${enCode}`,
|
const enCode = msg;
|
||||||
{
|
|
||||||
cache: "no-cache",
|
const res = await fetch(`https://otp.wibudev.com/api/wa/send-text`, {
|
||||||
headers: {
|
method: "POST",
|
||||||
Authorization: `Bearer ${process.env.WA_SERVER_TOKEN}`,
|
headers: {
|
||||||
},
|
"Content-Type": "application/json",
|
||||||
|
Authorization: `Bearer ${process.env.WA_SERVER_TOKEN}`,
|
||||||
},
|
},
|
||||||
);
|
body: JSON.stringify({
|
||||||
// const res = await fetch(
|
number: nomor,
|
||||||
// `https://wa.wibudev.com/code?nom=${nomor}&text=HIPMI - Kode ini bersifat RAHASIA dan JANGAN DI BAGIKAN KEPADA SIAPAPUN, termasuk anggota ataupun pengurus HIPMI lainnya.
|
text: enCode,
|
||||||
// \n
|
}),
|
||||||
// >> Kode OTP anda: ${codeOtp}.
|
});
|
||||||
// `,
|
|
||||||
// );
|
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,24 +1,25 @@
|
|||||||
// lib/firebase-admin.ts
|
// lib/firebase-admin.ts
|
||||||
import { cert, getApp, getApps, initializeApp } from 'firebase-admin/app';
|
import { cert, getApp, getApps, initializeApp } from 'firebase-admin/app';
|
||||||
import { getMessaging } from 'firebase-admin/messaging';
|
import { getMessaging, Messaging } from 'firebase-admin/messaging';
|
||||||
|
|
||||||
// Ambil dari environment
|
function getAdminApp() {
|
||||||
const serviceAccount = {
|
if (getApps().length > 0) return getApp();
|
||||||
projectId: process.env.FIREBASE_ADMIN_PROJECT_ID,
|
|
||||||
clientEmail: process.env.FIREBASE_ADMIN_CLIENT_EMAIL,
|
|
||||||
privateKey: process.env.FIREBASE_ADMIN_PRIVATE_KEY?.replace(/\\n/g, '\n'),
|
|
||||||
};
|
|
||||||
|
|
||||||
if (!serviceAccount.projectId || !serviceAccount.clientEmail || !serviceAccount.privateKey) {
|
const privateKey = process.env.FIREBASE_ADMIN_PRIVATE_KEY?.replace(/\\n/g, '\n');
|
||||||
throw new Error('Firebase Admin credentials are missing in environment variables');
|
const projectId = process.env.FIREBASE_ADMIN_PROJECT_ID;
|
||||||
|
const clientEmail = process.env.FIREBASE_ADMIN_CLIENT_EMAIL;
|
||||||
|
|
||||||
|
if (!projectId || !clientEmail || !privateKey) {
|
||||||
|
throw new Error('Firebase Admin credentials are missing in environment variables');
|
||||||
|
}
|
||||||
|
|
||||||
|
return initializeApp({
|
||||||
|
credential: cert({ projectId, clientEmail, privateKey }),
|
||||||
|
projectId,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inisialisasi hanya sekali
|
export const adminMessaging: Pick<Messaging, 'send' | 'sendEachForMulticast'> = {
|
||||||
const app = !getApps().length
|
send: (message) => getMessaging(getAdminApp()).send(message),
|
||||||
? initializeApp({
|
sendEachForMulticast: (message) => getMessaging(getAdminApp()).sendEachForMulticast(message),
|
||||||
credential: cert(serviceAccount),
|
};
|
||||||
projectId: serviceAccount.projectId,
|
|
||||||
})
|
|
||||||
: getApp();
|
|
||||||
|
|
||||||
export const adminMessaging = getMessaging(app);
|
|
||||||
|
|||||||
188
src/lib/prisma-retry.ts
Normal file
188
src/lib/prisma-retry.ts
Normal file
@@ -0,0 +1,188 @@
|
|||||||
|
import { prisma } from './prisma';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retry configuration for database operations
|
||||||
|
*/
|
||||||
|
interface RetryConfig {
|
||||||
|
maxRetries: number;
|
||||||
|
initialDelay: number;
|
||||||
|
maxDelay: number;
|
||||||
|
factor: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
const DEFAULT_RETRY_CONFIG: RetryConfig = {
|
||||||
|
maxRetries: 3,
|
||||||
|
initialDelay: 100,
|
||||||
|
maxDelay: 5000,
|
||||||
|
factor: 2,
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if error is retryable (transient error)
|
||||||
|
*/
|
||||||
|
function isRetryableError(error: any): boolean {
|
||||||
|
const errorMsg = error instanceof Error ? error.message : '';
|
||||||
|
|
||||||
|
// Retry on connection-related errors
|
||||||
|
const retryablePatterns = [
|
||||||
|
'ECONNRESET',
|
||||||
|
'ECONNREFUSED',
|
||||||
|
'ETIMEDOUT',
|
||||||
|
'ENOTFOUND',
|
||||||
|
'connection closed',
|
||||||
|
'connection terminated',
|
||||||
|
'connection timeout',
|
||||||
|
'socket hang up',
|
||||||
|
'too many connections',
|
||||||
|
'pool is full',
|
||||||
|
'server login has been failing',
|
||||||
|
'FATAL:',
|
||||||
|
'PrismaClientUnknownRequestError',
|
||||||
|
];
|
||||||
|
|
||||||
|
return retryablePatterns.some(pattern =>
|
||||||
|
errorMsg.toLowerCase().includes(pattern.toLowerCase())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute database operation with retry mechanism
|
||||||
|
*
|
||||||
|
* @param operation - The database operation to execute
|
||||||
|
* @param config - Retry configuration (optional)
|
||||||
|
* @param operationName - Name of the operation for logging
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* const user = await withRetry(
|
||||||
|
* () => prisma.user.findUnique({ where: { id: '123' } }),
|
||||||
|
* undefined,
|
||||||
|
* 'findUser'
|
||||||
|
* );
|
||||||
|
*/
|
||||||
|
export async function withRetry<T>(
|
||||||
|
operation: () => Promise<T>,
|
||||||
|
config?: Partial<RetryConfig>,
|
||||||
|
operationName?: string
|
||||||
|
): Promise<T> {
|
||||||
|
const retryConfig = { ...DEFAULT_RETRY_CONFIG, ...config };
|
||||||
|
let lastError: any;
|
||||||
|
|
||||||
|
for (let attempt = 1; attempt <= retryConfig.maxRetries; attempt++) {
|
||||||
|
try {
|
||||||
|
const result = await operation();
|
||||||
|
|
||||||
|
// Log success if it was a retry
|
||||||
|
if (attempt > 1 && operationName) {
|
||||||
|
console.log(`✅ [DB-RETRY] ${operationName} succeeded after ${attempt} attempts`);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
} catch (error) {
|
||||||
|
lastError = error;
|
||||||
|
const errorMsg = error instanceof Error ? error.message : 'Unknown error';
|
||||||
|
|
||||||
|
// Check if we should retry
|
||||||
|
if (attempt < retryConfig.maxRetries && isRetryableError(error)) {
|
||||||
|
// Calculate delay with exponential backoff + jitter
|
||||||
|
const delay = Math.min(
|
||||||
|
retryConfig.initialDelay * Math.pow(retryConfig.factor, attempt - 1),
|
||||||
|
retryConfig.maxDelay
|
||||||
|
);
|
||||||
|
const jitter = Math.random() * 0.3 * delay; // Add 30% jitter
|
||||||
|
|
||||||
|
if (operationName) {
|
||||||
|
console.warn(
|
||||||
|
`⚠️ [DB-RETRY] ${operationName} failed (attempt ${attempt}/${retryConfig.maxRetries}): ${errorMsg}`
|
||||||
|
);
|
||||||
|
console.log(`⏳ [DB-RETRY] Retrying in ${Math.round(delay + jitter)}ms...`);
|
||||||
|
}
|
||||||
|
|
||||||
|
await new Promise(resolve => setTimeout(resolve, delay + jitter));
|
||||||
|
} else {
|
||||||
|
// Don't retry - either max retries reached or not a retryable error
|
||||||
|
if (operationName) {
|
||||||
|
console.error(
|
||||||
|
`❌ [DB-RETRY] ${operationName} failed after ${attempt} attempts: ${errorMsg}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// All retries exhausted, throw the last error
|
||||||
|
throw lastError;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute database operation with timeout
|
||||||
|
*
|
||||||
|
* @param operation - The database operation to execute
|
||||||
|
* @param timeout - Timeout in milliseconds (default: 30000)
|
||||||
|
* @param operationName - Name of the operation for logging
|
||||||
|
*/
|
||||||
|
export async function withTimeout<T>(
|
||||||
|
operation: () => Promise<T>,
|
||||||
|
timeout: number = 30000,
|
||||||
|
operationName?: string
|
||||||
|
): Promise<T> {
|
||||||
|
const timeoutPromise = new Promise<never>((_, reject) => {
|
||||||
|
setTimeout(() => {
|
||||||
|
reject(new Error(`Operation timed out after ${timeout}ms`));
|
||||||
|
}, timeout);
|
||||||
|
});
|
||||||
|
|
||||||
|
try {
|
||||||
|
return await Promise.race([operation(), timeoutPromise]);
|
||||||
|
} catch (error) {
|
||||||
|
const errorMsg = error instanceof Error ? error.message : 'Unknown error';
|
||||||
|
if (errorMsg.includes('timed out')) {
|
||||||
|
if (operationName) {
|
||||||
|
console.error(`⏱️ [DB-TIMEOUT] ${operationName} timed out after ${timeout}ms`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Combine retry and timeout for robust database operations
|
||||||
|
*
|
||||||
|
* @param operation - The database operation to execute
|
||||||
|
* @param options - Retry and timeout options
|
||||||
|
* @param operationName - Name of the operation for logging
|
||||||
|
*/
|
||||||
|
export async function withRetryAndTimeout<T>(
|
||||||
|
operation: () => Promise<T>,
|
||||||
|
options?: {
|
||||||
|
retry?: Partial<RetryConfig>;
|
||||||
|
timeout?: number;
|
||||||
|
},
|
||||||
|
operationName?: string
|
||||||
|
): Promise<T> {
|
||||||
|
return withRetry(
|
||||||
|
() => withTimeout(operation, options?.timeout, operationName),
|
||||||
|
options?.retry,
|
||||||
|
operationName
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Health check for database connection
|
||||||
|
*/
|
||||||
|
export async function checkDatabaseConnection(): Promise<boolean> {
|
||||||
|
try {
|
||||||
|
await withTimeout(
|
||||||
|
() => prisma.$queryRaw`SELECT 1`,
|
||||||
|
5000,
|
||||||
|
'healthCheck'
|
||||||
|
);
|
||||||
|
return true;
|
||||||
|
} catch (error) {
|
||||||
|
const errorMsg = error instanceof Error ? error.message : 'Unknown error';
|
||||||
|
console.error('❌ [DB-HEALTH] Database connection check failed:', errorMsg);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export { prisma };
|
||||||
@@ -1,54 +1,54 @@
|
|||||||
import { PrismaClient } from "@prisma/client";
|
import { PrismaClient } from "@prisma/client";
|
||||||
|
|
||||||
// Deklarasikan variabel global untuk menandai apakah listener sudah ditambahkan
|
/**
|
||||||
|
* Instance global Prisma client untuk connection pooling
|
||||||
|
* Menggunakan pattern globalThis untuk mencegah multiple instance selama:
|
||||||
|
* - Hot module replacement (HMR) di development
|
||||||
|
* - Multiple import di seluruh aplikasi
|
||||||
|
* - Server-side rendering di Next.js
|
||||||
|
*/
|
||||||
declare global {
|
declare global {
|
||||||
var prisma: PrismaClient;
|
// eslint-disable-next-line no-var
|
||||||
var prismaListenersAdded: boolean; // Flag untuk menandai listener
|
var prisma: PrismaClient | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
let prisma: PrismaClient;
|
// Konfigurasi connection pool via parameter query DATABASE_URL:
|
||||||
|
// connection_limit=10&pool_timeout=20&connect_timeout=10
|
||||||
if (process.env.NODE_ENV === "production") {
|
const prisma =
|
||||||
prisma = new PrismaClient({
|
globalThis.prisma ??
|
||||||
// Reduce logging in production to improve performance
|
new PrismaClient({
|
||||||
log: ['error', 'warn'],
|
log:
|
||||||
|
process.env.NODE_ENV === "development"
|
||||||
|
? ["error", "warn"]
|
||||||
|
: ["error"],
|
||||||
datasources: {
|
datasources: {
|
||||||
db: {
|
db: {
|
||||||
url: process.env.DATABASE_URL,
|
url: process.env.DATABASE_URL,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
if (!global.prisma) {
|
// Hanya assign ke global di development untuk mencegah multiple instance saat HMR
|
||||||
global.prisma = new PrismaClient({
|
// Di production, ini di-skip karena tidak ada HMR
|
||||||
log: ['error', 'warn', 'info', 'query'], // More verbose logging in development
|
if (process.env.NODE_ENV !== "production") {
|
||||||
datasources: {
|
globalThis.prisma = prisma;
|
||||||
db: {
|
|
||||||
url: process.env.DATABASE_URL,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
prisma = global.prisma;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tambahkan listener hanya jika belum ditambahkan sebelumnya
|
/**
|
||||||
if (!global.prismaListenersAdded) {
|
* Handler graceful shutdown untuk koneksi Prisma
|
||||||
// Handle graceful shutdown
|
* Panggil ini HANYA saat terminasi process (SIGINT/SIGTERM)
|
||||||
process.on("SIGINT", async () => {
|
* JANGAN panggil $disconnect() setelah query individual
|
||||||
console.log("Received SIGINT signal. Closing database connections...");
|
*/
|
||||||
await prisma.$disconnect();
|
async function gracefulShutdown(): Promise<void> {
|
||||||
process.exit(0);
|
console.log("[Prisma] Menutup koneksi database...");
|
||||||
});
|
await prisma.$disconnect();
|
||||||
|
console.log("[Prisma] Semua koneksi ditutup");
|
||||||
|
}
|
||||||
|
|
||||||
process.on("SIGTERM", async () => {
|
// Register shutdown handlers (hanya di environment Node.js)
|
||||||
console.log("Received SIGTERM signal. Closing database connections...");
|
if (typeof process !== "undefined") {
|
||||||
await prisma.$disconnect();
|
process.on("SIGINT", gracefulShutdown);
|
||||||
process.exit(0);
|
process.on("SIGTERM", gracefulShutdown);
|
||||||
});
|
|
||||||
|
|
||||||
// Tandai bahwa listener sudah ditambahkan
|
|
||||||
global.prismaListenersAdded = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default prisma;
|
export default prisma;
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ const CONFIG: MiddlewareConfig = {
|
|||||||
"/auth/api/login",
|
"/auth/api/login",
|
||||||
"/waiting-room",
|
"/waiting-room",
|
||||||
"/zCoba/*",
|
"/zCoba/*",
|
||||||
|
"/event/*/confirmation",
|
||||||
"/aset/global/main_background.png",
|
"/aset/global/main_background.png",
|
||||||
"/aset/logo/logo-hipmi.png",
|
"/aset/logo/logo-hipmi.png",
|
||||||
"/aset/logo/hiconnect.png",
|
"/aset/logo/hiconnect.png",
|
||||||
@@ -66,10 +67,6 @@ export const middleware = async (req: NextRequest) => {
|
|||||||
const { pathname } = req.nextUrl;
|
const { pathname } = req.nextUrl;
|
||||||
|
|
||||||
const apiBaseUrl = process.env.NEXT_PUBLIC_API_URL || new URL(req.url).origin;
|
const apiBaseUrl = process.env.NEXT_PUBLIC_API_URL || new URL(req.url).origin;
|
||||||
// Removed excessive logging that was causing high CPU usage
|
|
||||||
// const dbUrl = process.env.DATABASE_URL;
|
|
||||||
// console.log("DATABASE_URL >>", dbUrl);
|
|
||||||
// console.log("URL Access >>", req.url);
|
|
||||||
|
|
||||||
// Handle CORS preflight
|
// Handle CORS preflight
|
||||||
const corsResponse = handleCors(req);
|
const corsResponse = handleCors(req);
|
||||||
|
|||||||
204
zCoba.js
204
zCoba.js
@@ -1,204 +0,0 @@
|
|||||||
const { PrismaClient } = require('@prisma/client')
|
|
||||||
const axios = require('axios')
|
|
||||||
|
|
||||||
const prisma = new PrismaClient()
|
|
||||||
|
|
||||||
// Daftar contoh data
|
|
||||||
const donationDataList = [
|
|
||||||
{
|
|
||||||
"data": {
|
|
||||||
"authorId": "cmha6wb9w0001cfndwl9fcse6",
|
|
||||||
"title": "Bantuan Pendidikan Anak-anak Kurang Mampu",
|
|
||||||
"target": 50000000,
|
|
||||||
"donasiMaster_DurasiId": 3,
|
|
||||||
"donasiMaster_KategoriId": 3,
|
|
||||||
"namaBank": "Bank Central Asia",
|
|
||||||
"rekening": "1234567890",
|
|
||||||
"imageId": "cm60j9q3m000xc9dc584v8rh8",
|
|
||||||
"pembukaan": "Kami ingin membantu anak-anak kurang mampu mendapatkan pendidikan yang layak.",
|
|
||||||
"cerita": "Pendidikan adalah hak dasar setiap anak. Namun, banyak anak-anak di pelosok negeri yang tidak bisa menikmati pendidikan karena keterbatasan ekonomi. Melalui kampanye ini, kami ingin mengumpulkan dana untuk membantu biaya pendidikan mereka.",
|
|
||||||
"imageCeritaId": "cm60j9q3m000xc9dc584v8rj0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"data": {
|
|
||||||
"authorId": "cmha6wb9w0001cfndwl9fcse6",
|
|
||||||
"title": "Pembangunan Masjid di Desa Terpencil",
|
|
||||||
"target": 100000000,
|
|
||||||
"donasiMaster_DurasiId": 3,
|
|
||||||
"donasiMaster_KategoriId": 3,
|
|
||||||
"namaBank": "Bank Mandiri",
|
|
||||||
"rekening": "0987654321",
|
|
||||||
"imageId": "cm60j9q3m000xc9dc584v8rh8",
|
|
||||||
"pembukaan": "Membangun masjid untuk masyarakat di daerah terpencil yang belum memiliki tempat ibadah.",
|
|
||||||
"cerita": "Di sebuah desa terpencil, masyarakat setiap hari harus berjalan jauh untuk bisa melaksanakan sholat berjamaah. Kami ingin membantu membangun masjid di tengah-tengah mereka agar ibadah bisa dilakukan dengan lebih tenang dan khusyuk.",
|
|
||||||
"imageCeritaId": "cm60j9q3m000xc9dc584v8rj1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"data": {
|
|
||||||
"authorId": "cmha6wb9w0001cfndwl9fcse6",
|
|
||||||
"title": "Bantuan Korban Bencana Alam",
|
|
||||||
"target": 75000000,
|
|
||||||
"donasiMaster_DurasiId": 3,
|
|
||||||
"donasiMaster_KategoriId": 3,
|
|
||||||
"namaBank": "Bank Rakyat Indonesia",
|
|
||||||
"rekening": "5678901234",
|
|
||||||
"imageId": "cm60j9q3m000xc9dc584v8rh8",
|
|
||||||
"pembukaan": "Membantu meringankan beban korban bencana alam berupa kebutuhan pokok dan kebutuhan darurat.",
|
|
||||||
"cerita": "Beberapa wilayah dilanda bencana banjir dan tanah longsor. Masyarakat kehilangan harta benda dan membutuhkan bantuan segera. Dana yang terkumpul akan digunakan untuk menyediakan makanan, obat-obatan, dan kebutuhan pokok lainnya.",
|
|
||||||
"imageCeritaId": "cm60j9q3m000xc9dc584v8rj2"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"data": {
|
|
||||||
"authorId": "cmha6wb9w0001cfndwl9fcse6",
|
|
||||||
"title": "Pengadaan Alat Medis Rumah Sakit",
|
|
||||||
"target": 150000000,
|
|
||||||
"donasiMaster_DurasiId": 3,
|
|
||||||
"donasiMaster_KategoriId": 3,
|
|
||||||
"namaBank": "Bank Negara Indonesia",
|
|
||||||
"rekening": "4321098765",
|
|
||||||
"imageId": "cm60j9q3m000xc9dc584v8rh8",
|
|
||||||
"pembukaan": "Meningkatkan kualitas pelayanan kesehatan dengan menyediakan alat medis yang lebih baik.",
|
|
||||||
"cerita": "Rumah sakit daerah kekurangan alat medis untuk melayani pasien. Melalui donasi ini, kami ingin membantu pengadaan alat-alat medis penting seperti ventilator, USG, dan alat laboratorium untuk meningkatkan kualitas pelayanan kesehatan.",
|
|
||||||
"imageCeritaId": "cm60j9q3m000xc9dc584v8rj3"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"data": {
|
|
||||||
"authorId": "cmha6wb9w0001cfndwl9fcse6",
|
|
||||||
"title": "Program Beasiswa Mahasiswa Berprestasi",
|
|
||||||
"target": 80000000,
|
|
||||||
"donasiMaster_DurasiId": 3,
|
|
||||||
"donasiMaster_KategoriId": 3,
|
|
||||||
"namaBank": "Bank Danamon",
|
|
||||||
"rekening": "1122334455",
|
|
||||||
"imageId": "cm60j9q3m000xc9dc584v8rh8",
|
|
||||||
"pembukaan": "Memberikan kesempatan kepada mahasiswa berprestasi untuk melanjutkan pendidikan tanpa beban biaya.",
|
|
||||||
"cerita": "Banyak mahasiswa berprestasi yang tidak mampu melanjutkan pendidikan karena keterbatasan biaya. Program beasiswa ini akan membantu mereka menyelesaikan kuliah hingga sarjana.",
|
|
||||||
"imageCeritaId": "cm60j9q3m000xc9dc584v8rj4"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"data": {
|
|
||||||
"authorId": "cmha6wb9w0001cfndwl9fcse6",
|
|
||||||
"title": "Pengadaan Air Bersih untuk Desa Kekeringan",
|
|
||||||
"target": 60000000,
|
|
||||||
"donasiMaster_DurasiId": 3,
|
|
||||||
"donasiMaster_KategoriId": 3,
|
|
||||||
"namaBank": "Bank Permata",
|
|
||||||
"rekening": "6677889900",
|
|
||||||
"imageId": "cm60j9q3m000xc9dc584v8rh8",
|
|
||||||
"pembukaan": "Menyediakan akses air bersih bagi masyarakat yang tinggal di daerah rawan kekeringan.",
|
|
||||||
"cerita": "Beberapa desa mengalami kekeringan setiap tahunnya, membuat warga kesulitan mendapatkan air bersih. Kami ingin membangun sumur bor dan sistem distribusi air untuk membantu masyarakat setempat.",
|
|
||||||
"imageCeritaId": "cm60j9q3m000xc9dc584v8rj5"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"data": {
|
|
||||||
"authorId": "cmha6wb9w0001cfndwl9fcse6",
|
|
||||||
"title": "Pengobatan Gratis untuk Warga Tidak Mampu",
|
|
||||||
"target": 40000000,
|
|
||||||
"donasiMaster_DurasiId": 3,
|
|
||||||
"donasiMaster_KategoriId": 3,
|
|
||||||
"namaBank": "Bank Panin",
|
|
||||||
"rekening": "9988776655",
|
|
||||||
"imageId": "cm60j9q3m000xc9dc584v8rh8",
|
|
||||||
"pembukaan": "Memberikan layanan kesehatan gratis bagi warga yang tidak mampu membayar biaya pengobatan.",
|
|
||||||
"cerita": "Banyak warga yang menunda pengobatan karena keterbatasan biaya. Melalui program ini, kami akan menyelenggarakan pengobatan gratis secara berkala di berbagai wilayah.",
|
|
||||||
"imageCeritaId": "cm60j9q3m000xc9dc584v8rj6"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"data": {
|
|
||||||
"authorId": "cmha6wb9w0001cfndwl9fcse6",
|
|
||||||
"title": "Pembangunan Taman Bacaan Masyarakat",
|
|
||||||
"target": 35000000,
|
|
||||||
"donasiMaster_DurasiId": 3,
|
|
||||||
"donasiMaster_KategoriId": 3,
|
|
||||||
"namaBank": "Bank Mega",
|
|
||||||
"rekening": "1357924680",
|
|
||||||
"imageId": "cm60j9q3m000xc9dc584v8rh8",
|
|
||||||
"pembukaan": "Membangun taman bacaan untuk meningkatkan minat baca masyarakat di wilayah pedesaan.",
|
|
||||||
"cerita": "Minat baca masyarakat di pedesaan masih rendah karena keterbatasan akses buku. Taman bacaan ini akan menyediakan ribuan buku gratis dan ruang baca yang nyaman untuk semua usia.",
|
|
||||||
"imageCeritaId": "cm60j9q3m000xc9dc584v8rj7"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"data": {
|
|
||||||
"authorId": "cmha6wb9w0001cfndwl9fcse6",
|
|
||||||
"title": "Pelatihan Keterampilan untuk Pengangguran",
|
|
||||||
"target": 55000000,
|
|
||||||
"donasiMaster_DurasiId": 3,
|
|
||||||
"donasiMaster_KategoriId": 3,
|
|
||||||
"namaBank": "Bank CIMB Niaga",
|
|
||||||
"rekening": "2468135790",
|
|
||||||
"imageId": "cm60j9q3m000xc9dc584v8rh8",
|
|
||||||
"pembukaan": "Memberikan pelatihan keterampilan untuk membantu pengangguran mendapatkan pekerjaan atau usaha mandiri.",
|
|
||||||
"cerita": "Angka pengangguran masih tinggi di beberapa wilayah. Program pelatihan ini akan memberikan keterampilan yang dibutuhkan pasar kerja, seperti menjahit, memasak, teknologi informasi, dan lainnya.",
|
|
||||||
"imageCeritaId": "cm60j9q3m000xc9dc584v8rj8"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"data": {
|
|
||||||
"authorId": "cmha6wb9w0001cfndwl9fcse6",
|
|
||||||
"title": "Renovasi Gedung Sekolah Rusak",
|
|
||||||
"target": 90000000,
|
|
||||||
"donasiMaster_DurasiId": 3,
|
|
||||||
"donasiMaster_KategoriId": 3,
|
|
||||||
"namaBank": "Bank OCBC NISP",
|
|
||||||
"rekening": "1029384756",
|
|
||||||
"imageId": "cm60j9q3m000xc9dc584v8rh8",
|
|
||||||
"pembukaan": "Merestrukturasi gedung sekolah yang rusak agar siswa bisa belajar dengan aman dan nyaman.",
|
|
||||||
"cerita": "Banyak gedung sekolah yang rusak parah dan membahayakan keselamatan siswa. Dana dari kampanye ini akan digunakan untuk renovasi dan perbaikan gedung sekolah yang membutuhkan.",
|
|
||||||
"imageCeritaId": "cm60j9q3m000xc9dc584v8rj9"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
async function sendDonationData() {
|
|
||||||
const baseUrl = 'http://localhost:3000/api/mobile/donation'; // Sesuaikan dengan URL server Anda
|
|
||||||
const headers = {
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
};
|
|
||||||
|
|
||||||
for (let i = 0; i < donationDataList.length; i++) {
|
|
||||||
try {
|
|
||||||
console.log(`Mengirim data ke-${i + 1}...`);
|
|
||||||
const response = await axios.post(`${baseUrl}?category=permanent`, donationDataList[i], {
|
|
||||||
headers: headers
|
|
||||||
});
|
|
||||||
console.log(`Data ke-${i + 1} berhasil dikirim:`, response.data);
|
|
||||||
} catch (error) {
|
|
||||||
console.error(`Error saat mengirim data ke-${i + 1}:`, error.response?.data || error.message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function main() {
|
|
||||||
// Menjalankan fungsi untuk mengirim data donasi
|
|
||||||
await sendDonationData();
|
|
||||||
|
|
||||||
// Fungsi asli untuk update notifikasi
|
|
||||||
const result = await prisma.notifikasi.updateMany({
|
|
||||||
where: {
|
|
||||||
recipientId: 'cmha7p6yc0000cfoe5w2e7gdr',
|
|
||||||
},
|
|
||||||
data: {
|
|
||||||
isRead: false,
|
|
||||||
readAt: null,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
console.log(`✅ Rows affected: ${result.count}`)
|
|
||||||
}
|
|
||||||
|
|
||||||
main()
|
|
||||||
.catch((err) => {
|
|
||||||
console.error('❌ Error:', err)
|
|
||||||
process.exit(1)
|
|
||||||
})
|
|
||||||
.finally(async () => {
|
|
||||||
await prisma.$disconnect()
|
|
||||||
})
|
|
||||||
Reference in New Issue
Block a user