This repository has been archived on 2026-11-17. You can view files and clone it, but cannot push or open issues or pull requests.
gitgram-ai/gitgram/mobile/app/store/my-listings.tsx
caelum0x 49b183818c Unify gitgram + aitimemachine into the monorepo (de-submodule) and merge vendored engines
Convert gitgram/ and aitimemachine/ from embedded git repos (which showed as
opaque submodule gitlinks on GitHub) into fully-tracked first-party content.

AITM now merges its 7 vendored repos as first-party engines:
- memory: beads (Go task DAG) + context7 (docs SDK), unified into saved_contexts
- git: vendored C git (bundled binary) + gitnexus (in-process code intelligence)
- agentic: a2a (@a2a-js/sdk) + pal (AITM-managed Python subprocess)

Includes the full session's product build: Gitgram web/mobile/backend features,
AITM website/CLI/MCP, the unified memory layer, engine build tooling
(scripts/build-engines.sh, Dockerfile, CI), docs (README, ENGINES.md, ARCHITECTURE.md),
and extensive test suites.

Build artifacts, node_modules, external/, and gemini-cli are gitignored.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-23 14:14:09 +03:00

221 lines
5.4 KiB
TypeScript

import React, { useState, useEffect } from 'react';
import {
View,
Text,
StyleSheet,
FlatList,
TouchableOpacity,
Alert,
} from 'react-native';
import { useRouter } from 'expo-router';
import { Colors } from '../../constants/Colors';
import Header from '../../components/navigation/Header';
import LoadingSpinner from '../../components/common/LoadingSpinner';
import EmptyState from '../../components/common/EmptyState';
import { Image } from 'expo-image';
import { storeService } from '../../services/storeService';
import { logger } from '../../utils/logger';
import Icon from 'react-native-vector-icons/MaterialIcons';
export default function MyListingsScreen() {
const router = useRouter();
const [items, setItems] = useState<any[]>([]);
const [loading, setLoading] = useState(true);
useEffect(() => {
loadMyListings();
}, []);
const loadMyListings = async () => {
try {
setLoading(true);
const response = await storeService.getMyItems();
setItems(response.items || []);
} catch (error) {
logger.error('Load my listings error:', error);
} finally {
setLoading(false);
}
};
const handleDelete = async (itemId: string) => {
Alert.alert(
'Delete Item',
'Are you sure you want to delete this listing?',
[
{ text: 'Cancel', style: 'cancel' },
{
text: 'Delete',
style: 'destructive',
onPress: async () => {
try {
await storeService.deleteItem(itemId);
setItems((prev) => prev.filter((item) => item.id !== itemId));
Alert.alert('Success', 'Item deleted successfully');
} catch (error) {
logger.error('Delete item error:', error);
Alert.alert('Error', 'Failed to delete item');
}
},
},
]
);
};
const renderItem = ({ item }: { item: any }) => (
<TouchableOpacity
style={styles.itemCard}
onPress={() => router.push(`/store/item/${item.id}`)}
>
{item.images && item.images.length > 0 && (
<Image source={{ uri: item.images[0] }} style={styles.itemImage} />
)}
<View style={styles.itemInfo}>
<Text style={styles.itemTitle}>{item.title}</Text>
<Text style={styles.itemPrice}>${item.price}</Text>
<View style={styles.itemStats}>
<Text style={styles.statText}>Sales: {item.salesCount || 0}</Text>
<Text style={styles.statText}>⭐ {item.rating || '0.0'}</Text>
</View>
<View style={styles.itemStatus}>
<View
style={[
styles.statusBadge,
item.isActive ? styles.activeBadge : styles.inactiveBadge,
]}
>
<Text style={styles.statusText}>
{item.isActive ? 'Active' : 'Inactive'}
</Text>
</View>
</View>
</View>
<View style={styles.itemActions}>
<TouchableOpacity
style={styles.editButton}
onPress={() => router.push(`/store/item/${item.id}/edit`)}
>
<Icon name="edit" size={20} color={Colors.accent} />
</TouchableOpacity>
<TouchableOpacity
style={styles.deleteButton}
onPress={() => handleDelete(item.id)}
>
<Icon name="delete" size={20} color={Colors.error || '#ff4444'} />
</TouchableOpacity>
</View>
</TouchableOpacity>
);
if (loading) {
return (
<View style={styles.container}>
<Header title="My Listings" />
<LoadingSpinner fullScreen />
</View>
);
}
return (
<View style={styles.container}>
<Header
title="My Listings"
rightIcon="add"
onRightPress={() => router.push('/store/sell')}
/>
{items.length > 0 ? (
<FlatList
data={items}
renderItem={renderItem}
keyExtractor={(item) => item.id}
contentContainerStyle={styles.listContent}
/>
) : (
<EmptyState
title="No listings yet"
message="Start selling your projects and code!"
icon="🛒"
/>
)}
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: Colors.background,
},
listContent: {
padding: 16,
},
itemCard: {
flexDirection: 'row',
backgroundColor: Colors.surface,
borderRadius: 12,
padding: 12,
marginBottom: 12,
gap: 12,
},
itemImage: {
width: 80,
height: 80,
borderRadius: 8,
},
itemInfo: {
flex: 1,
},
itemTitle: {
fontSize: 16,
fontWeight: '600',
color: Colors.text,
marginBottom: 4,
},
itemPrice: {
fontSize: 18,
fontWeight: 'bold',
color: Colors.accent,
marginBottom: 8,
},
itemStats: {
flexDirection: 'row',
gap: 16,
marginBottom: 8,
},
statText: {
fontSize: 12,
color: Colors.textSecondary,
},
itemStatus: {
marginTop: 4,
},
statusBadge: {
alignSelf: 'flex-start',
paddingHorizontal: 8,
paddingVertical: 4,
borderRadius: 4,
},
activeBadge: {
backgroundColor: '#4caf50',
},
inactiveBadge: {
backgroundColor: Colors.textSecondary,
},
statusText: {
fontSize: 12,
fontWeight: '600',
color: Colors.text,
},
itemActions: {
justifyContent: 'space-between',
paddingVertical: 4,
},
editButton: {
padding: 8,
},
deleteButton: {
padding: 8,
},
});