From c6a7dfa429ac22418cb457b5d62a078d549e9b9b Mon Sep 17 00:00:00 2001 From: Sai-CITZ <144365433+Sai-CITZ@users.noreply.github.com> Date: Wed, 11 Oct 2023 09:01:41 -0700 Subject: [PATCH] Fixed submission table sort (#1077) --- .../forms/common/models/views/submissionMetadata.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/app/src/forms/common/models/views/submissionMetadata.js b/app/src/forms/common/models/views/submissionMetadata.js index 0385faf29..68585de93 100644 --- a/app/src/forms/common/models/views/submissionMetadata.js +++ b/app/src/forms/common/models/views/submissionMetadata.js @@ -62,12 +62,10 @@ class SubmissionMetadata extends Model { if (!pagination) { builder.orderBy('createdAt', 'DESC'); } else { - let orderBy = params?.sortBy; - let orderDesc = params?.sortDesc; - if (orderDesc === 'true') { - builder.orderBy(orderBy, 'desc'); - } else if (orderDesc === 'false') { - builder.orderBy(orderBy, 'asc'); + let orderBy = params?.sortBy.column; + let orderDirection = params?.sortBy.order; + if (orderBy && orderDirection) { + builder.orderBy(orderBy, orderDirection); } } },