diff --git a/care.config.ts b/care.config.ts
index f48d842d262..0721552b888 100644
--- a/care.config.ts
+++ b/care.config.ts
@@ -103,6 +103,14 @@ const careConfig = {
},
appointments: {
+ /**
+ * Relative number of days to show in the appointments page by default.
+ * 0 means today, positive for future days, negative for past days.
+ */
+ defaultDateFilter: env.REACT_APPOINTMENTS_DEFAULT_DATE_FILTER
+ ? parseInt(env.REACT_APPOINTMENTS_DEFAULT_DATE_FILTER)
+ : 7,
+
// Kill switch in-case the heatmap API doesn't scale as expected
useAvailabilityStatsAPI: boolean(
"REACT_APPOINTMENTS_USE_AVAILABILITY_STATS_API",
diff --git a/public/locale/en.json b/public/locale/en.json
index c1222b52486..f4edb490014 100644
--- a/public/locale/en.json
+++ b/public/locale/en.json
@@ -1171,7 +1171,6 @@
"last_administered": "Last administered",
"last_discharge_reason": "Last Discharge Reason",
"last_edited": "Last Edited",
- "last_fortnight_short": "Last 2wk",
"last_login": "Last Login",
"last_modified": "Last Modified",
"last_modified_by": "Last Modified By",
@@ -1302,7 +1301,7 @@
"new_password_same_as_old": "Your new password must not match the old password.",
"new_password_validation": "New password is not valid.",
"new_session": "New Session",
- "next_fortnight_short": "Next 2wk",
+ "next_month": "Next month",
"next_sessions": "Next Sessions",
"next_week_short": "Next wk",
"no": "No",
diff --git a/src/pages/Appointments/AppointmentsPage.tsx b/src/pages/Appointments/AppointmentsPage.tsx
index 269561aa2a0..39d3431edb5 100644
--- a/src/pages/Appointments/AppointmentsPage.tsx
+++ b/src/pages/Appointments/AppointmentsPage.tsx
@@ -1,3 +1,4 @@
+import careConfig from "@careConfig";
import { CaretDownIcon, CheckIcon, ReloadIcon } from "@radix-ui/react-icons";
import { PopoverClose } from "@radix-ui/react-popover";
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
@@ -123,25 +124,25 @@ function DateRangeDisplay({ dateFrom, dateTo }: DateRangeDisplayProps) {
// Case 2: Pre-defined ranges
const ranges = [
- {
- label: t("last_fortnight_short"),
- from: subDays(today, 14),
- to: today,
- },
{
label: t("last_week_short"),
from: subDays(today, 7),
to: today,
},
+ {
+ label: t("yesterday"),
+ from: subDays(today, 1),
+ to: subDays(today, 1),
+ },
{
label: t("next_week_short"),
from: today,
to: addDays(today, 7),
},
{
- label: t("next_fortnight_short"),
+ label: t("next_month"),
from: today,
- to: addDays(today, 14),
+ to: addDays(today, 30),
},
];
@@ -266,11 +267,22 @@ export default function AppointmentsPage(props: { facilityId?: string }) {
updates.practitioner = authUser.username;
}
- // Set today's date range if no dates are present
+ // Set default date range if no dates are present
if (!qParams.date_from && !qParams.date_to) {
const today = new Date();
- updates.date_from = dateQueryString(today);
- updates.date_to = dateQueryString(today);
+ const defaultDays = careConfig.appointments.defaultDateFilter;
+
+ if (defaultDays === 0) {
+ // Today only
+ updates.date_from = dateQueryString(today);
+ updates.date_to = dateQueryString(today);
+ } else {
+ // Past or future days based on configuration
+ const fromDate = defaultDays > 0 ? today : addDays(today, defaultDays);
+ const toDate = defaultDays > 0 ? addDays(today, defaultDays) : today;
+ updates.date_from = dateQueryString(fromDate);
+ updates.date_to = dateQueryString(toDate);
+ }
}
// Only update if there are changes
@@ -455,13 +467,13 @@ export default function AppointmentsPage(props: { facilityId?: string }) {
const today = new Date();
setQParams({
...qParams,
- date_from: dateQueryString(subDays(today, 14)),
+ date_from: dateQueryString(subDays(today, 7)),
date_to: dateQueryString(today),
slot: null,
});
}}
>
- {t("last_fortnight_short")}
+ {t("last_week_short")}