feat: Update assets and improve code comments across multiple components
- Updated favicon and various image assets. - Enhanced comments. - Adjusted styles and functionality in several components for improved user experience. - Updated package-lock.json to reflect dependency updates.
This commit is contained in:
@@ -11,6 +11,7 @@ import dayjs from 'dayjs';
|
||||
import { formatTimestamp, parseTimestamp } from '@/utils/dateTime';
|
||||
import { downloadAndShareDocument, uploadDocument } from '@/utils/documentUtils';
|
||||
import AddDocumentModal from '@/components/AddDocumentModal';
|
||||
import { SafeAreaView } from 'react-native-safe-area-context';
|
||||
|
||||
export default function SiteDocumentsScreen() {
|
||||
const router = useRouter();
|
||||
@@ -24,12 +25,12 @@ export default function SiteDocumentsScreen() {
|
||||
const [showUploadModal, setShowUploadModal] = useState(false);
|
||||
const [isUploading, setIsUploading] = useState(false);
|
||||
|
||||
// Fetch dei documenti del cantiere
|
||||
// Fetch site documents
|
||||
const fetchSiteDocuments = useCallback(async (siteId: number, isRefreshing = false) => {
|
||||
try {
|
||||
if (!isRefreshing) setIsLoading(true);
|
||||
|
||||
// Fetch Documenti
|
||||
// Fetch Documents
|
||||
const response = await api.get(`/attachment/get-site-attachments`, {
|
||||
params: { siteId }
|
||||
});
|
||||
@@ -74,13 +75,13 @@ export default function SiteDocumentsScreen() {
|
||||
});
|
||||
const [showRangePicker, setShowRangePicker] = useState(false);
|
||||
|
||||
// Filtraggio Documenti
|
||||
// Filter documents based on search term and date range
|
||||
const filteredDocs = documents.filter(doc => {
|
||||
// Filtro Testuale (su nome documento)
|
||||
// Textual Filter (on document name)
|
||||
const matchesSearch = doc.title.toLowerCase().includes(searchTerm.toLowerCase());
|
||||
if (!matchesSearch) return false;
|
||||
|
||||
// Filtro Date Range
|
||||
// Date Range Filter
|
||||
if (range.startDate || range.endDate) {
|
||||
const docDate = parseTimestamp(doc.updated_at);
|
||||
if (range.startDate) {
|
||||
@@ -95,7 +96,7 @@ export default function SiteDocumentsScreen() {
|
||||
return true;
|
||||
});
|
||||
|
||||
// Gestione Download e Condivisione Documento
|
||||
// Handle Document Download and Share
|
||||
const handleDownloadAndShare = async (mimetype: string, fileName: string, fileUrl: string) => {
|
||||
try {
|
||||
await downloadAndShareDocument(mimetype, fileName, fileUrl);
|
||||
@@ -105,7 +106,7 @@ export default function SiteDocumentsScreen() {
|
||||
}
|
||||
};
|
||||
|
||||
// Gestione Caricamento Documento
|
||||
// Handle Document Upload
|
||||
const handleUploadDocument = async (file: any, customTitle?: string) => {
|
||||
setIsUploading(true);
|
||||
try {
|
||||
@@ -130,36 +131,40 @@ export default function SiteDocumentsScreen() {
|
||||
return (
|
||||
<View className="flex-1 bg-gray-50">
|
||||
{/* Header */}
|
||||
<View className="bg-white p-6 pt-16 shadow-sm border-b border-gray-100 flex-row items-center gap-4">
|
||||
<TouchableOpacity onPress={() => router.back()} className="p-2 -ml-2 rounded-full active:bg-gray-100">
|
||||
<ChevronLeft size={28} color="#4b5563" />
|
||||
</TouchableOpacity>
|
||||
<View className="bg-white px-4 pb-6 shadow-sm border-b border-gray-100">
|
||||
<SafeAreaView edges={['top']} className='pt-4'>
|
||||
<View className='flex-row items-center gap-4'>
|
||||
<TouchableOpacity onPress={() => router.back()} className="p-2 -ml-2 rounded-full active:bg-gray-100">
|
||||
<ChevronLeft size={28} color="#4b5563" />
|
||||
</TouchableOpacity>
|
||||
|
||||
<View className="flex-1">
|
||||
{/* Badge Codice Cantiere */}
|
||||
{site.code && (
|
||||
<View className="self-start bg-[#E6F4F4] px-2 py-0.5 rounded mb-1 border border-[#099499]/20">
|
||||
<Text className="text-base font-bold text-[#099499]">
|
||||
{site.code}
|
||||
<View className="flex-1">
|
||||
{/* Site Code Badge */}
|
||||
{site.code && (
|
||||
<View className="self-start bg-[#E6F4F4] px-2 py-0.5 rounded mb-1 border border-[#099499]/20">
|
||||
<Text className="text-base font-bold text-[#099499]">
|
||||
{site.code}
|
||||
</Text>
|
||||
</View>
|
||||
)}
|
||||
|
||||
{/* Site Name with Truncate */}
|
||||
<Text
|
||||
className="text-xl font-bold text-gray-800 leading-tight"
|
||||
numberOfLines={1}
|
||||
ellipsizeMode="tail"
|
||||
>
|
||||
{site.name}
|
||||
</Text>
|
||||
|
||||
<Text className="text-sm text-gray-500 mt-0.5">Archivio documenti</Text>
|
||||
</View>
|
||||
)}
|
||||
|
||||
{/* Nome Cantiere con Truncate funzionante */}
|
||||
<Text
|
||||
className="text-xl font-bold text-gray-800 leading-tight"
|
||||
numberOfLines={1}
|
||||
ellipsizeMode="tail"
|
||||
>
|
||||
{site.name}
|
||||
</Text>
|
||||
|
||||
<Text className="text-sm text-gray-500 mt-0.5">Archivio documenti</Text>
|
||||
</View>
|
||||
</View>
|
||||
</SafeAreaView>
|
||||
</View>
|
||||
|
||||
<View className="p-5 gap-6 flex-1">
|
||||
{/* Search + Date Row (Spostato qui) */}
|
||||
{/* Search + Date Row */}
|
||||
<View className="flex-row gap-2">
|
||||
<View className="flex-1 relative justify-center">
|
||||
<View className="absolute left-4 z-10">
|
||||
@@ -189,7 +194,7 @@ export default function SiteDocumentsScreen() {
|
||||
onApply={setRange}
|
||||
/>
|
||||
|
||||
{/* Lista Documenti */}
|
||||
{/* Documents List */}
|
||||
<ScrollView
|
||||
contentContainerStyle={{ gap: 16, paddingBottom: 100 }}
|
||||
showsVerticalScrollIndicator={false}
|
||||
@@ -222,7 +227,7 @@ export default function SiteDocumentsScreen() {
|
||||
</ScrollView>
|
||||
</View>
|
||||
|
||||
{/* FAB (Spostato qui) */}
|
||||
{/* FAB */}
|
||||
<TouchableOpacity
|
||||
onPress={() => setShowUploadModal(true)}
|
||||
className="absolute bottom-8 right-6 w-16 h-16 bg-[#099499] rounded-full shadow-lg items-center justify-center active:scale-90"
|
||||
@@ -230,13 +235,13 @@ export default function SiteDocumentsScreen() {
|
||||
<Plus size={32} color="white" />
|
||||
</TouchableOpacity>
|
||||
|
||||
{/* Modale Caricamento Documento */}
|
||||
{/* Upload Document Modal */}
|
||||
<AddDocumentModal
|
||||
visible={showUploadModal}
|
||||
onClose={() => setShowUploadModal(false)}
|
||||
onUpload={handleUploadDocument}
|
||||
isUploading={isUploading}
|
||||
/>
|
||||
</View>
|
||||
</View >
|
||||
);
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import api from '@/utils/api';
|
||||
import LoadingScreen from '@/components/LoadingScreen';
|
||||
import { ConstructionSite } from '@/types/types';
|
||||
import { useAlert } from '@/components/AlertComponent';
|
||||
import { SafeAreaView } from 'react-native-safe-area-context';
|
||||
|
||||
export default function SitesScreen() {
|
||||
const [searchTerm, setSearchTerm] = useState('');
|
||||
@@ -15,12 +16,12 @@ export default function SitesScreen() {
|
||||
const router = useRouter();
|
||||
const alert = useAlert();
|
||||
|
||||
// Fetch cantieri e documenti
|
||||
// Fetch sites and documents
|
||||
const fetchConstructionSites = async () => {
|
||||
try {
|
||||
if (!refreshing) setIsLoading(true);
|
||||
|
||||
// Fetch Cantieri
|
||||
// Fetch Sites and their attachments count
|
||||
const response = await api.get('/construction-site/sites-attachments');
|
||||
setConstructionSites(response.data);
|
||||
} catch (error) {
|
||||
@@ -41,7 +42,7 @@ export default function SitesScreen() {
|
||||
fetchConstructionSites();
|
||||
};
|
||||
|
||||
// Filtriamo i cantieri in base alla ricerca
|
||||
// Filter sites based on search term
|
||||
const filteredSites = constructionSites.filter(site =>
|
||||
site.name.toLowerCase().includes(searchTerm.toLowerCase()) ||
|
||||
site.code.toLowerCase().includes(searchTerm.toLowerCase())
|
||||
@@ -54,9 +55,11 @@ export default function SitesScreen() {
|
||||
return (
|
||||
<View className="flex-1 bg-gray-50">
|
||||
{/* Header */}
|
||||
<View className="bg-white p-6 pt-16 shadow-sm border-b border-gray-100">
|
||||
<Text className="text-3xl font-bold text-gray-800 mb-1">Cantieri</Text>
|
||||
<Text className="text-base text-gray-500">Seleziona un cantiere per vedere i documenti</Text>
|
||||
<View className="bg-white px-6 pb-6 shadow-sm border-b border-gray-100">
|
||||
<SafeAreaView edges={['top']} className='pt-4'>
|
||||
<Text className="text-3xl font-bold text-gray-800 mb-1">Cantieri</Text>
|
||||
<Text className="text-base text-gray-500">Seleziona un cantiere per vedere i documenti</Text>
|
||||
</SafeAreaView>
|
||||
</View>
|
||||
|
||||
<View className="px-5 mt-5 gap-6 flex-1">
|
||||
@@ -74,11 +77,10 @@ export default function SitesScreen() {
|
||||
/>
|
||||
</View>
|
||||
|
||||
{/* Lista Cantieri */}
|
||||
{/* TODO: Rimuovere lo ScrollIndicator? */}
|
||||
{/* Sites List */}
|
||||
<ScrollView
|
||||
contentContainerStyle={{ gap: 16, paddingBottom: 40 }}
|
||||
showsVerticalScrollIndicator={true}
|
||||
showsVerticalScrollIndicator={false}
|
||||
refreshControl={
|
||||
<RefreshControl refreshing={refreshing} onRefresh={onRefresh} colors={['#099499']} />
|
||||
}
|
||||
@@ -88,8 +90,8 @@ export default function SitesScreen() {
|
||||
key={index}
|
||||
onPress={() => router.push({
|
||||
pathname: '/(protected)/sites/[id]',
|
||||
params: {
|
||||
id: site.id ,
|
||||
params: {
|
||||
id: site.id,
|
||||
siteData: JSON.stringify(site),
|
||||
}
|
||||
})}
|
||||
@@ -111,7 +113,6 @@ export default function SitesScreen() {
|
||||
</View>
|
||||
</View>
|
||||
|
||||
{/* Freccia al posto del download */}
|
||||
<ChevronRight size={24} color="#9ca3af" />
|
||||
</TouchableOpacity>
|
||||
))}
|
||||
|
||||
Reference in New Issue
Block a user