Compare commits
83 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 | |||
| 58e1afaa45 | |||
| f65f9b7834 | |||
| 250b7c5261 | |||
| 935e519662 | |||
| 36b9248ed7 | |||
| c6dbd152d5 | |||
| 714cf5cd5a | |||
| a2c5f053da | |||
| a68343599d | |||
| 419b87fc92 | |||
| bedc0cc88b | |||
| 0271c87ba9 | |||
| a9fbd544e5 | |||
| 5551f30721 | |||
| 00d36454d1 | |||
| a762fbe9b1 | |||
| a98ab18423 | |||
| 9afd741d4f | |||
| 1c227a2850 | |||
| 817919f8f7 | |||
| 5bdb998d2e | |||
| 90031e23ef | |||
| b585aa3024 | |||
| 596ebd2ff4 | |||
| a8f9d2ac0d | |||
| d43f3762a3 | |||
| aa700523ca | |||
| e89886e1db | |||
| 236ab4d4a4 | |||
| 934d6a3ef1 | |||
| a7694bd7d5 | |||
| eaa7692359 | |||
| 3b0ea3d847 | |||
| 097758a431 | |||
| d51ce346e6 | |||
| 6f5849aa29 | |||
| 91f4bb6c9e | |||
| 6aceb212e4 | |||
| 42803f9b92 | |||
| 1fe0001994 | |||
| 2a857f54e7 | |||
| b82a283731 | |||
| bb79a68f44 | |||
| f103ae93ad | |||
| 1c9459dcf3 | |||
| 8b54f5ca65 | |||
| 6d7d0fd07e | |||
| c94da645f3 | |||
| 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
|
||||||
52
CHANGELOG.md
52
CHANGELOG.md
@@ -2,6 +2,58 @@
|
|||||||
|
|
||||||
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.3](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.6.2...v1.6.3) (2026-03-03)
|
||||||
|
|
||||||
|
## [1.6.2](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.6.1...v1.6.2) (2026-02-25)
|
||||||
|
|
||||||
|
## [1.6.1](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.6.0...v1.6.1) (2026-02-25)
|
||||||
|
|
||||||
|
## [1.6.0](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.5.40...v1.6.0) (2026-02-23)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* Implementasi pagination pada endpoint mobile donation ([e89886e](https://wibugit.wibudev.com/wibu/hipmi/commit/e89886e1dbc8cb4d95e6cc7c2787fb22a1dcaf56))
|
||||||
|
* Tambahkan pagination pada API mobile investasi ([a7694bd](https://wibugit.wibudev.com/wibu/hipmi/commit/a7694bd7d5d72b6499443faf99301faca730d3ed))
|
||||||
|
* update mobile donation API and related dependencies ([934d6a3](https://wibugit.wibudev.com/wibu/hipmi/commit/934d6a3ef1015367bee85779796df4f11c5e779c))
|
||||||
|
|
||||||
|
## [1.5.40](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.5.39...v1.5.40) (2026-02-06)
|
||||||
|
|
||||||
|
## [1.5.39](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.5.38...v1.5.39) (2026-01-30)
|
||||||
|
|
||||||
## [1.5.38](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.5.37...v1.5.38) (2026-01-27)
|
## [1.5.38](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.5.37...v1.5.38) (2026-01-27)
|
||||||
|
|
||||||
## [1.5.37](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.5.36...v1.5.37) (2026-01-23)
|
## [1.5.37](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.5.36...v1.5.37) (2026-01-23)
|
||||||
|
|||||||
39
CHANGELOG_COMMIT.md
Normal file
39
CHANGELOG_COMMIT.md
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
## Catatan Perubahan untuk Commit
|
||||||
|
|
||||||
|
### Fitur: Penambahan Pagination pada Endpoint Admin Mobile
|
||||||
|
|
||||||
|
#### Deskripsi Umum
|
||||||
|
Telah dilakukan penambahan fitur pagination pada beberapa endpoint admin mobile untuk meningkatkan kinerja dan pengalaman pengguna saat mengakses data dalam jumlah besar.
|
||||||
|
|
||||||
|
#### File yang Diubah
|
||||||
|
|
||||||
|
1. **src/app/api/mobile/admin/job/route.ts**
|
||||||
|
- Ditambahkan parameter `page` dari `searchParams`
|
||||||
|
- Diterapkan logika pagination dengan `takeData` (default 10) dan `skipData`
|
||||||
|
- Query `prisma.job.findMany` telah dimodifikasi untuk mendukung pagination
|
||||||
|
|
||||||
|
2. **src/app/api/mobile/admin/event/route.ts**
|
||||||
|
- Diperbaiki definisi variabel `page` untuk memastikan tipe data yang konsisten
|
||||||
|
- Ditambahkan default value 1 untuk parameter `page`
|
||||||
|
- Perhitungan `skipData` disesuaikan agar lebih efisien
|
||||||
|
|
||||||
|
3. **src/app/api/mobile/admin/event/[id]/participants/route.ts**
|
||||||
|
- Ditambahkan parameter `page` dari `searchParams`
|
||||||
|
- Diterapkan logika pagination dengan `takeData` (default 10) dan `skipData`
|
||||||
|
- Query `prisma.event_Peserta.findMany` telah dimodifikasi untuk mendukung pagination
|
||||||
|
|
||||||
|
#### Tujuan Perubahan
|
||||||
|
- Meningkatkan kinerja aplikasi saat mengambil data dalam jumlah besar
|
||||||
|
- Memungkinkan pengguna untuk mengakses data secara bertahap melalui halaman-halaman
|
||||||
|
- Mengurangi beban server saat mengambil data dalam jumlah besar
|
||||||
|
- Memberikan pengalaman pengguna yang lebih baik saat mengakses data admin
|
||||||
|
|
||||||
|
#### Cara Penggunaan
|
||||||
|
Untuk menggunakan fitur pagination, cukup tambahkan parameter `page` pada query string saat melakukan permintaan ke endpoint yang telah dimodifikasi. Contoh:
|
||||||
|
```
|
||||||
|
GET /api/mobile/admin/job?page=2
|
||||||
|
GET /api/mobile/admin/event?page=3
|
||||||
|
GET /api/mobile/admin/event/{id}/participants?page=1
|
||||||
|
```
|
||||||
|
|
||||||
|
Default jumlah data per halaman adalah 10 item.
|
||||||
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"]
|
||||||
45
PROMPT-AI.md
Normal file
45
PROMPT-AI.md
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
|
||||||
|
File utama: src/app/api/mobile/admin/forum/[id]/comment/route.ts
|
||||||
|
|
||||||
|
Terapkan pagination pada file "File utama" pada method GET
|
||||||
|
Analisa juga file "File utama", jika belum memiliki page dari seachParams maka terapkan. Juga pastikan take dan skip sudah sesuai dengan pagination. Buat default nya menjadi 10 untuk take data
|
||||||
|
|
||||||
|
Contoh:
|
||||||
|
const page = Number(searchParams.get("page"));
|
||||||
|
const takeData = 10;
|
||||||
|
const skipData = page * takeData - takeData;
|
||||||
|
|
||||||
|
dan penerapannya pada query
|
||||||
|
take: page ? takeData : undefined,
|
||||||
|
skip: page ? skipData : undefined,
|
||||||
|
|
||||||
|
Gunakan bahasa indonesia pada cli agar saya mudah membacanya.
|
||||||
|
|
||||||
|
<!-- Additinal prompt -->
|
||||||
|
File refrensi: src/app/api/mobile/event/[id]/[status]/route.ts
|
||||||
|
Anda bisa menggunakan refrensi dari "File refrensi" jika butuh pemahaman dengan tipe fitur yang sama
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Auto input promt -->
|
||||||
|
End-point: src/app/api/mobile/donation/route.ts
|
||||||
|
|
||||||
|
Buatkan auto input untuk method POST dengan data yang dibutuhkan sesuai dengan struktur data yang ada di file tersebut, tidak perlu "temporary" cukup data "permanent" dengan ketentuan sebagai berikut:
|
||||||
|
- authorId: string ( cmha6wb9w0001cfndwl9fcse6 )
|
||||||
|
- title: string
|
||||||
|
- target: number
|
||||||
|
- donasiMaster_DurasiId: number ( 3 )
|
||||||
|
- donasiMaster_KategoriId: number ( 3 )
|
||||||
|
- namaBank: string
|
||||||
|
- rekening: string
|
||||||
|
- imageId: number ( cm60j9q3m000xc9dc584v8rh8 )
|
||||||
|
|
||||||
|
Untuk sisa nya anda bisa bebas mengisi data tersebut.
|
||||||
|
|
||||||
|
<!-- COMMIT & PUSH -->
|
||||||
|
Branch: mobile-api/10-feb-26
|
||||||
|
Jalankan perintah ini: git checkout -b "Branch"
|
||||||
|
Setelah itu jalankan perintah ini: git add .
|
||||||
|
Setelah itu jalankan perintah ini: git commit -m "
|
||||||
|
<Berikan semua catatan perubahan pada branch ini, tampilan pada saya dan pastikan dalam bahasa indonesia. Saya akan cek baru saya akan berikan perintah push>
|
||||||
|
"
|
||||||
|
Setelah itu jalankan perintah ini: git push origin "Branch"
|
||||||
249
QWEN.md
Normal file
249
QWEN.md
Normal file
@@ -0,0 +1,249 @@
|
|||||||
|
# HIPMI Project - QWEN.md
|
||||||
|
|
||||||
|
## Project Overview
|
||||||
|
|
||||||
|
HIPMI (Himpunan Pengusaha Muya Indonesia) is a comprehensive Next.js-based web application built for the Indonesian Young Entrepreneurs Association. The project is a sophisticated platform that provides multiple business functionalities including investment management, donations, events, job listings, forums, voting systems, and collaborative projects.
|
||||||
|
|
||||||
|
### Key Technologies
|
||||||
|
- **Framework**: Next.js 13+ (with App Router)
|
||||||
|
- **Language**: TypeScript
|
||||||
|
- **Database**: PostgreSQL with Prisma ORM
|
||||||
|
- **Styling**: Tailwind CSS with Mantine UI components
|
||||||
|
- **Authentication**: JWT-based with custom middleware
|
||||||
|
- **Runtime**: Bun (instead of Node.js)
|
||||||
|
- **Deployment**: Standalone output configuration
|
||||||
|
|
||||||
|
### Team Structure
|
||||||
|
- **bagas**: Frontend, DevOps
|
||||||
|
- **lukman**: Frontend, UI
|
||||||
|
- **lia**: Backend, Frontend, QC
|
||||||
|
- **malik**: Leader
|
||||||
|
|
||||||
|
## Architecture & Features
|
||||||
|
|
||||||
|
### Core Modules
|
||||||
|
The application is organized into several major functional areas:
|
||||||
|
|
||||||
|
1. **Authentication System** (`/auth`) - Login, registration, validation
|
||||||
|
2. **Investment Platform** (`/investasi`) - Investment creation, trading, portfolio management
|
||||||
|
3. **Donation System** (`/donasi`) - Fundraising campaigns, donation processing
|
||||||
|
4. **Event Management** (`/event`) - Event creation, participation, management
|
||||||
|
5. **Voting System** (`/vote`) - Voting creation and participation
|
||||||
|
6. **Job Board** (`/job`) - Job posting and application system
|
||||||
|
7. **Forum** (`/forum`) - Discussion platform with reporting features
|
||||||
|
8. **Collaboration Platform** (`/colab`) - Project collaboration tools
|
||||||
|
9. **User Profiles** (`/profile`) - User profile management
|
||||||
|
10. **Business Maps** (`/maps`) - Business location mapping
|
||||||
|
|
||||||
|
### Admin Panel
|
||||||
|
The application includes a comprehensive admin panel (`/admin`) with modules for managing:
|
||||||
|
- Investment approvals and transfers
|
||||||
|
- Donation campaign reviews
|
||||||
|
- Event management
|
||||||
|
- Forum moderation
|
||||||
|
- Job posting reviews
|
||||||
|
- User access management
|
||||||
|
- Voting oversight
|
||||||
|
|
||||||
|
### Technical Architecture
|
||||||
|
|
||||||
|
#### Routing & Authentication
|
||||||
|
- Custom middleware handles authentication and authorization
|
||||||
|
- Public routes are defined in the middleware configuration
|
||||||
|
- JWT tokens are stored in cookies with secure options
|
||||||
|
- Role-based access control (MasterUserRole model)
|
||||||
|
|
||||||
|
#### Database Schema
|
||||||
|
The Prisma schema defines a comprehensive data model with:
|
||||||
|
- User management with roles and profiles
|
||||||
|
- Investment and financial systems
|
||||||
|
- Donation and crowdfunding features
|
||||||
|
- Event management
|
||||||
|
- Forum and discussion systems
|
||||||
|
- Collaboration platforms
|
||||||
|
- Notification systems
|
||||||
|
- Business mapping features
|
||||||
|
|
||||||
|
#### Environment Configuration
|
||||||
|
The application uses multiple environment files for different deployment stages:
|
||||||
|
- Development: `run.env.dev`, `run.env.local.dev`
|
||||||
|
- Build: `run.env.build.dev`, `run.env.build.local`
|
||||||
|
- Runtime: `run.env.start.dev`, `run.env.start.local`
|
||||||
|
|
||||||
|
## Building and Running
|
||||||
|
|
||||||
|
### Prerequisites
|
||||||
|
- Bun runtime installed
|
||||||
|
- PostgreSQL database
|
||||||
|
- Required environment variables configured
|
||||||
|
|
||||||
|
### Setup Commands
|
||||||
|
```bash
|
||||||
|
# Install dependencies
|
||||||
|
bun install
|
||||||
|
|
||||||
|
# Setup database (Prisma)
|
||||||
|
bun prisma generate
|
||||||
|
bun prisma db push
|
||||||
|
bun prisma db seed
|
||||||
|
|
||||||
|
# Development server
|
||||||
|
bun run dev
|
||||||
|
|
||||||
|
# Build for production
|
||||||
|
bun run build
|
||||||
|
|
||||||
|
# Start production server
|
||||||
|
bun run start
|
||||||
|
```
|
||||||
|
|
||||||
|
### Development Scripts
|
||||||
|
- `dev`: Starts development server with HTTPS
|
||||||
|
- `build`: Builds the application for production
|
||||||
|
- `start`: Starts the production server
|
||||||
|
- `lint`: Runs Next.js linting
|
||||||
|
- `ver`: Creates version tags
|
||||||
|
|
||||||
|
## Development Conventions
|
||||||
|
|
||||||
|
### Git Workflow
|
||||||
|
The team follows a structured Git workflow:
|
||||||
|
1. Check status with `git status`
|
||||||
|
2. Add specific files with `git add <file>` (avoid `git add -A`)
|
||||||
|
3. Commit with structured messages following conventional commits:
|
||||||
|
- `feat`: New features
|
||||||
|
- `fix`: Bug fixes
|
||||||
|
- `docs`: Documentation updates
|
||||||
|
- `chore`: Routine tasks
|
||||||
|
- `refactor`: Code restructuring
|
||||||
|
- `test`: Testing additions
|
||||||
|
- `style`: Styling changes
|
||||||
|
- `perf`: Performance improvements
|
||||||
|
|
||||||
|
### Commit Message Format
|
||||||
|
```
|
||||||
|
type: Short description
|
||||||
|
|
||||||
|
Body:
|
||||||
|
- Detailed description of changes
|
||||||
|
- Motivation for changes
|
||||||
|
- Breaking changes if any
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
### Main Directories
|
||||||
|
- `src/app`: Next.js App Router pages and layouts
|
||||||
|
- `src/app_modules`: Reusable application modules
|
||||||
|
- `src/lib`: Shared libraries and utilities
|
||||||
|
- `src/util`: Utility functions
|
||||||
|
- `prisma`: Database schema and migrations
|
||||||
|
- `public`: Static assets
|
||||||
|
- `certificates`, `logs`: Application data directories
|
||||||
|
|
||||||
|
### Key Files
|
||||||
|
- `package.json`: Dependencies and scripts
|
||||||
|
- `next.config.js`: Next.js configuration
|
||||||
|
- `middleware.tsx`: Authentication and routing middleware
|
||||||
|
- `tsconfig.json`: TypeScript configuration
|
||||||
|
- `tailwind.config.js`: Styling configuration
|
||||||
|
- `gen_page.tsx`: Generated page routing utility
|
||||||
|
- `prisma/schema.prisma`: Database schema definition
|
||||||
|
|
||||||
|
## Special Features
|
||||||
|
|
||||||
|
### Real-time Capabilities
|
||||||
|
- WebSocket integration for real-time updates
|
||||||
|
- MQTT support for messaging
|
||||||
|
- Live notifications system
|
||||||
|
|
||||||
|
### Payment Integration
|
||||||
|
- Midtrans payment gateway for investments
|
||||||
|
- Multiple payment methods
|
||||||
|
- Invoice generation and tracking
|
||||||
|
|
||||||
|
### File Handling
|
||||||
|
- PDF generation and viewing
|
||||||
|
- Image processing and storage
|
||||||
|
- Document management for investments
|
||||||
|
|
||||||
|
### Mobile Support
|
||||||
|
- Responsive design
|
||||||
|
- Mobile-specific features
|
||||||
|
- Device token management
|
||||||
|
|
||||||
|
## Security Measures
|
||||||
|
|
||||||
|
### Authentication
|
||||||
|
- JWT-based authentication
|
||||||
|
- Session management
|
||||||
|
- Role-based access control
|
||||||
|
- Secure token storage in cookies
|
||||||
|
|
||||||
|
### Input Validation
|
||||||
|
- Prisma schema validations
|
||||||
|
- Server-side validation
|
||||||
|
- Sanitization of user inputs
|
||||||
|
|
||||||
|
### Data Protection
|
||||||
|
- Encrypted tokens
|
||||||
|
- Secure API routes
|
||||||
|
- Proper CORS configuration
|
||||||
19
bun.lock
19
bun.lock
@@ -39,6 +39,7 @@
|
|||||||
"@types/react-dom": "18.2.7",
|
"@types/react-dom": "18.2.7",
|
||||||
"@types/uuid": "^9.0.4",
|
"@types/uuid": "^9.0.4",
|
||||||
"autoprefixer": "10.4.14",
|
"autoprefixer": "10.4.14",
|
||||||
|
"axios": "^1.13.5",
|
||||||
"bufferutil": "^4.0.8",
|
"bufferutil": "^4.0.8",
|
||||||
"bun": "^1.1.38",
|
"bun": "^1.1.38",
|
||||||
"caniuse-lite": "^1.0.30001757",
|
"caniuse-lite": "^1.0.30001757",
|
||||||
@@ -1324,7 +1325,7 @@
|
|||||||
|
|
||||||
"axe-core": ["axe-core@4.10.2", "", {}, "sha512-RE3mdQ7P3FRSe7eqCWoeQ/Z9QXrtniSjp1wUjt5nRC3WIpz5rSCve6o3fsZ2aCpJtrZjSZgjwXAoTO5k4tEI0w=="],
|
"axe-core": ["axe-core@4.10.2", "", {}, "sha512-RE3mdQ7P3FRSe7eqCWoeQ/Z9QXrtniSjp1wUjt5nRC3WIpz5rSCve6o3fsZ2aCpJtrZjSZgjwXAoTO5k4tEI0w=="],
|
||||||
|
|
||||||
"axios": ["axios@0.26.1", "", { "dependencies": { "follow-redirects": "^1.14.8" } }, "sha512-fPwcX4EvnSHuInCMItEhAGnaSEXRBjtzh9fOtsE6E1G6p7vl7edEeZe11QHf18+6+9gR5PbKV/sGKNaD8YaMeA=="],
|
"axios": ["axios@1.13.5", "", { "dependencies": { "follow-redirects": "^1.15.11", "form-data": "^4.0.5", "proxy-from-env": "^1.1.0" } }, "sha512-cz4ur7Vb0xS4/KUN0tPWe44eqxrIu31me+fbang3ijiNscE129POzipJJA6zniq2C/Z6sJCjMimjS8Lc/GAs8Q=="],
|
||||||
|
|
||||||
"axobject-query": ["axobject-query@4.1.0", "", {}, "sha512-qIj0G9wZbMGNLjLmg1PT6v2mE9AH2zlnADJD/2tC6E00hgmhUOfEB6greHPAfLRSufHqROIUTkw6E+M3lH0PTQ=="],
|
"axobject-query": ["axobject-query@4.1.0", "", {}, "sha512-qIj0G9wZbMGNLjLmg1PT6v2mE9AH2zlnADJD/2tC6E00hgmhUOfEB6greHPAfLRSufHqROIUTkw6E+M3lH0PTQ=="],
|
||||||
|
|
||||||
@@ -1882,7 +1883,7 @@
|
|||||||
|
|
||||||
"fn.name": ["fn.name@1.1.0", "", {}, "sha512-GRnmB5gPyJpAhTQdSZTSp9uaPSvl09KoYcMQtsB9rQoOmzs9dH6ffeccH+Z+cv6P68Hu5bC6JjRh4Ah/mHSNRw=="],
|
"fn.name": ["fn.name@1.1.0", "", {}, "sha512-GRnmB5gPyJpAhTQdSZTSp9uaPSvl09KoYcMQtsB9rQoOmzs9dH6ffeccH+Z+cv6P68Hu5bC6JjRh4Ah/mHSNRw=="],
|
||||||
|
|
||||||
"follow-redirects": ["follow-redirects@1.15.9", "", {}, "sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ=="],
|
"follow-redirects": ["follow-redirects@1.15.11", "", {}, "sha512-deG2P0JfjrTxl50XGCDyfI97ZGVCxIpfKYmfyrQ54n5FO/0gfIES8C/Psl6kWVDolizcaaxZJnTS0QSMxvnsBQ=="],
|
||||||
|
|
||||||
"fontfaceobserver": ["fontfaceobserver@2.3.0", "", {}, "sha512-6FPvD/IVyT4ZlNe7Wcn5Fb/4ChigpucKYSvD6a+0iMoLn2inpo711eyIcKjmDtE5XNcgAkSH9uN/nfAeZzHEfg=="],
|
"fontfaceobserver": ["fontfaceobserver@2.3.0", "", {}, "sha512-6FPvD/IVyT4ZlNe7Wcn5Fb/4ChigpucKYSvD6a+0iMoLn2inpo711eyIcKjmDtE5XNcgAkSH9uN/nfAeZzHEfg=="],
|
||||||
|
|
||||||
@@ -1892,7 +1893,7 @@
|
|||||||
|
|
||||||
"foreground-child": ["foreground-child@3.3.1", "", { "dependencies": { "cross-spawn": "^7.0.6", "signal-exit": "^4.0.1" } }, "sha512-gIXjKqtFuWEgzFRJA9WCQeSJLZDjgJUOMCMzxtvFq/37KojM1BFGufqsCy0r4qSQmYLsZYMeyRqzIWOMup03sw=="],
|
"foreground-child": ["foreground-child@3.3.1", "", { "dependencies": { "cross-spawn": "^7.0.6", "signal-exit": "^4.0.1" } }, "sha512-gIXjKqtFuWEgzFRJA9WCQeSJLZDjgJUOMCMzxtvFq/37KojM1BFGufqsCy0r4qSQmYLsZYMeyRqzIWOMup03sw=="],
|
||||||
|
|
||||||
"form-data": ["form-data@4.0.2", "", { "dependencies": { "asynckit": "^0.4.0", "combined-stream": "^1.0.8", "es-set-tostringtag": "^2.1.0", "mime-types": "^2.1.12" } }, "sha512-hGfm/slu0ZabnNt4oaRZ6uREyfCj6P4fT/n6A1rGV+Z0VdGXjfOhVUpkn6qVQONHGIFwmveGXyDs75+nr6FM8w=="],
|
"form-data": ["form-data@4.0.5", "", { "dependencies": { "asynckit": "^0.4.0", "combined-stream": "^1.0.8", "es-set-tostringtag": "^2.1.0", "hasown": "^2.0.2", "mime-types": "^2.1.12" } }, "sha512-8RipRLol37bNs2bhoV67fiTEvdTrbMUYcFTiy3+wuuOnUog2QBHCZWXDRijWQfAkhBj2Uf5UnVaiWwA5vdd82w=="],
|
||||||
|
|
||||||
"form-data-encoder": ["form-data-encoder@1.7.2", "", {}, "sha512-qfqtYan3rxrnCk1VYaA4H+Ms9xdpPqvLZa6xmMgFvhO32x7/3J/ExcTd6qpxM0vH2GdMI+poehyBZvqfMTto8A=="],
|
"form-data-encoder": ["form-data-encoder@1.7.2", "", {}, "sha512-qfqtYan3rxrnCk1VYaA4H+Ms9xdpPqvLZa6xmMgFvhO32x7/3J/ExcTd6qpxM0vH2GdMI+poehyBZvqfMTto8A=="],
|
||||||
|
|
||||||
@@ -3618,6 +3619,8 @@
|
|||||||
|
|
||||||
"@types/jsonwebtoken/@types/node": ["@types/node@22.19.1", "", { "dependencies": { "undici-types": "~6.21.0" } }, "sha512-LCCV0HdSZZZb34qifBsyWlUmok6W7ouER+oQIGBScS8EsZsQbrtFTUrDX4hOl+CS6p7cnNC4td+qrSVGSCTUfQ=="],
|
"@types/jsonwebtoken/@types/node": ["@types/node@22.19.1", "", { "dependencies": { "undici-types": "~6.21.0" } }, "sha512-LCCV0HdSZZZb34qifBsyWlUmok6W7ouER+oQIGBScS8EsZsQbrtFTUrDX4hOl+CS6p7cnNC4td+qrSVGSCTUfQ=="],
|
||||||
|
|
||||||
|
"@types/node-fetch/form-data": ["form-data@4.0.2", "", { "dependencies": { "asynckit": "^0.4.0", "combined-stream": "^1.0.8", "es-set-tostringtag": "^2.1.0", "mime-types": "^2.1.12" } }, "sha512-hGfm/slu0ZabnNt4oaRZ6uREyfCj6P4fT/n6A1rGV+Z0VdGXjfOhVUpkn6qVQONHGIFwmveGXyDs75+nr6FM8w=="],
|
||||||
|
|
||||||
"@types/request/@types/node": ["@types/node@22.19.1", "", { "dependencies": { "undici-types": "~6.21.0" } }, "sha512-LCCV0HdSZZZb34qifBsyWlUmok6W7ouER+oQIGBScS8EsZsQbrtFTUrDX4hOl+CS6p7cnNC4td+qrSVGSCTUfQ=="],
|
"@types/request/@types/node": ["@types/node@22.19.1", "", { "dependencies": { "undici-types": "~6.21.0" } }, "sha512-LCCV0HdSZZZb34qifBsyWlUmok6W7ouER+oQIGBScS8EsZsQbrtFTUrDX4hOl+CS6p7cnNC4td+qrSVGSCTUfQ=="],
|
||||||
|
|
||||||
"@types/request/form-data": ["form-data@2.5.5", "", { "dependencies": { "asynckit": "^0.4.0", "combined-stream": "^1.0.8", "es-set-tostringtag": "^2.1.0", "hasown": "^2.0.2", "mime-types": "^2.1.35", "safe-buffer": "^5.2.1" } }, "sha512-jqdObeR2rxZZbPSGL+3VckHMYtu+f9//KXBsVny6JSX/pa38Fy+bGjuG8eW/H6USNQWhLi8Num++cU2yOCNz4A=="],
|
"@types/request/form-data": ["form-data@2.5.5", "", { "dependencies": { "asynckit": "^0.4.0", "combined-stream": "^1.0.8", "es-set-tostringtag": "^2.1.0", "hasown": "^2.0.2", "mime-types": "^2.1.35", "safe-buffer": "^5.2.1" } }, "sha512-jqdObeR2rxZZbPSGL+3VckHMYtu+f9//KXBsVny6JSX/pa38Fy+bGjuG8eW/H6USNQWhLi8Num++cU2yOCNz4A=="],
|
||||||
@@ -3630,6 +3633,8 @@
|
|||||||
|
|
||||||
"ast-types/tslib": ["tslib@2.8.1", "", {}, "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w=="],
|
"ast-types/tslib": ["tslib@2.8.1", "", {}, "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w=="],
|
||||||
|
|
||||||
|
"autocannon/form-data": ["form-data@4.0.2", "", { "dependencies": { "asynckit": "^0.4.0", "combined-stream": "^1.0.8", "es-set-tostringtag": "^2.1.0", "mime-types": "^2.1.12" } }, "sha512-hGfm/slu0ZabnNt4oaRZ6uREyfCj6P4fT/n6A1rGV+Z0VdGXjfOhVUpkn6qVQONHGIFwmveGXyDs75+nr6FM8w=="],
|
||||||
|
|
||||||
"autoprefixer/caniuse-lite": ["caniuse-lite@1.0.30001701", "", {}, "sha512-faRs/AW3jA9nTwmJBSO1PQ6L/EOgsB5HMQQq4iCu5zhPgVVgO/pZRHlmatwijZKetFw8/Pr4q6dEN8sJuq8qTw=="],
|
"autoprefixer/caniuse-lite": ["caniuse-lite@1.0.30001701", "", {}, "sha512-faRs/AW3jA9nTwmJBSO1PQ6L/EOgsB5HMQQq4iCu5zhPgVVgO/pZRHlmatwijZKetFw8/Pr4q6dEN8sJuq8qTw=="],
|
||||||
|
|
||||||
"babel-plugin-polyfill-corejs2/semver": ["semver@6.3.1", "", { "bin": { "semver": "bin/semver.js" } }, "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA=="],
|
"babel-plugin-polyfill-corejs2/semver": ["semver@6.3.1", "", { "bin": { "semver": "bin/semver.js" } }, "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA=="],
|
||||||
@@ -3810,6 +3815,8 @@
|
|||||||
|
|
||||||
"metro-file-map/debug": ["debug@2.6.9", "", { "dependencies": { "ms": "2.0.0" } }, "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA=="],
|
"metro-file-map/debug": ["debug@2.6.9", "", { "dependencies": { "ms": "2.0.0" } }, "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA=="],
|
||||||
|
|
||||||
|
"midtrans-client/axios": ["axios@0.26.1", "", { "dependencies": { "follow-redirects": "^1.14.8" } }, "sha512-fPwcX4EvnSHuInCMItEhAGnaSEXRBjtzh9fOtsE6E1G6p7vl7edEeZe11QHf18+6+9gR5PbKV/sGKNaD8YaMeA=="],
|
||||||
|
|
||||||
"minipass-flush/minipass": ["minipass@3.3.6", "", { "dependencies": { "yallist": "^4.0.0" } }, "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw=="],
|
"minipass-flush/minipass": ["minipass@3.3.6", "", { "dependencies": { "yallist": "^4.0.0" } }, "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw=="],
|
||||||
|
|
||||||
"minipass-pipeline/minipass": ["minipass@3.3.6", "", { "dependencies": { "yallist": "^4.0.0" } }, "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw=="],
|
"minipass-pipeline/minipass": ["minipass@3.3.6", "", { "dependencies": { "yallist": "^4.0.0" } }, "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw=="],
|
||||||
@@ -4190,6 +4197,12 @@
|
|||||||
|
|
||||||
"metro/debug/ms": ["ms@2.0.0", "", {}, "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A=="],
|
"metro/debug/ms": ["ms@2.0.0", "", {}, "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A=="],
|
||||||
|
|
||||||
|
"midtrans-client/axios/follow-redirects": ["follow-redirects@1.15.9", "", {}, "sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ=="],
|
||||||
|
|
||||||
|
"next-dev/axios/follow-redirects": ["follow-redirects@1.15.9", "", {}, "sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ=="],
|
||||||
|
|
||||||
|
"next-dev/axios/form-data": ["form-data@4.0.2", "", { "dependencies": { "asynckit": "^0.4.0", "combined-stream": "^1.0.8", "es-set-tostringtag": "^2.1.0", "mime-types": "^2.1.12" } }, "sha512-hGfm/slu0ZabnNt4oaRZ6uREyfCj6P4fT/n6A1rGV+Z0VdGXjfOhVUpkn6qVQONHGIFwmveGXyDs75+nr6FM8w=="],
|
||||||
|
|
||||||
"next-dev/react-dom/scheduler": ["scheduler@0.23.2", "", { "dependencies": { "loose-envify": "^1.1.0" } }, "sha512-UOShsPwz7NrMUqhR6t0hWjFduvOzbtv7toDH1/hIrfRNIDBnnBWd0CwJTGvTpngVlmwGCdP9/Zl/tVrDqcuYzQ=="],
|
"next-dev/react-dom/scheduler": ["scheduler@0.23.2", "", { "dependencies": { "loose-envify": "^1.1.0" } }, "sha512-UOShsPwz7NrMUqhR6t0hWjFduvOzbtv7toDH1/hIrfRNIDBnnBWd0CwJTGvTpngVlmwGCdP9/Zl/tVrDqcuYzQ=="],
|
||||||
|
|
||||||
"next-scroll-loader/react-dom/scheduler": ["scheduler@0.23.2", "", { "dependencies": { "loose-envify": "^1.1.0" } }, "sha512-UOShsPwz7NrMUqhR6t0hWjFduvOzbtv7toDH1/hIrfRNIDBnnBWd0CwJTGvTpngVlmwGCdP9/Zl/tVrDqcuYzQ=="],
|
"next-scroll-loader/react-dom/scheduler": ["scheduler@0.23.2", "", { "dependencies": { "loose-envify": "^1.1.0" } }, "sha512-UOShsPwz7NrMUqhR6t0hWjFduvOzbtv7toDH1/hIrfRNIDBnnBWd0CwJTGvTpngVlmwGCdP9/Zl/tVrDqcuYzQ=="],
|
||||||
|
|||||||
@@ -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,27 +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", ".prisma/client"],
|
||||||
},
|
},
|
||||||
output: "standalone",
|
webpack: (config, { isServer }) => {
|
||||||
staticPageGenerationTimeout: 180, // tingkatkan menjadi 3 menit
|
if (isServer) {
|
||||||
eslint: {
|
config.externals = config.externals || [];
|
||||||
ignoreDuringBuilds: true,
|
config.externals.push("@prisma/client");
|
||||||
|
config.externals.push(".prisma/client");
|
||||||
|
}
|
||||||
|
return config;
|
||||||
|
},
|
||||||
|
|
||||||
|
async headers() {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
source: "/.well-known/:path*",
|
||||||
|
headers: [
|
||||||
|
{ key: "Content-Type", value: "application/json" },
|
||||||
|
{
|
||||||
|
key: "Cache-Control",
|
||||||
|
value: "no-cache, no-store, must-revalidate",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
];
|
||||||
},
|
},
|
||||||
// async headers() {
|
|
||||||
// return [
|
|
||||||
// {
|
|
||||||
// source: "/(.*)",
|
|
||||||
// headers: [
|
|
||||||
// {
|
|
||||||
// key: "Cache-Control",
|
|
||||||
// value: "no-store, max-age=0",
|
|
||||||
// },
|
|
||||||
// ],
|
|
||||||
// },
|
|
||||||
// ];
|
|
||||||
// },
|
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = nextConfig;
|
module.exports = nextConfig;
|
||||||
|
|||||||
@@ -1,15 +1,16 @@
|
|||||||
{
|
{
|
||||||
"name": "hipmi",
|
"name": "hipmi",
|
||||||
"version": "1.5.38",
|
"version": "1.7.2",
|
||||||
"private": true,
|
"private": true,
|
||||||
"prisma": {
|
"prisma": {
|
||||||
"seed": "bun prisma/seed.ts"
|
"seed": "bun prisma/seed.ts"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "next dev --experimental-https",
|
"dev": "next dev --experimental-https",
|
||||||
"build": "next build",
|
"build": "prisma generate && next build",
|
||||||
"build:dev": "next build",
|
"build:dev": "prisma generate && next build",
|
||||||
"start": "next start",
|
"start": "next start",
|
||||||
|
"postbuild": "node scripts/postbuild.js",
|
||||||
"lint": "next lint",
|
"lint": "next lint",
|
||||||
"ver": "bunx commit-and-tag-version -- --prerelease"
|
"ver": "bunx commit-and-tag-version -- --prerelease"
|
||||||
},
|
},
|
||||||
@@ -50,6 +51,7 @@
|
|||||||
"@types/react-dom": "18.2.7",
|
"@types/react-dom": "18.2.7",
|
||||||
"@types/uuid": "^9.0.4",
|
"@types/uuid": "^9.0.4",
|
||||||
"autoprefixer": "10.4.14",
|
"autoprefixer": "10.4.14",
|
||||||
|
"axios": "^1.13.5",
|
||||||
"bufferutil": "^4.0.8",
|
"bufferutil": "^4.0.8",
|
||||||
"bun": "^1.1.38",
|
"bun": "^1.1.38",
|
||||||
"caniuse-lite": "^1.0.30001757",
|
"caniuse-lite": "^1.0.30001757",
|
||||||
|
|||||||
@@ -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"]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}]
|
]
|
||||||
60
scripts/postbuild.js
Normal file
60
scripts/postbuild.js
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
|
const standaloneDir = path.join(__dirname, '../.next/standalone');
|
||||||
|
const prismaDir = path.join(__dirname, '../node_modules/.prisma');
|
||||||
|
|
||||||
|
console.log('🚀 Running postbuild script...');
|
||||||
|
|
||||||
|
// Copy Prisma binaries ke standalone output
|
||||||
|
if (fs.existsSync(prismaDir)) {
|
||||||
|
const dest = path.join(standaloneDir, 'node_modules/.prisma');
|
||||||
|
fs.mkdirSync(path.dirname(dest), { recursive: true });
|
||||||
|
fs.cpSync(prismaDir, dest, { recursive: true });
|
||||||
|
console.log('✓ Prisma binaries copied to standalone output');
|
||||||
|
} else {
|
||||||
|
console.warn('⚠ Prisma binaries directory not found, skipping...');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Copy schema.prisma jika diperlukan
|
||||||
|
const schemaSrc = path.join(__dirname, '../prisma/schema.prisma');
|
||||||
|
const schemaDest = path.join(standaloneDir, 'prisma/schema.prisma');
|
||||||
|
if (fs.existsSync(schemaSrc)) {
|
||||||
|
fs.mkdirSync(path.dirname(schemaDest), { recursive: true });
|
||||||
|
fs.copyFileSync(schemaSrc, schemaDest);
|
||||||
|
console.log('✓ schema.prisma copied to standalone output');
|
||||||
|
} else {
|
||||||
|
console.warn('⚠ schema.prisma not found, skipping...');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Copy prisma client dari node_modules/@prisma/client
|
||||||
|
const prismaClientSrc = path.join(__dirname, '../node_modules/@prisma/client');
|
||||||
|
const prismaClientDest = path.join(standaloneDir, 'node_modules/@prisma/client');
|
||||||
|
if (fs.existsSync(prismaClientSrc)) {
|
||||||
|
fs.mkdirSync(path.dirname(prismaClientDest), { recursive: true });
|
||||||
|
fs.cpSync(prismaClientSrc, prismaClientDest, { recursive: true });
|
||||||
|
console.log('✓ @prisma/client copied to standalone output');
|
||||||
|
} else {
|
||||||
|
console.warn('⚠ @prisma/client not found, skipping...');
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { prisma } from "@/lib";
|
|||||||
import { randomOTP } from "@/app_modules/auth/fun/rondom_otp";
|
import { randomOTP } from "@/app_modules/auth/fun/rondom_otp";
|
||||||
import backendLogger from "@/util/backendLogger";
|
import backendLogger from "@/util/backendLogger";
|
||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
import { sendCodeOtp } from "@/lib/code-otp-sender";
|
import { funSendToWhatsApp } from "@/lib/code-otp-sender";
|
||||||
|
|
||||||
export async function POST(req: Request) {
|
export async function POST(req: Request) {
|
||||||
if (req.method !== "POST") {
|
if (req.method !== "POST") {
|
||||||
@@ -30,7 +30,7 @@ export async function POST(req: Request) {
|
|||||||
{ status: 400 },
|
{ status: 400 },
|
||||||
);
|
);
|
||||||
|
|
||||||
const resSendCode = await sendCodeOtp({
|
const resSendCode = await funSendToWhatsApp({
|
||||||
nomor,
|
nomor,
|
||||||
codeOtp: codeOtp.toString(),
|
codeOtp: codeOtp.toString(),
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
|
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";
|
||||||
import { sendCodeOtp } from "@/lib/code-otp-sender";
|
import { funSendToWhatsApp } from "@/lib/code-otp-sender";
|
||||||
|
|
||||||
export async function POST(req: Request) {
|
export async function POST(req: Request) {
|
||||||
try {
|
try {
|
||||||
@@ -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(
|
||||||
@@ -35,7 +56,7 @@ export async function POST(req: Request) {
|
|||||||
{ status: 400 },
|
{ status: 400 },
|
||||||
);
|
);
|
||||||
|
|
||||||
const resSendCode = await sendCodeOtp({
|
const resSendCode = await funSendToWhatsApp({
|
||||||
nomor,
|
nomor,
|
||||||
codeOtp: codeOtp.toString(),
|
codeOtp: codeOtp.toString(),
|
||||||
});
|
});
|
||||||
@@ -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,
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import {
|
|||||||
NotificationMobileBodyType,
|
NotificationMobileBodyType,
|
||||||
NotificationMobileTitleType,
|
NotificationMobileTitleType,
|
||||||
} from "../../../../../types/type-mobile-notification";
|
} from "../../../../../types/type-mobile-notification";
|
||||||
import { sendCodeOtp } from "@/lib/code-otp-sender";
|
import { funSendToWhatsApp } from "@/lib/code-otp-sender";
|
||||||
|
|
||||||
export async function POST(req: Request) {
|
export async function POST(req: Request) {
|
||||||
if (req.method !== "POST") {
|
if (req.method !== "POST") {
|
||||||
@@ -70,7 +70,7 @@ export async function POST(req: Request) {
|
|||||||
{ status: 400 }
|
{ status: 400 }
|
||||||
);
|
);
|
||||||
|
|
||||||
const resSendCode = await sendCodeOtp({
|
const resSendCode = await funSendToWhatsApp({
|
||||||
nomor: data.nomor,
|
nomor: data.nomor,
|
||||||
codeOtp: codeOtp.toString(),
|
codeOtp: codeOtp.toString(),
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
@@ -14,8 +14,6 @@ export async function POST(req: Request) {
|
|||||||
try {
|
try {
|
||||||
const { data } = await req.json();
|
const { data } = await req.json();
|
||||||
|
|
||||||
console.log("data >>", data);
|
|
||||||
|
|
||||||
const cekUsername = await prisma.user.findUnique({
|
const cekUsername = await prisma.user.findUnique({
|
||||||
where: {
|
where: {
|
||||||
username: data.username,
|
username: data.username,
|
||||||
@@ -29,12 +27,12 @@ export async function POST(req: Request) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// ✅ Validasi wajib setuju Terms
|
// ✅ Validasi wajib setuju Terms
|
||||||
if (data.termsOfServiceAccepted !== true) {
|
// if (data.termsOfServiceAccepted !== true) {
|
||||||
return NextResponse.json({
|
// return NextResponse.json({
|
||||||
success: false,
|
// success: false,
|
||||||
message: "You must agree to the Terms of Service",
|
// message: "You must agree to the Terms of Service",
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
|
|
||||||
const createUser = await prisma.user.create({
|
const createUser = await prisma.user.create({
|
||||||
data: {
|
data: {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { prisma } from "@/lib";
|
|||||||
import { randomOTP } from "@/app_modules/auth/fun/rondom_otp";
|
import { randomOTP } from "@/app_modules/auth/fun/rondom_otp";
|
||||||
import backendLogger from "@/util/backendLogger";
|
import backendLogger from "@/util/backendLogger";
|
||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
import { sendCodeOtp } from "@/lib/code-otp-sender";
|
import { funSendToWhatsApp } from "@/lib/code-otp-sender";
|
||||||
|
|
||||||
export async function POST(req: Request) {
|
export async function POST(req: Request) {
|
||||||
if (req.method !== "POST") {
|
if (req.method !== "POST") {
|
||||||
@@ -17,7 +17,7 @@ export async function POST(req: Request) {
|
|||||||
const body = await req.json();
|
const body = await req.json();
|
||||||
const { nomor } = body;
|
const { nomor } = body;
|
||||||
|
|
||||||
const resSendCode = await sendCodeOtp({
|
const resSendCode = await funSendToWhatsApp({
|
||||||
nomor,
|
nomor,
|
||||||
codeOtp: codeOtp.toString(),
|
codeOtp: codeOtp.toString(),
|
||||||
});
|
});
|
||||||
@@ -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,11 +1,23 @@
|
|||||||
|
import { funFindDonaturList } from "@/lib/mobile/donation/find-donatur-list";
|
||||||
|
import {
|
||||||
|
sendNotificationMobileToManyUser,
|
||||||
|
sendNotificationMobileToOneUser,
|
||||||
|
} from "@/lib/mobile/notification/send-notification";
|
||||||
import prisma from "@/lib/prisma";
|
import prisma from "@/lib/prisma";
|
||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
|
import {
|
||||||
|
NotificationMobileBodyType,
|
||||||
|
NotificationMobileTitleType,
|
||||||
|
} from "../../../../../../../../types/type-mobile-notification";
|
||||||
|
import { routeUserMobile } from "@/lib/mobile/route-page-mobile";
|
||||||
|
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||||
|
|
||||||
export { POST, GET };
|
export { POST, GET };
|
||||||
|
|
||||||
async function POST(request: Request, { params }: { params: { id: string } }) {
|
async function POST(request: Request, { params }: { params: { id: string } }) {
|
||||||
const { id } = params;
|
const { id } = params;
|
||||||
const { data } = await request.json();
|
const { data } = await request.json();
|
||||||
|
const { title, nominalCair, deskripsi, imageId, authorId } = data;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const dataDonasi = await prisma.donasi.findUnique({
|
const dataDonasi = await prisma.donasi.findUnique({
|
||||||
@@ -22,19 +34,19 @@ async function POST(request: Request, { params }: { params: { id: string } }) {
|
|||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{
|
{
|
||||||
success: false,
|
success: false,
|
||||||
message: "Pencarian Donasi Gagal",
|
message: "DataPencarian Donasi Gagal",
|
||||||
reason: "Pencarian Donasi Gagal",
|
reason: "Data Pencarian Donasi Gagal",
|
||||||
},
|
},
|
||||||
{ status: 400 }
|
{ status: 400 },
|
||||||
);
|
);
|
||||||
|
|
||||||
const createPencairan = await prisma.donasi_PencairanDana.create({
|
const createPencairan = await prisma.donasi_PencairanDana.create({
|
||||||
data: {
|
data: {
|
||||||
donasiId: id,
|
donasiId: id,
|
||||||
nominalCair: +data.nominalCair,
|
nominalCair: +nominalCair,
|
||||||
deskripsi: data.deskripsi,
|
deskripsi: deskripsi,
|
||||||
title: data.title,
|
title: title,
|
||||||
imageId: data.imageId,
|
imageId: imageId,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -45,11 +57,11 @@ async function POST(request: Request, { params }: { params: { id: string } }) {
|
|||||||
message: "Pencairan Dana Gagal",
|
message: "Pencairan Dana Gagal",
|
||||||
reason: "Pencairan Dana Gagal",
|
reason: "Pencairan Dana Gagal",
|
||||||
},
|
},
|
||||||
{ status: 400 }
|
{ status: 400 },
|
||||||
);
|
);
|
||||||
|
|
||||||
const hasilTotalPencairan =
|
const hasilTotalPencairan =
|
||||||
Number(dataDonasi.totalPencairan) + Number(data.nominalCair);
|
Number(dataDonasi.totalPencairan) + Number(nominalCair);
|
||||||
// const hasilAkumulasiPencairan = Number(dataDonasi.akumulasiPencairan) + 1;
|
// const hasilAkumulasiPencairan = Number(dataDonasi.akumulasiPencairan) + 1;
|
||||||
|
|
||||||
const countPencairan = await prisma.donasi_PencairanDana.count({
|
const countPencairan = await prisma.donasi_PencairanDana.count({
|
||||||
@@ -66,8 +78,47 @@ async function POST(request: Request, { params }: { params: { id: string } }) {
|
|||||||
akumulasiPencairan: countPencairan,
|
akumulasiPencairan: countPencairan,
|
||||||
totalPencairan: hasilTotalPencairan,
|
totalPencairan: hasilTotalPencairan,
|
||||||
},
|
},
|
||||||
|
select: {
|
||||||
|
authorId: true,
|
||||||
|
title: true,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// ================= START SEND NOTIFICATION =================
|
||||||
|
await sendNotificationMobileToOneUser({
|
||||||
|
recipientId: updateDonasi?.authorId!,
|
||||||
|
senderId: authorId,
|
||||||
|
payload: {
|
||||||
|
title: "Pencairan Dana Berhasil" as NotificationMobileTitleType,
|
||||||
|
body: `Telah dilaksanakan pencairan dana untuk ${updateDonasi?.title}` as NotificationMobileBodyType,
|
||||||
|
type: "announcement",
|
||||||
|
kategoriApp: "DONASI",
|
||||||
|
deepLink: routeUserMobile.donationDetailPublish({
|
||||||
|
id: id,
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const recipientIds = await funFindDonaturList(id);
|
||||||
|
|
||||||
|
if (recipientIds.length > 0) {
|
||||||
|
await sendNotificationMobileToManyUser({
|
||||||
|
recipientIds,
|
||||||
|
senderId: authorId,
|
||||||
|
payload: {
|
||||||
|
title: "Pencarian Dana" as NotificationMobileTitleType,
|
||||||
|
body: `Update pencarian dana pada ${updateDonasi?.title}` as NotificationMobileBodyType,
|
||||||
|
type: "announcement",
|
||||||
|
kategoriApp: "DONASI",
|
||||||
|
deepLink: routeUserMobile.donationDetailPublish({
|
||||||
|
id: id,
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// ================= END SEND NOTIFICATION =================
|
||||||
|
|
||||||
if (!updateDonasi)
|
if (!updateDonasi)
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{
|
{
|
||||||
@@ -75,7 +126,7 @@ async function POST(request: Request, { params }: { params: { id: string } }) {
|
|||||||
message: "Update Donasi Gagal",
|
message: "Update Donasi Gagal",
|
||||||
reason: "Update Donasi Gagal",
|
reason: "Update Donasi Gagal",
|
||||||
},
|
},
|
||||||
{ status: 400 }
|
{ status: 400 },
|
||||||
);
|
);
|
||||||
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
@@ -84,7 +135,7 @@ async function POST(request: Request, { params }: { params: { id: string } }) {
|
|||||||
message: "Pencairan Dana Berhasil",
|
message: "Pencairan Dana Berhasil",
|
||||||
// data: data,
|
// data: data,
|
||||||
},
|
},
|
||||||
{ status: 200 }
|
{ status: 200 },
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("[ERROR]", error);
|
console.error("[ERROR]", error);
|
||||||
@@ -94,7 +145,7 @@ async function POST(request: Request, { params }: { params: { id: string } }) {
|
|||||||
message: "Pencairan Dana Gagal",
|
message: "Pencairan Dana Gagal",
|
||||||
reason: (error as Error).message,
|
reason: (error as Error).message,
|
||||||
},
|
},
|
||||||
{ status: 500 }
|
{ status: 500 },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -104,13 +155,12 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
|||||||
const { searchParams } = new URL(request.url);
|
const { searchParams } = new URL(request.url);
|
||||||
const category = searchParams.get("category");
|
const category = searchParams.get("category");
|
||||||
const page = searchParams.get("page");
|
const page = searchParams.get("page");
|
||||||
const takeData = 10;
|
const takeData = PAGINATION_DEFAULT_TAKE;
|
||||||
const skipData = Number(page) * takeData - takeData;
|
const skipData = Number(page) * takeData - takeData;
|
||||||
|
|
||||||
console.log("[CATEGORY]", category);
|
console.log("[CATEGORY]", category);
|
||||||
let fixData;
|
let fixData;
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if (category === "get-all") {
|
if (category === "get-all") {
|
||||||
fixData = await prisma.donasi_PencairanDana.findMany({
|
fixData = await prisma.donasi_PencairanDana.findMany({
|
||||||
take: page ? takeData : undefined,
|
take: page ? takeData : undefined,
|
||||||
@@ -125,6 +175,7 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
|||||||
id: true,
|
id: true,
|
||||||
createdAt: true,
|
createdAt: true,
|
||||||
nominalCair: true,
|
nominalCair: true,
|
||||||
|
title: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
} else if (category === "get-one") {
|
} else if (category === "get-one") {
|
||||||
@@ -140,7 +191,7 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
|||||||
message: "Category tidak ditemukan",
|
message: "Category tidak ditemukan",
|
||||||
reason: "Category tidak ditemukan",
|
reason: "Category tidak ditemukan",
|
||||||
},
|
},
|
||||||
{ status: 400 }
|
{ status: 400 },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -150,7 +201,7 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
|||||||
message: "Success get data disbursement",
|
message: "Success get data disbursement",
|
||||||
data: fixData,
|
data: fixData,
|
||||||
},
|
},
|
||||||
{ status: 200 }
|
{ status: 200 },
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("[ERROR]", error);
|
console.error("[ERROR]", error);
|
||||||
@@ -160,7 +211,7 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
|||||||
message: "Gagal mendapatkan data disbursement",
|
message: "Gagal mendapatkan data disbursement",
|
||||||
reason: (error as Error).message,
|
reason: (error as Error).message,
|
||||||
},
|
},
|
||||||
{ status: 500 }
|
{ status: 500 },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
import { prisma } from "@/lib";
|
import { prisma } from "@/lib";
|
||||||
|
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||||
|
|
||||||
export { GET };
|
export { GET };
|
||||||
|
|
||||||
@@ -9,7 +10,7 @@ async function GET(req: Request, { params }: { params: { id: string } }) {
|
|||||||
const { searchParams } = new URL(req.url);
|
const { searchParams } = new URL(req.url);
|
||||||
const page = searchParams.get("page");
|
const page = searchParams.get("page");
|
||||||
const status = searchParams.get("status");
|
const status = searchParams.get("status");
|
||||||
const takeData = 10;
|
const takeData = PAGINATION_DEFAULT_TAKE;
|
||||||
const skipData = Number(page) * takeData - takeData;
|
const skipData = Number(page) * takeData - takeData;
|
||||||
const fixStatus = _.startCase(status || "");
|
const fixStatus = _.startCase(status || "");
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
import prisma from "@/lib/prisma";
|
import prisma from "@/lib/prisma";
|
||||||
|
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||||
|
|
||||||
export { GET };
|
export { GET };
|
||||||
|
|
||||||
@@ -9,11 +10,10 @@ async function GET(request: Request) {
|
|||||||
const category = searchParams.get("category");
|
const category = searchParams.get("category");
|
||||||
const page = searchParams.get("page");
|
const page = searchParams.get("page");
|
||||||
const search = searchParams.get("search");
|
const search = searchParams.get("search");
|
||||||
const takeData = 10;
|
const takeData = PAGINATION_DEFAULT_TAKE;
|
||||||
const skipData = Number(page) * takeData - takeData;
|
const skipData = Number(page) * takeData - takeData;
|
||||||
console.log("[CATEGORY]", category);
|
|
||||||
let fixData;
|
let fixData;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (category === "dashboard") {
|
if (category === "dashboard") {
|
||||||
const publish = await prisma.donasi.count({
|
const publish = await prisma.donasi.count({
|
||||||
@@ -48,7 +48,7 @@ async function GET(request: Request) {
|
|||||||
where: {
|
where: {
|
||||||
active: true,
|
active: true,
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
const categoryDonation = countCategoryDonation.length;
|
const categoryDonation = countCategoryDonation.length;
|
||||||
@@ -68,7 +68,6 @@ async function GET(request: Request) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log("[STATUS]", checkStatus);
|
|
||||||
|
|
||||||
if (!checkStatus) {
|
if (!checkStatus) {
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
@@ -77,7 +76,7 @@ async function GET(request: Request) {
|
|||||||
message: "Failed to get data donation",
|
message: "Failed to get data donation",
|
||||||
reason: "Status not found",
|
reason: "Status not found",
|
||||||
},
|
},
|
||||||
{ status: 500 }
|
{ status: 500 },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,6 +99,12 @@ async function GET(request: Request) {
|
|||||||
select: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
title: true,
|
title: true,
|
||||||
|
target: true,
|
||||||
|
DonasiMaster_Durasi: {
|
||||||
|
select: {
|
||||||
|
name: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
Author: {
|
Author: {
|
||||||
select: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
@@ -109,7 +114,6 @@ async function GET(request: Request) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log("[LIST]", fixData);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
@@ -118,7 +122,7 @@ async function GET(request: Request) {
|
|||||||
message: `Success get data donation ${category}`,
|
message: `Success get data donation ${category}`,
|
||||||
data: fixData,
|
data: fixData,
|
||||||
},
|
},
|
||||||
{ status: 200 }
|
{ status: 200 },
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error get data donation:", error);
|
console.error("Error get data donation:", error);
|
||||||
@@ -128,7 +132,7 @@ async function GET(request: Request) {
|
|||||||
message: "Failed to get data donation",
|
message: "Failed to get data donation",
|
||||||
reason: (error as Error).message,
|
reason: (error as Error).message,
|
||||||
},
|
},
|
||||||
{ status: 500 }
|
{ status: 500 },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,15 @@
|
|||||||
import { NextResponse } from "next/server";
|
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||||
import prisma from "@/lib/prisma";
|
import prisma from "@/lib/prisma";
|
||||||
|
import { NextResponse } from "next/server";
|
||||||
|
|
||||||
export { GET };
|
export { GET };
|
||||||
|
|
||||||
async function GET(request: Request, { params }: { params: { id: string } }) {
|
async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||||
|
const { searchParams } = new URL(request.url);
|
||||||
|
const page = Number(searchParams.get("page")) || 1;
|
||||||
|
const takeData = PAGINATION_DEFAULT_TAKE;
|
||||||
|
const skipData = page * takeData - takeData;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { id } = params;
|
const { id } = params;
|
||||||
|
|
||||||
@@ -12,6 +18,7 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
|||||||
eventId: id,
|
eventId: id,
|
||||||
},
|
},
|
||||||
select: {
|
select: {
|
||||||
|
id: true,
|
||||||
eventId: true,
|
eventId: true,
|
||||||
userId: true,
|
userId: true,
|
||||||
isPresent: true,
|
isPresent: true,
|
||||||
@@ -35,6 +42,8 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
take: page ? takeData : undefined,
|
||||||
|
skip: page ? skipData : undefined,
|
||||||
});
|
});
|
||||||
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import _ from "lodash";
|
|
||||||
import { prisma } from "@/lib";
|
import { prisma } from "@/lib";
|
||||||
import { NextResponse } from "next/server";
|
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||||
|
import _ from "lodash";
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
|
import { NextResponse } from "next/server";
|
||||||
|
|
||||||
export { GET };
|
export { GET };
|
||||||
|
|
||||||
@@ -11,13 +12,12 @@ async function GET(request: Request) {
|
|||||||
const fixStatus = _.startCase(category || "");
|
const fixStatus = _.startCase(category || "");
|
||||||
|
|
||||||
const search = searchParams.get("search");
|
const search = searchParams.get("search");
|
||||||
const page = searchParams.get("page");
|
const page = Number(searchParams.get("page")) || 1;
|
||||||
const takeData = 10;
|
const takeData = PAGINATION_DEFAULT_TAKE;
|
||||||
const skipData = Number(page) * takeData - takeData;
|
const skipData = page * takeData - takeData;
|
||||||
let fixData;
|
let fixData;
|
||||||
|
|
||||||
console.log("[CATEGORY]", category);
|
|
||||||
// console.log("[FIX STATUS]", fixStatus);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (category === "dashboard") {
|
if (category === "dashboard") {
|
||||||
@@ -71,7 +71,6 @@ async function GET(request: Request) {
|
|||||||
typeOfEvent,
|
typeOfEvent,
|
||||||
};
|
};
|
||||||
} else if (category === "history") {
|
} else if (category === "history") {
|
||||||
console.log("[HISTORY HERE]");
|
|
||||||
|
|
||||||
const data = await prisma.event.findMany({
|
const data = await prisma.event.findMany({
|
||||||
take: page ? takeData : undefined,
|
take: page ? takeData : undefined,
|
||||||
@@ -151,21 +150,22 @@ async function GET(request: Request) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
select: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
title: true,
|
title: true,
|
||||||
tanggal: true,
|
tanggal: true,
|
||||||
Author: {
|
tanggalSelesai: true,
|
||||||
select: {
|
Author: {
|
||||||
id: true,
|
select: {
|
||||||
username: true,
|
id: true,
|
||||||
Profile: {
|
username: true,
|
||||||
select: {
|
Profile: {
|
||||||
name: true,
|
select: {
|
||||||
},
|
name: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
fixData = data;
|
fixData = data;
|
||||||
@@ -177,7 +177,7 @@ async function GET(request: Request) {
|
|||||||
message: `Success get data event ${category}`,
|
message: `Success get data event ${category}`,
|
||||||
data: fixData,
|
data: fixData,
|
||||||
},
|
},
|
||||||
{ status: 200 }
|
{ status: 200 },
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(`[ERROR GET DATA EVENT: ${category}]`, error);
|
console.log(`[ERROR GET DATA EVENT: ${category}]`, error);
|
||||||
@@ -187,7 +187,7 @@ async function GET(request: Request) {
|
|||||||
message: `Error get data event ${category}`,
|
message: `Error get data event ${category}`,
|
||||||
reason: (error as Error).message,
|
reason: (error as Error).message,
|
||||||
},
|
},
|
||||||
{ status: 500 }
|
{ status: 500 },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import {
|
|||||||
NotificationMobileTitleType,
|
NotificationMobileTitleType,
|
||||||
} from "../../../../../../../../types/type-mobile-notification";
|
} from "../../../../../../../../types/type-mobile-notification";
|
||||||
import { routeUserMobile } from "@/lib/mobile/route-page-mobile";
|
import { routeUserMobile } from "@/lib/mobile/route-page-mobile";
|
||||||
|
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||||
|
|
||||||
export { GET, PUT };
|
export { GET, PUT };
|
||||||
|
|
||||||
@@ -14,9 +15,9 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
|||||||
const { id } = params;
|
const { id } = params;
|
||||||
const { searchParams } = new URL(request.url);
|
const { searchParams } = new URL(request.url);
|
||||||
const search = searchParams.get("search");
|
const search = searchParams.get("search");
|
||||||
const page = searchParams.get("page");
|
const page = Number(searchParams.get("page"));
|
||||||
const takeData = 10;
|
const takeData = PAGINATION_DEFAULT_TAKE;
|
||||||
const skipData = Number(page) * takeData - takeData;
|
const skipData = page * takeData - takeData;
|
||||||
const category = searchParams.get("category");
|
const category = searchParams.get("category");
|
||||||
let fixData;
|
let fixData;
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -1,15 +1,16 @@
|
|||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
import { prisma } from "@/lib";
|
import { prisma } from "@/lib";
|
||||||
|
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||||
|
|
||||||
export async function GET(
|
export async function GET(
|
||||||
request: Request,
|
request: Request,
|
||||||
{ params }: { params: { id: string } }
|
{ params }: { params: { id: string } },
|
||||||
) {
|
) {
|
||||||
const { id } = params;
|
const { id } = params;
|
||||||
const { searchParams } = new URL(request.url);
|
const { searchParams } = new URL(request.url);
|
||||||
const search = searchParams.get("search");
|
const search = searchParams.get("search");
|
||||||
const page = searchParams.get("page");
|
const page = searchParams.get("page");
|
||||||
const takeData = 10;
|
const takeData = PAGINATION_DEFAULT_TAKE;
|
||||||
const skipData = Number(page) * takeData - takeData;
|
const skipData = Number(page) * takeData - takeData;
|
||||||
let fixData;
|
let fixData;
|
||||||
|
|
||||||
@@ -60,7 +61,7 @@ export async function GET(
|
|||||||
message: "Success get list report posting",
|
message: "Success get list report posting",
|
||||||
data: fixData,
|
data: fixData,
|
||||||
},
|
},
|
||||||
{ status: 200 }
|
{ status: 200 },
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("[ERROR GET LIST REPORT POSTING]", error);
|
console.error("[ERROR GET LIST REPORT POSTING]", error);
|
||||||
@@ -70,7 +71,7 @@ export async function GET(
|
|||||||
message: "Error get list report posting",
|
message: "Error get list report posting",
|
||||||
reason: (error as Error).message,
|
reason: (error as Error).message,
|
||||||
},
|
},
|
||||||
{ status: 500 }
|
{ status: 500 },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
import { prisma } from "@/lib";
|
import { prisma } from "@/lib";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
|
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||||
|
|
||||||
export { GET };
|
export { GET };
|
||||||
|
|
||||||
@@ -9,7 +10,7 @@ async function GET(request: Request, { params }: { params: { name: string } }) {
|
|||||||
const category = searchParams.get("category");
|
const category = searchParams.get("category");
|
||||||
const search = searchParams.get("search");
|
const search = searchParams.get("search");
|
||||||
const page = searchParams.get("page");
|
const page = searchParams.get("page");
|
||||||
const takeData = 10;
|
const takeData = PAGINATION_DEFAULT_TAKE;
|
||||||
const skipData = Number(page) * takeData - takeData;
|
const skipData = Number(page) * takeData - takeData;
|
||||||
|
|
||||||
let fixData;
|
let fixData;
|
||||||
@@ -79,7 +80,11 @@ async function GET(request: Request, { params }: { params: { name: string } }) {
|
|||||||
_count: {
|
_count: {
|
||||||
select: {
|
select: {
|
||||||
Forum_ReportPosting: true,
|
Forum_ReportPosting: true,
|
||||||
Forum_Komentar: true,
|
Forum_Komentar: {
|
||||||
|
where: {
|
||||||
|
isActive: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -139,6 +144,14 @@ async function GET(request: Request, { params }: { params: { name: string } }) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Hitung count report untuk setiap Forum_Posting id
|
||||||
|
const countByPostingId = data.reduce((acc: any, item: any) => {
|
||||||
|
const key = item.Forum_Posting?.id;
|
||||||
|
if (!key) return acc;
|
||||||
|
acc[key] = (acc[key] || 0) + 1;
|
||||||
|
return acc;
|
||||||
|
}, {});
|
||||||
|
|
||||||
const filterLatest = (data: any) =>
|
const filterLatest = (data: any) =>
|
||||||
Object.values(
|
Object.values(
|
||||||
data.reduce((acc: any, item: any) => {
|
data.reduce((acc: any, item: any) => {
|
||||||
@@ -151,10 +164,16 @@ async function GET(request: Request, { params }: { params: { name: string } }) {
|
|||||||
acc[key] = item;
|
acc[key] = item;
|
||||||
}
|
}
|
||||||
return acc;
|
return acc;
|
||||||
}, {})
|
}, {}),
|
||||||
);
|
);
|
||||||
|
|
||||||
fixData = filterLatest(data);
|
const filteredData = filterLatest(data);
|
||||||
|
|
||||||
|
// Tambahkan count ke setiap item
|
||||||
|
fixData = filteredData.map((item: any) => ({
|
||||||
|
...item,
|
||||||
|
count: countByPostingId[item.Forum_Posting?.id] || 0,
|
||||||
|
}));
|
||||||
} else if (category === "report_comment") {
|
} else if (category === "report_comment") {
|
||||||
const data = await prisma.forum_ReportKomentar.findMany({
|
const data = await prisma.forum_ReportKomentar.findMany({
|
||||||
take: page ? takeData : undefined,
|
take: page ? takeData : undefined,
|
||||||
@@ -193,6 +212,14 @@ async function GET(request: Request, { params }: { params: { name: string } }) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Hitung count report untuk setiap Forum_Komentar id
|
||||||
|
const countByKomentarId = data.reduce((acc: any, item: any) => {
|
||||||
|
const key = item.Forum_Komentar?.id;
|
||||||
|
if (!key) return acc;
|
||||||
|
acc[key] = (acc[key] || 0) + 1;
|
||||||
|
return acc;
|
||||||
|
}, {});
|
||||||
|
|
||||||
const filterLatest = (data: any) =>
|
const filterLatest = (data: any) =>
|
||||||
Object.values(
|
Object.values(
|
||||||
data.reduce((acc: any, item: any) => {
|
data.reduce((acc: any, item: any) => {
|
||||||
@@ -205,10 +232,16 @@ async function GET(request: Request, { params }: { params: { name: string } }) {
|
|||||||
acc[key] = item;
|
acc[key] = item;
|
||||||
}
|
}
|
||||||
return acc;
|
return acc;
|
||||||
}, {})
|
}, {}),
|
||||||
);
|
);
|
||||||
|
|
||||||
fixData = filterLatest(data);
|
const filteredData = filterLatest(data);
|
||||||
|
|
||||||
|
// Tambahkan count ke setiap item
|
||||||
|
fixData = filteredData.map((item: any) => ({
|
||||||
|
...item,
|
||||||
|
count: countByKomentarId[item.Forum_Komentar?.id] || 0,
|
||||||
|
}));
|
||||||
} else {
|
} else {
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{
|
{
|
||||||
@@ -216,7 +249,7 @@ async function GET(request: Request, { params }: { params: { name: string } }) {
|
|||||||
message: "Invalid category",
|
message: "Invalid category",
|
||||||
reason: "Invalid category",
|
reason: "Invalid category",
|
||||||
},
|
},
|
||||||
{ status: 400 }
|
{ status: 400 },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -226,7 +259,7 @@ async function GET(request: Request, { params }: { params: { name: string } }) {
|
|||||||
message: `Success get data forum ${category}`,
|
message: `Success get data forum ${category}`,
|
||||||
data: fixData,
|
data: fixData,
|
||||||
},
|
},
|
||||||
{ status: 200 }
|
{ status: 200 },
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
@@ -235,7 +268,7 @@ async function GET(request: Request, { params }: { params: { name: string } }) {
|
|||||||
message: `Error get data forum ${category}`,
|
message: `Error get data forum ${category}`,
|
||||||
reason: (error as Error).message,
|
reason: (error as Error).message,
|
||||||
},
|
},
|
||||||
{ status: 500 }
|
{ status: 500 },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,20 @@
|
|||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
import prisma from "@/lib/prisma";
|
import prisma from "@/lib/prisma";
|
||||||
|
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||||
|
|
||||||
export async function GET(
|
export async function GET(
|
||||||
request: Request,
|
request: Request,
|
||||||
{ params }: { params: { id: string } }
|
{ params }: { params: { id: string } },
|
||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
let fixData;
|
let fixData;
|
||||||
const { id } = params;
|
const { id } = params;
|
||||||
const { searchParams } = new URL(request.url);
|
const { searchParams } = new URL(request.url);
|
||||||
const page = searchParams.get("page");
|
const page = Number(searchParams.get("page"));
|
||||||
const status = searchParams.get("status");
|
const status = searchParams.get("status");
|
||||||
const takeData = 10;
|
const takeData = PAGINATION_DEFAULT_TAKE;
|
||||||
const skipData = Number(page) * takeData - takeData;
|
const skipData = page * takeData - takeData;
|
||||||
|
|
||||||
const fixStatus = _.startCase(status ? status : "");
|
const fixStatus = _.startCase(status ? status : "");
|
||||||
|
|
||||||
@@ -43,6 +44,7 @@ export async function GET(
|
|||||||
id: true,
|
id: true,
|
||||||
Author: true,
|
Author: true,
|
||||||
StatusInvoice: true,
|
StatusInvoice: true,
|
||||||
|
nominal: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -54,7 +56,7 @@ export async function GET(
|
|||||||
message: "Success get status transaksi",
|
message: "Success get status transaksi",
|
||||||
data: fixData,
|
data: fixData,
|
||||||
},
|
},
|
||||||
{ status: 200 }
|
{ status: 200 },
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Eror get status transaksi", error);
|
console.error("Eror get status transaksi", error);
|
||||||
@@ -64,7 +66,7 @@ export async function GET(
|
|||||||
message: "Error get status transaksi",
|
message: "Error get status transaksi",
|
||||||
reason: (error as Error).message,
|
reason: (error as Error).message,
|
||||||
},
|
},
|
||||||
{ status: 500 }
|
{ status: 500 },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
import { prisma } from "@/lib";
|
import { prisma } from "@/lib";
|
||||||
|
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||||
|
|
||||||
export { GET };
|
export { GET };
|
||||||
|
|
||||||
@@ -9,12 +10,9 @@ async function GET(request: Request) {
|
|||||||
const category = searchParams.get("category");
|
const category = searchParams.get("category");
|
||||||
const search = searchParams.get("search");
|
const search = searchParams.get("search");
|
||||||
const page = searchParams.get("page");
|
const page = searchParams.get("page");
|
||||||
const takeData = 10;
|
const takeData = PAGINATION_DEFAULT_TAKE;
|
||||||
const skipData = Number(page) * takeData - takeData;
|
const skipData = Number(page) * takeData - takeData;
|
||||||
|
|
||||||
console.log("[CATEGORY]", category);
|
|
||||||
console.log("[PAGE]", page);
|
|
||||||
|
|
||||||
let fixData;
|
let fixData;
|
||||||
try {
|
try {
|
||||||
if (category === "dashboard") {
|
if (category === "dashboard") {
|
||||||
@@ -49,7 +47,6 @@ async function GET(request: Request) {
|
|||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
const fixCategoryToStatus = _.startCase(category || "");
|
const fixCategoryToStatus = _.startCase(category || "");
|
||||||
console.log("[STATUS]", fixCategoryToStatus);
|
|
||||||
|
|
||||||
const data = await prisma.investasi.findMany({
|
const data = await prisma.investasi.findMany({
|
||||||
take: page ? takeData : undefined,
|
take: page ? takeData : undefined,
|
||||||
@@ -70,6 +67,12 @@ async function GET(request: Request) {
|
|||||||
select: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
title: true,
|
title: true,
|
||||||
|
targetDana: true,
|
||||||
|
MasterPencarianInvestor: {
|
||||||
|
select: {
|
||||||
|
name: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
author: {
|
author: {
|
||||||
select: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
import { prisma } from "@/lib";
|
import { prisma } from "@/lib";
|
||||||
|
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||||
|
|
||||||
export { GET };
|
export { GET };
|
||||||
|
|
||||||
@@ -8,6 +9,9 @@ async function GET(request: Request, { params }: { params: { name: string } }) {
|
|||||||
const { searchParams } = new URL(request.url);
|
const { searchParams } = new URL(request.url);
|
||||||
const category = searchParams.get("category");
|
const category = searchParams.get("category");
|
||||||
const search = searchParams.get("search");
|
const search = searchParams.get("search");
|
||||||
|
const page = Number(searchParams.get("page")) || 1;
|
||||||
|
const takeData = PAGINATION_DEFAULT_TAKE;
|
||||||
|
const skipData = page * takeData - takeData;
|
||||||
let fixData;
|
let fixData;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -66,6 +70,8 @@ async function GET(request: Request, { params }: { params: { name: string } }) {
|
|||||||
title: true,
|
title: true,
|
||||||
Author: true,
|
Author: true,
|
||||||
},
|
},
|
||||||
|
take: page ? takeData : undefined,
|
||||||
|
skip: page ? skipData : undefined,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,22 @@
|
|||||||
import { prisma } from "@/lib";
|
import { prisma } from "@/lib";
|
||||||
|
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
|
|
||||||
export { GET, POST };
|
export { GET, POST };
|
||||||
|
|
||||||
async function GET() {
|
async function GET(request: Request) {
|
||||||
try {
|
try {
|
||||||
|
const { searchParams } = new URL(request.url);
|
||||||
|
const page = Number(searchParams.get("page"));
|
||||||
|
const takeData = PAGINATION_DEFAULT_TAKE;
|
||||||
|
const skipData = page * takeData - takeData;
|
||||||
|
|
||||||
const data = await prisma.masterBank.findMany({
|
const data = await prisma.masterBank.findMany({
|
||||||
orderBy: {
|
orderBy: {
|
||||||
updatedAt: "desc",
|
updatedAt: "desc",
|
||||||
},
|
},
|
||||||
|
take: page ? takeData : undefined,
|
||||||
|
skip: page ? skipData : undefined,
|
||||||
});
|
});
|
||||||
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { NextResponse } from "next/server";
|
|
||||||
import { prisma } from "@/lib";
|
import { prisma } from "@/lib";
|
||||||
|
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||||
|
import { NextResponse } from "next/server";
|
||||||
|
|
||||||
export { GET, PUT };
|
export { GET, PUT };
|
||||||
|
|
||||||
@@ -11,6 +12,10 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
|||||||
const category = searchParams.get("category");
|
const category = searchParams.get("category");
|
||||||
const subBidangId = searchParams.get("subBidangId");
|
const subBidangId = searchParams.get("subBidangId");
|
||||||
|
|
||||||
|
const page = Number(searchParams.get("page")) || 1;
|
||||||
|
const takeData = PAGINATION_DEFAULT_TAKE;
|
||||||
|
const skipData = page * takeData - takeData;
|
||||||
|
|
||||||
if (category === "all") {
|
if (category === "all") {
|
||||||
const bidang = await prisma.masterBidangBisnis.findUnique({
|
const bidang = await prisma.masterBidangBisnis.findUnique({
|
||||||
where: {
|
where: {
|
||||||
@@ -45,6 +50,16 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
fixData = subBidang;
|
||||||
|
} else if (category === "only-sub-bidang") {
|
||||||
|
const subBidang = await prisma.masterSubBidangBisnis.findMany({
|
||||||
|
where: {
|
||||||
|
masterBidangBisnisId: id,
|
||||||
|
},
|
||||||
|
take: takeData,
|
||||||
|
skip: skipData,
|
||||||
|
});
|
||||||
|
|
||||||
fixData = subBidang;
|
fixData = subBidang;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,9 +86,6 @@ async function PUT(request: Request, { params }: { params: { id: string } }) {
|
|||||||
const { searchParams } = new URL(request.url);
|
const { searchParams } = new URL(request.url);
|
||||||
const category = searchParams.get("category");
|
const category = searchParams.get("category");
|
||||||
|
|
||||||
console.log("category", category);
|
|
||||||
console.log("data", data);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (category === "bidang") {
|
if (category === "bidang") {
|
||||||
const updateData = await prisma.masterBidangBisnis.update({
|
const updateData = await prisma.masterBidangBisnis.update({
|
||||||
|
|||||||
@@ -2,15 +2,24 @@ import { NextResponse } from "next/server";
|
|||||||
import { prisma } from "@/lib";
|
import { prisma } from "@/lib";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import { Prisma } from "@prisma/client";
|
import { Prisma } from "@prisma/client";
|
||||||
|
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||||
|
|
||||||
export { GET, POST };
|
export { GET, POST };
|
||||||
|
|
||||||
async function GET(request: Request) {
|
async function GET(request: Request) {
|
||||||
try {
|
try {
|
||||||
|
const { searchParams } = new URL(request.url);
|
||||||
|
const page = Number(searchParams.get("page"));
|
||||||
|
const takeData = PAGINATION_DEFAULT_TAKE;
|
||||||
|
const skipData = page * takeData - takeData;
|
||||||
|
|
||||||
|
|
||||||
const data = await prisma.masterBidangBisnis.findMany({
|
const data = await prisma.masterBidangBisnis.findMany({
|
||||||
orderBy: {
|
orderBy: {
|
||||||
createdAt: "asc",
|
createdAt: "asc",
|
||||||
},
|
},
|
||||||
|
take: page ? takeData : undefined,
|
||||||
|
skip: page ? skipData : undefined,
|
||||||
});
|
});
|
||||||
|
|
||||||
return NextResponse.json({
|
return NextResponse.json({
|
||||||
|
|||||||
@@ -1,10 +1,14 @@
|
|||||||
import { NextResponse } from "next/server";
|
import { NextRequest, NextResponse } from "next/server";
|
||||||
import prisma from "@/lib/prisma";
|
import prisma from "@/lib/prisma";
|
||||||
|
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||||
|
|
||||||
export { GET, POST };
|
export { GET, POST };
|
||||||
|
|
||||||
async function GET(request: Request) {
|
async function GET(request: NextRequest) {
|
||||||
const { searchParams } = new URL(request.url);
|
const { searchParams } = new URL(request.url);
|
||||||
|
const page = Number(searchParams.get("page"));
|
||||||
|
const takeData = PAGINATION_DEFAULT_TAKE;
|
||||||
|
const skipData = page * takeData - takeData;
|
||||||
// const category = searchParams.get("category");
|
// const category = searchParams.get("category");
|
||||||
let fixData;
|
let fixData;
|
||||||
|
|
||||||
@@ -13,6 +17,8 @@ async function GET(request: Request) {
|
|||||||
orderBy: {
|
orderBy: {
|
||||||
createdAt: "asc",
|
createdAt: "asc",
|
||||||
},
|
},
|
||||||
|
take: page ? takeData : undefined,
|
||||||
|
skip: page ? skipData : undefined,
|
||||||
});
|
});
|
||||||
|
|
||||||
// if (category === "category") {
|
// if (category === "category") {
|
||||||
|
|||||||
@@ -1,14 +1,22 @@
|
|||||||
import { NextResponse } from "next/server";
|
import { NextRequest, NextResponse } from "next/server";
|
||||||
import prisma from "@/lib/prisma";
|
import prisma from "@/lib/prisma";
|
||||||
|
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||||
|
|
||||||
export { GET, POST };
|
export { GET, POST };
|
||||||
|
|
||||||
async function GET(request: Request) {
|
async function GET(request: NextRequest) {
|
||||||
try {
|
try {
|
||||||
|
const searchParams = request.nextUrl.searchParams;
|
||||||
|
const page = Number(searchParams.get("page"));
|
||||||
|
const takeData = PAGINATION_DEFAULT_TAKE;
|
||||||
|
const skipData = page * takeData - takeData;
|
||||||
|
|
||||||
const data = await prisma.eventMaster_TipeAcara.findMany({
|
const data = await prisma.eventMaster_TipeAcara.findMany({
|
||||||
orderBy: {
|
orderBy: {
|
||||||
updatedAt: "desc",
|
updatedAt: "desc",
|
||||||
},
|
},
|
||||||
|
take: page ? takeData : undefined,
|
||||||
|
skip: page ? skipData : undefined,
|
||||||
});
|
});
|
||||||
|
|
||||||
return NextResponse.json({
|
return NextResponse.json({
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { prisma } from "@/lib";
|
import { prisma } from "@/lib";
|
||||||
|
import { funSendToWhatsApp } from "@/lib/code-otp-sender";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
|
|
||||||
@@ -50,8 +51,25 @@ async function PUT(request: Request, { params }: { params: { id: string } }) {
|
|||||||
data: {
|
data: {
|
||||||
active: data.active,
|
active: data.active,
|
||||||
},
|
},
|
||||||
|
select: {
|
||||||
|
nomor: true,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (data.active) {
|
||||||
|
const resSendCode = await funSendToWhatsApp({
|
||||||
|
nomor: updateData.nomor,
|
||||||
|
newMessage:
|
||||||
|
"Halo sahabat HIConnect, \nSelamat akun anda telah aktif ! \n\n*Pesan ini di kirim secara otomatis, tidak perlu di balas.",
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
const resSendCode = await funSendToWhatsApp({
|
||||||
|
nomor: updateData.nomor,
|
||||||
|
newMessage:
|
||||||
|
"Halo sahabat HIConnect, \nMohon maaf akun anda telah dinonaktifkan ! Hubungi admin untuk informasi lebih lanjut. \n\n*Pesan ini di kirim secara otomatis, tidak perlu di balas.",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
console.log("[Update Active Berhasil]", updateData);
|
console.log("[Update Active Berhasil]", updateData);
|
||||||
} else if (category === "role") {
|
} else if (category === "role") {
|
||||||
const fixName = _.startCase(data.role.replace(/_/g, " "));
|
const fixName = _.startCase(data.role.replace(/_/g, " "));
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { NextResponse } from "next/server";
|
|
||||||
import { prisma } from "@/lib";
|
import { prisma } from "@/lib";
|
||||||
|
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||||
|
import { NextResponse } from "next/server";
|
||||||
|
|
||||||
export { GET };
|
export { GET };
|
||||||
|
|
||||||
@@ -7,10 +8,16 @@ async function GET(request: Request) {
|
|||||||
const { searchParams } = new URL(request.url);
|
const { searchParams } = new URL(request.url);
|
||||||
const search = searchParams.get("search");
|
const search = searchParams.get("search");
|
||||||
const category = searchParams.get("category");
|
const category = searchParams.get("category");
|
||||||
|
const page = Number(searchParams.get("page"));
|
||||||
|
const takeData = PAGINATION_DEFAULT_TAKE;
|
||||||
|
const skipData = page * takeData - takeData;
|
||||||
|
|
||||||
|
console.log("SEARCH", search);
|
||||||
|
console.log("PAGE", page);
|
||||||
|
|
||||||
let fixData;
|
let fixData;
|
||||||
try {
|
try {
|
||||||
if(category === "only-user"){
|
if (category === "only-user") {
|
||||||
fixData = await prisma.user.findMany({
|
fixData = await prisma.user.findMany({
|
||||||
orderBy: {
|
orderBy: {
|
||||||
updatedAt: "desc",
|
updatedAt: "desc",
|
||||||
@@ -22,8 +29,10 @@ async function GET(request: Request) {
|
|||||||
mode: "insensitive",
|
mode: "insensitive",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
take: page ? takeData : undefined,
|
||||||
|
skip: page ? skipData : undefined,
|
||||||
});
|
});
|
||||||
} else if(category === "only-admin"){
|
} else if (category === "only-admin") {
|
||||||
fixData = await prisma.user.findMany({
|
fixData = await prisma.user.findMany({
|
||||||
orderBy: {
|
orderBy: {
|
||||||
updatedAt: "desc",
|
updatedAt: "desc",
|
||||||
@@ -35,8 +44,10 @@ async function GET(request: Request) {
|
|||||||
mode: "insensitive",
|
mode: "insensitive",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
take: page ? takeData : undefined,
|
||||||
|
skip: page ? skipData : undefined,
|
||||||
});
|
});
|
||||||
} else if (category === "all-role"){
|
} else if (category === "all-role") {
|
||||||
fixData = await prisma.user.findMany({
|
fixData = await prisma.user.findMany({
|
||||||
orderBy: {
|
orderBy: {
|
||||||
updatedAt: "desc",
|
updatedAt: "desc",
|
||||||
@@ -48,13 +59,15 @@ async function GET(request: Request) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
masterUserRoleId: "2",
|
masterUserRoleId: "2",
|
||||||
}
|
},
|
||||||
],
|
],
|
||||||
username: {
|
username: {
|
||||||
contains: search || "",
|
contains: search || "",
|
||||||
mode: "insensitive",
|
mode: "insensitive",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
take: page ? takeData : undefined,
|
||||||
|
skip: page ? skipData : undefined,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,13 +78,11 @@ async function GET(request: Request) {
|
|||||||
data: fixData,
|
data: fixData,
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return NextResponse.json(
|
return NextResponse.json({
|
||||||
{
|
status: 500,
|
||||||
status: 500,
|
success: false,
|
||||||
success: false,
|
message: "Error get data user access",
|
||||||
message: "Error get data user access",
|
reason: (error as Error).message,
|
||||||
reason: (error as Error).message,
|
});
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import _ from "lodash";
|
|||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
import { prisma } from "@/lib";
|
import { prisma } from "@/lib";
|
||||||
|
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||||
|
|
||||||
export { GET };
|
export { GET };
|
||||||
|
|
||||||
@@ -12,7 +13,7 @@ async function GET(request: Request) {
|
|||||||
|
|
||||||
const search = searchParams.get("search");
|
const search = searchParams.get("search");
|
||||||
const page = searchParams.get("page");
|
const page = searchParams.get("page");
|
||||||
const takeData = 10;
|
const takeData = PAGINATION_DEFAULT_TAKE;
|
||||||
const skipData = Number(page) * takeData - takeData;
|
const skipData = Number(page) * takeData - takeData;
|
||||||
let fixData;
|
let fixData;
|
||||||
|
|
||||||
|
|||||||
@@ -4,13 +4,42 @@ import { prisma } from "@/lib";
|
|||||||
export { POST, GET };
|
export { POST, GET };
|
||||||
|
|
||||||
async function POST(request: NextRequest) {
|
async function POST(request: NextRequest) {
|
||||||
const { data } = await request.json();
|
|
||||||
try {
|
try {
|
||||||
|
// Parse the request body - can accept either nested under 'data' or directly
|
||||||
|
const requestBody = await request.json();
|
||||||
|
|
||||||
|
// Check if the data is nested under 'data' property (as described in the issue)
|
||||||
|
// or if it's directly in the request body (more common pattern)
|
||||||
|
const payload = requestBody.data ? requestBody.data : requestBody;
|
||||||
|
|
||||||
|
const { userId, platform, deviceId, model, appVersion, fcmToken } = payload;
|
||||||
|
|
||||||
const { userId, platform, deviceId, model, appVersion, fcmToken } = data;
|
// Validate required fields
|
||||||
|
|
||||||
if (!fcmToken) {
|
if (!fcmToken) {
|
||||||
return NextResponse.json({ error: "Missing Token" }, { status: 400 });
|
return NextResponse.json(
|
||||||
|
{ error: "Missing FCM token", field: "fcmToken" },
|
||||||
|
{ status: 400 }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!userId) {
|
||||||
|
return NextResponse.json(
|
||||||
|
{ error: "Missing user ID", field: "userId" },
|
||||||
|
{ status: 400 }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verify that the user exists before creating/updating the device token
|
||||||
|
const userExists = await prisma.user.findUnique({
|
||||||
|
where: { id: userId },
|
||||||
|
select: { id: true }
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!userExists) {
|
||||||
|
return NextResponse.json(
|
||||||
|
{ error: "User not found", field: "userId" },
|
||||||
|
{ status: 404 }
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const existing = await prisma.tokenUserDevice.findFirst({
|
const existing = await prisma.tokenUserDevice.findFirst({
|
||||||
@@ -23,7 +52,6 @@ async function POST(request: NextRequest) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
console.log("✅ EX", existing);
|
console.log("✅ EX", existing);
|
||||||
|
|
||||||
let deviceToken;
|
let deviceToken;
|
||||||
@@ -31,7 +59,7 @@ async function POST(request: NextRequest) {
|
|||||||
if (existing) {
|
if (existing) {
|
||||||
deviceToken = await prisma.tokenUserDevice.update({
|
deviceToken = await prisma.tokenUserDevice.update({
|
||||||
where: {
|
where: {
|
||||||
id: existing?.id,
|
id: existing.id,
|
||||||
},
|
},
|
||||||
data: {
|
data: {
|
||||||
platform,
|
platform,
|
||||||
@@ -43,7 +71,7 @@ async function POST(request: NextRequest) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// Buat baru jika belum ada
|
// Create new device token record
|
||||||
deviceToken = await prisma.tokenUserDevice.create({
|
deviceToken = await prisma.tokenUserDevice.create({
|
||||||
data: {
|
data: {
|
||||||
token: fcmToken,
|
token: fcmToken,
|
||||||
@@ -58,9 +86,16 @@ async function POST(request: NextRequest) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return NextResponse.json({ success: true, data: deviceToken });
|
return NextResponse.json({ success: true, data: deviceToken });
|
||||||
} catch (error) {
|
} catch (error: any) {
|
||||||
|
console.error("Error registering device token:", error);
|
||||||
|
|
||||||
|
// Return more informative error response
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: (error as Error).message },
|
{
|
||||||
|
error: "Internal server error",
|
||||||
|
message: error.message || "An unexpected error occurred",
|
||||||
|
field: "server"
|
||||||
|
},
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
import prisma from "@/lib/prisma";
|
import prisma from "@/lib/prisma";
|
||||||
|
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||||
|
|
||||||
export { GET, PUT };
|
export { GET, PUT };
|
||||||
|
|
||||||
@@ -10,8 +11,14 @@ async function GET(
|
|||||||
) {
|
) {
|
||||||
const { id, status } = params;
|
const { id, status } = params;
|
||||||
const fixStatus = _.startCase(status);
|
const fixStatus = _.startCase(status);
|
||||||
|
const { searchParams } = new URL(request.url);
|
||||||
|
const page = Number(searchParams.get("page")) || 1;
|
||||||
|
const takeData = PAGINATION_DEFAULT_TAKE
|
||||||
|
const skipData = page * takeData - takeData;
|
||||||
|
|
||||||
let fixData;
|
let fixData;
|
||||||
|
let meta = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const checkStatus = await prisma.donasiMaster_StatusDonasi.findFirst({
|
const checkStatus = await prisma.donasiMaster_StatusDonasi.findFirst({
|
||||||
where: {
|
where: {
|
||||||
@@ -50,18 +57,38 @@ async function GET(
|
|||||||
orderBy: {
|
orderBy: {
|
||||||
updatedAt: "desc",
|
updatedAt: "desc",
|
||||||
},
|
},
|
||||||
|
take: takeData,
|
||||||
|
skip: skipData,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const totalData = await prisma.donasi.count({
|
||||||
|
where: {
|
||||||
|
authorId: id,
|
||||||
|
donasiMaster_StatusDonasiId: checkStatus.id,
|
||||||
|
active: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const totalPages = Math.ceil(totalData / takeData);
|
||||||
|
|
||||||
fixData = res.map((v: any) => ({
|
fixData = res.map((v: any) => ({
|
||||||
..._.omit(v, ["DonasiMaster_Durasi"]),
|
..._.omit(v, ["DonasiMaster_Durasi"]),
|
||||||
nameDonasiDurasi: v.DonasiMaster_Durasi.name,
|
nameDonasiDurasi: v.DonasiMaster_Durasi.name,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
meta = {
|
||||||
|
currentPage: page,
|
||||||
|
totalData: totalData,
|
||||||
|
totalPage: totalPages,
|
||||||
|
dataPerPage: takeData,
|
||||||
|
};
|
||||||
|
|
||||||
return NextResponse.json({
|
return NextResponse.json({
|
||||||
status: 200,
|
status: 200,
|
||||||
success: true,
|
success: true,
|
||||||
message: "Berhasil mendapatkan data",
|
message: "Berhasil mendapatkan data",
|
||||||
data: fixData,
|
data: fixData,
|
||||||
|
...(meta && { meta }),
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log("[ERROR]", error);
|
console.log("[ERROR]", error);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
import { prisma } from "@/lib";
|
import { prisma } from "@/lib";
|
||||||
|
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||||
|
|
||||||
export { GET };
|
export { GET };
|
||||||
|
|
||||||
@@ -7,7 +8,7 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
|||||||
const { id } = params;
|
const { id } = params;
|
||||||
const { searchParams } = new URL(request.url);
|
const { searchParams } = new URL(request.url);
|
||||||
const page = Number(searchParams.get("page"));
|
const page = Number(searchParams.get("page"));
|
||||||
const takeData = 5;
|
const takeData = PAGINATION_DEFAULT_TAKE;
|
||||||
const skipData = page * takeData - takeData;
|
const skipData = page * takeData - takeData;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||||
import prisma from "@/lib/prisma";
|
import prisma from "@/lib/prisma";
|
||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
|
|
||||||
@@ -9,11 +10,12 @@ export async function GET(
|
|||||||
let fixData;
|
let fixData;
|
||||||
const { id } = params;
|
const { id } = params;
|
||||||
const { searchParams } = new URL(request.url);
|
const { searchParams } = new URL(request.url);
|
||||||
const page = Number(searchParams.get("page"));
|
const page = Number(searchParams.get("page")) || 1; // Default page 1 jika tidak ada atau invalid
|
||||||
const takeData = 10;
|
const takeData = PAGINATION_DEFAULT_TAKE;
|
||||||
const skipData = page * takeData - takeData;
|
const skipData = page * takeData - takeData;
|
||||||
|
|
||||||
fixData = await prisma.donasi_Invoice.findMany({
|
// Query data dengan pagination
|
||||||
|
const data = await prisma.donasi_Invoice.findMany({
|
||||||
take: page ? takeData : undefined,
|
take: page ? takeData : undefined,
|
||||||
skip: page ? skipData : undefined,
|
skip: page ? skipData : undefined,
|
||||||
orderBy: {
|
orderBy: {
|
||||||
@@ -59,10 +61,31 @@ export async function GET(
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Hitung total data untuk pagination
|
||||||
|
const totalCount = await prisma.donasi_Invoice.count({
|
||||||
|
where: {
|
||||||
|
donasiId: id,
|
||||||
|
DonasiMaster_StatusInvoice: {
|
||||||
|
name: "Berhasil",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
// Hitung total halaman
|
||||||
|
const totalPages = Math.ceil(totalCount / takeData);
|
||||||
|
|
||||||
|
fixData = data;
|
||||||
|
|
||||||
return NextResponse.json({
|
return NextResponse.json({
|
||||||
success: true,
|
success: true,
|
||||||
message: "Data berhasil diambil",
|
message: "Data berhasil diambil",
|
||||||
data: fixData,
|
data: fixData,
|
||||||
|
pagination: {
|
||||||
|
currentPage: page,
|
||||||
|
totalPages: totalPages,
|
||||||
|
totalData: totalCount,
|
||||||
|
dataPerPage: takeData,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return NextResponse.json({
|
return NextResponse.json({
|
||||||
|
|||||||
@@ -1,25 +1,40 @@
|
|||||||
import { NextRequest, NextResponse } from "next/server";
|
import { NextRequest, NextResponse } from "next/server";
|
||||||
import { prisma } from "@/lib";
|
import { prisma } from "@/lib";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
|
import { sendNotificationMobileToManyUser } from "@/lib/mobile/notification/send-notification";
|
||||||
|
import {
|
||||||
|
NotificationMobileBodyType,
|
||||||
|
NotificationMobileTitleType,
|
||||||
|
} from "../../../../../../../types/type-mobile-notification";
|
||||||
|
import { routeUserMobile } from "@/lib/mobile/route-page-mobile";
|
||||||
|
import { funFindDonaturList } from "@/lib/mobile/donation/find-donatur-list";
|
||||||
|
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||||
|
|
||||||
export { POST, GET, PUT, DELETE };
|
export { POST, GET, PUT, DELETE };
|
||||||
|
|
||||||
async function POST(
|
async function POST(
|
||||||
request: NextRequest,
|
request: NextRequest,
|
||||||
{ params }: { params: { id: string } }
|
{ params }: { params: { id: string } },
|
||||||
) {
|
) {
|
||||||
const { id } = params;
|
const { id } = params;
|
||||||
const { data } = await request.json();
|
const { data } = await request.json();
|
||||||
|
const { title, deskripsi, imageId } = data;
|
||||||
|
|
||||||
|
const senderId = await prisma.donasi.findUnique({
|
||||||
|
where: { id: id },
|
||||||
|
select: {
|
||||||
|
authorId: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (data && data?.imageId) {
|
if (data && data?.imageId) {
|
||||||
const createWithFile = await prisma.donasi_Kabar.create({
|
const createWithFile = await prisma.donasi_Kabar.create({
|
||||||
data: {
|
data: {
|
||||||
title: data.title,
|
title: title,
|
||||||
deskripsi: data.deskripsi,
|
deskripsi: deskripsi,
|
||||||
donasiId: id,
|
donasiId: id,
|
||||||
imageId: data.imageId,
|
imageId: imageId,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -28,8 +43,8 @@ async function POST(
|
|||||||
} else {
|
} else {
|
||||||
const create = await prisma.donasi_Kabar.create({
|
const create = await prisma.donasi_Kabar.create({
|
||||||
data: {
|
data: {
|
||||||
title: data.title,
|
title: title,
|
||||||
deskripsi: data.deskripsi,
|
deskripsi: deskripsi,
|
||||||
donasiId: id,
|
donasiId: id,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -38,6 +53,25 @@ async function POST(
|
|||||||
return NextResponse.json({ status: 400, message: "Gagal disimpan" });
|
return NextResponse.json({ status: 400, message: "Gagal disimpan" });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const recipientIds = await funFindDonaturList(id);
|
||||||
|
|
||||||
|
// SEND NOTIFICATION
|
||||||
|
if (recipientIds.length > 0) {
|
||||||
|
await sendNotificationMobileToManyUser({
|
||||||
|
recipientIds,
|
||||||
|
senderId: senderId?.authorId!,
|
||||||
|
payload: {
|
||||||
|
title: "Berita terbaru" as NotificationMobileTitleType,
|
||||||
|
body: `Ada berita terupdate pada ${title}` as NotificationMobileBodyType,
|
||||||
|
type: "announcement",
|
||||||
|
kategoriApp: "DONASI",
|
||||||
|
deepLink: routeUserMobile.donationDetailPublish({
|
||||||
|
id: id,
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return NextResponse.json({
|
return NextResponse.json({
|
||||||
status: 200,
|
status: 200,
|
||||||
success: true,
|
success: true,
|
||||||
@@ -56,16 +90,21 @@ async function POST(
|
|||||||
|
|
||||||
async function GET(
|
async function GET(
|
||||||
request: NextRequest,
|
request: NextRequest,
|
||||||
{ params }: { params: { id: string } }
|
{ params }: { params: { id: string } },
|
||||||
) {
|
) {
|
||||||
const { id } = params;
|
const { id } = params;
|
||||||
const { searchParams } = new URL(request.url);
|
const { searchParams } = new URL(request.url);
|
||||||
const category = searchParams.get("category");
|
const category = searchParams.get("category");
|
||||||
|
const page = Number(searchParams.get("page")) || 1; // Default page 1 jika tidak ada
|
||||||
|
const takeData = PAGINATION_DEFAULT_TAKE; // Default 10 data per halaman
|
||||||
|
const skipData = page * takeData - takeData;
|
||||||
|
|
||||||
let fixData;
|
let fixData;
|
||||||
|
let totalCount = 0; // Untuk menghitung total data
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (category === "get-all") {
|
if (category === "get-all") {
|
||||||
fixData = await prisma.donasi_Kabar.findMany({
|
const data = await prisma.donasi_Kabar.findMany({
|
||||||
orderBy: {
|
orderBy: {
|
||||||
updatedAt: "desc",
|
updatedAt: "desc",
|
||||||
},
|
},
|
||||||
@@ -73,6 +112,8 @@ async function GET(
|
|||||||
donasiId: id,
|
donasiId: id,
|
||||||
active: true,
|
active: true,
|
||||||
},
|
},
|
||||||
|
take: page ? takeData : undefined,
|
||||||
|
skip: page ? skipData : undefined,
|
||||||
select: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
title: true,
|
title: true,
|
||||||
@@ -80,6 +121,17 @@ async function GET(
|
|||||||
createdAt: true,
|
createdAt: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Hitung total data untuk pagination
|
||||||
|
totalCount = await prisma.donasi_Kabar.count({
|
||||||
|
where: {
|
||||||
|
donasiId: id,
|
||||||
|
active: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
fixData = data;
|
||||||
|
|
||||||
} else if (category === "get-one") {
|
} else if (category === "get-one") {
|
||||||
const data = await prisma.donasi_Kabar.findUnique({
|
const data = await prisma.donasi_Kabar.findUnique({
|
||||||
where: {
|
where: {
|
||||||
@@ -102,11 +154,24 @@ async function GET(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Hitung total halaman jika kategori adalah get-all
|
||||||
|
let pagination = undefined;
|
||||||
|
if (category === "get-all") {
|
||||||
|
const totalPages = Math.ceil(totalCount / takeData);
|
||||||
|
pagination = {
|
||||||
|
currentPage: page,
|
||||||
|
totalPages: totalPages,
|
||||||
|
totalData: totalCount,
|
||||||
|
dataPerPage: takeData,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
return NextResponse.json({
|
return NextResponse.json({
|
||||||
status: 200,
|
status: 200,
|
||||||
success: true,
|
success: true,
|
||||||
message: "Berhasil mengambil kabar",
|
message: "Berhasil mengambil kabar",
|
||||||
data: fixData,
|
data: fixData,
|
||||||
|
pagination: pagination,
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("[ERROR GET NEWS]", error);
|
console.error("[ERROR GET NEWS]", error);
|
||||||
@@ -178,7 +243,7 @@ async function PUT(request: Request, { params }: { params: { id: string } }) {
|
|||||||
|
|
||||||
async function DELETE(
|
async function DELETE(
|
||||||
request: Request,
|
request: Request,
|
||||||
{ params }: { params: { id: string } }
|
{ params }: { params: { id: string } },
|
||||||
) {
|
) {
|
||||||
const { id } = params;
|
const { id } = params;
|
||||||
try {
|
try {
|
||||||
@@ -198,7 +263,7 @@ async function DELETE(
|
|||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${process.env.WS_APIKEY}`,
|
Authorization: `Bearer ${process.env.WS_APIKEY}`,
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!deleteImage) {
|
if (!deleteImage) {
|
||||||
|
|||||||
@@ -4,8 +4,9 @@ import _ from "lodash";
|
|||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
import { NotificationMobileBodyType } from "../../../../../types/type-mobile-notification";
|
import { NotificationMobileBodyType } from "../../../../../types/type-mobile-notification";
|
||||||
import { routeAdminMobile } from "@/lib/mobile/route-page-mobile";
|
import { routeAdminMobile } from "@/lib/mobile/route-page-mobile";
|
||||||
|
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||||
|
|
||||||
export { POST };
|
export { POST, GET };
|
||||||
|
|
||||||
async function POST(request: Request) {
|
async function POST(request: Request) {
|
||||||
const { data } = await request.json();
|
const { data } = await request.json();
|
||||||
@@ -121,11 +122,16 @@ async function POST(request: Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GET ALL DATA DONASI
|
// GET ALL DATA DONASI
|
||||||
export async function GET(request: Request) {
|
async function GET(request: Request) {
|
||||||
const { searchParams } = new URL(request.url);
|
const { searchParams } = new URL(request.url);
|
||||||
const category = searchParams.get("category");
|
const category = searchParams.get("category");
|
||||||
const authorId = searchParams.get("authorId");
|
const authorId = searchParams.get("authorId");
|
||||||
|
const page = Number(searchParams.get("page")) || 1; // Default page 1 jika tidak ada
|
||||||
|
const takeData = PAGINATION_DEFAULT_TAKE; // Default 10 data per halaman
|
||||||
|
const skipData = page * takeData - takeData;
|
||||||
|
|
||||||
let fixData;
|
let fixData;
|
||||||
|
let totalCount = 0; // Untuk menghitung total data
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (category === "beranda") {
|
if (category === "beranda") {
|
||||||
@@ -137,6 +143,8 @@ export async function GET(request: Request) {
|
|||||||
donasiMaster_StatusDonasiId: "1",
|
donasiMaster_StatusDonasiId: "1",
|
||||||
active: true,
|
active: true,
|
||||||
},
|
},
|
||||||
|
take: page ? takeData : undefined,
|
||||||
|
skip: page ? skipData : undefined,
|
||||||
select: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
imageId: true,
|
imageId: true,
|
||||||
@@ -152,6 +160,14 @@ export async function GET(request: Request) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Hitung total data untuk pagination
|
||||||
|
totalCount = await prisma.donasi.count({
|
||||||
|
where: {
|
||||||
|
donasiMaster_StatusDonasiId: "1",
|
||||||
|
active: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
fixData = data.map((v: any) => ({
|
fixData = data.map((v: any) => ({
|
||||||
..._.omit(v, ["DonasiMaster_Durasi"]),
|
..._.omit(v, ["DonasiMaster_Durasi"]),
|
||||||
durasiDonasi: v.DonasiMaster_Durasi.name,
|
durasiDonasi: v.DonasiMaster_Durasi.name,
|
||||||
@@ -164,6 +180,8 @@ export async function GET(request: Request) {
|
|||||||
where: {
|
where: {
|
||||||
authorId: authorId,
|
authorId: authorId,
|
||||||
},
|
},
|
||||||
|
take: page ? takeData : undefined,
|
||||||
|
skip: page ? skipData : undefined,
|
||||||
select: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
nominal: true,
|
nominal: true,
|
||||||
@@ -190,6 +208,13 @@ export async function GET(request: Request) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Hitung total data untuk pagination
|
||||||
|
totalCount = await prisma.donasi_Invoice.count({
|
||||||
|
where: {
|
||||||
|
authorId: authorId,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
fixData = data.map((v: any) => ({
|
fixData = data.map((v: any) => ({
|
||||||
..._.omit(v, ["DonasiMaster_StatusInvoice", "Donasi"]),
|
..._.omit(v, ["DonasiMaster_StatusInvoice", "Donasi"]),
|
||||||
statusInvoice: v.DonasiMaster_StatusInvoice.name,
|
statusInvoice: v.DonasiMaster_StatusInvoice.name,
|
||||||
@@ -202,8 +227,21 @@ export async function GET(request: Request) {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Hitung total halaman
|
||||||
|
const totalPages = Math.ceil(totalCount / takeData);
|
||||||
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ success: true, message: "Data berhasil diambil", data: fixData },
|
{
|
||||||
|
success: true,
|
||||||
|
message: "Data berhasil diambil",
|
||||||
|
data: fixData,
|
||||||
|
pagination: {
|
||||||
|
currentPage: page,
|
||||||
|
totalPages: totalPages,
|
||||||
|
totalData: totalCount,
|
||||||
|
dataPerPage: takeData,
|
||||||
|
}
|
||||||
|
},
|
||||||
{ status: 200 }
|
{ status: 200 }
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
import prisma from "@/lib/prisma";
|
import prisma from "@/lib/prisma";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
|
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||||
|
|
||||||
export { GET, PUT };
|
export { GET, PUT };
|
||||||
|
|
||||||
@@ -12,6 +13,11 @@ async function GET(
|
|||||||
const { id, status } = params;
|
const { id, status } = params;
|
||||||
const fixStatusName = _.startCase(status);
|
const fixStatusName = _.startCase(status);
|
||||||
|
|
||||||
|
const { searchParams } = new URL(request.url);
|
||||||
|
const page = Number(searchParams.get("page")) || 1;
|
||||||
|
const takeData = PAGINATION_DEFAULT_TAKE
|
||||||
|
const skipData = page * takeData - takeData;
|
||||||
|
|
||||||
const data = await prisma.event.findMany({
|
const data = await prisma.event.findMany({
|
||||||
orderBy: {
|
orderBy: {
|
||||||
updatedAt: "desc",
|
updatedAt: "desc",
|
||||||
@@ -37,13 +43,35 @@ async function GET(
|
|||||||
},
|
},
|
||||||
authorId: true,
|
authorId: true,
|
||||||
},
|
},
|
||||||
|
take: takeData,
|
||||||
|
skip: skipData,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Get total count for pagination info
|
||||||
|
const totalCount = await prisma.event.count({
|
||||||
|
where: {
|
||||||
|
active: true,
|
||||||
|
authorId: id,
|
||||||
|
isArsip: false,
|
||||||
|
EventMaster_Status: {
|
||||||
|
name: fixStatusName,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const totalPages = Math.ceil(totalCount / takeData);
|
||||||
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{
|
{
|
||||||
success: true,
|
success: true,
|
||||||
message: "Success get event",
|
message: "Success get event",
|
||||||
data: data,
|
data: data,
|
||||||
|
pagination: {
|
||||||
|
currentPage: page,
|
||||||
|
totalPages: totalPages,
|
||||||
|
totalData: totalCount,
|
||||||
|
dataPerPage: takeData,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{ status: 200 }
|
{ status: 200 }
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import {
|
|||||||
NotificationMobileTitleType,
|
NotificationMobileTitleType,
|
||||||
} from "../../../../../../../types/type-mobile-notification";
|
} from "../../../../../../../types/type-mobile-notification";
|
||||||
import { routeUserMobile } from "@/lib/mobile/route-page-mobile";
|
import { routeUserMobile } from "@/lib/mobile/route-page-mobile";
|
||||||
|
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||||
|
|
||||||
export { GET, POST };
|
export { GET, POST };
|
||||||
|
|
||||||
@@ -47,7 +48,7 @@ async function POST(request: Request, { params }: { params: { id: string } }) {
|
|||||||
message: "Success join event",
|
message: "Success join event",
|
||||||
data: createJoin,
|
data: createJoin,
|
||||||
},
|
},
|
||||||
{ status: 200 }
|
{ status: 200 },
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
@@ -56,7 +57,7 @@ async function POST(request: Request, { params }: { params: { id: string } }) {
|
|||||||
message: "Error join event",
|
message: "Error join event",
|
||||||
reason: (error as Error).message,
|
reason: (error as Error).message,
|
||||||
},
|
},
|
||||||
{ status: 500 }
|
{ status: 500 },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -64,12 +65,17 @@ async function POST(request: Request, { params }: { params: { id: string } }) {
|
|||||||
async function GET(request: Request, { params }: { params: { id: string } }) {
|
async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||||
try {
|
try {
|
||||||
const { id } = params;
|
const { id } = params;
|
||||||
|
const { searchParams } = new URL(request.url);
|
||||||
|
const page = Number(searchParams.get("page")) || 1;
|
||||||
|
const takeData = PAGINATION_DEFAULT_TAKE
|
||||||
|
const skipData = page * takeData - takeData;
|
||||||
|
|
||||||
const data = await prisma.event_Peserta.findMany({
|
const data = await prisma.event_Peserta.findMany({
|
||||||
where: {
|
where: {
|
||||||
eventId: id,
|
eventId: id,
|
||||||
},
|
},
|
||||||
select: {
|
select: {
|
||||||
|
id: true,
|
||||||
eventId: true,
|
eventId: true,
|
||||||
userId: true,
|
userId: true,
|
||||||
isPresent: true,
|
isPresent: true,
|
||||||
@@ -87,6 +93,8 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
take: takeData,
|
||||||
|
skip: skipData,
|
||||||
});
|
});
|
||||||
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
@@ -94,8 +102,14 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
|||||||
success: true,
|
success: true,
|
||||||
message: "Success get participants",
|
message: "Success get participants",
|
||||||
data: data,
|
data: data,
|
||||||
|
meta: {
|
||||||
|
page,
|
||||||
|
take: takeData,
|
||||||
|
total: await prisma.event_Peserta.count({ where: { eventId: id } }),
|
||||||
|
totalPages: Math.ceil(await prisma.event_Peserta.count({ where: { eventId: id } }) / takeData),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{ status: 200 }
|
{ status: 200 },
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
@@ -104,7 +118,7 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
|||||||
message: "Error get participants",
|
message: "Error get participants",
|
||||||
reason: (error as Error).message,
|
reason: (error as Error).message,
|
||||||
},
|
},
|
||||||
{ status: 500 }
|
{ status: 500 },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import _ from "lodash";
|
|||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
import { NotificationMobileBodyType } from "../../../../../types/type-mobile-notification";
|
import { NotificationMobileBodyType } from "../../../../../types/type-mobile-notification";
|
||||||
|
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||||
|
|
||||||
export { GET, POST };
|
export { GET, POST };
|
||||||
|
|
||||||
@@ -76,11 +77,15 @@ async function GET(request: Request) {
|
|||||||
const { searchParams } = new URL(request.url);
|
const { searchParams } = new URL(request.url);
|
||||||
const category = searchParams.get("category");
|
const category = searchParams.get("category");
|
||||||
const userId = searchParams.get("userId");
|
const userId = searchParams.get("userId");
|
||||||
|
const page = Number(searchParams.get("page")) || 1;
|
||||||
|
const takeData = PAGINATION_DEFAULT_TAKE;
|
||||||
|
const skipData = page * takeData - takeData;
|
||||||
|
|
||||||
console.log("[CAT]", category);
|
console.log("[CAT]", category);
|
||||||
console.log("[USER]", userId);
|
console.log("[USER]", userId);
|
||||||
|
|
||||||
let fixData;
|
let fixData;
|
||||||
|
let totalCount = 0;
|
||||||
|
|
||||||
if (category === "beranda") {
|
if (category === "beranda") {
|
||||||
const allData = await prisma.event.findMany({
|
const allData = await prisma.event.findMany({
|
||||||
@@ -108,84 +113,96 @@ async function GET(request: Request) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// const takeData = 10;
|
const [data, count] = await Promise.all([
|
||||||
// const skipData = page * takeData - takeData;
|
prisma.event.findMany({
|
||||||
|
take: takeData,
|
||||||
const data = await prisma.event.findMany({
|
skip: skipData,
|
||||||
// take: takeData,
|
orderBy: [
|
||||||
// skip: skipData,
|
{
|
||||||
orderBy: [
|
tanggal: "asc",
|
||||||
{
|
},
|
||||||
tanggal: "asc",
|
],
|
||||||
|
where: {
|
||||||
|
active: true,
|
||||||
|
eventMaster_StatusId: "1",
|
||||||
|
isArsip: false,
|
||||||
},
|
},
|
||||||
],
|
select: {
|
||||||
where: {
|
id: true,
|
||||||
active: true,
|
title: true,
|
||||||
eventMaster_StatusId: "1",
|
deskripsi: true,
|
||||||
isArsip: false,
|
tanggal: true,
|
||||||
},
|
tanggalSelesai: true,
|
||||||
select: {
|
EventMaster_Status: {
|
||||||
id: true,
|
select: {
|
||||||
title: true,
|
name: true,
|
||||||
deskripsi: true,
|
},
|
||||||
tanggal: true,
|
},
|
||||||
tanggalSelesai: true,
|
authorId: true,
|
||||||
EventMaster_Status: {
|
Author: {
|
||||||
select: {
|
include: {
|
||||||
name: true,
|
Profile: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
authorId: true,
|
}),
|
||||||
Author: {
|
prisma.event.count({
|
||||||
include: {
|
where: {
|
||||||
Profile: true,
|
active: true,
|
||||||
},
|
eventMaster_StatusId: "1",
|
||||||
|
isArsip: false,
|
||||||
},
|
},
|
||||||
},
|
})
|
||||||
});
|
]);
|
||||||
|
|
||||||
fixData = data;
|
fixData = data;
|
||||||
|
totalCount = count;
|
||||||
} else if (category === "contribution") {
|
} else if (category === "contribution") {
|
||||||
const data = await prisma.event_Peserta.findMany({
|
const [data, count] = await Promise.all([
|
||||||
where: {
|
prisma.event_Peserta.findMany({
|
||||||
userId: userId,
|
take: takeData,
|
||||||
},
|
skip: skipData,
|
||||||
select: {
|
where: {
|
||||||
eventId: true,
|
userId: userId,
|
||||||
userId: true,
|
},
|
||||||
Event: {
|
select: {
|
||||||
select: {
|
id: true,
|
||||||
id: true,
|
eventId: true,
|
||||||
title: true,
|
userId: true,
|
||||||
tanggal: true,
|
Event: {
|
||||||
Author: {
|
select: {
|
||||||
select: {
|
id: true,
|
||||||
id: true,
|
title: true,
|
||||||
username: true,
|
tanggal: true,
|
||||||
Profile: {
|
Author: {
|
||||||
select: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
name: true,
|
username: true,
|
||||||
imageId: true,
|
Profile: {
|
||||||
|
select: {
|
||||||
|
id: true,
|
||||||
|
name: true,
|
||||||
|
imageId: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
Event_Peserta: {
|
||||||
Event_Peserta: {
|
take: 4,
|
||||||
take: 4,
|
orderBy: {
|
||||||
orderBy: {
|
createdAt: "desc",
|
||||||
createdAt: "desc",
|
},
|
||||||
},
|
select: {
|
||||||
select: {
|
id: true,
|
||||||
id: true,
|
userId: true,
|
||||||
userId: true,
|
User: {
|
||||||
User: {
|
select: {
|
||||||
select: {
|
Profile: {
|
||||||
Profile: {
|
select: {
|
||||||
select: {
|
id: true,
|
||||||
id: true,
|
name: true,
|
||||||
name: true,
|
imageId: true,
|
||||||
imageId: true,
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -194,86 +211,109 @@ async function GET(request: Request) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
}),
|
||||||
// User: {
|
prisma.event_Peserta.count({
|
||||||
// select: {
|
where: {
|
||||||
// id: true,
|
userId: userId,
|
||||||
// username: true,
|
},
|
||||||
// Profile: {
|
})
|
||||||
// select: {
|
]);
|
||||||
// id: true,
|
|
||||||
// name: true,
|
|
||||||
// imageId: true,
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
fixData = data;
|
fixData = data;
|
||||||
|
totalCount = count;
|
||||||
} else if (category === "all-history") {
|
} else if (category === "all-history") {
|
||||||
const data = await prisma.event.findMany({
|
const [data, count] = await Promise.all([
|
||||||
orderBy: {
|
prisma.event.findMany({
|
||||||
tanggal: "desc",
|
take: takeData,
|
||||||
},
|
skip: skipData,
|
||||||
where: {
|
orderBy: {
|
||||||
eventMaster_StatusId: "1",
|
tanggal: "desc",
|
||||||
isArsip: true,
|
},
|
||||||
},
|
where: {
|
||||||
select: {
|
eventMaster_StatusId: "1",
|
||||||
id: true,
|
isArsip: true,
|
||||||
title: true,
|
},
|
||||||
tanggal: true,
|
select: {
|
||||||
deskripsi: true,
|
id: true,
|
||||||
active: true,
|
title: true,
|
||||||
authorId: true,
|
tanggal: true,
|
||||||
Author: {
|
deskripsi: true,
|
||||||
select: {
|
active: true,
|
||||||
id: true,
|
authorId: true,
|
||||||
username: true,
|
Author: {
|
||||||
Profile: true,
|
select: {
|
||||||
|
id: true,
|
||||||
|
username: true,
|
||||||
|
Profile: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
}),
|
||||||
});
|
prisma.event.count({
|
||||||
|
where: {
|
||||||
|
eventMaster_StatusId: "1",
|
||||||
|
isArsip: true,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
]);
|
||||||
|
|
||||||
fixData = data;
|
fixData = data;
|
||||||
|
totalCount = count;
|
||||||
} else if (category === "my-history") {
|
} else if (category === "my-history") {
|
||||||
const data = await prisma.event.findMany({
|
const [data, count] = await Promise.all([
|
||||||
orderBy: {
|
prisma.event.findMany({
|
||||||
tanggal: "desc",
|
take: takeData,
|
||||||
},
|
skip: skipData,
|
||||||
where: {
|
orderBy: {
|
||||||
authorId: userId,
|
tanggal: "desc",
|
||||||
eventMaster_StatusId: "1",
|
},
|
||||||
isArsip: true,
|
where: {
|
||||||
},
|
authorId: userId,
|
||||||
select: {
|
eventMaster_StatusId: "1",
|
||||||
id: true,
|
isArsip: true,
|
||||||
title: true,
|
},
|
||||||
tanggal: true,
|
select: {
|
||||||
deskripsi: true,
|
id: true,
|
||||||
active: true,
|
title: true,
|
||||||
authorId: true,
|
tanggal: true,
|
||||||
Author: {
|
deskripsi: true,
|
||||||
select: {
|
active: true,
|
||||||
id: true,
|
authorId: true,
|
||||||
username: true,
|
Author: {
|
||||||
Profile: true,
|
select: {
|
||||||
|
id: true,
|
||||||
|
username: true,
|
||||||
|
Profile: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
}),
|
||||||
});
|
prisma.event.count({
|
||||||
|
where: {
|
||||||
|
authorId: userId,
|
||||||
|
eventMaster_StatusId: "1",
|
||||||
|
isArsip: true,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
]);
|
||||||
|
|
||||||
fixData = data;
|
fixData = data;
|
||||||
|
totalCount = count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const totalPages = Math.ceil(totalCount / takeData);
|
||||||
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{
|
{
|
||||||
success: true,
|
success: true,
|
||||||
message: "Success get event",
|
message: "Success get event",
|
||||||
data: fixData,
|
data: fixData,
|
||||||
|
pagination: {
|
||||||
|
currentPage: page,
|
||||||
|
totalPages: totalPages,
|
||||||
|
totalData: totalCount,
|
||||||
|
dataPerPage: takeData,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{ status: 200 }
|
{ status: 200 }
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -90,9 +90,15 @@ async function POST(request: Request, { params }: { params: { id: string } }) {
|
|||||||
|
|
||||||
async function GET(request: Request, { params }: { params: { id: string } }) {
|
async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||||
const { id } = params;
|
const { id } = params;
|
||||||
|
const { searchParams } = new URL(request.url);
|
||||||
|
const page = Number(searchParams.get("page"));
|
||||||
|
const takeData = 5
|
||||||
|
const skipData = page * takeData - takeData;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const data = await prisma.forum_Komentar.findMany({
|
const data = await prisma.forum_Komentar.findMany({
|
||||||
|
take: page ? takeData : undefined,
|
||||||
|
skip: page ? skipData : undefined,
|
||||||
orderBy: {
|
orderBy: {
|
||||||
createdAt: "desc",
|
createdAt: "desc",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
import prisma from "@/lib/prisma";
|
import prisma from "@/lib/prisma";
|
||||||
|
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||||
|
|
||||||
export { GET, PUT };
|
export { GET, PUT };
|
||||||
|
|
||||||
@@ -9,6 +10,10 @@ async function GET(
|
|||||||
{ params }: { params: { id: string; status: string } }
|
{ params }: { params: { id: string; status: string } }
|
||||||
) {
|
) {
|
||||||
const { id, status } = params;
|
const { id, status } = params;
|
||||||
|
const { searchParams } = new URL(request.url);
|
||||||
|
const page = Number(searchParams.get("page"));
|
||||||
|
const takeData = PAGINATION_DEFAULT_TAKE;
|
||||||
|
const skipData = page ? page * takeData - takeData : 0;
|
||||||
const fixStatusName = _.startCase(status);
|
const fixStatusName = _.startCase(status);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -22,6 +27,8 @@ async function GET(
|
|||||||
name: fixStatusName,
|
name: fixStatusName,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
take: page ? takeData : undefined,
|
||||||
|
skip: page ? skipData : undefined,
|
||||||
select: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
title: true,
|
title: true,
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import {
|
|||||||
NotificationMobileTitleType,
|
NotificationMobileTitleType,
|
||||||
} from "../../../../../../../types/type-mobile-notification";
|
} from "../../../../../../../types/type-mobile-notification";
|
||||||
import { routeAdminMobile, routeUserMobile } from "@/lib/mobile/route-page-mobile";
|
import { routeAdminMobile, routeUserMobile } from "@/lib/mobile/route-page-mobile";
|
||||||
|
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||||
|
|
||||||
export { POST, GET, DELETE };
|
export { POST, GET, DELETE };
|
||||||
|
|
||||||
@@ -98,6 +99,9 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
|||||||
const { id } = params;
|
const { id } = params;
|
||||||
const { searchParams } = new URL(request.url);
|
const { searchParams } = new URL(request.url);
|
||||||
const category = searchParams.get("category");
|
const category = searchParams.get("category");
|
||||||
|
const page = Number(searchParams.get("page"));
|
||||||
|
const takeData = PAGINATION_DEFAULT_TAKE
|
||||||
|
const skipData = page * takeData - takeData
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let fixData;
|
let fixData;
|
||||||
@@ -117,6 +121,8 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
|||||||
investasiId: id,
|
investasiId: id,
|
||||||
active: true,
|
active: true,
|
||||||
},
|
},
|
||||||
|
take: page ? takeData : undefined,
|
||||||
|
skip: page ? skipData : undefined,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,16 @@
|
|||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
import prisma from "@/lib/prisma";
|
import prisma from "@/lib/prisma";
|
||||||
|
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||||
|
|
||||||
export { GET };
|
export { GET };
|
||||||
|
|
||||||
async function GET(request: Request, { params }: { params: { id: string } }) {
|
async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||||
const { id } = params;
|
const { id } = params;
|
||||||
|
|
||||||
|
const { searchParams } = new URL(request.url);
|
||||||
|
const page = Number(searchParams.get("page")) || 1;
|
||||||
|
const takeData = PAGINATION_DEFAULT_TAKE;
|
||||||
|
const skipData = page * takeData - takeData;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const data = await prisma.investasi_Invoice.findMany({
|
const data = await prisma.investasi_Invoice.findMany({
|
||||||
@@ -29,13 +35,30 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
take: takeData,
|
||||||
|
skip: skipData,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const totalData = await prisma.investasi_Invoice.count({
|
||||||
|
where: {
|
||||||
|
investasiId: id,
|
||||||
|
statusInvoiceId: "1",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const totalPages = Math.ceil(totalData / takeData);
|
||||||
|
|
||||||
return NextResponse.json({
|
return NextResponse.json({
|
||||||
status: 200,
|
status: 200,
|
||||||
success: true,
|
success: true,
|
||||||
message: "Berhasil Mendapatkan Data",
|
message: "Berhasil Mendapatkan Data",
|
||||||
data: data,
|
data: data,
|
||||||
|
meta: {
|
||||||
|
currentPage: page,
|
||||||
|
totalData: totalData,
|
||||||
|
totalPage: totalPages,
|
||||||
|
dataPerPage: takeData,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return NextResponse.json({
|
return NextResponse.json({
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import {
|
|||||||
NotificationMobileTitleType,
|
NotificationMobileTitleType,
|
||||||
NotificationMobileBodyType,
|
NotificationMobileBodyType,
|
||||||
} from "../../../../../../../types/type-mobile-notification";
|
} from "../../../../../../../types/type-mobile-notification";
|
||||||
|
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||||
|
|
||||||
export { POST, GET, PUT };
|
export { POST, GET, PUT };
|
||||||
|
|
||||||
@@ -53,6 +54,9 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
|||||||
const { searchParams } = new URL(request.url);
|
const { searchParams } = new URL(request.url);
|
||||||
const category = searchParams.get("category");
|
const category = searchParams.get("category");
|
||||||
const authorId = searchParams.get("authorId");
|
const authorId = searchParams.get("authorId");
|
||||||
|
const page = Number(searchParams.get("page"));
|
||||||
|
const takeData = PAGINATION_DEFAULT_TAKE;
|
||||||
|
const skipData = page ? page * takeData - takeData : 0;
|
||||||
|
|
||||||
console.log("[ID INVOICE]", id);
|
console.log("[ID INVOICE]", id);
|
||||||
|
|
||||||
@@ -103,6 +107,8 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
|||||||
statusInvoiceId: "1",
|
statusInvoiceId: "1",
|
||||||
isActive: true,
|
isActive: true,
|
||||||
},
|
},
|
||||||
|
take: page ? takeData : undefined,
|
||||||
|
skip: page ? skipData : undefined,
|
||||||
select: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
nominal: true,
|
nominal: true,
|
||||||
@@ -129,6 +135,8 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
|||||||
where: {
|
where: {
|
||||||
authorId: authorId,
|
authorId: authorId,
|
||||||
},
|
},
|
||||||
|
take: page ? takeData : undefined,
|
||||||
|
skip: page ? skipData : undefined,
|
||||||
select: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
statusInvoiceId: true,
|
statusInvoiceId: true,
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import _ from "lodash";
|
|||||||
import { prisma } from "@/lib";
|
import { prisma } from "@/lib";
|
||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
import { sendNotificationInvestmentAddNews } from "@/lib/mobile/notification/notification-add-news-investment";
|
import { sendNotificationInvestmentAddNews } from "@/lib/mobile/notification/notification-add-news-investment";
|
||||||
|
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||||
|
|
||||||
export { POST, GET, DELETE };
|
export { POST, GET, DELETE };
|
||||||
|
|
||||||
@@ -88,8 +89,13 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
|||||||
console.log("id", id);
|
console.log("id", id);
|
||||||
const { searchParams } = new URL(request.url);
|
const { searchParams } = new URL(request.url);
|
||||||
const category = searchParams.get("category");
|
const category = searchParams.get("category");
|
||||||
|
const page = Number(searchParams.get("page")) || 1;
|
||||||
|
const takeData = PAGINATION_DEFAULT_TAKE;
|
||||||
|
const skipData = page * takeData - takeData;
|
||||||
|
|
||||||
let fixData;
|
let fixData;
|
||||||
|
let meta = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (category === "one-news") {
|
if (category === "one-news") {
|
||||||
const data = await prisma.beritaInvestasi.findFirst({
|
const data = await prisma.beritaInvestasi.findFirst({
|
||||||
@@ -113,7 +119,7 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
|||||||
|
|
||||||
fixData = newData;
|
fixData = newData;
|
||||||
} else if (category === "all-news") {
|
} else if (category === "all-news") {
|
||||||
fixData = await prisma.beritaInvestasi.findMany({
|
const newsData = await prisma.beritaInvestasi.findMany({
|
||||||
orderBy: {
|
orderBy: {
|
||||||
updatedAt: "desc",
|
updatedAt: "desc",
|
||||||
},
|
},
|
||||||
@@ -121,7 +127,27 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
|||||||
investasiId: id,
|
investasiId: id,
|
||||||
active: true,
|
active: true,
|
||||||
},
|
},
|
||||||
|
take: takeData,
|
||||||
|
skip: skipData,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const totalData = await prisma.beritaInvestasi.count({
|
||||||
|
where: {
|
||||||
|
investasiId: id,
|
||||||
|
active: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const totalPages = Math.ceil(totalData / takeData);
|
||||||
|
|
||||||
|
fixData = newsData;
|
||||||
|
|
||||||
|
meta = {
|
||||||
|
currentPage: page,
|
||||||
|
totalData: totalData,
|
||||||
|
totalPage: totalPages,
|
||||||
|
dataPerPage: takeData,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return NextResponse.json({
|
return NextResponse.json({
|
||||||
@@ -129,6 +155,7 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
|||||||
success: true,
|
success: true,
|
||||||
message: "Berita berhasil diambil",
|
message: "Berita berhasil diambil",
|
||||||
data: fixData,
|
data: fixData,
|
||||||
|
...(meta && { meta }),
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log("[ERROR]", error);
|
console.log("[ERROR]", error);
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import moment from "moment";
|
|||||||
import { sendNotificationMobileToManyUser } from "@/lib/mobile/notification/send-notification";
|
import { sendNotificationMobileToManyUser } from "@/lib/mobile/notification/send-notification";
|
||||||
import { NotificationMobileBodyType } from "../../../../../types/type-mobile-notification";
|
import { NotificationMobileBodyType } from "../../../../../types/type-mobile-notification";
|
||||||
import { routeAdminMobile } from "@/lib/mobile/route-page-mobile";
|
import { routeAdminMobile } from "@/lib/mobile/route-page-mobile";
|
||||||
|
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||||
|
|
||||||
export { POST, GET };
|
export { POST, GET };
|
||||||
|
|
||||||
@@ -73,6 +74,9 @@ async function GET(request: Request) {
|
|||||||
const { searchParams } = new URL(request.url);
|
const { searchParams } = new URL(request.url);
|
||||||
const category = searchParams.get("category");
|
const category = searchParams.get("category");
|
||||||
const authorId = searchParams.get("authorId");
|
const authorId = searchParams.get("authorId");
|
||||||
|
const page = Number(searchParams.get("page"));
|
||||||
|
const takeData = PAGINATION_DEFAULT_TAKE
|
||||||
|
const skipData = page ? page * takeData - takeData : 0;
|
||||||
|
|
||||||
console.log("[CATEGORY]", category);
|
console.log("[CATEGORY]", category);
|
||||||
console.log("[AUTHOR ID]", authorId);
|
console.log("[AUTHOR ID]", authorId);
|
||||||
@@ -132,6 +136,8 @@ async function GET(request: Request) {
|
|||||||
where: {
|
where: {
|
||||||
masterStatusInvestasiId: "1",
|
masterStatusInvestasiId: "1",
|
||||||
},
|
},
|
||||||
|
take: page ? takeData : undefined,
|
||||||
|
skip: page ? skipData : undefined,
|
||||||
select: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
imageId: true,
|
imageId: true,
|
||||||
@@ -156,6 +162,8 @@ async function GET(request: Request) {
|
|||||||
authorId: authorId,
|
authorId: authorId,
|
||||||
statusInvoiceId: "1",
|
statusInvoiceId: "1",
|
||||||
},
|
},
|
||||||
|
take: page ? takeData : undefined,
|
||||||
|
skip: page ? skipData : undefined,
|
||||||
select: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
investasiId: true,
|
investasiId: true,
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||||
import prisma from "@/lib/prisma";
|
import prisma from "@/lib/prisma";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
@@ -12,6 +13,11 @@ async function GET(
|
|||||||
const { id, status } = params;
|
const { id, status } = params;
|
||||||
const fixStatusName = _.startCase(status);
|
const fixStatusName = _.startCase(status);
|
||||||
|
|
||||||
|
const { searchParams } = new URL(request.url);
|
||||||
|
const page = Number(searchParams.get("page"));
|
||||||
|
const takeData = PAGINATION_DEFAULT_TAKE;
|
||||||
|
const skipData = page ? page * takeData - takeData : 0;
|
||||||
|
|
||||||
const data = await prisma.job.findMany({
|
const data = await prisma.job.findMany({
|
||||||
orderBy: {
|
orderBy: {
|
||||||
updatedAt: "desc",
|
updatedAt: "desc",
|
||||||
@@ -28,13 +34,20 @@ async function GET(
|
|||||||
id: true,
|
id: true,
|
||||||
title: true,
|
title: true,
|
||||||
},
|
},
|
||||||
|
take: takeData,
|
||||||
|
skip: skipData,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{
|
{
|
||||||
success: true,
|
success: true,
|
||||||
message: "Success get job",
|
message: "Success get job",
|
||||||
data: data,
|
data: data,
|
||||||
|
pagination: {
|
||||||
|
currentPage: page,
|
||||||
|
dataPerPage: takeData,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{ status: 200 }
|
{ status: 200 }
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { routeAdminMobile } from "@/lib/mobile/route-page-mobile";
|
|||||||
import prisma from "@/lib/prisma";
|
import prisma from "@/lib/prisma";
|
||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
import { NotificationMobileBodyType } from "../../../../../types/type-mobile-notification";
|
import { NotificationMobileBodyType } from "../../../../../types/type-mobile-notification";
|
||||||
|
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||||
|
|
||||||
export { POST, GET };
|
export { POST, GET };
|
||||||
|
|
||||||
@@ -45,7 +46,7 @@ async function POST(request: Request) {
|
|||||||
message: "Berhasil disimpan",
|
message: "Berhasil disimpan",
|
||||||
data: create,
|
data: create,
|
||||||
},
|
},
|
||||||
{ status: 201 }
|
{ status: 201 },
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
@@ -54,7 +55,7 @@ async function POST(request: Request) {
|
|||||||
message: "Error create job",
|
message: "Error create job",
|
||||||
reason: (error as Error).message,
|
reason: (error as Error).message,
|
||||||
},
|
},
|
||||||
{ status: 500 }
|
{ status: 500 },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -64,94 +65,129 @@ async function GET(request: Request) {
|
|||||||
const search = searchParams.get("search");
|
const search = searchParams.get("search");
|
||||||
const category = searchParams.get("category");
|
const category = searchParams.get("category");
|
||||||
const authorId = searchParams.get("authorId");
|
const authorId = searchParams.get("authorId");
|
||||||
|
|
||||||
|
const page = Number(searchParams.get("page")) || 1;
|
||||||
|
const takeData = PAGINATION_DEFAULT_TAKE;
|
||||||
|
const skipData = page * takeData - takeData;
|
||||||
let fixData;
|
let fixData;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (category === "archive") {
|
if (category === "archive") {
|
||||||
const data = await prisma.job.findMany({
|
const [data, count] = await Promise.all([
|
||||||
where: {
|
prisma.job.findMany({
|
||||||
authorId: authorId,
|
where: {
|
||||||
isActive: true,
|
authorId: authorId,
|
||||||
isArsip: true,
|
isActive: true,
|
||||||
MasterStatus: {
|
isArsip: true,
|
||||||
name: "Publish",
|
MasterStatus: {
|
||||||
},
|
name: "Publish",
|
||||||
// title: {
|
|
||||||
// contains: search || "",
|
|
||||||
// mode: "insensitive",
|
|
||||||
// },
|
|
||||||
},
|
|
||||||
orderBy: {
|
|
||||||
createdAt: "desc",
|
|
||||||
},
|
|
||||||
select: {
|
|
||||||
id: true,
|
|
||||||
title: true,
|
|
||||||
deskripsi: true,
|
|
||||||
authorId: true,
|
|
||||||
MasterStatus: {
|
|
||||||
select: {
|
|
||||||
name: true,
|
|
||||||
},
|
},
|
||||||
|
// title: {
|
||||||
|
// contains: search || "",
|
||||||
|
// mode: "insensitive",
|
||||||
|
// },
|
||||||
},
|
},
|
||||||
Author: {
|
orderBy: {
|
||||||
select: {
|
createdAt: "desc",
|
||||||
id: true,
|
},
|
||||||
username: true,
|
select: {
|
||||||
Profile: {
|
id: true,
|
||||||
select: {
|
title: true,
|
||||||
id: true,
|
deskripsi: true,
|
||||||
name: true,
|
authorId: true,
|
||||||
imageId: true,
|
MasterStatus: {
|
||||||
|
select: {
|
||||||
|
name: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Author: {
|
||||||
|
select: {
|
||||||
|
id: true,
|
||||||
|
username: true,
|
||||||
|
Profile: {
|
||||||
|
select: {
|
||||||
|
id: true,
|
||||||
|
name: true,
|
||||||
|
imageId: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
take: takeData,
|
||||||
});
|
skip: skipData,
|
||||||
|
}),
|
||||||
|
prisma.job.count({
|
||||||
|
where: {
|
||||||
|
authorId: authorId,
|
||||||
|
isActive: true,
|
||||||
|
isArsip: true,
|
||||||
|
MasterStatus: {
|
||||||
|
name: "Publish",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
]);
|
||||||
|
|
||||||
fixData = data;
|
fixData = data;
|
||||||
} else if (category === "beranda") {
|
} else if (category === "beranda") {
|
||||||
const data = await prisma.job.findMany({
|
const [data, count] = await Promise.all([
|
||||||
where: {
|
prisma.job.findMany({
|
||||||
isActive: true,
|
where: {
|
||||||
isArsip: false,
|
isActive: true,
|
||||||
MasterStatus: {
|
isArsip: false,
|
||||||
name: "Publish",
|
MasterStatus: {
|
||||||
},
|
name: "Publish",
|
||||||
title: {
|
},
|
||||||
contains: search || "",
|
title: {
|
||||||
mode: "insensitive",
|
contains: search || "",
|
||||||
},
|
mode: "insensitive",
|
||||||
},
|
|
||||||
orderBy: {
|
|
||||||
createdAt: "desc",
|
|
||||||
},
|
|
||||||
select: {
|
|
||||||
id: true,
|
|
||||||
title: true,
|
|
||||||
deskripsi: true,
|
|
||||||
authorId: true,
|
|
||||||
MasterStatus: {
|
|
||||||
select: {
|
|
||||||
name: true,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Author: {
|
orderBy: {
|
||||||
select: {
|
createdAt: "desc",
|
||||||
id: true,
|
},
|
||||||
username: true,
|
select: {
|
||||||
Profile: {
|
id: true,
|
||||||
select: {
|
title: true,
|
||||||
id: true,
|
deskripsi: true,
|
||||||
name: true,
|
authorId: true,
|
||||||
imageId: true,
|
MasterStatus: {
|
||||||
|
select: {
|
||||||
|
name: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Author: {
|
||||||
|
select: {
|
||||||
|
id: true,
|
||||||
|
username: true,
|
||||||
|
Profile: {
|
||||||
|
select: {
|
||||||
|
id: true,
|
||||||
|
name: true,
|
||||||
|
imageId: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
take: takeData,
|
||||||
});
|
skip: skipData,
|
||||||
|
}),
|
||||||
|
prisma.job.count({
|
||||||
|
where: {
|
||||||
|
isActive: true,
|
||||||
|
isArsip: false,
|
||||||
|
MasterStatus: {
|
||||||
|
name: "Publish",
|
||||||
|
},
|
||||||
|
title: {
|
||||||
|
contains: search || "",
|
||||||
|
mode: "insensitive",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
]);
|
||||||
|
|
||||||
fixData = data;
|
fixData = data;
|
||||||
}
|
}
|
||||||
@@ -161,8 +197,12 @@ async function GET(request: Request) {
|
|||||||
success: true,
|
success: true,
|
||||||
message: "Success get data job-vacancy",
|
message: "Success get data job-vacancy",
|
||||||
data: fixData,
|
data: fixData,
|
||||||
|
pagination: {
|
||||||
|
currentPage: page,
|
||||||
|
dataPerPage: takeData,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{ status: 200 }
|
{ status: 200 },
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
@@ -171,7 +211,7 @@ async function GET(request: Request) {
|
|||||||
message: "Error get data job-vacancy",
|
message: "Error get data job-vacancy",
|
||||||
reason: (error as Error).message,
|
reason: (error as Error).message,
|
||||||
},
|
},
|
||||||
{ status: 500 }
|
{ status: 500 },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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";
|
||||||
@@ -6,43 +7,104 @@ import { adminMessaging } from "@/lib/firebase-admin";
|
|||||||
|
|
||||||
export async function GET(
|
export async function GET(
|
||||||
request: NextRequest,
|
request: NextRequest,
|
||||||
{ params }: { params: { id: string } }
|
{ params }: { params: { id: string } },
|
||||||
) {
|
) {
|
||||||
const { id } = params;
|
const { id } = params;
|
||||||
|
console.log("ID", id);
|
||||||
const { searchParams } = new URL(request.url);
|
const { searchParams } = new URL(request.url);
|
||||||
const category = searchParams.get("category");
|
const category = searchParams.get("category");
|
||||||
|
|
||||||
let fixData;
|
|
||||||
const fixCategory = _.upperCase(category || "");
|
const fixCategory = _.upperCase(category || "");
|
||||||
|
|
||||||
|
const page = Number(searchParams.get("page"));
|
||||||
|
console.log("page", page);
|
||||||
|
const takeData = 10;
|
||||||
|
const skipData = page * takeData - takeData;
|
||||||
|
|
||||||
|
let fixData;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const data = await prisma.notifikasi.findMany({
|
const data = await withRetry(
|
||||||
orderBy: {
|
() =>
|
||||||
createdAt: "desc",
|
prisma.notifikasi.findMany({
|
||||||
},
|
take: page ? takeData : undefined,
|
||||||
where: {
|
skip: page ? skipData : undefined,
|
||||||
recipientId: id,
|
orderBy: {
|
||||||
kategoriApp: fixCategory,
|
createdAt: "desc",
|
||||||
},
|
},
|
||||||
});
|
where: {
|
||||||
|
recipientId: id,
|
||||||
|
kategoriApp: fixCategory,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
undefined,
|
||||||
|
"getNotifications"
|
||||||
|
);
|
||||||
|
|
||||||
|
// Jika pagination digunakan, ambil juga total count untuk informasi
|
||||||
|
let totalCount;
|
||||||
|
let totalPages;
|
||||||
|
if (page) {
|
||||||
|
totalCount = await withRetry(
|
||||||
|
() =>
|
||||||
|
prisma.notifikasi.count({
|
||||||
|
where: {
|
||||||
|
recipientId: id,
|
||||||
|
kategoriApp: fixCategory,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
undefined,
|
||||||
|
"countNotifications"
|
||||||
|
);
|
||||||
|
totalPages = Math.ceil(totalCount / takeData);
|
||||||
|
}
|
||||||
|
|
||||||
fixData = data;
|
fixData = data;
|
||||||
|
|
||||||
return NextResponse.json({
|
const response = {
|
||||||
success: true,
|
success: true,
|
||||||
data: fixData,
|
data: fixData,
|
||||||
});
|
};
|
||||||
|
|
||||||
|
// Tambahkan metadata pagination jika parameter page disertakan
|
||||||
|
if (page) {
|
||||||
|
Object.assign(response, {
|
||||||
|
meta: {
|
||||||
|
page,
|
||||||
|
take: takeData,
|
||||||
|
skip: skipData,
|
||||||
|
total: totalCount,
|
||||||
|
totalPages,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
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 },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function PUT(
|
export async function PUT(
|
||||||
request: NextRequest,
|
request: NextRequest,
|
||||||
{ params }: { params: { id: string } }
|
{ params }: { params: { id: string } },
|
||||||
) {
|
) {
|
||||||
const { id } = params;
|
const { id } = params;
|
||||||
const { searchParams } = new URL(request.url);
|
const { searchParams } = new URL(request.url);
|
||||||
@@ -79,7 +141,7 @@ export async function PUT(
|
|||||||
console.error("Error marking notifications as read:", error);
|
console.error("Error marking notifications as read:", error);
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: (error as Error).message },
|
{ error: (error as Error).message },
|
||||||
{ 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",
|
||||||
|
|||||||
@@ -7,8 +7,13 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
|||||||
try {
|
try {
|
||||||
const { searchParams } = new URL(request.url);
|
const { searchParams } = new URL(request.url);
|
||||||
const id = searchParams.get("id");
|
const id = searchParams.get("id");
|
||||||
|
const page = parseInt(searchParams.get("page") || "1");
|
||||||
|
const take = 10; // Default 10 data
|
||||||
|
const skip = page * take - take;
|
||||||
|
|
||||||
const data = await prisma.portofolio.findMany({
|
const data = await prisma.portofolio.findMany({
|
||||||
|
skip,
|
||||||
|
take,
|
||||||
orderBy: {
|
orderBy: {
|
||||||
createdAt: "desc",
|
createdAt: "desc",
|
||||||
},
|
},
|
||||||
@@ -18,22 +23,30 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!data)
|
// Hitung total data untuk informasi pagination
|
||||||
return NextResponse.json(
|
const total = await prisma.portofolio.count({
|
||||||
{
|
where: {
|
||||||
success: false,
|
profileId: id,
|
||||||
message: "Data tidak ditemukan",
|
active: true,
|
||||||
},
|
},
|
||||||
{ status: 404 }
|
});
|
||||||
);
|
|
||||||
|
const totalPages = Math.ceil(total / take);
|
||||||
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{
|
{
|
||||||
success: true,
|
success: true,
|
||||||
message: "Berhasil mendapatkan data",
|
message: "Berhasil mendapatkan data",
|
||||||
data: data,
|
data: data,
|
||||||
|
meta: {
|
||||||
|
page,
|
||||||
|
take,
|
||||||
|
skip,
|
||||||
|
total,
|
||||||
|
totalPages,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{ status: 200 }
|
{ status: 200 },
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
@@ -42,7 +55,7 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
|||||||
message: "API Error Get Data Potofolio",
|
message: "API Error Get Data Potofolio",
|
||||||
reason: (error as Error).message,
|
reason: (error as Error).message,
|
||||||
},
|
},
|
||||||
{ status: 500 }
|
{ status: 500 },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -66,7 +79,10 @@ async function POST(request: Request) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (data.subBidang.length > 0 || data.subBidang.map((item: any) => item.id !== "")) {
|
if (
|
||||||
|
data.subBidang.length > 0 ||
|
||||||
|
data.subBidang.map((item: any) => item.id !== "")
|
||||||
|
) {
|
||||||
for (let i of data.subBidang) {
|
for (let i of data.subBidang) {
|
||||||
const createSubBidang =
|
const createSubBidang =
|
||||||
await prisma.portofolio_BidangDanSubBidangBisnis.create({
|
await prisma.portofolio_BidangDanSubBidangBisnis.create({
|
||||||
@@ -84,7 +100,7 @@ async function POST(request: Request) {
|
|||||||
success: false,
|
success: false,
|
||||||
message: "Gagal membuat sub bidang bisnis",
|
message: "Gagal membuat sub bidang bisnis",
|
||||||
},
|
},
|
||||||
{ status: 400 }
|
{ status: 400 },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -95,7 +111,7 @@ async function POST(request: Request) {
|
|||||||
success: false,
|
success: false,
|
||||||
message: "Gagal membuat portofolio",
|
message: "Gagal membuat portofolio",
|
||||||
},
|
},
|
||||||
{ status: 400 }
|
{ status: 400 },
|
||||||
);
|
);
|
||||||
|
|
||||||
const createMedsos = await prisma.portofolio_MediaSosial.create({
|
const createMedsos = await prisma.portofolio_MediaSosial.create({
|
||||||
@@ -115,7 +131,7 @@ async function POST(request: Request) {
|
|||||||
success: false,
|
success: false,
|
||||||
message: "Gagal menambahkan medsos",
|
message: "Gagal menambahkan medsos",
|
||||||
},
|
},
|
||||||
{ status: 400 }
|
{ status: 400 },
|
||||||
);
|
);
|
||||||
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
@@ -124,7 +140,7 @@ async function POST(request: Request) {
|
|||||||
message: "Berhasil mendapatkan data",
|
message: "Berhasil mendapatkan data",
|
||||||
data: createPortofolio,
|
data: createPortofolio,
|
||||||
},
|
},
|
||||||
{ status: 200 }
|
{ status: 200 },
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
@@ -133,7 +149,7 @@ async function POST(request: Request) {
|
|||||||
message: "API Error Post Data",
|
message: "API Error Post Data",
|
||||||
reason: (error as Error).message,
|
reason: (error as Error).message,
|
||||||
},
|
},
|
||||||
{ status: 500 }
|
{ status: 500 },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,8 +5,16 @@ export async function GET(request: Request) {
|
|||||||
try {
|
try {
|
||||||
const { searchParams } = new URL(request.url);
|
const { searchParams } = new URL(request.url);
|
||||||
const search = searchParams.get("search");
|
const search = searchParams.get("search");
|
||||||
|
const page = Number(searchParams.get("page"));
|
||||||
|
const takeData = 10;
|
||||||
|
const skipData = page * takeData - takeData;
|
||||||
|
|
||||||
|
console.log("SEARCH", search);
|
||||||
|
console.log("PAGE", page);
|
||||||
|
|
||||||
const data = await prisma.user.findMany({
|
const data = await prisma.user.findMany({
|
||||||
|
take: page ? takeData : undefined,
|
||||||
|
skip: page ? skipData : undefined,
|
||||||
orderBy: {
|
orderBy: {
|
||||||
username: "asc",
|
username: "asc",
|
||||||
},
|
},
|
||||||
@@ -19,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: {
|
||||||
@@ -43,16 +51,12 @@ export async function GET(request: Request) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
return NextResponse.json(
|
return NextResponse.json({
|
||||||
{
|
status: 200,
|
||||||
success: true,
|
success: true,
|
||||||
message: "Berhasil mendapatkan data",
|
message: "Berhasil mendapatkan data",
|
||||||
data: data,
|
data: data,
|
||||||
},
|
});
|
||||||
{
|
|
||||||
status: 200,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{
|
{
|
||||||
@@ -62,7 +66,7 @@ export async function GET(request: Request) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
status: 500,
|
status: 500,
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
import prisma from "@/lib/prisma";
|
import prisma from "@/lib/prisma";
|
||||||
|
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||||
|
|
||||||
export { GET, PUT };
|
export { GET, PUT };
|
||||||
|
|
||||||
@@ -10,14 +11,33 @@ async function GET(
|
|||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
const { id, status } = params;
|
const { id, status } = params;
|
||||||
console.log("[ID]", id);
|
|
||||||
const fixStatusName = _.startCase(status);
|
const fixStatusName = _.startCase(status);
|
||||||
console.log("[STATUS]", fixStatusName);
|
|
||||||
|
|
||||||
let fixData;
|
const { searchParams } = new URL(request.url);
|
||||||
|
const page = Number(searchParams.get("page")) || 1;
|
||||||
|
const takeData = PAGINATION_DEFAULT_TAKE
|
||||||
|
const skipData = page * takeData - takeData;
|
||||||
|
|
||||||
|
let data;
|
||||||
|
let totalCount;
|
||||||
|
|
||||||
if (fixStatusName === "Publish") {
|
if (fixStatusName === "Publish") {
|
||||||
fixData = await prisma.voting.findMany({
|
data = await prisma.voting.findMany({
|
||||||
|
where: {
|
||||||
|
authorId: id,
|
||||||
|
isActive: true,
|
||||||
|
akhirVote: {
|
||||||
|
gte: new Date(),
|
||||||
|
},
|
||||||
|
Voting_Status: {
|
||||||
|
name: fixStatusName,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
take: takeData,
|
||||||
|
skip: skipData,
|
||||||
|
});
|
||||||
|
|
||||||
|
totalCount = await prisma.voting.count({
|
||||||
where: {
|
where: {
|
||||||
authorId: id,
|
authorId: id,
|
||||||
isActive: true,
|
isActive: true,
|
||||||
@@ -30,7 +50,18 @@ async function GET(
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
fixData = await prisma.voting.findMany({
|
data = await prisma.voting.findMany({
|
||||||
|
where: {
|
||||||
|
authorId: id,
|
||||||
|
Voting_Status: {
|
||||||
|
name: fixStatusName,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
take: takeData,
|
||||||
|
skip: skipData,
|
||||||
|
});
|
||||||
|
|
||||||
|
totalCount = await prisma.voting.count({
|
||||||
where: {
|
where: {
|
||||||
authorId: id,
|
authorId: id,
|
||||||
Voting_Status: {
|
Voting_Status: {
|
||||||
@@ -40,10 +71,18 @@ async function GET(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const totalPages = Math.ceil(totalCount / takeData);
|
||||||
|
|
||||||
return NextResponse.json({
|
return NextResponse.json({
|
||||||
success: true,
|
success: true,
|
||||||
message: "Success get voting",
|
message: "Success get voting",
|
||||||
data: fixData,
|
data: data,
|
||||||
|
pagination: {
|
||||||
|
currentPage: page,
|
||||||
|
totalPages: totalPages,
|
||||||
|
totalData: totalCount,
|
||||||
|
dataPerPage: takeData,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log("[ERROR]", error);
|
console.log("[ERROR]", error);
|
||||||
@@ -61,9 +100,7 @@ async function PUT(
|
|||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
const { id, status } = params;
|
const { id, status } = params;
|
||||||
console.log("[ID]", id);
|
|
||||||
const fixStatusName = _.startCase(status);
|
const fixStatusName = _.startCase(status);
|
||||||
console.log("[STATUS]", fixStatusName);
|
|
||||||
|
|
||||||
const checkData = await prisma.voting.findFirst({
|
const checkData = await prisma.voting.findFirst({
|
||||||
where: {
|
where: {
|
||||||
@@ -79,8 +116,6 @@ async function PUT(
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log("[CHECKDATA]", checkData);
|
|
||||||
|
|
||||||
if (!checkData)
|
if (!checkData)
|
||||||
return NextResponse.json({
|
return NextResponse.json({
|
||||||
success: false,
|
success: false,
|
||||||
@@ -115,8 +150,6 @@ async function PUT(
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log("[UPDATE]", updateData);
|
|
||||||
|
|
||||||
return NextResponse.json({
|
return NextResponse.json({
|
||||||
success: true,
|
success: true,
|
||||||
message: "Success update voting",
|
message: "Success update voting",
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
import prisma from "@/lib/prisma";
|
import prisma from "@/lib/prisma";
|
||||||
|
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||||
|
|
||||||
export { GET };
|
export { GET };
|
||||||
|
|
||||||
@@ -8,10 +9,9 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
|||||||
const { searchParams } = new URL(request.url);
|
const { searchParams } = new URL(request.url);
|
||||||
const authorId = searchParams.get("authorId");
|
const authorId = searchParams.get("authorId");
|
||||||
const category = searchParams.get("category");
|
const category = searchParams.get("category");
|
||||||
|
const page = Number(searchParams.get("page"));
|
||||||
console.log("[ID]", id);
|
const takeData = PAGINATION_DEFAULT_TAKE;
|
||||||
console.log("[AUTHOR ID]", authorId);
|
const skipData = page ? page * takeData - takeData : 0;
|
||||||
console.log("[CATEGORY]", category);
|
|
||||||
|
|
||||||
let fixData;
|
let fixData;
|
||||||
|
|
||||||
@@ -53,7 +53,10 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
|||||||
where: {
|
where: {
|
||||||
votingId: id,
|
votingId: id,
|
||||||
},
|
},
|
||||||
|
take: page ? takeData : undefined,
|
||||||
|
skip: page ? skipData : undefined,
|
||||||
select: {
|
select: {
|
||||||
|
id: true,
|
||||||
Voting_DaftarNamaVote: {
|
Voting_DaftarNamaVote: {
|
||||||
select: {
|
select: {
|
||||||
value: true,
|
value: true,
|
||||||
@@ -75,8 +78,6 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log("[LIST KONTRIBUTOR]", listKontributor);
|
|
||||||
|
|
||||||
fixData = listKontributor;
|
fixData = listKontributor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import _ from "lodash";
|
|||||||
import { sendNotificationMobileToManyUser } from "@/lib/mobile/notification/send-notification";
|
import { sendNotificationMobileToManyUser } from "@/lib/mobile/notification/send-notification";
|
||||||
import { NotificationMobileBodyType } from "../../../../../types/type-mobile-notification";
|
import { NotificationMobileBodyType } from "../../../../../types/type-mobile-notification";
|
||||||
import { routeAdminMobile } from "@/lib/mobile/route-page-mobile";
|
import { routeAdminMobile } from "@/lib/mobile/route-page-mobile";
|
||||||
|
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||||
|
|
||||||
export { POST, GET };
|
export { POST, GET };
|
||||||
|
|
||||||
@@ -87,8 +88,9 @@ async function GET(request: Request) {
|
|||||||
const category = searchParams.get("category");
|
const category = searchParams.get("category");
|
||||||
const authorId = searchParams.get("authorId");
|
const authorId = searchParams.get("authorId");
|
||||||
const userLoginId = searchParams.get("userLoginId");
|
const userLoginId = searchParams.get("userLoginId");
|
||||||
|
const page = Number(searchParams.get("page"));
|
||||||
console.log("userLoginId >>", userLoginId);
|
const takeData = PAGINATION_DEFAULT_TAKE;
|
||||||
|
const skipData = page * takeData - takeData;
|
||||||
|
|
||||||
let fixData;
|
let fixData;
|
||||||
|
|
||||||
@@ -123,6 +125,8 @@ async function GET(request: Request) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
take: page ? takeData : undefined,
|
||||||
|
skip: page ? skipData : undefined,
|
||||||
include: {
|
include: {
|
||||||
Voting_DaftarNamaVote: {
|
Voting_DaftarNamaVote: {
|
||||||
orderBy: {
|
orderBy: {
|
||||||
@@ -154,6 +158,8 @@ async function GET(request: Request) {
|
|||||||
where: {
|
where: {
|
||||||
authorId: authorId,
|
authorId: authorId,
|
||||||
},
|
},
|
||||||
|
take: page ? takeData : undefined,
|
||||||
|
skip: page ? skipData : undefined,
|
||||||
include: {
|
include: {
|
||||||
Voting: {
|
Voting: {
|
||||||
select: {
|
select: {
|
||||||
@@ -211,6 +217,8 @@ async function GET(request: Request) {
|
|||||||
mode: "insensitive",
|
mode: "insensitive",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
take: page ? takeData : undefined,
|
||||||
|
skip: page ? skipData : undefined,
|
||||||
include: {
|
include: {
|
||||||
Voting_DaftarNamaVote: {
|
Voting_DaftarNamaVote: {
|
||||||
orderBy: {
|
orderBy: {
|
||||||
@@ -249,6 +257,8 @@ async function GET(request: Request) {
|
|||||||
mode: "insensitive",
|
mode: "insensitive",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
take: page ? takeData : undefined,
|
||||||
|
skip: page ? skipData : undefined,
|
||||||
include: {
|
include: {
|
||||||
Voting_DaftarNamaVote: {
|
Voting_DaftarNamaVote: {
|
||||||
orderBy: {
|
orderBy: {
|
||||||
|
|||||||
@@ -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 }
|
||||||
);
|
);
|
||||||
} finally {
|
|
||||||
await prisma.$disconnect();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user