2 Commits

Author SHA1 Message Date
e1bfbdbf1e feat(#17,#18): add location filter and custom-location autofill
All checks were successful
Luggage List Build / build-web (push) Successful in 52s
Luggage List Build / build-android (push) Successful in 7m2s
Luggage List Build / release (push) Successful in 17s
2026-04-18 21:59:23 +02:00
063e5090ed feat(#16): support custom placement when selecting other
All checks were successful
Luggage List Build / build-web (push) Successful in 40s
Luggage List Build / build-android (push) Successful in 7m26s
Luggage List Build / release (push) Successful in 15s
2026-04-18 21:41:18 +02:00
4 changed files with 127 additions and 8 deletions

View File

@@ -14,7 +14,7 @@ import TripsTab from './tabs/TripsTab';
import ItemsTab from './tabs/ItemsTab';
import CheckupTab from './tabs/CheckupTab';
import HistoryTab from './tabs/HistoryTab';
import { emptyData, STORAGE_KEY } from './constants';
import { emptyData, ITEM_PLACEMENTS, STORAGE_KEY } from './constants';
import { findBestTripId, makeId, parseYMD, todayYMD } from './utils/date';
import { styles } from './styles';
@@ -34,6 +34,7 @@ const emptyItemForm = () => ({
category: '',
status: 'unpacked',
placement: 'suitcase',
placementCustom: '',
lentTo: '',
imageUri: '',
imageQuality: 'balanced',
@@ -43,6 +44,7 @@ const emptyItemForm = () => ({
const emptyCheckupNoForm = () => ({
status: 'unpacked',
placement: 'suitcase',
placementCustom: '',
lentTo: '',
updateMasterList: false,
});
@@ -107,6 +109,35 @@ export default function AppRoot() {
return (data.checkupsByTrip[selectedTripId] || []).slice().sort((a, b) => b.createdAt - a.createdAt);
}, [data.checkupsByTrip, selectedTripId]);
const previousCustomPlacements = useMemo(() => {
const seen = new Set();
function takeFrom(items = [], bucket = []) {
items
.slice()
.sort((a, b) => (b.updatedAt || b.createdAt || 0) - (a.updatedAt || a.createdAt || 0))
.forEach((item) => {
const location = item.placement?.trim();
if (!location || ITEM_PLACEMENTS.includes(location) || seen.has(location)) return;
seen.add(location);
bucket.push(location);
});
return bucket;
}
const collected = [];
if (selectedTripId) {
takeFrom(data.itemsByTrip[selectedTripId] || [], collected);
}
Object.entries(data.itemsByTrip).forEach(([tripId, items]) => {
if (tripId === selectedTripId) return;
takeFrom(items || [], collected);
});
return collected;
}, [data.itemsByTrip, selectedTripId]);
const templateTrip = useMemo(
() => data.trips.find((trip) => trip.id === data.defaultTemplateTripId) || null,
[data.trips, data.defaultTemplateTripId]
@@ -227,7 +258,18 @@ export default function AppRoot() {
}
function updateItemForm(field, value) {
setItemForm((prev) => ({ ...prev, [field]: value }));
setItemForm((prev) => {
if (field === 'placement' && value === 'other') {
const fallbackLocation = previousCustomPlacements[0] || '';
return {
...prev,
placement: value,
placementCustom: prev.placementCustom?.trim() ? prev.placementCustom : fallbackLocation,
};
}
return { ...prev, [field]: value };
});
}
function openDatePicker(field) {
@@ -430,13 +472,17 @@ export default function AppRoot() {
}
function openEditItemModal(item) {
const existingPlacement = item.placement || 'suitcase';
const hasPresetPlacement = ITEM_PLACEMENTS.includes(existingPlacement);
setItemForm({
id: item.id,
name: item.name || '',
description: item.description || '',
category: item.category || '',
status: item.status || 'unpacked',
placement: item.placement || 'suitcase',
placement: hasPresetPlacement ? existingPlacement : 'other',
placementCustom: hasPresetPlacement || existingPlacement === 'other' ? '' : existingPlacement,
lentTo: item.lentTo || '',
imageUri: item.imageUri || '',
imageQuality: item.imageQuality || 'balanced',
@@ -456,6 +502,12 @@ export default function AppRoot() {
return;
}
const resolvedPlacement = itemForm.placement === 'other' ? itemForm.placementCustom.trim() : itemForm.placement;
if (!resolvedPlacement) {
showAlert('Missing location', 'Please enter a custom location for "other".');
return;
}
const now = Date.now();
setData((prev) => {
@@ -467,7 +519,7 @@ export default function AppRoot() {
description: itemForm.description.trim(),
category: itemForm.category.trim(),
status: itemForm.status,
placement: itemForm.placement,
placement: resolvedPlacement,
lentTo: itemForm.status === 'lent-to' ? itemForm.lentTo.trim() : '',
imageUri: itemForm.imageUri,
imageQuality: itemForm.imageQuality,
@@ -650,9 +702,14 @@ export default function AppRoot() {
function openCurrentCheckupNo() {
const entry = checkupCurrentEntry;
if (!entry) return;
const existingPlacement = entry.current.placement || 'suitcase';
const hasPresetPlacement = ITEM_PLACEMENTS.includes(existingPlacement);
setCheckupNoForm({
status: entry.current.status || 'unpacked',
placement: entry.current.placement || 'suitcase',
placement: hasPresetPlacement ? existingPlacement : 'other',
placementCustom: hasPresetPlacement || existingPlacement === 'other' ? '' : existingPlacement,
lentTo: entry.current.lentTo || '',
updateMasterList: false,
});
@@ -663,9 +720,15 @@ export default function AppRoot() {
const entry = checkupCurrentEntry;
if (!entry) return;
const resolvedPlacement = checkupNoForm.placement === 'other' ? checkupNoForm.placementCustom.trim() : checkupNoForm.placement;
if (!resolvedPlacement) {
showAlert('Missing location', 'Please enter a custom location for "other".');
return;
}
const patch = {
status: checkupNoForm.status,
placement: checkupNoForm.placement,
placement: resolvedPlacement,
lentTo: checkupNoForm.status === 'lent-to' ? checkupNoForm.lentTo.trim() : '',
};
@@ -936,6 +999,7 @@ export default function AppRoot() {
<ItemModal
visible={itemModalVisible}
itemForm={itemForm}
previousCustomPlacements={previousCustomPlacements}
setItemModalVisible={setItemModalVisible}
updateItemForm={updateItemForm}
pickItemImage={(options) => pickImage((uri) => updateItemForm('imageUri', uri), options)}

View File

@@ -103,6 +103,18 @@ export default function CheckupFlowModal({
/>
</Field>
{noForm.placement === 'other' ? (
<Field label="Custom location">
<TextInput
style={styles.input}
value={noForm.placementCustom}
onChangeText={(v) => setNoForm((prev) => ({ ...prev, placementCustom: v }))}
placeholder="bath-kit"
placeholderTextColor="#6b7280"
/>
</Field>
) : null}
{noForm.status === 'lent-to' ? (
<Field label="Lent to">
<TextInput

View File

@@ -14,6 +14,7 @@ function qualityValue(level) {
export default function ItemModal({
visible,
itemForm,
previousCustomPlacements,
setItemModalVisible,
updateItemForm,
pickItemImage,
@@ -81,6 +82,27 @@ export default function ItemModal({
<ChipGroup options={ITEM_PLACEMENTS} value={itemForm.placement} onChange={(v) => updateItemForm('placement', v)} />
</Field>
{itemForm.placement === 'other' ? (
<Field label="Custom location">
<TextInput
style={styles.input}
value={itemForm.placementCustom}
onChangeText={(v) => updateItemForm('placementCustom', v)}
placeholder="bath-kit"
placeholderTextColor="#6b7280"
/>
{previousCustomPlacements?.length ? (
<View style={styles.chipGroup}>
{previousCustomPlacements.slice(0, 6).map((location) => (
<Pressable key={location} style={styles.chip} onPress={() => updateItemForm('placementCustom', location)}>
<Text style={styles.chipText}>{location}</Text>
</Pressable>
))}
</View>
) : null}
</Field>
) : null}
{itemForm.status === 'lent-to' ? (
<Field label="Lent to">
<TextInput

View File

@@ -16,6 +16,7 @@ export default function ItemsTab({
}) {
const [statusFilter, setStatusFilter] = useState('all');
const [categoryFilter, setCategoryFilter] = useState('all');
const [locationFilter, setLocationFilter] = useState('all');
const [imagePreviewUri, setImagePreviewUri] = useState('');
const categories = useMemo(
@@ -23,19 +24,27 @@ export default function ItemsTab({
[selectedTripItems]
);
const locations = useMemo(
() => Array.from(new Set(selectedTripItems.map((item) => item.placement?.trim()).filter(Boolean))).sort((a, b) => a.localeCompare(b)),
[selectedTripItems]
);
const filteredItems = useMemo(
() =>
selectedTripItems.filter((item) => {
const matchStatus = statusFilter === 'all' || item.status === statusFilter;
const itemCategory = item.category?.trim() || '';
const itemLocation = item.placement?.trim() || '';
const matchCategory = categoryFilter === 'all' || itemCategory === categoryFilter;
return matchStatus && matchCategory;
const matchLocation = locationFilter === 'all' || itemLocation === locationFilter;
return matchStatus && matchCategory && matchLocation;
}),
[selectedTripItems, statusFilter, categoryFilter]
[selectedTripItems, statusFilter, categoryFilter, locationFilter]
);
const filterStatusOptions = ['all', ...ITEM_STATUSES];
const filterCategoryOptions = ['all', ...categories];
const filterLocationOptions = ['all', ...locations];
return (
<View style={styles.section}>
@@ -90,6 +99,18 @@ export default function ItemsTab({
);
})}
</View>
<Text style={styles.cardMeta}>Location</Text>
<View style={styles.chipGroup}>
{filterLocationOptions.map((location) => {
const active = locationFilter === location;
return (
<Pressable key={location} style={[styles.chip, active && styles.chipActive]} onPress={() => setLocationFilter(location)}>
<Text style={[styles.chipText, active && styles.chipTextActive]}>{formatFilterLabel(location)}</Text>
</Pressable>
);
})}
</View>
</View>
) : null}