Compare commits
26 Commits
luggage-li
...
luggage-li
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7cccc763f2 | ||
|
|
0a8444700e | ||
| 0057290055 | |||
| e1bfbdbf1e | |||
| 063e5090ed | |||
| 354a13e9a9 | |||
| 4018e97476 | |||
| 1e0eb7aee9 | |||
| a9ee91daf3 | |||
| 0e0ab4a059 | |||
| 89fd4c2f44 | |||
| fbdae66c9b | |||
| e8ffab355e | |||
| 2ec877362f | |||
| fb54db0619 | |||
| a93fec97dc | |||
| 86976d5c26 | |||
| 61b0a3d1fa | |||
| 3080c3affd | |||
| d33fecd657 | |||
| 2417d2d597 | |||
| f28ff010d7 | |||
| d40bd6a41c | |||
| 2e45261354 | |||
| bd500674a0 | |||
| ef7e0ba7a1 |
@@ -3,6 +3,10 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
|
paths:
|
||||||
|
- '**/*.js'
|
||||||
|
- '**/*.json'
|
||||||
|
- '.gitea/workflows/**'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-android:
|
build-android:
|
||||||
|
|||||||
@@ -1,28 +0,0 @@
|
|||||||
name: Luggage List Dev Branch Check
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches-ignore:
|
|
||||||
- main
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
validate:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: 🏗 Setup repo
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: 🏗 Setup Node
|
|
||||||
uses: actions/setup-node@v2
|
|
||||||
with:
|
|
||||||
node-version: 22
|
|
||||||
|
|
||||||
- name: 🏗 Setup pnpm
|
|
||||||
uses: pnpm/action-setup@v4
|
|
||||||
with:
|
|
||||||
version: latest
|
|
||||||
|
|
||||||
- name: 📦 Install dependencies
|
|
||||||
run: pnpm install
|
|
||||||
|
|
||||||
- name: 🧪 Web export smoke check
|
|
||||||
run: npx expo export --platform web
|
|
||||||
@@ -1,57 +0,0 @@
|
|||||||
name: Luggage List Manual APK Build
|
|
||||||
on:
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build-android:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: 🏗 Setup repo
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: 🏗 Setup Node
|
|
||||||
uses: actions/setup-node@v2
|
|
||||||
with:
|
|
||||||
node-version: 22
|
|
||||||
|
|
||||||
- name: 🏗 Setup pnpm
|
|
||||||
uses: pnpm/action-setup@v4
|
|
||||||
with:
|
|
||||||
version: latest
|
|
||||||
|
|
||||||
- name: 🏗 Setup Java
|
|
||||||
uses: actions/setup-java@v4
|
|
||||||
with:
|
|
||||||
distribution: temurin
|
|
||||||
java-version: 17
|
|
||||||
|
|
||||||
- name: 🏗 Setup Android SDK
|
|
||||||
uses: android-actions/setup-android@v3
|
|
||||||
|
|
||||||
- name: 🏗 Setup Expo and EAS
|
|
||||||
uses: expo/expo-github-action@v8
|
|
||||||
with:
|
|
||||||
token: ${{ secrets.EXPO_TOKEN }}
|
|
||||||
eas-version: latest
|
|
||||||
packager: pnpm
|
|
||||||
|
|
||||||
- name: 📦 Install dependencies
|
|
||||||
run: pnpm install
|
|
||||||
|
|
||||||
- name: 👷 Build app
|
|
||||||
run: |
|
|
||||||
eas build --local \
|
|
||||||
--non-interactive \
|
|
||||||
--output=./app-build \
|
|
||||||
--platform=android \
|
|
||||||
--profile=preview
|
|
||||||
|
|
||||||
- name: 📝 Rename build to APK
|
|
||||||
run: mv app-build luggage-list-manual.apk
|
|
||||||
|
|
||||||
- name: 📤 Upload build artifact
|
|
||||||
uses: actions/upload-artifact@v3
|
|
||||||
with:
|
|
||||||
name: luggage-list-manual-apk-build
|
|
||||||
path: luggage-list-manual.apk
|
|
||||||
if-no-files-found: error
|
|
||||||
45
.github/copilot-instructions.md
vendored
45
.github/copilot-instructions.md
vendored
@@ -1,45 +0,0 @@
|
|||||||
# Project Guidelines
|
|
||||||
|
|
||||||
## Code Style
|
|
||||||
- Keep components as functional React components and use hooks-based state.
|
|
||||||
- Follow existing naming and structure in `src/screens` and `src/components`:
|
|
||||||
- Screen files: `*Screen.js`
|
|
||||||
- Shared UI pieces: `src/components/*.js`
|
|
||||||
- Keep styling centralized in `src/styles.js` via `createStyles()` and use theme-driven inline color overrides in screens/components.
|
|
||||||
- Reuse `getTheme(darkMode, pinkMode)` from `src/theme.js` for color values; do not hardcode alternate palettes in individual screens.
|
|
||||||
|
|
||||||
## Architecture
|
|
||||||
- Root orchestration lives in `App.js`:
|
|
||||||
- App-level state includes current screen, focus mode, theme toggles, and timer/countdown state.
|
|
||||||
- Screen switching is controlled by the `screen` state (`home`, `timeuntil`, `timer`).
|
|
||||||
- Screen responsibilities:
|
|
||||||
- `HomeScreen`: mode selection and top controls.
|
|
||||||
- `TimeUntilScreen`: target clock-time countdown flow.
|
|
||||||
- `TimerScreen`: duration countdown flow.
|
|
||||||
- `FocusScreen`: minimal fullscreen countdown UI.
|
|
||||||
- Shared presentational components:
|
|
||||||
- `TopControls`: dark/pink/fullscreen/focus controls.
|
|
||||||
- `CountdownRow`: reusable HH:MM:SS display.
|
|
||||||
|
|
||||||
## Build And Run
|
|
||||||
- Install dependencies: `npm install`
|
|
||||||
- Start dev server: `npm start`
|
|
||||||
- Run on Android: `npm run android`
|
|
||||||
- Run on iOS: `npm run ios`
|
|
||||||
- Run on web: `npm run web`
|
|
||||||
- EAS builds use `eas.json` profiles (`development`, `preview`, `production`).
|
|
||||||
|
|
||||||
## Conventions
|
|
||||||
- Keep timer/countdown behavior in `App.js` unless intentionally refactoring architecture.
|
|
||||||
- Preserve current time behavior:
|
|
||||||
- `now` updates every second with `setInterval`.
|
|
||||||
- Time-until target is based on local device time and rolls to next day when target time has passed.
|
|
||||||
- Maintain platform guards:
|
|
||||||
- Web-only fullscreen uses `document.fullscreenElement` APIs.
|
|
||||||
- Android hardware back behavior is handled in `App.js` and should keep focus/screen fallback behavior.
|
|
||||||
- For countdown display, continue using `CountdownRow` and 2-digit padded units for consistency.
|
|
||||||
|
|
||||||
## Pitfalls
|
|
||||||
- This project has no test scripts configured; do not claim tests were run unless you add and run them.
|
|
||||||
- Be careful with web-only globals (`document`) and keep `Platform.OS` guards.
|
|
||||||
- Avoid introducing timezone assumptions without explicit product requirements; current logic is local-time based.
|
|
||||||
1
App.js
1
App.js
@@ -1,3 +1,4 @@
|
|||||||
|
import './global.css';
|
||||||
import AppRoot from './src/AppRoot';
|
import AppRoot from './src/AppRoot';
|
||||||
|
|
||||||
export default AppRoot;
|
export default AppRoot;
|
||||||
|
|||||||
@@ -30,11 +30,3 @@ Minimal local-first luggage management app built with Expo.
|
|||||||
npm install
|
npm install
|
||||||
npm run start
|
npm run start
|
||||||
```
|
```
|
||||||
|
|
||||||
## Build / CI
|
|
||||||
|
|
||||||
Gitea workflows are in `.gitea/workflows`:
|
|
||||||
|
|
||||||
- `dev.yml`: smoke check via `expo export --platform web` on non-main branches
|
|
||||||
- `ci.yml`: Android APK build via `eas build --local`, web bundle export, release tag/artifacts on `main`
|
|
||||||
- `manual-build.yml`: manual Android APK build via `eas build --local`
|
|
||||||
|
|||||||
39
TODO.md
39
TODO.md
@@ -1,39 +0,0 @@
|
|||||||
# TODO - Luggage List
|
|
||||||
|
|
||||||
## Stage
|
|
||||||
Improving & Fixing Bugs (V3)
|
|
||||||
|
|
||||||
## V2 Changes Requested
|
|
||||||
- [x] Trip can be selected from everywhere (global trip picker)
|
|
||||||
- [x] Fixed trip switching behavior for web by removing aggressive auto-reselect
|
|
||||||
- [x] Removed trip image crop (gallery pick without editing)
|
|
||||||
- [x] Item updates now happen in a modal
|
|
||||||
- [x] Redesigned item cards
|
|
||||||
- [x] Moved top nav to bottom and made it mobile-friendly
|
|
||||||
- [x] Removed top title block
|
|
||||||
- [x] Reworked check-up flow to yes/no checklist
|
|
||||||
- [x] “No” now opens update modal for check-up-only changes
|
|
||||||
- [x] Added optional toggle to also sync fix into trip item list
|
|
||||||
- [x] Removed JSON export feature
|
|
||||||
- [x] Improved keyboard behavior with KeyboardAvoidingView + scroll-safe forms
|
|
||||||
- [x] Full UI redesign (dark-first minimalist with accent colors)
|
|
||||||
- [x] Set new icon from `https://cdn.reversed.dev/pictures/yesnt.png`
|
|
||||||
|
|
||||||
## Validation
|
|
||||||
- [x] `npm install`
|
|
||||||
- [x] `npx expo export --platform web`
|
|
||||||
|
|
||||||
## Progress Log
|
|
||||||
- [x] V1 prototype complete and shipped
|
|
||||||
- [x] CI adjusted (no `eas init` in workflows)
|
|
||||||
- [x] V2 redesign + behavior fixes implemented
|
|
||||||
- [x] Removed legacy template src folder
|
|
||||||
- [x] Rebuilt app into modular `src/` structure (tabs/components/modals/styles/utils)
|
|
||||||
- [x] Fixed status-bar overlap with top spacing
|
|
||||||
- [x] Replaced trip date text inputs with calendar modal picker
|
|
||||||
- [x] Improved keyboard focus scrolling to focused input (not scroll-to-end)
|
|
||||||
- [x] Reworked bottom nav to real icons + labels
|
|
||||||
- [x] Clarified history as selected-trip check-up history
|
|
||||||
- [x] Increased safe top inset to avoid status-bar overlap
|
|
||||||
- [x] Added check-up stats (correct/bad/pending) and persisted per snapshot
|
|
||||||
- [x] Extra UI polish pass (spacing, cards, hierarchy)
|
|
||||||
21
app.json
21
app.json
@@ -2,12 +2,12 @@
|
|||||||
"expo": {
|
"expo": {
|
||||||
"name": "Luggage List",
|
"name": "Luggage List",
|
||||||
"slug": "luggage-list",
|
"slug": "luggage-list",
|
||||||
"version": "1.0.0",
|
"version": "2.0.0",
|
||||||
"orientation": "default",
|
"orientation": "default",
|
||||||
"icon": "./assets/icon.png",
|
"icon": "./assets/image.png",
|
||||||
"userInterfaceStyle": "automatic",
|
"userInterfaceStyle": "automatic",
|
||||||
"splash": {
|
"splash": {
|
||||||
"image": "./assets/splash-icon.png",
|
"image": "./assets/image.png",
|
||||||
"resizeMode": "contain",
|
"resizeMode": "contain",
|
||||||
"backgroundColor": "#f5f5f7"
|
"backgroundColor": "#f5f5f7"
|
||||||
},
|
},
|
||||||
@@ -19,12 +19,12 @@
|
|||||||
"android": {
|
"android": {
|
||||||
"package": "dev.reversed.luggagelist",
|
"package": "dev.reversed.luggagelist",
|
||||||
"adaptiveIcon": {
|
"adaptiveIcon": {
|
||||||
"foregroundImage": "./assets/icon.png",
|
"foregroundImage": "./assets/image.png",
|
||||||
"backgroundColor": "#f5f5f7"
|
"backgroundColor": "#f5f5f7"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"web": {
|
"web": {
|
||||||
"favicon": "./assets/icon.png",
|
"favicon": "./assets/image.png",
|
||||||
"name": "Luggage List",
|
"name": "Luggage List",
|
||||||
"themeColor": "#f5f5f7",
|
"themeColor": "#f5f5f7",
|
||||||
"backgroundColor": "#f5f5f7"
|
"backgroundColor": "#f5f5f7"
|
||||||
@@ -34,6 +34,15 @@
|
|||||||
"eas": {
|
"eas": {
|
||||||
"projectId": "1275f90e-33c6-4af1-942e-ca29a309f8c8"
|
"projectId": "1275f90e-33c6-4af1-942e-ca29a309f8c8"
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
"plugins": [
|
||||||
|
[
|
||||||
|
"expo-image-picker",
|
||||||
|
{
|
||||||
|
"photosPermission": "Allow Luggage List to access your photos for trip and item images.",
|
||||||
|
"cameraPermission": "Allow Luggage List to use your camera to take trip and item photos."
|
||||||
|
}
|
||||||
|
]
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 32 KiB |
BIN
assets/alert.mp3
BIN
assets/alert.mp3
Binary file not shown.
BIN
assets/icon.png
BIN
assets/icon.png
Binary file not shown.
|
Before Width: | Height: | Size: 32 KiB |
BIN
assets/image.png
Normal file
BIN
assets/image.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 31 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 32 KiB |
2
global.css
Normal file
2
global.css
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
@import 'tailwindcss';
|
||||||
|
@import 'uniwind';
|
||||||
9
metro.config.js
Normal file
9
metro.config.js
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
const { getDefaultConfig } = require('expo/metro-config');
|
||||||
|
const { withUniwindConfig } = require('uniwind/metro');
|
||||||
|
|
||||||
|
const config = getDefaultConfig(__dirname);
|
||||||
|
|
||||||
|
module.exports = withUniwindConfig(config, {
|
||||||
|
cssEntryFile: './global.css',
|
||||||
|
dtsFile: './src/uniwind-types.d.ts',
|
||||||
|
});
|
||||||
2368
package-lock.json
generated
2368
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
16
package.json
16
package.json
@@ -6,17 +6,27 @@
|
|||||||
"start": "expo start",
|
"start": "expo start",
|
||||||
"android": "expo start --android",
|
"android": "expo start --android",
|
||||||
"ios": "expo start --ios",
|
"ios": "expo start --ios",
|
||||||
"web": "expo start --web"
|
"web": "expo start --web",
|
||||||
|
"test": "vitest run",
|
||||||
|
"test:watch": "vitest"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@react-native-async-storage/async-storage": "2.2.0",
|
"@react-native-async-storage/async-storage": "2.2.0",
|
||||||
"expo": "~54.0.33",
|
"expo": "~54.0.33",
|
||||||
|
"expo-document-picker": "~14.0.7",
|
||||||
|
"expo-file-system": "~19.0.11",
|
||||||
"expo-image-picker": "~17.0.8",
|
"expo-image-picker": "~17.0.8",
|
||||||
|
"expo-sharing": "~14.0.7",
|
||||||
"expo-status-bar": "~3.0.9",
|
"expo-status-bar": "~3.0.9",
|
||||||
"react": "19.1.0",
|
"react": "19.1.0",
|
||||||
"react-dom": "19.1.0",
|
"react-dom": "19.1.0",
|
||||||
"react-native": "0.81.5",
|
"react-native": "0.81.5",
|
||||||
"react-native-web": "^0.21.0"
|
"react-native-web": "^0.21.0",
|
||||||
|
"tailwindcss": "^4.0.0",
|
||||||
|
"uniwind": "latest"
|
||||||
},
|
},
|
||||||
"private": true
|
"private": true,
|
||||||
|
"devDependencies": {
|
||||||
|
"vitest": "^1.6.1"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
7212
pnpm-lock.yaml
generated
Normal file
7212
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
870
src/AppRoot.js
870
src/AppRoot.js
File diff suppressed because it is too large
Load Diff
49
src/components/AppDialogModal.js
Normal file
49
src/components/AppDialogModal.js
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { Modal, Pressable, Text, View } from 'react-native';
|
||||||
|
import Ionicons from '@expo/vector-icons/Ionicons';
|
||||||
|
import { styles } from '../styles';
|
||||||
|
import { cn } from '../utils/cn';
|
||||||
|
|
||||||
|
export default function AppDialogModal({ visible, title, message, buttons = [], onClose }) {
|
||||||
|
if (!visible) return null;
|
||||||
|
|
||||||
|
const safeButtons = buttons.length ? buttons : [{ text: 'OK' }];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Modal visible={visible} transparent animationType="none" onRequestClose={onClose}>
|
||||||
|
<View className={styles.dialogBackdrop}>
|
||||||
|
<View className={styles.dialogCard}>
|
||||||
|
<View className={styles.sectionHeaderLeft}>
|
||||||
|
<Ionicons name="information-circle-outline" size={18} color="#d4d4d8" />
|
||||||
|
<Text className={styles.dialogTitle}>{title || 'Notice'}</Text>
|
||||||
|
</View>
|
||||||
|
{!!message ? <Text className={styles.dialogMessage}>{message}</Text> : null}
|
||||||
|
|
||||||
|
<View className={styles.dialogButtonsRow}>
|
||||||
|
{safeButtons.map((button, idx) => {
|
||||||
|
const tone = button.tone || (button.style === 'destructive' ? 'danger' : button.style === 'cancel' ? 'neutral' : 'primary');
|
||||||
|
const icon = tone === 'danger' ? 'warning-outline' : tone === 'neutral' ? 'close-outline' : 'checkmark-outline';
|
||||||
|
return (
|
||||||
|
<Pressable
|
||||||
|
key={`${button.text}-${idx}`}
|
||||||
|
className={cn(
|
||||||
|
styles.dialogBtn,
|
||||||
|
tone === 'primary' && styles.dialogBtnPrimary,
|
||||||
|
tone === 'danger' && styles.dialogBtnDanger,
|
||||||
|
tone === 'neutral' && styles.dialogBtnNeutral
|
||||||
|
)}
|
||||||
|
onPress={button.onPress}
|
||||||
|
>
|
||||||
|
<View className={styles.buttonContent}>
|
||||||
|
<Ionicons name={icon} size={14} color="#f8fafc" />
|
||||||
|
<Text className={styles.dialogBtnText}>{button.text || 'OK'}</Text>
|
||||||
|
</View>
|
||||||
|
</Pressable>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
</Modal>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -2,31 +2,51 @@ import React from 'react';
|
|||||||
import { Pressable, Text, View } from 'react-native';
|
import { Pressable, Text, View } from 'react-native';
|
||||||
import Ionicons from '@expo/vector-icons/Ionicons';
|
import Ionicons from '@expo/vector-icons/Ionicons';
|
||||||
import { styles } from '../styles';
|
import { styles } from '../styles';
|
||||||
|
import { cn } from '../utils/cn';
|
||||||
|
|
||||||
export default function BottomTab({ current, onChange }) {
|
function TabBtn({ tab, current, onChange }) {
|
||||||
const tabs = [
|
const active = current === tab.key;
|
||||||
|
return (
|
||||||
|
<Pressable onPress={() => onChange(tab.key)} className={styles.tabItem}>
|
||||||
|
<Ionicons name={active ? tab.iconActive : tab.icon} size={18} color={active ? '#dbeafe' : '#94a3b8'} />
|
||||||
|
<Text className={cn(styles.tabLabel, active && styles.tabLabelActive)}>{tab.label}</Text>
|
||||||
|
</Pressable>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function BottomTab({ current, onChange, onAddItem, canAddItem }) {
|
||||||
|
const leftTabs = [
|
||||||
{ key: 'trips', label: 'Trips', icon: 'airplane-outline', iconActive: 'airplane' },
|
{ key: 'trips', label: 'Trips', icon: 'airplane-outline', iconActive: 'airplane' },
|
||||||
{ key: 'items', label: 'Items', icon: 'briefcase-outline', iconActive: 'briefcase' },
|
{ key: 'items', label: 'Items', icon: 'briefcase-outline', iconActive: 'briefcase' },
|
||||||
|
];
|
||||||
|
|
||||||
|
const rightTabs = [
|
||||||
{ key: 'checkup', label: 'Check-Up', icon: 'checkmark-circle-outline', iconActive: 'checkmark-circle' },
|
{ key: 'checkup', label: 'Check-Up', icon: 'checkmark-circle-outline', iconActive: 'checkmark-circle' },
|
||||||
{ key: 'history', label: 'History', icon: 'time-outline', iconActive: 'time' },
|
{ key: 'history', label: 'History', icon: 'time-outline', iconActive: 'time' },
|
||||||
];
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={styles.tabBarWrap}>
|
<View className={styles.tabBarWrap}>
|
||||||
<View style={styles.tabBar}>
|
<View className={styles.tabBar}>
|
||||||
{tabs.map((tab) => {
|
<View className={styles.tabGroupSide}>
|
||||||
const active = current === tab.key;
|
{leftTabs.map((tab) => (
|
||||||
return (
|
<TabBtn key={tab.key} tab={tab} current={current} onChange={onChange} />
|
||||||
<Pressable key={tab.key} onPress={() => onChange(tab.key)} style={styles.tabItem}>
|
))}
|
||||||
<Ionicons
|
</View>
|
||||||
name={active ? tab.iconActive : tab.icon}
|
|
||||||
size={18}
|
<Pressable
|
||||||
color={active ? '#dbeafe' : '#94a3b8'}
|
className={cn(styles.tabAddBtn, !canAddItem && styles.tabAddBtnDisabled)}
|
||||||
/>
|
onPress={onAddItem}
|
||||||
<Text style={[styles.tabLabel, active && styles.tabLabelActive]}>{tab.label}</Text>
|
disabled={!canAddItem}
|
||||||
</Pressable>
|
>
|
||||||
);
|
<Ionicons name="add" size={26} color="#fff" />
|
||||||
})}
|
</Pressable>
|
||||||
|
|
||||||
|
<View className={styles.tabGroupSide}>
|
||||||
|
{rightTabs.map((tab) => (
|
||||||
|
<TabBtn key={tab.key} tab={tab} current={current} onChange={onChange} />
|
||||||
|
))}
|
||||||
|
</View>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,15 +1,16 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Pressable, Text, View } from 'react-native';
|
import { Pressable, Text, View } from 'react-native';
|
||||||
import { styles } from '../styles';
|
import { styles } from '../styles';
|
||||||
|
import { cn } from '../utils/cn';
|
||||||
|
|
||||||
export default function ChipGroup({ options, value, onChange }) {
|
export default function ChipGroup({ options, value, onChange }) {
|
||||||
return (
|
return (
|
||||||
<View style={styles.chipGroup}>
|
<View className={styles.chipGroup}>
|
||||||
{options.map((option) => {
|
{options.map((option) => {
|
||||||
const active = value === option;
|
const active = value === option;
|
||||||
return (
|
return (
|
||||||
<Pressable key={option} style={[styles.chip, active && styles.chipActive]} onPress={() => onChange(option)}>
|
<Pressable key={option} className={cn(styles.chip, active && styles.chipActive)} onPress={() => onChange(option)}>
|
||||||
<Text style={[styles.chipText, active && styles.chipTextActive]}>{option}</Text>
|
<Text className={cn(styles.chipText, active && styles.chipTextActive)}>{option}</Text>
|
||||||
</Pressable>
|
</Pressable>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import React, { useMemo, useState } from 'react';
|
import React, { useMemo, useState } from 'react';
|
||||||
import { Modal, Pressable, Text, View } from 'react-native';
|
import { Modal, Pressable, Text, View } from 'react-native';
|
||||||
|
import Ionicons from '@expo/vector-icons/Ionicons';
|
||||||
import { styles } from '../styles';
|
import { styles } from '../styles';
|
||||||
|
import { cn } from '../utils/cn';
|
||||||
import { todayYMD } from '../utils/date';
|
import { todayYMD } from '../utils/date';
|
||||||
|
|
||||||
const WEEKDAYS = ['Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su'];
|
const WEEKDAYS = ['Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su'];
|
||||||
@@ -48,40 +50,48 @@ export default function DatePickerModal({ visible, value, onClose, onSelect, tit
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal visible={visible} transparent animationType="fade" onRequestClose={onClose}>
|
<Modal visible={visible} transparent animationType="none" onRequestClose={onClose}>
|
||||||
<View style={styles.dateModalBackdrop}>
|
<View className={styles.dateModalBackdrop}>
|
||||||
<View style={styles.dateModalCard}>
|
<View className={styles.dateModalCard}>
|
||||||
<View style={styles.sectionRow}>
|
<View className={styles.sectionHeader}>
|
||||||
<Text style={styles.sectionTitle}>{title}</Text>
|
<View className={styles.sectionHeaderLeft}>
|
||||||
<Pressable onPress={onClose}>
|
<View className={styles.sectionHeaderIconWrap}>
|
||||||
<Text style={styles.closeText}>Close</Text>
|
<Ionicons name="calendar-outline" size={16} color="#d4d4d8" />
|
||||||
|
</View>
|
||||||
|
<Text className={styles.cardTitle}>{title}</Text>
|
||||||
|
</View>
|
||||||
|
<Pressable className={styles.secondaryBtnTight} onPress={onClose}>
|
||||||
|
<View className={styles.buttonContent}>
|
||||||
|
<Ionicons name="close" size={14} color="#f4f4f5" />
|
||||||
|
<Text className={styles.secondaryBtnText}>Close</Text>
|
||||||
|
</View>
|
||||||
</Pressable>
|
</Pressable>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<View style={styles.calendarHeader}>
|
<View className={styles.calendarHeader}>
|
||||||
<Pressable style={styles.calendarNavBtn} onPress={() => goMonth(-1)}>
|
<Pressable className={styles.calendarNavBtn} onPress={() => goMonth(-1)}>
|
||||||
<Text style={styles.calendarNavText}>‹</Text>
|
<Ionicons name="chevron-back" size={18} color="#e4e4e7" />
|
||||||
</Pressable>
|
</Pressable>
|
||||||
<Text style={styles.calendarMonthText}>{monthLabel(viewDate)}</Text>
|
<Text className={styles.calendarMonthText}>{monthLabel(viewDate)}</Text>
|
||||||
<Pressable style={styles.calendarNavBtn} onPress={() => goMonth(1)}>
|
<Pressable className={styles.calendarNavBtn} onPress={() => goMonth(1)}>
|
||||||
<Text style={styles.calendarNavText}>›</Text>
|
<Ionicons name="chevron-forward" size={18} color="#e4e4e7" />
|
||||||
</Pressable>
|
</Pressable>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<View style={styles.calendarWeekRow}>
|
<View className={styles.calendarWeekRow}>
|
||||||
{WEEKDAYS.map((w) => (
|
{WEEKDAYS.map((w) => (
|
||||||
<Text key={w} style={styles.calendarWeekday}>{w}</Text>
|
<Text key={w} className={styles.calendarWeekday}>{w}</Text>
|
||||||
))}
|
))}
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<View style={styles.calendarGrid}>
|
<View className={styles.calendarGrid}>
|
||||||
{grid.map((cell, idx) => {
|
{grid.map((cell, idx) => {
|
||||||
if (!cell) return <View key={`empty-${idx}`} style={styles.calendarCell} />;
|
if (!cell) return <View key={`empty-${idx}`} className={styles.calendarCell} />;
|
||||||
const ymd = toYMD(cell);
|
const ymd = toYMD(cell);
|
||||||
const isSelected = ymd === selected;
|
const isSelected = ymd === selected;
|
||||||
return (
|
return (
|
||||||
<Pressable key={ymd} style={[styles.calendarCell, isSelected && styles.calendarCellActive]} onPress={() => onSelect(ymd)}>
|
<Pressable key={ymd} className={cn(styles.calendarCell, isSelected && styles.calendarCellActive)} onPress={() => onSelect(ymd)}>
|
||||||
<Text style={[styles.calendarCellText, isSelected && styles.calendarCellTextActive]}>{cell.getDate()}</Text>
|
<Text className={cn(styles.calendarCellText, isSelected && styles.calendarCellTextActive)}>{cell.getDate()}</Text>
|
||||||
</Pressable>
|
</Pressable>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|||||||
@@ -1,11 +1,15 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Text, View } from 'react-native';
|
import { Text, View } from 'react-native';
|
||||||
|
import Ionicons from '@expo/vector-icons/Ionicons';
|
||||||
import { styles } from '../styles';
|
import { styles } from '../styles';
|
||||||
|
|
||||||
export default function Field({ label, children }) {
|
export default function Field({ label, icon, children }) {
|
||||||
return (
|
return (
|
||||||
<View style={styles.fieldWrap}>
|
<View className={styles.fieldWrap}>
|
||||||
<Text style={styles.label}>{label}</Text>
|
<View className={styles.labelRow}>
|
||||||
|
{icon ? <Ionicons name={icon} size={14} color="#d4d4d8" /> : null}
|
||||||
|
<Text className={styles.label}>{label}</Text>
|
||||||
|
</View>
|
||||||
{children}
|
{children}
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,35 +1,95 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Image, Pressable, Text, View } from 'react-native';
|
import { Image, Pressable, Text, View } from 'react-native';
|
||||||
|
import Ionicons from '@expo/vector-icons/Ionicons';
|
||||||
import { STATUS_COLORS } from '../constants';
|
import { STATUS_COLORS } from '../constants';
|
||||||
import { styles } from '../styles';
|
import { styles } from '../styles';
|
||||||
|
import { cn } from '../utils/cn';
|
||||||
|
import { formatStatusLabel, normalizeQuantity } from '../utils/labels';
|
||||||
|
|
||||||
function statusAccent(status) {
|
function statusAccent(status) {
|
||||||
return STATUS_COLORS[status] || '#64748b';
|
return STATUS_COLORS[status] || '#64748b';
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function ItemCard({ item, onEdit, onDelete }) {
|
export default function ItemCard({ item, onEdit, onDelete, onQuickPack, onQuickUnpack, onOpenImage }) {
|
||||||
|
const isPacked = item.status === 'packed';
|
||||||
|
const isUnpacked = item.status === 'unpacked';
|
||||||
|
const quantity = normalizeQuantity(item.quantity, 1);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={styles.itemCard}>
|
<View className={styles.itemCard}>
|
||||||
<View style={[styles.itemAccent, { backgroundColor: statusAccent(item.status) }]} />
|
<View className={styles.itemAccent} style={{ backgroundColor: statusAccent(item.status) }} />
|
||||||
<View style={styles.itemMain}>
|
|
||||||
<View style={styles.cardRow}>
|
<View className={styles.itemThumbWrap}>
|
||||||
<View style={styles.flex}>
|
{item.imageUri ? (
|
||||||
<Text style={styles.itemTitle}>{item.name}</Text>
|
<Pressable onPress={() => onOpenImage?.(item.imageUri)}>
|
||||||
<Text style={styles.itemMeta}>{item.category || 'uncategorized'} · {item.status}</Text>
|
<Image source={{ uri: item.imageUri }} className={styles.itemThumbSmall} />
|
||||||
<Text style={styles.itemMeta}>Location: {item.placement}</Text>
|
</Pressable>
|
||||||
{item.status === 'lent-to' && !!item.lentTo ? <Text style={styles.itemMeta}>Lent to: {item.lentTo}</Text> : null}
|
) : (
|
||||||
{!!item.description ? <Text style={styles.itemMeta}>{item.description}</Text> : null}
|
<View className={styles.itemThumbPlaceholder}>
|
||||||
|
<Ionicons name="briefcase-outline" size={20} color="#a1a1aa" />
|
||||||
</View>
|
</View>
|
||||||
<View style={styles.stackButtons}>
|
)}
|
||||||
<Pressable style={styles.miniBtn} onPress={() => onEdit(item)}>
|
</View>
|
||||||
<Text style={styles.miniBtnText}>Edit</Text>
|
|
||||||
|
<View className={styles.itemMain}>
|
||||||
|
<View className={styles.cardRow}>
|
||||||
|
<View className={styles.flex}>
|
||||||
|
<Text className={styles.itemTitle} numberOfLines={1}>{item.name}</Text>
|
||||||
|
<View className={styles.sectionHeaderLeft}>
|
||||||
|
<Ionicons name="albums-outline" size={12} color="#a1a1aa" />
|
||||||
|
<Text className={styles.itemMeta}>Qty: {quantity}</Text>
|
||||||
|
</View>
|
||||||
|
<View className={styles.sectionHeaderLeft}>
|
||||||
|
<Ionicons name="layers-outline" size={12} color="#a1a1aa" />
|
||||||
|
<Text className={styles.itemMeta} numberOfLines={1}>{item.category || 'uncategorized'} · {formatStatusLabel(item.status, item.lentTo)}</Text>
|
||||||
|
</View>
|
||||||
|
<View className={styles.sectionHeaderLeft}>
|
||||||
|
<Ionicons name="pin-outline" size={12} color="#a1a1aa" />
|
||||||
|
<Text className={styles.itemMeta}>Location: {item.placement}</Text>
|
||||||
|
</View>
|
||||||
|
{item.status === 'lent-to' && !!item.lentTo ? (
|
||||||
|
<View className={styles.sectionHeaderLeft}>
|
||||||
|
<Ionicons name="person-outline" size={12} color="#a1a1aa" />
|
||||||
|
<Text className={styles.itemMeta} numberOfLines={1}>Borrower: {item.lentTo}</Text>
|
||||||
|
</View>
|
||||||
|
) : null}
|
||||||
|
{!!item.description ? (
|
||||||
|
<View className={styles.sectionHeaderLeft}>
|
||||||
|
<Ionicons name="document-text-outline" size={12} color="#a1a1aa" />
|
||||||
|
<Text className={styles.itemMeta} numberOfLines={2}>{item.description}</Text>
|
||||||
|
</View>
|
||||||
|
) : null}
|
||||||
|
</View>
|
||||||
|
<View className={styles.stackButtons}>
|
||||||
|
<Pressable className={styles.miniBtn} onPress={() => onEdit(item)}>
|
||||||
|
<View className={styles.buttonContent}>
|
||||||
|
<Ionicons name="create-outline" size={12} color="#f4f4f5" />
|
||||||
|
<Text className={styles.miniBtnText}>Edit</Text>
|
||||||
|
</View>
|
||||||
</Pressable>
|
</Pressable>
|
||||||
<Pressable style={styles.miniBtnDanger} onPress={() => onDelete(item.id)}>
|
<Pressable className={styles.miniBtnDanger} onPress={() => onDelete(item.id)}>
|
||||||
<Text style={styles.miniBtnText}>Delete</Text>
|
<View className={styles.buttonContent}>
|
||||||
|
<Ionicons name="trash-outline" size={12} color="#f4f4f5" />
|
||||||
|
<Text className={styles.miniBtnText}>Delete</Text>
|
||||||
|
</View>
|
||||||
</Pressable>
|
</Pressable>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
{item.imageUri ? <Image source={{ uri: item.imageUri }} style={styles.previewImageSmall} /> : null}
|
|
||||||
|
<View className={styles.quickStatusRow}>
|
||||||
|
<Pressable className={cn(styles.quickStatusBtn, isPacked && styles.quickStatusBtnActive)} onPress={onQuickPack}>
|
||||||
|
<View className={styles.buttonContent}>
|
||||||
|
<Ionicons name="checkmark-circle-outline" size={12} color={isPacked ? '#e0f2fe' : '#d4d4d8'} />
|
||||||
|
<Text className={cn(styles.quickStatusBtnText, isPacked && styles.quickStatusBtnTextActive)}>Packed</Text>
|
||||||
|
</View>
|
||||||
|
</Pressable>
|
||||||
|
<Pressable className={cn(styles.quickStatusBtn, isUnpacked && styles.quickStatusBtnActive)} onPress={onQuickUnpack}>
|
||||||
|
<View className={styles.buttonContent}>
|
||||||
|
<Ionicons name="remove-circle-outline" size={12} color={isUnpacked ? '#e0f2fe' : '#d4d4d8'} />
|
||||||
|
<Text className={cn(styles.quickStatusBtnText, isUnpacked && styles.quickStatusBtnTextActive)}>Unpacked</Text>
|
||||||
|
</View>
|
||||||
|
</Pressable>
|
||||||
|
</View>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,28 +1,91 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Pressable, ScrollView, Text, View } from 'react-native';
|
import { Pressable, ScrollView, Text, View, useWindowDimensions } from 'react-native';
|
||||||
|
import Ionicons from '@expo/vector-icons/Ionicons';
|
||||||
import { styles } from '../styles';
|
import { styles } from '../styles';
|
||||||
|
import { cn } from '../utils/cn';
|
||||||
|
|
||||||
export default function TripPicker({ trips, selectedTripId, onChooseTrip }) {
|
export default function TripPicker({ trips, selectedTripId, onChooseTrip }) {
|
||||||
|
const { width } = useWindowDimensions();
|
||||||
|
const sortedTrips = trips.slice().sort((a, b) => b.startDate.localeCompare(a.startDate));
|
||||||
|
const useHorizontalScroll = sortedTrips.length > 2;
|
||||||
|
const extraTripCount = Math.max(0, sortedTrips.length - 2);
|
||||||
|
const scrollCardWidth = Math.max(152, Math.floor((width - 32) * 0.46));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={styles.tripPickerWrap}>
|
<View className={styles.tripPickerWrap}>
|
||||||
<ScrollView horizontal showsHorizontalScrollIndicator={false} contentContainerStyle={styles.tripChipScroll}>
|
<View className={styles.sectionHeader}>
|
||||||
{trips.length ? (
|
<View className={styles.sectionHeaderLeft}>
|
||||||
trips
|
<Ionicons name="map-outline" size={14} color="#d4d4d8" />
|
||||||
.slice()
|
<Text className={styles.tripPickerTitle}>Choose Trip</Text>
|
||||||
.sort((a, b) => b.startDate.localeCompare(a.startDate))
|
</View>
|
||||||
.map((trip) => {
|
{useHorizontalScroll ? <Text className={styles.tripPickerMoreBadge}>+{extraTripCount} more</Text> : null}
|
||||||
|
</View>
|
||||||
|
|
||||||
|
{trips.length ? (
|
||||||
|
useHorizontalScroll ? (
|
||||||
|
<>
|
||||||
|
<ScrollView
|
||||||
|
horizontal
|
||||||
|
nestedScrollEnabled
|
||||||
|
showsHorizontalScrollIndicator={false}
|
||||||
|
contentContainerStyle={styles.tripPickerScrollRow}
|
||||||
|
>
|
||||||
|
{sortedTrips.map((trip) => {
|
||||||
|
const active = selectedTripId === trip.id;
|
||||||
|
return (
|
||||||
|
<Pressable
|
||||||
|
key={trip.id}
|
||||||
|
className={cn(styles.tripChip, active && styles.tripChipActive)}
|
||||||
|
style={{ width: scrollCardWidth }}
|
||||||
|
onPress={() => onChooseTrip(trip.id)}
|
||||||
|
>
|
||||||
|
<View className={styles.sectionHeader}>
|
||||||
|
<View className={cn(styles.sectionHeaderLeft, styles.flex)}>
|
||||||
|
<Ionicons name="airplane-outline" size={14} color={active ? '#dbeafe' : '#d4d4d8'} />
|
||||||
|
<Text className={cn(styles.tripChipText, active && styles.tripChipTextActive)} numberOfLines={1}>{trip.name}</Text>
|
||||||
|
</View>
|
||||||
|
{active ? <Ionicons name="checkmark-circle" size={16} color="#bfdbfe" /> : null}
|
||||||
|
</View>
|
||||||
|
<Text className={cn(styles.tripChipSub, active && styles.tripChipSubActive)}>{trip.startDate}</Text>
|
||||||
|
</Pressable>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</ScrollView>
|
||||||
|
|
||||||
|
<View className={styles.tripPickerMoreHintRow}>
|
||||||
|
<Ionicons name="arrow-forward-circle-outline" size={13} color="#94a3b8" />
|
||||||
|
<Text className={styles.tripPickerMoreHintText}>Swipe to see {extraTripCount} more</Text>
|
||||||
|
</View>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<View style={styles.tripPickerGrid}>
|
||||||
|
{sortedTrips.map((trip) => {
|
||||||
const active = selectedTripId === trip.id;
|
const active = selectedTripId === trip.id;
|
||||||
return (
|
return (
|
||||||
<Pressable key={trip.id} style={[styles.tripChip, active && styles.tripChipActive]} onPress={() => onChooseTrip(trip.id)}>
|
<Pressable
|
||||||
<Text style={[styles.tripChipText, active && styles.tripChipTextActive]}>{trip.name}</Text>
|
key={trip.id}
|
||||||
<Text style={[styles.tripChipSub, active && styles.tripChipSubActive]}>{trip.startDate}</Text>
|
className={cn(styles.tripChip, active && styles.tripChipActive)}
|
||||||
|
style={sortedTrips.length === 1 ? styles.tripChipSingle : styles.tripChipGridItem}
|
||||||
|
onPress={() => onChooseTrip(trip.id)}
|
||||||
|
>
|
||||||
|
<View className={styles.sectionHeader}>
|
||||||
|
<View className={cn(styles.sectionHeaderLeft, styles.flex)}>
|
||||||
|
<Ionicons name="airplane-outline" size={14} color={active ? '#dbeafe' : '#d4d4d8'} />
|
||||||
|
<Text className={cn(styles.tripChipText, active && styles.tripChipTextActive)} numberOfLines={1}>{trip.name}</Text>
|
||||||
|
</View>
|
||||||
|
{active ? <Ionicons name="checkmark-circle" size={16} color="#bfdbfe" /> : null}
|
||||||
|
</View>
|
||||||
|
<Text className={cn(styles.tripChipSub, active && styles.tripChipSubActive)}>{trip.startDate}</Text>
|
||||||
</Pressable>
|
</Pressable>
|
||||||
);
|
);
|
||||||
})
|
})}
|
||||||
) : (
|
</View>
|
||||||
<Text style={styles.muted}>Create your first trip to start.</Text>
|
)
|
||||||
)}
|
) : (
|
||||||
</ScrollView>
|
<View className={styles.cardSoft}>
|
||||||
|
<Text className={styles.muted}>Create your first trip to start.</Text>
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
163
src/modals/BackupModal.js
Normal file
163
src/modals/BackupModal.js
Normal file
@@ -0,0 +1,163 @@
|
|||||||
|
import React, { useEffect, useRef, useState } from 'react';
|
||||||
|
import { KeyboardAvoidingView, Modal, Platform, Pressable, ScrollView, Text, TextInput, View } from 'react-native';
|
||||||
|
import Ionicons from '@expo/vector-icons/Ionicons';
|
||||||
|
import { styles } from '../styles';
|
||||||
|
import { cn } from '../utils/cn';
|
||||||
|
|
||||||
|
export default function BackupModal({
|
||||||
|
visible,
|
||||||
|
onClose,
|
||||||
|
exportJson,
|
||||||
|
importJson,
|
||||||
|
setImportJson,
|
||||||
|
exportFile,
|
||||||
|
importFile,
|
||||||
|
applyImport,
|
||||||
|
}) {
|
||||||
|
const exportInputRef = useRef(null);
|
||||||
|
const [showExportJson, setShowExportJson] = useState(false);
|
||||||
|
const [copyState, setCopyState] = useState('idle');
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!visible) return;
|
||||||
|
setShowExportJson(false);
|
||||||
|
setCopyState('idle');
|
||||||
|
}, [visible]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (copyState !== 'copied') return undefined;
|
||||||
|
const timeout = setTimeout(() => setCopyState('idle'), 1400);
|
||||||
|
return () => clearTimeout(timeout);
|
||||||
|
}, [copyState]);
|
||||||
|
|
||||||
|
async function handleCopyData() {
|
||||||
|
if (Platform.OS === 'web' && typeof navigator !== 'undefined' && navigator.clipboard?.writeText) {
|
||||||
|
try {
|
||||||
|
await navigator.clipboard.writeText(exportJson);
|
||||||
|
setCopyState('copied');
|
||||||
|
return;
|
||||||
|
} catch {
|
||||||
|
// fall through to manual copy fallback
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setShowExportJson(true);
|
||||||
|
setCopyState('manual');
|
||||||
|
|
||||||
|
if (Platform.OS === 'android') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
requestAnimationFrame(() => {
|
||||||
|
exportInputRef.current?.focus?.();
|
||||||
|
if (exportInputRef.current?.setNativeProps) {
|
||||||
|
exportInputRef.current.setNativeProps({
|
||||||
|
selection: { start: 0, end: exportJson.length },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Modal visible={visible} animationType="none" transparent>
|
||||||
|
<View className={styles.modalBackdrop}>
|
||||||
|
<KeyboardAvoidingView behavior={Platform.OS === 'ios' ? 'padding' : undefined} className={styles.modalKeyboardWrap}>
|
||||||
|
<View className={styles.modalCard}>
|
||||||
|
<View className={styles.sectionHeader}>
|
||||||
|
<View className={styles.sectionHeaderLeft}>
|
||||||
|
<View className={styles.sectionHeaderIconWrap}>
|
||||||
|
<Ionicons name="cloud-upload-outline" size={16} color="#d4d4d8" />
|
||||||
|
</View>
|
||||||
|
<Text className={styles.cardTitle}>Backup & Restore</Text>
|
||||||
|
</View>
|
||||||
|
<Pressable className={styles.secondaryBtnTight} onPress={onClose}>
|
||||||
|
<View className={styles.buttonContent}>
|
||||||
|
<Ionicons name="close" size={14} color="#f4f4f5" />
|
||||||
|
<Text className={styles.secondaryBtnText}>Close</Text>
|
||||||
|
</View>
|
||||||
|
</Pressable>
|
||||||
|
</View>
|
||||||
|
|
||||||
|
<ScrollView keyboardShouldPersistTaps="handled" contentContainerStyle={styles.modalScrollContent} showsVerticalScrollIndicator={false}>
|
||||||
|
<View className={styles.sectionHeaderLeft}>
|
||||||
|
<Ionicons name="download-outline" size={14} color="#d4d4d8" />
|
||||||
|
<Text className={styles.cardTitle}>Export JSON</Text>
|
||||||
|
</View>
|
||||||
|
<Text className={styles.cardMeta}>Use Show JSON or Copy Data.</Text>
|
||||||
|
|
||||||
|
<View className={styles.actionRow}>
|
||||||
|
<Pressable className={cn(styles.secondaryBtnTight, styles.flex)} onPress={() => setShowExportJson((prev) => !prev)}>
|
||||||
|
<View className={styles.buttonContent}>
|
||||||
|
<Ionicons name={showExportJson ? 'eye-off-outline' : 'eye-outline'} size={14} color="#f4f4f5" />
|
||||||
|
<Text className={styles.secondaryBtnText}>{showExportJson ? 'Hide JSON' : 'Show JSON'}</Text>
|
||||||
|
</View>
|
||||||
|
</Pressable>
|
||||||
|
|
||||||
|
<Pressable className={cn(styles.primaryBtnTight, styles.flex)} onPress={handleCopyData}>
|
||||||
|
<View className={styles.buttonContent}>
|
||||||
|
<Ionicons name={copyState === 'copied' ? 'checkmark-circle-outline' : 'copy-outline'} size={14} color="#ffffff" />
|
||||||
|
<Text className={styles.primaryBtnText}>{copyState === 'copied' ? 'Copied' : 'Copy Data'}</Text>
|
||||||
|
</View>
|
||||||
|
</Pressable>
|
||||||
|
</View>
|
||||||
|
|
||||||
|
<Pressable className={styles.secondaryBtn} onPress={exportFile}>
|
||||||
|
<View className={styles.buttonContent}>
|
||||||
|
<Ionicons name="share-social-outline" size={15} color="#f4f4f5" />
|
||||||
|
<Text className={styles.secondaryBtnText}>Export File</Text>
|
||||||
|
</View>
|
||||||
|
</Pressable>
|
||||||
|
|
||||||
|
{copyState === 'manual' ? (
|
||||||
|
<Text className={styles.cardMeta}>Direct clipboard is unavailable here. JSON is shown for manual copy.</Text>
|
||||||
|
) : null}
|
||||||
|
|
||||||
|
{showExportJson ? (
|
||||||
|
Platform.OS === 'android' ? (
|
||||||
|
<View style={styles.exportJsonBlock}>
|
||||||
|
<Text style={styles.exportJsonText} selectable>{exportJson}</Text>
|
||||||
|
</View>
|
||||||
|
) : (
|
||||||
|
<TextInput
|
||||||
|
ref={exportInputRef}
|
||||||
|
style={styles.inputMultiline}
|
||||||
|
multiline
|
||||||
|
value={exportJson}
|
||||||
|
editable={false}
|
||||||
|
selectTextOnFocus
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
) : null}
|
||||||
|
|
||||||
|
<View className={styles.sectionHeaderLeft}>
|
||||||
|
<Ionicons name="cloud-upload-outline" size={14} color="#d4d4d8" />
|
||||||
|
<Text className={styles.cardTitle}>Import JSON</Text>
|
||||||
|
</View>
|
||||||
|
<Text className={styles.cardMeta}>Paste a previous backup. This will replace current data.</Text>
|
||||||
|
<Pressable className={styles.secondaryBtn} onPress={importFile}>
|
||||||
|
<View className={styles.buttonContent}>
|
||||||
|
<Ionicons name="document-outline" size={15} color="#f4f4f5" />
|
||||||
|
<Text className={styles.secondaryBtnText}>Pick Backup File</Text>
|
||||||
|
</View>
|
||||||
|
</Pressable>
|
||||||
|
<TextInput
|
||||||
|
style={styles.inputMultiline}
|
||||||
|
multiline
|
||||||
|
value={importJson}
|
||||||
|
onChangeText={setImportJson}
|
||||||
|
placeholder="Paste backup JSON here"
|
||||||
|
placeholderTextColor="#71717a"
|
||||||
|
/>
|
||||||
|
<Pressable className={styles.primaryBtn} onPress={applyImport}>
|
||||||
|
<View className={styles.buttonContent}>
|
||||||
|
<Ionicons name="sync-outline" size={15} color="#ffffff" />
|
||||||
|
<Text className={styles.primaryBtnText}>Import & Replace</Text>
|
||||||
|
</View>
|
||||||
|
</Pressable>
|
||||||
|
</ScrollView>
|
||||||
|
</View>
|
||||||
|
</KeyboardAvoidingView>
|
||||||
|
</View>
|
||||||
|
</Modal>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { KeyboardAvoidingView, Modal, Platform, Pressable, ScrollView, Text, TextInput, View } from 'react-native';
|
import { KeyboardAvoidingView, Modal, Platform, Pressable, ScrollView, Text, TextInput, View } from 'react-native';
|
||||||
|
import Ionicons from '@expo/vector-icons/Ionicons';
|
||||||
import { ITEM_PLACEMENTS, ITEM_STATUSES } from '../constants';
|
import { ITEM_PLACEMENTS, ITEM_STATUSES } from '../constants';
|
||||||
import ChipGroup from '../components/ChipGroup';
|
import ChipGroup from '../components/ChipGroup';
|
||||||
import Field from '../components/Field';
|
import Field from '../components/Field';
|
||||||
@@ -14,18 +15,31 @@ export default function CheckupFixModal({
|
|||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<Modal visible={visible} animationType="slide" transparent>
|
<Modal visible={visible} animationType="slide" transparent>
|
||||||
<View style={styles.modalBackdrop}>
|
<View className={styles.modalBackdrop}>
|
||||||
<KeyboardAvoidingView behavior={Platform.OS === 'ios' ? 'padding' : 'height'} style={styles.modalKeyboardWrap}>
|
<KeyboardAvoidingView behavior={Platform.OS === 'ios' ? 'padding' : undefined} className={styles.modalKeyboardWrap}>
|
||||||
<View style={styles.modalCard}>
|
<View className={styles.modalCard}>
|
||||||
<View style={styles.sectionRow}>
|
<View className={styles.sectionHeader}>
|
||||||
<Text style={styles.sectionTitle}>Update for this Check-Up</Text>
|
<View className={styles.sectionHeaderLeft}>
|
||||||
<Pressable onPress={() => setCheckupFixModalVisible(false)}>
|
<View className={styles.sectionHeaderIconWrap}>
|
||||||
<Text style={styles.closeText}>Close</Text>
|
<Ionicons name="build-outline" size={16} color="#d4d4d8" />
|
||||||
|
</View>
|
||||||
|
<Text className={styles.cardTitle}>Update for this Check-Up</Text>
|
||||||
|
</View>
|
||||||
|
<Pressable className={styles.secondaryBtnTight} onPress={() => setCheckupFixModalVisible(false)}>
|
||||||
|
<View className={styles.buttonContent}>
|
||||||
|
<Ionicons name="close" size={14} color="#f4f4f5" />
|
||||||
|
<Text className={styles.secondaryBtnText}>Close</Text>
|
||||||
|
</View>
|
||||||
</Pressable>
|
</Pressable>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<ScrollView keyboardShouldPersistTaps="handled" showsVerticalScrollIndicator={false}>
|
<ScrollView
|
||||||
<Field label="Status">
|
keyboardShouldPersistTaps="handled"
|
||||||
|
keyboardDismissMode="interactive"
|
||||||
|
contentContainerStyle={styles.modalScrollContent}
|
||||||
|
showsVerticalScrollIndicator={false}
|
||||||
|
>
|
||||||
|
<Field label="Status" icon="radio-button-on-outline">
|
||||||
<ChipGroup
|
<ChipGroup
|
||||||
options={ITEM_STATUSES}
|
options={ITEM_STATUSES}
|
||||||
value={checkupFixForm.status}
|
value={checkupFixForm.status}
|
||||||
@@ -33,7 +47,7 @@ export default function CheckupFixModal({
|
|||||||
/>
|
/>
|
||||||
</Field>
|
</Field>
|
||||||
|
|
||||||
<Field label="Placement">
|
<Field label="Placement" icon="pin-outline">
|
||||||
<ChipGroup
|
<ChipGroup
|
||||||
options={ITEM_PLACEMENTS}
|
options={ITEM_PLACEMENTS}
|
||||||
value={checkupFixForm.placement}
|
value={checkupFixForm.placement}
|
||||||
@@ -42,28 +56,32 @@ export default function CheckupFixModal({
|
|||||||
</Field>
|
</Field>
|
||||||
|
|
||||||
{checkupFixForm.status === 'lent-to' ? (
|
{checkupFixForm.status === 'lent-to' ? (
|
||||||
<Field label="Lent to">
|
<Field label="Lent to" icon="person-outline">
|
||||||
<TextInput
|
<TextInput
|
||||||
style={styles.input}
|
className={styles.input}
|
||||||
value={checkupFixForm.lentTo}
|
value={checkupFixForm.lentTo}
|
||||||
onChangeText={(v) => setCheckupFixForm((prev) => ({ ...prev, lentTo: v }))}
|
onChangeText={(v) => setCheckupFixForm((prev) => ({ ...prev, lentTo: v }))}
|
||||||
placeholder="Person name"
|
placeholder="Person name"
|
||||||
placeholderTextColor="#6b7280"
|
placeholderTextColor="#71717a"
|
||||||
/>
|
/>
|
||||||
</Field>
|
</Field>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
<Pressable
|
<Pressable
|
||||||
style={styles.inlineToggle}
|
className={styles.inlineToggle}
|
||||||
onPress={() => setCheckupFixForm((prev) => ({ ...prev, updateMasterList: !prev.updateMasterList }))}
|
onPress={() => setCheckupFixForm((prev) => ({ ...prev, updateMasterList: !prev.updateMasterList }))}
|
||||||
>
|
>
|
||||||
<Text style={styles.inlineToggleText}>
|
<View className={styles.sectionHeaderLeft}>
|
||||||
{checkupFixForm.updateMasterList ? '☑' : '☐'} Also update item in trip list
|
<Ionicons name={checkupFixForm.updateMasterList ? 'checkbox-outline' : 'square-outline'} size={16} color="#d4d4d8" />
|
||||||
</Text>
|
<Text className={styles.inlineToggleText}>Also update item in trip list</Text>
|
||||||
|
</View>
|
||||||
</Pressable>
|
</Pressable>
|
||||||
|
|
||||||
<Pressable style={styles.primaryBtn} onPress={saveFixModal}>
|
<Pressable className={styles.primaryBtn} onPress={saveFixModal}>
|
||||||
<Text style={styles.primaryBtnText}>Save</Text>
|
<View className={styles.buttonContent}>
|
||||||
|
<Ionicons name="checkmark-circle-outline" size={15} color="#ffffff" />
|
||||||
|
<Text className={styles.primaryBtnText}>Save</Text>
|
||||||
|
</View>
|
||||||
</Pressable>
|
</Pressable>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
197
src/modals/CheckupFlowModal.js
Normal file
197
src/modals/CheckupFlowModal.js
Normal file
@@ -0,0 +1,197 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { KeyboardAvoidingView, Modal, Platform, Pressable, ScrollView, Text, TextInput, View } from 'react-native';
|
||||||
|
import Ionicons from '@expo/vector-icons/Ionicons';
|
||||||
|
import { ITEM_PLACEMENTS, ITEM_STATUSES } from '../constants';
|
||||||
|
import ChipGroup from '../components/ChipGroup';
|
||||||
|
import Field from '../components/Field';
|
||||||
|
import { styles } from '../styles';
|
||||||
|
import { cn } from '../utils/cn';
|
||||||
|
import { formatItemLabel, formatStatusLabel } from '../utils/labels';
|
||||||
|
|
||||||
|
export default function CheckupFlowModal({
|
||||||
|
visible,
|
||||||
|
entry,
|
||||||
|
stepIndex,
|
||||||
|
total,
|
||||||
|
mode,
|
||||||
|
noForm,
|
||||||
|
setNoForm,
|
||||||
|
onClose,
|
||||||
|
onYes,
|
||||||
|
onNo,
|
||||||
|
onSaveNo,
|
||||||
|
onSkip,
|
||||||
|
onBack,
|
||||||
|
onFinish,
|
||||||
|
}) {
|
||||||
|
const finished = !entry;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Modal visible={visible} animationType="slide" transparent>
|
||||||
|
<View className={styles.modalBackdrop}>
|
||||||
|
<KeyboardAvoidingView behavior={Platform.OS === 'ios' ? 'padding' : undefined} className={styles.modalKeyboardWrap}>
|
||||||
|
<View className={styles.modalCard}>
|
||||||
|
<View className={styles.sectionHeader}>
|
||||||
|
<View className={styles.sectionHeaderLeft}>
|
||||||
|
<View className={styles.sectionHeaderIconWrap}>
|
||||||
|
<Ionicons name="checkmark-circle-outline" size={16} color="#d4d4d8" />
|
||||||
|
</View>
|
||||||
|
<Text className={styles.cardTitle}>Check-Up</Text>
|
||||||
|
</View>
|
||||||
|
<Pressable className={styles.secondaryBtnTight} onPress={onClose}>
|
||||||
|
<View className={styles.buttonContent}>
|
||||||
|
<Ionicons name="close" size={14} color="#f4f4f5" />
|
||||||
|
<Text className={styles.secondaryBtnText}>Close</Text>
|
||||||
|
</View>
|
||||||
|
</Pressable>
|
||||||
|
</View>
|
||||||
|
|
||||||
|
{finished ? (
|
||||||
|
<View className={styles.section}>
|
||||||
|
<Text className={styles.cardTitle}>Done. Save this snapshot?</Text>
|
||||||
|
<Text className={styles.cardMeta}>All {total} items were checked.</Text>
|
||||||
|
<View className={styles.actionRow}>
|
||||||
|
<Pressable className={cn(styles.secondaryBtnTight, styles.flex)} onPress={onBack}>
|
||||||
|
<View className={styles.buttonContent}>
|
||||||
|
<Ionicons name="arrow-back-outline" size={14} color="#f4f4f5" />
|
||||||
|
<Text className={styles.secondaryBtnText}>Back</Text>
|
||||||
|
</View>
|
||||||
|
</Pressable>
|
||||||
|
<Pressable className={cn(styles.primaryBtnTight, styles.flex)} onPress={onFinish}>
|
||||||
|
<View className={styles.buttonContent}>
|
||||||
|
<Ionicons name="save-outline" size={14} color="#ffffff" />
|
||||||
|
<Text className={styles.primaryBtnText}>Save Snapshot</Text>
|
||||||
|
</View>
|
||||||
|
</Pressable>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
) : (
|
||||||
|
<ScrollView
|
||||||
|
keyboardShouldPersistTaps="handled"
|
||||||
|
keyboardDismissMode="interactive"
|
||||||
|
contentContainerStyle={styles.modalScrollContent}
|
||||||
|
showsVerticalScrollIndicator={false}
|
||||||
|
>
|
||||||
|
<Text className={styles.tripHistoryLabel}>
|
||||||
|
Item {stepIndex + 1} / {total}
|
||||||
|
</Text>
|
||||||
|
<View className={styles.checkupProgressTrack}>
|
||||||
|
<View className={styles.checkupProgressFill} style={{ width: `${Math.round(((stepIndex + 1) / total) * 100)}%` }} />
|
||||||
|
</View>
|
||||||
|
<Text className={styles.cardTitle}>{formatItemLabel(entry.name, entry.quantity)}</Text>
|
||||||
|
<View className={styles.sectionHeaderLeft}>
|
||||||
|
<Ionicons name="layers-outline" size={12} color="#a1a1aa" />
|
||||||
|
<Text className={styles.cardMeta}>{entry.category || 'uncategorized'}</Text>
|
||||||
|
</View>
|
||||||
|
<View className={styles.sectionHeaderLeft}>
|
||||||
|
<Ionicons name="pin-outline" size={12} color="#a1a1aa" />
|
||||||
|
<Text className={styles.cardMeta}>
|
||||||
|
Current: {formatStatusLabel(entry.current.status, entry.current.lentTo)} · {entry.current.placement}
|
||||||
|
</Text>
|
||||||
|
</View>
|
||||||
|
|
||||||
|
{mode === 'question' ? (
|
||||||
|
<View className={styles.answerRowWide}>
|
||||||
|
<View className={styles.actionRow}>
|
||||||
|
<Pressable className={cn(styles.secondaryBtnTight, styles.flex)} onPress={onBack}>
|
||||||
|
<View className={styles.buttonContent}>
|
||||||
|
<Ionicons name="arrow-back-outline" size={14} color="#f4f4f5" />
|
||||||
|
<Text className={styles.secondaryBtnText}>Back</Text>
|
||||||
|
</View>
|
||||||
|
</Pressable>
|
||||||
|
<Pressable className={cn(styles.secondaryBtnTight, styles.flex)} onPress={onSkip}>
|
||||||
|
<View className={styles.buttonContent}>
|
||||||
|
<Ionicons name="play-forward-outline" size={14} color="#f4f4f5" />
|
||||||
|
<Text className={styles.secondaryBtnText}>Skip</Text>
|
||||||
|
</View>
|
||||||
|
</Pressable>
|
||||||
|
</View>
|
||||||
|
<Pressable className={styles.answerYesWide} onPress={onYes}>
|
||||||
|
<View className={styles.buttonContent}>
|
||||||
|
<Ionicons name="checkmark-circle-outline" size={14} color="#f8fafc" />
|
||||||
|
<Text className={styles.answerText}>Yes, correct</Text>
|
||||||
|
</View>
|
||||||
|
</Pressable>
|
||||||
|
<Pressable className={styles.answerNoWide} onPress={onNo}>
|
||||||
|
<View className={styles.buttonContent}>
|
||||||
|
<Ionicons name="create-outline" size={14} color="#f8fafc" />
|
||||||
|
<Text className={styles.answerText}>No, update</Text>
|
||||||
|
</View>
|
||||||
|
</Pressable>
|
||||||
|
</View>
|
||||||
|
) : (
|
||||||
|
<View className={styles.section}>
|
||||||
|
<Field label="Status" icon="radio-button-on-outline">
|
||||||
|
<ChipGroup
|
||||||
|
options={ITEM_STATUSES}
|
||||||
|
value={noForm.status}
|
||||||
|
onChange={(v) => setNoForm((prev) => ({ ...prev, status: v }))}
|
||||||
|
/>
|
||||||
|
</Field>
|
||||||
|
|
||||||
|
<Field label="Placement" icon="pin-outline">
|
||||||
|
<ChipGroup
|
||||||
|
options={ITEM_PLACEMENTS}
|
||||||
|
value={noForm.placement}
|
||||||
|
onChange={(v) => setNoForm((prev) => ({ ...prev, placement: v }))}
|
||||||
|
/>
|
||||||
|
</Field>
|
||||||
|
|
||||||
|
{noForm.placement === 'other' ? (
|
||||||
|
<Field label="Custom location" icon="navigate-outline">
|
||||||
|
<TextInput
|
||||||
|
className={styles.input}
|
||||||
|
value={noForm.placementCustom}
|
||||||
|
onChangeText={(v) => setNoForm((prev) => ({ ...prev, placementCustom: v }))}
|
||||||
|
placeholder="bath-kit"
|
||||||
|
placeholderTextColor="#71717a"
|
||||||
|
/>
|
||||||
|
</Field>
|
||||||
|
) : null}
|
||||||
|
|
||||||
|
{noForm.status === 'lent-to' ? (
|
||||||
|
<Field label="Lent to" icon="person-outline">
|
||||||
|
<TextInput
|
||||||
|
className={styles.input}
|
||||||
|
value={noForm.lentTo}
|
||||||
|
onChangeText={(v) => setNoForm((prev) => ({ ...prev, lentTo: v }))}
|
||||||
|
placeholder="Person name"
|
||||||
|
placeholderTextColor="#71717a"
|
||||||
|
/>
|
||||||
|
</Field>
|
||||||
|
) : null}
|
||||||
|
|
||||||
|
<Pressable
|
||||||
|
className={styles.inlineToggle}
|
||||||
|
onPress={() => setNoForm((prev) => ({ ...prev, updateMasterList: !prev.updateMasterList }))}
|
||||||
|
>
|
||||||
|
<View className={styles.sectionHeaderLeft}>
|
||||||
|
<Ionicons name={noForm.updateMasterList ? 'checkbox-outline' : 'square-outline'} size={16} color="#d4d4d8" />
|
||||||
|
<Text className={styles.inlineToggleText}>Also update item in trip list</Text>
|
||||||
|
</View>
|
||||||
|
</Pressable>
|
||||||
|
|
||||||
|
<View className={styles.actionRow}>
|
||||||
|
<Pressable className={cn(styles.secondaryBtnTight, styles.flex)} onPress={onBack}>
|
||||||
|
<View className={styles.buttonContent}>
|
||||||
|
<Ionicons name="arrow-back-outline" size={14} color="#f4f4f5" />
|
||||||
|
<Text className={styles.secondaryBtnText}>Back</Text>
|
||||||
|
</View>
|
||||||
|
</Pressable>
|
||||||
|
<Pressable className={cn(styles.primaryBtnTight, styles.flex)} onPress={onSaveNo}>
|
||||||
|
<View className={styles.buttonContent}>
|
||||||
|
<Ionicons name="arrow-forward-circle-outline" size={14} color="#ffffff" />
|
||||||
|
<Text className={styles.primaryBtnText}>Save + Next</Text>
|
||||||
|
</View>
|
||||||
|
</Pressable>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
|
</ScrollView>
|
||||||
|
)}
|
||||||
|
</View>
|
||||||
|
</KeyboardAvoidingView>
|
||||||
|
</View>
|
||||||
|
</Modal>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,90 +1,426 @@
|
|||||||
import React from 'react';
|
import React, { useEffect, useRef, useState } from 'react';
|
||||||
import { Image, KeyboardAvoidingView, Modal, Platform, Pressable, ScrollView, Text, TextInput, View } from 'react-native';
|
import { Image, KeyboardAvoidingView, Modal, Platform, Pressable, ScrollView, Text, TextInput, View } from 'react-native';
|
||||||
|
import Ionicons from '@expo/vector-icons/Ionicons';
|
||||||
import { ITEM_PLACEMENTS, ITEM_STATUSES } from '../constants';
|
import { ITEM_PLACEMENTS, ITEM_STATUSES } from '../constants';
|
||||||
import ChipGroup from '../components/ChipGroup';
|
|
||||||
import Field from '../components/Field';
|
import Field from '../components/Field';
|
||||||
import { styles } from '../styles';
|
import { styles } from '../styles';
|
||||||
|
import { cn } from '../utils/cn';
|
||||||
|
|
||||||
|
const CATEGORY_OPTIONS = ['toiletries', 'electronics', 'documents', 'outfits', 'accessories', 'other'];
|
||||||
|
const PRESET_CATEGORIES = CATEGORY_OPTIONS.filter((option) => option !== 'other');
|
||||||
|
const IMAGE_QUALITY_OPTIONS = ['low', 'balanced', 'high'];
|
||||||
|
|
||||||
|
function normalizeValue(value) {
|
||||||
|
return (value || '').trim().toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
function optionLabel(value) {
|
||||||
|
return (value || '').replace(/-/g, ' ');
|
||||||
|
}
|
||||||
|
|
||||||
|
function SelectField({ value, placeholder, onPress }) {
|
||||||
|
return (
|
||||||
|
<Pressable className={styles.selectTrigger} onPress={onPress}>
|
||||||
|
<Text className={cn(styles.selectTriggerText, !value && styles.selectTriggerPlaceholder)}>{value ? optionLabel(value) : placeholder}</Text>
|
||||||
|
<Ionicons name="chevron-down" size={16} color="#a1a1aa" />
|
||||||
|
</Pressable>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function SelectPopupModal({ visible, title, options, value, onSelect, onClose }) {
|
||||||
|
if (!visible) return null;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Modal visible={visible} transparent animationType="none" onRequestClose={onClose}>
|
||||||
|
<View className={styles.selectModalBackdrop}>
|
||||||
|
<Pressable className={styles.selectModalBackdropHit} onPress={onClose} />
|
||||||
|
|
||||||
|
<View className={styles.selectModalCard}>
|
||||||
|
<View className={styles.sectionHeader}>
|
||||||
|
<Text className={styles.cardTitle}>{title}</Text>
|
||||||
|
<Pressable className={styles.secondaryBtnTight} onPress={onClose}>
|
||||||
|
<View className={styles.buttonContent}>
|
||||||
|
<Ionicons name="close" size={14} color="#f4f4f5" />
|
||||||
|
<Text className={styles.secondaryBtnText}>Close</Text>
|
||||||
|
</View>
|
||||||
|
</Pressable>
|
||||||
|
</View>
|
||||||
|
|
||||||
|
<View className={styles.selectMenu}>
|
||||||
|
{options.map((option, index) => {
|
||||||
|
const active = value === option;
|
||||||
|
const isLast = index === options.length - 1;
|
||||||
|
return (
|
||||||
|
<Pressable
|
||||||
|
key={option}
|
||||||
|
className={cn(styles.selectMenuItem, active && styles.selectMenuItemActive, isLast && styles.selectMenuItemLast)}
|
||||||
|
onPress={() => onSelect(option)}
|
||||||
|
>
|
||||||
|
<Text className={cn(styles.selectMenuItemText, active && styles.selectMenuItemTextActive)}>{optionLabel(option)}</Text>
|
||||||
|
<Ionicons name={active ? 'checkmark-circle' : 'ellipse-outline'} size={16} color={active ? '#93c5fd' : '#71717a'} />
|
||||||
|
</Pressable>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
</Modal>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function qualityValue(level) {
|
||||||
|
if (level === 'high') return 0.95;
|
||||||
|
if (level === 'low') return 0.45;
|
||||||
|
return 0.75;
|
||||||
|
}
|
||||||
|
|
||||||
export default function ItemModal({
|
export default function ItemModal({
|
||||||
visible,
|
visible,
|
||||||
itemForm,
|
itemForm,
|
||||||
|
previousCustomPlacements,
|
||||||
setItemModalVisible,
|
setItemModalVisible,
|
||||||
updateItemForm,
|
updateItemForm,
|
||||||
pickItemImage,
|
pickItemImage,
|
||||||
|
takeItemImage,
|
||||||
saveItemFromModal,
|
saveItemFromModal,
|
||||||
}) {
|
}) {
|
||||||
|
const [categoryCustomMode, setCategoryCustomMode] = useState(false);
|
||||||
|
const [placementCustomMode, setPlacementCustomMode] = useState(false);
|
||||||
|
const [openPicker, setOpenPicker] = useState(null);
|
||||||
|
const nameInputRef = useRef(null);
|
||||||
|
const quantityInputRef = useRef(null);
|
||||||
|
const descriptionInputRef = useRef(null);
|
||||||
|
const lentToInputRef = useRef(null);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!visible) {
|
||||||
|
setOpenPicker(null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const normalizedCategory = normalizeValue(itemForm.category);
|
||||||
|
const customCategory = !!normalizedCategory && !PRESET_CATEGORIES.includes(normalizedCategory);
|
||||||
|
setCategoryCustomMode(customCategory);
|
||||||
|
setPlacementCustomMode(itemForm.placement === 'other');
|
||||||
|
setOpenPicker(null);
|
||||||
|
}, [visible, itemForm.id]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!visible || itemForm.id) return undefined;
|
||||||
|
|
||||||
|
const timeout = setTimeout(() => {
|
||||||
|
nameInputRef.current?.focus?.();
|
||||||
|
}, 80);
|
||||||
|
|
||||||
|
return () => clearTimeout(timeout);
|
||||||
|
}, [visible, itemForm.id]);
|
||||||
|
|
||||||
|
const mediaOptions = {
|
||||||
|
quality: qualityValue(itemForm.imageQuality),
|
||||||
|
allowCrop: !!itemForm.imageAllowCrop,
|
||||||
|
};
|
||||||
|
|
||||||
|
const normalizedCategory = normalizeValue(itemForm.category);
|
||||||
|
const categorySelectValue = PRESET_CATEGORIES.includes(normalizedCategory) ? normalizedCategory : '';
|
||||||
|
const savedPlacementOptions = (previousCustomPlacements || []).slice(0, 6);
|
||||||
|
const savedPlacementValue = savedPlacementOptions.includes(itemForm.placementCustom) ? itemForm.placementCustom : '';
|
||||||
|
|
||||||
|
const pickerConfig = {
|
||||||
|
category: {
|
||||||
|
title: 'Select category',
|
||||||
|
options: CATEGORY_OPTIONS,
|
||||||
|
value: categorySelectValue,
|
||||||
|
onSelect: chooseCategory,
|
||||||
|
},
|
||||||
|
status: {
|
||||||
|
title: 'Select status',
|
||||||
|
options: ITEM_STATUSES,
|
||||||
|
value: itemForm.status,
|
||||||
|
onSelect: chooseStatus,
|
||||||
|
},
|
||||||
|
placement: {
|
||||||
|
title: 'Select placement',
|
||||||
|
options: ITEM_PLACEMENTS,
|
||||||
|
value: itemForm.placement,
|
||||||
|
onSelect: choosePlacement,
|
||||||
|
},
|
||||||
|
savedPlacement: {
|
||||||
|
title: 'Saved custom locations',
|
||||||
|
options: savedPlacementOptions,
|
||||||
|
value: savedPlacementValue,
|
||||||
|
onSelect: chooseSavedPlacement,
|
||||||
|
},
|
||||||
|
imageQuality: {
|
||||||
|
title: 'Image quality',
|
||||||
|
options: IMAGE_QUALITY_OPTIONS,
|
||||||
|
value: itemForm.imageQuality,
|
||||||
|
onSelect: chooseImageQuality,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const activePicker = openPicker ? pickerConfig[openPicker] : null;
|
||||||
|
|
||||||
|
function chooseCategory(value) {
|
||||||
|
if (value === 'other') {
|
||||||
|
setCategoryCustomMode(true);
|
||||||
|
if (PRESET_CATEGORIES.includes(normalizedCategory)) {
|
||||||
|
updateItemForm('category', '');
|
||||||
|
}
|
||||||
|
setOpenPicker(null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setCategoryCustomMode(false);
|
||||||
|
updateItemForm('category', value);
|
||||||
|
setOpenPicker(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
function chooseStatus(value) {
|
||||||
|
updateItemForm('status', value);
|
||||||
|
setOpenPicker(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
function choosePlacement(value) {
|
||||||
|
if (value === 'other') {
|
||||||
|
setPlacementCustomMode(true);
|
||||||
|
updateItemForm('placement', 'other');
|
||||||
|
setOpenPicker(null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setPlacementCustomMode(false);
|
||||||
|
updateItemForm('placement', value);
|
||||||
|
setOpenPicker(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
function chooseSavedPlacement(value) {
|
||||||
|
updateItemForm('placementCustom', value);
|
||||||
|
setOpenPicker(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
function chooseImageQuality(value) {
|
||||||
|
updateItemForm('imageQuality', value);
|
||||||
|
setOpenPicker(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
function resetCategorySelector() {
|
||||||
|
setCategoryCustomMode(false);
|
||||||
|
updateItemForm('category', '');
|
||||||
|
setOpenPicker(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
function resetPlacementSelector() {
|
||||||
|
setPlacementCustomMode(false);
|
||||||
|
updateItemForm('placement', ITEM_PLACEMENTS[0] || 'suitcase');
|
||||||
|
setOpenPicker(null);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal visible={visible} animationType="slide" transparent>
|
<Modal visible={visible} animationType="none" transparent>
|
||||||
<View style={styles.modalBackdrop}>
|
<View className={styles.modalBackdrop}>
|
||||||
<KeyboardAvoidingView behavior={Platform.OS === 'ios' ? 'padding' : 'height'} style={styles.modalKeyboardWrap}>
|
<KeyboardAvoidingView behavior={Platform.OS === 'ios' ? 'padding' : undefined} className={styles.modalKeyboardWrap}>
|
||||||
<View style={styles.modalCard}>
|
<View className={styles.modalCard}>
|
||||||
<View style={styles.sectionRow}>
|
<View className={styles.sectionHeader}>
|
||||||
<Text style={styles.sectionTitle}>{itemForm.id ? 'Update Item' : 'Add Item'}</Text>
|
<View className={styles.sectionHeaderLeft}>
|
||||||
<Pressable onPress={() => setItemModalVisible(false)}>
|
<View className={styles.sectionHeaderIconWrap}>
|
||||||
<Text style={styles.closeText}>Close</Text>
|
<Ionicons name={itemForm.id ? 'create-outline' : 'add-circle-outline'} size={16} color="#d4d4d8" />
|
||||||
|
</View>
|
||||||
|
<Text className={styles.cardTitle}>{itemForm.id ? 'Update Item' : 'Add Item'}</Text>
|
||||||
|
</View>
|
||||||
|
<Pressable className={styles.secondaryBtnTight} onPress={() => setItemModalVisible(false)}>
|
||||||
|
<View className={styles.buttonContent}>
|
||||||
|
<Ionicons name="close" size={14} color="#f4f4f5" />
|
||||||
|
<Text className={styles.secondaryBtnText}>Close</Text>
|
||||||
|
</View>
|
||||||
</Pressable>
|
</Pressable>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<ScrollView keyboardShouldPersistTaps="handled" showsVerticalScrollIndicator={false}>
|
<ScrollView
|
||||||
<Field label="Name">
|
keyboardShouldPersistTaps="handled"
|
||||||
|
keyboardDismissMode="interactive"
|
||||||
|
contentContainerStyle={styles.modalScrollContent}
|
||||||
|
showsVerticalScrollIndicator={false}
|
||||||
|
>
|
||||||
|
<Field label="Name" icon="text-outline">
|
||||||
<TextInput
|
<TextInput
|
||||||
style={styles.input}
|
ref={nameInputRef}
|
||||||
|
className={styles.input}
|
||||||
value={itemForm.name}
|
value={itemForm.name}
|
||||||
onChangeText={(v) => updateItemForm('name', v)}
|
onChangeText={(v) => updateItemForm('name', v)}
|
||||||
placeholder="Toothbrush"
|
placeholder="Toothbrush"
|
||||||
placeholderTextColor="#6b7280"
|
placeholderTextColor="#71717a"
|
||||||
|
returnKeyType="next"
|
||||||
|
blurOnSubmit={false}
|
||||||
|
onSubmitEditing={() => quantityInputRef.current?.focus?.()}
|
||||||
/>
|
/>
|
||||||
</Field>
|
</Field>
|
||||||
|
|
||||||
<Field label="Description">
|
<Field label="Quantity" icon="albums-outline">
|
||||||
<TextInput
|
<TextInput
|
||||||
style={styles.input}
|
ref={quantityInputRef}
|
||||||
|
className={styles.input}
|
||||||
|
value={`${itemForm.quantity || 1}`}
|
||||||
|
onChangeText={(v) => {
|
||||||
|
const numeric = (v || '').replace(/[^0-9]/g, '');
|
||||||
|
updateItemForm('quantity', numeric ? Math.max(1, Number.parseInt(numeric, 10)) : 1);
|
||||||
|
}}
|
||||||
|
placeholder="1"
|
||||||
|
placeholderTextColor="#71717a"
|
||||||
|
keyboardType="number-pad"
|
||||||
|
returnKeyType="next"
|
||||||
|
blurOnSubmit={false}
|
||||||
|
onSubmitEditing={() => descriptionInputRef.current?.focus?.()}
|
||||||
|
/>
|
||||||
|
</Field>
|
||||||
|
|
||||||
|
<Field label="Description" icon="document-text-outline">
|
||||||
|
<TextInput
|
||||||
|
ref={descriptionInputRef}
|
||||||
|
className={styles.input}
|
||||||
value={itemForm.description}
|
value={itemForm.description}
|
||||||
onChangeText={(v) => updateItemForm('description', v)}
|
onChangeText={(v) => updateItemForm('description', v)}
|
||||||
placeholder="Optional"
|
placeholder="Optional"
|
||||||
placeholderTextColor="#6b7280"
|
placeholderTextColor="#71717a"
|
||||||
|
returnKeyType={itemForm.status === 'lent-to' ? 'next' : 'done'}
|
||||||
|
onSubmitEditing={() => {
|
||||||
|
if (itemForm.status === 'lent-to') {
|
||||||
|
lentToInputRef.current?.focus?.();
|
||||||
|
}
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</Field>
|
</Field>
|
||||||
|
|
||||||
<Field label="Category">
|
<Field label="Category" icon="layers-outline">
|
||||||
<TextInput
|
{categoryCustomMode ? (
|
||||||
style={styles.input}
|
<View className={styles.selectCustomRow}>
|
||||||
value={itemForm.category}
|
<TextInput
|
||||||
onChangeText={(v) => updateItemForm('category', v)}
|
className={cn(styles.input, styles.flex)}
|
||||||
placeholder="toiletries"
|
value={itemForm.category}
|
||||||
placeholderTextColor="#6b7280"
|
onChangeText={(v) => updateItemForm('category', v)}
|
||||||
|
placeholder="Custom category"
|
||||||
|
placeholderTextColor="#71717a"
|
||||||
|
/>
|
||||||
|
<Pressable className={styles.selectCustomResetBtn} onPress={resetCategorySelector}>
|
||||||
|
<Ionicons name="refresh-outline" size={16} color="#d4d4d8" />
|
||||||
|
</Pressable>
|
||||||
|
</View>
|
||||||
|
) : (
|
||||||
|
<SelectField
|
||||||
|
value={categorySelectValue}
|
||||||
|
placeholder="Select category"
|
||||||
|
onPress={() => setOpenPicker('category')}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</Field>
|
||||||
|
|
||||||
|
<Field label="Status" icon="radio-button-on-outline">
|
||||||
|
<SelectField
|
||||||
|
value={itemForm.status}
|
||||||
|
placeholder="Select status"
|
||||||
|
onPress={() => setOpenPicker('status')}
|
||||||
/>
|
/>
|
||||||
</Field>
|
</Field>
|
||||||
|
|
||||||
<Field label="Status">
|
<Field label="Placement" icon="pin-outline">
|
||||||
<ChipGroup options={ITEM_STATUSES} value={itemForm.status} onChange={(v) => updateItemForm('status', v)} />
|
{placementCustomMode ? (
|
||||||
</Field>
|
<View className={styles.fieldWrap}>
|
||||||
|
<View className={styles.selectCustomRow}>
|
||||||
|
<TextInput
|
||||||
|
className={cn(styles.input, styles.flex)}
|
||||||
|
value={itemForm.placementCustom}
|
||||||
|
onChangeText={(v) => updateItemForm('placementCustom', v)}
|
||||||
|
placeholder="bath-kit"
|
||||||
|
placeholderTextColor="#71717a"
|
||||||
|
/>
|
||||||
|
<Pressable className={styles.selectCustomResetBtn} onPress={resetPlacementSelector}>
|
||||||
|
<Ionicons name="refresh-outline" size={16} color="#d4d4d8" />
|
||||||
|
</Pressable>
|
||||||
|
</View>
|
||||||
|
<Text className={styles.cardMeta}>Custom location</Text>
|
||||||
|
|
||||||
<Field label="Placement">
|
{savedPlacementOptions.length ? (
|
||||||
<ChipGroup options={ITEM_PLACEMENTS} value={itemForm.placement} onChange={(v) => updateItemForm('placement', v)} />
|
<SelectField
|
||||||
|
value={savedPlacementValue}
|
||||||
|
placeholder="Use saved custom location"
|
||||||
|
onPress={() => setOpenPicker('savedPlacement')}
|
||||||
|
/>
|
||||||
|
) : null}
|
||||||
|
</View>
|
||||||
|
) : (
|
||||||
|
<SelectField
|
||||||
|
value={itemForm.placement}
|
||||||
|
placeholder="Select placement"
|
||||||
|
onPress={() => setOpenPicker('placement')}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</Field>
|
</Field>
|
||||||
|
|
||||||
{itemForm.status === 'lent-to' ? (
|
{itemForm.status === 'lent-to' ? (
|
||||||
<Field label="Lent to">
|
<Field label="Lent to" icon="person-outline">
|
||||||
<TextInput
|
<TextInput
|
||||||
style={styles.input}
|
ref={lentToInputRef}
|
||||||
|
className={styles.input}
|
||||||
value={itemForm.lentTo}
|
value={itemForm.lentTo}
|
||||||
onChangeText={(v) => updateItemForm('lentTo', v)}
|
onChangeText={(v) => updateItemForm('lentTo', v)}
|
||||||
placeholder="Person name"
|
placeholder="Person name"
|
||||||
placeholderTextColor="#6b7280"
|
placeholderTextColor="#71717a"
|
||||||
|
returnKeyType="done"
|
||||||
/>
|
/>
|
||||||
</Field>
|
</Field>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
<Pressable style={styles.secondaryBtn} onPress={pickItemImage}>
|
<View className={styles.actionRow}>
|
||||||
<Text style={styles.secondaryBtnText}>{itemForm.imageUri ? 'Change image' : 'Add image'}</Text>
|
<Pressable className={cn(styles.secondaryBtnTight, styles.flex)} onPress={() => takeItemImage(mediaOptions)}>
|
||||||
</Pressable>
|
<View className={styles.buttonContent}>
|
||||||
{!!itemForm.imageUri && <Image source={{ uri: itemForm.imageUri }} style={styles.previewImageSmall} />}
|
<Ionicons name="camera-outline" size={14} color="#f4f4f5" />
|
||||||
|
<Text className={styles.secondaryBtnText}>Take photo</Text>
|
||||||
|
</View>
|
||||||
|
</Pressable>
|
||||||
|
<Pressable className={cn(styles.secondaryBtnTight, styles.flex)} onPress={() => pickItemImage(mediaOptions)}>
|
||||||
|
<View className={styles.buttonContent}>
|
||||||
|
<Ionicons name="images-outline" size={14} color="#f4f4f5" />
|
||||||
|
<Text className={styles.secondaryBtnText}>{itemForm.imageUri ? 'From gallery (change)' : 'From gallery'}</Text>
|
||||||
|
</View>
|
||||||
|
</Pressable>
|
||||||
|
</View>
|
||||||
|
|
||||||
<Pressable style={styles.primaryBtn} onPress={saveItemFromModal}>
|
{!!itemForm.imageUri ? (
|
||||||
<Text style={styles.primaryBtnText}>{itemForm.id ? 'Save Changes' : 'Add Item'}</Text>
|
<>
|
||||||
|
<Image source={{ uri: itemForm.imageUri }} className={styles.previewImageSmall} />
|
||||||
|
|
||||||
|
<Field label="Image optimization" icon="image-outline">
|
||||||
|
<SelectField
|
||||||
|
value={itemForm.imageQuality}
|
||||||
|
placeholder="Select quality"
|
||||||
|
onPress={() => setOpenPicker('imageQuality')}
|
||||||
|
/>
|
||||||
|
</Field>
|
||||||
|
|
||||||
|
<Pressable className={styles.inlineToggle} onPress={() => updateItemForm('imageAllowCrop', !itemForm.imageAllowCrop)}>
|
||||||
|
<View className={styles.sectionHeaderLeft}>
|
||||||
|
<Ionicons name={itemForm.imageAllowCrop ? 'checkbox-outline' : 'square-outline'} size={16} color="#d4d4d8" />
|
||||||
|
<Text className={styles.inlineToggleText}>Enable optional crop before save</Text>
|
||||||
|
</View>
|
||||||
|
</Pressable>
|
||||||
|
</>
|
||||||
|
) : null}
|
||||||
|
|
||||||
|
<Pressable className={styles.primaryBtn} onPress={saveItemFromModal}>
|
||||||
|
<View className={styles.buttonContent}>
|
||||||
|
<Ionicons name="checkmark-circle-outline" size={15} color="#ffffff" />
|
||||||
|
<Text className={styles.primaryBtnText}>{itemForm.id ? 'Save Changes' : 'Add Item'}</Text>
|
||||||
|
</View>
|
||||||
</Pressable>
|
</Pressable>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
||||||
|
<SelectPopupModal
|
||||||
|
visible={!!activePicker}
|
||||||
|
title={activePicker?.title || 'Select option'}
|
||||||
|
options={activePicker?.options || []}
|
||||||
|
value={activePicker?.value || ''}
|
||||||
|
onSelect={(value) => activePicker?.onSelect?.(value)}
|
||||||
|
onClose={() => setOpenPicker(null)}
|
||||||
|
/>
|
||||||
</View>
|
</View>
|
||||||
</KeyboardAvoidingView>
|
</KeyboardAvoidingView>
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
706
src/styles.js
706
src/styles.js
@@ -1,494 +1,244 @@
|
|||||||
import { Platform, StyleSheet } from 'react-native';
|
import { Platform } from 'react-native';
|
||||||
import { TAB_BAR_HEIGHT } from './constants';
|
import { TAB_BAR_HEIGHT } from './constants';
|
||||||
|
|
||||||
export const styles = StyleSheet.create({
|
export const styles = {
|
||||||
safe: {
|
safe: 'flex-1 bg-[#09090b]',
|
||||||
flex: 1,
|
flex: 'flex-1',
|
||||||
backgroundColor: '#090d12',
|
|
||||||
},
|
|
||||||
flex: {
|
|
||||||
flex: 1,
|
|
||||||
},
|
|
||||||
content: {
|
content: {
|
||||||
paddingHorizontal: 16,
|
paddingHorizontal: 16,
|
||||||
paddingTop: 12,
|
paddingTop: 14,
|
||||||
paddingBottom: TAB_BAR_HEIGHT + 22,
|
paddingBottom: TAB_BAR_HEIGHT + 24,
|
||||||
gap: 14,
|
gap: 18,
|
||||||
},
|
|
||||||
statusSpacer: {
|
|
||||||
height: Platform.OS === 'android' ? 8 : 0,
|
|
||||||
},
|
|
||||||
center: {
|
|
||||||
flex: 1,
|
|
||||||
alignItems: 'center',
|
|
||||||
justifyContent: 'center',
|
|
||||||
},
|
|
||||||
muted: {
|
|
||||||
color: '#8793a5',
|
|
||||||
},
|
},
|
||||||
|
statusSpacer: Platform.OS === 'android' ? 'h-2' : 'h-0',
|
||||||
|
center: 'flex-1 items-center justify-center',
|
||||||
|
muted: 'text-[#a1a1aa] text-sm leading-5',
|
||||||
|
loadingEmoji: 'text-[56px] mb-3',
|
||||||
|
loadingTitle: 'text-[#fafafa] font-black text-[22px] mb-3',
|
||||||
|
loadingBarTrack: 'w-[178px] h-[8px] rounded-full bg-[#1f1f23] border border-[#2f2f35] overflow-hidden mb-2',
|
||||||
|
loadingBarFill: 'h-full rounded-full bg-[#3b82f6]',
|
||||||
|
loadingPercent: 'text-[#a1a1aa] text-xs font-semibold tracking-[0.4px]',
|
||||||
|
|
||||||
tripPickerWrap: {
|
screenHero: 'rounded-xl bg-[#18181b] border border-[#27272a] p-5 gap-2 shadow-md',
|
||||||
marginBottom: 6,
|
screenHeroTop: 'flex-row items-center justify-between gap-3',
|
||||||
|
screenHeroTitle: 'text-[#fafafa] text-[26px] leading-[30px] font-black tracking-tight',
|
||||||
|
screenHeroSubtitle: 'text-[#a1a1aa] text-[13px] leading-[18px]',
|
||||||
|
screenHeroBadge: 'px-3 py-1.5 rounded-lg bg-[#27272a]',
|
||||||
|
screenHeroBadgeText: 'text-[#d4d4d8] text-xs font-semibold',
|
||||||
|
|
||||||
|
sectionHeader: 'flex-row items-center justify-between gap-3',
|
||||||
|
sectionHeaderLeft: 'flex-row items-center gap-2',
|
||||||
|
sectionHeaderIconWrap: 'w-7 h-7 rounded-lg bg-[#27272a] items-center justify-center',
|
||||||
|
sectionSubtle: 'text-[#a1a1aa] text-sm leading-5',
|
||||||
|
|
||||||
|
tripPickerWrap: 'gap-2',
|
||||||
|
tripPickerTitle: 'text-[#d4d4d8] text-sm font-semibold',
|
||||||
|
tripPickerMoreBadge: 'text-[#93c5fd] text-xs font-semibold px-2 py-1 rounded-lg bg-[#172338] border border-[#1e3a5f]',
|
||||||
|
tripPickerGrid: {
|
||||||
|
flexDirection: 'row',
|
||||||
|
flexWrap: 'wrap',
|
||||||
|
gap: 10,
|
||||||
},
|
},
|
||||||
tripChipScroll: {
|
tripPickerScrollRow: {
|
||||||
gap: 8,
|
gap: 10,
|
||||||
paddingRight: 12,
|
paddingRight: 4,
|
||||||
},
|
},
|
||||||
tripChip: {
|
tripPickerMoreHintRow: 'flex-row items-center gap-1.5 px-1',
|
||||||
paddingHorizontal: 12,
|
tripPickerMoreHintText: 'text-[#94a3b8] text-xs font-medium',
|
||||||
paddingVertical: 9,
|
tripChipGridItem: {
|
||||||
borderRadius: 12,
|
width: '48.5%',
|
||||||
backgroundColor: '#121923',
|
},
|
||||||
|
tripChipSingle: {
|
||||||
|
width: '100%',
|
||||||
|
},
|
||||||
|
tripChip: 'px-3.5 py-3.5 rounded-xl bg-[#18181b] border border-[#27272a] gap-1 shadow-md',
|
||||||
|
tripChipActive: 'bg-[#1e293b] border-[#60a5fa]',
|
||||||
|
tripChipText: 'text-[#f4f4f5] font-semibold text-base',
|
||||||
|
tripChipTextActive: 'text-[#f8fafc]',
|
||||||
|
tripChipSub: 'text-[#a1a1aa] text-xs',
|
||||||
|
tripChipSubActive: 'text-[#cbd5e1]',
|
||||||
|
|
||||||
|
section: 'gap-5',
|
||||||
|
sectionTitle: 'text-[#f4f4f5] text-[22px] leading-7 font-black tracking-tight',
|
||||||
|
sectionRow: 'flex-row justify-between items-center gap-3',
|
||||||
|
|
||||||
|
card: 'bg-[#18181b] rounded-xl border border-[#27272a] p-4 gap-3 shadow-md',
|
||||||
|
cardActive: 'border-[#60a5fa]',
|
||||||
|
cardArchived: 'opacity-[0.7] border-[#3f3f46]',
|
||||||
|
cardSoft: 'bg-[#111114] rounded-xl border border-[#27272a] p-4 gap-3 shadow-md',
|
||||||
|
cardRow: 'flex-row gap-3 items-start',
|
||||||
|
cardTitle: 'text-[#fafafa] font-bold text-[17px] leading-6',
|
||||||
|
cardMeta: 'text-[#a1a1aa] text-[13px] leading-[18px]',
|
||||||
|
tripHistoryLabel: 'text-[#93c5fd] text-sm font-medium',
|
||||||
|
tripHeroCard: 'bg-[#18181b] rounded-xl border border-[#27272a] p-5 gap-2 shadow-md',
|
||||||
|
tripHeroImage: 'w-full h-[180px] rounded-xl bg-[#111114]',
|
||||||
|
tripHeroTitle: 'text-[#fafafa] font-black text-[22px] leading-7',
|
||||||
|
tripListTitle: 'text-[#d4d4d8] font-semibold text-sm tracking-[0.5px] uppercase',
|
||||||
|
|
||||||
|
fieldWrap: 'gap-1.5',
|
||||||
|
labelRow: 'flex-row items-center gap-2',
|
||||||
|
label: 'text-[#d4d4d8] font-medium text-sm',
|
||||||
|
input: 'border border-[#3f3f46] rounded-xl bg-[#111114] text-[#f4f4f5] px-3.5 py-3',
|
||||||
|
selectCustomRow: 'flex-row items-center gap-2',
|
||||||
|
selectCustomResetBtn: 'w-11 h-11 rounded-xl bg-[#27272a] border border-[#3f3f46] items-center justify-center',
|
||||||
|
inputMultiline: {
|
||||||
borderWidth: 1,
|
borderWidth: 1,
|
||||||
borderColor: '#1f2937',
|
borderColor: '#3f3f46',
|
||||||
minWidth: 120,
|
borderRadius: 12,
|
||||||
|
backgroundColor: '#111114',
|
||||||
|
color: '#f4f4f5',
|
||||||
|
paddingHorizontal: 12,
|
||||||
|
paddingVertical: 10,
|
||||||
|
minHeight: 150,
|
||||||
|
textAlignVertical: 'top',
|
||||||
|
fontSize: 13,
|
||||||
|
fontFamily: Platform.OS === 'ios' ? 'Menlo' : 'monospace',
|
||||||
},
|
},
|
||||||
tripChipActive: {
|
exportJsonBlock: {
|
||||||
backgroundColor: '#1d2a3a',
|
borderWidth: 1,
|
||||||
borderColor: '#60a5fa',
|
borderColor: '#3f3f46',
|
||||||
|
borderRadius: 12,
|
||||||
|
backgroundColor: '#111114',
|
||||||
|
paddingHorizontal: 12,
|
||||||
|
paddingVertical: 10,
|
||||||
|
minHeight: 150,
|
||||||
},
|
},
|
||||||
tripChipText: {
|
exportJsonText: {
|
||||||
color: '#e2e8f0',
|
color: '#f4f4f5',
|
||||||
fontWeight: '700',
|
fontSize: 13,
|
||||||
},
|
lineHeight: 18,
|
||||||
tripChipTextActive: {
|
fontFamily: Platform.OS === 'ios' ? 'Menlo' : 'monospace',
|
||||||
color: '#bfdbfe',
|
|
||||||
},
|
|
||||||
tripChipSub: {
|
|
||||||
color: '#64748b',
|
|
||||||
fontSize: 12,
|
|
||||||
marginTop: 2,
|
|
||||||
},
|
|
||||||
tripChipSubActive: {
|
|
||||||
color: '#93c5fd',
|
|
||||||
},
|
},
|
||||||
|
dateInput: 'border border-[#3f3f46] rounded-xl bg-[#111114] px-3.5 py-3',
|
||||||
|
dateInputText: 'text-[#e4e4e7] font-medium',
|
||||||
|
|
||||||
section: {
|
chipGroup: 'flex-row flex-wrap gap-2',
|
||||||
|
chip: 'rounded-xl px-3 py-2 border border-[#3f3f46] bg-[#111114]',
|
||||||
|
chipActive: 'border-[#60a5fa] bg-[#172338]',
|
||||||
|
chipText: 'text-[#d4d4d8] font-medium text-xs',
|
||||||
|
chipTextActive: 'text-[#e0f2fe]',
|
||||||
|
selectTrigger: 'rounded-xl border border-[#3f3f46] bg-[#111114] px-3.5 py-3 flex-row items-center justify-between',
|
||||||
|
selectTriggerText: 'text-[#e4e4e7] text-sm font-medium',
|
||||||
|
selectTriggerPlaceholder: 'text-[#71717a] font-normal',
|
||||||
|
selectModalBackdrop: 'absolute inset-0 justify-center px-5',
|
||||||
|
selectModalBackdropHit: 'absolute inset-0 bg-[rgba(9,9,11,0.76)]',
|
||||||
|
selectModalCard: 'bg-[#18181b] rounded-xl border border-[#27272a] p-4 gap-3 shadow-md',
|
||||||
|
selectMenu: 'rounded-xl border border-[#3f3f46] bg-[#111114] overflow-hidden',
|
||||||
|
selectMenuItem: 'px-3.5 py-3 flex-row items-center justify-between border-b border-[#27272a]',
|
||||||
|
selectMenuItemLast: 'border-b-0',
|
||||||
|
selectMenuItemActive: 'bg-[#172338]',
|
||||||
|
selectMenuItemText: 'text-[#d4d4d8] text-sm font-medium',
|
||||||
|
selectMenuItemTextActive: 'text-[#e0f2fe]',
|
||||||
|
|
||||||
|
primaryBtn: 'mt-2 rounded-xl bg-[#2563eb] items-center justify-center py-3 px-3.5 w-full',
|
||||||
|
primaryBtnTight: 'rounded-xl bg-[#2563eb] items-center justify-center py-2.5 px-3.5',
|
||||||
|
primaryBtnText: 'text-white font-semibold text-sm',
|
||||||
|
secondaryBtn: 'mt-2 rounded-xl bg-[#27272a] border border-[#3f3f46] items-center justify-center py-3 px-3.5 w-full',
|
||||||
|
secondaryBtnTight: 'rounded-xl bg-[#27272a] border border-[#3f3f46] items-center justify-center py-2.5 px-3.5',
|
||||||
|
secondaryBtnText: 'text-[#f4f4f5] font-semibold text-sm',
|
||||||
|
actionRow: 'flex-row gap-2 mt-2',
|
||||||
|
actionRowInline: 'flex-row gap-2',
|
||||||
|
buttonContent: 'flex-row items-center justify-center gap-2',
|
||||||
|
|
||||||
|
inlineToggle: 'mt-1 rounded-xl bg-[#111114] border border-[#3f3f46] px-3.5 py-2.5',
|
||||||
|
inlineToggleText: 'text-[#d4d4d8] text-sm',
|
||||||
|
|
||||||
|
stackButtons: 'gap-2',
|
||||||
|
miniBtn: 'bg-[#27272a] border border-[#3f3f46] rounded-xl py-2 px-2.5',
|
||||||
|
miniBtnDanger: 'bg-[#3f1d1d] border border-[#7f1d1d] rounded-xl py-2 px-2.5',
|
||||||
|
miniBtnText: 'text-[#f4f4f5] font-semibold text-xs',
|
||||||
|
|
||||||
|
itemCard: 'rounded-xl bg-[#18181b] border border-[#27272a] overflow-hidden flex-row items-start shadow-md',
|
||||||
|
itemAccent: 'w-[4px] self-stretch',
|
||||||
|
itemThumbWrap: 'pt-4 pl-3.5',
|
||||||
|
itemThumbSmall: 'w-[46px] h-[46px] rounded-xl bg-[#111114]',
|
||||||
|
itemThumbPlaceholder: 'w-[46px] h-[46px] rounded-xl bg-[#111114] items-center justify-center border border-[#3f3f46]',
|
||||||
|
itemThumbPlaceholderText: 'text-xl',
|
||||||
|
itemMain: 'flex-1 p-4 gap-2',
|
||||||
|
itemTitle: 'text-[#fafafa] font-semibold text-base',
|
||||||
|
itemMeta: 'text-[#a1a1aa] text-[13px] leading-[18px]',
|
||||||
|
quickStatusRow: 'flex-row gap-2 mt-1',
|
||||||
|
quickStatusBtn: 'py-1.5 px-2.5 rounded-xl border border-[#3f3f46] bg-[#111114]',
|
||||||
|
quickStatusBtnActive: 'border-[#60a5fa] bg-[#1e293b]',
|
||||||
|
quickStatusBtnText: 'text-[#d4d4d8] font-semibold text-xs',
|
||||||
|
quickStatusBtnTextActive: 'text-[#e0f2fe]',
|
||||||
|
|
||||||
|
answerRow: 'mt-3 flex-row items-center gap-3',
|
||||||
|
answerYes: 'bg-[#14532d] border border-[#166534] rounded-xl px-4 py-3',
|
||||||
|
answerNo: 'bg-[#3f1d1d] border border-[#7f1d1d] rounded-xl px-4 py-3',
|
||||||
|
answerText: 'text-[#f8fafc] font-semibold',
|
||||||
|
answerRowWide: 'mt-4 gap-3',
|
||||||
|
checkupProgressTrack: 'w-full h-2 rounded-full bg-[#27272a] overflow-hidden mt-2 mb-3',
|
||||||
|
checkupProgressFill: 'h-full bg-[#2563eb]',
|
||||||
|
answerYesWide: 'bg-[#14532d] border border-[#166534] rounded-xl px-4 py-3.5 items-center',
|
||||||
|
answerNoWide: 'bg-[#3f1d1d] border border-[#7f1d1d] rounded-xl px-4 py-3.5 items-center',
|
||||||
|
answerStateDot: 'w-[10px] h-[10px] rounded-full bg-[#475569]',
|
||||||
|
answerStateDotOn: 'bg-[#22c55e]',
|
||||||
|
answerStateDotBad: 'bg-[#ef4444]',
|
||||||
|
|
||||||
|
statsRow: 'flex-row gap-2 flex-wrap mt-1',
|
||||||
|
statPill: 'rounded-xl py-1.5 px-2.5 border',
|
||||||
|
statPillCorrect: 'bg-[#14532d] border-[#166534]',
|
||||||
|
statPillBad: 'bg-[#3f1d1d] border-[#7f1d1d]',
|
||||||
|
statPillPending: 'bg-[#27272a] border-[#3f3f46]',
|
||||||
|
statPillText: 'text-[#f4f4f5] font-semibold text-xs',
|
||||||
|
packProgressLabel: 'text-[#d4d4d8] text-sm font-medium',
|
||||||
|
packProgressMeta: 'text-[#a1a1aa] text-xs font-semibold',
|
||||||
|
packProgressTrack: 'w-full h-2 rounded-full bg-[#27272a] overflow-hidden',
|
||||||
|
packProgressFill: 'h-full bg-[#22c55e]',
|
||||||
|
|
||||||
|
snapshotWrap: 'mt-3 border-t border-t-[#27272a] pt-3 gap-2',
|
||||||
|
snapshotRow: 'py-1.5',
|
||||||
|
snapshotTitle: 'text-[#f4f4f5] font-medium text-sm',
|
||||||
|
|
||||||
|
previewImage: 'w-full h-[160px] rounded-xl bg-[#111114]',
|
||||||
|
previewImageSmall: 'w-full h-[132px] rounded-xl bg-[#111114]',
|
||||||
|
imagePreviewBackdrop: 'flex-1 bg-[rgba(9,9,11,0.88)] items-center justify-center px-5',
|
||||||
|
imagePreviewCard: 'w-full max-w-[460px] rounded-xl border border-[#3f3f46] bg-[#18181b] p-5 gap-3 shadow-md',
|
||||||
|
imagePreviewImage: 'w-full h-[360px] rounded-xl bg-[#111114]',
|
||||||
|
imagePreviewHint: 'text-[#a1a1aa] text-center text-xs font-medium',
|
||||||
|
|
||||||
|
tabBarWrap: Platform.OS === 'ios'
|
||||||
|
? 'absolute bottom-[6px] left-0 right-0 px-[10px] pb-[14px]'
|
||||||
|
: 'absolute bottom-[6px] left-0 right-0 px-[10px] pb-2',
|
||||||
|
tabBar: 'h-[72px] rounded-2xl bg-[#0b1220] border border-[#1f2937] flex-row items-center justify-between px-2',
|
||||||
|
tabGroupSide: 'flex-row w-[42%] justify-around items-center',
|
||||||
|
tabItem: 'items-center justify-center gap-[3px] min-w-[56px]',
|
||||||
|
tabAddBtn: 'w-[54px] h-[54px] rounded-full items-center justify-center bg-[#2563eb] -mt-6 border-2 border-[#0b1220]',
|
||||||
|
tabAddBtnDisabled: 'opacity-[0.45]',
|
||||||
|
tabLabel: 'text-[#94a3b8] text-[11px] font-semibold',
|
||||||
|
tabLabelActive: 'text-[#dbeafe]',
|
||||||
|
|
||||||
|
modalBackdrop: 'flex-1 bg-[rgba(9,9,11,0.8)] px-5',
|
||||||
|
dialogBackdrop: 'flex-1 bg-[rgba(9,9,11,0.8)] items-center justify-center px-6',
|
||||||
|
dialogCard: 'w-full bg-[#18181b] rounded-xl border border-[#27272a] p-6 gap-5 shadow-md',
|
||||||
|
dialogTitle: 'text-[#fafafa] font-bold text-lg',
|
||||||
|
dialogMessage: 'text-[#d4d4d8] leading-6 text-sm',
|
||||||
|
dialogButtonsRow: 'flex-row gap-3 justify-end flex-wrap',
|
||||||
|
dialogBtn: 'rounded-xl py-2.5 px-3.5 border min-w-[92px] items-center',
|
||||||
|
dialogBtnPrimary: 'bg-[#2563eb] border-[#2563eb]',
|
||||||
|
dialogBtnDanger: 'bg-[#7f1d1d] border-[#991b1b]',
|
||||||
|
dialogBtnNeutral: 'bg-[#27272a] border-[#3f3f46]',
|
||||||
|
dialogBtnText: 'text-[#f8fafc] font-semibold text-sm',
|
||||||
|
modalKeyboardWrap: 'flex-1 w-full items-center justify-center',
|
||||||
|
modalCard: 'w-[96%] max-h-[92%] bg-[#18181b] rounded-xl border border-[#27272a] p-6 gap-4 shadow-md',
|
||||||
|
modalScrollContent: {
|
||||||
|
paddingBottom: 20,
|
||||||
gap: 12,
|
gap: 12,
|
||||||
},
|
},
|
||||||
sectionTitle: {
|
closeText: 'text-[#d4d4d8] font-semibold text-sm',
|
||||||
color: '#f1f5f9',
|
|
||||||
fontSize: 18,
|
|
||||||
fontWeight: '700',
|
|
||||||
},
|
|
||||||
sectionRow: {
|
|
||||||
flexDirection: 'row',
|
|
||||||
justifyContent: 'space-between',
|
|
||||||
alignItems: 'center',
|
|
||||||
gap: 10,
|
|
||||||
},
|
|
||||||
|
|
||||||
card: {
|
dateModalBackdrop: 'flex-1 bg-[rgba(9,9,11,0.82)] justify-center px-5',
|
||||||
backgroundColor: '#111827',
|
dateModalCard: 'bg-[#18181b] rounded-xl border border-[#27272a] p-6 gap-4 shadow-md',
|
||||||
borderRadius: 16,
|
calendarHeader: 'flex-row items-center justify-between',
|
||||||
borderWidth: 1,
|
calendarNavBtn: 'w-9 h-9 items-center justify-center rounded-xl bg-[#27272a]',
|
||||||
borderColor: '#1f2937',
|
calendarNavText: 'text-[#e4e4e7] text-[20px] font-bold leading-[22px]',
|
||||||
padding: 12,
|
calendarMonthText: 'text-[#fafafa] font-bold text-base',
|
||||||
gap: 8,
|
calendarWeekRow: 'flex-row justify-between',
|
||||||
},
|
calendarWeekday: 'text-[#a1a1aa] w-[14.2%] text-center text-xs',
|
||||||
cardActive: {
|
calendarGrid: 'flex-row flex-wrap',
|
||||||
borderColor: '#60a5fa',
|
calendarCell: 'w-[14.2%] h-[38px] items-center justify-center rounded-xl my-0.5',
|
||||||
},
|
calendarCellActive: 'bg-[#2563eb]',
|
||||||
cardSoft: {
|
calendarCellText: 'text-[#d4d4d8] font-medium',
|
||||||
backgroundColor: '#0f172a',
|
calendarCellTextActive: 'text-white font-semibold',
|
||||||
borderRadius: 16,
|
};
|
||||||
borderWidth: 1,
|
|
||||||
borderColor: '#1e293b',
|
|
||||||
padding: 12,
|
|
||||||
gap: 10,
|
|
||||||
},
|
|
||||||
cardRow: {
|
|
||||||
flexDirection: 'row',
|
|
||||||
gap: 10,
|
|
||||||
},
|
|
||||||
cardTitle: {
|
|
||||||
color: '#f8fafc',
|
|
||||||
fontWeight: '700',
|
|
||||||
fontSize: 15,
|
|
||||||
},
|
|
||||||
cardMeta: {
|
|
||||||
color: '#94a3b8',
|
|
||||||
marginTop: 3,
|
|
||||||
fontSize: 13,
|
|
||||||
},
|
|
||||||
tripHistoryLabel: {
|
|
||||||
color: '#93c5fd',
|
|
||||||
fontSize: 13,
|
|
||||||
marginTop: -2,
|
|
||||||
marginBottom: 2,
|
|
||||||
},
|
|
||||||
|
|
||||||
fieldWrap: {
|
|
||||||
gap: 6,
|
|
||||||
},
|
|
||||||
label: {
|
|
||||||
color: '#cbd5e1',
|
|
||||||
fontWeight: '600',
|
|
||||||
},
|
|
||||||
input: {
|
|
||||||
borderWidth: 1,
|
|
||||||
borderColor: '#243244',
|
|
||||||
borderRadius: 10,
|
|
||||||
backgroundColor: '#0b1220',
|
|
||||||
color: '#e5e7eb',
|
|
||||||
paddingHorizontal: 10,
|
|
||||||
paddingVertical: 11,
|
|
||||||
},
|
|
||||||
dateInput: {
|
|
||||||
borderWidth: 1,
|
|
||||||
borderColor: '#29415e',
|
|
||||||
borderRadius: 10,
|
|
||||||
backgroundColor: '#0b1220',
|
|
||||||
paddingHorizontal: 12,
|
|
||||||
paddingVertical: 12,
|
|
||||||
},
|
|
||||||
dateInputText: {
|
|
||||||
color: '#dbeafe',
|
|
||||||
fontWeight: '600',
|
|
||||||
},
|
|
||||||
|
|
||||||
chipGroup: {
|
|
||||||
flexDirection: 'row',
|
|
||||||
flexWrap: 'wrap',
|
|
||||||
gap: 7,
|
|
||||||
},
|
|
||||||
chip: {
|
|
||||||
borderRadius: 999,
|
|
||||||
paddingHorizontal: 11,
|
|
||||||
paddingVertical: 7,
|
|
||||||
borderWidth: 1,
|
|
||||||
borderColor: '#273449',
|
|
||||||
backgroundColor: '#0b1220',
|
|
||||||
},
|
|
||||||
chipActive: {
|
|
||||||
borderColor: '#60a5fa',
|
|
||||||
backgroundColor: '#172338',
|
|
||||||
},
|
|
||||||
chipText: {
|
|
||||||
color: '#cbd5e1',
|
|
||||||
fontWeight: '600',
|
|
||||||
fontSize: 12,
|
|
||||||
},
|
|
||||||
chipTextActive: {
|
|
||||||
color: '#bfdbfe',
|
|
||||||
},
|
|
||||||
|
|
||||||
primaryBtn: {
|
|
||||||
marginTop: 4,
|
|
||||||
borderRadius: 10,
|
|
||||||
backgroundColor: '#2563eb',
|
|
||||||
alignItems: 'center',
|
|
||||||
paddingVertical: 11,
|
|
||||||
paddingHorizontal: 12,
|
|
||||||
},
|
|
||||||
primaryBtnTight: {
|
|
||||||
borderRadius: 10,
|
|
||||||
backgroundColor: '#2563eb',
|
|
||||||
alignItems: 'center',
|
|
||||||
paddingVertical: 8,
|
|
||||||
paddingHorizontal: 12,
|
|
||||||
},
|
|
||||||
primaryBtnText: {
|
|
||||||
color: '#fff',
|
|
||||||
fontWeight: '700',
|
|
||||||
},
|
|
||||||
secondaryBtn: {
|
|
||||||
marginTop: 4,
|
|
||||||
borderRadius: 10,
|
|
||||||
backgroundColor: '#1f2937',
|
|
||||||
alignItems: 'center',
|
|
||||||
paddingVertical: 11,
|
|
||||||
paddingHorizontal: 12,
|
|
||||||
},
|
|
||||||
secondaryBtnTight: {
|
|
||||||
borderRadius: 10,
|
|
||||||
backgroundColor: '#1f2937',
|
|
||||||
alignItems: 'center',
|
|
||||||
paddingVertical: 8,
|
|
||||||
paddingHorizontal: 12,
|
|
||||||
},
|
|
||||||
secondaryBtnText: {
|
|
||||||
color: '#dbeafe',
|
|
||||||
fontWeight: '700',
|
|
||||||
},
|
|
||||||
|
|
||||||
inlineToggle: {
|
|
||||||
marginTop: 2,
|
|
||||||
},
|
|
||||||
inlineToggleText: {
|
|
||||||
color: '#cbd5e1',
|
|
||||||
},
|
|
||||||
|
|
||||||
stackButtons: {
|
|
||||||
gap: 7,
|
|
||||||
},
|
|
||||||
miniBtn: {
|
|
||||||
backgroundColor: '#1e293b',
|
|
||||||
borderRadius: 8,
|
|
||||||
paddingVertical: 7,
|
|
||||||
paddingHorizontal: 10,
|
|
||||||
},
|
|
||||||
miniBtnDanger: {
|
|
||||||
backgroundColor: '#3b1d22',
|
|
||||||
borderRadius: 8,
|
|
||||||
paddingVertical: 7,
|
|
||||||
paddingHorizontal: 10,
|
|
||||||
},
|
|
||||||
miniBtnText: {
|
|
||||||
color: '#e2e8f0',
|
|
||||||
fontWeight: '700',
|
|
||||||
fontSize: 12,
|
|
||||||
},
|
|
||||||
|
|
||||||
itemCard: {
|
|
||||||
borderRadius: 16,
|
|
||||||
backgroundColor: '#111827',
|
|
||||||
borderWidth: 1,
|
|
||||||
borderColor: '#1f2937',
|
|
||||||
overflow: 'hidden',
|
|
||||||
flexDirection: 'row',
|
|
||||||
},
|
|
||||||
itemAccent: {
|
|
||||||
width: 5,
|
|
||||||
},
|
|
||||||
itemMain: {
|
|
||||||
flex: 1,
|
|
||||||
padding: 12,
|
|
||||||
gap: 8,
|
|
||||||
},
|
|
||||||
itemTitle: {
|
|
||||||
color: '#f8fafc',
|
|
||||||
fontWeight: '700',
|
|
||||||
fontSize: 15,
|
|
||||||
},
|
|
||||||
itemMeta: {
|
|
||||||
color: '#94a3b8',
|
|
||||||
marginTop: 2,
|
|
||||||
fontSize: 13,
|
|
||||||
},
|
|
||||||
|
|
||||||
answerRow: {
|
|
||||||
marginTop: 8,
|
|
||||||
flexDirection: 'row',
|
|
||||||
alignItems: 'center',
|
|
||||||
gap: 8,
|
|
||||||
},
|
|
||||||
answerYes: {
|
|
||||||
backgroundColor: '#163223',
|
|
||||||
borderWidth: 1,
|
|
||||||
borderColor: '#1f7a4e',
|
|
||||||
borderRadius: 9,
|
|
||||||
paddingHorizontal: 16,
|
|
||||||
paddingVertical: 8,
|
|
||||||
},
|
|
||||||
answerNo: {
|
|
||||||
backgroundColor: '#3b1d22',
|
|
||||||
borderWidth: 1,
|
|
||||||
borderColor: '#7f1d1d',
|
|
||||||
borderRadius: 9,
|
|
||||||
paddingHorizontal: 16,
|
|
||||||
paddingVertical: 8,
|
|
||||||
},
|
|
||||||
answerText: {
|
|
||||||
color: '#f8fafc',
|
|
||||||
fontWeight: '700',
|
|
||||||
},
|
|
||||||
answerStateDot: {
|
|
||||||
width: 10,
|
|
||||||
height: 10,
|
|
||||||
borderRadius: 99,
|
|
||||||
backgroundColor: '#475569',
|
|
||||||
},
|
|
||||||
answerStateDotOn: {
|
|
||||||
backgroundColor: '#22c55e',
|
|
||||||
},
|
|
||||||
answerStateDotBad: {
|
|
||||||
backgroundColor: '#ef4444',
|
|
||||||
},
|
|
||||||
|
|
||||||
statsRow: {
|
|
||||||
flexDirection: 'row',
|
|
||||||
gap: 8,
|
|
||||||
flexWrap: 'wrap',
|
|
||||||
},
|
|
||||||
statPill: {
|
|
||||||
borderRadius: 999,
|
|
||||||
paddingVertical: 7,
|
|
||||||
paddingHorizontal: 11,
|
|
||||||
borderWidth: 1,
|
|
||||||
},
|
|
||||||
statPillCorrect: {
|
|
||||||
backgroundColor: '#163223',
|
|
||||||
borderColor: '#1f7a4e',
|
|
||||||
},
|
|
||||||
statPillBad: {
|
|
||||||
backgroundColor: '#3b1d22',
|
|
||||||
borderColor: '#7f1d1d',
|
|
||||||
},
|
|
||||||
statPillPending: {
|
|
||||||
backgroundColor: '#1f2937',
|
|
||||||
borderColor: '#334155',
|
|
||||||
},
|
|
||||||
statPillText: {
|
|
||||||
color: '#e2e8f0',
|
|
||||||
fontWeight: '700',
|
|
||||||
fontSize: 12,
|
|
||||||
},
|
|
||||||
|
|
||||||
snapshotWrap: {
|
|
||||||
marginTop: 8,
|
|
||||||
borderTopWidth: 1,
|
|
||||||
borderTopColor: '#1e293b',
|
|
||||||
paddingTop: 8,
|
|
||||||
gap: 7,
|
|
||||||
},
|
|
||||||
snapshotRow: {
|
|
||||||
paddingVertical: 3,
|
|
||||||
},
|
|
||||||
snapshotTitle: {
|
|
||||||
color: '#e2e8f0',
|
|
||||||
fontWeight: '600',
|
|
||||||
},
|
|
||||||
|
|
||||||
previewImage: {
|
|
||||||
width: '100%',
|
|
||||||
height: 150,
|
|
||||||
borderRadius: 10,
|
|
||||||
backgroundColor: '#111827',
|
|
||||||
},
|
|
||||||
previewImageSmall: {
|
|
||||||
width: '100%',
|
|
||||||
height: 120,
|
|
||||||
borderRadius: 10,
|
|
||||||
backgroundColor: '#111827',
|
|
||||||
},
|
|
||||||
|
|
||||||
tabBarWrap: {
|
|
||||||
position: 'absolute',
|
|
||||||
bottom: 0,
|
|
||||||
left: 0,
|
|
||||||
right: 0,
|
|
||||||
paddingHorizontal: 10,
|
|
||||||
paddingBottom: Platform.OS === 'ios' ? 14 : 8,
|
|
||||||
backgroundColor: 'transparent',
|
|
||||||
},
|
|
||||||
tabBar: {
|
|
||||||
height: TAB_BAR_HEIGHT,
|
|
||||||
borderRadius: 16,
|
|
||||||
backgroundColor: '#0b1220',
|
|
||||||
borderWidth: 1,
|
|
||||||
borderColor: '#1f2937',
|
|
||||||
flexDirection: 'row',
|
|
||||||
alignItems: 'center',
|
|
||||||
justifyContent: 'space-around',
|
|
||||||
},
|
|
||||||
tabItem: {
|
|
||||||
alignItems: 'center',
|
|
||||||
justifyContent: 'center',
|
|
||||||
gap: 4,
|
|
||||||
minWidth: 62,
|
|
||||||
},
|
|
||||||
tabLabel: {
|
|
||||||
color: '#94a3b8',
|
|
||||||
fontSize: 12,
|
|
||||||
fontWeight: '600',
|
|
||||||
},
|
|
||||||
tabLabelActive: {
|
|
||||||
color: '#dbeafe',
|
|
||||||
},
|
|
||||||
|
|
||||||
modalBackdrop: {
|
|
||||||
flex: 1,
|
|
||||||
backgroundColor: 'rgba(2,6,23,0.72)',
|
|
||||||
justifyContent: 'flex-end',
|
|
||||||
},
|
|
||||||
modalKeyboardWrap: {
|
|
||||||
width: '100%',
|
|
||||||
},
|
|
||||||
modalCard: {
|
|
||||||
maxHeight: '87%',
|
|
||||||
backgroundColor: '#0f172a',
|
|
||||||
borderTopLeftRadius: 18,
|
|
||||||
borderTopRightRadius: 18,
|
|
||||||
borderWidth: 1,
|
|
||||||
borderColor: '#1e293b',
|
|
||||||
padding: 14,
|
|
||||||
gap: 8,
|
|
||||||
},
|
|
||||||
closeText: {
|
|
||||||
color: '#93c5fd',
|
|
||||||
fontWeight: '700',
|
|
||||||
},
|
|
||||||
|
|
||||||
dateModalBackdrop: {
|
|
||||||
flex: 1,
|
|
||||||
backgroundColor: 'rgba(2,6,23,0.75)',
|
|
||||||
justifyContent: 'center',
|
|
||||||
paddingHorizontal: 16,
|
|
||||||
},
|
|
||||||
dateModalCard: {
|
|
||||||
backgroundColor: '#0f172a',
|
|
||||||
borderRadius: 16,
|
|
||||||
borderWidth: 1,
|
|
||||||
borderColor: '#1e293b',
|
|
||||||
padding: 14,
|
|
||||||
gap: 10,
|
|
||||||
},
|
|
||||||
calendarHeader: {
|
|
||||||
flexDirection: 'row',
|
|
||||||
alignItems: 'center',
|
|
||||||
justifyContent: 'space-between',
|
|
||||||
},
|
|
||||||
calendarNavBtn: {
|
|
||||||
width: 34,
|
|
||||||
height: 34,
|
|
||||||
alignItems: 'center',
|
|
||||||
justifyContent: 'center',
|
|
||||||
borderRadius: 10,
|
|
||||||
backgroundColor: '#1e293b',
|
|
||||||
},
|
|
||||||
calendarNavText: {
|
|
||||||
color: '#dbeafe',
|
|
||||||
fontSize: 20,
|
|
||||||
fontWeight: '700',
|
|
||||||
lineHeight: 22,
|
|
||||||
},
|
|
||||||
calendarMonthText: {
|
|
||||||
color: '#f8fafc',
|
|
||||||
fontWeight: '700',
|
|
||||||
fontSize: 15,
|
|
||||||
},
|
|
||||||
calendarWeekRow: {
|
|
||||||
flexDirection: 'row',
|
|
||||||
justifyContent: 'space-between',
|
|
||||||
},
|
|
||||||
calendarWeekday: {
|
|
||||||
color: '#94a3b8',
|
|
||||||
width: '14.2%',
|
|
||||||
textAlign: 'center',
|
|
||||||
fontSize: 12,
|
|
||||||
},
|
|
||||||
calendarGrid: {
|
|
||||||
flexDirection: 'row',
|
|
||||||
flexWrap: 'wrap',
|
|
||||||
},
|
|
||||||
calendarCell: {
|
|
||||||
width: '14.2%',
|
|
||||||
height: 38,
|
|
||||||
alignItems: 'center',
|
|
||||||
justifyContent: 'center',
|
|
||||||
borderRadius: 10,
|
|
||||||
marginVertical: 2,
|
|
||||||
},
|
|
||||||
calendarCellActive: {
|
|
||||||
backgroundColor: '#2563eb',
|
|
||||||
},
|
|
||||||
calendarCellText: {
|
|
||||||
color: '#cbd5e1',
|
|
||||||
fontWeight: '600',
|
|
||||||
},
|
|
||||||
calendarCellTextActive: {
|
|
||||||
color: '#fff',
|
|
||||||
fontWeight: '700',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|||||||
@@ -1,72 +1,64 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Pressable, Text, View } from 'react-native';
|
import { Pressable, Text, View } from 'react-native';
|
||||||
|
import Ionicons from '@expo/vector-icons/Ionicons';
|
||||||
import { styles } from '../styles';
|
import { styles } from '../styles';
|
||||||
|
import { cn } from '../utils/cn';
|
||||||
|
|
||||||
export default function CheckupTab({
|
export default function CheckupTab({ selectedTrip, selectedTripItems, checkupStats, startCheckupFlow }) {
|
||||||
checkupSession,
|
|
||||||
checkupStats,
|
|
||||||
answerCheckupYes,
|
|
||||||
openFixModal,
|
|
||||||
createFreshCheckupSession,
|
|
||||||
saveCheckup,
|
|
||||||
}) {
|
|
||||||
return (
|
return (
|
||||||
<View style={styles.section}>
|
<View className={styles.section}>
|
||||||
<View style={styles.sectionRow}>
|
<View className={styles.sectionHeaderLeft}>
|
||||||
<Text style={styles.sectionTitle}>Check-Up</Text>
|
<View className={styles.sectionHeaderIconWrap}>
|
||||||
<Pressable style={styles.secondaryBtnTight} onPress={createFreshCheckupSession}>
|
<Ionicons name="checkmark-circle-outline" size={16} color="#d4d4d8" />
|
||||||
<Text style={styles.secondaryBtnText}>Restart</Text>
|
</View>
|
||||||
</Pressable>
|
<Text className={styles.sectionTitle}>Check-Up Session</Text>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
{!!checkupSession.length && (
|
{!selectedTrip ? (
|
||||||
<View style={styles.statsRow}>
|
<View className={styles.cardSoft}>
|
||||||
<View style={[styles.statPill, styles.statPillCorrect]}>
|
<Text className={styles.muted}>Select a trip first.</Text>
|
||||||
<Text style={styles.statPillText}>Correct: {checkupStats.correct}</Text>
|
|
||||||
</View>
|
|
||||||
<View style={[styles.statPill, styles.statPillBad]}>
|
|
||||||
<Text style={styles.statPillText}>Bad: {checkupStats.bad}</Text>
|
|
||||||
</View>
|
|
||||||
<View style={[styles.statPill, styles.statPillPending]}>
|
|
||||||
<Text style={styles.statPillText}>Pending: {checkupStats.pending}</Text>
|
|
||||||
</View>
|
|
||||||
</View>
|
</View>
|
||||||
)}
|
) : null}
|
||||||
|
{selectedTrip && selectedTripItems.length === 0 ? (
|
||||||
{checkupSession.length === 0 ? <Text style={styles.muted}>No items for this trip yet.</Text> : null}
|
<View className={styles.cardSoft}>
|
||||||
|
<Text className={styles.muted}>No items for this trip yet.</Text>
|
||||||
{checkupSession.map((entry) => (
|
|
||||||
<View key={entry.itemId} style={styles.cardSoft}>
|
|
||||||
<Text style={styles.cardTitle}>{entry.name}</Text>
|
|
||||||
<Text style={styles.cardMeta}>{entry.category || 'uncategorized'}</Text>
|
|
||||||
<Text style={styles.cardMeta}>
|
|
||||||
{entry.current.status} · {entry.current.placement}
|
|
||||||
{entry.current.status === 'lent-to' && entry.current.lentTo ? ` · ${entry.current.lentTo}` : ''}
|
|
||||||
</Text>
|
|
||||||
|
|
||||||
<View style={styles.answerRow}>
|
|
||||||
<Pressable style={styles.answerYes} onPress={() => answerCheckupYes(entry.itemId)}>
|
|
||||||
<Text style={styles.answerText}>Yes</Text>
|
|
||||||
</Pressable>
|
|
||||||
<Pressable style={styles.answerNo} onPress={() => openFixModal(entry.itemId)}>
|
|
||||||
<Text style={styles.answerText}>No</Text>
|
|
||||||
</Pressable>
|
|
||||||
<View
|
|
||||||
style={[
|
|
||||||
styles.answerStateDot,
|
|
||||||
entry.result === 'correct' ? styles.answerStateDotOn : null,
|
|
||||||
entry.result === 'bad' ? styles.answerStateDotBad : null,
|
|
||||||
]}
|
|
||||||
/>
|
|
||||||
</View>
|
|
||||||
</View>
|
</View>
|
||||||
))}
|
) : null}
|
||||||
|
|
||||||
{!!checkupSession.length && (
|
{selectedTrip && selectedTripItems.length > 0 ? (
|
||||||
<Pressable style={styles.primaryBtn} onPress={saveCheckup}>
|
<View className={styles.cardSoft}>
|
||||||
<Text style={styles.primaryBtnText}>Save Check-Up Snapshot</Text>
|
<Text className={styles.cardTitle}>Run a check-up for {selectedTrip.name}</Text>
|
||||||
</Pressable>
|
<Text className={styles.cardMeta}>{selectedTripItems.length} items will be checked one by one.</Text>
|
||||||
)}
|
|
||||||
|
<View className={styles.statsRow}>
|
||||||
|
<View className={cn(styles.statPill, styles.statPillCorrect)}>
|
||||||
|
<View className={styles.buttonContent}>
|
||||||
|
<Ionicons name="checkmark-circle-outline" size={12} color="#f4f4f5" />
|
||||||
|
<Text className={styles.statPillText}>Correct: {checkupStats.correct}</Text>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
<View className={cn(styles.statPill, styles.statPillBad)}>
|
||||||
|
<View className={styles.buttonContent}>
|
||||||
|
<Ionicons name="close-circle-outline" size={12} color="#f4f4f5" />
|
||||||
|
<Text className={styles.statPillText}>Bad: {checkupStats.bad}</Text>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
<View className={cn(styles.statPill, styles.statPillPending)}>
|
||||||
|
<View className={styles.buttonContent}>
|
||||||
|
<Ionicons name="pause-circle-outline" size={12} color="#f4f4f5" />
|
||||||
|
<Text className={styles.statPillText}>Pending: {checkupStats.pending}</Text>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
|
||||||
|
<Pressable className={styles.primaryBtn} onPress={startCheckupFlow}>
|
||||||
|
<View className={styles.buttonContent}>
|
||||||
|
<Ionicons name="play-circle-outline" size={15} color="#ffffff" />
|
||||||
|
<Text className={styles.primaryBtnText}>Start Check-Up</Text>
|
||||||
|
</View>
|
||||||
|
</Pressable>
|
||||||
|
</View>
|
||||||
|
) : null}
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,36 +1,74 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Pressable, Text, View } from 'react-native';
|
import { Pressable, Text, View } from 'react-native';
|
||||||
|
import Ionicons from '@expo/vector-icons/Ionicons';
|
||||||
import { styles } from '../styles';
|
import { styles } from '../styles';
|
||||||
|
import { formatItemLabel, formatStatusLabel } from '../utils/labels';
|
||||||
|
|
||||||
export default function HistoryTab({ selectedTrip, selectedTripCheckups, selectedCheckupId, setSelectedCheckupId }) {
|
export default function HistoryTab({ selectedTrip, selectedTripCheckups, selectedCheckupId, setSelectedCheckupId, onDeleteCheckup }) {
|
||||||
return (
|
return (
|
||||||
<View style={styles.section}>
|
<View className={styles.section}>
|
||||||
<Text style={styles.sectionTitle}>History</Text>
|
<View className={styles.sectionHeaderLeft}>
|
||||||
|
<View className={styles.sectionHeaderIconWrap}>
|
||||||
|
<Ionicons name="time-outline" size={16} color="#d4d4d8" />
|
||||||
|
</View>
|
||||||
|
<Text className={styles.sectionTitle}>Check-Up History</Text>
|
||||||
|
</View>
|
||||||
|
|
||||||
{!selectedTrip ? <Text style={styles.muted}>Select a trip first.</Text> : null}
|
{!selectedTrip ? (
|
||||||
{selectedTrip ? <Text style={styles.tripHistoryLabel}>Check-ups for: {selectedTrip.name}</Text> : null}
|
<View className={styles.cardSoft}>
|
||||||
{selectedTrip && selectedTripCheckups.length === 0 ? <Text style={styles.muted}>No check-ups saved yet.</Text> : null}
|
<Text className={styles.muted}>Select a trip first.</Text>
|
||||||
|
</View>
|
||||||
|
) : null}
|
||||||
|
{selectedTrip ? (
|
||||||
|
<View className={styles.sectionHeaderLeft}>
|
||||||
|
<Ionicons name="briefcase-outline" size={13} color="#93c5fd" />
|
||||||
|
<Text className={styles.tripHistoryLabel}>Check-ups for: {selectedTrip.name}</Text>
|
||||||
|
</View>
|
||||||
|
) : null}
|
||||||
|
{selectedTrip && selectedTripCheckups.length === 0 ? (
|
||||||
|
<View className={styles.cardSoft}>
|
||||||
|
<Text className={styles.muted}>No check-ups saved yet.</Text>
|
||||||
|
</View>
|
||||||
|
) : null}
|
||||||
|
|
||||||
{selectedTripCheckups.map((checkup) => (
|
{selectedTripCheckups.map((checkup) => (
|
||||||
<View key={checkup.id} style={styles.cardSoft}>
|
<View key={checkup.id} className={styles.cardSoft}>
|
||||||
<Pressable onPress={() => setSelectedCheckupId((prev) => (prev === checkup.id ? null : checkup.id))}>
|
<Pressable
|
||||||
<Text style={styles.cardTitle}>{new Date(checkup.createdAt).toLocaleString()}</Text>
|
onPress={() => setSelectedCheckupId((prev) => (prev === checkup.id ? null : checkup.id))}
|
||||||
<Text style={styles.cardMeta}>
|
onLongPress={() => onDeleteCheckup(checkup.id)}
|
||||||
{checkup.snapshot.length} items · correct: {checkup.stats?.correct ?? checkup.snapshot.filter((x) => x.result === 'correct').length} · bad:{' '}
|
delayLongPress={280}
|
||||||
{checkup.stats?.bad ?? checkup.snapshot.filter((x) => x.result === 'bad').length}
|
>
|
||||||
</Text>
|
<View className={styles.sectionHeader}>
|
||||||
<Text style={styles.cardMeta}>{selectedCheckupId === checkup.id ? 'Tap to collapse' : 'Tap to open'}</Text>
|
<View className={styles.sectionHeaderLeft}>
|
||||||
|
<Ionicons name="calendar-outline" size={14} color="#a1a1aa" />
|
||||||
|
<Text className={styles.cardTitle}>{new Date(checkup.createdAt).toLocaleString()}</Text>
|
||||||
|
</View>
|
||||||
|
<Ionicons name={selectedCheckupId === checkup.id ? 'chevron-up' : 'chevron-down'} size={16} color="#a1a1aa" />
|
||||||
|
</View>
|
||||||
|
<View className={styles.sectionHeaderLeft}>
|
||||||
|
<Ionicons name="analytics-outline" size={13} color="#a1a1aa" />
|
||||||
|
<Text className={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>
|
||||||
|
</View>
|
||||||
|
<Text className={styles.cardMeta}>{selectedCheckupId === checkup.id ? 'Tap to collapse' : 'Tap to open'} · long hold to delete</Text>
|
||||||
</Pressable>
|
</Pressable>
|
||||||
|
|
||||||
{selectedCheckupId === checkup.id ? (
|
{selectedCheckupId === checkup.id ? (
|
||||||
<View style={styles.snapshotWrap}>
|
<View className={styles.snapshotWrap}>
|
||||||
{checkup.snapshot.map((entry) => (
|
{checkup.snapshot.map((entry) => (
|
||||||
<View key={entry.itemId} style={styles.snapshotRow}>
|
<View key={entry.itemId} className={styles.snapshotRow}>
|
||||||
<Text style={styles.snapshotTitle}>{entry.name}</Text>
|
<View className={styles.sectionHeaderLeft}>
|
||||||
<Text style={styles.cardMeta}>
|
<Ionicons name="cube-outline" size={12} color="#a1a1aa" />
|
||||||
{entry.status} · {entry.placement}
|
<Text className={styles.snapshotTitle}>{formatItemLabel(entry.name, entry.quantity)}</Text>
|
||||||
{entry.status === 'lent-to' && entry.lentTo ? ` · ${entry.lentTo}` : ''}
|
</View>
|
||||||
</Text>
|
<View className={styles.sectionHeaderLeft}>
|
||||||
|
<Ionicons name="pin-outline" size={12} color="#a1a1aa" />
|
||||||
|
<Text className={styles.cardMeta}>
|
||||||
|
{formatStatusLabel(entry.status, entry.lentTo)} · {entry.placement}
|
||||||
|
</Text>
|
||||||
|
</View>
|
||||||
</View>
|
</View>
|
||||||
))}
|
))}
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
@@ -1,24 +1,206 @@
|
|||||||
import React from 'react';
|
import React, { useMemo, useState } from 'react';
|
||||||
import { Pressable, Text, View } from 'react-native';
|
import { Image, Modal, Pressable, Text, View } from 'react-native';
|
||||||
|
import Ionicons from '@expo/vector-icons/Ionicons';
|
||||||
import ItemCard from '../components/ItemCard';
|
import ItemCard from '../components/ItemCard';
|
||||||
|
import { ITEM_STATUSES } from '../constants';
|
||||||
import { styles } from '../styles';
|
import { styles } from '../styles';
|
||||||
|
import { cn } from '../utils/cn';
|
||||||
|
import { formatFilterLabel, formatStatusLabel } from '../utils/labels';
|
||||||
|
|
||||||
|
export default function ItemsTab({
|
||||||
|
selectedTrip,
|
||||||
|
selectedTripItems,
|
||||||
|
openAddItemModal,
|
||||||
|
openEditItemModal,
|
||||||
|
deleteItem,
|
||||||
|
quickSetItemStatus,
|
||||||
|
bulkSetItemStatus,
|
||||||
|
}) {
|
||||||
|
const [statusFilter, setStatusFilter] = useState('all');
|
||||||
|
const [categoryFilter, setCategoryFilter] = useState('all');
|
||||||
|
const [locationFilter, setLocationFilter] = useState('all');
|
||||||
|
const [imagePreviewUri, setImagePreviewUri] = useState('');
|
||||||
|
|
||||||
|
const categories = useMemo(
|
||||||
|
() => Array.from(new Set(selectedTripItems.map((item) => item.category?.trim()).filter(Boolean))).sort((a, b) => a.localeCompare(b)),
|
||||||
|
[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;
|
||||||
|
const matchLocation = locationFilter === 'all' || itemLocation === locationFilter;
|
||||||
|
return matchStatus && matchCategory && matchLocation;
|
||||||
|
}),
|
||||||
|
[selectedTripItems, statusFilter, categoryFilter, locationFilter]
|
||||||
|
);
|
||||||
|
|
||||||
|
const packedItemCount = useMemo(
|
||||||
|
() => selectedTripItems.filter((item) => item.status === 'packed').length,
|
||||||
|
[selectedTripItems]
|
||||||
|
);
|
||||||
|
const packProgress = selectedTripItems.length ? packedItemCount / selectedTripItems.length : 0;
|
||||||
|
|
||||||
|
const filterStatusOptions = ['all', ...ITEM_STATUSES];
|
||||||
|
const filterCategoryOptions = ['all', ...categories];
|
||||||
|
const filterLocationOptions = ['all', ...locations];
|
||||||
|
|
||||||
export default function ItemsTab({ selectedTrip, selectedTripItems, openAddItemModal, openEditItemModal, deleteItem }) {
|
|
||||||
return (
|
return (
|
||||||
<View style={styles.section}>
|
<View className={styles.section}>
|
||||||
<View style={styles.sectionRow}>
|
<View className={styles.sectionHeader}>
|
||||||
<Text style={styles.sectionTitle}>Luggage Items</Text>
|
<View className={styles.sectionHeaderLeft}>
|
||||||
<Pressable style={styles.primaryBtnTight} onPress={openAddItemModal}>
|
<View className={styles.sectionHeaderIconWrap}>
|
||||||
<Text style={styles.primaryBtnText}>+ Add</Text>
|
<Ionicons name="briefcase-outline" size={16} color="#d4d4d8" />
|
||||||
|
</View>
|
||||||
|
<Text className={styles.sectionTitle}>Packing List</Text>
|
||||||
|
</View>
|
||||||
|
<Pressable className={styles.primaryBtnTight} onPress={openAddItemModal}>
|
||||||
|
<View className={styles.buttonContent}>
|
||||||
|
<Ionicons name="add-circle-outline" size={14} color="#ffffff" />
|
||||||
|
<Text className={styles.primaryBtnText}>Add</Text>
|
||||||
|
</View>
|
||||||
</Pressable>
|
</Pressable>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
{!selectedTrip ? <Text style={styles.muted}>Select a trip first.</Text> : null}
|
{!selectedTrip ? (
|
||||||
{selectedTripItems.length === 0 && selectedTrip ? <Text style={styles.muted}>No items yet.</Text> : null}
|
<View className={styles.cardSoft}>
|
||||||
|
<Text className={styles.muted}>Select a trip first.</Text>
|
||||||
|
</View>
|
||||||
|
) : null}
|
||||||
|
{selectedTripItems.length === 0 && selectedTrip ? (
|
||||||
|
<View className={styles.cardSoft}>
|
||||||
|
<Text className={styles.muted}>No items yet.</Text>
|
||||||
|
</View>
|
||||||
|
) : null}
|
||||||
|
|
||||||
{selectedTripItems.map((item) => (
|
{selectedTrip && selectedTripItems.length > 0 ? (
|
||||||
<ItemCard key={item.id} item={item} onEdit={openEditItemModal} onDelete={deleteItem} />
|
<View className={styles.cardSoft}>
|
||||||
|
<View className={styles.sectionHeader}>
|
||||||
|
<View className={styles.sectionHeaderLeft}>
|
||||||
|
<Ionicons name="checkmark-done-outline" size={16} color="#86efac" />
|
||||||
|
<Text className={styles.cardTitle}>Progress</Text>
|
||||||
|
</View>
|
||||||
|
<Text className={styles.packProgressMeta}>{Math.round(packProgress * 100)}%</Text>
|
||||||
|
</View>
|
||||||
|
<Text className={styles.packProgressLabel}>{packedItemCount}/{selectedTripItems.length} items packed</Text>
|
||||||
|
<View className={styles.packProgressTrack}>
|
||||||
|
<View className={styles.packProgressFill} style={{ width: `${Math.round(packProgress * 100)}%` }} />
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
) : null}
|
||||||
|
|
||||||
|
{selectedTrip ? (
|
||||||
|
<View className={styles.cardSoft}>
|
||||||
|
<View className={styles.sectionHeaderLeft}>
|
||||||
|
<Ionicons name="flash-outline" size={16} color="#d4d4d8" />
|
||||||
|
<Text className={styles.cardTitle}>Quick Actions</Text>
|
||||||
|
</View>
|
||||||
|
<View className={styles.actionRow}>
|
||||||
|
<Pressable className={cn(styles.secondaryBtnTight, styles.flex)} onPress={() => bulkSetItemStatus(filteredItems.map((x) => x.id), 'packed')}>
|
||||||
|
<View className={styles.buttonContent}>
|
||||||
|
<Ionicons name="checkmark-circle-outline" size={14} color="#f4f4f5" />
|
||||||
|
<Text className={styles.secondaryBtnText}>Pack All ({filteredItems.length})</Text>
|
||||||
|
</View>
|
||||||
|
</Pressable>
|
||||||
|
<Pressable className={cn(styles.secondaryBtnTight, styles.flex)} onPress={() => bulkSetItemStatus(filteredItems.map((x) => x.id), 'unpacked')}>
|
||||||
|
<View className={styles.buttonContent}>
|
||||||
|
<Ionicons name="remove-circle-outline" size={14} color="#f4f4f5" />
|
||||||
|
<Text className={styles.secondaryBtnText}>Unpack All ({filteredItems.length})</Text>
|
||||||
|
</View>
|
||||||
|
</Pressable>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
) : null}
|
||||||
|
|
||||||
|
{selectedTripItems.length > 0 ? (
|
||||||
|
<View className={styles.cardSoft}>
|
||||||
|
<View className={styles.sectionHeaderLeft}>
|
||||||
|
<Ionicons name="funnel-outline" size={16} color="#d4d4d8" />
|
||||||
|
<Text className={styles.cardTitle}>Filters</Text>
|
||||||
|
</View>
|
||||||
|
|
||||||
|
<View className={styles.sectionHeaderLeft}>
|
||||||
|
<Ionicons name="radio-button-on-outline" size={12} color="#a1a1aa" />
|
||||||
|
<Text className={styles.cardMeta}>Status</Text>
|
||||||
|
</View>
|
||||||
|
<View className={styles.chipGroup}>
|
||||||
|
{filterStatusOptions.map((status) => {
|
||||||
|
const active = statusFilter === status;
|
||||||
|
return (
|
||||||
|
<Pressable key={status} className={cn(styles.chip, active && styles.chipActive)} onPress={() => setStatusFilter(status)}>
|
||||||
|
<Text className={cn(styles.chipText, active && styles.chipTextActive)}>{status === 'all' ? formatFilterLabel(status) : formatStatusLabel(status)}</Text>
|
||||||
|
</Pressable>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</View>
|
||||||
|
|
||||||
|
<View className={styles.sectionHeaderLeft}>
|
||||||
|
<Ionicons name="layers-outline" size={12} color="#a1a1aa" />
|
||||||
|
<Text className={styles.cardMeta}>Category</Text>
|
||||||
|
</View>
|
||||||
|
<View className={styles.chipGroup}>
|
||||||
|
{filterCategoryOptions.map((category) => {
|
||||||
|
const active = categoryFilter === category;
|
||||||
|
return (
|
||||||
|
<Pressable key={category} className={cn(styles.chip, active && styles.chipActive)} onPress={() => setCategoryFilter(category)}>
|
||||||
|
<Text className={cn(styles.chipText, active && styles.chipTextActive)}>{formatFilterLabel(category)}</Text>
|
||||||
|
</Pressable>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</View>
|
||||||
|
|
||||||
|
<View className={styles.sectionHeaderLeft}>
|
||||||
|
<Ionicons name="pin-outline" size={12} color="#a1a1aa" />
|
||||||
|
<Text className={styles.cardMeta}>Location</Text>
|
||||||
|
</View>
|
||||||
|
<View className={styles.chipGroup}>
|
||||||
|
{filterLocationOptions.map((location) => {
|
||||||
|
const active = locationFilter === location;
|
||||||
|
return (
|
||||||
|
<Pressable key={location} className={cn(styles.chip, active && styles.chipActive)} onPress={() => setLocationFilter(location)}>
|
||||||
|
<Text className={cn(styles.chipText, active && styles.chipTextActive)}>{formatFilterLabel(location)}</Text>
|
||||||
|
</Pressable>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
) : null}
|
||||||
|
|
||||||
|
{filteredItems.map((item) => (
|
||||||
|
<ItemCard
|
||||||
|
key={item.id}
|
||||||
|
item={item}
|
||||||
|
onEdit={openEditItemModal}
|
||||||
|
onDelete={deleteItem}
|
||||||
|
onQuickPack={() => quickSetItemStatus(item.id, 'packed')}
|
||||||
|
onQuickUnpack={() => quickSetItemStatus(item.id, 'unpacked')}
|
||||||
|
onOpenImage={(uri) => setImagePreviewUri(uri)}
|
||||||
|
/>
|
||||||
))}
|
))}
|
||||||
|
|
||||||
|
{selectedTripItems.length > 0 && filteredItems.length === 0 ? (
|
||||||
|
<View className={styles.cardSoft}>
|
||||||
|
<Text className={styles.muted}>No items match the current filters.</Text>
|
||||||
|
</View>
|
||||||
|
) : null}
|
||||||
|
|
||||||
|
<Modal visible={!!imagePreviewUri} transparent animationType="fade">
|
||||||
|
<Pressable className={styles.imagePreviewBackdrop} onPress={() => setImagePreviewUri('')}>
|
||||||
|
<Pressable className={styles.imagePreviewCard} onPress={() => {}}>
|
||||||
|
{imagePreviewUri ? <Image source={{ uri: imagePreviewUri }} className={styles.imagePreviewImage} resizeMode="contain" /> : null}
|
||||||
|
<Text className={styles.imagePreviewHint}>Tap outside to close</Text>
|
||||||
|
</Pressable>
|
||||||
|
</Pressable>
|
||||||
|
</Modal>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,112 +1,444 @@
|
|||||||
import React from 'react';
|
import React, { useMemo, useState } from 'react';
|
||||||
import { Image, Pressable, Text, TextInput, View } from 'react-native';
|
import { KeyboardAvoidingView, Modal, Platform, Pressable, ScrollView, Text, TextInput, View } from 'react-native';
|
||||||
|
import Ionicons from '@expo/vector-icons/Ionicons';
|
||||||
|
import DatePickerModal from '../components/DatePickerModal';
|
||||||
import Field from '../components/Field';
|
import Field from '../components/Field';
|
||||||
import { styles } from '../styles';
|
import { styles } from '../styles';
|
||||||
|
import { cn } from '../utils/cn';
|
||||||
|
|
||||||
function DateField({ label, value, onPress }) {
|
function DateField({ label, value, onPress }) {
|
||||||
return (
|
return (
|
||||||
<Field label={label}>
|
<Field label={label} icon="calendar-outline">
|
||||||
<Pressable style={styles.dateInput} onPress={onPress}>
|
<Pressable className={styles.dateInput} onPress={onPress}>
|
||||||
<Text style={styles.dateInputText}>{value}</Text>
|
<View className={styles.sectionHeader}>
|
||||||
|
<Text className={styles.dateInputText}>{value}</Text>
|
||||||
|
<Ionicons name="chevron-forward" size={14} color="#a1a1aa" />
|
||||||
|
</View>
|
||||||
</Pressable>
|
</Pressable>
|
||||||
</Field>
|
</Field>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const emptyEditForm = {
|
||||||
|
name: '',
|
||||||
|
location: '',
|
||||||
|
startDate: '',
|
||||||
|
endDate: '',
|
||||||
|
};
|
||||||
|
|
||||||
export default function TripsTab({
|
export default function TripsTab({
|
||||||
tripForm,
|
tripForm,
|
||||||
updateTripForm,
|
updateTripForm,
|
||||||
pickTripImage,
|
|
||||||
templateTrip,
|
templateTrip,
|
||||||
createTrip,
|
createTrip,
|
||||||
trips,
|
trips,
|
||||||
selectedTripId,
|
selectedTripId,
|
||||||
chooseTrip,
|
|
||||||
setTripAsTemplate,
|
setTripAsTemplate,
|
||||||
|
saveTripEdits,
|
||||||
|
setTripArchived,
|
||||||
deleteTrip,
|
deleteTrip,
|
||||||
onInputFocus,
|
onInputFocus,
|
||||||
defaultTemplateTripId,
|
defaultTemplateTripId,
|
||||||
openDatePicker,
|
openDatePicker,
|
||||||
|
activeTripItemCount,
|
||||||
|
activeTripPackedCount,
|
||||||
|
activeTripCheckupCount,
|
||||||
|
openBackupModal,
|
||||||
}) {
|
}) {
|
||||||
|
const [createModalVisible, setCreateModalVisible] = useState(false);
|
||||||
|
const [viewTripId, setViewTripId] = useState(null);
|
||||||
|
const [editMode, setEditMode] = useState(false);
|
||||||
|
const [editForm, setEditForm] = useState(emptyEditForm);
|
||||||
|
const [viewDatePicker, setViewDatePicker] = useState({ visible: false, field: 'startDate' });
|
||||||
|
|
||||||
|
const activeTrip = useMemo(() => trips.find((trip) => trip.id === selectedTripId) || null, [trips, selectedTripId]);
|
||||||
|
const viewingTrip = useMemo(() => trips.find((trip) => trip.id === viewTripId) || null, [trips, viewTripId]);
|
||||||
|
const activeTrips = useMemo(() => trips.filter((trip) => !trip.archived), [trips]);
|
||||||
|
const archivedTrips = useMemo(() => trips.filter((trip) => trip.archived), [trips]);
|
||||||
|
|
||||||
|
function submitCreateTrip() {
|
||||||
|
const ok = createTrip();
|
||||||
|
if (ok) setCreateModalVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
function openView(tripId) {
|
||||||
|
const trip = trips.find((x) => x.id === tripId);
|
||||||
|
if (!trip) return;
|
||||||
|
setViewTripId(tripId);
|
||||||
|
setEditMode(false);
|
||||||
|
setEditForm({
|
||||||
|
name: trip.name || '',
|
||||||
|
location: trip.location || '',
|
||||||
|
startDate: trip.startDate || '',
|
||||||
|
endDate: trip.endDate || '',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateEditForm(field, value) {
|
||||||
|
setEditForm((prev) => ({ ...prev, [field]: value }));
|
||||||
|
}
|
||||||
|
|
||||||
|
function saveEditFromView() {
|
||||||
|
if (!viewingTrip) return;
|
||||||
|
const ok = saveTripEdits(viewingTrip.id, editForm);
|
||||||
|
if (!ok) return;
|
||||||
|
setEditMode(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
function applyTemplateFromView() {
|
||||||
|
if (!viewingTrip) return;
|
||||||
|
setTripAsTemplate(viewingTrip.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleArchiveFromView() {
|
||||||
|
if (!viewingTrip) return;
|
||||||
|
setTripArchived(viewingTrip.id, !viewingTrip.archived);
|
||||||
|
if (!viewingTrip.archived) {
|
||||||
|
setViewTripId(null);
|
||||||
|
setEditMode(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function deleteFromView() {
|
||||||
|
if (!viewingTrip) return;
|
||||||
|
const tripId = viewingTrip.id;
|
||||||
|
setViewTripId(null);
|
||||||
|
setEditMode(false);
|
||||||
|
deleteTrip(tripId);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={styles.section}>
|
<View className={styles.section}>
|
||||||
<Text style={styles.sectionTitle}>Trips</Text>
|
<View className={styles.sectionHeaderLeft}>
|
||||||
|
<View className={styles.sectionHeaderIconWrap}>
|
||||||
|
<Ionicons name="airplane-outline" size={16} color="#d4d4d8" />
|
||||||
|
</View>
|
||||||
|
<Text className={styles.sectionTitle}>Trip Planner</Text>
|
||||||
|
</View>
|
||||||
|
|
||||||
<View style={styles.cardSoft}>
|
<View className={styles.actionRow}>
|
||||||
<Field label="Name">
|
<Pressable className={cn(styles.secondaryBtnTight, styles.flex)} onPress={openBackupModal}>
|
||||||
<TextInput
|
<View className={styles.buttonContent}>
|
||||||
style={styles.input}
|
<Ionicons name="save-outline" size={14} color="#f4f4f5" />
|
||||||
value={tripForm.name}
|
<Text className={styles.secondaryBtnText}>Backup</Text>
|
||||||
onChangeText={(v) => updateTripForm('name', v)}
|
</View>
|
||||||
placeholder="Summer Weekend"
|
|
||||||
placeholderTextColor="#6b7280"
|
|
||||||
onFocus={onInputFocus}
|
|
||||||
/>
|
|
||||||
</Field>
|
|
||||||
|
|
||||||
<Field label="Location">
|
|
||||||
<TextInput
|
|
||||||
style={styles.input}
|
|
||||||
value={tripForm.location}
|
|
||||||
onChangeText={(v) => updateTripForm('location', v)}
|
|
||||||
placeholder="Berlin"
|
|
||||||
placeholderTextColor="#6b7280"
|
|
||||||
onFocus={onInputFocus}
|
|
||||||
/>
|
|
||||||
</Field>
|
|
||||||
|
|
||||||
<DateField label="Start Date" value={tripForm.startDate} onPress={() => openDatePicker('startDate')} />
|
|
||||||
<DateField label="End Date" value={tripForm.endDate} onPress={() => openDatePicker('endDate')} />
|
|
||||||
|
|
||||||
<Pressable style={styles.secondaryBtn} onPress={pickTripImage}>
|
|
||||||
<Text style={styles.secondaryBtnText}>{tripForm.imageUri ? 'Change trip image' : 'Add trip image'}</Text>
|
|
||||||
</Pressable>
|
</Pressable>
|
||||||
|
<Pressable className={cn(styles.primaryBtnTight, styles.flex)} onPress={() => setCreateModalVisible(true)}>
|
||||||
{tripForm.imageUri ? <Image source={{ uri: tripForm.imageUri }} style={styles.previewImage} /> : null}
|
<View className={styles.buttonContent}>
|
||||||
|
<Ionicons name="add-circle-outline" size={14} color="#ffffff" />
|
||||||
{templateTrip ? (
|
<Text className={styles.primaryBtnText}>New Trip</Text>
|
||||||
<Pressable style={styles.inlineToggle} onPress={() => updateTripForm('copyDefaultTemplate', !tripForm.copyDefaultTemplate)}>
|
</View>
|
||||||
<Text style={styles.inlineToggleText}>
|
|
||||||
{tripForm.copyDefaultTemplate ? '☑' : '☐'} Copy items from template ({templateTrip.name})
|
|
||||||
</Text>
|
|
||||||
</Pressable>
|
|
||||||
) : null}
|
|
||||||
|
|
||||||
<Pressable style={styles.inlineToggle} onPress={() => updateTripForm('setAsDefaultTemplate', !tripForm.setAsDefaultTemplate)}>
|
|
||||||
<Text style={styles.inlineToggleText}>{tripForm.setAsDefaultTemplate ? '☑' : '☐'} Set as default template</Text>
|
|
||||||
</Pressable>
|
|
||||||
|
|
||||||
<Pressable style={styles.primaryBtn} onPress={createTrip}>
|
|
||||||
<Text style={styles.primaryBtnText}>Create Trip</Text>
|
|
||||||
</Pressable>
|
</Pressable>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
{trips
|
{activeTrip ? (
|
||||||
|
<View className={styles.tripHeroCard}>
|
||||||
|
<View className={styles.sectionHeaderLeft}>
|
||||||
|
<Ionicons name="location-outline" size={16} color="#d4d4d8" />
|
||||||
|
<Text className={styles.tripHeroTitle}>{activeTrip.name}</Text>
|
||||||
|
</View>
|
||||||
|
<Text className={styles.cardMeta}>{activeTrip.location || 'No location'} · {activeTrip.startDate} → {activeTrip.endDate}</Text>
|
||||||
|
<View className={styles.sectionHeaderLeft}>
|
||||||
|
<Ionicons name="layers-outline" size={13} color="#a1a1aa" />
|
||||||
|
<Text className={styles.cardMeta}>{activeTripItemCount} items · {activeTripCheckupCount} check-ups</Text>
|
||||||
|
</View>
|
||||||
|
<View className={styles.sectionHeader}>
|
||||||
|
<View className={styles.sectionHeaderLeft}>
|
||||||
|
<Ionicons name="checkmark-done-outline" size={13} color="#86efac" />
|
||||||
|
<Text className={styles.packProgressLabel}>{activeTripPackedCount}/{activeTripItemCount} items packed</Text>
|
||||||
|
</View>
|
||||||
|
<Text className={styles.packProgressMeta}>{activeTripItemCount ? Math.round((activeTripPackedCount / activeTripItemCount) * 100) : 0}%</Text>
|
||||||
|
</View>
|
||||||
|
<View className={styles.packProgressTrack}>
|
||||||
|
<View
|
||||||
|
className={styles.packProgressFill}
|
||||||
|
style={{ width: `${activeTripItemCount ? (activeTripPackedCount / activeTripItemCount) * 100 : 0}%` }}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
) : (
|
||||||
|
<View className={styles.cardSoft}>
|
||||||
|
<Text className={styles.muted}>No active trips. Unarchive one or create a new trip.</Text>
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<Text className={styles.tripListTitle}>Active Trips</Text>
|
||||||
|
|
||||||
|
{activeTrips
|
||||||
.slice()
|
.slice()
|
||||||
.sort((a, b) => b.startDate.localeCompare(a.startDate))
|
.sort((a, b) => b.startDate.localeCompare(a.startDate))
|
||||||
.map((trip) => (
|
.map((trip) => (
|
||||||
<View key={trip.id} style={[styles.card, selectedTripId === trip.id && styles.cardActive]}>
|
<View key={trip.id} className={cn(styles.card, selectedTripId === trip.id && styles.cardActive)}>
|
||||||
<View style={styles.cardRow}>
|
<View className={styles.cardRow}>
|
||||||
<View style={styles.flex}>
|
<View className={styles.flex}>
|
||||||
<Text style={styles.cardTitle}>{trip.name}</Text>
|
<Text className={styles.cardTitle}>{trip.name}</Text>
|
||||||
<Text style={styles.cardMeta}>{trip.location || 'No location'} · {trip.startDate} → {trip.endDate}</Text>
|
<Text className={styles.cardMeta}>{trip.location || 'No location'} · {trip.startDate} → {trip.endDate}</Text>
|
||||||
<Text style={styles.cardMeta}>{defaultTemplateTripId === trip.id ? 'Default template' : ' '}</Text>
|
{defaultTemplateTripId === trip.id ? (
|
||||||
|
<View className={styles.sectionHeaderLeft}>
|
||||||
|
<Ionicons name="bookmark-outline" size={12} color="#a1a1aa" />
|
||||||
|
<Text className={styles.cardMeta}>Default template</Text>
|
||||||
|
</View>
|
||||||
|
) : null}
|
||||||
</View>
|
</View>
|
||||||
<View style={styles.stackButtons}>
|
<View className={styles.stackButtons}>
|
||||||
<Pressable style={styles.miniBtn} onPress={() => chooseTrip(trip.id)}>
|
<Pressable className={styles.miniBtn} onPress={() => openView(trip.id)}>
|
||||||
<Text style={styles.miniBtnText}>Select</Text>
|
<View className={styles.buttonContent}>
|
||||||
</Pressable>
|
<Ionicons name="eye-outline" size={12} color="#f4f4f5" />
|
||||||
<Pressable style={styles.miniBtn} onPress={() => setTripAsTemplate(trip.id)}>
|
<Text className={styles.miniBtnText}>View</Text>
|
||||||
<Text style={styles.miniBtnText}>Template</Text>
|
</View>
|
||||||
</Pressable>
|
|
||||||
<Pressable style={styles.miniBtnDanger} onPress={() => deleteTrip(trip.id)}>
|
|
||||||
<Text style={styles.miniBtnText}>Delete</Text>
|
|
||||||
</Pressable>
|
</Pressable>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
{trip.imageUri ? <Image source={{ uri: trip.imageUri }} style={styles.previewImageSmall} /> : null}
|
|
||||||
</View>
|
</View>
|
||||||
))}
|
))}
|
||||||
|
|
||||||
|
{archivedTrips.length > 0 ? (
|
||||||
|
<>
|
||||||
|
<Text className={styles.tripListTitle}>Archived Trips</Text>
|
||||||
|
{archivedTrips
|
||||||
|
.slice()
|
||||||
|
.sort((a, b) => b.startDate.localeCompare(a.startDate))
|
||||||
|
.map((trip) => (
|
||||||
|
<View key={trip.id} className={cn(styles.card, styles.cardArchived)}>
|
||||||
|
<View className={styles.cardRow}>
|
||||||
|
<View className={styles.flex}>
|
||||||
|
<Text className={styles.cardTitle}>{trip.name}</Text>
|
||||||
|
<Text className={styles.cardMeta}>{trip.location || 'No location'} · {trip.startDate} → {trip.endDate}</Text>
|
||||||
|
<View className={styles.sectionHeaderLeft}>
|
||||||
|
<Ionicons name="archive-outline" size={12} color="#a1a1aa" />
|
||||||
|
<Text className={styles.cardMeta}>Archived</Text>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
<View className={styles.stackButtons}>
|
||||||
|
<Pressable className={styles.miniBtn} onPress={() => openView(trip.id)}>
|
||||||
|
<View className={styles.buttonContent}>
|
||||||
|
<Ionicons name="eye-outline" size={12} color="#f4f4f5" />
|
||||||
|
<Text className={styles.miniBtnText}>View</Text>
|
||||||
|
</View>
|
||||||
|
</Pressable>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
))}
|
||||||
|
</>
|
||||||
|
) : null}
|
||||||
|
|
||||||
|
<Modal visible={createModalVisible} animationType="slide" transparent>
|
||||||
|
<View className={styles.modalBackdrop}>
|
||||||
|
<KeyboardAvoidingView behavior={Platform.OS === 'ios' ? 'padding' : undefined} className={styles.modalKeyboardWrap}>
|
||||||
|
<View className={styles.modalCard}>
|
||||||
|
<View className={styles.sectionHeader}>
|
||||||
|
<View className={styles.sectionHeaderLeft}>
|
||||||
|
<View className={styles.sectionHeaderIconWrap}>
|
||||||
|
<Ionicons name="add-circle-outline" size={16} color="#d4d4d8" />
|
||||||
|
</View>
|
||||||
|
<Text className={styles.cardTitle}>Create Trip</Text>
|
||||||
|
</View>
|
||||||
|
<Pressable className={styles.secondaryBtnTight} onPress={() => setCreateModalVisible(false)}>
|
||||||
|
<View className={styles.buttonContent}>
|
||||||
|
<Ionicons name="close" size={14} color="#f4f4f5" />
|
||||||
|
<Text className={styles.secondaryBtnText}>Close</Text>
|
||||||
|
</View>
|
||||||
|
</Pressable>
|
||||||
|
</View>
|
||||||
|
|
||||||
|
<ScrollView
|
||||||
|
keyboardShouldPersistTaps="handled"
|
||||||
|
keyboardDismissMode="interactive"
|
||||||
|
contentContainerStyle={styles.modalScrollContent}
|
||||||
|
showsVerticalScrollIndicator={false}
|
||||||
|
>
|
||||||
|
<Field label="Name" icon="text-outline">
|
||||||
|
<TextInput
|
||||||
|
className={styles.input}
|
||||||
|
value={tripForm.name}
|
||||||
|
onChangeText={(v) => updateTripForm('name', v)}
|
||||||
|
placeholder="Summer Weekend"
|
||||||
|
placeholderTextColor="#71717a"
|
||||||
|
onFocus={onInputFocus}
|
||||||
|
/>
|
||||||
|
</Field>
|
||||||
|
|
||||||
|
<Field label="Location" icon="location-outline">
|
||||||
|
<TextInput
|
||||||
|
className={styles.input}
|
||||||
|
value={tripForm.location}
|
||||||
|
onChangeText={(v) => updateTripForm('location', v)}
|
||||||
|
placeholder="Berlin"
|
||||||
|
placeholderTextColor="#71717a"
|
||||||
|
onFocus={onInputFocus}
|
||||||
|
/>
|
||||||
|
</Field>
|
||||||
|
|
||||||
|
<DateField label="Start Date" value={tripForm.startDate} onPress={() => openDatePicker('startDate')} />
|
||||||
|
<DateField label="End Date" value={tripForm.endDate} onPress={() => openDatePicker('endDate')} />
|
||||||
|
|
||||||
|
{templateTrip ? (
|
||||||
|
<Pressable className={styles.inlineToggle} onPress={() => updateTripForm('copyDefaultTemplate', !tripForm.copyDefaultTemplate)}>
|
||||||
|
<View className={styles.sectionHeaderLeft}>
|
||||||
|
<Ionicons name={tripForm.copyDefaultTemplate ? 'checkbox-outline' : 'square-outline'} size={16} color="#d4d4d8" />
|
||||||
|
<Text className={styles.inlineToggleText}>Copy items from template ({templateTrip.name})</Text>
|
||||||
|
</View>
|
||||||
|
</Pressable>
|
||||||
|
) : null}
|
||||||
|
|
||||||
|
<Pressable className={styles.inlineToggle} onPress={() => updateTripForm('setAsDefaultTemplate', !tripForm.setAsDefaultTemplate)}>
|
||||||
|
<View className={styles.sectionHeaderLeft}>
|
||||||
|
<Ionicons name={tripForm.setAsDefaultTemplate ? 'checkbox-outline' : 'square-outline'} size={16} color="#d4d4d8" />
|
||||||
|
<Text className={styles.inlineToggleText}>Set as default template</Text>
|
||||||
|
</View>
|
||||||
|
</Pressable>
|
||||||
|
|
||||||
|
<Pressable className={styles.primaryBtn} onPress={submitCreateTrip}>
|
||||||
|
<View className={styles.buttonContent}>
|
||||||
|
<Ionicons name="checkmark-circle-outline" size={15} color="#ffffff" />
|
||||||
|
<Text className={styles.primaryBtnText}>Create Trip</Text>
|
||||||
|
</View>
|
||||||
|
</Pressable>
|
||||||
|
</ScrollView>
|
||||||
|
</View>
|
||||||
|
</KeyboardAvoidingView>
|
||||||
|
</View>
|
||||||
|
</Modal>
|
||||||
|
|
||||||
|
<Modal visible={!!viewingTrip} animationType="slide" transparent>
|
||||||
|
<View className={styles.modalBackdrop}>
|
||||||
|
<KeyboardAvoidingView behavior={Platform.OS === 'ios' ? 'padding' : undefined} className={styles.modalKeyboardWrap}>
|
||||||
|
<View className={styles.modalCard}>
|
||||||
|
<View className={styles.sectionHeader}>
|
||||||
|
<View className={styles.sectionHeaderLeft}>
|
||||||
|
<View className={styles.sectionHeaderIconWrap}>
|
||||||
|
<Ionicons name="compass-outline" size={16} color="#d4d4d8" />
|
||||||
|
</View>
|
||||||
|
<Text className={styles.cardTitle}>Trip Details</Text>
|
||||||
|
</View>
|
||||||
|
<Pressable
|
||||||
|
className={styles.secondaryBtnTight}
|
||||||
|
onPress={() => {
|
||||||
|
setViewTripId(null);
|
||||||
|
setEditMode(false);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<View className={styles.buttonContent}>
|
||||||
|
<Ionicons name="close" size={14} color="#f4f4f5" />
|
||||||
|
<Text className={styles.secondaryBtnText}>Close</Text>
|
||||||
|
</View>
|
||||||
|
</Pressable>
|
||||||
|
</View>
|
||||||
|
|
||||||
|
{viewingTrip ? (
|
||||||
|
<ScrollView
|
||||||
|
keyboardShouldPersistTaps="handled"
|
||||||
|
keyboardDismissMode="interactive"
|
||||||
|
contentContainerStyle={styles.modalScrollContent}
|
||||||
|
showsVerticalScrollIndicator={false}
|
||||||
|
>
|
||||||
|
{!editMode ? (
|
||||||
|
<>
|
||||||
|
<Text className={styles.tripHeroTitle}>{viewingTrip.name}</Text>
|
||||||
|
<View className={styles.sectionHeaderLeft}>
|
||||||
|
<Ionicons name="location-outline" size={13} color="#a1a1aa" />
|
||||||
|
<Text className={styles.cardMeta}>{viewingTrip.location || 'No location'}</Text>
|
||||||
|
</View>
|
||||||
|
<View className={styles.sectionHeaderLeft}>
|
||||||
|
<Ionicons name="calendar-outline" size={13} color="#a1a1aa" />
|
||||||
|
<Text className={styles.cardMeta}>{viewingTrip.startDate} → {viewingTrip.endDate}</Text>
|
||||||
|
</View>
|
||||||
|
<View className={styles.sectionHeaderLeft}>
|
||||||
|
<Ionicons name="bookmark-outline" size={13} color="#a1a1aa" />
|
||||||
|
<Text className={styles.cardMeta}>{defaultTemplateTripId === viewingTrip.id ? 'Default template trip' : 'Not default template'}</Text>
|
||||||
|
</View>
|
||||||
|
<View className={styles.sectionHeaderLeft}>
|
||||||
|
<Ionicons name="archive-outline" size={13} color="#a1a1aa" />
|
||||||
|
<Text className={styles.cardMeta}>{viewingTrip.archived ? 'Archived' : 'Active'}</Text>
|
||||||
|
</View>
|
||||||
|
|
||||||
|
<Pressable className={styles.secondaryBtn} onPress={() => setEditMode(true)}>
|
||||||
|
<View className={styles.buttonContent}>
|
||||||
|
<Ionicons name="create-outline" size={14} color="#f4f4f5" />
|
||||||
|
<Text className={styles.secondaryBtnText}>Edit Trip</Text>
|
||||||
|
</View>
|
||||||
|
</Pressable>
|
||||||
|
|
||||||
|
<Pressable className={styles.secondaryBtn} onPress={applyTemplateFromView}>
|
||||||
|
<View className={styles.buttonContent}>
|
||||||
|
<Ionicons name="bookmark-outline" size={14} color="#f4f4f5" />
|
||||||
|
<Text className={styles.secondaryBtnText}>Set as Template</Text>
|
||||||
|
</View>
|
||||||
|
</Pressable>
|
||||||
|
|
||||||
|
<Pressable className={styles.secondaryBtn} onPress={toggleArchiveFromView}>
|
||||||
|
<View className={styles.buttonContent}>
|
||||||
|
<Ionicons name={viewingTrip.archived ? 'refresh-outline' : 'archive-outline'} size={14} color="#f4f4f5" />
|
||||||
|
<Text className={styles.secondaryBtnText}>{viewingTrip.archived ? 'Unarchive Trip' : 'Archive Trip'}</Text>
|
||||||
|
</View>
|
||||||
|
</Pressable>
|
||||||
|
|
||||||
|
<Pressable className={styles.secondaryBtn} onPress={deleteFromView}>
|
||||||
|
<View className={styles.buttonContent}>
|
||||||
|
<Ionicons name="trash-outline" size={14} color="#f4f4f5" />
|
||||||
|
<Text className={styles.secondaryBtnText}>Delete Trip</Text>
|
||||||
|
</View>
|
||||||
|
</Pressable>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<Field label="Name" icon="text-outline">
|
||||||
|
<TextInput
|
||||||
|
className={styles.input}
|
||||||
|
value={editForm.name}
|
||||||
|
onChangeText={(v) => updateEditForm('name', v)}
|
||||||
|
placeholder="Trip name"
|
||||||
|
placeholderTextColor="#71717a"
|
||||||
|
onFocus={onInputFocus}
|
||||||
|
/>
|
||||||
|
</Field>
|
||||||
|
|
||||||
|
<Field label="Location" icon="location-outline">
|
||||||
|
<TextInput
|
||||||
|
className={styles.input}
|
||||||
|
value={editForm.location}
|
||||||
|
onChangeText={(v) => updateEditForm('location', v)}
|
||||||
|
placeholder="Location"
|
||||||
|
placeholderTextColor="#71717a"
|
||||||
|
onFocus={onInputFocus}
|
||||||
|
/>
|
||||||
|
</Field>
|
||||||
|
|
||||||
|
<DateField label="Start Date" value={editForm.startDate} onPress={() => setViewDatePicker({ visible: true, field: 'startDate' })} />
|
||||||
|
<DateField label="End Date" value={editForm.endDate} onPress={() => setViewDatePicker({ visible: true, field: 'endDate' })} />
|
||||||
|
|
||||||
|
<Pressable className={styles.primaryBtn} onPress={saveEditFromView}>
|
||||||
|
<View className={styles.buttonContent}>
|
||||||
|
<Ionicons name="checkmark-circle-outline" size={15} color="#ffffff" />
|
||||||
|
<Text className={styles.primaryBtnText}>Save Trip</Text>
|
||||||
|
</View>
|
||||||
|
</Pressable>
|
||||||
|
<Pressable className={styles.secondaryBtn} onPress={() => setEditMode(false)}>
|
||||||
|
<View className={styles.buttonContent}>
|
||||||
|
<Ionicons name="close-circle-outline" size={15} color="#f4f4f5" />
|
||||||
|
<Text className={styles.secondaryBtnText}>Cancel Edit</Text>
|
||||||
|
</View>
|
||||||
|
</Pressable>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</ScrollView>
|
||||||
|
) : null}
|
||||||
|
</View>
|
||||||
|
</KeyboardAvoidingView>
|
||||||
|
</View>
|
||||||
|
</Modal>
|
||||||
|
|
||||||
|
<DatePickerModal
|
||||||
|
visible={viewDatePicker.visible}
|
||||||
|
title={viewDatePicker.field === 'startDate' ? 'Pick start date' : 'Pick end date'}
|
||||||
|
value={editForm[viewDatePicker.field]}
|
||||||
|
onClose={() => setViewDatePicker((prev) => ({ ...prev, visible: false }))}
|
||||||
|
onSelect={(ymd) => {
|
||||||
|
updateEditForm(viewDatePicker.field, ymd);
|
||||||
|
setViewDatePicker((prev) => ({ ...prev, visible: false }));
|
||||||
|
}}
|
||||||
|
/>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
10
src/uniwind-types.d.ts
vendored
Normal file
10
src/uniwind-types.d.ts
vendored
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
// NOTE: This file is generated by uniwind and it should not be edited manually.
|
||||||
|
/// <reference types="uniwind/types" />
|
||||||
|
|
||||||
|
declare module 'uniwind' {
|
||||||
|
export interface UniwindConfig {
|
||||||
|
themes: readonly ['light', 'dark']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export {}
|
||||||
76
src/utils/backup.js
Normal file
76
src/utils/backup.js
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
import { normalizeNameAndQuantity } from './labels';
|
||||||
|
|
||||||
|
export function normalizeItemRecord(item = {}) {
|
||||||
|
const normalized = normalizeNameAndQuantity(item.name, item.quantity);
|
||||||
|
return {
|
||||||
|
...item,
|
||||||
|
name: normalized.name,
|
||||||
|
quantity: normalized.quantity,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function normalizeSnapshotRecord(entry = {}) {
|
||||||
|
const normalized = normalizeNameAndQuantity(entry.name, entry.quantity);
|
||||||
|
return {
|
||||||
|
...entry,
|
||||||
|
name: normalized.name,
|
||||||
|
quantity: normalized.quantity,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function normalizePayloadShape(payload = {}) {
|
||||||
|
const itemsByTrip = {};
|
||||||
|
Object.entries(payload.itemsByTrip || {}).forEach(([tripId, items]) => {
|
||||||
|
itemsByTrip[tripId] = (Array.isArray(items) ? items : []).map(normalizeItemRecord);
|
||||||
|
});
|
||||||
|
|
||||||
|
const checkupsByTrip = {};
|
||||||
|
Object.entries(payload.checkupsByTrip || {}).forEach(([tripId, checkups]) => {
|
||||||
|
checkupsByTrip[tripId] = (Array.isArray(checkups) ? checkups : []).map((checkup) => ({
|
||||||
|
...checkup,
|
||||||
|
snapshot: (Array.isArray(checkup?.snapshot) ? checkup.snapshot : []).map(normalizeSnapshotRecord),
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
...payload,
|
||||||
|
itemsByTrip,
|
||||||
|
checkupsByTrip,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function stringifyBackupData(data) {
|
||||||
|
return JSON.stringify(
|
||||||
|
{
|
||||||
|
version: 2,
|
||||||
|
exportedAt: new Date().toISOString(),
|
||||||
|
data,
|
||||||
|
},
|
||||||
|
null,
|
||||||
|
2
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function parseBackupText(rawText = '') {
|
||||||
|
if (!`${rawText || ''}`.trim()) {
|
||||||
|
return { ok: false, error: 'missing-backup' };
|
||||||
|
}
|
||||||
|
|
||||||
|
let parsed;
|
||||||
|
try {
|
||||||
|
parsed = JSON.parse(rawText);
|
||||||
|
} catch {
|
||||||
|
return { ok: false, error: 'invalid-json' };
|
||||||
|
}
|
||||||
|
|
||||||
|
const payload = parsed?.data && typeof parsed.data === 'object' ? parsed.data : parsed;
|
||||||
|
|
||||||
|
if (!payload || typeof payload !== 'object' || !Array.isArray(payload.trips) || !payload.itemsByTrip || !payload.checkupsByTrip) {
|
||||||
|
return { ok: false, error: 'invalid-backup' };
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
ok: true,
|
||||||
|
payload: normalizePayloadShape(payload),
|
||||||
|
};
|
||||||
|
}
|
||||||
90
src/utils/backup.test.js
Normal file
90
src/utils/backup.test.js
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
import {
|
||||||
|
normalizeItemRecord,
|
||||||
|
normalizePayloadShape,
|
||||||
|
parseBackupText,
|
||||||
|
stringifyBackupData,
|
||||||
|
} from './backup';
|
||||||
|
|
||||||
|
describe('backup helpers', () => {
|
||||||
|
test('normalizeItemRecord migrates legacy quantity from item name', () => {
|
||||||
|
expect(
|
||||||
|
normalizeItemRecord({
|
||||||
|
id: 'item_1',
|
||||||
|
name: '3x socks',
|
||||||
|
quantity: 1,
|
||||||
|
})
|
||||||
|
).toEqual({
|
||||||
|
id: 'item_1',
|
||||||
|
name: 'socks',
|
||||||
|
quantity: 3,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test('normalizePayloadShape normalizes nested items and snapshots', () => {
|
||||||
|
const normalized = normalizePayloadShape({
|
||||||
|
trips: [],
|
||||||
|
itemsByTrip: {
|
||||||
|
trip_1: [{ id: 'item_1', name: '2x cables', quantity: 1 }],
|
||||||
|
},
|
||||||
|
checkupsByTrip: {
|
||||||
|
trip_1: [
|
||||||
|
{
|
||||||
|
id: 'checkup_1',
|
||||||
|
snapshot: [{ itemId: 'item_1', name: '4x batteries', quantity: 1 }],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(normalized.itemsByTrip.trip_1[0]).toEqual({
|
||||||
|
id: 'item_1',
|
||||||
|
name: 'cables',
|
||||||
|
quantity: 2,
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(normalized.checkupsByTrip.trip_1[0].snapshot[0]).toEqual({
|
||||||
|
itemId: 'item_1',
|
||||||
|
name: 'batteries',
|
||||||
|
quantity: 4,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test('stringifyBackupData returns versioned backup payload', () => {
|
||||||
|
const json = stringifyBackupData({ trips: [] });
|
||||||
|
const parsed = JSON.parse(json);
|
||||||
|
|
||||||
|
expect(parsed.version).toBe(2);
|
||||||
|
expect(parsed.data).toEqual({ trips: [] });
|
||||||
|
expect(typeof parsed.exportedAt).toBe('string');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('parseBackupText rejects missing and malformed payloads', () => {
|
||||||
|
expect(parseBackupText('')).toEqual({ ok: false, error: 'missing-backup' });
|
||||||
|
expect(parseBackupText('{bad')).toEqual({ ok: false, error: 'invalid-json' });
|
||||||
|
expect(parseBackupText('{"foo":1}')).toEqual({ ok: false, error: 'invalid-backup' });
|
||||||
|
});
|
||||||
|
|
||||||
|
test('parseBackupText accepts wrapped backup payloads and normalizes data', () => {
|
||||||
|
const wrapped = JSON.stringify({
|
||||||
|
version: 2,
|
||||||
|
data: {
|
||||||
|
trips: [{ id: 'trip_1' }],
|
||||||
|
itemsByTrip: {
|
||||||
|
trip_1: [{ id: 'item_1', name: '2x socks', quantity: 1 }],
|
||||||
|
},
|
||||||
|
checkupsByTrip: {
|
||||||
|
trip_1: [],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = parseBackupText(wrapped);
|
||||||
|
|
||||||
|
expect(result.ok).toBe(true);
|
||||||
|
expect(result.payload.itemsByTrip.trip_1[0]).toEqual({
|
||||||
|
id: 'item_1',
|
||||||
|
name: 'socks',
|
||||||
|
quantity: 2,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
3
src/utils/cn.js
Normal file
3
src/utils/cn.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
export function cn(...parts) {
|
||||||
|
return parts.filter(Boolean).join(' ');
|
||||||
|
}
|
||||||
15
src/utils/cn.test.js
Normal file
15
src/utils/cn.test.js
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
import { cn } from './cn';
|
||||||
|
|
||||||
|
describe('cn', () => {
|
||||||
|
test('joins truthy class parts', () => {
|
||||||
|
expect(cn('a', 'b', 'c')).toBe('a b c');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('skips falsy parts', () => {
|
||||||
|
expect(cn('a', '', null, undefined, false, 'b')).toBe('a b');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('returns empty string when nothing is provided', () => {
|
||||||
|
expect(cn()).toBe('');
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -23,3 +23,34 @@ export function findActiveTripId(trips) {
|
|||||||
});
|
});
|
||||||
return active?.id || null;
|
return active?.id || null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function findNextTripId(trips) {
|
||||||
|
const today = parseYMD(todayYMD());
|
||||||
|
if (!today) return null;
|
||||||
|
|
||||||
|
const next = trips
|
||||||
|
.map((trip) => ({ id: trip.id, start: parseYMD(trip.startDate) }))
|
||||||
|
.filter((trip) => !!trip.start && trip.start >= today)
|
||||||
|
.sort((a, b) => a.start - b.start)[0];
|
||||||
|
|
||||||
|
return next?.id || null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function findBestTripId(trips) {
|
||||||
|
const activeTripId = findActiveTripId(trips);
|
||||||
|
if (activeTripId) return activeTripId;
|
||||||
|
|
||||||
|
const nextTripId = findNextTripId(trips);
|
||||||
|
if (nextTripId) return nextTripId;
|
||||||
|
|
||||||
|
const latestPast = trips
|
||||||
|
.map((trip) => ({ id: trip.id, end: parseYMD(trip.endDate), start: parseYMD(trip.startDate) }))
|
||||||
|
.filter((trip) => !!trip.end || !!trip.start)
|
||||||
|
.sort((a, b) => {
|
||||||
|
const aTime = (a.end || a.start).getTime();
|
||||||
|
const bTime = (b.end || b.start).getTime();
|
||||||
|
return bTime - aTime;
|
||||||
|
})[0];
|
||||||
|
|
||||||
|
return latestPast?.id || null;
|
||||||
|
}
|
||||||
|
|||||||
78
src/utils/date.test.js
Normal file
78
src/utils/date.test.js
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
import { findActiveTripId, findBestTripId, findNextTripId, makeId, parseYMD, todayYMD } from './date';
|
||||||
|
import { vi } from 'vitest';
|
||||||
|
|
||||||
|
describe('date helpers', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
vi.useFakeTimers();
|
||||||
|
vi.setSystemTime(new Date(2026, 3, 18, 12, 0, 0));
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
vi.useRealTimers();
|
||||||
|
vi.restoreAllMocks();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('makeId returns a prefixed id with timestamp and random suffix', () => {
|
||||||
|
vi.spyOn(Math, 'random').mockReturnValue(0.123456);
|
||||||
|
const id = makeId('item');
|
||||||
|
|
||||||
|
expect(id).toMatch(/^item_\d+_[a-z0-9]{6}$/);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('todayYMD returns yyyy-mm-dd', () => {
|
||||||
|
expect(todayYMD()).toBe('2026-04-18');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('parseYMD returns null for invalid format', () => {
|
||||||
|
expect(parseYMD('2026/04/18')).toBeNull();
|
||||||
|
expect(parseYMD('')).toBeNull();
|
||||||
|
expect(parseYMD(null)).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('parseYMD returns date for valid format', () => {
|
||||||
|
const parsed = parseYMD('2026-04-18');
|
||||||
|
|
||||||
|
expect(parsed).toBeInstanceOf(Date);
|
||||||
|
expect(parsed?.getFullYear()).toBe(2026);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('findActiveTripId picks a currently active trip', () => {
|
||||||
|
const trips = [
|
||||||
|
{ id: 'past', startDate: '2026-04-01', endDate: '2026-04-10' },
|
||||||
|
{ id: 'active', startDate: '2026-04-15', endDate: '2026-04-20' },
|
||||||
|
{ id: 'future', startDate: '2026-05-01', endDate: '2026-05-05' },
|
||||||
|
];
|
||||||
|
|
||||||
|
expect(findActiveTripId(trips)).toBe('active');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('findNextTripId picks nearest upcoming trip', () => {
|
||||||
|
const trips = [
|
||||||
|
{ id: 'next-later', startDate: '2026-05-10', endDate: '2026-05-12' },
|
||||||
|
{ id: 'next-soon', startDate: '2026-04-20', endDate: '2026-04-22' },
|
||||||
|
{ id: 'past', startDate: '2026-03-01', endDate: '2026-03-02' },
|
||||||
|
];
|
||||||
|
|
||||||
|
expect(findNextTripId(trips)).toBe('next-soon');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('findBestTripId prefers active trip, then next trip, then latest past trip', () => {
|
||||||
|
const activeTrips = [
|
||||||
|
{ id: 'active', startDate: '2026-04-10', endDate: '2026-04-20' },
|
||||||
|
{ id: 'future', startDate: '2026-04-25', endDate: '2026-04-27' },
|
||||||
|
];
|
||||||
|
expect(findBestTripId(activeTrips)).toBe('active');
|
||||||
|
|
||||||
|
const nextTrips = [
|
||||||
|
{ id: 'future-1', startDate: '2026-04-30', endDate: '2026-05-02' },
|
||||||
|
{ id: 'future-2', startDate: '2026-04-22', endDate: '2026-04-23' },
|
||||||
|
];
|
||||||
|
expect(findBestTripId(nextTrips)).toBe('future-2');
|
||||||
|
|
||||||
|
const pastTrips = [
|
||||||
|
{ id: 'old', startDate: '2026-02-01', endDate: '2026-02-05' },
|
||||||
|
{ id: 'recent', startDate: '2026-04-01', endDate: '2026-04-10' },
|
||||||
|
];
|
||||||
|
expect(findBestTripId(pastTrips)).toBe('recent');
|
||||||
|
});
|
||||||
|
});
|
||||||
27
src/utils/items.js
Normal file
27
src/utils/items.js
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
import { ITEM_PLACEMENTS } from '../constants';
|
||||||
|
|
||||||
|
export function toPlacementFormState(rawPlacement = 'suitcase') {
|
||||||
|
const placement = `${rawPlacement || ''}`.trim() || 'suitcase';
|
||||||
|
const hasPresetPlacement = ITEM_PLACEMENTS.includes(placement);
|
||||||
|
|
||||||
|
return {
|
||||||
|
placement: hasPresetPlacement ? placement : 'other',
|
||||||
|
placementCustom: hasPresetPlacement || placement === 'other' ? '' : placement,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function resolvePlacementValue(placement = '', placementCustom = '') {
|
||||||
|
const normalizedPlacement = `${placement || ''}`.trim();
|
||||||
|
if (!normalizedPlacement) return '';
|
||||||
|
|
||||||
|
if (normalizedPlacement === 'other') {
|
||||||
|
return `${placementCustom || ''}`.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
return normalizedPlacement;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function withPlacementCustomFallback(currentCustom = '', fallback = '') {
|
||||||
|
const custom = `${currentCustom || ''}`.trim();
|
||||||
|
return custom || `${fallback || ''}`.trim();
|
||||||
|
}
|
||||||
33
src/utils/items.test.js
Normal file
33
src/utils/items.test.js
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
import { resolvePlacementValue, toPlacementFormState, withPlacementCustomFallback } from './items';
|
||||||
|
|
||||||
|
describe('items helpers', () => {
|
||||||
|
test('toPlacementFormState keeps known placements as-is', () => {
|
||||||
|
expect(toPlacementFormState('suitcase')).toEqual({
|
||||||
|
placement: 'suitcase',
|
||||||
|
placementCustom: '',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test('toPlacementFormState converts custom placements to other with value', () => {
|
||||||
|
expect(toPlacementFormState('hotel safe')).toEqual({
|
||||||
|
placement: 'other',
|
||||||
|
placementCustom: 'hotel safe',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test('resolvePlacementValue returns custom value when placement is other', () => {
|
||||||
|
expect(resolvePlacementValue('other', ' hotel safe ')).toBe('hotel safe');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('resolvePlacementValue returns direct placement when not other', () => {
|
||||||
|
expect(resolvePlacementValue('backpack', 'ignored')).toBe('backpack');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('withPlacementCustomFallback prefers existing custom value', () => {
|
||||||
|
expect(withPlacementCustomFallback('closet shelf', 'hotel safe')).toBe('closet shelf');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('withPlacementCustomFallback uses fallback when custom is empty', () => {
|
||||||
|
expect(withPlacementCustomFallback(' ', 'hotel safe')).toBe('hotel safe');
|
||||||
|
});
|
||||||
|
});
|
||||||
83
src/utils/labels.js
Normal file
83
src/utils/labels.js
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
export function toTitleWords(value) {
|
||||||
|
if (!value) return '';
|
||||||
|
return value
|
||||||
|
.toString()
|
||||||
|
.split('-')
|
||||||
|
.map((part) => (part ? part[0].toUpperCase() + part.slice(1) : part))
|
||||||
|
.join(' ');
|
||||||
|
}
|
||||||
|
|
||||||
|
export function formatStatusLabel(status, lentTo = '') {
|
||||||
|
if (!status) return '';
|
||||||
|
if (status === 'lent-to') {
|
||||||
|
const name = lentTo?.trim();
|
||||||
|
return name ? `Lent To ${name}` : 'Lent To';
|
||||||
|
}
|
||||||
|
return toTitleWords(status);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function formatFilterLabel(value) {
|
||||||
|
if (!value) return '';
|
||||||
|
if (value === 'all') return 'All';
|
||||||
|
return toTitleWords(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function normalizeQuantity(value, fallback = 1) {
|
||||||
|
const parsed = Number.parseInt(`${value ?? ''}`, 10);
|
||||||
|
if (Number.isFinite(parsed) && parsed > 0) return parsed;
|
||||||
|
return fallback;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function extractLegacyQuantityFromName(rawName = '') {
|
||||||
|
const name = `${rawName || ''}`.trim();
|
||||||
|
if (!name) {
|
||||||
|
return { matched: false, name: '', quantity: 1 };
|
||||||
|
}
|
||||||
|
|
||||||
|
let matched = name.match(/^(\d+)\s*[xX×]\s*(.+)$/);
|
||||||
|
if (matched) {
|
||||||
|
const quantity = normalizeQuantity(matched[1], 1);
|
||||||
|
const cleanName = (matched[2] || '').trim() || name;
|
||||||
|
return { matched: true, name: cleanName, quantity };
|
||||||
|
}
|
||||||
|
|
||||||
|
matched = name.match(/^(.+?)\s+(\d+)\s*[xX×]$/);
|
||||||
|
if (matched) {
|
||||||
|
const quantity = normalizeQuantity(matched[2], 1);
|
||||||
|
const cleanName = (matched[1] || '').trim() || name;
|
||||||
|
return { matched: true, name: cleanName, quantity };
|
||||||
|
}
|
||||||
|
|
||||||
|
return { matched: false, name, quantity: 1 };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function normalizeNameAndQuantity(rawName = '', rawQuantity = null) {
|
||||||
|
const explicitQuantity = normalizeQuantity(rawQuantity, 0);
|
||||||
|
const legacy = extractLegacyQuantityFromName(rawName);
|
||||||
|
|
||||||
|
if (legacy.matched && explicitQuantity <= 1) {
|
||||||
|
return {
|
||||||
|
name: legacy.name,
|
||||||
|
quantity: normalizeQuantity(legacy.quantity, 1),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const quantity = explicitQuantity > 0 ? explicitQuantity : legacy.quantity;
|
||||||
|
const cleanName = `${rawName || ''}`.trim() || legacy.name;
|
||||||
|
|
||||||
|
return {
|
||||||
|
name: cleanName,
|
||||||
|
quantity: normalizeQuantity(quantity, 1),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function formatItemLabel(name = '', quantity = 1) {
|
||||||
|
const cleanName = `${name || ''}`.trim();
|
||||||
|
const normalizedQuantity = normalizeQuantity(quantity, 1);
|
||||||
|
|
||||||
|
if (!cleanName) {
|
||||||
|
return normalizedQuantity > 1 ? `${normalizedQuantity}x item` : 'item';
|
||||||
|
}
|
||||||
|
|
||||||
|
return normalizedQuantity > 1 ? `${normalizedQuantity}x ${cleanName}` : cleanName;
|
||||||
|
}
|
||||||
72
src/utils/labels.test.js
Normal file
72
src/utils/labels.test.js
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
import {
|
||||||
|
extractLegacyQuantityFromName,
|
||||||
|
formatFilterLabel,
|
||||||
|
formatItemLabel,
|
||||||
|
formatStatusLabel,
|
||||||
|
normalizeNameAndQuantity,
|
||||||
|
normalizeQuantity,
|
||||||
|
toTitleWords,
|
||||||
|
} from './labels';
|
||||||
|
|
||||||
|
describe('labels helpers', () => {
|
||||||
|
test('toTitleWords title-cases dashed words', () => {
|
||||||
|
expect(toTitleWords('left-behind')).toBe('Left Behind');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('formatStatusLabel formats lent-to with optional person', () => {
|
||||||
|
expect(formatStatusLabel('lent-to', 'Alex')).toBe('Lent To Alex');
|
||||||
|
expect(formatStatusLabel('lent-to', ' ')).toBe('Lent To');
|
||||||
|
expect(formatStatusLabel('packed')).toBe('Packed');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('formatFilterLabel handles all and regular values', () => {
|
||||||
|
expect(formatFilterLabel('all')).toBe('All');
|
||||||
|
expect(formatFilterLabel('with-user')).toBe('With User');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('normalizeQuantity uses positive integers and fallback for invalid values', () => {
|
||||||
|
expect(normalizeQuantity(3)).toBe(3);
|
||||||
|
expect(normalizeQuantity('7')).toBe(7);
|
||||||
|
expect(normalizeQuantity('0')).toBe(1);
|
||||||
|
expect(normalizeQuantity('', 5)).toBe(5);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('extractLegacyQuantityFromName parses leading and trailing quantity formats', () => {
|
||||||
|
expect(extractLegacyQuantityFromName('3x socks')).toEqual({
|
||||||
|
matched: true,
|
||||||
|
name: 'socks',
|
||||||
|
quantity: 3,
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(extractLegacyQuantityFromName('socks 4x')).toEqual({
|
||||||
|
matched: true,
|
||||||
|
name: 'socks',
|
||||||
|
quantity: 4,
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(extractLegacyQuantityFromName('2× chargers')).toEqual({
|
||||||
|
matched: true,
|
||||||
|
name: 'chargers',
|
||||||
|
quantity: 2,
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(extractLegacyQuantityFromName('passport')).toEqual({
|
||||||
|
matched: false,
|
||||||
|
name: 'passport',
|
||||||
|
quantity: 1,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test('normalizeNameAndQuantity prioritizes explicit quantity but migrates legacy names', () => {
|
||||||
|
expect(normalizeNameAndQuantity('3x socks', null)).toEqual({ name: 'socks', quantity: 3 });
|
||||||
|
expect(normalizeNameAndQuantity('3x socks', 1)).toEqual({ name: 'socks', quantity: 3 });
|
||||||
|
expect(normalizeNameAndQuantity('3x socks', 5)).toEqual({ name: '3x socks', quantity: 5 });
|
||||||
|
expect(normalizeNameAndQuantity('socks', 2)).toEqual({ name: 'socks', quantity: 2 });
|
||||||
|
});
|
||||||
|
|
||||||
|
test('formatItemLabel includes quantity prefix when quantity > 1', () => {
|
||||||
|
expect(formatItemLabel('socks', 3)).toBe('3x socks');
|
||||||
|
expect(formatItemLabel('passport', 1)).toBe('passport');
|
||||||
|
expect(formatItemLabel('', 2)).toBe('2x item');
|
||||||
|
});
|
||||||
|
});
|
||||||
34
src/utils/trips.js
Normal file
34
src/utils/trips.js
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
import { parseYMD } from './date';
|
||||||
|
|
||||||
|
export function validateTripDraft({ name = '', startDate = '', endDate = '' }) {
|
||||||
|
if (!`${name || ''}`.trim()) {
|
||||||
|
return {
|
||||||
|
valid: false,
|
||||||
|
title: 'Missing name',
|
||||||
|
message: 'Trip name is required.',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const start = parseYMD(startDate);
|
||||||
|
const end = parseYMD(endDate);
|
||||||
|
|
||||||
|
if (!start || !end) {
|
||||||
|
return {
|
||||||
|
valid: false,
|
||||||
|
title: 'Invalid dates',
|
||||||
|
message: 'Please select valid trip dates.',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (start > end) {
|
||||||
|
return {
|
||||||
|
valid: false,
|
||||||
|
title: 'Invalid dates',
|
||||||
|
message: 'Start date cannot be after end date.',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
valid: true,
|
||||||
|
};
|
||||||
|
}
|
||||||
57
src/utils/trips.test.js
Normal file
57
src/utils/trips.test.js
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
import { validateTripDraft } from './trips';
|
||||||
|
|
||||||
|
describe('trips helpers', () => {
|
||||||
|
test('returns missing-name validation error', () => {
|
||||||
|
expect(
|
||||||
|
validateTripDraft({
|
||||||
|
name: ' ',
|
||||||
|
startDate: '2026-04-20',
|
||||||
|
endDate: '2026-04-22',
|
||||||
|
})
|
||||||
|
).toEqual({
|
||||||
|
valid: false,
|
||||||
|
title: 'Missing name',
|
||||||
|
message: 'Trip name is required.',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test('returns invalid-dates validation error for malformed dates', () => {
|
||||||
|
expect(
|
||||||
|
validateTripDraft({
|
||||||
|
name: 'Paris',
|
||||||
|
startDate: '2026/04/20',
|
||||||
|
endDate: '2026-04-22',
|
||||||
|
})
|
||||||
|
).toEqual({
|
||||||
|
valid: false,
|
||||||
|
title: 'Invalid dates',
|
||||||
|
message: 'Please select valid trip dates.',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test('returns invalid-dates validation error when start is after end', () => {
|
||||||
|
expect(
|
||||||
|
validateTripDraft({
|
||||||
|
name: 'Paris',
|
||||||
|
startDate: '2026-05-01',
|
||||||
|
endDate: '2026-04-22',
|
||||||
|
})
|
||||||
|
).toEqual({
|
||||||
|
valid: false,
|
||||||
|
title: 'Invalid dates',
|
||||||
|
message: 'Start date cannot be after end date.',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test('returns valid for a good trip draft', () => {
|
||||||
|
expect(
|
||||||
|
validateTripDraft({
|
||||||
|
name: 'Paris',
|
||||||
|
startDate: '2026-04-20',
|
||||||
|
endDate: '2026-04-22',
|
||||||
|
})
|
||||||
|
).toEqual({
|
||||||
|
valid: true,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
9
vitest.config.js
Normal file
9
vitest.config.js
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
const { defineConfig } = require('vitest/config');
|
||||||
|
|
||||||
|
module.exports = defineConfig({
|
||||||
|
test: {
|
||||||
|
environment: 'node',
|
||||||
|
globals: true,
|
||||||
|
include: ['src/utils/**/*.test.js'],
|
||||||
|
},
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user