### Install dependencies Source: https://github.com/dreiiiiim/wash-and-go-front-back/blob/main/wash-and-go-SE2/README.md Install all required project dependencies using npm. ```bash npm install ``` -------------------------------- ### Run the development server Source: https://github.com/dreiiiiim/wash-and-go-front-back/blob/main/wash-and-go-SE2/README.md Start the local development server. ```bash npm run dev ``` -------------------------------- ### GET /api/auth/google Source: https://context7.com/dreiiiiim/wash-and-go-front-back/llms.txt Initiates the Google OAuth authentication flow. ```APIDOC ## GET /api/auth/google ### Description Initiates the Google OAuth 2.0 authentication process. This endpoint redirects the user to Google's sign-in page. After successful authentication with Google, the user will be redirected back to the specified `redirectTo` URL with authentication tokens. ### Method GET ### Endpoint /api/auth/google ### Query Parameters - **redirectTo** (string) - Required - The URL to redirect the user to after successful Google authentication. This URL should be configured to handle the authentication callback. ### Request Example ```bash # Redirect user to Google OAuth (browser redirect) # Frontend initiates this by navigating to: curl -I "http://localhost:3001/api/auth/google?redirectTo=http://localhost:5173/auth/callback" ``` ### Response #### Success Response (302) - **Location** (header) - The URL to Google's OAuth consent screen. #### Response Example ``` HTTP/1.1 302 Found Location: https://accounts.google.com/o/oauth2/v2/auth?... ``` ``` -------------------------------- ### Get All Services Source: https://context7.com/dreiiiiim/wash-and-go-front-back/llms.txt Retrieves a list of all active services, including their pricing information organized by category. ```bash curl http://localhost:3001/api/services ``` -------------------------------- ### GET /api/services Source: https://context7.com/dreiiiiim/wash-and-go-front-back/llms.txt Retrieves all active service packages with pricing information. ```APIDOC ## GET /api/services ### Description Fetches a list of all available services, categorized by LUBE, GROOMING, and COATING, including their pricing details. ### Method GET ### Endpoint /api/services ### Response #### Success Response (200) - **id** (string) - Unique identifier for the service. - **category** (string) - The category of the service (e.g., LUBE, GROOMING, COATING). - **name** (string) - The name of the service. - **description** (string) - A detailed description of the service. - **durationHours** (integer) - The estimated duration of the service in hours. - **vehicleType** (string) - The type of vehicle the service is applicable to. - **isLubeFlat** (boolean) - Indicates if lube pricing is flat rate. - **prices** (object) - Pricing details for different vehicle sizes (SMALL, MEDIUM, LARGE, EXTRA_LARGE). - **lubePrices** (object) - Fuel-based pricing for lube services (GAS, DIESEL). #### Response Example ```json [ { "id": "grooming-interior", "category": "GROOMING", "name": "Interior Detailing", "description": "Deep cleaning of seats, carpets, dashboard, and sanitation.", "durationHours": 3, "vehicleType": "VEHICLE", "isLubeFlat": false, "prices": { "SMALL": 2700, "MEDIUM": 3700, "LARGE": 4500, "EXTRA_LARGE": 5200 } } ] ``` ``` -------------------------------- ### Get All Bookings (Admin) Source: https://context7.com/dreiiiiim/wash-and-go-front-back/llms.txt Retrieves all bookings in the system. This endpoint requires admin authentication and supports filtering by status and date. ```bash # Get all bookings (admin only) curl http://localhost:3001/api/bookings \ -H "Authorization: Bearer YOUR_SUPABASE_JWT_TOKEN" ``` ```bash # Get bookings filtered by status curl "http://localhost:3001/api/bookings?status=PENDING" \ -H "Authorization: Bearer YOUR_SUPABASE_JWT_TOKEN" ``` -------------------------------- ### React Project Imports Configuration Source: https://github.com/dreiiiiim/wash-and-go-front-back/blob/main/wash-and-go-SE2/index.html Configuration for importing React and related libraries using esm.sh. This setup is common for modern React projects using module loading. ```json { "imports": { "react": "https://esm.sh/react@^19.2.4", "react-dom/": "https://esm.sh/react-dom@^19.2.4/", "react/": "https://esm.sh/react@^19.2.4/", "lucide-react": "https://esm.sh/lucide-react@^0.564.0", "date-fns": "https://esm.sh/date-fns@^4.1.0" } } ``` -------------------------------- ### Frontend API Client Usage Examples Source: https://context7.com/dreiiiiim/wash-and-go-front-back/llms.txt Demonstrates how to use the typed frontend API client for various backend operations, including fetching services, creating bookings, and checking status. Assumes automatic token handling. ```typescript import { api } from './lib/api'; // Fetch all services const services = await api.getServices(); console.log(services); // [{ id: 'grooming-full', name: 'Full Detailing', prices: {...} }, ...] // Create a booking (with optional auth token) const booking = await api.createBooking({ customerName: 'Juan Dela Cruz', customerPhone: '09171234567', serviceId: 'grooming-full', vehicleSize: 'MEDIUM', vehicleType: 'VEHICLE', date: '2024-02-15', timeSlot: '09:00 AM', plateNumber: 'ABC-1234', paymentMethod: 'gcash', paymentProofUrl: 'proofs/1707987654321-proof.jpg' }, userToken); console.log(`Booking created: ${booking.id}`); // Booking created: BK-123456 // Check booking status by ID (public endpoint) const status = await api.getBookingById('BK-123456'); console.log(`Status: ${status.status}`); // Status: PENDING // Get booked time slots for a date and category const bookedSlots = await api.getBookedSlots('2024-02-15', 'GROOMING'); console.log('Unavailable slots:', bookedSlots); // Unavailable slots: ['09:00 AM', '02:00 PM'] // Admin: Get all bookings const allBookings = await api.getAllBookings(adminToken); // Admin: Update booking status const updated = await api.updateStatus('BK-123456', 'CONFIRMED', adminToken); // Customer: Get my bookings const myBookings = await api.getMyBookings(userToken); // Admin: Update service pricing await api.updateService('grooming-full', { price_small: 5800, price_medium: 7600 }, adminToken); ``` -------------------------------- ### GET /api/storage/view-url Source: https://context7.com/dreiiiiim/wash-and-go-front-back/llms.txt Generates a signed URL for viewing a payment proof image. Valid for 1 hour. ```APIDOC ## GET /api/storage/view-url ### Description Generates a signed URL for viewing a payment proof image. Valid for 1 hour. Requires admin authentication. ### Method GET ### Endpoint /api/storage/view-url ### Parameters #### Query Parameters - **path** (string) - Required - The storage path of the image to view. ### Request Example curl "http://localhost:3001/api/storage/view-url?path=proofs/1707987654321-proof.jpg" -H "Authorization: Bearer YOUR_ADMIN_JWT_TOKEN" ### Response #### Success Response (200) - **url** (string) - The signed URL for viewing the image. ``` -------------------------------- ### GET /api/services/{id} Source: https://context7.com/dreiiiiim/wash-and-go-front-back/llms.txt Retrieves details for a specific service package by its ID. ```APIDOC ## GET /api/services/{id} ### Description Fetches the details of a single service package using its unique identifier. ### Method GET ### Endpoint /api/services/{id} ### Path Parameters - **id** (string) - Required - The unique identifier of the service to retrieve. ### Response #### Success Response (200) - **id** (string) - Unique identifier for the service. - **category** (string) - The category of the service. - **name** (string) - The name of the service. - **description** (string) - A detailed description of the service. - **durationHours** (integer) - The estimated duration of the service in hours. - **vehicleType** (string) - The type of vehicle the service is applicable to. - **prices** (object) - Pricing details for different vehicle sizes. #### Response Example ```json { "id": "ceramic-3yr-vehicle", "category": "COATING", "name": "Ceramic Coating (3 Years) — Vehicle", "description": "Standard car wash, asphalt removal, exterior detailing...", "durationHours": 8, "vehicleType": "VEHICLE", "prices": { "SMALL": 11000, "MEDIUM": 12000, "LARGE": 13000, "EXTRA_LARGE": 15000 } } ``` ``` -------------------------------- ### Get My Bookings Source: https://context7.com/dreiiiiim/wash-and-go-front-back/llms.txt Retrieves all bookings associated with the currently authenticated user. Requires authentication. ```bash curl http://localhost:3001/api/bookings/my-bookings \ -H "Authorization: Bearer YOUR_SUPABASE_JWT_TOKEN" ``` -------------------------------- ### Initiate Google OAuth Login Source: https://context7.com/dreiiiiim/wash-and-go-front-back/llms.txt Starts the Google OAuth authentication process. This endpoint redirects the user to Google's sign-in page. The `redirectTo` parameter specifies the callback URL after authentication. ```bash curl -I "http://localhost:3001/api/auth/google?redirectTo=http://localhost:5173/auth/callback" ``` -------------------------------- ### Get Service by ID Source: https://context7.com/dreiiiiim/wash-and-go-front-back/llms.txt Retrieves detailed information for a specific service package using its unique ID. ```bash curl http://localhost:3001/api/services/ceramic-3yr-vehicle ``` -------------------------------- ### GET /api/auth/me Source: https://context7.com/dreiiiiim/wash-and-go-front-back/llms.txt Retrieves the profile information of the currently authenticated user. ```APIDOC ## GET /api/auth/me ### Description Fetches the profile details of the user authenticated via Supabase JWT. Requires a valid JWT token in the Authorization header. ### Method GET ### Endpoint /api/auth/me ### Request Example ```bash curl http://localhost:3001/api/auth/me \ -H "Authorization: Bearer YOUR_SUPABASE_JWT_TOKEN" ``` ### Response #### Success Response (200) - **id** (string) - The unique identifier of the user. - **email** (string) - The email address of the user. - **user_metadata** (object) - An object containing additional user information like full name and avatar URL. - **full_name** (string) - The user's full name. - **avatar_url** (string) - The URL of the user's avatar. #### Response Example ```json { "id": "uuid-of-user", "email": "user@example.com", "user_metadata": { "full_name": "Juan Dela Cruz", "avatar_url": "https://..." } } ``` ``` -------------------------------- ### Get Bookings by Date and Status Source: https://context7.com/dreiiiiim/wash-and-go-front-back/llms.txt Retrieves bookings filtered by a specific date and status. Requires an authorization token. ```bash curl "http://localhost:3001/api/bookings?date=2024-02-15&status=CONFIRMED" \ -H "Authorization: Bearer YOUR_SUPABASE_JWT_TOKEN" ``` -------------------------------- ### Get Signed URL for Uploading Payment Proof Source: https://context7.com/dreiiiiim/wash-and-go-front-back/llms.txt Use this endpoint to obtain a pre-signed URL for uploading payment proof images to storage. Requires a JWT token for authorization. ```bash curl -X POST "http://localhost:3001/api/storage/upload-url?fileName=proof.jpg" \ -H "Authorization: Bearer YOUR_SUPABASE_JWT_TOKEN" ``` -------------------------------- ### GET /api/bookings/my-bookings Source: https://context7.com/dreiiiiim/wash-and-go-front-back/llms.txt Retrieves all bookings for the authenticated user (customer). Requires authentication. ```APIDOC ## GET /api/bookings/my-bookings ### Description Retrieves a list of all bookings associated with the currently authenticated customer. Requires a valid JWT token in the Authorization header. ### Method GET ### Endpoint /api/bookings/my-bookings ### Request Example ```bash curl http://localhost:3001/api/bookings/my-bookings \ -H "Authorization: Bearer YOUR_SUPABASE_JWT_TOKEN" ``` ### Response #### Success Response (200) - **id** (string) - The unique identifier for the booking. - **serviceName** (string) - The name of the service booked. - **status** (string) - The current status of the booking. - **date** (string) - The date of the booking. #### Response Example ```json [ { "id": "BK-123456", "serviceName": "Full Detailing", "status": "COMPLETED", "date": "2024-02-10", "...": "..." } ] ``` ``` -------------------------------- ### GET /api/bookings Source: https://context7.com/dreiiiiim/wash-and-go-front-back/llms.txt Retrieves bookings for a specific date and status. Requires authentication. ```APIDOC ## GET /api/bookings ### Description Retrieves bookings filtered by date and status. Requires an Authorization header with a valid JWT token. ### Method GET ### Endpoint /api/bookings ### Query Parameters - **date** (string) - Required - The date to filter bookings by (e.g., YYYY-MM-DD). - **status** (string) - Optional - The status to filter bookings by (e.g., CONFIRMED, PENDING). ### Request Example ```bash curl "http://localhost:3001/api/bookings?date=2024-02-15&status=CONFIRMED" \ -H "Authorization: Bearer YOUR_SUPABASE_JWT_TOKEN" ``` ### Response #### Success Response (200) - **id** (string) - The unique identifier for the booking. - **customerName** (string) - The name of the customer. - **status** (string) - The current status of the booking. #### Response Example ```json [ { "id": "BK-123456", "customerName": "Juan Dela Cruz", "status": "CONFIRMED", "...": "..." } ] ``` ``` -------------------------------- ### GET /api/storage/upload-url Source: https://context7.com/dreiiiiim/wash-and-go-front-back/llms.txt Generates a signed URL for uploading files to Supabase Storage. ```APIDOC ## GET /api/storage/upload-url ### Description Generates a pre-signed URL that allows authenticated users to upload files directly to Supabase Storage. This is typically used for uploading proof of payment images. ### Method GET ### Endpoint /api/storage/upload-url ### Query Parameters - **fileName** (string) - Required - The desired name for the file being uploaded. - **contentType** (string) - Required - The MIME type of the file (e.g., `image/jpeg`, `image/png`). ### Request Example ```bash # Request upload URL for a JPG image curl "http://localhost:3001/api/storage/upload-url?fileName=payment_proof.jpg&contentType=image/jpeg" \ -H "Authorization: Bearer YOUR_SUPABASE_JWT_TOKEN" ``` ### Response #### Success Response (200) - **uploadUrl** (string) - The signed URL for uploading the file. - **publicUrl** (string) - The public URL where the file will be accessible after upload. #### Response Example ```json { "uploadUrl": "https://your-supabase-storage-url/path/to/object?signature=...", "publicUrl": "https://your-supabase-storage-url/path/to/object" } ``` ``` -------------------------------- ### Get Signed URL for Viewing Payment Proof Source: https://context7.com/dreiiiiim/wash-and-go-front-back/llms.txt Generates a signed URL to view a specific payment proof image. This URL is valid for 1 hour and requires an admin JWT token. ```bash curl "http://localhost:3001/api/storage/view-url?path=proofs/1707987654321-proof.jpg" \ -H "Authorization: Bearer YOUR_ADMIN_JWT_TOKEN" ``` -------------------------------- ### Get Upload URL for Storage Source: https://context7.com/dreiiiiim/wash-and-go-front-back/llms.txt Generates a signed URL for uploading images to Supabase Storage, typically used for payment proofs. Authentication is required. ```bash curl ``` -------------------------------- ### Get All Bookings (Admin) API Source: https://context7.com/dreiiiiim/wash-and-go-front-back/llms.txt Retrieves all bookings made in the system. This endpoint supports optional filtering by booking status and date, and requires administrator authentication. ```APIDOC ## GET /api/bookings ### Description Retrieves all bookings with optional filtering by status and date. Requires admin authentication. ### Method GET ### Endpoint /api/bookings ### Parameters #### Query Parameters - **status** (string) - Optional - Filters bookings by their status (e.g., "PENDING", "CONFIRMED"). - **date** (string) - Optional - Filters bookings by date (YYYY-MM-DD). #### Headers - **Authorization** (string) - Required - Bearer token for authentication (e.g., "Bearer YOUR_SUPABASE_JWT_TOKEN"). ### Response #### Success Response (200) - An array of booking objects, each containing details similar to the 'Get Booking by ID' response. #### Response Example ```json [ { "id": "BK-123456", "customerName": "Juan Dela Cruz", "customerPhone": "09171234567", "serviceId": "grooming-full", "serviceName": "Full Detailing", "vehicleSize": "MEDIUM", "vehicleType": "VEHICLE", "vehicleCategory": "Car", "fuelType": null, "oilType": null, "date": "2024-02-15", "timeSlot": "09:00 AM", "plateNumber": "ABC-1234", "totalPrice": 7300, "downPaymentAmount": 2190, "status": "PENDING", "paymentMethod": "gcash", "paymentProofUrl": "proofs/1707987654321-proof.jpg", "createdAt": 1707987654321 } ] ``` ``` -------------------------------- ### Get Current User Profile Source: https://context7.com/dreiiiiim/wash-and-go-front-back/llms.txt Retrieves the profile information of the currently authenticated user. A valid Supabase JWT token is required for authentication. ```bash curl http://localhost:3001/api/auth/me \ -H "Authorization: Bearer YOUR_SUPABASE_JWT_TOKEN" ``` -------------------------------- ### Get Booking by ID Source: https://context7.com/dreiiiiim/wash-and-go-front-back/llms.txt Retrieves a specific booking's details using its unique ID. This endpoint is publicly accessible and does not require authentication, allowing customers to check their booking status. ```bash # Get booking details by ID curl http://localhost:3001/api/bookings/BK-123456 ``` -------------------------------- ### Get Booking by ID API Source: https://context7.com/dreiiiiim/wash-and-go-front-back/llms.txt Retrieves the details of a single booking using its unique ID. This endpoint is publicly accessible and does not require authentication, allowing customers to check their booking status. ```APIDOC ## GET /api/bookings/{id} ### Description Retrieves a single booking by its ID. This endpoint is public and used for customers to check their booking status without authentication. ### Method GET ### Endpoint /api/bookings/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the booking (e.g., "BK-123456"). ### Response #### Success Response (200) - **id** (string) - The unique identifier for the booking. - **customerName** (string) - The name of the customer. - **customerPhone** (string) - The phone number of the customer. - **serviceId** (string) - The ID of the service booked. - **serviceName** (string) - The name of the service booked. - **vehicleSize** (string) - The size of the vehicle. - **vehicleType** (string) - The type of vehicle. - **vehicleCategory** (string) - The category of the vehicle. - **fuelType** (string | null) - The fuel type of the vehicle. - **oilType** (string | null) - The type of oil for lube services. - **date** (string) - The date of the booking. - **timeSlot** (string) - The time slot of the booking. - **plateNumber** (string | null) - The license plate number of the vehicle. - **totalPrice** (number) - The total calculated price for the service. - **downPaymentAmount** (number) - The required down payment amount. - **status** (string) - The current status of the booking. - **paymentProofUrl** (string | null) - The URL or path to the payment proof image. - **paymentMethod** (string | null) - The method of payment. - **createdAt** (number) - Timestamp of when the booking was created. #### Response Example ```json { "id": "BK-123456", "customerName": "Juan Dela Cruz", "customerPhone": "09171234567", "serviceId": "grooming-full", "serviceName": "Full Detailing", "vehicleSize": "MEDIUM", "vehicleType": "VEHICLE", "vehicleCategory": "Car", "fuelType": null, "oilType": null, "date": "2024-02-15", "timeSlot": "09:00 AM", "plateNumber": "ABC-1234", "totalPrice": 7300, "downPaymentAmount": 2190, "status": "CONFIRMED", "paymentProofUrl": "proofs/1707987654321-proof.jpg", "paymentMethod": "gcash", "createdAt": 1707987654321 } ``` ``` -------------------------------- ### Get Booked Slots for a Service Category Source: https://context7.com/dreiiiiim/wash-and-go-front-back/llms.txt Fetches a list of time slots that are fully booked for a specified date and service category. This is used by the frontend to disable unavailable slots in the booking calendar. ```bash # Get booked slots for grooming services on a specific date curl "http://localhost:3001/api/bookings/booked-slots?date=2024-02-15&category=GROOMING" ``` ```bash # Get booked slots for lube services (capacity: 1) curl "http://localhost:3001/api/bookings/booked-slots?date=2024-02-15&category=LUBE" ``` -------------------------------- ### Get Booked Slots API Source: https://context7.com/dreiiiiim/wash-and-go-front-back/llms.txt Returns a list of time slots that are fully booked for a specific date and service category. This is used by the frontend to disable unavailable slots in the scheduling calendar. ```APIDOC ## GET /api/bookings/booked-slots ### Description Returns an array of time slots that are fully booked for a given date and service category. Used by the frontend to disable unavailable time slots in the scheduling calendar. ### Method GET ### Endpoint /api/bookings/booked-slots ### Parameters #### Query Parameters - **date** (string) - Required - The date to check for booked slots (YYYY-MM-DD). - **category** (string) - Required - The service category (e.g., "GROOMING", "LUBE", "COATING"). ### Response #### Success Response (200) - An array of strings, where each string represents a fully booked time slot (e.g., ["09:00 AM", "10:00 AM"]). #### Response Example ```json ["09:00 AM", "10:00 AM", "02:00 PM"] ``` ``` -------------------------------- ### Clone the repository Source: https://github.com/dreiiiiim/wash-and-go-front-back/blob/main/wash-and-go-SE2/README.md Download the project source code and navigate into the directory. ```bash git clone cd wash-and-go-SE2 ``` -------------------------------- ### Configure environment variables Source: https://github.com/dreiiiiim/wash-and-go-front-back/blob/main/wash-and-go-SE2/README.md Define the Gemini API key in a .env.local file. ```text GEMINI_API_KEY=your_api_key_here ``` -------------------------------- ### Upload File Using Signed URL Source: https://context7.com/dreiiiiim/wash-and-go-front-back/llms.txt After obtaining a signed URL, use this command to upload the actual file. Ensure the Content-Type header matches the file type. ```bash curl -X PUT "SIGNED_URL_FROM_ABOVE" \ -H "Content-Type: image/jpeg" \ --data-binary @/path/to/proof.jpg ``` -------------------------------- ### Create Services Table with Pricing by Vehicle Size Source: https://context7.com/dreiiiiim/wash-and-go-front-back/llms.txt Defines the 'services' table to store details about available services, including category, name, description, duration, and pricing tiers based on vehicle size. It also supports fuel-type specific pricing for lube services. ```sql CREATE TABLE public.services ( id TEXT PRIMARY KEY, category TEXT NOT NULL CHECK (category IN ('LUBE', 'GROOMING', 'COATING')), name TEXT NOT NULL, description TEXT, duration_hours INT NOT NULL, price_small INT NOT NULL, price_medium INT NOT NULL, price_large INT NOT NULL, price_extra_large INT NOT NULL, is_lube_flat BOOLEAN DEFAULT FALSE, lube_prices JSONB, -- {"GAS": 1650, "DIESEL": 2250} vehicle_type TEXT, -- 'VEHICLE' or 'MOTORCYCLE' is_active BOOLEAN NOT NULL DEFAULT TRUE, created_at TIMESTAMP WITH TIME ZONE DEFAULT timezone('utc', now()) ); ``` -------------------------------- ### Create Grooming Service Booking Source: https://context7.com/dreiiiiim/wash-and-go-front-back/llms.txt Use this endpoint to create a new grooming service booking. It automatically calculates prices and validates time slot availability. Requires customer details, service ID, vehicle information, date, time, and payment details. ```bash # Create a grooming service booking curl -X POST http://localhost:3001/api/bookings \ -H "Content-Type: application/json" \ -d '{ "customerName": "Juan Dela Cruz", "customerPhone": "09171234567", "serviceId": "grooming-full", "vehicleSize": "MEDIUM", "vehicleType": "VEHICLE", "date": "2024-02-15", "timeSlot": "09:00 AM", "plateNumber": "ABC-1234", "paymentMethod": "gcash", "paymentProofUrl": "proofs/1707987654321-proof.jpg" }' ``` -------------------------------- ### POST /api/storage/upload-url Source: https://context7.com/dreiiiiim/wash-and-go-front-back/llms.txt Generates a signed URL for uploading a payment proof image to storage. ```APIDOC ## POST /api/storage/upload-url ### Description Generates a signed URL for uploading a payment proof image to storage. ### Method POST ### Endpoint /api/storage/upload-url ### Parameters #### Query Parameters - **fileName** (string) - Required - The name of the file to be uploaded. ### Request Example curl -X POST "http://localhost:3001/api/storage/upload-url?fileName=proof.jpg" -H "Authorization: Bearer YOUR_SUPABASE_JWT_TOKEN" ### Response #### Success Response (200) - **signedUrl** (string) - The URL to use for the PUT upload request. - **path** (string) - The storage path for the uploaded file. #### Response Example { "signedUrl": "https://your-project.supabase.co/storage/v1/upload/sign/payment-proofs/proofs/1707987654321-proof.jpg?token=...", "path": "proofs/1707987654321-proof.jpg" } ``` -------------------------------- ### Create Lube Service Booking Source: https://context7.com/dreiiiiim/wash-and-go-front-back/llms.txt Use this endpoint to create a new lube service booking, specifying optional fuel and oil types. It calculates prices and checks time slot availability. Requires customer details, service ID, vehicle information, date, and time. ```bash # Create a lube service booking with fuel type curl -X POST http://localhost:3001/api/bookings \ -H "Content-Type: application/json" \ -d '{ "customerName": "Maria Santos", "customerPhone": "09181234567", "serviceId": "lube-premium-fully-synthetic", "vehicleSize": "LARGE", "vehicleType": "VEHICLE", "fuelType": "DIESEL", "oilType": "FULLY_SYNTHETIC", "date": "2024-02-16", "timeSlot": "10:00 AM" }' ``` -------------------------------- ### Update Service Details Source: https://context7.com/dreiiiiim/wash-and-go-front-back/llms.txt Updates service details and pricing information. This endpoint requires administrator privileges. ```bash curl -X PATCH http://localhost:3001/api/services/grooming-full \ -H "Authorization: Bearer YOUR_ADMIN_JWT_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "price_small": 5800, "price_medium": 7600, "price_large": 9200, "price_extra_large": 10000 }' ``` ```bash curl -X PATCH http://localhost:3001/api/services/lube-premium-regular \ -H "Authorization: Bearer YOUR_ADMIN_JWT_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "lube_prices": {"GAS": 1750, "DIESEL": 2350} }' ``` -------------------------------- ### Create Profiles Table with Role-Based Access Source: https://context7.com/dreiiiiim/wash-and-go-front-back/llms.txt Defines the 'profiles' table to store user information, including their role which is restricted to 'customer' or 'admin'. ```sql CREATE TABLE public.profiles ( id UUID REFERENCES auth.users ON DELETE CASCADE NOT NULL PRIMARY KEY, full_name TEXT, avatar_url TEXT, phone TEXT, role TEXT NOT NULL DEFAULT 'customer' CHECK (role IN ('customer', 'admin')), created_at TIMESTAMP WITH TIME ZONE DEFAULT timezone('utc', now()), updated_at TIMESTAMP WITH TIME ZONE DEFAULT timezone('utc', now()) ); ``` -------------------------------- ### Create Booking API Source: https://context7.com/dreiiiiim/wash-and-go-front-back/llms.txt Creates a new service booking. The system automatically calculates the price based on the selected service, vehicle size, and fuel type. It also validates time slot availability before confirming the booking. Upon successful creation, a unique booking ID (format: BK-XXXXXX) is returned. ```APIDOC ## POST /api/bookings ### Description Creates a new service booking with automatic price calculation and time slot availability validation. ### Method POST ### Endpoint /api/bookings ### Parameters #### Request Body - **customerName** (string) - Required - The name of the customer. - **customerPhone** (string) - Required - The phone number of the customer. - **serviceId** (string) - Required - The ID of the service to book (e.g., "grooming-full", "lube-premium-fully-synthetic"). - **vehicleSize** (string) - Required - The size of the vehicle (e.g., "MEDIUM", "LARGE"). - **vehicleType** (string) - Required - The type of vehicle (e.g., "VEHICLE"). - **fuelType** (string) - Optional - The fuel type of the vehicle (e.g., "DIESEL"). - **oilType** (string) - Optional - The type of oil for lube services (e.g., "FULLY_SYNTHETIC"). - **date** (string) - Required - The desired date for the booking (YYYY-MM-DD). - **timeSlot** (string) - Required - The desired time slot for the booking (e.g., "09:00 AM"). - **plateNumber** (string) - Optional - The license plate number of the vehicle. - **paymentMethod** (string) - Optional - The method of payment (e.g., "gcash"). - **paymentProofUrl** (string) - Optional - The URL or path to the payment proof image. ### Request Example ```json { "customerName": "Juan Dela Cruz", "customerPhone": "09171234567", "serviceId": "grooming-full", "vehicleSize": "MEDIUM", "vehicleType": "VEHICLE", "date": "2024-02-15", "timeSlot": "09:00 AM", "plateNumber": "ABC-1234", "paymentMethod": "gcash", "paymentProofUrl": "proofs/1707987654321-proof.jpg" } ``` ### Response #### Success Response (200) - **id** (string) - The unique identifier for the booking (format: BK-XXXXXX). - **customerName** (string) - The name of the customer. - **customerPhone** (string) - The phone number of the customer. - **serviceId** (string) - The ID of the service booked. - **serviceName** (string) - The name of the service booked. - **vehicleSize** (string) - The size of the vehicle. - **vehicleType** (string) - The type of vehicle. - **vehicleCategory** (string) - The category of the vehicle. - **fuelType** (string | null) - The fuel type of the vehicle. - **oilType** (string | null) - The type of oil for lube services. - **date** (string) - The date of the booking. - **timeSlot** (string) - The time slot of the booking. - **plateNumber** (string | null) - The license plate number of the vehicle. - **totalPrice** (number) - The total calculated price for the service. - **downPaymentAmount** (number) - The required down payment amount. - **status** (string) - The current status of the booking (e.g., "PENDING", "CONFIRMED"). - **paymentMethod** (string | null) - The method of payment. - **paymentProofUrl** (string | null) - The URL or path to the payment proof image. - **createdAt** (number) - Timestamp of when the booking was created. #### Response Example ```json { "id": "BK-123456", "customerName": "Juan Dela Cruz", "customerPhone": "09171234567", "serviceId": "grooming-full", "serviceName": "Full Detailing", "vehicleSize": "MEDIUM", "vehicleType": "VEHICLE", "vehicleCategory": "Car", "fuelType": null, "oilType": null, "date": "2024-02-15", "timeSlot": "09:00 AM", "plateNumber": "ABC-1234", "totalPrice": 7300, "downPaymentAmount": 2190, "status": "PENDING", "paymentMethod": "gcash", "paymentProofUrl": "proofs/1707987654321-proof.jpg", "createdAt": 1707987654321 } ``` ``` -------------------------------- ### CSS Styling for Wash & Go Baliwag Source: https://github.com/dreiiiiim/wash-and-go-front-back/blob/main/wash-and-go-SE2/index.html Basic CSS for setting the font family and background color. Ensure Inter font is available or provide a fallback. ```css body { font-family: "Inter", sans-serif; background-color: #f5f5f5; } ``` -------------------------------- ### PATCH /api/services/{id} Source: https://context7.com/dreiiiiim/wash-and-go-front-back/llms.txt Updates service details and pricing information. Requires admin authentication. ```APIDOC ## PATCH /api/services/{id} ### Description Updates the details and pricing for a specific service. This operation requires administrator privileges and authentication. ### Method PATCH ### Endpoint /api/services/{id} ### Path Parameters - **id** (string) - Required - The ID of the service to update. ### Request Body - **price_small** (integer) - Optional - Updated price for SMALL vehicle size. - **price_medium** (integer) - Optional - Updated price for MEDIUM vehicle size. - **price_large** (integer) - Optional - Updated price for LARGE vehicle size. - **price_extra_large** (integer) - Optional - Updated price for EXTRA_LARGE vehicle size. - **lube_prices** (object) - Optional - Object containing updated fuel-based lube prices (e.g., `{"GAS": 1750, "DIESEL": 2350}`). ### Request Example ```bash # Update service prices curl -X PATCH http://localhost:3001/api/services/grooming-full \ -H "Authorization: Bearer YOUR_ADMIN_JWT_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "price_small": 5800, "price_medium": 7600, "price_large": 9200, "price_extra_large": 10000 }' ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message indicating the service was updated. #### Response Example ```json { "message": "Service updated successfully." } ``` ``` -------------------------------- ### Check Time Slot Availability Source: https://context7.com/dreiiiiim/wash-and-go-front-back/llms.txt Checks if a specific time slot is available for booking on a given date and for a particular service category. Returns a boolean indicating availability. ```bash # Check if a slot is available curl "http://localhost:3001/api/bookings/availability?date=2024-02-15&timeSlot=09:00%20AM&category=COATING" ``` -------------------------------- ### Create Bookings Table with Slot Uniqueness Constraint Source: https://context7.com/dreiiiiim/wash-and-go-front-back/llms.txt Defines the 'bookings' table to manage customer appointments, including service details, vehicle information, date, time slot, pricing, and status. It enforces constraints on vehicle type, fuel type, oil type, and booking status. ```sql CREATE TABLE public.bookings ( id TEXT PRIMARY KEY, user_id UUID REFERENCES auth.users ON DELETE SET NULL, customer_name TEXT NOT NULL, customer_phone TEXT NOT NULL, service_id TEXT REFERENCES public.services NOT NULL, service_name TEXT NOT NULL, vehicle_size TEXT NOT NULL CHECK (vehicle_size IN ('SMALL', 'MEDIUM', 'LARGE', 'EXTRA_LARGE')), vehicle_type TEXT CHECK (vehicle_type IN ('VEHICLE', 'MOTORCYCLE')), fuel_type TEXT CHECK (fuel_type IN ('GAS', 'DIESEL')), oil_type TEXT CHECK (oil_type IN ('REGULAR', 'SEMI_SYNTHETIC', 'FULLY_SYNTHETIC')), date DATE NOT NULL, time_slot TEXT NOT NULL, plate_number TEXT, total_price INT NOT NULL, down_payment_amount INT NOT NULL, status TEXT NOT NULL DEFAULT 'PENDING' CHECK (status IN ('PENDING', 'CONFIRMED', 'IN_PROGRESS', 'CANCELLED', 'COMPLETED')), payment_proof_url TEXT, payment_method TEXT, created_at TIMESTAMP WITH TIME ZONE DEFAULT timezone('utc', now()), updated_at TIMESTAMP WITH TIME ZONE DEFAULT timezone('utc', now()) ); ``` -------------------------------- ### Update Booking Status Source: https://context7.com/dreiiiiim/wash-and-go-front-back/llms.txt Updates the status of a specific booking. This endpoint is restricted to administrators. Valid statuses include PENDING, CONFIRMED, IN_PROGRESS, COMPLETED, and CANCELLED. ```bash curl -X PATCH http://localhost:3001/api/bookings/BK-123456/status \ -H "Authorization: Bearer YOUR_ADMIN_JWT_TOKEN" \ -H "Content-Type: application/json" \ -d '{"status": "CONFIRMED"}' ``` ```bash curl -X PATCH http://localhost:3001/api/bookings/BK-123456/status \ -H "Authorization: Bearer YOUR_ADMIN_JWT_TOKEN" \ -H "Content-Type: application/json" \ -d '{"status": "COMPLETED"}' ``` -------------------------------- ### RLS Policy: Services are publicly readable Source: https://context7.com/dreiiiiim/wash-and-go-front-back/llms.txt Applies a Row Level Security policy to the 'services' table, allowing anyone to read active services. This policy ensures that only services marked as 'is_active = true' are visible to the public. ```sql CREATE POLICY "Services are publicly readable" ON public.services FOR SELECT USING (is_active = true); ``` -------------------------------- ### RLS Policy: Anyone can create a booking Source: https://context7.com/dreiiiiim/wash-and-go-front-back/llms.txt Applies a Row Level Security policy to the 'bookings' table, permitting any user to create a new booking. This policy is set with 'true' to allow all insert operations. ```sql CREATE POLICY "Anyone can create a booking" ON public.bookings FOR INSERT WITH CHECK (true); ``` -------------------------------- ### Check Slot Availability API Source: https://context7.com/dreiiiiim/wash-and-go-front-back/llms.txt Checks if a specific time slot is available for booking on a given date and for a particular service category. ```APIDOC ## GET /api/bookings/availability ### Description Checks if a specific time slot is available for booking on a given date and service category. ### Method GET ### Endpoint /api/bookings/availability ### Parameters #### Query Parameters - **date** (string) - Required - The date to check availability for (YYYY-MM-DD). - **timeSlot** (string) - Required - The specific time slot to check (e.g., "09:00 AM"). - **category** (string) - Required - The service category (e.g., "COATING"). ### Response #### Success Response (200) - **date** (string) - The date checked. - **timeSlot** (string) - The time slot checked. - **available** (boolean) - Indicates if the slot is available (`true`) or not (`false`). - **category** (string) - The service category checked. #### Response Example ```json { "date": "2024-02-15", "timeSlot": "09:00 AM", "available": true, "category": "COATING" } ``` ``` -------------------------------- ### RLS Policy: Users can view own bookings Source: https://context7.com/dreiiiiim/wash-and-go-front-back/llms.txt Applies a Row Level Security policy to the 'bookings' table, enabling authenticated users to view only their own bookings. This is enforced by checking if the 'user_id' in the booking record matches the authenticated user's ID (auth.uid()). ```sql CREATE POLICY "Users can view own bookings" ON public.bookings FOR SELECT USING (user_id = auth.uid()); ``` -------------------------------- ### PATCH /api/bookings/{id}/status Source: https://context7.com/dreiiiiim/wash-and-go-front-back/llms.txt Updates the status of a specific booking. Only accessible by administrators. ```APIDOC ## PATCH /api/bookings/{id}/status ### Description Updates the status of a specified booking. This endpoint is restricted to administrators and requires admin authentication. ### Method PATCH ### Endpoint /api/bookings/{id}/status ### Path Parameters - **id** (string) - Required - The ID of the booking to update. ### Request Body - **status** (string) - Required - The new status for the booking. Valid options: PENDING, CONFIRMED, IN_PROGRESS, COMPLETED, CANCELLED. ### Request Example ```bash # Confirm a pending booking curl -X PATCH http://localhost:3001/api/bookings/BK-123456/status \ -H "Authorization: Bearer YOUR_ADMIN_JWT_TOKEN" \ -H "Content-Type: application/json" \ -d '{"status": "CONFIRMED"}' ``` ### Response #### Success Response (200) - **id** (string) - The ID of the updated booking. - **status** (string) - The new status of the booking. #### Response Example ```json { "id": "BK-123456", "status": "COMPLETED", "...": "..." } ``` ``` -------------------------------- ### TypeScript Core Type Definitions Source: https://context7.com/dreiiiiim/wash-and-go-front-back/llms.txt Defines essential TypeScript enums and interfaces for maintaining type safety across the application, including service categories, vehicle details, and booking statuses. ```typescript // Service categories determine bay capacity enum ServiceCategory { LUBE = 'LUBE', // 1 slot per time GROOMING = 'GROOMING', // 2 slots per time COATING = 'COATING' // 2 slots per time } // Vehicle size affects pricing for non-lube services enum VehicleSize { SMALL = 'SMALL', MEDIUM = 'MEDIUM', LARGE = 'LARGE', EXTRA_LARGE = 'EXTRA_LARGE' } enum VehicleType { VEHICLE = 'VEHICLE', MOTORCYCLE = 'MOTORCYCLE' } enum FuelType { GAS = 'GAS', DIESEL = 'DIESEL' } enum BookingStatus { PENDING = 'PENDING', CONFIRMED = 'CONFIRMED', IN_PROGRESS = 'IN_PROGRESS', CANCELLED = 'CANCELLED', COMPLETED = 'COMPLETED' } // Service package with dual pricing models interface ServicePackage { id: string; category: ServiceCategory; name: string; description: string; durationHours: number; // Size-based pricing for grooming/coating prices: Record; // Flat pricing by fuel type for lube services lubePrices?: Record; isLubeFlat?: boolean; vehicleType?: VehicleType; } // Complete booking record interface Booking { id: string; customerName: string; customerPhone: string; serviceId: string; serviceName: string; vehicleSize: VehicleSize; vehicleType?: VehicleType; fuelType?: FuelType; date: string; // YYYY-MM-DD timeSlot: string; // e.g., "09:00 AM" totalPrice: number; downPaymentAmount: number; status: BookingStatus; paymentProofUrl?: string; paymentMethod?: string; plateNumber?: string; createdAt: number; } // Available time slots const TIME_SLOTS = [ "08:00 AM", "09:00 AM", "10:00 AM", "11:00 AM", "01:00 PM", "02:00 PM", "03:00 PM", "04:00 PM", "05:00 PM" ]; // Down payment is 30% of total price const DOWN_PAYMENT_PERCENTAGE = 0.30; ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.