fix: align frontend types and tests for react 19 (#339)

This commit is contained in:
Daniel Volz
2026-02-27 01:01:48 +01:00
committed by GitHub
parent 6b27d234d9
commit cc22f80209
23 changed files with 166 additions and 74 deletions
+4 -1
View File
@@ -2,7 +2,7 @@
// MedicationAvatar Component
// =============================================================================
import { useEffect, useState } from "react";
import { useEffect, useRef, useState } from "react";
export type MedicationAvatarProps = {
name: string;
@@ -12,8 +12,11 @@ export type MedicationAvatarProps = {
export function MedicationAvatar({ name, imageUrl, size = "sm" }: MedicationAvatarProps) {
const [thumbFailed, setThumbFailed] = useState(false);
const previousImageUrlRef = useRef(imageUrl);
useEffect(() => {
if (previousImageUrlRef.current === imageUrl) return;
previousImageUrlRef.current = imageUrl;
setThumbFailed(false);
}, [imageUrl]);
+5 -5
View File
@@ -96,9 +96,9 @@ export function MobileEditModal({
onAddTakenByPerson,
onRemoveTakenByPerson,
onTakenByKeyDown,
_onSetBlisterValue,
_onAddBlister,
_onRemoveBlister,
onSetBlisterValue: _onSetBlisterValue,
onAddBlister: _onAddBlister,
onRemoveBlister: _onRemoveBlister,
onSetIntakeValue,
onAddIntake,
onRemoveIntake,
@@ -108,7 +108,7 @@ export function MobileEditModal({
onDeleteMedImage,
imageUploadError,
onClose,
_onResetForm,
onResetForm: _onResetForm,
onSaveMedication,
}: MobileEditModalProps) {
const { t } = useTranslation();
@@ -402,7 +402,7 @@ export function MobileEditModal({
<select
className="package-type-select"
value={form.packageType}
onChange={(e) => onHandleValueChange("packageType", e.target.value)}
onChange={(e) => onHandleValueChange("packageType", e.target.value as FormState["packageType"])}
>
<option value="blister">{t("form.packageTypeBlister")}</option>
<option value="bottle">{t("form.packageTypeBottle")}</option>
+2 -2
View File
@@ -21,11 +21,11 @@ import { MedicationAvatar } from "./MedicationAvatar";
function getStockStatus(
daysLeft: number | null,
medsLeft: number,
thresholds: { lowStockDays: number; normalStockDays: number; highStockDays: number; reminderDaysBefore: number }
thresholds: { lowStockDays: number; normalStockDays: number; highStockDays: number; criticalStockDays: number }
) {
if (medsLeft <= 0 || daysLeft === 0) return { className: "danger", label: "status.outOfStock" };
if (daysLeft === null) return { className: "success", label: "status.noSchedule" };
if (daysLeft <= thresholds.reminderDaysBefore) return { className: "danger", label: "status.criticalStock" };
if (daysLeft <= thresholds.criticalStockDays) return { className: "danger", label: "status.criticalStock" };
if (daysLeft < thresholds.lowStockDays) return { className: "warning", label: "status.lowStock" };
if (daysLeft >= thresholds.highStockDays) return { className: "high", label: "status.highStock" };
return { className: "success", label: "status.normal" };