feat: add history long-press delete and quick item status actions
Some checks failed
Luggage List Build / build-web (push) Successful in 29s
Luggage List Build / release (push) Has been cancelled
Luggage List Build / build-android (push) Has been cancelled

This commit is contained in:
2026-04-18 14:34:05 +02:00
parent 2e45261354
commit d40bd6a41c
6 changed files with 121 additions and 8 deletions

View File

@@ -1,8 +1,25 @@
import React from 'react';
import { Pressable, Text, View } from 'react-native';
import { Alert, Pressable, Text, View } from 'react-native';
import { styles } from '../styles';
export default function HistoryTab({ selectedTrip, selectedTripCheckups, selectedCheckupId, setSelectedCheckupId }) {
export default function HistoryTab({
selectedTrip,
selectedTripCheckups,
selectedCheckupId,
setSelectedCheckupId,
onDeleteCheckup,
}) {
function askDelete(checkup) {
Alert.alert('Delete check-up?', 'This snapshot will be removed from history.', [
{ text: 'Cancel', style: 'cancel' },
{
text: 'Delete',
style: 'destructive',
onPress: () => onDeleteCheckup(checkup.id),
},
]);
}
return (
<View style={styles.section}>
<Text style={styles.sectionTitle}>History</Text>
@@ -13,13 +30,17 @@ export default function HistoryTab({ selectedTrip, selectedTripCheckups, selecte
{selectedTripCheckups.map((checkup) => (
<View key={checkup.id} style={styles.cardSoft}>
<Pressable onPress={() => setSelectedCheckupId((prev) => (prev === checkup.id ? null : checkup.id))}>
<Pressable
onPress={() => setSelectedCheckupId((prev) => (prev === checkup.id ? null : checkup.id))}
onLongPress={() => askDelete(checkup)}
delayLongPress={280}
>
<Text style={styles.cardTitle}>{new Date(checkup.createdAt).toLocaleString()}</Text>
<Text style={styles.cardMeta}>
{checkup.snapshot.length} items · correct: {checkup.stats?.correct ?? checkup.snapshot.filter((x) => x.result === 'correct').length} · bad:{' '}
{checkup.stats?.bad ?? checkup.snapshot.filter((x) => x.result === 'bad').length}
</Text>
<Text style={styles.cardMeta}>{selectedCheckupId === checkup.id ? 'Tap to collapse' : 'Tap to open'}</Text>
<Text style={styles.cardMeta}>{selectedCheckupId === checkup.id ? 'Tap to collapse' : 'Tap to open'} · long hold to delete</Text>
</Pressable>
{selectedCheckupId === checkup.id ? (