import { FastifyInstance } from 'fastify';
import {
    getSupplyItems,
    getShoppingList,
    getSupplyItem,
    createSupplyItem,
    updateSupplyItem,
    deleteSupplyItem,
    markAsOrdered,
    adjustQuantity,
} from '../controllers/supplies.controller';

export async function suppliesRoutes(server: FastifyInstance) {
    // Get all supply items
    server.get('/supplies', getSupplyItems);

    // Get shopping list (items below threshold)
    server.get('/supplies/shopping-list', getShoppingList);

    // Get single supply item
    server.get('/supplies/:id', getSupplyItem);

    // Create supply item
    server.post('/supplies', createSupplyItem);

    // Update supply item
    server.patch('/supplies/:id', updateSupplyItem);

    // Delete supply item
    server.delete('/supplies/:id', deleteSupplyItem);

    // Mark item as ordered
    server.post('/supplies/:id/order', markAsOrdered);

    // Adjust quantity
    server.post('/supplies/:id/adjust', adjustQuantity);
}
