Compare commits
1 Commits
luggage-li
...
luggage-li
| Author | SHA1 | Date | |
|---|---|---|---|
| 063e5090ed |
@@ -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,
|
||||
});
|
||||
@@ -430,13 +432,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 +462,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 +479,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 +662,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 +680,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() : '',
|
||||
};
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -81,6 +81,18 @@ 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"
|
||||
/>
|
||||
</Field>
|
||||
) : null}
|
||||
|
||||
{itemForm.status === 'lent-to' ? (
|
||||
<Field label="Lent to">
|
||||
<TextInput
|
||||
|
||||
Reference in New Issue
Block a user