import express from "express";
import {
  getAllClients,
  getClient,
  createClient,
  updateClient,
  deleteClient
} from "../controllers/userController.js";
import { verifyToken } from "../middleware/authMiddleware.js";
import { adminOnly } from "../middleware/roleMiddleware.js";

const router = express.Router();

// GET /clients - admin only
router.get("/", verifyToken, adminOnly, getAllClients);

// GET /clients/:id - any authenticated user (client can view own profile)
router.get("/:id", verifyToken, getClient);

// POST /clients - admin only
router.post("/", verifyToken, adminOnly, createClient);

// PUT /clients/:id - admin only
router.put("/:id", verifyToken, adminOnly, updateClient);

// DELETE /clients/:id - admin only
router.delete("/:id", verifyToken, adminOnly, deleteClient);

export default router;