First commit of the new app
This commit is contained in:
30
assets/components/reserva/formatters.ts
Normal file
30
assets/components/reserva/formatters.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { API_BASE_URL } from '@/assets/config/api';
|
||||
|
||||
export const formatDateShort = (dateString: string) => {
|
||||
if (!dateString) return '';
|
||||
const d = new Date(dateString);
|
||||
if (Number.isNaN(d.getTime())) return dateString;
|
||||
return d.toLocaleDateString('pt-PT');
|
||||
};
|
||||
|
||||
export const formatDateLong = (dateString: string) => {
|
||||
if (!dateString) return '';
|
||||
const d = new Date(dateString);
|
||||
if (Number.isNaN(d.getTime())) return dateString;
|
||||
return d.toLocaleDateString('pt-PT', {
|
||||
day: '2-digit',
|
||||
month: 'short',
|
||||
year: 'numeric',
|
||||
});
|
||||
};
|
||||
|
||||
export const formatCurrency = (value: string) =>
|
||||
`${parseFloat(value || '0').toFixed(0)} EUR`;
|
||||
|
||||
export const getImageUrl = (path?: string) => {
|
||||
if (!path) return '';
|
||||
if (path.startsWith('http')) return path;
|
||||
const baseUrl = API_BASE_URL.replace(/\/pt\/app$/, '');
|
||||
const imagePath = path.startsWith('/') ? path : `/${path}`;
|
||||
return `${baseUrl}${imagePath}`;
|
||||
};
|
||||
Reference in New Issue
Block a user