feat: Implement document management features

- Added a new DocumentsScreen for managing user documents with search and date filtering capabilities.
- Created AddDocumentModal for uploading documents with file selection and custom title options.
- Introduced SiteDocumentsScreen to display documents related to specific construction sites.
- Implemented SitesScreen for listing construction sites with search functionality.
- Updated ProfileScreen to link to the new DocumentsScreen.
- Refactored RangePickerModal for selecting date ranges in document filtering.
- Improved date formatting utilities for better timestamp handling.
- Added necessary API calls for document and site management.
- Updated types to reflect changes in document structure and site information.
- Added expo-document-picker dependency for document selection functionality.
This commit is contained in:
2025-12-17 18:03:54 +01:00
parent ef88c518d1
commit 6e5b9cde68
15 changed files with 731 additions and 93 deletions

View File

@ -1,16 +1,6 @@
import React, { useState, useContext } from 'react';
import { Eye, EyeOff, Lock, LogIn, Mail } from 'lucide-react-native';
import {
KeyboardAvoidingView,
Platform,
ScrollView,
Text,
TextInput,
TouchableOpacity,
View,
Image,
Alert
} from 'react-native';
import { KeyboardAvoidingView, Platform, ScrollView, Text, TextInput, TouchableOpacity, View, Image, Alert } from 'react-native';
import { AuthContext } from '@/utils/authContext';
import api from '@/utils/api';
@ -21,6 +11,7 @@ export default function LoginScreen() {
const [showPassword, setShowPassword] = useState(false);
const [isLoading, setIsLoading] = useState(false);
// TODO: Riscrivere funzione per migliorare leggibilità e gestione errori
const handleLogin = async () => {
// TODO: Implementa toast o messaggio di errore più user-friendly
if (!username || !password) {
@ -31,9 +22,10 @@ export default function LoginScreen() {
setIsLoading(true);
try {
console.log("Tentativo login con:", username);
username.trim();
password.trim();
// Chiamata vera al backend
// Esegui richiesta di login
const response = await api.post("/user/login", {
username: username,
password: password
@ -46,10 +38,8 @@ export default function LoginScreen() {
// Passiamo token e dati utente al context che gestirà salvataggio e redirect
authContext.logIn(token, user);
} catch (error: any) {
console.error("Login Error:", error);
let message = "Si è verificato un errore durante l'accesso.";
if (error.response) {