Skip to content

Commit 67a32dc

Browse files
authored
fix: fix the sort order params (#1659)
1 parent 11d7773 commit 67a32dc

File tree

5 files changed

+14
-12
lines changed

5 files changed

+14
-12
lines changed

application/CohortManager/src/Web/app/api/GetValidationExceptions/route.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ import mockDataStore from "@/app/data/mockDataStore";
44
function sortExceptions<
55
T extends { DateCreated: string; ServiceNowCreatedDate?: string }
66
>(items: T[], sortBy: string | null, dateField: keyof T = "DateCreated"): T[] {
7-
if (sortBy === "1") {
7+
if (sortBy === "0") {
8+
// Ascending: oldest first
89
return items.sort(
910
(a, b) =>
1011
new Date(a[dateField] as string).getTime() -
1112
new Date(b[dateField] as string).getTime()
1213
);
13-
} else if (sortBy === "0") {
14+
} else if (sortBy === "1") {
15+
// Descending: newest first
1416
return items.sort(
1517
(a, b) =>
1618
new Date(b[dateField] as string).getTime() -

application/CohortManager/src/Web/app/exceptions/[filter]/page.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,19 @@ export default async function Page({
3939

4040
const breadcrumbItems = [{ label: "Home", url: "/" }];
4141
const resolvedSearchParams = searchParams ? await searchParams : {};
42-
const sortBy = resolvedSearchParams.sortBy === "1" ? 1 : 0;
42+
const sortBy = resolvedSearchParams.sortBy === "0" ? 0 : 1;
4343
const currentPage = Math.max(
4444
1,
4545
parseInt(resolvedSearchParams.page || "1", 10)
4646
);
4747

4848
const sortOptions = [
4949
{
50-
value: "0",
50+
value: "1",
5151
label: "Status last updated (most recent first)",
5252
},
5353
{
54-
value: "1",
54+
value: "0",
5555
label: "Status last updated (oldest first)",
5656
},
5757
];

application/CohortManager/src/Web/app/exceptions/page.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,19 @@ export default async function Page({
4949

5050
const breadcrumbItems = [{ label: "Home", url: "/" }];
5151
const resolvedSearchParams = searchParams ? await searchParams : {};
52-
const sortBy = resolvedSearchParams.sortBy === "1" ? 1 : 0;
52+
const sortBy = resolvedSearchParams.sortBy === "0" ? 0 : 1;
5353
const currentPage = Math.max(
5454
1,
5555
parseInt(resolvedSearchParams.page || "1", 10)
5656
);
5757

5858
const sortOptions = [
5959
{
60-
value: "0",
60+
value: "1",
6161
label: "Date exception created (newest first)",
6262
},
6363
{
64-
value: "1",
64+
value: "0",
6565
label: "Date exception created (oldest first)",
6666
},
6767
];

application/CohortManager/src/Web/tests/features/notRaisedExceptions.feature

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Feature: Not raised exceptions page
1111
Scenario: Table shows 10 "Not raised" exceptions with expected columns
1212
Then the table "exceptions-table" has 10 rows
1313
And every row in the table "exceptions-table" has status "Not raised"
14-
And the first row in the table "exceptions-table" has exception ID "2073"
14+
And the first row in the table "exceptions-table" has exception ID "2028"
1515

1616
Scenario: Sort the not raised exceptions table by "Date exception created (oldest first)"
1717
Given I should see the heading "Not raised breast screening exceptions"
@@ -23,7 +23,7 @@ Feature: Not raised exceptions page
2323
Given I should see the heading "Not raised breast screening exceptions"
2424
When I sort the table by "Date exception created (newest first)"
2525
Then the table "exceptions-table" has 10 rows
26-
And the first row in the table "exceptions-table" has exception ID "2073"
26+
And the first row in the table "exceptions-table" has exception ID "2028"
2727

2828
Scenario: Breadcrumb back to homepage
2929
Then I see the link "Home"

application/CohortManager/src/Web/tests/features/raisedExceptions.feature

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Feature: Raised exceptions page
1414
Then I see text containing "Showing 1 to 10" in the element "raised-exception-count"
1515
And the table "exceptions-table" has 10 rows
1616
And every row in the table "exceptions-table" has status "Raised"
17-
And the first row in the table "exceptions-table" has exception ID "3001"
17+
And the first row in the table "exceptions-table" has exception ID "4001"
1818

1919
Scenario: Sort the raised exceptions table by "Status last updated (oldest first)"
2020
Given I should see the heading "Raised breast screening exceptions"
@@ -26,7 +26,7 @@ Feature: Raised exceptions page
2626
Given I should see the heading "Raised breast screening exceptions"
2727
When I sort the table by "Status last updated (most recent first)"
2828
Then the table "exceptions-table" has 10 rows
29-
And the first row in the table "exceptions-table" has exception ID "3001"
29+
And the first row in the table "exceptions-table" has exception ID "4001"
3030

3131
Scenario: Check for breadcrumb navigation back to homepage
3232
When I go to the page "/exceptions"

0 commit comments

Comments
 (0)