feat: add trip deletion and adjust CI/CD workflows for luggage-list
This commit is contained in:
38
App.js
38
App.js
@@ -292,6 +292,33 @@ export default function App() {
|
||||
setData((prev) => ({ ...prev, defaultTemplateTripId: tripId }));
|
||||
}
|
||||
|
||||
function deleteTrip(tripId) {
|
||||
Alert.alert('Delete trip?', 'This removes the trip, its items, and its check-up history.', [
|
||||
{ text: 'Cancel', style: 'cancel' },
|
||||
{
|
||||
text: 'Delete',
|
||||
style: 'destructive',
|
||||
onPress: () => {
|
||||
setData((prev) => {
|
||||
const nextTrips = prev.trips.filter((trip) => trip.id !== tripId);
|
||||
const nextItemsByTrip = { ...prev.itemsByTrip };
|
||||
const nextCheckupsByTrip = { ...prev.checkupsByTrip };
|
||||
delete nextItemsByTrip[tripId];
|
||||
delete nextCheckupsByTrip[tripId];
|
||||
|
||||
return {
|
||||
...prev,
|
||||
trips: nextTrips,
|
||||
itemsByTrip: nextItemsByTrip,
|
||||
checkupsByTrip: nextCheckupsByTrip,
|
||||
defaultTemplateTripId: prev.defaultTemplateTripId === tripId ? null : prev.defaultTemplateTripId,
|
||||
};
|
||||
});
|
||||
},
|
||||
},
|
||||
]);
|
||||
}
|
||||
|
||||
function saveItem() {
|
||||
if (!selectedTripId) {
|
||||
Alert.alert('No trip', 'Create or select a trip first.');
|
||||
@@ -629,9 +656,14 @@ export default function App() {
|
||||
{data.defaultTemplateTripId === trip.id ? ' • Template' : ''}
|
||||
</Text>
|
||||
</Pressable>
|
||||
<Pressable style={styles.smallActionBtn} onPress={() => setTripAsTemplate(trip.id)}>
|
||||
<Text style={styles.smallActionBtnText}>Template</Text>
|
||||
</Pressable>
|
||||
<View style={styles.itemActionsColumn}>
|
||||
<Pressable style={styles.smallActionBtn} onPress={() => setTripAsTemplate(trip.id)}>
|
||||
<Text style={styles.smallActionBtnText}>Template</Text>
|
||||
</Pressable>
|
||||
<Pressable style={styles.smallActionBtn} onPress={() => deleteTrip(trip.id)}>
|
||||
<Text style={styles.smallActionBtnText}>Delete</Text>
|
||||
</Pressable>
|
||||
</View>
|
||||
</View>
|
||||
))}
|
||||
</Card>
|
||||
|
||||
Reference in New Issue
Block a user