forked from Yara724/api
dynamic locations
This commit is contained in:
@@ -172,6 +172,9 @@ describe("management accounts, optional Fanavaran fields and tenant boundaries",
|
||||
it.each([
|
||||
["file_maker", "ThirdPartyClaimExpertId", "CarBodyClaimExpertId"],
|
||||
["file_reviewer", "ThirdPartyExpertiseClaim", "CarBodyExpertiseClaim"],
|
||||
["expert", "ThirdPartyClaimExpertId", "CarBodyClaimExpertId"],
|
||||
["damage_expert", "ThirdPartyClaimExpertId", "CarBodyClaimExpertId"],
|
||||
["field_expert", "ThirdPartyClaimExpertId", "CarBodyClaimExpertId"],
|
||||
])(
|
||||
"persists and edits %s Fanavaran IDs and locations using the real schemas",
|
||||
async (role, first, second) => {
|
||||
@@ -187,6 +190,7 @@ describe("management accounts, optional Fanavaran fields and tenant boundaries",
|
||||
);
|
||||
expect(row[first]).toBe("100");
|
||||
expect(row[second]).toBe("200");
|
||||
expect(row.locations).toMatchObject([{ id: "1", name: "تهران" }]);
|
||||
const edited = await service.updateStaff(tenant, role, String(row._id), {
|
||||
[first]: "300",
|
||||
[second]: null,
|
||||
|
||||
@@ -199,12 +199,16 @@ export class ManagementService {
|
||||
}
|
||||
if (field === "locations") {
|
||||
if (
|
||||
![RoleEnum.FILE_MAKER, RoleEnum.FILE_REVIEWER].includes(
|
||||
role as RoleEnum,
|
||||
)
|
||||
![
|
||||
RoleEnum.EXPERT,
|
||||
RoleEnum.DAMAGE_EXPERT,
|
||||
RoleEnum.FIELD_EXPERT,
|
||||
RoleEnum.FILE_MAKER,
|
||||
RoleEnum.FILE_REVIEWER,
|
||||
].includes(role as RoleEnum)
|
||||
)
|
||||
throw new BadRequestException(
|
||||
"Locations apply only to file makers and reviewers",
|
||||
"Locations apply only to expert staff roles",
|
||||
);
|
||||
if (!Array.isArray(value))
|
||||
throw new BadRequestException("Locations must be an array");
|
||||
|
||||
Reference in New Issue
Block a user