Skip to content

Commit c564c58

Browse files
committed
agregar validaciones y utils
1 parent 958adea commit c564c58

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed

frontend/utils/constants.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
export const API_ENDPOINTS = {
2+
SEISMIC: '/api/simulate/seismic',
3+
TSUNAMI: '/api/simulate/tsunami',
4+
HEALTH: '/api/health'
5+
};
6+
7+
export const MAP_DEFAULTS = {
8+
CENTER_LAT: 0,
9+
CENTER_LON: 0,
10+
ZOOM: 2
11+
};
12+
13+
export const SIMULATION_LIMITS = {
14+
MAX_MAGNITUDE: 10,
15+
MIN_MAGNITUDE: 0,
16+
MAX_DEPTH: 1000,
17+
MIN_DEPTH: 0
18+
};

frontend/utils/formatters.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
export const formatNumber = (num: number, decimals: number = 2): string => {
2+
return num.toFixed(decimals);
3+
};
4+
5+
export const formatDate = (date: Date): string => {
6+
return date.toLocaleDateString('es-ES');
7+
};
8+
9+
export const formatCoordinates = (lat: number, lon: number): string => {
10+
return `${formatNumber(lat)}°, ${formatNumber(lon)}°`;
11+
};

frontend/utils/validation.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
export const validateLatitude = (lat: number): boolean => {
2+
return lat >= -90 && lat <= 90;
3+
};
4+
5+
export const validateLongitude = (lon: number): boolean => {
6+
return lon >= -180 && lon <= 180;
7+
};
8+
9+
export const validateMagnitude = (mag: number): boolean => {
10+
return mag >= 0 && mag <= 10;
11+
};
12+
13+
export const validateDepth = (depth: number): boolean => {
14+
return depth >= 0 && depth <= 1000;
15+
};

0 commit comments

Comments
 (0)