Deep-audit + build-out across all products to fully-usable state; all typecheck clean. - gitgram-web (99): wire Store feature to real endpoints, close 9 gaps - gitgram-backend (100): close 8 flow gaps, document infra-provisioning items - gitgram-mobile (90): fix API base-URL/path mismatch (404s) + copy proximity components into components/proximity wired to real screens; 15 gaps, +react-native-svg - aitm-core (95): wire natural-language CLI flow end-to-end; 11 gaps - aitm-api (97): fix teams metadata runtime bug; copy a2a-js server/client/grpc into src/a2a and wire A2A route; crates.io package search; 8 gaps - aitm-mcp (100): fix A2A client/server card mismatch; 9 gaps - aitm-website (95): build missing docs routes; 9 gaps Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
130 lines
3.3 KiB
TypeScript
130 lines
3.3 KiB
TypeScript
import React, { useState, useEffect, useMemo } from 'react';
|
|
import { StyleSheet, ScrollView, View, FlatList, TouchableOpacity } from 'react-native';
|
|
import { useRouter } from 'expo-router';
|
|
import { ThemedView } from '../../components/ui/ThemedView';
|
|
import { ThemedText } from '../../components/ui/ThemedText';
|
|
import { Input } from '../../components/ui/Input';
|
|
import { Colors } from '../../constants/Colors';
|
|
import { storeService, StoreItem } from '../../services/storeService';
|
|
import { Image } from 'expo-image';
|
|
import { logger } from '../../utils/logger';
|
|
|
|
export default function StoreScreen() {
|
|
const router = useRouter();
|
|
const [products, setProducts] = useState<StoreItem[]>([]);
|
|
const [searchQuery, setSearchQuery] = useState('');
|
|
|
|
const filteredProducts = useMemo(() => {
|
|
if (!searchQuery.trim()) return products;
|
|
const q = searchQuery.toLowerCase();
|
|
return products.filter(
|
|
(p) =>
|
|
p.name?.toLowerCase().includes(q) ||
|
|
p.description?.toLowerCase().includes(q)
|
|
);
|
|
}, [products, searchQuery]);
|
|
|
|
useEffect(() => {
|
|
loadProducts();
|
|
}, []);
|
|
|
|
const loadProducts = async () => {
|
|
try {
|
|
const response = await storeService.getItems();
|
|
setProducts(response.items || response.products || []);
|
|
} catch (error) {
|
|
logger.error('Load products error:', error);
|
|
}
|
|
};
|
|
|
|
const renderItem = ({ item }: { item: StoreItem }) => (
|
|
<TouchableOpacity
|
|
style={styles.item}
|
|
onPress={() => router.push(`/store/item/${item.id}`)}
|
|
>
|
|
<Image source={{ uri: item.images?.[0] }} style={styles.image} />
|
|
<View style={styles.details}>
|
|
<ThemedText style={styles.name} numberOfLines={1}>{item.name}</ThemedText>
|
|
<ThemedText style={styles.price}>${item.price.toFixed(2)}</ThemedText>
|
|
</View>
|
|
</TouchableOpacity>
|
|
);
|
|
|
|
return (
|
|
<ThemedView style={styles.container}>
|
|
<View style={styles.header}>
|
|
<ThemedText type="title">Store</ThemedText>
|
|
<TouchableOpacity onPress={() => router.push('/store/sell')}>
|
|
<ThemedText type="link">Sell</ThemedText>
|
|
</TouchableOpacity>
|
|
</View>
|
|
|
|
<View style={styles.searchContainer}>
|
|
<Input
|
|
placeholder="Search items..."
|
|
value={searchQuery}
|
|
onChangeText={setSearchQuery}
|
|
/>
|
|
</View>
|
|
|
|
<FlatList
|
|
data={filteredProducts}
|
|
renderItem={renderItem}
|
|
keyExtractor={item => item.id}
|
|
numColumns={2}
|
|
contentContainerStyle={styles.list}
|
|
columnWrapperStyle={styles.columnWrapper}
|
|
/>
|
|
</ThemedView>
|
|
);
|
|
}
|
|
|
|
const styles = StyleSheet.create({
|
|
container: {
|
|
flex: 1,
|
|
},
|
|
header: {
|
|
flexDirection: 'row',
|
|
justifyContent: 'space-between',
|
|
alignItems: 'center',
|
|
padding: 20,
|
|
paddingBottom: 10,
|
|
},
|
|
searchContainer: {
|
|
paddingHorizontal: 20,
|
|
marginBottom: 10,
|
|
},
|
|
list: {
|
|
padding: 10,
|
|
},
|
|
columnWrapper: {
|
|
justifyContent: 'space-between',
|
|
paddingHorizontal: 10,
|
|
},
|
|
item: {
|
|
width: '48%',
|
|
backgroundColor: Colors.surface,
|
|
borderRadius: 12,
|
|
marginBottom: 16,
|
|
overflow: 'hidden',
|
|
},
|
|
image: {
|
|
width: '100%',
|
|
aspectRatio: 1,
|
|
},
|
|
details: {
|
|
padding: 12,
|
|
},
|
|
name: {
|
|
fontSize: 16,
|
|
fontWeight: '600',
|
|
marginBottom: 4,
|
|
},
|
|
price: {
|
|
fontSize: 14,
|
|
color: Colors.primary,
|
|
fontWeight: 'bold',
|
|
},
|
|
});
|
|
|