mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-15 15:02:04 +00:00
Merge branch 'fix/v1437-review' into release/v1.43.7
# Conflicts: # src/app/api/analytics/route.ts
This commit is contained in:
commit
45c027aee2
217 files changed
+3636
-2127
No files matched your search
@@ -96,7 +96,7 @@ export function EfficacyTab({
|
||||
const timezone = user?.timezone || DEFAULT_TIMEZONE;
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
const { data, isLoading, isError, refetch } = useQuery({
|
||||
const { data, isLoading, isError, error, refetch } = useQuery({
|
||||
queryKey: queryKeys.medicationEfficacy(medicationId),
|
||||
queryFn: () =>
|
||||
apiGet<MedicationEfficacyDTO>(
|
||||
@@ -128,7 +128,7 @@ export function EfficacyTab({
|
||||
title={t("medications.efficacy.title")}
|
||||
dataSlot="medication-wirkung-section"
|
||||
>
|
||||
<QueryErrorCard onRetry={() => refetch()} />
|
||||
<QueryErrorCard error={error} onRetry={() => refetch()} />
|
||||
</MedicationDetailSection>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -201,28 +201,29 @@ export function IntakeHistoryListV2({
|
||||
|
||||
const offset = page * pageSize;
|
||||
|
||||
const { data, isLoading, isError, refetch } = useQuery<IntakeListResponse>({
|
||||
queryKey: queryKeys.medicationIntakeList(medicationId, {
|
||||
sortBy,
|
||||
sortDir,
|
||||
limit: pageSize,
|
||||
offset,
|
||||
status: STATUS_FILTER,
|
||||
}),
|
||||
queryFn: async () => {
|
||||
const params = new URLSearchParams({
|
||||
const { data, isLoading, isError, error, refetch } =
|
||||
useQuery<IntakeListResponse>({
|
||||
queryKey: queryKeys.medicationIntakeList(medicationId, {
|
||||
sortBy,
|
||||
sortDir,
|
||||
limit: String(pageSize),
|
||||
offset: String(offset),
|
||||
limit: pageSize,
|
||||
offset,
|
||||
status: STATUS_FILTER,
|
||||
});
|
||||
return apiGet<IntakeListResponse>(
|
||||
`/api/medications/${medicationId}/intake?${params.toString()}`,
|
||||
);
|
||||
},
|
||||
enabled: isAuthenticated,
|
||||
});
|
||||
}),
|
||||
queryFn: async () => {
|
||||
const params = new URLSearchParams({
|
||||
sortBy,
|
||||
sortDir,
|
||||
limit: String(pageSize),
|
||||
offset: String(offset),
|
||||
status: STATUS_FILTER,
|
||||
});
|
||||
return apiGet<IntakeListResponse>(
|
||||
`/api/medications/${medicationId}/intake?${params.toString()}`,
|
||||
);
|
||||
},
|
||||
enabled: isAuthenticated,
|
||||
});
|
||||
|
||||
const sourceLabels: Record<IntakeSourceValue, string> = useMemo(
|
||||
() =>
|
||||
@@ -274,6 +275,7 @@ export function IntakeHistoryListV2({
|
||||
</div>
|
||||
) : isError ? (
|
||||
<QueryErrorCard
|
||||
error={error}
|
||||
title={t("medications.loadFailed")}
|
||||
onRetry={() => void refetch()}
|
||||
/>
|
||||
|
||||
@@ -14,7 +14,6 @@ import { MedicationCardBody } from "@/components/medications/card-parts/medicati
|
||||
import { useWeekdayLabel } from "@/components/medications/card-parts/medication-next-last-slot";
|
||||
import { formatTimeWindowRange } from "@/lib/time-window-format";
|
||||
import { formatDateTime, formatTime } from "@/lib/format";
|
||||
import { getDateTimeFormat } from "@/lib/intl/formatter-cache";
|
||||
import { getMedicationCategoryLabel } from "@/lib/medications/category-label";
|
||||
import { formatDose } from "@/lib/medications/format-dose";
|
||||
import { formatUnitsPerDose } from "@/lib/medications/units-per-dose";
|
||||
@@ -38,7 +37,7 @@ import { LogInjectionSiteDialog } from "@/components/medications/log-injection-s
|
||||
import { useGlobalExcludedInjectionSites } from "@/lib/medications/use-injection-site-prefs";
|
||||
import { useAuth } from "@/hooks/use-auth";
|
||||
import type { InjectionSiteKey } from "@/lib/medications/injection-sites";
|
||||
import { DEFAULT_TIMEZONE } from "@/lib/tz/format";
|
||||
import { DEFAULT_TIMEZONE, userDayKey } from "@/lib/tz/format";
|
||||
|
||||
interface Schedule {
|
||||
id: string;
|
||||
@@ -381,22 +380,16 @@ export function MedicationCard({
|
||||
: null;
|
||||
|
||||
function formatLastTakenAt(value: string): string {
|
||||
// Intentionally en-CA: gives YYYY-MM-DD which is locale-independent and
|
||||
// string-comparable for the today / yesterday / older bucketing below.
|
||||
// The actual user-facing display goes through formatTime / formatDateTime.
|
||||
const dayFormatter = getDateTimeFormat("en-CA", {
|
||||
timeZone: userTz,
|
||||
year: "numeric",
|
||||
month: "2-digit",
|
||||
day: "2-digit",
|
||||
});
|
||||
// Day keys (YYYY-MM-DD) in the profile zone, string-comparable for the
|
||||
// today / yesterday / older bucketing below. The user-facing display goes
|
||||
// through formatTime / formatDateTime.
|
||||
const now = new Date();
|
||||
const yesterday = new Date(now);
|
||||
yesterday.setDate(yesterday.getDate() - 1);
|
||||
|
||||
const intakeDay = dayFormatter.format(new Date(value));
|
||||
const todayDay = dayFormatter.format(now);
|
||||
const yesterdayDay = dayFormatter.format(yesterday);
|
||||
const intakeDay = userDayKey(new Date(value), userTz);
|
||||
const todayDay = userDayKey(now, userTz);
|
||||
const yesterdayDay = userDayKey(yesterday, userTz);
|
||||
const time = formatTime(value);
|
||||
|
||||
if (intakeDay === todayDay) return `${t("medications.today")}, ${time}`;
|
||||
|
||||
@@ -242,7 +242,10 @@ export function MedicationCategoriesSheet({
|
||||
>
|
||||
<div className="space-y-2" data-slot="medication-categories-sheet">
|
||||
{categories.isError ? (
|
||||
<QueryErrorRow onRetry={() => void categories.refetch()} />
|
||||
<QueryErrorRow
|
||||
error={categories.error}
|
||||
onRetry={() => void categories.refetch()}
|
||||
/>
|
||||
) : (
|
||||
(categories.data ?? []).map((category) => (
|
||||
<CategoryRow
|
||||
|
||||
@@ -155,6 +155,7 @@ export function SideEffectsSection({ medicationId }: SideEffectsSectionProps) {
|
||||
data,
|
||||
isLoading,
|
||||
isError,
|
||||
error,
|
||||
refetch,
|
||||
fetchNextPage,
|
||||
hasNextPage,
|
||||
@@ -330,7 +331,7 @@ export function SideEffectsSection({ medicationId }: SideEffectsSectionProps) {
|
||||
)}
|
||||
|
||||
{!isLoading && isError && (
|
||||
<QueryErrorCard onRetry={() => void refetch()} />
|
||||
<QueryErrorCard error={error} onRetry={() => void refetch()} />
|
||||
)}
|
||||
|
||||
{!isLoading && !isError && items.length === 0 && (
|
||||
|
||||
Reference in new issue
Block a user