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:
@ -39,3 +39,37 @@ export const formatPickerDate = (d: DateType | null | undefined) => {
|
||||
|
||||
return `${yyyy}-${mm}-${dd}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Trasforma un timestamp in stringa "DD/MM/YYYY HH:mm:ss"
|
||||
* @param timestamp stringa o oggetto Date
|
||||
* @returns stringa formattata oppure vuota se input non valido
|
||||
*/
|
||||
export const formatTimestamp = (timestamp: string | Date | null | undefined): string => {
|
||||
if (!timestamp) return '';
|
||||
|
||||
const date = timestamp instanceof Date ? timestamp : new Date(timestamp);
|
||||
if (isNaN(date.getTime())) return '';
|
||||
|
||||
const dd = String(date.getDate()).padStart(2, '0');
|
||||
const mm = String(date.getMonth() + 1).padStart(2, '0'); // mesi da 0 a 11
|
||||
const yyyy = date.getFullYear();
|
||||
|
||||
const hh = String(date.getHours()).padStart(2, '0');
|
||||
const min = String(date.getMinutes()).padStart(2, '0');
|
||||
const ss = String(date.getSeconds()).padStart(2, '0');
|
||||
|
||||
return `${dd}/${mm}/${yyyy} ${hh}:${min}:${ss}`;
|
||||
};
|
||||
|
||||
/**
|
||||
* Converte un timestamp ISO in oggetto Date
|
||||
* @param dateStr stringa data in formato ISO
|
||||
* @returns oggetto Date corrispondente
|
||||
*/
|
||||
export const parseTimestamp = (dateStr: string | undefined | null): Date => {
|
||||
if (!dateStr) return new Date();
|
||||
const date = new Date(dateStr);
|
||||
if (isNaN(date.getTime())) return new Date();
|
||||
return date;
|
||||
};
|
||||
Reference in New Issue
Block a user