mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-28 10:10:57 +00:00
fix(companies): honest status errors and per-role suspension visibility
A suspended customer trying to create a contract was told their account was "awaiting approval" - the guards collapsed every non-active status into the pending message. Contract and booking creation now go through a shared assertCompanyActiveFor that names the real company status, and the per-role guard names the role's actual state (suspended, blacklisted, rejected - with the reviewer note) so a customer suspended for one operation knows the others still work. Portal: the operation dropdown gets a Suspended badge, the block modal a suspended branch quoting the staff message, and the wizard a suspended/blacklisted gate instead of falling through to a submit error. EDRFREIGHT-234
This commit is contained in:
@@ -13,7 +13,6 @@ import { YardCountry } from '@edr/types';
|
||||
import { deriveTradeDirection } from '../../common/derive-trade-direction.util';
|
||||
import { CompaniesService } from '../companies/companies.service';
|
||||
import { ProfileType } from '../companies/entities/company-profile.entity';
|
||||
import { CompanyStatus } from '../companies/entities/company.entity';
|
||||
import { ServiceType } from '../rule-engine/entities/service-type.entity';
|
||||
import { Yard } from '../rule-engine/entities/yard.entity';
|
||||
import { FilesService } from '../files/files.service';
|
||||
@@ -181,11 +180,7 @@ export class ContractsService {
|
||||
);
|
||||
}
|
||||
const { company } = await this.companiesService.getCompanyInfoByUserId(userId);
|
||||
if (company.status !== CompanyStatus.Active) {
|
||||
throw new ForbiddenException(
|
||||
"Your company is awaiting approval — you can't create contracts yet.",
|
||||
);
|
||||
}
|
||||
this.companiesService.assertCompanyActiveFor(company, 'contracts');
|
||||
companyId = company.id;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user