feat: add and enhance PermitsScreen and RequestPermitModal

- add LoadingScreen component
- update utilities
This commit is contained in:
2025-12-15 17:20:57 +01:00
parent b9807f6cc2
commit ef88c518d1
9 changed files with 166 additions and 122 deletions

View File

@ -1,3 +1,5 @@
import { DateType } from "react-native-ui-datepicker";
/**
* Trasforma una data da "YYYY-MM-DD" a "DD/MM/YYYY"
* @param dateStr stringa data in formato ISO "YYYY-MM-DD"
@ -19,3 +21,21 @@ export const formatTime = (timeStr: string | null | undefined): string => {
const [hours, minutes] = timeStr.split(':');
return `${hours}:${minutes}`;
};
/**
* Formatta una data per l'uso con un date picker, normalizzandola a mezzanotte
* @param d Data in formato DateType
* @returns stringa data in formato "YYYY-MM-DD" o null se l'input è null/undefined
*/
export const formatPickerDate = (d: DateType | null | undefined) => {
if (!d) return null;
const date = new Date(d as string | number | Date);
const normalized = new Date(date.getFullYear(), date.getMonth(), date.getDate());
const yyyy = normalized.getFullYear();
const mm = String(normalized.getMonth() + 1).padStart(2, "0");
const dd = String(normalized.getDate()).padStart(2, "0");
return `${yyyy}-${mm}-${dd}`;
}