### Clone Repository and Install Dependencies (Bash) Source: https://github.com/hayzxc/prana-webaccess/blob/main/SETUP.md Clones the Prana Argentum Certificate Portal repository and installs project dependencies using npm. Ensure Node.js 18+ and npm/yarn are installed. ```bash git clone cd certification-portal npm install --legacy-peer-deps ``` -------------------------------- ### Run Development Server (Bash) Source: https://github.com/hayzxc/prana-webaccess/blob/main/SETUP.md Starts the Next.js development server for the Prana Argentum Certificate Portal. Access the application at http://localhost:3000. ```bash npm run dev ``` -------------------------------- ### Supabase Connection Error Example (Log) Source: https://github.com/hayzxc/prana-webaccess/blob/main/SETUP.md An example of a Supabase connection error that may occur if the Supabase URL is not correctly configured in the environment variables. ```log Error: supabaseUrl is required ``` -------------------------------- ### Available NPM Scripts (Bash) Source: https://github.com/hayzxc/prana-webaccess/blob/main/SETUP.md Lists the common npm scripts available for managing the Prana Argentum Certificate Portal development lifecycle. These scripts facilitate starting the server, building for production, linting, and type checking. ```bash npm run dev # Start development server npm run build # Build for production npm run start # Start production server npm run lint # Run ESLint npm run type-check # TypeScript type checking ``` -------------------------------- ### Project Structure Overview (Tree) Source: https://github.com/hayzxc/prana-webaccess/blob/main/SETUP.md Illustrates the directory structure of the Prana Argentum Certificate Portal, built with Next.js. Highlights key directories like `app`, `components`, `lib`, and `scripts`. ```tree ├── app/ # Next.js App Router │ ├── admin/ # Admin dashboard │ ├── dashboard/ # User dashboard │ ├── login/ # Authentication │ └── api/ # API routes ├── components/ # React components │ ├── ui/ # shadcn/ui components │ └── ... # Custom components ├── lib/ # Utilities and configurations ├── scripts/ # Database scripts └── public/ # Static assets ``` -------------------------------- ### Supabase Storage Bucket Error Example (Log) Source: https://github.com/hayzxc/prana-webaccess/blob/main/SETUP.md An example of an error related to file uploads failing due to a missing storage bucket. Ensure a public storage bucket is created in Supabase. ```log Error: Storage bucket not found ``` -------------------------------- ### Database Management with Supabase CLI (Bash) Source: https://github.com/hayzxc/prana-webaccess/blob/main/SETUP.md Manages database schema and generates TypeScript types for the Supabase database. Requires the Supabase CLI to be installed and configured. ```bash supabase db pull supabase db push supabase gen types typescript --local > types/database.types.ts ``` -------------------------------- ### Vercel Build Failure Example (Log) Source: https://github.com/hayzxc/prana-webaccess/blob/main/SETUP.md An example of a build failure on Vercel, often related to missing environment variables. Ensure all necessary variables are set in the Vercel project settings. ```log Error: Failed to collect page data ``` -------------------------------- ### Environment Variable Configuration (env) Source: https://github.com/hayzxc/prana-webaccess/blob/main/SETUP.md Sets up local environment variables for Supabase connection and JWT secret. Copy `.env.example` to `.env.local` and replace placeholders with actual credentials obtained from Supabase and generated secrets. ```env NEXT_PUBLIC_SUPABASE_URL=https://your-project-id.supabase.co NEXT_PUBLIC_SUPABASE_ANON_KEY=your_anon_key_here SUPABASE_SERVICE_ROLE_KEY=your_service_role_key_here JWT_SECRET=your_generated_secret_here ``` -------------------------------- ### JWT Secret Configuration Error Example (Log) Source: https://github.com/hayzxc/prana-webaccess/blob/main/SETUP.md An example of an authentication error indicating that the JWT secret is not configured. This requires generating and setting the JWT_SECRET environment variable. ```log Error: JWT secret not configured ``` -------------------------------- ### Update Project with Bash Source: https://github.com/hayzxc/prana-webaccess/blob/main/SETUP.md This snippet outlines the bash commands required to update the Prana Web Access project. It involves pulling the latest changes from the main branch, installing dependencies using npm with legacy peer dependency support, and building the project. ```bash git pull origin main npm install --legacy-peer-deps npm run build ``` -------------------------------- ### Setup Database - Bash Source: https://github.com/hayzxc/prana-webaccess/blob/main/README.md Configures the PostgreSQL database using Prisma. This involves generating the Prisma client, applying database migrations, and seeding initial data for admin and user accounts. ```bash # Generate Prisma Client npx prisma generate # Run Migrations npx prisma migrate deploy # Seed Initial Data (Admin/User accounts) npx prisma db seed ``` -------------------------------- ### Install Dependencies - Bash Source: https://github.com/hayzxc/prana-webaccess/blob/main/README.md Installs all the necessary project dependencies using npm. Ensure Node.js and npm are installed and configured before running this command. ```bash npm install ``` -------------------------------- ### Get All Users (GET) Source: https://context7.com/hayzxc/prana-webaccess/llms.txt Retrieves a list of all users with their basic information. Requires admin authentication. Returns a list of user objects. ```bash curl -X GET http://localhost:3000/api/users \ -H "Cookie: auth-token=" ``` -------------------------------- ### Certificate Management API Endpoints (Bash) Source: https://context7.com/hayzxc/prana-webaccess/llms.txt Demonstrates how to retrieve all certificates and create new ones using cURL. The 'Get All Certificates' endpoint respects user roles for data visibility, while 'Create Certificate' requires admin privileges and handles automatic date calculations for fumigation services. ```bash # Get certificates (requires auth) curl -X GET http://localhost:3000/api/certificates \ -H "Cookie: auth-token=" # Success response (200) - Admin view { "success": true, "data": [ { "id": "cert123", "name": "Fumigation Certificate", "recipientEmail": "client@company.com", "recipientName": "PT Example Corp", "issueDate": "2024-06-01T00:00:00.000Z", "status": "VALID", "serviceType": "FUMIGATION", "containerNumber": "MSKU1234567", "noticeId": "NID2024001", "woNumber": "WO-2024-001", "progressStatus": "READY", "gassingTime": "2024-06-01T08:00:00.000Z", "aerationStartTime": "2024-06-01T14:00:00.000Z", "containerReadyTime": "2024-06-02T11:00:00.000Z", "issuedBy": { "id": "user123", "name": "Admin User", "email": "admin@prana.com" } } ] } # Create fumigation certificate (admin only) curl -X POST http://localhost:3000/api/certificates \ -H "Content-Type: application/json" \ -H "Cookie: auth-token=" \ -d '{ "name": "Fumigation Certificate", "recipientEmail": "client@company.com", "recipientName": "PT Example Corp", "issueDate": "2024-06-15T00:00:00.000Z", "status": "VALID", "serviceType": "FUMIGATION", "containerNumber": "MSKU7654321", "noticeId": "NID2024002", "woNumber": "WO-2024-002", "location": "Jakarta Port", "gassingTime": "2024-06-15T08:00:00.000Z" }' ``` -------------------------------- ### Optional Environment Variables for Application Source: https://github.com/hayzxc/prana-webaccess/blob/main/DEPLOYMENT.md Details optional environment variables that can be configured for enhanced features like email notifications and analytics. These are not strictly required for basic deployment but are useful for extended functionality. ```env # Email (if using email notifications) SMTP_HOST=smtp.gmail.com SMTP_PORT=587 SMTP_USER=your-email@gmail.com SMTP_PASS=your-app-password # Analytics GOOGLE_ANALYTICS_ID=GA_MEASUREMENT_ID ``` -------------------------------- ### Search Fumigation Tracking (GET) Source: https://context7.com/hayzxc/prana-webaccess/llms.txt Retrieves fumigation tracking status publicly using container number and notice ID. No authentication required. Returns tracking data or error messages. ```bash curl -X GET "http://localhost:3000/api/tracking?containerNumber=MSKU1234567¬iceId=NID2024001" ``` -------------------------------- ### User Authentication API Endpoints (Bash) Source: https://context7.com/hayzxc/prana-webaccess/llms.txt Provides examples for user login, registration, retrieving current user information, and logout using cURL. These endpoints are crucial for managing user sessions and access control within the application. ```bash # Login request curl -X POST http://localhost:3000/api/auth/login \ -H "Content-Type: application/json" \ -d '{ "email": "admin@prana.com", "password": "admin123" }' # Success response (200) { "success": true, "data": { "id": "clx123abc", "name": "Admin User", "email": "admin@prana.com", "role": "ADMIN", "createdAt": "2024-01-01T00:00:00.000Z" }, "message": "Login successful" } # Error response (401) { "success": false, "message": "Invalid credentials" } # Register request curl -X POST http://localhost:3000/api/auth/register \ -H "Content-Type: application/json" \ -d '{ "name": "John Doe", "email": "john@example.com", "password": "securePassword123", "role": "USER" }' # Success response (201) { "success": true, "data": { "id": "clx456def", "name": "John Doe", "email": "john@example.com", "role": "USER", "createdAt": "2024-06-15T10:30:00.000Z" }, "message": "User registered successfully" } # Error response - email exists (409) { "success": false, "message": "Email already registered" } # Get current user (requires auth cookie) curl -X GET http://localhost:3000/api/auth/me \ -H "Cookie: auth-token=" # Success response (200) { "success": true, "data": { "id": "clx123abc", "name": "Admin User", "email": "admin@prana.com", "role": "ADMIN" }, "message": "User information retrieved" } # Logout request curl -X POST http://localhost:3000/api/auth/logout \ -H "Cookie: auth-token=" # Success response (200) { "success": true, "message": "Logout successful" } ``` -------------------------------- ### GET /api/certificates/suggestions Source: https://context7.com/hayzxc/prana-webaccess/llms.txt Retrieves autocomplete suggestions for form fields based on existing data. Requires authentication. ```APIDOC ## GET /api/certificates/suggestions ### Description Returns autocomplete suggestions for form fields based on existing data. Requires authentication. ### Method GET ### Endpoint `/api/certificates/suggestions` ### Parameters #### Query Parameters - **field** (string) - Required - The form field for which to get suggestions (e.g., `recipientEmail`, `recipientName`, `containerNumber`). Supported fields: `recipientEmail`, `recipientName`, `location`, `containerNumber`, `noticeId`, `woNumber`, `companyName`, `companyEmail`. - **query** (string) - Required - The search query string to find matching suggestions. ### Response #### Success Response (200) - **success** (boolean) - Indicates if the operation was successful. - **data** (array) - An array of matching suggestion strings. #### Response Example ```json { "success": true, "data": [ "client@company.com", "client2@example.com", "clientservices@corp.com" ] } ``` ``` -------------------------------- ### Get All Consultation Requests (Bash) Source: https://context7.com/hayzxc/prana-webaccess/llms.txt Retrieves a list of all consultation requests. This endpoint does not require authentication and returns a 200 OK status with an array of consultation request objects. ```bash # Get consultation requests curl -X GET http://localhost:3000/api/consultation-requests ``` -------------------------------- ### Get Record Sheets (GET) Source: https://context7.com/hayzxc/prana-webaccess/llms.txt Retrieves all record sheets, including their gas readings. Requires authentication. Returns a list of record sheet objects. ```bash curl -X GET http://localhost:3000/api/record-sheets \ -H "Cookie: auth-token=" ``` -------------------------------- ### Vercel Environment Variables Configuration Source: https://github.com/hayzxc/prana-webaccess/blob/main/DEPLOYMENT.md This snippet shows the essential environment variables required for deploying the application on Vercel. These variables cover authentication, database connection, and Supabase integration. Ensure these are correctly configured in your Vercel project settings. ```env NEXTAUTH_SECRET=your-secret-key NEXTAUTH_URL=https://your-domain.vercel.app DATABASE_URL=your-database-url SUPABASE_URL=your-supabase-url SUPABASE_ANON_KEY=your-supabase-anon-key ``` -------------------------------- ### GET /api/consultation-requests Source: https://context7.com/hayzxc/prana-webaccess/llms.txt Retrieves a list of all consultation requests. No authentication is required for this endpoint. ```APIDOC ## GET /api/consultation-requests ### Description Retrieves all consultation requests. No authentication required. ### Method GET ### Endpoint /api/consultation-requests ### Response #### Success Response (200) - An array of consultation request objects. - **id** (string) - The unique identifier for the consultation request. - **customerName** (string) - The name of the customer. - **customerEmail** (string) - The email address of the customer. - **customerPhone** (string) - The phone number of the customer. - **companyName** (string) - The name of the customer's company. - **serviceType** (string) - The type of service requested (e.g., "FUMIGATION", "CARGO_SURVEY"). - **message** (string) - The message or request details from the customer. - **status** (string) - The current status of the request (e.g., "PENDING", "IN_PROGRESS"). - **adminNotes** (string|null) - Notes added by an administrator. - **createdAt** (string) - The timestamp when the request was created (ISO 8601 format). - **updatedAt** (string) - The timestamp when the request was last updated (ISO 8601 format). #### Response Example ```json [ { "id": "consult123", "customerName": "PT New Client", "customerEmail": "contact@newclient.com", "customerPhone": "+62812345678", "companyName": "PT New Client Corp", "serviceType": "FUMIGATION", "message": "Need fumigation service for export shipment", "status": "PENDING", "adminNotes": null, "createdAt": "2024-06-15T09:00:00.000Z", "updatedAt": "2024-06-15T09:00:00.000Z" } ] ``` ``` -------------------------------- ### Get Record Sheets Source: https://context7.com/hayzxc/prana-webaccess/llms.txt Retrieves all record sheets, including their associated gas readings. Authentication is required. ```APIDOC ## GET /api/record-sheets ### Description Retrieves a list of all record sheets, including their gas readings. This endpoint requires user authentication. ### Method GET ### Endpoint /api/record-sheets ### Parameters #### Headers - **Cookie** (string) - Required - Authentication token (e.g., `auth-token=`). ### Response #### Success Response (200 OK) - **success** (boolean) - Indicates if the request was successful. - **data** (array) - An array of record sheet objects, each containing gas reading details. #### Response Example (200) ```json { "success": true, "data": [ { "id": "rec123", "containerNumber": "MSKU1234567", "gassingTime": "2024-06-15T08:00:00.000Z", "gasReadings": [ { "timestamp": "2024-06-15T08:30:00.000Z", "temperature": 25.5, "humidity": 70.2 }, { "timestamp": "2024-06-15T09:00:00.000Z", "temperature": 25.8, "humidity": 70.5 } ] } // ... more record sheets ] } ``` #### Error Response (401 Unauthorized) Returned if the user is not authenticated. #### Error Response (403 Forbidden) Returned if the authenticated user does not have permission to access record sheets. ``` -------------------------------- ### GET /api/fumigation-trackings Source: https://context7.com/hayzxc/prana-webaccess/llms.txt Retrieves a list of fumigation tracking records. Users can only see records associated with their email, while administrators can see all records. ```APIDOC ## GET /api/fumigation-trackings ### Description Retrieves fumigation tracking records. Admins see all records; users only see records matching their email. Requires authentication. ### Method GET ### Endpoint `/api/fumigation-trackings` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the operation was successful. - **data** (array) - An array of fumigation tracking objects. - **id** (string) - Unique identifier for the tracking record. - **containerNumber** (string) - The container number associated with the fumigation. - **noticeId** (string) - The notice ID related to the fumigation. - **woNumber** (string) - The work order number. - **companyName** (string) - The name of the company. - **companyEmail** (string) - The email of the company contact. - **location** (string) - The location of the fumigation. - **progressStatus** (string) - The current progress status of the fumigation (e.g., PENDING, GASSING, AERATION, READY, COMPLETED). - **gassingTime** (string) - Timestamp when gassing started (ISO 8601 format). - **aerationStartTime** (string) - Timestamp when aeration started (ISO 8601 format). - **containerReadyTime** (string) - Timestamp when the container is ready (ISO 8601 format). - **notes** (string) - Additional notes about the fumigation. - **createdAt** (string) - Timestamp when the record was created (ISO 8601 format). - **updatedAt** (string) - Timestamp when the record was last updated (ISO 8601 format). #### Response Example ```json { "success": true, "data": [ { "id": "track123", "containerNumber": "MSKU1234567", "noticeId": "NID2024001", "woNumber": "WO-2024-001", "companyName": "PT Example Corp", "companyEmail": "client@company.com", "location": "Jakarta Port", "progressStatus": "GASSING", "gassingTime": "2024-06-15T08:00:00.000Z", "aerationStartTime": null, "containerReadyTime": null, "notes": "Container fumigation in progress", "createdAt": "2024-06-15T07:00:00.000Z", "updatedAt": "2024-06-15T08:00:00.000Z" } ] } ``` ``` -------------------------------- ### Required Environment Variables for Application Source: https://github.com/hayzxc/prana-webaccess/blob/main/DEPLOYMENT.md Lists the mandatory environment variables for the application's core functionalities, including authentication, database access, and file uploads. These variables are crucial for the application to run correctly and securely. ```env # Authentication NEXTAUTH_SECRET=your-nextauth-secret NEXTAUTH_URL=https://your-domain.com # Database DATABASE_URL=postgresql://user:password@host:port/database SUPABASE_URL=https://your-project.supabase.co SUPABASE_ANON_KEY=your-anon-key SUPABASE_SERVICE_ROLE_KEY=your-service-role-key # File Upload UPLOAD_MAX_SIZE=10485760 ALLOWED_FILE_TYPES=pdf,jpg,jpeg,png,doc,docx ``` -------------------------------- ### Get Field Suggestions for Certificates Source: https://context7.com/hayzxc/prana-webaccess/llms.txt Retrieves autocomplete suggestions for various form fields related to certificates. This is useful for implementing type-ahead search functionalities. Supported fields include recipientEmail, recipientName, location, containerNumber, noticeId, woNumber, companyName, and companyEmail. ```bash # Get email suggestions curl -X GET "http://localhost:3000/api/certificates/suggestions?field=recipientEmail&query=client" \ -H "Cookie: auth-token=" ``` -------------------------------- ### Get All Fumigation Tracking Records Source: https://context7.com/hayzxc/prana-webaccess/llms.txt Retrieves a list of all fumigation tracking records. Access is restricted based on user role: administrators can view all records, while regular users can only see records associated with their email address. ```bash # Get fumigation trackings (requires auth) curl -X GET http://localhost:3000/api/fumigation-trackings \ -H "Cookie: auth-token=" ``` -------------------------------- ### Generate JWT Secret (Bash) Source: https://github.com/hayzxc/prana-webaccess/blob/main/SETUP.md Generates a secure random base64 encoded string to be used as the JWT secret. This command requires OpenSSL to be installed. ```bash openssl rand -base64 32 ``` -------------------------------- ### Create User (POST) Source: https://context7.com/hayzxc/prana-webaccess/llms.txt Creates a new user account with specified details including name, email, password, and role. Requires admin authentication. Returns the created user object or an error. ```bash curl -X POST http://localhost:3000/api/users \ -H "Content-Type: application/json" \ -H "Cookie: auth-token=" \ -d '{ "name": "Jane Smith", "email": "jane@example.com", "password": "securePass456", "role": "USER" }' ``` -------------------------------- ### Clone Repository - Bash Source: https://github.com/hayzxc/prana-webaccess/blob/main/README.md Clones the Prana-webaccess repository from GitHub and navigates into the project directory. This is the first step in setting up the project locally. ```bash git clone https://github.com/hayzxc/Prana-webaccess.git cd Prana-webaccess ``` -------------------------------- ### Update Fumigation Tracking Status Source: https://context7.com/hayzxc/prana-webaccess/llms.txt Updates the progress status of a fumigation tracking record. This can be used to set aeration start times or mark a container as ready. ```APIDOC ## PATCH /api/fumigation-trackings/{id} ### Description Updates the progress status of a specific fumigation tracking record. This endpoint is used to transition the tracking through different stages like AERATION or READY. ### Method PATCH ### Endpoint /api/fumigation-trackings/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the fumigation tracking record to update. #### Request Body - **progressStatus** (string) - Required - The new progress status to set for the tracking (e.g., "AERATION", "READY"). ### Request Example ```json { "progressStatus": "AERATION" } ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the update was successful. - **data** (object) - Contains the updated fumigation tracking record. - **id** (string) - The tracking ID. - **progressStatus** (string) - The updated progress status. - **aerationStartTime** (string) - The timestamp when aeration started (if applicable). - **containerReadyTime** (string) - The timestamp when the container was ready (if applicable). #### Response Example ```json { "success": true, "data": { "id": "track456", "progressStatus": "AERATION", "aerationStartTime": "2024-06-15T14:00:00.000Z", "containerReadyTime": null } } ``` ``` -------------------------------- ### Create Record Sheet (Bash) Source: https://context7.com/hayzxc/prana-webaccess/llms.txt Creates a new record sheet for a certificate using a POST request. Requires administrator privileges and includes details about the commodity, treatment, and inspection. Returns a 201 Created status on success. ```bash # Create record sheet (admin only) curl -X POST http://localhost:3000/api/record-sheets \ -H "Content-Type: application/json" \ -H "Cookie: auth-token=" \ -d '{ "certificateId": "cert123", "commodity": "Rice", "treatmentDate": "2024-06-16T00:00:00.000Z", "gasType": "Phosphine", "concentration": "3 g/m³", "exposureTime": "72 hours", "temperature": "28°C", "humidity": "70%", "containerNumber": "MSKU9876543", "inspectorName": "user123", "notes": "Extended treatment period" }' ``` -------------------------------- ### Generate Certificate Document API Source: https://context7.com/hayzxc/prana-webaccess/llms.txt Generates a Word document (.docx) from a certificate template. This API accepts a POST request with JSON payload containing all necessary certificate details. The output is a DOCX file, and the Content-Type header indicates the file format. ```bash # Generate certificate document curl -X POST http://localhost:3000/api/generate-certificate \ -H "Content-Type: application/json" \ -d '{ "date issued(dd/mm/yyyy)": "15/06/2024", "Nomer Sertifikat": "CERT-2024-001", "Treatment Number": "TRT-001", "Consigment Link": "CONS-2024-ABC", "seal number": "SEAL-123456", "client_ name": "PT Example Corporation", "client address": "Jl. Sudirman No. 1, Jakarta", "commodity description": "Wheat Grain in Bulk", "commodity country of origin": "Australia", "commodity quantity": "25,000 MT", "port of loading": "Melbourne", "destination country": "Indonesia", "dose": "48 g/m³", "period": "24 hours", "temperature": "25°C", "applied dose": "48 g/m³", "place of fumigation": "Tanjung Priok Port", "Alamat": "Jl. Pelabuhan No. 1, Jakarta Utara", "date and time fumigation commenced": "15/06/2024 08:00", "date and time fumigation completed": "16/06/2024 08:00", "final tlv": "< 1 ppm", "full name": "John Inspector", "date": "16/06/2024", "accreditation number": "ACC-2024-001" }' \ --output certificate.docx # Success response: Returns DOCX file with Content-Type: # application/vnd.openxmlformats-officedocument.wordprocessingml.document ``` -------------------------------- ### POST /api/fumigation-trackings Source: https://context7.com/hayzxc/prana-webaccess/llms.txt Creates a new fumigation tracking record. This endpoint requires administrator privileges. ```APIDOC ## POST /api/fumigation-trackings ### Description Creates a new fumigation tracking record. Admin access required. ### Method POST ### Endpoint `/api/fumigation-trackings` ### Parameters #### Request Body - **containerNumber** (string) - Required - The container number for the fumigation. - **noticeId** (string) - Required - The notice ID related to the fumigation. - **woNumber** (string) - Required - The work order number. - **companyName** (string) - Required - The name of the company. - **companyEmail** (string) - Required - The email of the company contact. - **location** (string) - Required - The location of the fumigation. - **notes** (string) - Optional - Additional notes about the fumigation. ### Request Example ```json { "containerNumber": "MSKU9876543", "noticeId": "NID2024003", "woNumber": "WO-2024-003", "companyName": "PT Client Corp", "companyEmail": "operations@client.com", "location": "Tanjung Priok Port", "notes": "New fumigation request" } ``` ### Response #### Success Response (201 Created) - **success** (boolean) - Indicates if the operation was successful. - **data** (object) - Contains the newly created fumigation tracking record. - **id** (string) - Unique identifier for the tracking record. - **containerNumber** (string) - The container number. - **noticeId** (string) - The notice ID. - **woNumber** (string) - The work order number. - **companyName** (string) - The name of the company. - **companyEmail** (string) - The email of the company contact. - **location** (string) - The location of the fumigation. - **progressStatus** (string) - The initial progress status (defaults to PENDING). - **notes** (string) - Additional notes. - **createdAt** (string) - Timestamp when the record was created (ISO 8601 format). #### Response Example ```json { "success": true, "data": { "id": "track456", "containerNumber": "MSKU9876543", "noticeId": "NID2024003", "woNumber": "WO-2024-003", "companyName": "PT Client Corp", "companyEmail": "operations@client.com", "location": "Tanjung Priok Port", "progressStatus": "PENDING", "notes": "New fumigation request", "createdAt": "2024-06-15T10:00:00.000Z" } } ``` ``` -------------------------------- ### Certificate Management API Source: https://context7.com/hayzxc/prana-webaccess/llms.txt Endpoints for managing fumigation certificates, including retrieving all certificates and creating new ones. ```APIDOC ## GET /api/certificates ### Description Retrieves a list of certificates. Administrators can view all certificates, while regular users can only see certificates addressed to their email. ### Method GET ### Endpoint /api/certificates ### Parameters #### Query Parameters - **Cookie** (string) - Required - The JWT authentication token. ### Request Example ```bash curl -X GET http://localhost:3000/api/certificates \ -H "Cookie: auth-token=" ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the operation was successful. - **data** (array) - An array of certificate objects. - **id** (string) - Certificate unique identifier. - **name** (string) - Name of the certificate. - **recipientEmail** (string) - Email of the certificate recipient. - **recipientName** (string) - Name of the certificate recipient. - **issueDate** (string) - Date the certificate was issued. - **status** (string) - Current status of the certificate (e.g., VALID). - **serviceType** (string) - Type of service provided (e.g., FUMIGATION). - **containerNumber** (string) - Container number associated with the certificate. - **noticeId** (string) - Notice ID. - **woNumber** (string) - Work Order number. - **progressStatus** (string) - Current progress status (e.g., READY). - **gassingTime** (string) - Timestamp of gassing. - **aerationStartTime** (string) - Timestamp when aeration started. - **containerReadyTime** (string) - Timestamp when the container is ready. - **issuedBy** (object) - Information about the issuer. - **id** (string) - Issuer's unique identifier. - **name** (string) - Issuer's name. - **email** (string) - Issuer's email. #### Response Example ```json { "success": true, "data": [ { "id": "cert123", "name": "Fumigation Certificate", "recipientEmail": "client@company.com", "recipientName": "PT Example Corp", "issueDate": "2024-06-01T00:00:00.000Z", "status": "VALID", "serviceType": "FUMIGATION", "containerNumber": "MSKU1234567", "noticeId": "NID2024001", "woNumber": "WO-2024-001", "progressStatus": "READY", "gassingTime": "2024-06-01T08:00:00.000Z", "aerationStartTime": "2024-06-01T14:00:00.000Z", "containerReadyTime": "2024-06-02T11:00:00.000Z", "issuedBy": { "id": "user123", "name": "Admin User", "email": "admin@prana.com" } } ] } ``` ``` ```APIDOC ## POST /api/certificates ### Description Creates a new certificate. This endpoint requires administrator privileges. For fumigation certificates, the container ready time is automatically calculated as 27 hours after the `gassingTime`. ### Method POST ### Endpoint /api/certificates ### Parameters #### Request Body - **name** (string) - Required - The name of the certificate (e.g., "Fumigation Certificate"). - **recipientEmail** (string) - Required - The email address of the recipient. - **recipientName** (string) - Required - The name of the recipient. - **issueDate** (string) - Required - The date the certificate is issued (ISO 8601 format). - **status** (string) - Required - The status of the certificate (e.g., "VALID"). - **serviceType** (string) - Required - The type of service (e.g., "FUMIGATION"). - **containerNumber** (string) - Required - The container number. - **noticeId** (string) - Required - The notice ID. - **woNumber** (string) - Required - The work order number. - **location** (string) - Optional - The location where the service was performed. - **gassingTime** (string) - Optional - The time when gassing occurred (ISO 8601 format). Required for fumigation certificates to calculate ready time. ### Request Example ```json { "name": "Fumigation Certificate", "recipientEmail": "client@company.com", "recipientName": "PT Example Corp", "issueDate": "2024-06-15T00:00:00.000Z", "status": "VALID", "serviceType": "FUMIGATION", "containerNumber": "MSKU7654321", "noticeId": "NID2024002", "woNumber": "WO-2024-002", "location": "Jakarta Port", "gassingTime": "2024-06-15T08:00:00.000Z" } ``` ### Response #### Success Response (201) - **success** (boolean) - Indicates if the operation was successful. - **data** (object) - The newly created certificate object. - **id** (string) - Certificate unique identifier. - **name** (string) - Name of the certificate. - **recipientEmail** (string) - Email of the certificate recipient. - **recipientName** (string) - Name of the certificate recipient. - **issueDate** (string) - Date the certificate was issued. - **status** (string) - Current status of the certificate. - **serviceType** (string) - Type of service provided. - **containerNumber** (string) - Container number. - **noticeId** (string) - Notice ID. - **woNumber** (string) - Work Order number. - **location** (string) - Location of service. - **gassingTime** (string) - Timestamp of gassing. - **containerReadyTime** (string) - Timestamp when the container is ready (calculated). - **issuedBy** (object) - Information about the issuer. - **id** (string) - Issuer's unique identifier. - **name** (string) - Issuer's name. - **email** (string) - Issuer's email. - **message** (string) - A confirmation message. #### Response Example ```json { "success": true, "data": { "id": "cert456", "name": "Fumigation Certificate", "recipientEmail": "client@company.com", "recipientName": "PT Example Corp", "issueDate": "2024-06-15T00:00:00.000Z", "status": "VALID", "serviceType": "FUMIGATION", "containerNumber": "MSKU7654321", "noticeId": "NID2024002", "woNumber": "WO-2024-002", "location": "Jakarta Port", "gassingTime": "2024-06-15T08:00:00.000Z", "containerReadyTime": "2024-06-16T11:00:00.000Z", "issuedBy": { "id": "admin_user_id", "name": "Admin User", "email": "admin@prana.com" } }, "message": "Certificate created successfully" } ``` ``` -------------------------------- ### Create New Fumigation Tracking Record Source: https://context7.com/hayzxc/prana-webaccess/llms.txt Creates a new record for fumigation tracking. This endpoint requires administrator privileges and accepts a JSON payload with details of the fumigation. ```bash # Create fumigation tracking (admin only) curl -X POST http://localhost:3000/api/fumigation-trackings \ -H "Content-Type: application/json" \ -H "Cookie: auth-token=" \ -d '{ "containerNumber": "MSKU9876543", "noticeId": "NID2024003", "woNumber": "WO-2024-003", "companyName": "PT Client Corp", "companyEmail": "operations@client.com", "location": "Tanjung Priok Port", "notes": "New fumigation request" }' ``` -------------------------------- ### Upload File API Source: https://context7.com/hayzxc/prana-webaccess/llms.txt Uploads a file using the UploadThing service. This endpoint requires admin access, indicated by an 'auth-token' in the cookie. It accepts a multipart/form-data request with the file. Success returns a URL and file details; errors like no file return a 400 status. ```bash # Upload file (admin only) curl -X POST http://localhost:3000/api/upload \ -H "Cookie: auth-token=" \ -F "file=@/path/to/certificate.pdf" # Success response (200) { "success": true, "url": "https://utfs.io/f/abc123xyz", "fileName": "certificate.pdf", "fileSize": 245678 } # Error - no file (400) { "success": false, "message": "No file uploaded" } ``` -------------------------------- ### Create Consultation Request (Bash) Source: https://context7.com/hayzxc/prana-webaccess/llms.txt Submits a new consultation request. This is a public endpoint, meaning no authentication is required. It accepts a JSON payload with customer details and service requirements, returning a 201 Created status. ```bash # Submit consultation request (public) curl -X POST http://localhost:3000/api/consultation-requests \ -H "Content-Type: application/json" \ -d '{ "customerName": "Ahmad Supplier", "customerEmail": "ahmad@supplier.com", "customerPhone": "+62898765432", "companyName": "PT Supplier Indonesia", "serviceType": "CARGO_SURVEY", "message": "Requesting cargo survey for incoming shipment from China" }' ``` -------------------------------- ### File Upload API Source: https://context7.com/hayzxc/prana-webaccess/llms.txt Handles file uploads using UploadThing. Requires admin access. ```APIDOC ## POST /api/upload ### Description Uploads a file using UploadThing. Admin access required. ### Method POST ### Endpoint `/api/upload` ### Parameters #### Headers - **Cookie** (string) - Required - Authentication token for admin access (e.g., `auth-token=`) #### Form Data - **file** (file) - Required - The file to upload. ### Request Example ```bash # Upload file (admin only) curl -X POST http://localhost:3000/api/upload \ -H "Cookie: auth-token=" \ -F "file=@/path/to/certificate.pdf" ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the upload was successful. - **url** (string) - The URL of the uploaded file. - **fileName** (string) - The name of the uploaded file. - **fileSize** (integer) - The size of the uploaded file in bytes. #### Error Response (400) - **success** (boolean) - Indicates if the upload was successful. - **message** (string) - Error message if no file was uploaded. #### Response Example (Success) ```json { "success": true, "url": "https://utfs.io/f/abc123xyz", "fileName": "certificate.pdf", "fileSize": 245678 } ``` #### Response Example (Error) ```json { "success": false, "message": "No file uploaded" } ``` ```