Skip to content

Commit

Permalink
fix: recurring reservations index page
Browse files Browse the repository at this point in the history
- also fixes general Swedish time format ("kl" -> "kl.")
  • Loading branch information
vincit-matu committed Dec 18, 2024
1 parent 29f9b3d commit 5d5cb8e
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 16 deletions.
40 changes: 29 additions & 11 deletions apps/ui/pages/recurring/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,40 @@ export async function getServerSideProps(ctx: GetServerSidePropsContext) {
};
}

function getDateTime(date: string | Date) {
return new Date(date).getTime();
}

function RecurringLander({ applicationRounds }: Props): JSX.Element {
const { t } = useTranslation();

const activeApplicationRounds = applicationRounds.filter(
(ar) => ar.status === ApplicationRoundStatusChoice.Open
);
const activeApplicationRounds = applicationRounds
.filter((ar) => ar.status === ApplicationRoundStatusChoice.Open)
.sort(
(a, b) =>
getDateTime(b.applicationPeriodEnd) -
getDateTime(a.applicationPeriodEnd)
);

const pendingApplicationRounds = applicationRounds.filter(
(ar) => ar.status === ApplicationRoundStatusChoice.Upcoming
);
const pendingApplicationRounds = applicationRounds
.filter((ar) => ar.status === ApplicationRoundStatusChoice.Upcoming)
.sort(
(a, b) =>
getDateTime(a.applicationPeriodBegin) -
getDateTime(b.applicationPeriodBegin)
);

const pastApplicationRounds = applicationRounds.filter(
(ar) =>
ar.status !== ApplicationRoundStatusChoice.Open &&
ar.status !== ApplicationRoundStatusChoice.Upcoming
);
const pastApplicationRounds = applicationRounds
.filter(
(ar) =>
ar.status !== ApplicationRoundStatusChoice.Open &&
ar.status !== ApplicationRoundStatusChoice.Upcoming
)
.sort(
(a, b) =>
getDateTime(b.applicationPeriodEnd) -
getDateTime(a.applicationPeriodEnd)
);

return (
<>
Expand Down
2 changes: 1 addition & 1 deletion apps/ui/public/locales/en/recurringLander.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"heading": "Seasonal booking",
"subHeading": "Apply for the regular use of City of Helsinki spaces. Learn about the spaces and application deadlines on this page.",
"subHeading": "Apply for the regular use of City of Helsinki spaces.",
"roundHeadings": {
"active": "Ongoing application rounds",
"pending": "Upcoming application rounds",
Expand Down
2 changes: 1 addition & 1 deletion apps/ui/public/locales/fi/applicationRound.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"card": {
"applyButton": "Hae tiloja",
"displayPastButton": "Näytä tilat",
"criteria": "Tutustu hakuohjeisiin",
"criteria": "Tutustu hakuehtoihin",
"pending": "Haku avautuu {{opening}}",
"open": "Haku auki {{until}} saakka",
"past": "Haku sulkeutui {{closing}}",
Expand Down
2 changes: 1 addition & 1 deletion apps/ui/public/locales/fi/recurringLander.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"heading": "Kausivaraus",
"subHeading": "Hae Helsingin kaupungin tiloja säännölliseen käyttöön. Tutustu tiloihin ja hakuaikoihin tällä sivulla.",
"subHeading": "Hae Helsingin kaupungin tiloja säännölliseen käyttöön.",
"roundHeadings": {
"active": "Käynnissä olevat haut",
"pending": "Tulevat haut",
Expand Down
2 changes: 1 addition & 1 deletion apps/ui/public/locales/sv/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"dateLabel": "Datum",
"timeLabel": "Tid",
"dateWithWeekday": "{{date, datetime}}",
"dayTimeSeparator": " kl",
"dayTimeSeparator": " kl.",
"today": "I dag",
"tomorrow": "I morgon",
"day": "Dag",
Expand Down
2 changes: 1 addition & 1 deletion apps/ui/public/locales/sv/recurringLander.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"heading": "Säsongsbokning",
"subHeading": "Sök Helsingfors stads lokaler för regelbunden användning. Bekanta dig med lokalerna och ansökningstiderna här på sidan.",
"subHeading": "Sök Helsingfors stads lokaler för regelbunden användning.",
"roundHeadings": {
"active": "Pågående ansökningar",
"pending": "Kommande ansökningar",
Expand Down

0 comments on commit 5d5cb8e

Please sign in to comment.