Compare commits
4 Commits
mobile-not
...
mobile-api
| Author | SHA1 | Date | |
|---|---|---|---|
| 42803f9b92 | |||
| 2a857f54e7 | |||
| bb79a68f44 | |||
| f103ae93ad |
@@ -2,6 +2,8 @@
|
||||
|
||||
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.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)
|
||||
|
||||
19
PROMPT-AI.md
Normal file
19
PROMPT-AI.md
Normal file
@@ -0,0 +1,19 @@
|
||||
|
||||
File utama: src/app/api/mobile/event/route.ts
|
||||
File refrensi: src/app/api/mobile/job/[id]/[status]/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,
|
||||
|
||||
Anda bisa menggunakan refrensi dari "File refrensi" jika butuh pemahaman dengan tipe fitur yang sama
|
||||
|
||||
Gunakan bahasa indonesia pada cli agar saya mudah membacanya.
|
||||
201
QWEN.md
Normal file
201
QWEN.md
Normal file
@@ -0,0 +1,201 @@
|
||||
# HIPMI Project - QWEN.md
|
||||
|
||||
## Project Overview
|
||||
|
||||
HIPMI (Himpunan Pengusaha Muda Indonesia) is a comprehensive Next.js-based web application built for the Indonesian Young Entrepreneurs Association. The project is a sophisticated platform that provides multiple business functionalities including investment management, donations, events, job listings, forums, voting systems, and collaborative projects.
|
||||
|
||||
### Key Technologies
|
||||
- **Framework**: Next.js 13+ (with App Router)
|
||||
- **Language**: TypeScript
|
||||
- **Database**: PostgreSQL with Prisma ORM
|
||||
- **Styling**: Tailwind CSS with Mantine UI components
|
||||
- **Authentication**: JWT-based with custom middleware
|
||||
- **Runtime**: Bun (instead of Node.js)
|
||||
- **Deployment**: Standalone output configuration
|
||||
|
||||
### Team Structure
|
||||
- **bagas**: Frontend, DevOps
|
||||
- **lukman**: Frontend, UI
|
||||
- **lia**: Backend, Frontend, QC
|
||||
- **malik**: Leader
|
||||
|
||||
## Architecture & Features
|
||||
|
||||
### Core Modules
|
||||
The application is organized into several major functional areas:
|
||||
|
||||
1. **Authentication System** (`/auth`) - Login, registration, validation
|
||||
2. **Investment Platform** (`/investasi`) - Investment creation, trading, portfolio management
|
||||
3. **Donation System** (`/donasi`) - Fundraising campaigns, donation processing
|
||||
4. **Event Management** (`/event`) - Event creation, participation, management
|
||||
5. **Voting System** (`/vote`) - Voting creation and participation
|
||||
6. **Job Board** (`/job`) - Job posting and application system
|
||||
7. **Forum** (`/forum`) - Discussion platform with reporting features
|
||||
8. **Collaboration Platform** (`/colab`) - Project collaboration tools
|
||||
9. **User Profiles** (`/profile`) - User profile management
|
||||
10. **Business Maps** (`/maps`) - Business location mapping
|
||||
|
||||
### Admin Panel
|
||||
The application includes a comprehensive admin panel (`/admin`) with modules for managing:
|
||||
- Investment approvals and transfers
|
||||
- Donation campaign reviews
|
||||
- Event management
|
||||
- Forum moderation
|
||||
- Job posting reviews
|
||||
- User access management
|
||||
- Voting oversight
|
||||
|
||||
### Technical Architecture
|
||||
|
||||
#### Routing & Authentication
|
||||
- Custom middleware handles authentication and authorization
|
||||
- Public routes are defined in the middleware configuration
|
||||
- JWT tokens are stored in cookies with secure options
|
||||
- Role-based access control (MasterUserRole model)
|
||||
|
||||
#### Database Schema
|
||||
The Prisma schema defines a comprehensive data model with:
|
||||
- User management with roles and profiles
|
||||
- Investment and financial systems
|
||||
- Donation and crowdfunding features
|
||||
- Event management
|
||||
- Forum and discussion systems
|
||||
- Collaboration platforms
|
||||
- Notification systems
|
||||
- Business mapping features
|
||||
|
||||
#### Environment Configuration
|
||||
The application uses multiple environment files for different deployment stages:
|
||||
- Development: `run.env.dev`, `run.env.local.dev`
|
||||
- Build: `run.env.build.dev`, `run.env.build.local`
|
||||
- Runtime: `run.env.start.dev`, `run.env.start.local`
|
||||
|
||||
## Building and Running
|
||||
|
||||
### Prerequisites
|
||||
- Bun runtime installed
|
||||
- PostgreSQL database
|
||||
- Required environment variables configured
|
||||
|
||||
### Setup Commands
|
||||
```bash
|
||||
# Install dependencies
|
||||
bun install
|
||||
|
||||
# Setup database (Prisma)
|
||||
bun prisma generate
|
||||
bun prisma db push
|
||||
bun prisma db seed
|
||||
|
||||
# Development server
|
||||
bun run dev
|
||||
|
||||
# Build for production
|
||||
bun run build
|
||||
|
||||
# Start production server
|
||||
bun run start
|
||||
```
|
||||
|
||||
### Development Scripts
|
||||
- `dev`: Starts development server with HTTPS
|
||||
- `build`: Builds the application for production
|
||||
- `start`: Starts the production server
|
||||
- `lint`: Runs Next.js linting
|
||||
- `ver`: Creates version tags
|
||||
|
||||
## Development Conventions
|
||||
|
||||
### Git Workflow
|
||||
The team follows a structured Git workflow:
|
||||
1. Check status with `git status`
|
||||
2. Add specific files with `git add <file>` (avoid `git add -A`)
|
||||
3. Commit with structured messages following conventional commits:
|
||||
- `feat`: New features
|
||||
- `fix`: Bug fixes
|
||||
- `docs`: Documentation updates
|
||||
- `chore`: Routine tasks
|
||||
- `refactor`: Code restructuring
|
||||
- `test`: Testing additions
|
||||
- `style`: Styling changes
|
||||
- `perf`: Performance improvements
|
||||
|
||||
### Code Standards
|
||||
- TypeScript with strict mode enabled
|
||||
- Component header comments with file description, creator, date
|
||||
- Function comments with parameter and return value descriptions
|
||||
- Custom type interface comments
|
||||
- Error handling comments
|
||||
- Complex logic comments
|
||||
|
||||
### Commit Message Format
|
||||
```
|
||||
type: Short description
|
||||
|
||||
Body:
|
||||
- Detailed description of changes
|
||||
- Motivation for changes
|
||||
- Breaking changes if any
|
||||
|
||||
References: #issue-number
|
||||
```
|
||||
|
||||
## Project Structure
|
||||
|
||||
### Main Directories
|
||||
- `src/app`: Next.js App Router pages and layouts
|
||||
- `src/app_modules`: Reusable application modules
|
||||
- `src/lib`: Shared libraries and utilities
|
||||
- `src/util`: Utility functions
|
||||
- `prisma`: Database schema and migrations
|
||||
- `public`: Static assets
|
||||
- `certificates`, `logs`: Application data directories
|
||||
|
||||
### Key Files
|
||||
- `package.json`: Dependencies and scripts
|
||||
- `next.config.js`: Next.js configuration
|
||||
- `middleware.tsx`: Authentication and routing middleware
|
||||
- `tsconfig.json`: TypeScript configuration
|
||||
- `tailwind.config.js`: Styling configuration
|
||||
- `gen_page.tsx`: Generated page routing utility
|
||||
- `prisma/schema.prisma`: Database schema definition
|
||||
|
||||
## Special Features
|
||||
|
||||
### Real-time Capabilities
|
||||
- WebSocket integration for real-time updates
|
||||
- MQTT support for messaging
|
||||
- Live notifications system
|
||||
|
||||
### Payment Integration
|
||||
- Midtrans payment gateway for investments
|
||||
- Multiple payment methods
|
||||
- Invoice generation and tracking
|
||||
|
||||
### File Handling
|
||||
- PDF generation and viewing
|
||||
- Image processing and storage
|
||||
- Document management for investments
|
||||
|
||||
### Mobile Support
|
||||
- Responsive design
|
||||
- Mobile-specific features
|
||||
- Device token management
|
||||
|
||||
## Security Measures
|
||||
|
||||
### Authentication
|
||||
- JWT-based authentication
|
||||
- Session management
|
||||
- Role-based access control
|
||||
- Secure token storage in cookies
|
||||
|
||||
### Input Validation
|
||||
- Prisma schema validations
|
||||
- Server-side validation
|
||||
- Sanitization of user inputs
|
||||
|
||||
### Data Protection
|
||||
- Encrypted tokens
|
||||
- Secure API routes
|
||||
- Proper CORS configuration
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hipmi",
|
||||
"version": "1.5.38",
|
||||
"version": "1.5.39",
|
||||
"private": true,
|
||||
"prisma": {
|
||||
"seed": "bun prisma/seed.ts"
|
||||
|
||||
@@ -12,6 +12,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 = 10;
|
||||
const skipData = page * takeData - takeData;
|
||||
|
||||
const data = await prisma.event.findMany({
|
||||
orderBy: {
|
||||
updatedAt: "desc",
|
||||
@@ -37,13 +42,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 }
|
||||
);
|
||||
|
||||
@@ -76,11 +76,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 = 5;
|
||||
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({
|
||||
@@ -108,84 +112,95 @@ 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: {
|
||||
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,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -194,86 +209,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,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 },
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
48
zCoba.js
48
zCoba.js
@@ -1,28 +1,26 @@
|
||||
// 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 prisma = new PrismaClient()
|
||||
|
||||
console.error("errornya disini klik aja",import.meta.url);
|
||||
console.log(new Set(data.map((d) => d.authorId)));
|
||||
async function main() {
|
||||
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