FEAT: update CustomerSidebarSection to support both menu and link items

This commit is contained in:
viniciusgadea
2026-03-17 15:25:55 -03:00
parent 19521489fa
commit 9ef4c51ba1
3 changed files with 20 additions and 52 deletions
+8 -48
View File
@@ -11166,53 +11166,6 @@
"description"
]
},
"CustomerSidebarLinkItem": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"title": {
"type": "string"
},
"link": {
"type": "string"
},
"icon": {
"type": "string"
}
},
"required": [
"type",
"title",
"link"
]
},
"CustomerSidebarMenuItem": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"title": {
"type": "string"
},
"icon": {
"type": "string"
},
"items": {
"type": "array",
"items": {
"$ref": "#/components/schemas/CustomerSidebarLinkItem"
}
}
},
"required": [
"type",
"title",
"items"
]
},
"CustomerSidebarSection": {
"type": "object",
"properties": {
@@ -11222,7 +11175,14 @@
"items": {
"type": "array",
"items": {
"$ref": "#/components/schemas/CustomerSidebarMenuItem"
"oneOf": [
{
"$ref": "#/components/schemas/CustomerSidebarMenuItem"
},
{
"$ref": "#/components/schemas/CustomerSidebarLinkItem"
}
]
}
}
},
+2 -2
View File
@@ -72,7 +72,7 @@ export class CustomersService implements OnModuleInit {
const result = await lastValueFrom(
this.customerService.CustomerGetLinks({ id: customerId }),
);
return (result.links as unknown as CustomerLinksConfig) || null;
return (result.links as CustomerLinksConfig) || null;
} catch (err) {
if (err.details === ErrorCodes.CUSTOMER.NOT_FOUND)
throw new HttpException(err.details, HttpStatus.NOT_FOUND);
@@ -89,7 +89,7 @@ export class CustomersService implements OnModuleInit {
return await firstValueFrom(
this.customerService.CustomerSetLinks({
id: customerId,
links: links as unknown as CustomerSetLinksRequest['links'],
links: links as CustomerSetLinksRequest['links'],
}),
);
} catch (err) {
+10 -2
View File
@@ -36,8 +36,16 @@ export class CustomerSidebarMenuItem {
export class CustomerSidebarSection {
@ApiProperty()
title: string;
@ApiProperty({ type: [CustomerSidebarMenuItem] })
items: CustomerSidebarMenuItem[];
@ApiProperty({
type: 'array',
items: {
oneOf: [
{ $ref: '#/components/schemas/CustomerSidebarMenuItem' },
{ $ref: '#/components/schemas/CustomerSidebarLinkItem' },
],
},
})
items: (CustomerSidebarMenuItem | CustomerSidebarLinkItem)[];
}
export class CustomerLinksConfig {