import { useState } from 'react'; import { View, Text, TextInput, Pressable, StyleSheet, ActivityIndicator, ScrollView, Platform, Alert, } from 'react-native'; import { useRouter } from 'expo-router'; import { useStoresStore } from '@/store/stores'; import { api } from '@/lib/api'; import type { Store } from '@shop/types'; /** * New store creation screen */ export default function NewStoreScreen() { const router = useRouter(); const { addStore } = useStoresStore(); const [storeName, setStoreName] = useState(''); const [storeLocation, setStoreLocation] = useState(''); const [isLoading, setIsLoading] = useState(false); const handleCreateStore = async () => { if (!storeName.trim()) { Alert.alert('Error', 'Please enter a store name'); return; } try { setIsLoading(true); const newStore = await api.post('/api/stores', { name: storeName, location: storeLocation || undefined, }); addStore(newStore); Alert.alert('Success', 'Store created', [ { text: 'OK', onPress: () => router.back(), }, ]); } catch (err) { console.error('Failed to create store:', err); Alert.alert('Error', 'Failed to create store'); } finally { setIsLoading(false); } }; return ( {/* Header */} router.back()}> ✕ New Store {/* Form */} Store Name * Location (optional) Next Steps After creating the store, you'll be able to: • Add aisles with custom names and colors • Organize items by aisle • Use this store for shopping lists {isLoading ? ( ) : ( Create Store )} ); } const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: '#fff', }, header: { flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', paddingHorizontal: 16, paddingVertical: 12, marginTop: Platform.OS === 'ios' ? 44 : 12, borderBottomWidth: 1, borderBottomColor: '#e0e0e0', }, title: { fontSize: 18, fontWeight: '600', color: '#000', }, closeButton: { fontSize: 20, color: '#007AFF', }, content: { flex: 1, padding: 16, }, formGroup: { marginBottom: 24, }, label: { fontSize: 14, fontWeight: '600', color: '#000', marginBottom: 8, }, input: { borderWidth: 1, borderColor: '#ddd', borderRadius: 8, paddingHorizontal: 12, paddingVertical: 10, fontSize: 16, backgroundColor: '#f9f9f9', }, infoBox: { backgroundColor: '#f0f8ff', borderLeftWidth: 4, borderLeftColor: '#007AFF', padding: 12, borderRadius: 8, marginBottom: 24, }, infoTitle: { fontSize: 14, fontWeight: '600', color: '#007AFF', marginBottom: 8, }, infoText: { fontSize: 13, color: '#666', marginBottom: 8, }, infoBullet: { fontSize: 13, color: '#666', marginBottom: 4, }, createButton: { backgroundColor: '#007AFF', paddingVertical: 12, borderRadius: 8, justifyContent: 'center', alignItems: 'center', marginBottom: 24, }, createButtonText: { color: '#fff', fontSize: 16, fontWeight: '600', }, buttonDisabled: { opacity: 0.6, }, });