From 3e23b2508477ebb36e42dcf46a098c982f27adf1 Mon Sep 17 00:00:00 2001 From: Alexis G Date: Mon, 22 Nov 2021 16:39:11 +0100 Subject: [PATCH] feat: Sort list of categories Revert `getPapersByLabel` changes see: c3f652d --- src/components/Papers/PaperGroup.jsx | 4 +++- src/helpers/queries.js | 7 +++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/components/Papers/PaperGroup.jsx b/src/components/Papers/PaperGroup.jsx index 41c59d74..f04e6baf 100644 --- a/src/components/Papers/PaperGroup.jsx +++ b/src/components/Papers/PaperGroup.jsx @@ -49,7 +49,9 @@ const PaperGroup = () => { return label }) ) - ] + ].sort( + (a, b) => (scannerT(`items.${a}`) > scannerT(`items.${b}`) && 1) || -1 + ) : [] const goPapersList = useCallback( diff --git a/src/helpers/queries.js b/src/helpers/queries.js index e5ebd32e..fd1873e7 100644 --- a/src/helpers/queries.js +++ b/src/helpers/queries.js @@ -18,8 +18,7 @@ export const getAllQualificationLabel = papersDefinitions => { type: 'file', trashed: false }) - .indexFields(['metadata.qualification.label']) - .sortBy([{ 'metadata.qualification.label': 'desc' }]), + .indexFields(['metadata.qualification.label']), options: { as: `getAllQualificationLabel`, fetchPolicy: defaultFetchPolicy @@ -39,8 +38,8 @@ export const getPapersByLabel = label => ({ type: 'file', trashed: false }) - .indexFields(['name', 'metadata.qualification']) - .sortBy([{ name: 'asc' }]), + .indexFields(['created_at', 'metadata.qualification']) + .sortBy([{ created_at: 'desc' }]), options: { as: `getPapersByLabel:${label}`, fetchPolicy: defaultFetchPolicy