feat: restrict admin areas and show mobile pickups

Limit monitoring and journal access to admins, reduce regular-user navigation,
and show the latest pickup directly in mobile configuration cards.
This commit is contained in:
2026-08-05 20:10:22 +02:00
parent 713f52caa0
commit a64bfe2d3f
10 changed files with 103 additions and 47 deletions

View File

@@ -1,4 +1,6 @@
import { useMemo, useState } from 'react';
import { formatDistanceToNowStrict } from 'date-fns';
import { de } from 'date-fns/locale';
import './MobileConfigList.css';
const FILTER_OPTIONS = [
@@ -7,6 +9,17 @@ const FILTER_OPTIONS = [
{ value: 'inactive', label: 'Inaktiv' }
];
const formatLastPickup = (value) => {
const date = new Date(value);
if (!value || Number.isNaN(date.getTime())) {
return { relative: 'Unbekannt', exact: null };
}
return {
relative: formatDistanceToNowStrict(date, { addSuffix: true, locale: de }),
exact: date.toLocaleDateString('de-DE')
};
};
const MobileConfigList = ({
entries,
regularPickupMap,
@@ -84,6 +97,7 @@ const MobileConfigList = ({
{filteredEntries.map((entry) => {
const range = entry.desiredDateRange || (entry.desiredDate ? { start: entry.desiredDate, end: entry.desiredDate } : null);
const slots = formatRegularPickup(regularPickupMap?.[entry.id]);
const lastPickup = formatLastPickup(entry.lastPickupAt);
return (
<article
key={entry.id}
@@ -95,6 +109,9 @@ const MobileConfigList = ({
<h3 className="mobile-config-card__title">{entry.label || `Store ${entry.id}`}</h3>
<p className="mobile-config-card__id">#{entry.id}</p>
{slots && <p className="mobile-config-card__slots">Slots: {slots}</p>}
<p className="mobile-config-card__last-pickup" title={lastPickup.exact || undefined}>
Letzte Abholung: <strong>{lastPickup.relative}</strong>
</p>
</div>
<a
href={`https://foodsharing.de/store/${entry.id}`}