import { applyDecorators, UseGuards } from '@nestjs/common';
import { JwtGuard } from '@tria-plc/api-common/modules/auth/services/jwt.guard';

import { FreightPermissionGuard } from './freight-permission.guard';
import {
  FREIGHT_PERMS,
  type RuleEngineResourceSlug,
} from '../seed/freight-permissions.registry';

export const RuleEngineView = (slug: RuleEngineResourceSlug) =>
  applyDecorators(
    UseGuards(JwtGuard, FreightPermissionGuard([FREIGHT_PERMS.ruleEngine.view(slug)])),
  );

export const RuleEngineManage = (slug: RuleEngineResourceSlug) =>
  applyDecorators(
    UseGuards(JwtGuard, FreightPermissionGuard([FREIGHT_PERMS.ruleEngine.manage(slug)])),
  );
