Compare commits
26 Commits
mobile-not
...
mobile-api
| Author | SHA1 | Date | |
|---|---|---|---|
| e89886e1db | |||
| 934d6a3ef1 | |||
| a7694bd7d5 | |||
| 3b0ea3d847 | |||
| 097758a431 | |||
| 6f5849aa29 | |||
| 6aceb212e4 | |||
| 42803f9b92 | |||
| 2a857f54e7 | |||
| bb79a68f44 | |||
| f103ae93ad | |||
| 1c9459dcf3 | |||
| 8b54f5ca65 | |||
| c94da645f3 | |||
| da0477102e | |||
| 70db97f5bb | |||
| 8ccf1f2b6e | |||
| 048b7b6094 | |||
| fc23e01275 | |||
| 20d05c1cc7 | |||
| 2c269db250 | |||
| fea94df7bb | |||
| 3c6dde6204 | |||
| cb0845e264 | |||
| d09e30c049 | |||
| c8bd928c33 |
@@ -2,6 +2,14 @@
|
||||
|
||||
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.36](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.5.35...v1.5.36) (2026-01-13)
|
||||
|
||||
## [1.5.35](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.5.34...v1.5.35) (2026-01-12)
|
||||
|
||||
45
PROMPT-AI.md
Normal file
45
PROMPT-AI.md
Normal file
@@ -0,0 +1,45 @@
|
||||
|
||||
File utama: src/app/api/mobile/donation/[id]/donatur/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"
|
||||
201
QWEN.md
Normal file
201
QWEN.md
Normal file
@@ -0,0 +1,201 @@
|
||||
# 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
|
||||
|
||||
### 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
|
||||
19
bun.lock
19
bun.lock
@@ -39,6 +39,7 @@
|
||||
"@types/react-dom": "18.2.7",
|
||||
"@types/uuid": "^9.0.4",
|
||||
"autoprefixer": "10.4.14",
|
||||
"axios": "^1.13.5",
|
||||
"bufferutil": "^4.0.8",
|
||||
"bun": "^1.1.38",
|
||||
"caniuse-lite": "^1.0.30001757",
|
||||
@@ -1324,7 +1325,7 @@
|
||||
|
||||
"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=="],
|
||||
|
||||
@@ -1882,7 +1883,7 @@
|
||||
|
||||
"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=="],
|
||||
|
||||
@@ -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=="],
|
||||
|
||||
"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=="],
|
||||
|
||||
@@ -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/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/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=="],
|
||||
|
||||
"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=="],
|
||||
|
||||
"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=="],
|
||||
|
||||
"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-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=="],
|
||||
|
||||
"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-scroll-loader/react-dom/scheduler": ["scheduler@0.23.2", "", { "dependencies": { "loose-envify": "^1.1.0" } }, "sha512-UOShsPwz7NrMUqhR6t0hWjFduvOzbtv7toDH1/hIrfRNIDBnnBWd0CwJTGvTpngVlmwGCdP9/Zl/tVrDqcuYzQ=="],
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hipmi",
|
||||
"version": "1.5.36",
|
||||
"version": "1.5.40",
|
||||
"private": true,
|
||||
"prisma": {
|
||||
"seed": "bun prisma/seed.ts"
|
||||
@@ -50,6 +50,7 @@
|
||||
"@types/react-dom": "18.2.7",
|
||||
"@types/uuid": "^9.0.4",
|
||||
"autoprefixer": "10.4.14",
|
||||
"axios": "^1.13.5",
|
||||
"bufferutil": "^4.0.8",
|
||||
"bun": "^1.1.38",
|
||||
"caniuse-lite": "^1.0.30001757",
|
||||
|
||||
@@ -295,7 +295,7 @@
|
||||
<p>You have the right to request access to the personal information we collect from you, details about how we have processed it, correct inaccuracies, or delete your personal information. You may also have the right to withdraw your consent to our processing of your personal information. These rights may be limited in some circumstances by applicable law.</p>
|
||||
<p>To make a request, please contact us at <a href="mailto:bip.baliinteraktifperkasa@gmail.com">bip.baliinteraktifperkasa@gmail.com</a>.</p>
|
||||
<hr style="margin: 30px 0; border: 0; border-top: 1px solid #eee;">
|
||||
<p>© 2025 Bali Interaktif Perkasa. All rights reserved.</p>
|
||||
<p>© 2026 Bali Interaktif Perkasa. All rights reserved.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -104,7 +104,7 @@
|
||||
</p>
|
||||
|
||||
<footer>
|
||||
<p>© 2025 Bali Interaktif Perkasa. All rights reserved.</p>
|
||||
<p>© 2026 Bali Interaktif Perkasa. All rights reserved.</p>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
@@ -2,12 +2,13 @@ import { prisma } from "@/lib";
|
||||
import { randomOTP } from "@/app_modules/auth/fun/rondom_otp";
|
||||
import backendLogger from "@/util/backendLogger";
|
||||
import { NextResponse } from "next/server";
|
||||
import { funSendToWhatsApp } from "@/lib/code-otp-sender";
|
||||
|
||||
export async function POST(req: Request) {
|
||||
if (req.method !== "POST") {
|
||||
return NextResponse.json(
|
||||
{ success: false, message: "Method Not Allowed" },
|
||||
{ status: 405 }
|
||||
{ status: 405 },
|
||||
);
|
||||
}
|
||||
|
||||
@@ -26,29 +27,21 @@ export async function POST(req: Request) {
|
||||
if (!createOtpId)
|
||||
return NextResponse.json(
|
||||
{ success: false, message: "Gagal mengirim kode OTP" },
|
||||
{ status: 400 }
|
||||
{ status: 400 },
|
||||
);
|
||||
|
||||
const msg = `HIPMI%20-%20Kode%20ini%20bersifat%20RAHASIA%20dan%20JANGAN%20DI%20BAGIKAN%20KEPADA%20SIAPAPUN%2C%20termasuk%20anggota%20ataupun%20pengurus%20HIPMI%20lainnya.%5Cn%5Cn%3E%3E%20Kode%20OTP%20anda%3A%20${codeOtp}.`;
|
||||
// const encodedMsg = encodeURIComponent(msg);
|
||||
const resSendCode = await funSendToWhatsApp({
|
||||
nomor,
|
||||
codeOtp: codeOtp.toString(),
|
||||
});
|
||||
|
||||
const res = await fetch(
|
||||
`https://cld-dkr-prod-wajs-server.wibudev.com/api/wa/code?nom=${nomor}&text=${msg}`,
|
||||
{
|
||||
cache: "no-cache",
|
||||
headers: {
|
||||
Authorization: `Bearer ${process.env.WA_SERVER_TOKEN}`,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
if (res.status !== 200)
|
||||
if (resSendCode.status !== 200)
|
||||
return NextResponse.json(
|
||||
{ success: false, message: "Nomor Whatsapp Tidak Aktif" },
|
||||
{ status: 400 }
|
||||
{ status: 400 },
|
||||
);
|
||||
|
||||
const sendWa = await res.text();
|
||||
const sendWa = await resSendCode.text();
|
||||
console.log("WA Response:", sendWa);
|
||||
|
||||
return NextResponse.json(
|
||||
@@ -57,7 +50,7 @@ export async function POST(req: Request) {
|
||||
message: "Kode verifikasi terkirim",
|
||||
kodeId: createOtpId.id,
|
||||
},
|
||||
{ status: 200 }
|
||||
{ status: 200 },
|
||||
);
|
||||
} catch (error) {
|
||||
backendLogger.log("Error Login", error);
|
||||
@@ -67,7 +60,7 @@ export async function POST(req: Request) {
|
||||
message: "Terjadi masalah saat login",
|
||||
reason: error as Error,
|
||||
},
|
||||
{ status: 500 }
|
||||
{ status: 500 },
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { prisma } from "@/lib";
|
||||
import { randomOTP } from "@/app_modules/auth/fun/rondom_otp";
|
||||
import { NextResponse } from "next/server";
|
||||
import { funSendToWhatsApp } from "@/lib/code-otp-sender";
|
||||
|
||||
export async function POST(req: Request) {
|
||||
try {
|
||||
@@ -31,30 +32,21 @@ export async function POST(req: Request) {
|
||||
if (!createOtpId)
|
||||
return NextResponse.json(
|
||||
{ success: false, message: "Gagal mengirim kode OTP" },
|
||||
{ status: 400 }
|
||||
{ status: 400 },
|
||||
);
|
||||
|
||||
// const msg = `HIPMI - Kode ini bersifat RAHASIA dan JANGAN DI BAGIKAN KEPAADA SIAPAPUN, termasuk anggota ataupun pengurus HIPMI lainnya.\n\n\n> Kode OTP anda: ${codeOtp}.`;
|
||||
// const encodedMsg = encodeURIComponent(msg);
|
||||
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 resSendCode = await funSendToWhatsApp({
|
||||
nomor,
|
||||
codeOtp: codeOtp.toString(),
|
||||
});
|
||||
|
||||
const res = await fetch(
|
||||
`https://cld-dkr-prod-wajs-server.wibudev.com/api/wa/code?nom=${nomor}&text=${msg}`,
|
||||
{
|
||||
cache: "no-cache",
|
||||
headers: {
|
||||
Authorization: `Bearer ${process.env.WA_SERVER_TOKEN}`,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
if (res.status !== 200)
|
||||
if (resSendCode.status !== 200)
|
||||
return NextResponse.json(
|
||||
{ success: false, message: "Nomor Whatsapp Tidak Aktif" },
|
||||
{ status: 400 }
|
||||
{ status: 400 },
|
||||
);
|
||||
|
||||
const sendWa = await res.text();
|
||||
const sendWa = await resSendCode.text();
|
||||
console.log("WA Response:", sendWa);
|
||||
|
||||
return NextResponse.json(
|
||||
@@ -64,7 +56,7 @@ export async function POST(req: Request) {
|
||||
kodeId: createOtpId.id,
|
||||
isAcceptTerms: user.termsOfServiceAccepted,
|
||||
},
|
||||
{ status: 200 }
|
||||
{ status: 200 },
|
||||
);
|
||||
} catch (error) {
|
||||
return NextResponse.json(
|
||||
@@ -73,7 +65,7 @@ export async function POST(req: Request) {
|
||||
message: "Terjadi masalah saat login",
|
||||
reason: error as Error,
|
||||
},
|
||||
{ status: 500 }
|
||||
{ status: 500 },
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
NotificationMobileBodyType,
|
||||
NotificationMobileTitleType,
|
||||
} from "../../../../../types/type-mobile-notification";
|
||||
import { funSendToWhatsApp } from "@/lib/code-otp-sender";
|
||||
|
||||
export async function POST(req: Request) {
|
||||
if (req.method !== "POST") {
|
||||
@@ -69,23 +70,21 @@ export async function POST(req: Request) {
|
||||
{ status: 400 }
|
||||
);
|
||||
|
||||
// const msg = `HIPMI - Kode ini bersifat RAHASIA dan JANGAN DI BAGIKAN KEPAADA SIAPAPUN, termasuk anggota ataupun pengurus HIPMI lainnya.\n\n\n> Kode OTP anda: ${codeOtp}.`;
|
||||
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 encodedMsg = encodeURIComponent(msg);
|
||||
const resSendCode = await funSendToWhatsApp({
|
||||
nomor: data.nomor,
|
||||
codeOtp: codeOtp.toString(),
|
||||
});
|
||||
|
||||
const res = await fetch(
|
||||
`https://wa.wibudev.com/code?nom=${data.nomor}&text=${msg}`,
|
||||
{ cache: "no-cache" }
|
||||
);
|
||||
|
||||
const sendWa = await res.json();
|
||||
|
||||
if (sendWa.status !== "success")
|
||||
if (resSendCode.status !== 200)
|
||||
return NextResponse.json(
|
||||
{ success: false, message: "Nomor Whatsapp Tidak Aktif" },
|
||||
{ status: 400 }
|
||||
{ status: 400 },
|
||||
);
|
||||
|
||||
const sendWa = await resSendCode.text();
|
||||
console.log("WA Response:", sendWa);
|
||||
|
||||
|
||||
// =========== START SEND NOTIFICATION =========== //
|
||||
|
||||
const adminUsers = await prisma.user.findMany({
|
||||
|
||||
@@ -2,12 +2,13 @@ import { prisma } from "@/lib";
|
||||
import { randomOTP } from "@/app_modules/auth/fun/rondom_otp";
|
||||
import backendLogger from "@/util/backendLogger";
|
||||
import { NextResponse } from "next/server";
|
||||
import { funSendToWhatsApp } from "@/lib/code-otp-sender";
|
||||
|
||||
export async function POST(req: Request) {
|
||||
if (req.method !== "POST") {
|
||||
return NextResponse.json(
|
||||
{ success: false, message: "Method Not Allowed" },
|
||||
{ status: 405 }
|
||||
{ status: 405 },
|
||||
);
|
||||
}
|
||||
|
||||
@@ -16,25 +17,18 @@ export async function POST(req: Request) {
|
||||
const body = await req.json();
|
||||
const { nomor } = body;
|
||||
|
||||
const msg = `HIPMI%20-%20Kode%20ini%20bersifat%20RAHASIA%20dan%20JANGAN%20DI%20BAGIKAN%20KEPADA%20SIAPAPUN%2C%20termasuk%20anggota%20ataupun%20pengurus%20HIPMI%20lainnya.%5Cn%5Cn%3E%3E%20Kode%20OTP%20anda%3A%20${codeOtp}.`;
|
||||
const resSendCode = await funSendToWhatsApp({
|
||||
nomor,
|
||||
codeOtp: codeOtp.toString(),
|
||||
});
|
||||
|
||||
const res = await fetch(
|
||||
`https://cld-dkr-prod-wajs-server.wibudev.com/api/wa/code?nom=${nomor}&text=${msg}`,
|
||||
{
|
||||
cache: "no-cache",
|
||||
headers: {
|
||||
Authorization: `Bearer ${process.env.WA_SERVER_TOKEN}`,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
if (res.status !== 200)
|
||||
if (resSendCode.status !== 200)
|
||||
return NextResponse.json(
|
||||
{ success: false, message: "Nomor Whatsapp Tidak Aktif" },
|
||||
{ status: 400 }
|
||||
{ status: 400 },
|
||||
);
|
||||
|
||||
const sendWa = await res.text();
|
||||
const sendWa = await resSendCode.text();
|
||||
console.log("WA Response:", sendWa);
|
||||
|
||||
const createOtpId = await prisma.kodeOtp.create({
|
||||
@@ -50,7 +44,7 @@ export async function POST(req: Request) {
|
||||
success: false,
|
||||
message: "Gagal Membuat Kode OTP",
|
||||
},
|
||||
{ status: 400 }
|
||||
{ status: 400 },
|
||||
);
|
||||
|
||||
return NextResponse.json(
|
||||
@@ -59,7 +53,7 @@ export async function POST(req: Request) {
|
||||
message: "Kode Verifikasi Dikirim",
|
||||
kodeId: createOtpId.id,
|
||||
},
|
||||
{ status: 200 }
|
||||
{ status: 200 },
|
||||
);
|
||||
} catch (error) {
|
||||
backendLogger.error(" Error Resend OTP", error);
|
||||
@@ -68,7 +62,7 @@ export async function POST(req: Request) {
|
||||
success: false,
|
||||
message: "Server Whatsapp Error !!",
|
||||
},
|
||||
{ status: 500 }
|
||||
{ status: 500 },
|
||||
);
|
||||
} finally {
|
||||
await prisma.$disconnect();
|
||||
|
||||
@@ -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 { NextResponse } from "next/server";
|
||||
import {
|
||||
NotificationMobileBodyType,
|
||||
NotificationMobileTitleType,
|
||||
} from "../../../../../../../../types/type-mobile-notification";
|
||||
import { routeUserMobile } from "@/lib/mobile/route-page-mobile";
|
||||
|
||||
export { POST, GET };
|
||||
|
||||
async function POST(request: Request, { params }: { params: { id: string } }) {
|
||||
const { id } = params;
|
||||
const { data } = await request.json();
|
||||
const { title, nominalCair, deskripsi, imageId, authorId } = data;
|
||||
|
||||
try {
|
||||
const dataDonasi = await prisma.donasi.findUnique({
|
||||
@@ -22,19 +33,19 @@ async function POST(request: Request, { params }: { params: { id: string } }) {
|
||||
return NextResponse.json(
|
||||
{
|
||||
success: false,
|
||||
message: "Pencarian Donasi Gagal",
|
||||
reason: "Pencarian Donasi Gagal",
|
||||
message: "DataPencarian Donasi Gagal",
|
||||
reason: "Data Pencarian Donasi Gagal",
|
||||
},
|
||||
{ status: 400 }
|
||||
{ status: 400 },
|
||||
);
|
||||
|
||||
const createPencairan = await prisma.donasi_PencairanDana.create({
|
||||
data: {
|
||||
donasiId: id,
|
||||
nominalCair: +data.nominalCair,
|
||||
deskripsi: data.deskripsi,
|
||||
title: data.title,
|
||||
imageId: data.imageId,
|
||||
nominalCair: +nominalCair,
|
||||
deskripsi: deskripsi,
|
||||
title: title,
|
||||
imageId: imageId,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -45,11 +56,11 @@ async function POST(request: Request, { params }: { params: { id: string } }) {
|
||||
message: "Pencairan Dana Gagal",
|
||||
reason: "Pencairan Dana Gagal",
|
||||
},
|
||||
{ status: 400 }
|
||||
{ status: 400 },
|
||||
);
|
||||
|
||||
const hasilTotalPencairan =
|
||||
Number(dataDonasi.totalPencairan) + Number(data.nominalCair);
|
||||
Number(dataDonasi.totalPencairan) + Number(nominalCair);
|
||||
// const hasilAkumulasiPencairan = Number(dataDonasi.akumulasiPencairan) + 1;
|
||||
|
||||
const countPencairan = await prisma.donasi_PencairanDana.count({
|
||||
@@ -66,8 +77,47 @@ async function POST(request: Request, { params }: { params: { id: string } }) {
|
||||
akumulasiPencairan: countPencairan,
|
||||
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)
|
||||
return NextResponse.json(
|
||||
{
|
||||
@@ -75,7 +125,7 @@ async function POST(request: Request, { params }: { params: { id: string } }) {
|
||||
message: "Update Donasi Gagal",
|
||||
reason: "Update Donasi Gagal",
|
||||
},
|
||||
{ status: 400 }
|
||||
{ status: 400 },
|
||||
);
|
||||
|
||||
return NextResponse.json(
|
||||
@@ -84,7 +134,7 @@ async function POST(request: Request, { params }: { params: { id: string } }) {
|
||||
message: "Pencairan Dana Berhasil",
|
||||
// data: data,
|
||||
},
|
||||
{ status: 200 }
|
||||
{ status: 200 },
|
||||
);
|
||||
} catch (error) {
|
||||
console.error("[ERROR]", error);
|
||||
@@ -94,7 +144,7 @@ async function POST(request: Request, { params }: { params: { id: string } }) {
|
||||
message: "Pencairan Dana Gagal",
|
||||
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);
|
||||
let fixData;
|
||||
try {
|
||||
|
||||
if (category === "get-all") {
|
||||
fixData = await prisma.donasi_PencairanDana.findMany({
|
||||
take: page ? takeData : undefined,
|
||||
@@ -140,7 +189,7 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||
message: "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",
|
||||
data: fixData,
|
||||
},
|
||||
{ status: 200 }
|
||||
{ status: 200 },
|
||||
);
|
||||
} catch (error) {
|
||||
console.error("[ERROR]", error);
|
||||
@@ -160,7 +209,7 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||
message: "Gagal mendapatkan data disbursement",
|
||||
reason: (error as Error).message,
|
||||
},
|
||||
{ status: 500 }
|
||||
{ status: 500 },
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { prisma } from "@/lib";
|
||||
import _ from "lodash";
|
||||
import { sendNotificationMobileToOneUser } from "@/lib/mobile/notification/send-notification";
|
||||
import { NotificationMobileBodyType, NotificationMobileTitleType } from "../../../../../../../../types/type-mobile-notification";
|
||||
import { routeUserMobile } from "@/lib/mobile/route-page-mobile";
|
||||
|
||||
export { GET, PUT };
|
||||
|
||||
@@ -50,6 +53,7 @@ async function GET(req: Request, { params }: { params: { id: string } }) {
|
||||
interface DataType {
|
||||
donationId: string;
|
||||
nominal: number;
|
||||
senderId: string;
|
||||
}
|
||||
|
||||
async function PUT(req: Request, { params }: { params: { id: string } }) {
|
||||
@@ -111,6 +115,9 @@ async function PUT(req: Request, { params }: { params: { id: string } }) {
|
||||
data: {
|
||||
donasiMaster_StatusInvoiceId: checkStatusTransaksi.id,
|
||||
},
|
||||
select: {
|
||||
authorId: true,
|
||||
},
|
||||
});
|
||||
|
||||
if (!updateInvoice) {
|
||||
@@ -154,6 +161,38 @@ async function PUT(req: Request, { params }: { params: { id: string } }) {
|
||||
);
|
||||
}
|
||||
|
||||
// SEND NOTIFICATION: to donatur
|
||||
await sendNotificationMobileToOneUser({
|
||||
recipientId: updateInvoice?.authorId as string,
|
||||
senderId: data?.senderId || "",
|
||||
payload: {
|
||||
title: "Transaksi Berhasil" as NotificationMobileTitleType,
|
||||
body: `Selamat anda menjadi donatur pada ${updateDonasi?.title}` as NotificationMobileBodyType,
|
||||
type: "announcement",
|
||||
kategoriApp: "DONASI",
|
||||
deepLink: routeUserMobile.donationTransaction,
|
||||
},
|
||||
});
|
||||
|
||||
// SEND NOTIFICATION: to creator
|
||||
await sendNotificationMobileToOneUser({
|
||||
recipientId: updateDonasi?.authorId as any,
|
||||
senderId: data?.senderId || "",
|
||||
payload: {
|
||||
title: "Ada Donatur Baru !" as NotificationMobileTitleType,
|
||||
body: `Cek daftar donatur pada ${updateDonasi?.title}` as NotificationMobileBodyType,
|
||||
type: "announcement",
|
||||
kategoriApp: "DONASI",
|
||||
deepLink: routeUserMobile.donationDetailPublish({
|
||||
id: updateDonasi?.id as string,
|
||||
}),
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return NextResponse.json(
|
||||
{
|
||||
success: true,
|
||||
|
||||
@@ -1,6 +1,15 @@
|
||||
import {
|
||||
sendNotificationMobileToManyUser,
|
||||
sendNotificationMobileToOneUser,
|
||||
} from "@/lib/mobile/notification/send-notification";
|
||||
import { routeUserMobile } from "@/lib/mobile/route-page-mobile";
|
||||
import prisma from "@/lib/prisma";
|
||||
import _ from "lodash";
|
||||
import { NextResponse } from "next/server";
|
||||
import {
|
||||
NotificationMobileBodyType,
|
||||
NotificationMobileTitleType,
|
||||
} from "../../../../../../../types/type-mobile-notification";
|
||||
|
||||
export { GET, PUT };
|
||||
|
||||
@@ -60,7 +69,7 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||
donatur: successInvoice,
|
||||
},
|
||||
},
|
||||
{ status: 200 }
|
||||
{ status: 200 },
|
||||
);
|
||||
} catch (error) {
|
||||
return NextResponse.json(
|
||||
@@ -69,7 +78,7 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||
message: "Error get detail Investasi",
|
||||
reason: (error as Error).message,
|
||||
},
|
||||
{ status: 500 }
|
||||
{ status: 500 },
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -77,6 +86,10 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||
async function PUT(request: Request, { params }: { params: { id: string } }) {
|
||||
const { id } = params;
|
||||
const { data } = await request.json();
|
||||
const { catatan, senderId } = data;
|
||||
console.log("[PUT CATATAN]", catatan);
|
||||
console.log("[PUT SENDER ID]", senderId);
|
||||
|
||||
const { searchParams } = new URL(request.url);
|
||||
const status = searchParams.get("status");
|
||||
const fixStatus = _.startCase(status as string);
|
||||
@@ -102,7 +115,7 @@ async function PUT(request: Request, { params }: { params: { id: string } }) {
|
||||
message: "Error update data event",
|
||||
reason: "Status not found",
|
||||
},
|
||||
{ status: 500 }
|
||||
{ status: 500 },
|
||||
);
|
||||
|
||||
if (fixStatus === "Reject") {
|
||||
@@ -111,11 +124,24 @@ async function PUT(request: Request, { params }: { params: { id: string } }) {
|
||||
id: id,
|
||||
},
|
||||
data: {
|
||||
catatan: data,
|
||||
catatan: catatan,
|
||||
donasiMaster_StatusDonasiId: checkStatus.id,
|
||||
},
|
||||
});
|
||||
|
||||
// SEND NOTIFICATION
|
||||
await sendNotificationMobileToOneUser({
|
||||
recipientId: updateData.authorId as any,
|
||||
senderId: senderId,
|
||||
payload: {
|
||||
title: "Pengajuan Review Ditolak",
|
||||
body: "Mohon perbaiki data sesuai catatan penolakan !",
|
||||
type: "announcement",
|
||||
kategoriApp: "DONASI",
|
||||
deepLink: routeUserMobile.donationByStatus({ status: "reject" }),
|
||||
},
|
||||
});
|
||||
|
||||
fixData = updateData;
|
||||
} else if (fixStatus === "Publish") {
|
||||
const updateData = await prisma.donasi.update({
|
||||
@@ -128,6 +154,39 @@ async function PUT(request: Request, { params }: { params: { id: string } }) {
|
||||
},
|
||||
});
|
||||
|
||||
// SEND NOTIFICAtION
|
||||
await sendNotificationMobileToOneUser({
|
||||
recipientId: updateData.authorId as any,
|
||||
senderId: senderId,
|
||||
payload: {
|
||||
title: "Review Selesai",
|
||||
body: `Donasi kamu telah dipublikasikan ! ${updateData.title}` as NotificationMobileBodyType,
|
||||
type: "announcement",
|
||||
kategoriApp: "DONASI",
|
||||
deepLink: routeUserMobile.donationByStatus({ status: "publish" }),
|
||||
},
|
||||
});
|
||||
|
||||
const allUsers = await prisma.user.findMany({
|
||||
where: {
|
||||
NOT: { id: updateData.authorId as any },
|
||||
active: true,
|
||||
},
|
||||
select: { id: true },
|
||||
});
|
||||
|
||||
await sendNotificationMobileToManyUser({
|
||||
recipientIds: allUsers.map((user) => user.id),
|
||||
senderId: senderId,
|
||||
payload: {
|
||||
title: "Ayo Cek Donasi Terbaru" as NotificationMobileTitleType,
|
||||
body: `${updateData.title}` as NotificationMobileBodyType,
|
||||
type: "announcement",
|
||||
kategoriApp: "DONASI",
|
||||
deepLink: routeUserMobile.donationDetailPublish({ id: id }),
|
||||
},
|
||||
});
|
||||
|
||||
fixData = updateData;
|
||||
}
|
||||
|
||||
@@ -137,7 +196,7 @@ async function PUT(request: Request, { params }: { params: { id: string } }) {
|
||||
message: "Data Donasi Berhasil Diambil",
|
||||
data: data,
|
||||
},
|
||||
{ status: 200 }
|
||||
{ status: 200 },
|
||||
);
|
||||
} catch (error) {
|
||||
return NextResponse.json(
|
||||
@@ -146,7 +205,7 @@ async function PUT(request: Request, { params }: { params: { id: string } }) {
|
||||
message: "Error get detail Investasi",
|
||||
reason: (error as Error).message,
|
||||
},
|
||||
{ status: 500 }
|
||||
{ status: 500 },
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
import _ from "lodash";
|
||||
import { NextResponse } from "next/server";
|
||||
import prisma from "@/lib/prisma";
|
||||
import { sendNotificationMobileToOneUser } from "@/lib/mobile/notification/send-notification";
|
||||
import {
|
||||
NotificationMobileBodyType,
|
||||
NotificationMobileTitleType,
|
||||
} from "../../../../../../../../types/type-mobile-notification";
|
||||
import { routeUserMobile } from "@/lib/mobile/route-page-mobile";
|
||||
|
||||
export { GET, PUT };
|
||||
|
||||
@@ -82,21 +88,43 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||
|
||||
async function PUT(request: Request, { params }: { params: { id: string } }) {
|
||||
const { id } = params;
|
||||
const data = await request.json();
|
||||
|
||||
console.log("SENDER Comment", data);
|
||||
|
||||
try {
|
||||
const deleteData = await prisma.forum_Komentar.update({
|
||||
const deactiveComment = await prisma.forum_Komentar.update({
|
||||
where: {
|
||||
id: id,
|
||||
},
|
||||
data: {
|
||||
isActive: false,
|
||||
},
|
||||
select: {
|
||||
authorId: true,
|
||||
komentar: true,
|
||||
},
|
||||
});
|
||||
|
||||
// SEND NOTIFICATION
|
||||
await sendNotificationMobileToOneUser({
|
||||
recipientId: deactiveComment?.authorId as string,
|
||||
senderId: data?.senderId,
|
||||
payload: {
|
||||
title: "Penghapusan Komentar" as NotificationMobileTitleType,
|
||||
body: `Komentar anda telah dilaporkan: ${deactiveComment?.komentar}` as NotificationMobileBodyType,
|
||||
type: "announcement",
|
||||
kategoriApp: "FORUM",
|
||||
deepLink: routeUserMobile.forumPreviewReportComment({ id: id }),
|
||||
},
|
||||
});
|
||||
|
||||
console.log("[DEACTIVATE COMMENT]");
|
||||
return NextResponse.json(
|
||||
{
|
||||
success: true,
|
||||
message: "Success deactivate comment",
|
||||
data: deleteData,
|
||||
// data: deactiveComment,
|
||||
},
|
||||
{ status: 200 }
|
||||
);
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import prisma from "@/lib/prisma";
|
||||
import _ from "lodash";
|
||||
import { sendNotificationMobileToOneUser } from "@/lib/mobile/notification/send-notification";
|
||||
import {
|
||||
NotificationMobileBodyType,
|
||||
NotificationMobileTitleType,
|
||||
} from "../../../../../../../types/type-mobile-notification";
|
||||
import { routeUserMobile } from "@/lib/mobile/route-page-mobile";
|
||||
|
||||
export { GET, PUT };
|
||||
|
||||
@@ -78,14 +84,23 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||
|
||||
async function PUT(request: Request, { params }: { params: { id: string } }) {
|
||||
const { id } = params;
|
||||
const data = await request.json();
|
||||
const { senderId } = data;
|
||||
|
||||
console.log("SENDER POSTING", data);
|
||||
|
||||
try {
|
||||
const data = await prisma.forum_Posting.update({
|
||||
const deactivePosting = await prisma.forum_Posting.update({
|
||||
where: {
|
||||
id: id,
|
||||
},
|
||||
data: {
|
||||
isActive: false,
|
||||
},
|
||||
select: {
|
||||
authorId: true,
|
||||
diskusi: true,
|
||||
},
|
||||
});
|
||||
|
||||
const deactivateComment = await prisma.forum_Komentar.updateMany({
|
||||
@@ -97,12 +112,25 @@ async function PUT(request: Request, { params }: { params: { id: string } }) {
|
||||
},
|
||||
});
|
||||
|
||||
console.log("[DEACTIVATE COMMENT]", deactivateComment);
|
||||
// SEND NOTIFICATION
|
||||
await sendNotificationMobileToOneUser({
|
||||
recipientId: deactivePosting?.authorId as string,
|
||||
senderId: senderId,
|
||||
payload: {
|
||||
title: "Penghapusan Postingan" as NotificationMobileTitleType,
|
||||
body: `Postingan anda telah dilaporkan: ${deactivePosting?.diskusi}` as NotificationMobileBodyType,
|
||||
type: "announcement",
|
||||
kategoriApp: "FORUM",
|
||||
deepLink: routeUserMobile.forumPreviewReportPosting({ id: id }),
|
||||
},
|
||||
});
|
||||
|
||||
console.log("[DEACTIVATE POSTINGAN & COMMENT]", deactivateComment);
|
||||
return NextResponse.json(
|
||||
{
|
||||
success: true,
|
||||
message: "Success deactivate posting",
|
||||
data: data,
|
||||
data: deactivePosting,
|
||||
},
|
||||
{ status: 200 }
|
||||
);
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { prisma } from "@/lib";
|
||||
import { sendNotificationMobileToOneUser } from "@/lib/mobile/notification/send-notification";
|
||||
import {
|
||||
NotificationMobileBodyType,
|
||||
NotificationMobileTitleType,
|
||||
} from "../../../../../../../../types/type-mobile-notification";
|
||||
import { routeUserMobile } from "@/lib/mobile/route-page-mobile";
|
||||
|
||||
export { GET, PUT };
|
||||
|
||||
@@ -65,19 +71,39 @@ async function PUT(req: Request, { params }: { params: { id: string } }) {
|
||||
data: {
|
||||
statusInvoiceId: "4",
|
||||
},
|
||||
// select: {
|
||||
// StatusInvoice: true,
|
||||
// authorId: true,
|
||||
// },
|
||||
select: {
|
||||
Investasi: {
|
||||
select: {
|
||||
title: true,
|
||||
},
|
||||
},
|
||||
authorId: true,
|
||||
},
|
||||
});
|
||||
|
||||
// SEND NOTIFICAtION
|
||||
await sendNotificationMobileToOneUser({
|
||||
recipientId: updt?.authorId as string,
|
||||
senderId: data?.senderId || "",
|
||||
payload: {
|
||||
title: "Transaksi Tertolak" as NotificationMobileTitleType,
|
||||
body: `Maaf transaksi kamu telah ditolak ! ${updt?.Investasi?.title}` as NotificationMobileBodyType,
|
||||
type: "announcement",
|
||||
kategoriApp: "INVESTASI",
|
||||
deepLink: routeUserMobile.investmentTransaction,
|
||||
},
|
||||
});
|
||||
|
||||
fixData = updt;
|
||||
} else if (category === "accept") {
|
||||
const dataInvestasi: any = await prisma.investasi.findFirst({
|
||||
const findInvestasi = await prisma.investasi.findFirst({
|
||||
where: {
|
||||
id: data.investasiId,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
authorId: true,
|
||||
totalLembar: true,
|
||||
sisaLembar: true,
|
||||
lembarTerbeli: true,
|
||||
@@ -85,30 +111,33 @@ async function PUT(req: Request, { params }: { params: { id: string } }) {
|
||||
});
|
||||
|
||||
// Hitung TOTAL SISA LEMBAR
|
||||
const investasi_sisaLembar = Number(dataInvestasi?.sisaLembar);
|
||||
const investasi_sisaLembar = Number(findInvestasi?.sisaLembar);
|
||||
const invoice_lembarTerbeli = Number(data.lembarTerbeli);
|
||||
const resultSisaLembar = investasi_sisaLembar - invoice_lembarTerbeli;
|
||||
|
||||
// TAMBAH LEMBAR TERBELI
|
||||
const investasi_lembarTerbeli = Number(dataInvestasi?.lembarTerbeli);
|
||||
const investasi_lembarTerbeli = Number(findInvestasi?.lembarTerbeli);
|
||||
const resultLembarTerbeli =
|
||||
investasi_lembarTerbeli + invoice_lembarTerbeli;
|
||||
|
||||
// Progress
|
||||
const investasi_totalLembar = Number(dataInvestasi?.totalLembar);
|
||||
const investasi_totalLembar = Number(findInvestasi?.totalLembar);
|
||||
const progress = (resultLembarTerbeli / investasi_totalLembar) * 100;
|
||||
const resultProgres = Number(progress).toFixed(2);
|
||||
|
||||
const updt = await prisma.investasi_Invoice.update({
|
||||
const updateInvoice = await prisma.investasi_Invoice.update({
|
||||
where: {
|
||||
id: id,
|
||||
},
|
||||
data: {
|
||||
statusInvoiceId: "1",
|
||||
},
|
||||
select: {
|
||||
authorId: true,
|
||||
},
|
||||
});
|
||||
|
||||
if (!updt) {
|
||||
if (!updateInvoice) {
|
||||
return NextResponse.json(
|
||||
{
|
||||
success: false,
|
||||
@@ -144,7 +173,35 @@ async function PUT(req: Request, { params }: { params: { id: string } }) {
|
||||
);
|
||||
}
|
||||
|
||||
fixData = updt;
|
||||
// SEND NOTIFICATION: to investor
|
||||
await sendNotificationMobileToOneUser({
|
||||
recipientId: updateInvoice?.authorId as string,
|
||||
senderId: data?.senderId || "",
|
||||
payload: {
|
||||
title: "Transaksi Berhasil" as NotificationMobileTitleType,
|
||||
body: `Selamat anda menjadi investor pada investasi ${findInvestasi?.title}` as NotificationMobileBodyType,
|
||||
type: "announcement",
|
||||
kategoriApp: "INVESTASI",
|
||||
deepLink: routeUserMobile.investmentTransaction,
|
||||
},
|
||||
});
|
||||
|
||||
// SEND NOTIFICATION: to creator
|
||||
await sendNotificationMobileToOneUser({
|
||||
recipientId: findInvestasi?.authorId as any,
|
||||
senderId: data?.senderId || "",
|
||||
payload: {
|
||||
title: "Ada Investor Baru !" as NotificationMobileTitleType,
|
||||
body: `Cek daftar investor pada ${findInvestasi?.title}` as NotificationMobileBodyType,
|
||||
type: "announcement",
|
||||
kategoriApp: "INVESTASI",
|
||||
deepLink: routeUserMobile.investmentDetailPublish({
|
||||
id: findInvestasi?.id as string,
|
||||
}),
|
||||
},
|
||||
});
|
||||
|
||||
fixData = updateInvoice;
|
||||
} else {
|
||||
return NextResponse.json(
|
||||
{
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { prisma } from "@/lib";
|
||||
import {
|
||||
sendNotificationMobileToManyUser,
|
||||
sendNotificationMobileToOneUser,
|
||||
} from "@/lib/mobile/notification/send-notification";
|
||||
import { routeUserMobile } from "@/lib/mobile/route-page-mobile";
|
||||
import {
|
||||
NotificationMobileBodyType,
|
||||
NotificationMobileTitleType,
|
||||
} from "../../../../../../../types/type-mobile-notification";
|
||||
|
||||
export { GET, PUT };
|
||||
|
||||
@@ -78,14 +87,19 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||
async function PUT(request: Request, { params }: { params: { id: string } }) {
|
||||
const { id } = params;
|
||||
const { data } = await request.json();
|
||||
const { catatan, senderId } = data;
|
||||
|
||||
console.log("[DATA]", data);
|
||||
console.log("[CATATAN]", catatan);
|
||||
console.log("[SENDER ID]", senderId);
|
||||
|
||||
const { searchParams } = new URL(request.url);
|
||||
const status = searchParams.get("status");
|
||||
|
||||
console.log("[=======Start Investment console=======]");
|
||||
console.log("[ID]", id);
|
||||
console.log("[DATA]", data);
|
||||
console.log("[STATUS]", status);
|
||||
console.log("[=======End Investment console=======]");
|
||||
// console.log("[=======Start Investment console=======]");
|
||||
// console.log("[ID]", id);
|
||||
// console.log("[STATUS]", status);
|
||||
// console.log("[=======End Investment console=======]");
|
||||
|
||||
const publishTime = new Date();
|
||||
|
||||
@@ -96,9 +110,26 @@ async function PUT(request: Request, { params }: { params: { id: string } }) {
|
||||
id: id,
|
||||
},
|
||||
data: {
|
||||
catatan: data,
|
||||
catatan: catatan,
|
||||
masterStatusInvestasiId: "4",
|
||||
},
|
||||
select: {
|
||||
authorId: true,
|
||||
title: true,
|
||||
},
|
||||
});
|
||||
|
||||
// SEND NOTIFICATION
|
||||
await sendNotificationMobileToOneUser({
|
||||
recipientId: updatedData.authorId as any,
|
||||
senderId: senderId,
|
||||
payload: {
|
||||
title: "Pengajuan Review Ditolak",
|
||||
body: "Mohon perbaiki data sesuai catatan penolakan !",
|
||||
type: "announcement",
|
||||
kategoriApp: "INVESTASI",
|
||||
deepLink: routeUserMobile.investmentPortofolioByStatus({ status: "reject" }),
|
||||
},
|
||||
});
|
||||
|
||||
console.log("[UPDATE REJECT]", updatedData);
|
||||
@@ -114,6 +145,39 @@ async function PUT(request: Request, { params }: { params: { id: string } }) {
|
||||
},
|
||||
});
|
||||
|
||||
// SEND NOTIFICAtION
|
||||
await sendNotificationMobileToOneUser({
|
||||
recipientId: updatedData.authorId as any,
|
||||
senderId: senderId,
|
||||
payload: {
|
||||
title: "Review Selesai",
|
||||
body: `Investasi kamu telah dipublikasikan ! ${updatedData.title}` as NotificationMobileBodyType,
|
||||
type: "announcement",
|
||||
kategoriApp: "INVESTASI",
|
||||
deepLink: routeUserMobile.investmentPortofolioByStatus({ status: "publish" }),
|
||||
},
|
||||
});
|
||||
|
||||
const allUsers = await prisma.user.findMany({
|
||||
where: {
|
||||
NOT: { id: updatedData.authorId as any },
|
||||
active: true,
|
||||
},
|
||||
select: { id: true },
|
||||
});
|
||||
|
||||
await sendNotificationMobileToManyUser({
|
||||
recipientIds: allUsers.map((user) => user.id),
|
||||
senderId: senderId,
|
||||
payload: {
|
||||
title: "Ayo Cek Investasi Terbaru" as NotificationMobileTitleType,
|
||||
body: `${updatedData.title}` as NotificationMobileBodyType,
|
||||
type: "announcement",
|
||||
kategoriApp: "INVESTASI",
|
||||
deepLink: routeUserMobile.investmentDetailPublish({ id: id }),
|
||||
},
|
||||
});
|
||||
|
||||
console.log("[UPDATE PUBLISH]", updatedData);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { prisma } from "@/lib";
|
||||
import { funSendToWhatsApp } from "@/lib/code-otp-sender";
|
||||
import _ from "lodash";
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
@@ -50,8 +51,25 @@ async function PUT(request: Request, { params }: { params: { id: string } }) {
|
||||
data: {
|
||||
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);
|
||||
} else if (category === "role") {
|
||||
const fixName = _.startCase(data.role.replace(/_/g, " "));
|
||||
|
||||
@@ -1,8 +1,17 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { prisma } from "@/lib";
|
||||
import _ from "lodash";
|
||||
import {
|
||||
sendNotificationMobileToManyUser,
|
||||
sendNotificationMobileToOneUser,
|
||||
} from "@/lib/mobile/notification/send-notification";
|
||||
import { routeUserMobile } from "@/lib/mobile/route-page-mobile";
|
||||
import {
|
||||
NotificationMobileBodyType,
|
||||
NotificationMobileTitleType,
|
||||
} from "../../../../../../../types/type-mobile-notification";
|
||||
|
||||
export { GET , PUT};
|
||||
export { GET, PUT };
|
||||
|
||||
async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||
const { id } = params;
|
||||
@@ -41,12 +50,16 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||
async function PUT(request: Request, { params }: { params: { id: string } }) {
|
||||
const { id } = params;
|
||||
const { data } = await request.json();
|
||||
const { catatan, senderId } = data;
|
||||
|
||||
console.log("catatan", catatan);
|
||||
console.log("senderId", senderId);
|
||||
|
||||
const { searchParams } = new URL(request.url);
|
||||
const status = searchParams.get("status");
|
||||
const fixStatus = _.startCase(status as string);
|
||||
let fixData;
|
||||
|
||||
|
||||
try {
|
||||
const checkStatus = await prisma.voting_Status.findFirst({
|
||||
where: {
|
||||
@@ -71,9 +84,23 @@ async function PUT(request: Request, { params }: { params: { id: string } }) {
|
||||
},
|
||||
data: {
|
||||
voting_StatusId: checkStatus.id,
|
||||
catatan: data,
|
||||
catatan: catatan,
|
||||
},
|
||||
});
|
||||
|
||||
// SEND NOTIFICATION
|
||||
await sendNotificationMobileToOneUser({
|
||||
recipientId: updateStatus.authorId as any,
|
||||
senderId: senderId,
|
||||
payload: {
|
||||
title: "Pengajuan Review Ditolak",
|
||||
body: "Mohon perbaiki data sesuai catatan penolakan !",
|
||||
type: "announcement",
|
||||
kategoriApp: "VOTING",
|
||||
deepLink: routeUserMobile.votingByStatus({ status: "reject" }),
|
||||
},
|
||||
});
|
||||
|
||||
fixData = updateStatus;
|
||||
} else if (fixStatus === "Publish") {
|
||||
const updateStatus = await prisma.voting.update({
|
||||
@@ -84,6 +111,39 @@ async function PUT(request: Request, { params }: { params: { id: string } }) {
|
||||
voting_StatusId: checkStatus.id,
|
||||
},
|
||||
});
|
||||
|
||||
await sendNotificationMobileToOneUser({
|
||||
recipientId: updateStatus.authorId as any,
|
||||
senderId: senderId,
|
||||
payload: {
|
||||
title: "Review Selesai",
|
||||
body: "Voting kamu telah dipublikasikan !" as NotificationMobileBodyType,
|
||||
type: "announcement",
|
||||
kategoriApp: "VOTING",
|
||||
deepLink: routeUserMobile.votingByStatus({ status: "publish" }),
|
||||
},
|
||||
});
|
||||
|
||||
const adminUsers = await prisma.user.findMany({
|
||||
where: {
|
||||
masterUserRoleId: "1",
|
||||
NOT: { id: updateStatus.authorId as any },
|
||||
},
|
||||
select: { id: true },
|
||||
});
|
||||
|
||||
await sendNotificationMobileToManyUser({
|
||||
recipientIds: adminUsers.map((user) => user.id),
|
||||
senderId: senderId,
|
||||
payload: {
|
||||
title: "Cek Voting Baru Terpublikasi" as NotificationMobileTitleType,
|
||||
body: `${updateStatus.title}` as NotificationMobileBodyType,
|
||||
type: "announcement",
|
||||
kategoriApp: "VOTING",
|
||||
deepLink: routeUserMobile.votingDetailPublised({ id: id }),
|
||||
},
|
||||
});
|
||||
|
||||
fixData = updateStatus;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,13 +4,42 @@ import { prisma } from "@/lib";
|
||||
export { POST, GET };
|
||||
|
||||
async function POST(request: NextRequest) {
|
||||
const { data } = await request.json();
|
||||
try {
|
||||
// Parse the request body - can accept either nested under 'data' or directly
|
||||
const requestBody = await request.json();
|
||||
|
||||
const { userId, platform, deviceId, model, appVersion, fcmToken } = data;
|
||||
// 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;
|
||||
|
||||
// Validate required fields
|
||||
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({
|
||||
@@ -23,7 +52,6 @@ async function POST(request: NextRequest) {
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
console.log("✅ EX", existing);
|
||||
|
||||
let deviceToken;
|
||||
@@ -31,7 +59,7 @@ async function POST(request: NextRequest) {
|
||||
if (existing) {
|
||||
deviceToken = await prisma.tokenUserDevice.update({
|
||||
where: {
|
||||
id: existing?.id,
|
||||
id: existing.id,
|
||||
},
|
||||
data: {
|
||||
platform,
|
||||
@@ -43,7 +71,7 @@ async function POST(request: NextRequest) {
|
||||
},
|
||||
});
|
||||
} else {
|
||||
// Buat baru jika belum ada
|
||||
// Create new device token record
|
||||
deviceToken = await prisma.tokenUserDevice.create({
|
||||
data: {
|
||||
token: fcmToken,
|
||||
@@ -58,9 +86,16 @@ async function POST(request: NextRequest) {
|
||||
}
|
||||
|
||||
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(
|
||||
{ error: (error as Error).message },
|
||||
{
|
||||
error: "Internal server error",
|
||||
message: error.message || "An unexpected error occurred",
|
||||
field: "server"
|
||||
},
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import _ from "lodash";
|
||||
import { NextResponse } from "next/server";
|
||||
import prisma from "@/lib/prisma";
|
||||
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||
|
||||
export { GET, PUT };
|
||||
|
||||
@@ -10,8 +11,14 @@ async function GET(
|
||||
) {
|
||||
const { id, status } = params;
|
||||
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 meta = null;
|
||||
|
||||
try {
|
||||
const checkStatus = await prisma.donasiMaster_StatusDonasi.findFirst({
|
||||
where: {
|
||||
@@ -50,18 +57,38 @@ async function GET(
|
||||
orderBy: {
|
||||
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) => ({
|
||||
..._.omit(v, ["DonasiMaster_Durasi"]),
|
||||
nameDonasiDurasi: v.DonasiMaster_Durasi.name,
|
||||
}));
|
||||
|
||||
meta = {
|
||||
currentPage: page,
|
||||
totalData: totalData,
|
||||
totalPage: totalPages,
|
||||
dataPerPage: takeData,
|
||||
};
|
||||
|
||||
return NextResponse.json({
|
||||
status: 200,
|
||||
success: true,
|
||||
message: "Berhasil mendapatkan data",
|
||||
data: fixData,
|
||||
...(meta && { meta }),
|
||||
});
|
||||
} catch (error) {
|
||||
console.log("[ERROR]", error);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { prisma } from "@/lib";
|
||||
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||
|
||||
export { GET };
|
||||
|
||||
@@ -7,7 +8,7 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||
const { id } = params;
|
||||
const { searchParams } = new URL(request.url);
|
||||
const page = Number(searchParams.get("page"));
|
||||
const takeData = 5;
|
||||
const takeData = PAGINATION_DEFAULT_TAKE;
|
||||
const skipData = page * takeData - takeData;
|
||||
|
||||
try {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||
import prisma from "@/lib/prisma";
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
@@ -9,11 +10,12 @@ export async function GET(
|
||||
let fixData;
|
||||
const { id } = params;
|
||||
const { searchParams } = new URL(request.url);
|
||||
const page = Number(searchParams.get("page"));
|
||||
const takeData = 10;
|
||||
const page = Number(searchParams.get("page")) || 1; // Default page 1 jika tidak ada atau invalid
|
||||
const takeData = PAGINATION_DEFAULT_TAKE;
|
||||
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,
|
||||
skip: page ? skipData : undefined,
|
||||
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({
|
||||
success: true,
|
||||
message: "Data berhasil diambil",
|
||||
data: fixData,
|
||||
pagination: {
|
||||
currentPage: page,
|
||||
totalPages: totalPages,
|
||||
totalData: totalCount,
|
||||
dataPerPage: takeData,
|
||||
},
|
||||
});
|
||||
} catch (error) {
|
||||
return NextResponse.json({
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
import _ from "lodash";
|
||||
import { NextResponse } from "next/server";
|
||||
import prisma from "@/lib/prisma";
|
||||
import { sendNotificationMobileToManyUser } from "@/lib/mobile/notification/send-notification";
|
||||
import {
|
||||
NotificationMobileBodyType,
|
||||
NotificationMobileTitleType,
|
||||
} from "../../../../../../../types/type-mobile-notification";
|
||||
import { routeAdminMobile } from "@/lib/mobile/route-page-mobile";
|
||||
|
||||
export { POST, GET, PUT };
|
||||
|
||||
@@ -33,6 +39,14 @@ async function POST(request: Request, { params }: { params: { id: string } }) {
|
||||
},
|
||||
});
|
||||
|
||||
if (!create) {
|
||||
return NextResponse.json({
|
||||
status: 500,
|
||||
success: false,
|
||||
message: "Gagal membuat invoice",
|
||||
});
|
||||
}
|
||||
|
||||
return NextResponse.json({
|
||||
status: 201,
|
||||
success: true,
|
||||
@@ -65,7 +79,7 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||
createdAt: true,
|
||||
donasiMaster_BankId: true,
|
||||
donasiMaster_StatusInvoiceId: true,
|
||||
MasterBank: true,
|
||||
MasterBank: true,
|
||||
Donasi: {
|
||||
select: {
|
||||
id: true,
|
||||
@@ -139,7 +153,7 @@ async function PUT(request: Request, { params }: { params: { id: string } }) {
|
||||
});
|
||||
}
|
||||
|
||||
const update = await prisma.donasi_Invoice.update({
|
||||
const updated = await prisma.donasi_Invoice.update({
|
||||
where: {
|
||||
id: id,
|
||||
},
|
||||
@@ -164,7 +178,40 @@ async function PUT(request: Request, { params }: { params: { id: string } }) {
|
||||
},
|
||||
});
|
||||
|
||||
console.log("[UPDATE INVOICE]", update);
|
||||
if (!updated) {
|
||||
return NextResponse.json({
|
||||
status: 500,
|
||||
success: false,
|
||||
message: "Gagal memperbarui data",
|
||||
});
|
||||
}
|
||||
|
||||
const findUsers = await prisma.user.findMany({
|
||||
where: {
|
||||
masterUserRoleId: "2",
|
||||
active: true,
|
||||
NOT: { id: updated?.Donasi?.authorId as string },
|
||||
},
|
||||
select: { id: true },
|
||||
});
|
||||
|
||||
// SEND NOTIFICATION
|
||||
await sendNotificationMobileToManyUser({
|
||||
recipientIds: findUsers.map((user) => user.id),
|
||||
senderId: data.authorId,
|
||||
payload: {
|
||||
title: "Ada Donasi Baru !" as NotificationMobileTitleType,
|
||||
body: `Cek data investor pada ${updated?.Donasi?.title}` as NotificationMobileBodyType,
|
||||
type: "announcement",
|
||||
kategoriApp: "DONASI",
|
||||
deepLink: routeAdminMobile.donationDetailPublish({
|
||||
id: updated?.Donasi?.id as string,
|
||||
status: "publish",
|
||||
}),
|
||||
},
|
||||
});
|
||||
|
||||
console.log("[UPDATE INVOICE]", updated);
|
||||
|
||||
return NextResponse.json({
|
||||
status: 200,
|
||||
|
||||
@@ -1,25 +1,40 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { prisma } from "@/lib";
|
||||
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 };
|
||||
|
||||
async function POST(
|
||||
request: NextRequest,
|
||||
{ params }: { params: { id: string } }
|
||||
{ params }: { params: { id: string } },
|
||||
) {
|
||||
const { id } = params;
|
||||
const { data } = await request.json();
|
||||
const { title, deskripsi, imageId } = data;
|
||||
|
||||
const senderId = await prisma.donasi.findUnique({
|
||||
where: { id: id },
|
||||
select: {
|
||||
authorId: true,
|
||||
},
|
||||
});
|
||||
|
||||
try {
|
||||
if (data && data?.imageId) {
|
||||
const createWithFile = await prisma.donasi_Kabar.create({
|
||||
data: {
|
||||
title: data.title,
|
||||
deskripsi: data.deskripsi,
|
||||
title: title,
|
||||
deskripsi: deskripsi,
|
||||
donasiId: id,
|
||||
imageId: data.imageId,
|
||||
imageId: imageId,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -28,8 +43,8 @@ async function POST(
|
||||
} else {
|
||||
const create = await prisma.donasi_Kabar.create({
|
||||
data: {
|
||||
title: data.title,
|
||||
deskripsi: data.deskripsi,
|
||||
title: title,
|
||||
deskripsi: deskripsi,
|
||||
donasiId: id,
|
||||
},
|
||||
});
|
||||
@@ -38,6 +53,25 @@ async function POST(
|
||||
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({
|
||||
status: 200,
|
||||
success: true,
|
||||
@@ -56,16 +90,21 @@ async function POST(
|
||||
|
||||
async function GET(
|
||||
request: NextRequest,
|
||||
{ params }: { params: { id: string } }
|
||||
{ params }: { params: { id: string } },
|
||||
) {
|
||||
const { id } = params;
|
||||
const { searchParams } = new URL(request.url);
|
||||
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 totalCount = 0; // Untuk menghitung total data
|
||||
|
||||
try {
|
||||
if (category === "get-all") {
|
||||
fixData = await prisma.donasi_Kabar.findMany({
|
||||
const data = await prisma.donasi_Kabar.findMany({
|
||||
orderBy: {
|
||||
updatedAt: "desc",
|
||||
},
|
||||
@@ -73,6 +112,8 @@ async function GET(
|
||||
donasiId: id,
|
||||
active: true,
|
||||
},
|
||||
take: page ? takeData : undefined,
|
||||
skip: page ? skipData : undefined,
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
@@ -80,6 +121,17 @@ async function GET(
|
||||
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") {
|
||||
const data = await prisma.donasi_Kabar.findUnique({
|
||||
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({
|
||||
status: 200,
|
||||
success: true,
|
||||
message: "Berhasil mengambil kabar",
|
||||
data: fixData,
|
||||
pagination: pagination,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("[ERROR GET NEWS]", error);
|
||||
@@ -178,7 +243,7 @@ async function PUT(request: Request, { params }: { params: { id: string } }) {
|
||||
|
||||
async function DELETE(
|
||||
request: Request,
|
||||
{ params }: { params: { id: string } }
|
||||
{ params }: { params: { id: string } },
|
||||
) {
|
||||
const { id } = params;
|
||||
try {
|
||||
@@ -198,7 +263,7 @@ async function DELETE(
|
||||
headers: {
|
||||
Authorization: `Bearer ${process.env.WS_APIKEY}`,
|
||||
},
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
if (!deleteImage) {
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
import { sendNotificationMobileToManyUser } from "@/lib/mobile/notification/send-notification";
|
||||
import prisma from "@/lib/prisma";
|
||||
import _ from "lodash";
|
||||
import { NextResponse } from "next/server";
|
||||
import { NotificationMobileBodyType } from "../../../../../types/type-mobile-notification";
|
||||
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) {
|
||||
const { data } = await request.json();
|
||||
@@ -49,6 +53,26 @@ async function POST(request: Request) {
|
||||
|
||||
console.log("[DATA DONASI]", dataDonasi);
|
||||
|
||||
const adminUsers = await prisma.user.findMany({
|
||||
where: { masterUserRoleId: "2", NOT: { id: data.authorId } },
|
||||
select: { id: true },
|
||||
});
|
||||
|
||||
// SEND NOTIFICATION
|
||||
await sendNotificationMobileToManyUser({
|
||||
recipientIds: adminUsers.map((user) => user.id),
|
||||
senderId: data.authorId,
|
||||
payload: {
|
||||
title: "Pengajuan Review Baru",
|
||||
body: data.title as NotificationMobileBodyType,
|
||||
type: "announcement",
|
||||
deepLink: routeAdminMobile.donationByStatus({ status: "review" }),
|
||||
kategoriApp: "DONASI",
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
|
||||
if (!dataDonasi)
|
||||
return NextResponse.json({
|
||||
status: 400,
|
||||
@@ -98,11 +122,16 @@ async function POST(request: Request) {
|
||||
}
|
||||
|
||||
// GET ALL DATA DONASI
|
||||
export async function GET(request: Request) {
|
||||
async function GET(request: Request) {
|
||||
const { searchParams } = new URL(request.url);
|
||||
const category = searchParams.get("category");
|
||||
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 totalCount = 0; // Untuk menghitung total data
|
||||
|
||||
try {
|
||||
if (category === "beranda") {
|
||||
@@ -114,6 +143,8 @@ export async function GET(request: Request) {
|
||||
donasiMaster_StatusDonasiId: "1",
|
||||
active: true,
|
||||
},
|
||||
take: page ? takeData : undefined,
|
||||
skip: page ? skipData : undefined,
|
||||
select: {
|
||||
id: true,
|
||||
imageId: true,
|
||||
@@ -129,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) => ({
|
||||
..._.omit(v, ["DonasiMaster_Durasi"]),
|
||||
durasiDonasi: v.DonasiMaster_Durasi.name,
|
||||
@@ -141,6 +180,8 @@ export async function GET(request: Request) {
|
||||
where: {
|
||||
authorId: authorId,
|
||||
},
|
||||
take: page ? takeData : undefined,
|
||||
skip: page ? skipData : undefined,
|
||||
select: {
|
||||
id: true,
|
||||
nominal: true,
|
||||
@@ -167,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) => ({
|
||||
..._.omit(v, ["DonasiMaster_StatusInvoice", "Donasi"]),
|
||||
statusInvoice: v.DonasiMaster_StatusInvoice.name,
|
||||
@@ -179,8 +227,21 @@ export async function GET(request: Request) {
|
||||
}));
|
||||
}
|
||||
|
||||
// Hitung total halaman
|
||||
const totalPages = Math.ceil(totalCount / takeData);
|
||||
|
||||
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 }
|
||||
);
|
||||
} catch (error) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import prisma from "@/lib/prisma";
|
||||
import _ from "lodash";
|
||||
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||
|
||||
export { GET, PUT };
|
||||
|
||||
@@ -12,6 +13,11 @@ async function GET(
|
||||
const { id, status } = params;
|
||||
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({
|
||||
orderBy: {
|
||||
updatedAt: "desc",
|
||||
@@ -37,13 +43,35 @@ async function GET(
|
||||
},
|
||||
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(
|
||||
{
|
||||
success: true,
|
||||
message: "Success get event",
|
||||
data: data,
|
||||
pagination: {
|
||||
currentPage: page,
|
||||
totalPages: totalPages,
|
||||
totalData: totalCount,
|
||||
dataPerPage: takeData,
|
||||
},
|
||||
},
|
||||
{ status: 200 }
|
||||
);
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
import { sendNotificationMobileToOneUser } from "@/lib/mobile/notification/send-notification";
|
||||
import prisma from "@/lib/prisma";
|
||||
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 { GET, POST };
|
||||
|
||||
@@ -13,25 +20,35 @@ async function POST(request: Request, { params }: { params: { id: string } }) {
|
||||
eventId: id,
|
||||
userId: userId,
|
||||
},
|
||||
|
||||
// select: {
|
||||
// Event: {
|
||||
// select: {
|
||||
// id: true,
|
||||
// title: true,
|
||||
// authorId: true,
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
});
|
||||
|
||||
const findEvent = await prisma.event.findUnique({
|
||||
where: { id: id },
|
||||
select: { authorId: true, title: true },
|
||||
});
|
||||
|
||||
// SEND NOTIFICATION
|
||||
if (userId !== findEvent?.authorId) {
|
||||
await sendNotificationMobileToOneUser({
|
||||
recipientId: findEvent?.authorId as string,
|
||||
senderId: userId,
|
||||
payload: {
|
||||
title: "Peserta Baru Join" as NotificationMobileTitleType,
|
||||
body: `Ada peserta baru dalam event: ${findEvent?.title}` as NotificationMobileBodyType,
|
||||
type: "announcement",
|
||||
deepLink: routeUserMobile.eventDetailPublised({ id: id }),
|
||||
kategoriApp: "EVENT",
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
return NextResponse.json(
|
||||
{
|
||||
success: true,
|
||||
message: "Success join event",
|
||||
data: createJoin,
|
||||
},
|
||||
{ status: 200 }
|
||||
{ status: 200 },
|
||||
);
|
||||
} catch (error) {
|
||||
return NextResponse.json(
|
||||
@@ -40,7 +57,7 @@ async function POST(request: Request, { params }: { params: { id: string } }) {
|
||||
message: "Error join event",
|
||||
reason: (error as Error).message,
|
||||
},
|
||||
{ status: 500 }
|
||||
{ status: 500 },
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -48,12 +65,17 @@ async function POST(request: Request, { params }: { params: { id: string } }) {
|
||||
async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||
try {
|
||||
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({
|
||||
where: {
|
||||
eventId: id,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
eventId: true,
|
||||
userId: true,
|
||||
isPresent: true,
|
||||
@@ -71,6 +93,8 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||
},
|
||||
},
|
||||
},
|
||||
take: takeData,
|
||||
skip: skipData,
|
||||
});
|
||||
|
||||
return NextResponse.json(
|
||||
@@ -78,8 +102,14 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||
success: true,
|
||||
message: "Success get participants",
|
||||
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) {
|
||||
return NextResponse.json(
|
||||
@@ -88,7 +118,7 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||
message: "Error get participants",
|
||||
reason: (error as Error).message,
|
||||
},
|
||||
{ status: 500 }
|
||||
{ status: 500 },
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import _ from "lodash";
|
||||
import moment from "moment";
|
||||
import { NextResponse } from "next/server";
|
||||
import { NotificationMobileBodyType } from "../../../../../types/type-mobile-notification";
|
||||
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||
|
||||
export { GET, POST };
|
||||
|
||||
@@ -38,6 +39,7 @@ async function POST(request: Request) {
|
||||
select: { id: true },
|
||||
});
|
||||
|
||||
// SEND NOTIFICATION
|
||||
await sendNotificationMobileToManyUser({
|
||||
recipientIds: adminUsers.map((user) => user.id),
|
||||
senderId: data.authorId,
|
||||
@@ -75,11 +77,15 @@ async function GET(request: Request) {
|
||||
const { searchParams } = new URL(request.url);
|
||||
const category = searchParams.get("category");
|
||||
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("[USER]", userId);
|
||||
|
||||
let fixData;
|
||||
let totalCount = 0;
|
||||
|
||||
if (category === "beranda") {
|
||||
const allData = await prisma.event.findMany({
|
||||
@@ -107,84 +113,96 @@ async function GET(request: Request) {
|
||||
}
|
||||
}
|
||||
|
||||
// const takeData = 10;
|
||||
// const skipData = page * takeData - takeData;
|
||||
|
||||
const data = await prisma.event.findMany({
|
||||
// take: takeData,
|
||||
// skip: skipData,
|
||||
orderBy: [
|
||||
{
|
||||
tanggal: "asc",
|
||||
const [data, count] = await Promise.all([
|
||||
prisma.event.findMany({
|
||||
take: takeData,
|
||||
skip: skipData,
|
||||
orderBy: [
|
||||
{
|
||||
tanggal: "asc",
|
||||
},
|
||||
],
|
||||
where: {
|
||||
active: true,
|
||||
eventMaster_StatusId: "1",
|
||||
isArsip: false,
|
||||
},
|
||||
],
|
||||
where: {
|
||||
active: true,
|
||||
eventMaster_StatusId: "1",
|
||||
isArsip: false,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
deskripsi: true,
|
||||
tanggal: true,
|
||||
tanggalSelesai: true,
|
||||
EventMaster_Status: {
|
||||
select: {
|
||||
name: true,
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
deskripsi: true,
|
||||
tanggal: true,
|
||||
tanggalSelesai: true,
|
||||
EventMaster_Status: {
|
||||
select: {
|
||||
name: true,
|
||||
},
|
||||
},
|
||||
authorId: true,
|
||||
Author: {
|
||||
include: {
|
||||
Profile: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
authorId: true,
|
||||
Author: {
|
||||
include: {
|
||||
Profile: true,
|
||||
},
|
||||
}),
|
||||
prisma.event.count({
|
||||
where: {
|
||||
active: true,
|
||||
eventMaster_StatusId: "1",
|
||||
isArsip: false,
|
||||
},
|
||||
},
|
||||
});
|
||||
})
|
||||
]);
|
||||
|
||||
fixData = data;
|
||||
totalCount = count;
|
||||
} else if (category === "contribution") {
|
||||
const data = await prisma.event_Peserta.findMany({
|
||||
where: {
|
||||
userId: userId,
|
||||
},
|
||||
select: {
|
||||
eventId: true,
|
||||
userId: true,
|
||||
Event: {
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
tanggal: true,
|
||||
Author: {
|
||||
select: {
|
||||
id: true,
|
||||
username: true,
|
||||
Profile: {
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
imageId: true,
|
||||
const [data, count] = await Promise.all([
|
||||
prisma.event_Peserta.findMany({
|
||||
take: takeData,
|
||||
skip: skipData,
|
||||
where: {
|
||||
userId: userId,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
eventId: true,
|
||||
userId: true,
|
||||
Event: {
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
tanggal: true,
|
||||
Author: {
|
||||
select: {
|
||||
id: true,
|
||||
username: true,
|
||||
Profile: {
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
imageId: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Event_Peserta: {
|
||||
take: 4,
|
||||
orderBy: {
|
||||
createdAt: "desc",
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
userId: true,
|
||||
User: {
|
||||
select: {
|
||||
Profile: {
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
imageId: true,
|
||||
Event_Peserta: {
|
||||
take: 4,
|
||||
orderBy: {
|
||||
createdAt: "desc",
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
userId: true,
|
||||
User: {
|
||||
select: {
|
||||
Profile: {
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
imageId: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -193,86 +211,109 @@ async function GET(request: Request) {
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
// User: {
|
||||
// select: {
|
||||
// id: true,
|
||||
// username: true,
|
||||
// Profile: {
|
||||
// select: {
|
||||
// id: true,
|
||||
// name: true,
|
||||
// imageId: true,
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
},
|
||||
});
|
||||
}),
|
||||
prisma.event_Peserta.count({
|
||||
where: {
|
||||
userId: userId,
|
||||
},
|
||||
})
|
||||
]);
|
||||
|
||||
fixData = data;
|
||||
totalCount = count;
|
||||
} else if (category === "all-history") {
|
||||
const data = await prisma.event.findMany({
|
||||
orderBy: {
|
||||
tanggal: "desc",
|
||||
},
|
||||
where: {
|
||||
eventMaster_StatusId: "1",
|
||||
isArsip: true,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
tanggal: true,
|
||||
deskripsi: true,
|
||||
active: true,
|
||||
authorId: true,
|
||||
Author: {
|
||||
select: {
|
||||
id: true,
|
||||
username: true,
|
||||
Profile: true,
|
||||
const [data, count] = await Promise.all([
|
||||
prisma.event.findMany({
|
||||
take: takeData,
|
||||
skip: skipData,
|
||||
orderBy: {
|
||||
tanggal: "desc",
|
||||
},
|
||||
where: {
|
||||
eventMaster_StatusId: "1",
|
||||
isArsip: true,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
tanggal: true,
|
||||
deskripsi: true,
|
||||
active: true,
|
||||
authorId: true,
|
||||
Author: {
|
||||
select: {
|
||||
id: true,
|
||||
username: true,
|
||||
Profile: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}),
|
||||
prisma.event.count({
|
||||
where: {
|
||||
eventMaster_StatusId: "1",
|
||||
isArsip: true,
|
||||
},
|
||||
})
|
||||
]);
|
||||
|
||||
fixData = data;
|
||||
totalCount = count;
|
||||
} else if (category === "my-history") {
|
||||
const data = await prisma.event.findMany({
|
||||
orderBy: {
|
||||
tanggal: "desc",
|
||||
},
|
||||
where: {
|
||||
authorId: userId,
|
||||
eventMaster_StatusId: "1",
|
||||
isArsip: true,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
tanggal: true,
|
||||
deskripsi: true,
|
||||
active: true,
|
||||
authorId: true,
|
||||
Author: {
|
||||
select: {
|
||||
id: true,
|
||||
username: true,
|
||||
Profile: true,
|
||||
const [data, count] = await Promise.all([
|
||||
prisma.event.findMany({
|
||||
take: takeData,
|
||||
skip: skipData,
|
||||
orderBy: {
|
||||
tanggal: "desc",
|
||||
},
|
||||
where: {
|
||||
authorId: userId,
|
||||
eventMaster_StatusId: "1",
|
||||
isArsip: true,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
tanggal: true,
|
||||
deskripsi: true,
|
||||
active: true,
|
||||
authorId: true,
|
||||
Author: {
|
||||
select: {
|
||||
id: true,
|
||||
username: true,
|
||||
Profile: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}),
|
||||
prisma.event.count({
|
||||
where: {
|
||||
authorId: userId,
|
||||
eventMaster_StatusId: "1",
|
||||
isArsip: true,
|
||||
},
|
||||
})
|
||||
]);
|
||||
|
||||
fixData = data;
|
||||
totalCount = count;
|
||||
}
|
||||
|
||||
const totalPages = Math.ceil(totalCount / takeData);
|
||||
|
||||
return NextResponse.json(
|
||||
{
|
||||
success: true,
|
||||
message: "Success get event",
|
||||
data: fixData,
|
||||
pagination: {
|
||||
currentPage: page,
|
||||
totalPages: totalPages,
|
||||
totalData: totalCount,
|
||||
dataPerPage: takeData,
|
||||
},
|
||||
},
|
||||
{ status: 200 }
|
||||
);
|
||||
|
||||
@@ -1,11 +1,18 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import prisma from "@/lib/prisma";
|
||||
import { sendNotificationMobileToOneUser } from "@/lib/mobile/notification/send-notification";
|
||||
import {
|
||||
NotificationMobileBodyType,
|
||||
NotificationMobileTitleType,
|
||||
} from "../../../../../../../types/type-mobile-notification";
|
||||
import { routeUserMobile } from "@/lib/mobile/route-page-mobile";
|
||||
|
||||
export { POST, GET, DELETE };
|
||||
|
||||
async function POST(request: Request, { params }: { params: { id: string } }) {
|
||||
const { id } = params;
|
||||
const { data } = await request.json();
|
||||
const { comment, authorId } = data;
|
||||
|
||||
console.log("[ID COMMENT]", id);
|
||||
console.log("[DATA COMMENT]", data);
|
||||
@@ -14,8 +21,8 @@ async function POST(request: Request, { params }: { params: { id: string } }) {
|
||||
const createComment = await prisma.forum_Komentar.create({
|
||||
data: {
|
||||
forum_PostingId: id,
|
||||
komentar: data.comment,
|
||||
authorId: data.authorId,
|
||||
komentar: comment,
|
||||
authorId: authorId,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
@@ -38,6 +45,24 @@ async function POST(request: Request, { params }: { params: { id: string } }) {
|
||||
},
|
||||
});
|
||||
|
||||
const findForum = await prisma.forum_Posting.findUnique({
|
||||
where: { id: id },
|
||||
select: { authorId: true, diskusi: true },
|
||||
});
|
||||
|
||||
// SEND NOTIFICATION
|
||||
await sendNotificationMobileToOneUser({
|
||||
recipientId: findForum?.authorId as string,
|
||||
senderId: authorId,
|
||||
payload: {
|
||||
title: "Komentar Baru" as NotificationMobileTitleType,
|
||||
body: `Ayo cek komentar pada postingan: ${findForum?.diskusi}` as NotificationMobileBodyType,
|
||||
type: "announcement",
|
||||
kategoriApp: "FORUM",
|
||||
deepLink: routeUserMobile.forumDetail({ id: id }),
|
||||
},
|
||||
});
|
||||
|
||||
if (!createComment) {
|
||||
return NextResponse.json({
|
||||
status: 400,
|
||||
@@ -52,7 +77,6 @@ async function POST(request: Request, { params }: { params: { id: string } }) {
|
||||
message: "Berhasil update data",
|
||||
data: createComment,
|
||||
});
|
||||
|
||||
} catch (error) {
|
||||
console.log("[ERROR COMMENT]", error);
|
||||
return NextResponse.json({
|
||||
@@ -66,9 +90,15 @@ async function POST(request: Request, { params }: { params: { id: string } }) {
|
||||
|
||||
async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||
const { id } = params;
|
||||
const { searchParams } = new URL(request.url);
|
||||
const page = Number(searchParams.get("page"));
|
||||
const takeData = 5
|
||||
const skipData = page * takeData - takeData;
|
||||
|
||||
try {
|
||||
const data = await prisma.forum_Komentar.findMany({
|
||||
take: page ? takeData : undefined,
|
||||
skip: page ? skipData : undefined,
|
||||
orderBy: {
|
||||
createdAt: "desc",
|
||||
},
|
||||
@@ -114,7 +144,10 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||
}
|
||||
}
|
||||
|
||||
async function DELETE(request: Request, { params }: { params: { id: string } }) {
|
||||
async function DELETE(
|
||||
request: Request,
|
||||
{ params }: { params: { id: string } }
|
||||
) {
|
||||
const { id } = params;
|
||||
|
||||
try {
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
export async function GET(
|
||||
request: Request,
|
||||
{ params }: { params: { id: string } }
|
||||
) {
|
||||
const { id } = params;
|
||||
|
||||
try {
|
||||
const data = await prisma.forum_Komentar.findUnique({
|
||||
where: {
|
||||
id: id,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
komentar: true,
|
||||
isActive: true,
|
||||
createdAt: true,
|
||||
Forum_ReportKomentar: {
|
||||
select: {
|
||||
deskripsi: true,
|
||||
ForumMaster_KategoriReport: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
return NextResponse.json({
|
||||
status: 200,
|
||||
success: true,
|
||||
data: data,
|
||||
});
|
||||
} catch (error) {
|
||||
console.log("[ERROR]", error);
|
||||
return NextResponse.json({
|
||||
status: 500,
|
||||
success: false,
|
||||
message: "Gagal mendapatkan data posting",
|
||||
reason: (error as Error).message,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
export async function GET(
|
||||
request: Request,
|
||||
{ params }: { params: { id: string } }
|
||||
) {
|
||||
const { id } = params;
|
||||
|
||||
try {
|
||||
const data = await prisma.forum_Posting.findUnique({
|
||||
where: {
|
||||
id: id,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
diskusi: true,
|
||||
isActive: true,
|
||||
createdAt: true,
|
||||
authorId: true,
|
||||
Author: {
|
||||
select: {
|
||||
id: true,
|
||||
username: true,
|
||||
},
|
||||
},
|
||||
Forum_ReportPosting: {
|
||||
select: {
|
||||
deskripsi: true,
|
||||
ForumMaster_KategoriReport: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
return NextResponse.json({
|
||||
status: 200,
|
||||
success: true,
|
||||
data: data,
|
||||
});
|
||||
} catch (error) {
|
||||
console.log("[ERROR]", error);
|
||||
return NextResponse.json({
|
||||
status: 500,
|
||||
success: false,
|
||||
message: "Gagal mendapatkan data posting",
|
||||
reason: (error as Error).message,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,11 @@
|
||||
import { prisma } from "@/lib";
|
||||
import { sendNotificationMobileToManyUser } from "@/lib/mobile/notification/send-notification";
|
||||
import { routeAdminMobile } from "@/lib/mobile/route-page-mobile";
|
||||
import { NextResponse } from "next/server";
|
||||
import {
|
||||
NotificationMobileBodyType,
|
||||
NotificationMobileTitleType,
|
||||
} from "../../../../../../../types/type-mobile-notification";
|
||||
|
||||
export { POST };
|
||||
|
||||
@@ -7,44 +13,70 @@ async function POST(request: Request, { params }: { params: { id: string } }) {
|
||||
let fixData;
|
||||
const { id } = params;
|
||||
const { data } = await request.json();
|
||||
console.log("[DATA]", data);
|
||||
console.log("[ID]", id);
|
||||
const { authorId: reportedUserId, categoryId, description } = data;
|
||||
|
||||
try {
|
||||
const content = await prisma.forum_Komentar.findUnique({
|
||||
where: {
|
||||
id: id,
|
||||
},
|
||||
// Komentar yang di report
|
||||
const findComment = await prisma.forum_Komentar.findUnique({
|
||||
where: { id: id },
|
||||
select: { authorId: true, komentar: true },
|
||||
});
|
||||
|
||||
const reportList = await prisma.forumMaster_KategoriReport.findUnique({
|
||||
// List admin untuk dikirim notifikasi
|
||||
const adminUsers = await prisma.user.findMany({
|
||||
where: {
|
||||
id: data.categoryId,
|
||||
masterUserRoleId: "2",
|
||||
NOT: { id: findComment?.authorId as any },
|
||||
},
|
||||
select: { id: true },
|
||||
});
|
||||
|
||||
const msg = `Report Komentar: "${content?.komentar}" dengan kategori \n\n\n${reportList?.title} : \n\n${reportList?.deskripsi}`;
|
||||
const res = await fetch(
|
||||
`https://cld-dkr-prod-wajs-server.wibudev.com/api/wa/code?nom=6282340374412&text=${msg}`,
|
||||
{ cache: "no-cache" }
|
||||
);
|
||||
|
||||
if (data.categoryId) {
|
||||
fixData = await prisma.forum_ReportKomentar.create({
|
||||
if (categoryId) {
|
||||
const createdReport = await prisma.forum_ReportKomentar.create({
|
||||
data: {
|
||||
forum_KomentarId: id,
|
||||
userId: data.authorId,
|
||||
forumMaster_KategoriReportId: data.categoryId as any,
|
||||
userId: reportedUserId,
|
||||
forumMaster_KategoriReportId: categoryId,
|
||||
},
|
||||
});
|
||||
|
||||
//SEND NOTIFICATION
|
||||
await sendNotificationMobileToManyUser({
|
||||
recipientIds: adminUsers.map((user) => user.id),
|
||||
senderId: reportedUserId,
|
||||
payload: {
|
||||
title: "Laporan Dari User" as NotificationMobileTitleType,
|
||||
body: `Report terhadap komentar, ${findComment?.komentar}` as NotificationMobileBodyType,
|
||||
type: "announcement",
|
||||
kategoriApp: "FORUM",
|
||||
deepLink: routeAdminMobile.forumPreviewReportComment,
|
||||
},
|
||||
});
|
||||
|
||||
fixData = createdReport;
|
||||
} else {
|
||||
fixData = await prisma.forum_ReportKomentar.create({
|
||||
const createdReport = await prisma.forum_ReportKomentar.create({
|
||||
data: {
|
||||
forum_KomentarId: id,
|
||||
userId: data.authorId,
|
||||
deskripsi: data.description,
|
||||
userId: reportedUserId,
|
||||
deskripsi: description,
|
||||
},
|
||||
});
|
||||
|
||||
//SEND NOTIFICATION
|
||||
await sendNotificationMobileToManyUser({
|
||||
recipientIds: adminUsers.map((user) => user.id),
|
||||
senderId: reportedUserId,
|
||||
payload: {
|
||||
title: "Laporan Dari User" as NotificationMobileTitleType,
|
||||
body: `Report terhadap komentar, ${findComment?.komentar}` as NotificationMobileBodyType,
|
||||
type: "announcement",
|
||||
kategoriApp: "FORUM",
|
||||
deepLink: routeAdminMobile.forumPreviewReportComment,
|
||||
},
|
||||
});
|
||||
|
||||
fixData = createdReport;
|
||||
}
|
||||
|
||||
if (!fixData) {
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import {
|
||||
sendNotificationMobileToManyUser
|
||||
} from "@/lib/mobile/notification/send-notification";
|
||||
import {
|
||||
routeAdminMobile
|
||||
} from "@/lib/mobile/route-page-mobile";
|
||||
import prisma from "@/lib/prisma";
|
||||
import { NextResponse } from "next/server";
|
||||
import {
|
||||
NotificationMobileBodyType,
|
||||
NotificationMobileTitleType,
|
||||
} from "../../../../../../../types/type-mobile-notification";
|
||||
|
||||
export { POST };
|
||||
|
||||
@@ -7,38 +17,70 @@ async function POST(request: Request, { params }: { params: { id: string } }) {
|
||||
let fixData;
|
||||
const { id } = params;
|
||||
const { data } = await request.json();
|
||||
console.log("[DATA]", data);
|
||||
console.log("[ID]", id);
|
||||
const { authorId: reportedUserId, categoryId, description } = data;
|
||||
|
||||
try {
|
||||
const content = await prisma.forum_Posting.findUnique({
|
||||
where: {
|
||||
id: id,
|
||||
},
|
||||
// Postingan yang akan di report
|
||||
const findPosting = await prisma.forum_Posting.findUnique({
|
||||
where: { id: id },
|
||||
select: { authorId: true, diskusi: true },
|
||||
});
|
||||
|
||||
const msg = `Report Postingan: "${content?.diskusi}"`;
|
||||
const res = await fetch(
|
||||
`https://cld-dkr-prod-wajs-server.wibudev.com/api/wa/code?nom=6282340374412&text=${msg}`,
|
||||
{ cache: "no-cache" }
|
||||
);
|
||||
// List admin untuk dikirim notifikasi
|
||||
const adminUsers = await prisma.user.findMany({
|
||||
where: {
|
||||
masterUserRoleId: "2",
|
||||
NOT: { id: findPosting?.authorId as any },
|
||||
},
|
||||
select: { id: true },
|
||||
});
|
||||
|
||||
if (data.categoryId) {
|
||||
fixData = await prisma.forum_ReportPosting.create({
|
||||
if (categoryId) {
|
||||
const createReported = await prisma.forum_ReportPosting.create({
|
||||
data: {
|
||||
forum_PostingId: id,
|
||||
userId: data.authorId,
|
||||
forumMaster_KategoriReportId: data.categoryId,
|
||||
userId: reportedUserId,
|
||||
forumMaster_KategoriReportId: categoryId,
|
||||
},
|
||||
});
|
||||
|
||||
//SEND NOTIFICATION
|
||||
await sendNotificationMobileToManyUser({
|
||||
recipientIds: adminUsers.map((user) => user.id),
|
||||
senderId: reportedUserId,
|
||||
payload: {
|
||||
title: "Laporan Dari User" as NotificationMobileTitleType,
|
||||
body: `Report terhadap postingan, ${findPosting?.diskusi}` as NotificationMobileBodyType,
|
||||
type: "announcement",
|
||||
kategoriApp: "FORUM",
|
||||
deepLink: routeAdminMobile.forumPreviewReportPosting,
|
||||
},
|
||||
});
|
||||
|
||||
fixData = createReported;
|
||||
} else {
|
||||
fixData = await prisma.forum_ReportPosting.create({
|
||||
const createReported = await prisma.forum_ReportPosting.create({
|
||||
data: {
|
||||
forum_PostingId: id,
|
||||
userId: data.authorId,
|
||||
deskripsi: data.description,
|
||||
userId: reportedUserId,
|
||||
deskripsi: description,
|
||||
},
|
||||
});
|
||||
|
||||
//SEND NOTIFICATION
|
||||
await sendNotificationMobileToManyUser({
|
||||
recipientIds: adminUsers.map((user) => user.id),
|
||||
senderId: reportedUserId,
|
||||
payload: {
|
||||
title: "Laporan Dari User" as NotificationMobileTitleType,
|
||||
body: `Report terhadap postingan, ${findPosting?.diskusi}` as NotificationMobileBodyType,
|
||||
type: "announcement",
|
||||
kategoriApp: "FORUM",
|
||||
deepLink: routeAdminMobile.forumPreviewReportPosting,
|
||||
},
|
||||
});
|
||||
|
||||
fixData = createReported;
|
||||
}
|
||||
|
||||
if (!fixData) {
|
||||
|
||||
@@ -1,22 +1,54 @@
|
||||
import _ from "lodash";
|
||||
import { NextResponse } from "next/server";
|
||||
import prisma from "@/lib/prisma";
|
||||
import { sendNotificationMobileToManyUser } from "@/lib/mobile/notification/send-notification";
|
||||
import { NotificationMobileBodyType, NotificationMobileTitleType } from "../../../../../types/type-mobile-notification";
|
||||
import { routeUserMobile } from "@/lib/mobile/route-page-mobile";
|
||||
|
||||
export { POST, GET };
|
||||
|
||||
async function POST(request: Request) {
|
||||
const { data } = await request.json();
|
||||
console.log("[DATA]", data);
|
||||
const { diskusi, authorId } = data;
|
||||
|
||||
try {
|
||||
const create = await prisma.forum_Posting.create({
|
||||
data: {
|
||||
diskusi: data.diskusi,
|
||||
authorId: data.authorId,
|
||||
diskusi: diskusi,
|
||||
authorId: authorId,
|
||||
forumMaster_StatusPostingId: 1,
|
||||
},
|
||||
});
|
||||
|
||||
if (!create) {
|
||||
return NextResponse.json({
|
||||
success: false,
|
||||
message: "Gagal memposting",
|
||||
status: 400,
|
||||
});
|
||||
}
|
||||
|
||||
const allUsers = await prisma.user.findMany({
|
||||
where: {
|
||||
id: { not: authorId },
|
||||
},
|
||||
select: { id: true },
|
||||
});
|
||||
|
||||
// SEND NOTIFICATION
|
||||
await sendNotificationMobileToManyUser({
|
||||
recipientIds: allUsers.map((user) => user.id),
|
||||
senderId: authorId,
|
||||
payload: {
|
||||
title: "Ada Diskusi Baru" as NotificationMobileTitleType,
|
||||
body: `${diskusi}` as NotificationMobileBodyType,
|
||||
type: "announcement",
|
||||
kategoriApp: "FORUM",
|
||||
deepLink: routeUserMobile.forumBeranda,
|
||||
},
|
||||
});
|
||||
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
message: "Berhasil membuat postingan",
|
||||
@@ -43,7 +75,6 @@ async function GET(request: Request) {
|
||||
const takeData = 5;
|
||||
const skipData = (Number(page) - 1) * takeData;
|
||||
|
||||
|
||||
// console.log("authorId", authorId);
|
||||
// console.log("userLoginId", userLoginId);
|
||||
// console.log("search", search);
|
||||
@@ -128,13 +159,12 @@ async function GET(request: Request) {
|
||||
|
||||
fixData = newData;
|
||||
} else if (category === "forumku") {
|
||||
|
||||
const count = await prisma.forum_Posting.count({
|
||||
where: {
|
||||
isActive: true,
|
||||
authorId: authorId,
|
||||
},
|
||||
})
|
||||
});
|
||||
|
||||
const data = await prisma.forum_Posting.findMany({
|
||||
take: page ? takeData : undefined,
|
||||
@@ -191,7 +221,7 @@ async function GET(request: Request) {
|
||||
const dataFix = {
|
||||
data: newData,
|
||||
count,
|
||||
}
|
||||
};
|
||||
|
||||
fixData = dataFix;
|
||||
} else {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import _ from "lodash";
|
||||
import { NextResponse } from "next/server";
|
||||
import prisma from "@/lib/prisma";
|
||||
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||
|
||||
export { GET, PUT };
|
||||
|
||||
@@ -9,6 +10,10 @@ async function GET(
|
||||
{ params }: { params: { id: string; status: string } }
|
||||
) {
|
||||
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);
|
||||
|
||||
try {
|
||||
@@ -22,6 +27,8 @@ async function GET(
|
||||
name: fixStatusName,
|
||||
},
|
||||
},
|
||||
take: page ? takeData : undefined,
|
||||
skip: page ? skipData : undefined,
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { prisma } from "@/lib";
|
||||
import { sendNotificationMobileToManyUser } from "@/lib/mobile/notification/send-notification";
|
||||
import {
|
||||
NotificationMobileBodyType,
|
||||
NotificationMobileTitleType,
|
||||
} from "../../../../../../../types/type-mobile-notification";
|
||||
import { routeAdminMobile, routeUserMobile } from "@/lib/mobile/route-page-mobile";
|
||||
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||
|
||||
export { POST, GET, DELETE };
|
||||
|
||||
@@ -10,7 +17,7 @@ async function POST(request: Request, { params }: { params: { id: string } }) {
|
||||
console.log("[POST DOCUMENT DATA]", data);
|
||||
|
||||
try {
|
||||
const create = await prisma.dokumenInvestasi.upsert({
|
||||
const createdDocs = await prisma.dokumenInvestasi.upsert({
|
||||
where: {
|
||||
id: id,
|
||||
},
|
||||
@@ -23,9 +30,49 @@ async function POST(request: Request, { params }: { params: { id: string } }) {
|
||||
title: data.title,
|
||||
fileId: data.fileId,
|
||||
},
|
||||
select: {
|
||||
investasiId: true,
|
||||
investasi: {
|
||||
select: {
|
||||
title: true,
|
||||
authorId: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
if (!create)
|
||||
console.log("[CREATED DOCS]", createdDocs);
|
||||
|
||||
const findInvestor = await prisma.investasi_Invoice.findMany({
|
||||
where: {
|
||||
investasiId: id,
|
||||
StatusInvoice: {
|
||||
name: "Berhasil",
|
||||
},
|
||||
},
|
||||
select: {
|
||||
authorId: true,
|
||||
},
|
||||
});
|
||||
|
||||
console.log("[FIND INVESTOR]", findInvestor);
|
||||
|
||||
// SEND NOTIFICATION
|
||||
await sendNotificationMobileToManyUser({
|
||||
recipientIds: findInvestor.map((e) => e.authorId!),
|
||||
senderId: createdDocs.investasi?.authorId as string,
|
||||
payload: {
|
||||
title: "Cek Dokumen" as NotificationMobileTitleType,
|
||||
body: `Ada dokumen terupdate pada ${createdDocs.investasi?.title}` as NotificationMobileBodyType,
|
||||
type: "announcement",
|
||||
kategoriApp: "INVESTASI",
|
||||
deepLink: routeUserMobile.investmentDetailPublish({
|
||||
id: createdDocs.investasiId as string,
|
||||
}),
|
||||
},
|
||||
});
|
||||
|
||||
if (!createdDocs)
|
||||
return NextResponse.json({
|
||||
status: 201,
|
||||
success: true,
|
||||
@@ -52,6 +99,9 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||
const { id } = params;
|
||||
const { searchParams } = new URL(request.url);
|
||||
const category = searchParams.get("category");
|
||||
const page = Number(searchParams.get("page"));
|
||||
const takeData = PAGINATION_DEFAULT_TAKE
|
||||
const skipData = page * takeData - takeData
|
||||
|
||||
try {
|
||||
let fixData;
|
||||
@@ -71,6 +121,8 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||
investasiId: id,
|
||||
active: true,
|
||||
},
|
||||
take: page ? takeData : undefined,
|
||||
skip: page ? skipData : undefined,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -93,7 +145,7 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||
|
||||
async function DELETE(
|
||||
request: Request,
|
||||
{ params }: { params: { id: string } }
|
||||
{ params }: { params: { id: string } },
|
||||
) {
|
||||
const { id } = params;
|
||||
|
||||
@@ -111,7 +163,7 @@ async function DELETE(
|
||||
headers: {
|
||||
Authorization: `Bearer ${process.env.WS_APIKEY}`,
|
||||
},
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
return NextResponse.json({
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import prisma from "@/lib/prisma";
|
||||
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||
|
||||
export { GET };
|
||||
|
||||
async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||
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 {
|
||||
const data = await prisma.investasi_Invoice.findMany({
|
||||
where: {
|
||||
@@ -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({
|
||||
status: 200,
|
||||
success: true,
|
||||
message: "Berhasil Mendapatkan Data",
|
||||
data: data,
|
||||
meta: {
|
||||
currentPage: page,
|
||||
totalData: totalData,
|
||||
totalPage: totalPages,
|
||||
dataPerPage: takeData,
|
||||
},
|
||||
});
|
||||
} catch (error) {
|
||||
return NextResponse.json({
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
import { prisma } from "@/lib";
|
||||
import { sendNotificationMobileToManyUser } from "@/lib/mobile/notification/send-notification";
|
||||
import { routeAdminMobile } from "@/lib/mobile/route-page-mobile";
|
||||
import _ from "lodash";
|
||||
import { NextResponse } from "next/server";
|
||||
import {
|
||||
NotificationMobileTitleType,
|
||||
NotificationMobileBodyType,
|
||||
} from "../../../../../../../types/type-mobile-notification";
|
||||
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||
|
||||
export { POST, GET, PUT };
|
||||
|
||||
@@ -47,10 +54,12 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||
const { searchParams } = new URL(request.url);
|
||||
const category = searchParams.get("category");
|
||||
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);
|
||||
|
||||
|
||||
let fixData;
|
||||
|
||||
try {
|
||||
@@ -98,6 +107,8 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||
statusInvoiceId: "1",
|
||||
isActive: true,
|
||||
},
|
||||
take: page ? takeData : undefined,
|
||||
skip: page ? skipData : undefined,
|
||||
select: {
|
||||
id: true,
|
||||
nominal: true,
|
||||
@@ -124,6 +135,8 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||
where: {
|
||||
authorId: authorId,
|
||||
},
|
||||
take: page ? takeData : undefined,
|
||||
skip: page ? skipData : undefined,
|
||||
select: {
|
||||
id: true,
|
||||
statusInvoiceId: true,
|
||||
@@ -198,8 +211,49 @@ async function PUT(request: Request, { params }: { params: { id: string } }) {
|
||||
statusInvoiceId: checkStatus.id,
|
||||
imageId: data.imageId,
|
||||
},
|
||||
select: {
|
||||
investasiId: true,
|
||||
},
|
||||
});
|
||||
|
||||
if (fixStatus === "Proses") {
|
||||
// kirim notif ke author investasi
|
||||
const findInvestasi = await prisma.investasi.findUnique({
|
||||
where: {
|
||||
id: update.investasiId as any,
|
||||
},
|
||||
select: {
|
||||
title: true,
|
||||
authorId: true,
|
||||
},
|
||||
});
|
||||
|
||||
const findUsers = await prisma.user.findMany({
|
||||
where: {
|
||||
masterUserRoleId: "2",
|
||||
active: true,
|
||||
NOT: { id: findInvestasi?.authorId as any },
|
||||
},
|
||||
select: { id: true },
|
||||
});
|
||||
|
||||
// SEND NOTIFICATION
|
||||
await sendNotificationMobileToManyUser({
|
||||
recipientIds: findUsers.map((user) => user.id),
|
||||
senderId: data.authorId,
|
||||
payload: {
|
||||
title: "Ada Investor Baru !" as NotificationMobileTitleType,
|
||||
body: `Cek data investor pada ${findInvestasi?.title}` as NotificationMobileBodyType,
|
||||
type: "announcement",
|
||||
kategoriApp: "INVESTASI",
|
||||
deepLink: routeAdminMobile.investmentDetailPublish({
|
||||
id: update.investasiId as string,
|
||||
status: "publish",
|
||||
}),
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
console.log("[UPDATE]", update);
|
||||
|
||||
return NextResponse.json({
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import _ from "lodash";
|
||||
import { prisma } from "@/lib";
|
||||
import { NextResponse } from "next/server";
|
||||
import { sendNotificationInvestmentAddNews } from "@/lib/mobile/notification/notification-add-news-investment";
|
||||
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||
|
||||
export { POST, GET, DELETE };
|
||||
|
||||
@@ -21,6 +23,21 @@ async function POST(request: Request, { params }: { params: { id: string } }) {
|
||||
deskripsi: data.deskripsi,
|
||||
imageId: data.imageId,
|
||||
},
|
||||
select: {
|
||||
investasiId: true,
|
||||
investasi: {
|
||||
select: {
|
||||
title: true,
|
||||
authorId: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
await sendNotificationInvestmentAddNews({
|
||||
invesmentId: createWithFile.investasiId,
|
||||
senderId: createWithFile.investasi.authorId as string,
|
||||
title: createWithFile.investasi.title,
|
||||
});
|
||||
|
||||
fixData = createWithFile;
|
||||
@@ -31,6 +48,21 @@ async function POST(request: Request, { params }: { params: { id: string } }) {
|
||||
title: _.startCase(data.title),
|
||||
deskripsi: data.deskripsi,
|
||||
},
|
||||
select: {
|
||||
investasiId: true,
|
||||
investasi: {
|
||||
select: {
|
||||
title: true,
|
||||
authorId: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
await sendNotificationInvestmentAddNews({
|
||||
invesmentId: createWitOutFile.investasiId,
|
||||
senderId: createWitOutFile.investasi.authorId as string,
|
||||
title: createWitOutFile.investasi.title,
|
||||
});
|
||||
|
||||
fixData = createWitOutFile;
|
||||
@@ -57,8 +89,13 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||
console.log("id", id);
|
||||
const { searchParams } = new URL(request.url);
|
||||
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 meta = null;
|
||||
|
||||
try {
|
||||
if (category === "one-news") {
|
||||
const data = await prisma.beritaInvestasi.findFirst({
|
||||
@@ -82,7 +119,7 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||
|
||||
fixData = newData;
|
||||
} else if (category === "all-news") {
|
||||
fixData = await prisma.beritaInvestasi.findMany({
|
||||
const newsData = await prisma.beritaInvestasi.findMany({
|
||||
orderBy: {
|
||||
updatedAt: "desc",
|
||||
},
|
||||
@@ -90,7 +127,27 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||
investasiId: id,
|
||||
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({
|
||||
@@ -98,6 +155,7 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||
success: true,
|
||||
message: "Berita berhasil diambil",
|
||||
data: fixData,
|
||||
...(meta && { meta }),
|
||||
});
|
||||
} catch (error) {
|
||||
console.log("[ERROR]", error);
|
||||
@@ -111,7 +169,7 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||
|
||||
async function DELETE(
|
||||
request: Request,
|
||||
{ params }: { params: { id: string } }
|
||||
{ params }: { params: { id: string } },
|
||||
) {
|
||||
const { id } = params;
|
||||
console.log("id", id);
|
||||
|
||||
@@ -2,6 +2,10 @@ import _ from "lodash";
|
||||
import { NextResponse } from "next/server";
|
||||
import prisma from "@/lib/prisma";
|
||||
import moment from "moment";
|
||||
import { sendNotificationMobileToManyUser } from "@/lib/mobile/notification/send-notification";
|
||||
import { NotificationMobileBodyType } from "../../../../../types/type-mobile-notification";
|
||||
import { routeAdminMobile } from "@/lib/mobile/route-page-mobile";
|
||||
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||
|
||||
export { POST, GET };
|
||||
|
||||
@@ -9,12 +13,14 @@ async function POST(request: Request) {
|
||||
const { data } = await request.json();
|
||||
console.log(["DATA INVESTASI"], data);
|
||||
|
||||
const fixTitle = _.startCase(data.title)
|
||||
|
||||
try {
|
||||
const create = await prisma.investasi.create({
|
||||
data: {
|
||||
masterStatusInvestasiId: "2",
|
||||
authorId: data.authorId,
|
||||
title: _.startCase(data.title),
|
||||
title: fixTitle,
|
||||
targetDana: data.targetDana,
|
||||
hargaLembar: data.hargaLembar,
|
||||
totalLembar: data.totalLembar,
|
||||
@@ -30,6 +36,24 @@ async function POST(request: Request) {
|
||||
|
||||
console.log("[CREATE INVESTASI]", create);
|
||||
|
||||
const adminUsers = await prisma.user.findMany({
|
||||
where: { masterUserRoleId: "2", NOT: { id: data.authorId } },
|
||||
select: { id: true },
|
||||
});
|
||||
|
||||
// SEND NOTIFICATION
|
||||
await sendNotificationMobileToManyUser({
|
||||
recipientIds: adminUsers.map((user) => user.id),
|
||||
senderId: data.authorId,
|
||||
payload: {
|
||||
title: "Pengajuan Review Baru",
|
||||
body: fixTitle as NotificationMobileBodyType,
|
||||
type: "announcement",
|
||||
deepLink: routeAdminMobile.investmentByStatus({ status: "review" }),
|
||||
kategoriApp: "INVESTASI",
|
||||
},
|
||||
});
|
||||
|
||||
return NextResponse.json({
|
||||
status: 201,
|
||||
success: true,
|
||||
@@ -50,6 +74,9 @@ async function GET(request: Request) {
|
||||
const { searchParams } = new URL(request.url);
|
||||
const category = searchParams.get("category");
|
||||
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("[AUTHOR ID]", authorId);
|
||||
@@ -109,6 +136,8 @@ async function GET(request: Request) {
|
||||
where: {
|
||||
masterStatusInvestasiId: "1",
|
||||
},
|
||||
take: page ? takeData : undefined,
|
||||
skip: page ? skipData : undefined,
|
||||
select: {
|
||||
id: true,
|
||||
imageId: true,
|
||||
@@ -133,6 +162,8 @@ async function GET(request: Request) {
|
||||
authorId: authorId,
|
||||
statusInvoiceId: "1",
|
||||
},
|
||||
take: page ? takeData : undefined,
|
||||
skip: page ? skipData : undefined,
|
||||
select: {
|
||||
id: true,
|
||||
investasiId: true,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||
import prisma from "@/lib/prisma";
|
||||
import _ from "lodash";
|
||||
import { NextResponse } from "next/server";
|
||||
@@ -12,6 +13,11 @@ async function GET(
|
||||
const { id, status } = params;
|
||||
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({
|
||||
orderBy: {
|
||||
updatedAt: "desc",
|
||||
@@ -28,13 +34,20 @@ async function GET(
|
||||
id: true,
|
||||
title: true,
|
||||
},
|
||||
take: takeData,
|
||||
skip: skipData,
|
||||
});
|
||||
|
||||
|
||||
return NextResponse.json(
|
||||
{
|
||||
success: true,
|
||||
message: "Success get job",
|
||||
data: data,
|
||||
pagination: {
|
||||
currentPage: page,
|
||||
dataPerPage: takeData,
|
||||
},
|
||||
},
|
||||
{ status: 200 }
|
||||
);
|
||||
|
||||
@@ -3,6 +3,7 @@ import { routeAdminMobile } from "@/lib/mobile/route-page-mobile";
|
||||
import prisma from "@/lib/prisma";
|
||||
import { NextResponse } from "next/server";
|
||||
import { NotificationMobileBodyType } from "../../../../../types/type-mobile-notification";
|
||||
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||
|
||||
export { POST, GET };
|
||||
|
||||
@@ -45,7 +46,7 @@ async function POST(request: Request) {
|
||||
message: "Berhasil disimpan",
|
||||
data: create,
|
||||
},
|
||||
{ status: 201 }
|
||||
{ status: 201 },
|
||||
);
|
||||
} catch (error) {
|
||||
return NextResponse.json(
|
||||
@@ -54,7 +55,7 @@ async function POST(request: Request) {
|
||||
message: "Error create job",
|
||||
reason: (error as Error).message,
|
||||
},
|
||||
{ status: 500 }
|
||||
{ status: 500 },
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -64,94 +65,129 @@ async function GET(request: Request) {
|
||||
const search = searchParams.get("search");
|
||||
const category = searchParams.get("category");
|
||||
const authorId = searchParams.get("authorId");
|
||||
|
||||
const page = Number(searchParams.get("page")) || 1;
|
||||
const takeData = PAGINATION_DEFAULT_TAKE;
|
||||
const skipData = page * takeData - takeData;
|
||||
let fixData;
|
||||
|
||||
try {
|
||||
if (category === "archive") {
|
||||
const data = await prisma.job.findMany({
|
||||
where: {
|
||||
authorId: authorId,
|
||||
isActive: true,
|
||||
isArsip: true,
|
||||
MasterStatus: {
|
||||
name: "Publish",
|
||||
},
|
||||
// title: {
|
||||
// contains: search || "",
|
||||
// mode: "insensitive",
|
||||
// },
|
||||
},
|
||||
orderBy: {
|
||||
createdAt: "desc",
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
deskripsi: true,
|
||||
authorId: true,
|
||||
MasterStatus: {
|
||||
select: {
|
||||
name: true,
|
||||
const [data, count] = await Promise.all([
|
||||
prisma.job.findMany({
|
||||
where: {
|
||||
authorId: authorId,
|
||||
isActive: true,
|
||||
isArsip: true,
|
||||
MasterStatus: {
|
||||
name: "Publish",
|
||||
},
|
||||
// title: {
|
||||
// contains: search || "",
|
||||
// mode: "insensitive",
|
||||
// },
|
||||
},
|
||||
Author: {
|
||||
select: {
|
||||
id: true,
|
||||
username: true,
|
||||
Profile: {
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
imageId: true,
|
||||
orderBy: {
|
||||
createdAt: "desc",
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
deskripsi: true,
|
||||
authorId: 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;
|
||||
} else if (category === "beranda") {
|
||||
const data = await prisma.job.findMany({
|
||||
where: {
|
||||
isActive: true,
|
||||
isArsip: false,
|
||||
MasterStatus: {
|
||||
name: "Publish",
|
||||
},
|
||||
title: {
|
||||
contains: search || "",
|
||||
mode: "insensitive",
|
||||
},
|
||||
},
|
||||
orderBy: {
|
||||
createdAt: "desc",
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
deskripsi: true,
|
||||
authorId: true,
|
||||
MasterStatus: {
|
||||
select: {
|
||||
name: true,
|
||||
const [data, count] = await Promise.all([
|
||||
prisma.job.findMany({
|
||||
where: {
|
||||
isActive: true,
|
||||
isArsip: false,
|
||||
MasterStatus: {
|
||||
name: "Publish",
|
||||
},
|
||||
title: {
|
||||
contains: search || "",
|
||||
mode: "insensitive",
|
||||
},
|
||||
},
|
||||
Author: {
|
||||
select: {
|
||||
id: true,
|
||||
username: true,
|
||||
Profile: {
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
imageId: true,
|
||||
orderBy: {
|
||||
createdAt: "desc",
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
deskripsi: true,
|
||||
authorId: 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;
|
||||
}
|
||||
@@ -161,8 +197,12 @@ async function GET(request: Request) {
|
||||
success: true,
|
||||
message: "Success get data job-vacancy",
|
||||
data: fixData,
|
||||
pagination: {
|
||||
currentPage: page,
|
||||
dataPerPage: takeData,
|
||||
},
|
||||
},
|
||||
{ status: 200 }
|
||||
{ status: 200 },
|
||||
);
|
||||
} catch (error) {
|
||||
return NextResponse.json(
|
||||
@@ -171,7 +211,7 @@ async function GET(request: Request) {
|
||||
message: "Error get data job-vacancy",
|
||||
reason: (error as Error).message,
|
||||
},
|
||||
{ status: 500 }
|
||||
{ status: 500 },
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,17 +6,25 @@ import { adminMessaging } from "@/lib/firebase-admin";
|
||||
|
||||
export async function GET(
|
||||
request: NextRequest,
|
||||
{ params }: { params: { id: string } }
|
||||
{ params }: { params: { id: string } },
|
||||
) {
|
||||
const { id } = params;
|
||||
console.log("ID", id);
|
||||
const { searchParams } = new URL(request.url);
|
||||
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;
|
||||
const fixCategory = _.upperCase(category || "");
|
||||
|
||||
try {
|
||||
const data = await prisma.notifikasi.findMany({
|
||||
take: page ? takeData : undefined,
|
||||
skip: page ? skipData : undefined,
|
||||
orderBy: {
|
||||
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;
|
||||
|
||||
return NextResponse.json({
|
||||
const response = {
|
||||
success: true,
|
||||
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) {
|
||||
return NextResponse.json(
|
||||
{ error: (error as Error).message },
|
||||
{ status: 500 }
|
||||
{ status: 500 },
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export async function PUT(
|
||||
request: NextRequest,
|
||||
{ params }: { params: { id: string } }
|
||||
{ params }: { params: { id: string } },
|
||||
) {
|
||||
const { id } = params;
|
||||
const { searchParams } = new URL(request.url);
|
||||
@@ -79,7 +115,7 @@ export async function PUT(
|
||||
console.error("Error marking notifications as read:", error);
|
||||
return NextResponse.json(
|
||||
{ error: (error as Error).message },
|
||||
{ status: 500 }
|
||||
{ status: 500 },
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,8 +7,13 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||
try {
|
||||
const { searchParams } = new URL(request.url);
|
||||
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({
|
||||
skip,
|
||||
take,
|
||||
orderBy: {
|
||||
createdAt: "desc",
|
||||
},
|
||||
@@ -18,22 +23,30 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||
},
|
||||
});
|
||||
|
||||
if (!data)
|
||||
return NextResponse.json(
|
||||
{
|
||||
success: false,
|
||||
message: "Data tidak ditemukan",
|
||||
},
|
||||
{ status: 404 }
|
||||
);
|
||||
// Hitung total data untuk informasi pagination
|
||||
const total = await prisma.portofolio.count({
|
||||
where: {
|
||||
profileId: id,
|
||||
active: true,
|
||||
},
|
||||
});
|
||||
|
||||
const totalPages = Math.ceil(total / take);
|
||||
|
||||
return NextResponse.json(
|
||||
{
|
||||
success: true,
|
||||
message: "Berhasil mendapatkan data",
|
||||
data: data,
|
||||
meta: {
|
||||
page,
|
||||
take,
|
||||
skip,
|
||||
total,
|
||||
totalPages,
|
||||
},
|
||||
},
|
||||
{ status: 200 }
|
||||
{ status: 200 },
|
||||
);
|
||||
} catch (error) {
|
||||
return NextResponse.json(
|
||||
@@ -42,7 +55,7 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||
message: "API Error Get Data Potofolio",
|
||||
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) {
|
||||
const createSubBidang =
|
||||
await prisma.portofolio_BidangDanSubBidangBisnis.create({
|
||||
@@ -84,7 +100,7 @@ async function POST(request: Request) {
|
||||
success: false,
|
||||
message: "Gagal membuat sub bidang bisnis",
|
||||
},
|
||||
{ status: 400 }
|
||||
{ status: 400 },
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -95,7 +111,7 @@ async function POST(request: Request) {
|
||||
success: false,
|
||||
message: "Gagal membuat portofolio",
|
||||
},
|
||||
{ status: 400 }
|
||||
{ status: 400 },
|
||||
);
|
||||
|
||||
const createMedsos = await prisma.portofolio_MediaSosial.create({
|
||||
@@ -115,7 +131,7 @@ async function POST(request: Request) {
|
||||
success: false,
|
||||
message: "Gagal menambahkan medsos",
|
||||
},
|
||||
{ status: 400 }
|
||||
{ status: 400 },
|
||||
);
|
||||
|
||||
return NextResponse.json(
|
||||
@@ -124,7 +140,7 @@ async function POST(request: Request) {
|
||||
message: "Berhasil mendapatkan data",
|
||||
data: createPortofolio,
|
||||
},
|
||||
{ status: 200 }
|
||||
{ status: 200 },
|
||||
);
|
||||
} catch (error) {
|
||||
return NextResponse.json(
|
||||
@@ -133,7 +149,7 @@ async function POST(request: Request) {
|
||||
message: "API Error Post Data",
|
||||
reason: (error as Error).message,
|
||||
},
|
||||
{ status: 500 }
|
||||
{ status: 500 },
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,8 +5,16 @@ export async function GET(request: Request) {
|
||||
try {
|
||||
const { searchParams } = new URL(request.url);
|
||||
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({
|
||||
take: page ? takeData : undefined,
|
||||
skip: page ? skipData : undefined,
|
||||
orderBy: {
|
||||
username: "asc",
|
||||
},
|
||||
@@ -43,16 +51,12 @@ export async function GET(request: Request) {
|
||||
},
|
||||
});
|
||||
|
||||
return NextResponse.json(
|
||||
{
|
||||
success: true,
|
||||
message: "Berhasil mendapatkan data",
|
||||
data: data,
|
||||
},
|
||||
{
|
||||
status: 200,
|
||||
}
|
||||
);
|
||||
return NextResponse.json({
|
||||
status: 200,
|
||||
success: true,
|
||||
message: "Berhasil mendapatkan data",
|
||||
data: data,
|
||||
});
|
||||
} catch (error) {
|
||||
return NextResponse.json(
|
||||
{
|
||||
@@ -62,7 +66,7 @@ export async function GET(request: Request) {
|
||||
},
|
||||
{
|
||||
status: 500,
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import _ from "lodash";
|
||||
import { NextResponse } from "next/server";
|
||||
import prisma from "@/lib/prisma";
|
||||
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||
|
||||
export { GET, PUT };
|
||||
|
||||
@@ -10,14 +11,33 @@ async function GET(
|
||||
) {
|
||||
try {
|
||||
const { id, status } = params;
|
||||
console.log("[ID]", id);
|
||||
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") {
|
||||
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: {
|
||||
authorId: id,
|
||||
isActive: true,
|
||||
@@ -30,7 +50,18 @@ async function GET(
|
||||
},
|
||||
});
|
||||
} 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: {
|
||||
authorId: id,
|
||||
Voting_Status: {
|
||||
@@ -40,10 +71,18 @@ async function GET(
|
||||
});
|
||||
}
|
||||
|
||||
const totalPages = Math.ceil(totalCount / takeData);
|
||||
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
message: "Success get voting",
|
||||
data: fixData,
|
||||
data: data,
|
||||
pagination: {
|
||||
currentPage: page,
|
||||
totalPages: totalPages,
|
||||
totalData: totalCount,
|
||||
dataPerPage: takeData,
|
||||
},
|
||||
});
|
||||
} catch (error) {
|
||||
console.log("[ERROR]", error);
|
||||
@@ -61,9 +100,7 @@ async function PUT(
|
||||
) {
|
||||
try {
|
||||
const { id, status } = params;
|
||||
console.log("[ID]", id);
|
||||
const fixStatusName = _.startCase(status);
|
||||
console.log("[STATUS]", fixStatusName);
|
||||
|
||||
const checkData = await prisma.voting.findFirst({
|
||||
where: {
|
||||
@@ -79,8 +116,6 @@ async function PUT(
|
||||
},
|
||||
});
|
||||
|
||||
console.log("[CHECKDATA]", checkData);
|
||||
|
||||
if (!checkData)
|
||||
return NextResponse.json({
|
||||
success: false,
|
||||
@@ -115,8 +150,6 @@ async function PUT(
|
||||
},
|
||||
});
|
||||
|
||||
console.log("[UPDATE]", updateData);
|
||||
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
message: "Success update voting",
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import prisma from "@/lib/prisma";
|
||||
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||
|
||||
export { GET };
|
||||
|
||||
@@ -8,10 +9,9 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||
const { searchParams } = new URL(request.url);
|
||||
const authorId = searchParams.get("authorId");
|
||||
const category = searchParams.get("category");
|
||||
|
||||
console.log("[ID]", id);
|
||||
console.log("[AUTHOR ID]", authorId);
|
||||
console.log("[CATEGORY]", category);
|
||||
const page = Number(searchParams.get("page"));
|
||||
const takeData = PAGINATION_DEFAULT_TAKE;
|
||||
const skipData = page ? page * takeData - takeData : 0;
|
||||
|
||||
let fixData;
|
||||
|
||||
@@ -53,7 +53,10 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||
where: {
|
||||
votingId: id,
|
||||
},
|
||||
take: page ? takeData : undefined,
|
||||
skip: page ? skipData : undefined,
|
||||
select: {
|
||||
id: true,
|
||||
Voting_DaftarNamaVote: {
|
||||
select: {
|
||||
value: true,
|
||||
@@ -75,8 +78,6 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||
},
|
||||
});
|
||||
|
||||
console.log("[LIST KONTRIBUTOR]", listKontributor);
|
||||
|
||||
fixData = listKontributor;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import prisma from "@/lib/prisma";
|
||||
import _ from "lodash";
|
||||
import { sendNotificationMobileToOneUser } from "@/lib/mobile/notification/send-notification";
|
||||
import {
|
||||
NotificationMobileBodyType,
|
||||
NotificationMobileTitleType,
|
||||
} from "../../../../../../types/type-mobile-notification";
|
||||
import { routeUserMobile } from "@/lib/mobile/route-page-mobile";
|
||||
|
||||
export { GET, DELETE, PUT, POST };
|
||||
|
||||
@@ -39,7 +45,6 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||
const listNamaVote = data?.Voting_DaftarNamaVote || [];
|
||||
|
||||
for (let v of listNamaVote) {
|
||||
|
||||
const kontributor = await prisma.voting_Kontributor.findMany({
|
||||
where: {
|
||||
voting_DaftarNamaVoteId: v.id,
|
||||
@@ -90,7 +95,6 @@ async function DELETE(
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
message: "Berhasil menghapus data",
|
||||
@@ -171,7 +175,6 @@ async function PUT(request: Request, { params }: { params: { id: string } }) {
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
if (!updateVoting)
|
||||
return NextResponse.json({ status: 400, message: "Gagal Update" });
|
||||
}
|
||||
@@ -193,11 +196,12 @@ async function PUT(request: Request, { params }: { params: { id: string } }) {
|
||||
async function POST(request: Request, { params }: { params: { id: string } }) {
|
||||
const { id } = params;
|
||||
const { data } = await request.json();
|
||||
const { chooseId, userId } = data;
|
||||
|
||||
try {
|
||||
const findData = await prisma.voting_DaftarNamaVote.findFirst({
|
||||
const findDatapilihan = await prisma.voting_DaftarNamaVote.findFirst({
|
||||
where: {
|
||||
id: data.chooseId,
|
||||
id: chooseId,
|
||||
},
|
||||
select: {
|
||||
jumlah: true,
|
||||
@@ -205,28 +209,32 @@ async function POST(request: Request, { params }: { params: { id: string } }) {
|
||||
},
|
||||
});
|
||||
|
||||
if (!findData)
|
||||
if (!findDatapilihan)
|
||||
return NextResponse.json({
|
||||
success: false,
|
||||
message: "Data tidak ditemukan",
|
||||
});
|
||||
|
||||
const updateData = await prisma.voting_DaftarNamaVote.update({
|
||||
const updateDataPilihan = await prisma.voting_DaftarNamaVote.update({
|
||||
where: {
|
||||
id: data.chooseId,
|
||||
},
|
||||
data: {
|
||||
jumlah: findData.jumlah + 1,
|
||||
jumlah: findDatapilihan.jumlah + 1,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
if (!updateData)
|
||||
if (!updateDataPilihan)
|
||||
return NextResponse.json({
|
||||
success: false,
|
||||
message: "Gagal Update Data",
|
||||
});
|
||||
|
||||
const findVotingData = await prisma.voting.findUnique({
|
||||
where: { id: id },
|
||||
select: { authorId: true, title: true },
|
||||
});
|
||||
|
||||
const createKontributor = await prisma.voting_Kontributor.create({
|
||||
data: {
|
||||
votingId: id,
|
||||
@@ -250,6 +258,21 @@ async function POST(request: Request, { params }: { params: { id: string } }) {
|
||||
message: "Gagal Menjadi Kontributor",
|
||||
});
|
||||
|
||||
// SEND NOTIFICATION
|
||||
if (userId !== findVotingData?.authorId) {
|
||||
await sendNotificationMobileToOneUser({
|
||||
recipientId: findVotingData?.authorId as string,
|
||||
senderId: userId,
|
||||
payload: {
|
||||
title: "User Melakukan Vote" as NotificationMobileTitleType,
|
||||
body: `Salah satu user telah melakukan voting pada: ${findVotingData?.title}` as NotificationMobileBodyType,
|
||||
type: "announcement",
|
||||
deepLink: routeUserMobile.votingDetailPublised({ id: id }),
|
||||
kategoriApp: "VOTING",
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
message: "Berhasil Voting",
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import prisma from "@/lib/prisma";
|
||||
import _ from "lodash";
|
||||
import { sendNotificationMobileToManyUser } from "@/lib/mobile/notification/send-notification";
|
||||
import { NotificationMobileBodyType } from "../../../../../types/type-mobile-notification";
|
||||
import { routeAdminMobile } from "@/lib/mobile/route-page-mobile";
|
||||
import { PAGINATION_DEFAULT_TAKE } from "@/lib/constans-value/constansValue";
|
||||
|
||||
export { POST, GET };
|
||||
|
||||
@@ -41,6 +45,24 @@ async function POST(request: Request) {
|
||||
});
|
||||
}
|
||||
|
||||
const adminUsers = await prisma.user.findMany({
|
||||
where: { masterUserRoleId: "2", NOT: { id: data.authorId } },
|
||||
select: { id: true },
|
||||
});
|
||||
|
||||
// SEND NOTIFICATION
|
||||
await sendNotificationMobileToManyUser({
|
||||
recipientIds: adminUsers.map((user) => user.id),
|
||||
senderId: data.authorId,
|
||||
payload: {
|
||||
title: "Pengajuan Review Baru",
|
||||
body: create.title as NotificationMobileBodyType,
|
||||
type: "announcement",
|
||||
deepLink: routeAdminMobile.votingByStatus({ status: "review" }),
|
||||
kategoriApp: "VOTING",
|
||||
},
|
||||
});
|
||||
|
||||
return NextResponse.json(
|
||||
{
|
||||
success: true,
|
||||
@@ -66,8 +88,9 @@ async function GET(request: Request) {
|
||||
const category = searchParams.get("category");
|
||||
const authorId = searchParams.get("authorId");
|
||||
const userLoginId = searchParams.get("userLoginId");
|
||||
|
||||
console.log("userLoginId >>", userLoginId);
|
||||
const page = Number(searchParams.get("page"));
|
||||
const takeData = PAGINATION_DEFAULT_TAKE;
|
||||
const skipData = page * takeData - takeData;
|
||||
|
||||
let fixData;
|
||||
|
||||
@@ -102,6 +125,8 @@ async function GET(request: Request) {
|
||||
},
|
||||
},
|
||||
},
|
||||
take: page ? takeData : undefined,
|
||||
skip: page ? skipData : undefined,
|
||||
include: {
|
||||
Voting_DaftarNamaVote: {
|
||||
orderBy: {
|
||||
@@ -125,8 +150,6 @@ async function GET(request: Request) {
|
||||
});
|
||||
|
||||
fixData = data;
|
||||
|
||||
|
||||
} else if (category === "contribution") {
|
||||
const data = await prisma.voting_Kontributor.findMany({
|
||||
orderBy: {
|
||||
@@ -135,6 +158,8 @@ async function GET(request: Request) {
|
||||
where: {
|
||||
authorId: authorId,
|
||||
},
|
||||
take: page ? takeData : undefined,
|
||||
skip: page ? skipData : undefined,
|
||||
include: {
|
||||
Voting: {
|
||||
select: {
|
||||
@@ -192,6 +217,8 @@ async function GET(request: Request) {
|
||||
mode: "insensitive",
|
||||
},
|
||||
},
|
||||
take: page ? takeData : undefined,
|
||||
skip: page ? skipData : undefined,
|
||||
include: {
|
||||
Voting_DaftarNamaVote: {
|
||||
orderBy: {
|
||||
@@ -230,6 +257,8 @@ async function GET(request: Request) {
|
||||
mode: "insensitive",
|
||||
},
|
||||
},
|
||||
take: page ? takeData : undefined,
|
||||
skip: page ? skipData : undefined,
|
||||
include: {
|
||||
Voting_DaftarNamaVote: {
|
||||
orderBy: {
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
[
|
||||
{
|
||||
"name": "default_user",
|
||||
"name": "demo_user",
|
||||
"nomor": "6282340374412",
|
||||
"masterUserRoleId": "1",
|
||||
"active": true,
|
||||
"termsOfServiceAccepted": false
|
||||
},
|
||||
{
|
||||
"name": "admin_911",
|
||||
"name": "demo_admin",
|
||||
"nomor": "6281339158911",
|
||||
"masterUserRoleId": "3",
|
||||
"active": true,
|
||||
|
||||
31
src/lib/code-otp-sender.ts
Normal file
31
src/lib/code-otp-sender.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
const sendCodeOtp = async ({
|
||||
nomor,
|
||||
codeOtp,
|
||||
newMessage,
|
||||
}: {
|
||||
nomor: string;
|
||||
codeOtp?: string;
|
||||
newMessage?: string;
|
||||
}) => {
|
||||
const msg = newMessage || `HIPMI - Kode ini bersifat RAHASIA dan JANGAN DI BAGIKAN KEPADA SIAPAPUN, termasuk anggota ataupun pengurus HIPMI lainnya.\n\n>> Kode OTP anda: ${codeOtp}.`;
|
||||
const enCode = encodeURIComponent(msg);
|
||||
const res = await fetch(
|
||||
`https://cld-dkr-prod-wajs-server.wibudev.com/api/wa/code?nom=${nomor}&text=${enCode}`,
|
||||
{
|
||||
cache: "no-cache",
|
||||
headers: {
|
||||
Authorization: `Bearer ${process.env.WA_SERVER_TOKEN}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
// const res = await fetch(
|
||||
// `https://wa.wibudev.com/code?nom=${nomor}&text=HIPMI - Kode ini bersifat RAHASIA dan JANGAN DI BAGIKAN KEPADA SIAPAPUN, termasuk anggota ataupun pengurus HIPMI lainnya.
|
||||
// \n
|
||||
// >> Kode OTP anda: ${codeOtp}.
|
||||
// `,
|
||||
// );
|
||||
|
||||
return res;
|
||||
};
|
||||
|
||||
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;
|
||||
};
|
||||
@@ -0,0 +1,46 @@
|
||||
import {
|
||||
NotificationMobileBodyType,
|
||||
NotificationMobileTitleType,
|
||||
} from "../../../../types/type-mobile-notification";
|
||||
import { sendNotificationMobileToManyUser } from "./send-notification";
|
||||
import { routeUserMobile } from "../route-page-mobile";
|
||||
import prisma from "@/lib/prisma";
|
||||
|
||||
export const sendNotificationInvestmentAddNews = async ({
|
||||
invesmentId,
|
||||
senderId,
|
||||
title,
|
||||
}: {
|
||||
invesmentId: string;
|
||||
senderId: string;
|
||||
title: string;
|
||||
}) => {
|
||||
const findInvestor = await prisma.investasi_Invoice.findMany({
|
||||
where: {
|
||||
investasiId: invesmentId,
|
||||
StatusInvoice: {
|
||||
name: "Berhasil",
|
||||
},
|
||||
},
|
||||
select: {
|
||||
authorId: true,
|
||||
},
|
||||
});
|
||||
|
||||
console.log("[FIND INVESTOR]", findInvestor);
|
||||
|
||||
// SEND NOTIFICATION
|
||||
await sendNotificationMobileToManyUser({
|
||||
recipientIds: findInvestor.map((e) => e.authorId!),
|
||||
senderId: senderId,
|
||||
payload: {
|
||||
title: "Berita terbaru" as NotificationMobileTitleType,
|
||||
body: `Ada berita yang terupdate pada ${title}` as NotificationMobileBodyType,
|
||||
type: "announcement",
|
||||
kategoriApp: "INVESTASI",
|
||||
deepLink: routeUserMobile.investmentDetailPublish({
|
||||
id: invesmentId,
|
||||
}),
|
||||
},
|
||||
});
|
||||
};
|
||||
@@ -5,16 +5,43 @@ type StatusApp = "review" | "draft" | "reject" | "publish";
|
||||
const routeAdminMobile = {
|
||||
userAccess: ({ id }: { id: string }) => `/admin/user-access/${id}`,
|
||||
// JOB
|
||||
jobDetail: ({ id, status }: { id: string; status: StatusApp }) =>
|
||||
`/admin/job/${id}/${status}`,
|
||||
jobByStatus: ({ status }: { status: StatusApp }) =>
|
||||
`/admin/job/${status}/status`,
|
||||
|
||||
// EVENT
|
||||
eventByStatus: ({ status }: { status: StatusApp }) =>
|
||||
`/admin/event/${status}/status`,
|
||||
|
||||
// VOTING
|
||||
votingByStatus: ({ status }: { status: StatusApp }) =>
|
||||
`/admin/voting/${status}/status`,
|
||||
|
||||
// FORUM
|
||||
forumPreviewReportPosting: `/admin/forum/report-posting`,
|
||||
forumPreviewReportComment: `/admin/forum/report-comment`,
|
||||
|
||||
// INVESTMENT
|
||||
investmentByStatus: ({ status }: { status: StatusApp }) => `/admin/investment/${status}/status`,
|
||||
investmentDetailPublish: ({
|
||||
id,
|
||||
status,
|
||||
}: {
|
||||
id: string;
|
||||
status: StatusApp;
|
||||
}) => `/admin/investment/${id}/${status}`,
|
||||
|
||||
// DONATION
|
||||
donationByStatus: ({ status }: { status: StatusApp }) => `/admin/donation/${status}/status`,
|
||||
donationDetailPublish: ({
|
||||
id,
|
||||
status,
|
||||
}: {
|
||||
id: string;
|
||||
status: StatusApp;
|
||||
}) => `/admin/donation/${id}/${status}`,
|
||||
};
|
||||
|
||||
// ================ ROUTER USER =================
|
||||
const routeUserMobile = {
|
||||
home: `/(user)/home`,
|
||||
// JOB
|
||||
@@ -26,4 +53,29 @@ const routeUserMobile = {
|
||||
eventByStatus: ({ status }: { status?: StatusApp }) =>
|
||||
`/event/(tabs)/status?status=${status}`,
|
||||
eventDetailPublised: ({ id }: { id: string }) => `/event/${id}/publish`,
|
||||
|
||||
// VOTING
|
||||
votingByStatus: ({ status }: { status?: StatusApp }) =>
|
||||
`/voting/(tabs)/status?status=${status}`,
|
||||
votingDetailPublised: ({ id }: { id: string }) => `/voting/${id}`,
|
||||
|
||||
// FORUM
|
||||
forumBeranda: `/forum`,
|
||||
forumDetail: ({ id }: { id: string }) => `/forum/${id}`,
|
||||
forumPreviewReportPosting: ({ id }: { id: string }) =>
|
||||
`/forum/${id}/preview-report-posting`,
|
||||
forumPreviewReportComment: ({ id }: { id: string }) =>
|
||||
`/forum/${id}/preview-report-comment`,
|
||||
|
||||
// INVESTMENT
|
||||
investmentPortofolioByStatus: ({ status }: { status?: StatusApp }) =>
|
||||
`/investment/(tabs)/portofolio?status=${status}`,
|
||||
investmentDetailPublish: ({ id }: { id: string }) => `/investment/${id}`,
|
||||
investmentTransaction: `/investment/(tabs)/transaction`,
|
||||
|
||||
// DONATION
|
||||
donationByStatus: ({ status }: { status?: StatusApp }) =>
|
||||
`/donation/(tabs)/status?status=${status}`,
|
||||
donationDetailPublish: ({ id }: { id: string }) => `/donation/${id}`,
|
||||
donationTransaction: `/donation/(tabs)/my-donation`,
|
||||
};
|
||||
|
||||
@@ -23,6 +23,6 @@
|
||||
"@/*": ["./src/*"]
|
||||
}
|
||||
},
|
||||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts", "src/app_modules/investasi/proses_transaksi/view.jsx", "src/app/api/investasi/midtrans/[id]/route.ts", "src/app_modules/job/create/TextEdit.tsx", "src/app/api/mobile/forum/[id]/report-comment/route.ts"],
|
||||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts", "src/app_modules/investasi/proses_transaksi/view.jsx", "src/app/api/investasi/midtrans/[id]/route.ts", "src/app_modules/job/create/TextEdit.tsx", "src/app/api/mobile/forum/[id]/report-comment-del-soon/route.ts"],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
|
||||
226
zCoba.js
226
zCoba.js
@@ -1,28 +1,204 @@
|
||||
// const data = [
|
||||
// {
|
||||
// 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 { PrismaClient } = require('@prisma/client')
|
||||
const axios = require('axios')
|
||||
|
||||
const prisma = new PrismaClient()
|
||||
|
||||
console.error("errornya disini klik aja",import.meta.url);
|
||||
console.log(new Set(data.map((d) => d.authorId)));
|
||||
// Daftar contoh data
|
||||
const donationDataList = [
|
||||
{
|
||||
"data": {
|
||||
"authorId": "cmha6wb9w0001cfndwl9fcse6",
|
||||
"title": "Bantuan Pendidikan Anak-anak Kurang Mampu",
|
||||
"target": 50000000,
|
||||
"donasiMaster_DurasiId": 3,
|
||||
"donasiMaster_KategoriId": 3,
|
||||
"namaBank": "Bank Central Asia",
|
||||
"rekening": "1234567890",
|
||||
"imageId": "cm60j9q3m000xc9dc584v8rh8",
|
||||
"pembukaan": "Kami ingin membantu anak-anak kurang mampu mendapatkan pendidikan yang layak.",
|
||||
"cerita": "Pendidikan adalah hak dasar setiap anak. Namun, banyak anak-anak di pelosok negeri yang tidak bisa menikmati pendidikan karena keterbatasan ekonomi. Melalui kampanye ini, kami ingin mengumpulkan dana untuk membantu biaya pendidikan mereka.",
|
||||
"imageCeritaId": "cm60j9q3m000xc9dc584v8rj0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"authorId": "cmha6wb9w0001cfndwl9fcse6",
|
||||
"title": "Pembangunan Masjid di Desa Terpencil",
|
||||
"target": 100000000,
|
||||
"donasiMaster_DurasiId": 3,
|
||||
"donasiMaster_KategoriId": 3,
|
||||
"namaBank": "Bank Mandiri",
|
||||
"rekening": "0987654321",
|
||||
"imageId": "cm60j9q3m000xc9dc584v8rh8",
|
||||
"pembukaan": "Membangun masjid untuk masyarakat di daerah terpencil yang belum memiliki tempat ibadah.",
|
||||
"cerita": "Di sebuah desa terpencil, masyarakat setiap hari harus berjalan jauh untuk bisa melaksanakan sholat berjamaah. Kami ingin membantu membangun masjid di tengah-tengah mereka agar ibadah bisa dilakukan dengan lebih tenang dan khusyuk.",
|
||||
"imageCeritaId": "cm60j9q3m000xc9dc584v8rj1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"authorId": "cmha6wb9w0001cfndwl9fcse6",
|
||||
"title": "Bantuan Korban Bencana Alam",
|
||||
"target": 75000000,
|
||||
"donasiMaster_DurasiId": 3,
|
||||
"donasiMaster_KategoriId": 3,
|
||||
"namaBank": "Bank Rakyat Indonesia",
|
||||
"rekening": "5678901234",
|
||||
"imageId": "cm60j9q3m000xc9dc584v8rh8",
|
||||
"pembukaan": "Membantu meringankan beban korban bencana alam berupa kebutuhan pokok dan kebutuhan darurat.",
|
||||
"cerita": "Beberapa wilayah dilanda bencana banjir dan tanah longsor. Masyarakat kehilangan harta benda dan membutuhkan bantuan segera. Dana yang terkumpul akan digunakan untuk menyediakan makanan, obat-obatan, dan kebutuhan pokok lainnya.",
|
||||
"imageCeritaId": "cm60j9q3m000xc9dc584v8rj2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"authorId": "cmha6wb9w0001cfndwl9fcse6",
|
||||
"title": "Pengadaan Alat Medis Rumah Sakit",
|
||||
"target": 150000000,
|
||||
"donasiMaster_DurasiId": 3,
|
||||
"donasiMaster_KategoriId": 3,
|
||||
"namaBank": "Bank Negara Indonesia",
|
||||
"rekening": "4321098765",
|
||||
"imageId": "cm60j9q3m000xc9dc584v8rh8",
|
||||
"pembukaan": "Meningkatkan kualitas pelayanan kesehatan dengan menyediakan alat medis yang lebih baik.",
|
||||
"cerita": "Rumah sakit daerah kekurangan alat medis untuk melayani pasien. Melalui donasi ini, kami ingin membantu pengadaan alat-alat medis penting seperti ventilator, USG, dan alat laboratorium untuk meningkatkan kualitas pelayanan kesehatan.",
|
||||
"imageCeritaId": "cm60j9q3m000xc9dc584v8rj3"
|
||||
}
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"authorId": "cmha6wb9w0001cfndwl9fcse6",
|
||||
"title": "Program Beasiswa Mahasiswa Berprestasi",
|
||||
"target": 80000000,
|
||||
"donasiMaster_DurasiId": 3,
|
||||
"donasiMaster_KategoriId": 3,
|
||||
"namaBank": "Bank Danamon",
|
||||
"rekening": "1122334455",
|
||||
"imageId": "cm60j9q3m000xc9dc584v8rh8",
|
||||
"pembukaan": "Memberikan kesempatan kepada mahasiswa berprestasi untuk melanjutkan pendidikan tanpa beban biaya.",
|
||||
"cerita": "Banyak mahasiswa berprestasi yang tidak mampu melanjutkan pendidikan karena keterbatasan biaya. Program beasiswa ini akan membantu mereka menyelesaikan kuliah hingga sarjana.",
|
||||
"imageCeritaId": "cm60j9q3m000xc9dc584v8rj4"
|
||||
}
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"authorId": "cmha6wb9w0001cfndwl9fcse6",
|
||||
"title": "Pengadaan Air Bersih untuk Desa Kekeringan",
|
||||
"target": 60000000,
|
||||
"donasiMaster_DurasiId": 3,
|
||||
"donasiMaster_KategoriId": 3,
|
||||
"namaBank": "Bank Permata",
|
||||
"rekening": "6677889900",
|
||||
"imageId": "cm60j9q3m000xc9dc584v8rh8",
|
||||
"pembukaan": "Menyediakan akses air bersih bagi masyarakat yang tinggal di daerah rawan kekeringan.",
|
||||
"cerita": "Beberapa desa mengalami kekeringan setiap tahunnya, membuat warga kesulitan mendapatkan air bersih. Kami ingin membangun sumur bor dan sistem distribusi air untuk membantu masyarakat setempat.",
|
||||
"imageCeritaId": "cm60j9q3m000xc9dc584v8rj5"
|
||||
}
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"authorId": "cmha6wb9w0001cfndwl9fcse6",
|
||||
"title": "Pengobatan Gratis untuk Warga Tidak Mampu",
|
||||
"target": 40000000,
|
||||
"donasiMaster_DurasiId": 3,
|
||||
"donasiMaster_KategoriId": 3,
|
||||
"namaBank": "Bank Panin",
|
||||
"rekening": "9988776655",
|
||||
"imageId": "cm60j9q3m000xc9dc584v8rh8",
|
||||
"pembukaan": "Memberikan layanan kesehatan gratis bagi warga yang tidak mampu membayar biaya pengobatan.",
|
||||
"cerita": "Banyak warga yang menunda pengobatan karena keterbatasan biaya. Melalui program ini, kami akan menyelenggarakan pengobatan gratis secara berkala di berbagai wilayah.",
|
||||
"imageCeritaId": "cm60j9q3m000xc9dc584v8rj6"
|
||||
}
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"authorId": "cmha6wb9w0001cfndwl9fcse6",
|
||||
"title": "Pembangunan Taman Bacaan Masyarakat",
|
||||
"target": 35000000,
|
||||
"donasiMaster_DurasiId": 3,
|
||||
"donasiMaster_KategoriId": 3,
|
||||
"namaBank": "Bank Mega",
|
||||
"rekening": "1357924680",
|
||||
"imageId": "cm60j9q3m000xc9dc584v8rh8",
|
||||
"pembukaan": "Membangun taman bacaan untuk meningkatkan minat baca masyarakat di wilayah pedesaan.",
|
||||
"cerita": "Minat baca masyarakat di pedesaan masih rendah karena keterbatasan akses buku. Taman bacaan ini akan menyediakan ribuan buku gratis dan ruang baca yang nyaman untuk semua usia.",
|
||||
"imageCeritaId": "cm60j9q3m000xc9dc584v8rj7"
|
||||
}
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"authorId": "cmha6wb9w0001cfndwl9fcse6",
|
||||
"title": "Pelatihan Keterampilan untuk Pengangguran",
|
||||
"target": 55000000,
|
||||
"donasiMaster_DurasiId": 3,
|
||||
"donasiMaster_KategoriId": 3,
|
||||
"namaBank": "Bank CIMB Niaga",
|
||||
"rekening": "2468135790",
|
||||
"imageId": "cm60j9q3m000xc9dc584v8rh8",
|
||||
"pembukaan": "Memberikan pelatihan keterampilan untuk membantu pengangguran mendapatkan pekerjaan atau usaha mandiri.",
|
||||
"cerita": "Angka pengangguran masih tinggi di beberapa wilayah. Program pelatihan ini akan memberikan keterampilan yang dibutuhkan pasar kerja, seperti menjahit, memasak, teknologi informasi, dan lainnya.",
|
||||
"imageCeritaId": "cm60j9q3m000xc9dc584v8rj8"
|
||||
}
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"authorId": "cmha6wb9w0001cfndwl9fcse6",
|
||||
"title": "Renovasi Gedung Sekolah Rusak",
|
||||
"target": 90000000,
|
||||
"donasiMaster_DurasiId": 3,
|
||||
"donasiMaster_KategoriId": 3,
|
||||
"namaBank": "Bank OCBC NISP",
|
||||
"rekening": "1029384756",
|
||||
"imageId": "cm60j9q3m000xc9dc584v8rh8",
|
||||
"pembukaan": "Merestrukturasi gedung sekolah yang rusak agar siswa bisa belajar dengan aman dan nyaman.",
|
||||
"cerita": "Banyak gedung sekolah yang rusak parah dan membahayakan keselamatan siswa. Dana dari kampanye ini akan digunakan untuk renovasi dan perbaikan gedung sekolah yang membutuhkan.",
|
||||
"imageCeritaId": "cm60j9q3m000xc9dc584v8rj9"
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
async function sendDonationData() {
|
||||
const baseUrl = 'http://localhost:3000/api/mobile/donation'; // Sesuaikan dengan URL server Anda
|
||||
const headers = {
|
||||
'Content-Type': 'application/json',
|
||||
};
|
||||
|
||||
for (let i = 0; i < donationDataList.length; i++) {
|
||||
try {
|
||||
console.log(`Mengirim data ke-${i + 1}...`);
|
||||
const response = await axios.post(`${baseUrl}?category=permanent`, donationDataList[i], {
|
||||
headers: headers
|
||||
});
|
||||
console.log(`Data ke-${i + 1} berhasil dikirim:`, response.data);
|
||||
} catch (error) {
|
||||
console.error(`Error saat mengirim data ke-${i + 1}:`, error.response?.data || error.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function main() {
|
||||
// Menjalankan fungsi untuk mengirim data donasi
|
||||
await sendDonationData();
|
||||
|
||||
// Fungsi asli untuk update notifikasi
|
||||
const result = await prisma.notifikasi.updateMany({
|
||||
where: {
|
||||
recipientId: 'cmha7p6yc0000cfoe5w2e7gdr',
|
||||
},
|
||||
data: {
|
||||
isRead: false,
|
||||
readAt: null,
|
||||
},
|
||||
})
|
||||
|
||||
console.log(`✅ Rows affected: ${result.count}`)
|
||||
}
|
||||
|
||||
main()
|
||||
.catch((err) => {
|
||||
console.error('❌ Error:', err)
|
||||
process.exit(1)
|
||||
})
|
||||
.finally(async () => {
|
||||
await prisma.$disconnect()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user