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:
@@ -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}`}
|
||||
|
||||
Reference in New Issue
Block a user