caelum0x f80b04ae0f feat(ritgram): move GitGram app into railyard as Ritgram, next to Rithub
Moved later/gitgram-ai/gitgram/ to apps/ritgram/ (fresh history; full history stays in caelum0x/gitgram).
AITimeMachine stays separate in later/gitgram-ai per the Rithub master plan.
Logs, pid files and env files are ignored; GPL-3.0 mobile/proximity noted in THIRD_PARTY_NOTICES.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-11-13 04:18:46 +03:00

145 lines
3.5 KiB
TypeScript

import React, { useState } from 'react';
import {
View,
Text,
StyleSheet,
TouchableOpacity,
Alert,
} from 'react-native';
import { useLocalSearchParams, useRouter } from 'expo-router';
import { Colors } from '../../../constants/Colors';
import Header from '../../../components/navigation/Header';
import { postService } from '../../../services/postService';
import { logger } from '../../../utils/logger';
import Icon from 'react-native-vector-icons/MaterialIcons';
export default function PostDeleteScreen() {
const { id } = useLocalSearchParams<{ id: string }>();
const router = useRouter();
const [loading, setLoading] = useState(false);
const handleDelete = () => {
Alert.alert(
'Delete Post',
'Are you sure you want to delete this post? This action cannot be undone.',
[
{
text: 'Cancel',
style: 'cancel',
},
{
text: 'Delete',
style: 'destructive',
onPress: confirmDelete,
},
]
);
};
const confirmDelete = async () => {
setLoading(true);
try {
await postService.deletePost(id!);
Alert.alert('Success', 'Post deleted successfully', [
{
text: 'OK',
onPress: () => router.back(),
},
]);
} catch (error: any) {
logger.error('Delete post error:', error);
Alert.alert('Error', error.response?.data?.error || 'Failed to delete post');
} finally {
setLoading(false);
}
};
return (
<View style={styles.container}>
<Header title="Delete Post" />
<View style={styles.content}>
<Icon name="delete-outline" size={64} color={Colors.error || '#ff4444'} style={styles.icon} />
<Text style={styles.title}>Delete Post?</Text>
<Text style={styles.description}>
This will permanently delete your post. This action cannot be undone.
</Text>
<TouchableOpacity
style={[styles.deleteButton, loading && styles.buttonDisabled]}
onPress={handleDelete}
disabled={loading}
>
<Text style={styles.deleteButtonText}>
{loading ? 'Deleting...' : 'Delete Post'}
</Text>
</TouchableOpacity>
<TouchableOpacity
style={styles.cancelButton}
onPress={() => router.back()}
disabled={loading}
>
<Text style={styles.cancelButtonText}>Cancel</Text>
</TouchableOpacity>
</View>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: Colors.background,
},
content: {
flex: 1,
padding: 20,
justifyContent: 'center',
alignItems: 'center',
},
icon: {
marginBottom: 24,
},
title: {
fontSize: 24,
fontWeight: '600',
color: Colors.text,
marginBottom: 12,
textAlign: 'center',
},
description: {
fontSize: 16,
color: Colors.textSecondary,
textAlign: 'center',
marginBottom: 32,
paddingHorizontal: 20,
},
deleteButton: {
backgroundColor: Colors.error || '#ff4444',
borderRadius: 8,
padding: 16,
alignItems: 'center',
width: '100%',
marginBottom: 12,
},
buttonDisabled: {
opacity: 0.6,
},
deleteButtonText: {
color: Colors.text,
fontSize: 16,
fontWeight: '600',
},
cancelButton: {
padding: 16,
alignItems: 'center',
width: '100%',
},
cancelButtonText: {
color: Colors.textSecondary,
fontSize: 16,
fontWeight: '600',
},
});