Skip to content

Commit

Permalink
fix: documents countries order by name
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanoshadjipetrou committed Nov 20, 2024
1 parent b45f4b3 commit f87122f
Showing 1 changed file with 35 additions and 28 deletions.
63 changes: 35 additions & 28 deletions src/controllers/documents.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,35 +30,42 @@ export class DocumentsController {
);

return {
data: _.map(groupedByLocation, (locationObj, location) => {
const groupedByType = _.groupBy(
locationObj,
DocumentsListMapping.type,
);
data: _.orderBy(
_.map(groupedByLocation, (locationObj, location) => {
const groupedByType = _.groupBy(
locationObj,
DocumentsListMapping.type,
);

return {
name: location,
documents: Object.keys(locationObj).length,
_children: _.map(groupedByType, (typeObj, type) => {
const groupedBySubType = _.groupBy(
typeObj,
DocumentsListMapping.subType,
);
return {
name: type,
documents: Object.keys(typeObj).length,
_children: _.map(groupedBySubType, (subTypeObj, subType) => ({
name: subType,
documents: Object.keys(subTypeObj).length,
_children: _.map(subTypeObj, doc => ({
name: _.get(doc, DocumentsListMapping.title, ''),
documents: _.get(doc, DocumentsListMapping.url, ''),
})),
})),
};
}),
};
}),
return {
name: location,
documents: Object.keys(locationObj).length,
_children: _.map(groupedByType, (typeObj, type) => {
const groupedBySubType = _.groupBy(
typeObj,
DocumentsListMapping.subType,
);
return {
name: type,
documents: Object.keys(typeObj).length,
_children: _.map(
groupedBySubType,
(subTypeObj, subType) => ({
name: subType,
documents: Object.keys(subTypeObj).length,
_children: _.map(subTypeObj, doc => ({
name: _.get(doc, DocumentsListMapping.title, ''),
documents: _.get(doc, DocumentsListMapping.url, ''),
})),
}),
),
};
}),
};
}),
'name',
'asc',
),
};
})
.catch(handleDataApiError);
Expand Down

0 comments on commit f87122f

Please sign in to comment.