Skip to content

Commit

Permalink
CMS-622: Use display names for date types on Export page (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
duncan-oxd authored Jan 25, 2025
1 parent 6c8b8e7 commit 995187b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
21 changes: 19 additions & 2 deletions backend/routes/api/export.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@ import {

const router = Router();

// Map date type names to a different name for display
const dateTypeDisplayNames = new Map([
["Operation", "Operating"],
// "Reservation" displays as-is
]);

// Returns a display string for a date type
function getDateTypeDisplay(dateType) {
return dateTypeDisplayNames.get(dateType) ?? dateType;
}

// Get options for the export form
router.get(
"/options",
Expand All @@ -31,7 +42,13 @@ router.get(
const dateTypes = DateType.findAll({
attributes: ["id", "name"],
order: [["name", "ASC"]],
});
}).then((dateTypesArray) =>
// Update display names for date types
dateTypesArray.map((dateType) => ({
id: dateType.id,
name: getDateTypeDisplay(dateType.name),
})),
);

const years = (
await Season.findAll({
Expand Down Expand Up @@ -188,7 +205,7 @@ router.get(
"Sub-Area": feature.name,
"Sub-Area Type (Park feature)": feature.featureType.name,
"Operating Year": dateRange.season.operatingYear,
"Type of date": dateRange.dateType.name,
"Type of date": getDateTypeDisplay(dateRange.dateType.name),
"Start date": formatDate(dateRange.startDate),
"End date": formatDate(dateRange.endDate),
Status: dateRange.season.status,
Expand Down
2 changes: 1 addition & 1 deletion backend/strapi-sync/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ export async function createDateTypes() {
description: "Dates where reservations are available.",
},
{
name: "Off Season",
name: "Winter fees",
startDateLabel: "Winter start date",
endDateLabel: "Winter end date",
description: "Reduced services and reduced legislated winter fees.",
Expand Down

0 comments on commit 995187b

Please sign in to comment.