Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3b0ea3d847 | |||
| 097758a431 | |||
| 6f5849aa29 | |||
| 6aceb212e4 | |||
| 42803f9b92 | |||
| 2a857f54e7 | |||
| bb79a68f44 | |||
| f103ae93ad | |||
| 1c9459dcf3 | |||
| 8b54f5ca65 | |||
| c94da645f3 | |||
| da0477102e |
@@ -2,6 +2,12 @@
|
|||||||
|
|
||||||
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.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.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)
|
||||||
|
|
||||||
## [1.5.36](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.5.35...v1.5.36) (2026-01-13)
|
## [1.5.36](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.5.35...v1.5.36) (2026-01-13)
|
||||||
|
|||||||
20
PROMPT-AI.md
Normal file
20
PROMPT-AI.md
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
|
||||||
|
File utama: src/app/api/mobile/investment/[id]/invoice/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
|
||||||
201
QWEN.md
Normal file
201
QWEN.md
Normal file
@@ -0,0 +1,201 @@
|
|||||||
|
# HIPMI Project - QWEN.md
|
||||||
|
|
||||||
|
## Project Overview
|
||||||
|
|
||||||
|
HIPMI (Himpunan Pengusaha Muda 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
|
||||||
|
|
||||||
|
### Code Standards
|
||||||
|
- TypeScript with strict mode enabled
|
||||||
|
- Component header comments with file description, creator, date
|
||||||
|
- Function comments with parameter and return value descriptions
|
||||||
|
- Custom type interface comments
|
||||||
|
- Error handling comments
|
||||||
|
- Complex logic comments
|
||||||
|
|
||||||
|
### Commit Message Format
|
||||||
|
```
|
||||||
|
type: Short description
|
||||||
|
|
||||||
|
Body:
|
||||||
|
- Detailed description of changes
|
||||||
|
- Motivation for changes
|
||||||
|
- Breaking changes if any
|
||||||
|
|
||||||
|
References: #issue-number
|
||||||
|
```
|
||||||
|
|
||||||
|
## 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
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hipmi",
|
"name": "hipmi",
|
||||||
"version": "1.5.37",
|
"version": "1.5.40",
|
||||||
"private": true,
|
"private": true,
|
||||||
"prisma": {
|
"prisma": {
|
||||||
"seed": "bun prisma/seed.ts"
|
"seed": "bun prisma/seed.ts"
|
||||||
|
|||||||
@@ -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,7 @@
|
|||||||
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 {
|
||||||
@@ -35,7 +35,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(),
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -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(),
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -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(),
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,11 +1,22 @@
|
|||||||
|
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";
|
||||||
|
|
||||||
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 +33,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 +56,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 +77,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 +125,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 +134,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 +144,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 },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -110,7 +160,6 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
|||||||
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,
|
||||||
@@ -140,7 +189,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 +199,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 +209,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,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,25 +1,39 @@
|
|||||||
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";
|
||||||
|
|
||||||
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 +42,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 +52,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,7 +89,7 @@ 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);
|
||||||
@@ -178,7 +211,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 +231,7 @@ async function DELETE(
|
|||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${process.env.WS_APIKEY}`,
|
Authorization: `Bearer ${process.env.WS_APIKEY}`,
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!deleteImage) {
|
if (!deleteImage) {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ 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";
|
||||||
|
|
||||||
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,7 +121,7 @@ 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");
|
||||||
|
|||||||
@@ -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,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,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
@@ -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 },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,17 +6,25 @@ 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");
|
||||||
|
const fixCategory = _.upperCase(category || "");
|
||||||
|
|
||||||
|
const page = Number(searchParams.get("page"));
|
||||||
|
console.log("page", page);
|
||||||
|
const takeData = 10;
|
||||||
|
const skipData = page * takeData - takeData;
|
||||||
|
|
||||||
let fixData;
|
let fixData;
|
||||||
const fixCategory = _.upperCase(category || "");
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const data = await prisma.notifikasi.findMany({
|
const data = await prisma.notifikasi.findMany({
|
||||||
|
take: page ? takeData : undefined,
|
||||||
|
skip: page ? skipData : undefined,
|
||||||
orderBy: {
|
orderBy: {
|
||||||
createdAt: "desc",
|
createdAt: "desc",
|
||||||
},
|
},
|
||||||
@@ -26,23 +34,51 @@ export async function GET(
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Jika pagination digunakan, ambil juga total count untuk informasi
|
||||||
|
let totalCount;
|
||||||
|
let totalPages;
|
||||||
|
if (page) {
|
||||||
|
totalCount = await prisma.notifikasi.count({
|
||||||
|
where: {
|
||||||
|
recipientId: id,
|
||||||
|
kategoriApp: fixCategory,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
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) {
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: (error as Error).message },
|
{ error: (error as Error).message },
|
||||||
{ 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 +115,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 },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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",
|
||||||
},
|
},
|
||||||
@@ -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: {
|
||||||
|
|||||||
@@ -1,13 +1,16 @@
|
|||||||
const sendCodeOtp = async ({
|
const sendCodeOtp = async ({
|
||||||
nomor,
|
nomor,
|
||||||
codeOtp,
|
codeOtp,
|
||||||
|
newMessage,
|
||||||
}: {
|
}: {
|
||||||
nomor: string;
|
nomor: string;
|
||||||
codeOtp: string;
|
codeOtp?: string;
|
||||||
|
newMessage?: string;
|
||||||
}) => {
|
}) => {
|
||||||
const msg = `HIPMI%20-%20Kode%20ini%20bersifat%20RAHASIA%20dan%20JANGAN%20DI%20BAGIKAN%20KEPADA%20SIAPAPUN%2C%20termasuk%20anggota%20ataupun%20pengurus%20HIPMI%20lainnya.%20Kode%20OTP%20anda%3A%20${codeOtp}.`;
|
const msg = newMessage || `HIPMI - Kode ini bersifat RAHASIA dan JANGAN DI BAGIKAN KEPADA SIAPAPUN, termasuk anggota ataupun pengurus HIPMI lainnya.\n\n>> Kode OTP anda: ${codeOtp}.`;
|
||||||
|
const enCode = encodeURIComponent(msg);
|
||||||
const res = await fetch(
|
const res = await fetch(
|
||||||
`https://cld-dkr-prod-wajs-server.wibudev.com/api/wa/code?nom=${nomor}&text=${msg}`,
|
`https://cld-dkr-prod-wajs-server.wibudev.com/api/wa/code?nom=${nomor}&text=${enCode}`,
|
||||||
{
|
{
|
||||||
cache: "no-cache",
|
cache: "no-cache",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -25,4 +28,4 @@ const sendCodeOtp = async ({
|
|||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
|
|
||||||
export { sendCodeOtp };
|
export { sendCodeOtp as funSendToWhatsApp };
|
||||||
|
|||||||
1
src/lib/constans-value/constansValue.ts
Normal file
1
src/lib/constans-value/constansValue.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export const PAGINATION_DEFAULT_TAKE = 10;
|
||||||
25
src/lib/mobile/donation/find-donatur-list.tsx
Normal file
25
src/lib/mobile/donation/find-donatur-list.tsx
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
import prisma from "@/lib/prisma";
|
||||||
|
|
||||||
|
export const funFindDonaturList = async (donasiId: string) => {
|
||||||
|
const finDonatur = await prisma.donasi_Invoice.findMany({
|
||||||
|
where: {
|
||||||
|
donasiId: donasiId,
|
||||||
|
DonasiMaster_StatusInvoice: {
|
||||||
|
name: "Berhasil",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
select: {
|
||||||
|
authorId: true,
|
||||||
|
},
|
||||||
|
distinct: ["authorId"], // Ambil hanya authorId unik dari DB
|
||||||
|
});
|
||||||
|
|
||||||
|
// Filter null safety (jika diperlukan)
|
||||||
|
const recipientIds = finDonatur
|
||||||
|
.map((e) => e.authorId)
|
||||||
|
.filter((id): id is string => id !== null && id !== undefined);
|
||||||
|
|
||||||
|
console.log("[FIND DONATUR UNIK]", recipientIds);
|
||||||
|
|
||||||
|
return recipientIds;
|
||||||
|
};
|
||||||
48
zCoba.js
48
zCoba.js
@@ -1,28 +1,26 @@
|
|||||||
// const data = [
|
const { PrismaClient } = require('@prisma/client')
|
||||||
// {
|
|
||||||
// authorId: "clx8pl7r90005su4mldioo0v1",
|
|
||||||
// Donasi: {
|
|
||||||
// id: "clyr304q0000410ljvzms3mag",
|
|
||||||
// title: "Donasi Bencana Alam Aceh",
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// authorId: "clx8pl7r90005su4mldioo0v1",
|
|
||||||
// Donasi: {
|
|
||||||
// id: "clyr304q0000410ljvzms3mag",
|
|
||||||
// title: "Donasi Bencana Alam Aceh",
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// authorId: "clycka5eu0001ina3i1ssgze9",
|
|
||||||
// Donasi: {
|
|
||||||
// id: "clyr304q0000410ljvzms3mag",
|
|
||||||
// title: "Donasi Bencana Alam Aceh",
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// ];
|
|
||||||
|
|
||||||
|
const prisma = new PrismaClient()
|
||||||
|
|
||||||
console.error("errornya disini klik aja",import.meta.url);
|
async function main() {
|
||||||
console.log(new Set(data.map((d) => d.authorId)));
|
const result = await prisma.notifikasi.updateMany({
|
||||||
|
where: {
|
||||||
|
recipientId: 'cmha7p6yc0000cfoe5w2e7gdr',
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
isRead: false,
|
||||||
|
readAt: null,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
console.log(`✅ Rows affected: ${result.count}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
main()
|
||||||
|
.catch((err) => {
|
||||||
|
console.error('❌ Error:', err)
|
||||||
|
process.exit(1)
|
||||||
|
})
|
||||||
|
.finally(async () => {
|
||||||
|
await prisma.$disconnect()
|
||||||
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user