import { Response, NextFunction } from 'express'; import { AuthRequest } from '../middleware/auth.middleware'; import { BranchService } from '../services/branch.service'; const branchService = new BranchService(); export class BranchController { public createBranch = async (req: AuthRequest, res: Response, next: NextFunction) => { try { const { organizationId } = req.params; const branch = await branchService.createBranch(organizationId, req.body); res.status(201).json(branch); } catch (err) { next(err); } }; public getBranches = async (req: AuthRequest, res: Response, next: NextFunction) => { try { const { organizationId } = req.params; const branches = await branchService.getOrganizationBranches(organizationId); res.status(200).json(branches); } catch (err) { next(err); } }; public updateBranch = async (req: AuthRequest, res: Response, next: NextFunction) => { try { const { id } = req.params; const branch = await branchService.updateBranch(id, req.body); res.status(200).json(branch); } catch (err) { next(err); } }; public deleteBranch = async (req: AuthRequest, res: Response, next: NextFunction) => { try { const { id } = req.params; await branchService.deleteBranch(id); res.status(200).json({ message: 'Branch deleted successfully' }); } catch (err) { next(err); } }; }