Minimax correcao
This commit is contained in:
@@ -6,7 +6,7 @@ import '../middleware/authMiddleware.js'; // Ensure type augmentation
|
||||
export const createInspection = async (req: Request, res: Response) => {
|
||||
try {
|
||||
const organizationId = req.appUser?.organizationId;
|
||||
const createdBy = req.appUser?.clerkId;
|
||||
const createdBy = req.appUser?.email || 'guest';
|
||||
const inspection = await inspectionService.createInspection({
|
||||
...req.body,
|
||||
organizationId,
|
||||
@@ -46,17 +46,10 @@ export const getInspectionsByProject = async (req: Request, res: Response) => {
|
||||
export const updateInspection = async (req: Request, res: Response) => {
|
||||
try {
|
||||
const organizationId = req.appUser?.organizationId;
|
||||
const userId = req.appUser?.clerkId;
|
||||
const userRole = req.appUser?.organizationRole || req.appUser?.role;
|
||||
const isDeveloper = req.appUser?.email === 'admtracksteel@gmail.com';
|
||||
|
||||
const inspection = await inspectionService.updateInspection(
|
||||
req.params.id as string,
|
||||
req.body,
|
||||
organizationId,
|
||||
userId,
|
||||
userRole as any,
|
||||
isDeveloper
|
||||
req.body
|
||||
);
|
||||
if (!inspection) return res.status(403).json({ error: 'Não autorizado ou não encontrado.' });
|
||||
res.json(inspection);
|
||||
@@ -69,16 +62,9 @@ export const updateInspection = async (req: Request, res: Response) => {
|
||||
export const deleteInspection = async (req: Request, res: Response) => {
|
||||
try {
|
||||
const organizationId = req.appUser?.organizationId;
|
||||
const userId = req.appUser?.clerkId;
|
||||
const userRole = req.appUser?.organizationRole || req.appUser?.role;
|
||||
const isDeveloper = req.appUser?.email === 'admtracksteel@gmail.com';
|
||||
|
||||
const success = await inspectionService.deleteInspection(
|
||||
req.params.id as string,
|
||||
organizationId,
|
||||
userId,
|
||||
userRole as any,
|
||||
isDeveloper
|
||||
req.params.id as string
|
||||
);
|
||||
if (!success) return res.status(403).json({ error: 'Não autorizado ou não encontrado.' });
|
||||
res.status(204).send();
|
||||
@@ -91,7 +77,9 @@ export const deleteInspection = async (req: Request, res: Response) => {
|
||||
export const getAllInspections = async (req: Request, res: Response) => {
|
||||
try {
|
||||
const organizationId = req.appUser?.organizationId;
|
||||
const inspections = await inspectionService.getAllInspections(organizationId);
|
||||
const inspections = organizationId
|
||||
? await inspectionService.getInspectionsByOrganization(organizationId)
|
||||
: await inspectionService.getInspectionStats();
|
||||
res.json(inspections);
|
||||
} catch (error: unknown) {
|
||||
const message = error instanceof Error ? error.message : 'Unknown error';
|
||||
|
||||
Reference in New Issue
Block a user