Dockerized everything and added CI/CD deployment

This commit is contained in:
c-d-p
2025-04-22 22:54:31 +02:00
parent bf147af3ef
commit 02d191853b
17 changed files with 434 additions and 71 deletions

View File

@@ -1,13 +1,18 @@
import React, { useState } from 'react';
import { View, StyleSheet } from 'react-native';
import { Button, Checkbox, Text, ActivityIndicator, Snackbar } from 'react-native-paper';
import { clearDatabase } from '../api/admin'; // Revert to standard import without extension
import { clearDatabase } from '../api/admin';
// Remove useNavigation import if no longer needed elsewhere in this file
// import { useNavigation } from '@react-navigation/native';
import { useAuth } from '../contexts/AuthContext'; // Import useAuth
const AdminScreen = () => {
const [isHardClear, setIsHardClear] = useState(false);
const [isLoading, setIsLoading] = useState(false);
const [snackbarVisible, setSnackbarVisible] = useState(false);
const [snackbarMessage, setSnackbarMessage] = useState('');
// const navigation = useNavigation(); // Remove if not used elsewhere
const { logout } = useAuth(); // Get the logout function from context
const handleClearDb = async () => {
setIsLoading(true);
@@ -16,12 +21,25 @@ const AdminScreen = () => {
const response = await clearDatabase(isHardClear);
setSnackbarMessage(response.message || 'Database cleared successfully.');
setSnackbarVisible(true);
// If hard clear was successful, trigger the logout process from AuthContext
if (isHardClear) {
console.log('Hard clear successful, calling logout...');
await logout(); // Call the logout function from AuthContext
// The RootNavigator will automatically switch to the AuthFlow
// No need to manually navigate or set loading to false here
return; // Exit early
}
} catch (error: any) {
console.error("Error clearing database:", error);
setSnackbarMessage(error.response?.data?.detail || 'Failed to clear database.');
setSnackbarVisible(true);
} finally {
setIsLoading(false);
// Only set loading to false if it wasn't a hard clear (as logout handles navigation)
if (!isHardClear) {
setIsLoading(false);
}
}
};
@@ -78,4 +96,4 @@ const styles = StyleSheet.create({
},
});
export default AdminScreen;
export default AdminScreen;