diff --git a/capacitor.config.ts b/capacitor.config.ts index 9e798d3..2895ab8 100755 --- a/capacitor.config.ts +++ b/capacitor.config.ts @@ -23,8 +23,8 @@ const config: CapacitorConfig = { SplashShowOnlyFirstTime: 'false', SplashScreen: 'screen', SplashScreenDelay: '3000', - GOOGLE_MAPS_ANDROID_API_KEY: 'AIzaSyBmkTsg0-1VKllM_vHD6V1EhPnF0YUP-88', - GOOGLE_MAPS_IOS_API_KEY: 'AIzaSyBmkTsg0-1VKllM_vHD6V1EhPnF0YUP-88' + GOOGLE_MAPS_ANDROID_API_KEY: 'AIzaSyC_1FWK6tQ7VTPRJLxf2Mn2DEo3E28UF3k', + GOOGLE_MAPS_IOS_API_KEY: 'AIzaSyC_1FWK6tQ7VTPRJLxf2Mn2DEo3E28UF3k' } } }; diff --git a/src/app/pages/category/category.page.ts b/src/app/pages/category/category.page.ts index 96b3815..17f2b5e 100755 --- a/src/app/pages/category/category.page.ts +++ b/src/app/pages/category/category.page.ts @@ -60,11 +60,10 @@ export class CategoryPage implements OnInit { }); this.getCurrentLocation(); console.log(this.minyear); - if (new Date().getMonth() == 11) { - this.maxyear = ((new Date().getFullYear()+1) + '-' + '01' + '-' + (new Date().getDate() < 10 ? '0' : '') + new Date().getDate()).toString(); - } else { - this.maxyear = (new Date().getFullYear() + '-' + ((new Date().getMonth() + 2) < 10 ? '0' : '') + (new Date().getMonth() + 2) +'-' + (new Date().getDate() < 10 ? '0' : '') + new Date().getDate()).toString(); - } + // Máximo 2 días de anticipación + const maxDate = new Date(); + maxDate.setDate(maxDate.getDate() + 2); + this.maxyear = maxDate.toISOString().slice(0, 10); console.log(this.maxyear); } @@ -160,13 +159,34 @@ export class CategoryPage implements OnInit { } addpostulation() { + // Validar que fecha y hora estén seleccionadas + if (!this.setDate || !this.setHour) { + this.alertService.presentToast(this.translateService.instant('alerts.select_date_time') || 'Selecciona fecha y hora'); + return; + } + + // Calcular diferencia de fecha directamente + const today = new Date(); + today.setHours(0, 0, 0, 0); + const selectedDate = new Date(this.setDate); + selectedDate.setHours(0, 0, 0, 0); + this.differenceDate = selectedDate.getTime() - today.getTime(); + + // Calcular diferencia de hora this.differenceHour = (new Date(this.setHour).getTime() - new Date().getTime()); - console.log(this.differenceHour); - console.log("mintime:" + this.mintime * 3600000); - console.log("maxtime:" + this.maxtime * 3600000) + + console.log("differenceDate:", this.differenceDate); + console.log("differenceHour:", this.differenceHour); + console.log("mintime:", this.mintime * 3600000); + + // Máximo 2 días de anticipación (172800000 ms = 2 días) + const maxDays = 2 * 24 * 60 * 60 * 1000; + console.log("maxDays:", maxDays); + + // Validación de tiempo mínimo (mismo día y menos de mintime horas) if (this.differenceDate < 86400000 && this.differenceHour < (this.mintime * 3600000)) { this.alertService.presentToast(this.translateService.instant('alerts.categories_mintime')); - } else if (this.differenceDate <= (this.maxtime * 3600000)) { + } else if (this.differenceDate <= maxDays) { if (this.myAddress && this.myPosition.latitude && this.myPosition.longitude) { this.loadingCtrl.create().then((overlay) => { this.loading = overlay; diff --git a/src/app/pages/dashboard/dashboard.page.html b/src/app/pages/dashboard/dashboard.page.html index efd4fe6..59bfaf1 100755 --- a/src/app/pages/dashboard/dashboard.page.html +++ b/src/app/pages/dashboard/dashboard.page.html @@ -29,8 +29,8 @@ ion-item:active:after {
diff --git a/src/app/pages/dashboard/dashboard.page.ts b/src/app/pages/dashboard/dashboard.page.ts index cfd7aff..46c8d08 100755 --- a/src/app/pages/dashboard/dashboard.page.ts +++ b/src/app/pages/dashboard/dashboard.page.ts @@ -157,14 +157,14 @@ export class DashboardPage implements OnInit { this.categories = this.aux_categories; console.log(ev); - let val = ev.target.value; + let val = ev.detail.value || ev.target.value; // if the value is an empty string don't filter the items if (val && val.trim() != '') { // Filter the items - this.categories = this.categories.filter((categories) => { - return (categories.toLowerCase().indexOf(val.toLowerCase()) > -1); + this.categories = this.categories.filter((category) => { + return (category.toLowerCase().indexOf(val.toLowerCase()) > -1); }); // Show the results diff --git a/src/app/pages/hero/hero.page.html b/src/app/pages/hero/hero.page.html index 7576116..2de7fba 100755 --- a/src/app/pages/hero/hero.page.html +++ b/src/app/pages/hero/hero.page.html @@ -19,7 +19,7 @@ {{'hero.categories' | translate}} - {{category.display}} + {{category}}
diff --git a/src/assets/i18n/en.json b/src/assets/i18n/en.json index 7f323f5..aea19fb 100755 --- a/src/assets/i18n/en.json +++ b/src/assets/i18n/en.json @@ -188,6 +188,7 @@ "categories_mintime": "Services must be requested at least 2 hours in advance", "no_provider": "There are no heroes available in the area", "valid_address": "Enter a valid address", + "select_date_time": "Select date and time for the service", "categories_maxtime": "Services must be requested with a maximum of 2 days in advance", "categories_success": "Requested service, wait for a hero to apply to the postulation", "error": "Please contact technical support, Status:", diff --git a/src/assets/i18n/es.json b/src/assets/i18n/es.json index 49a5fa7..66ad6cf 100755 --- a/src/assets/i18n/es.json +++ b/src/assets/i18n/es.json @@ -188,6 +188,7 @@ "categories_mintime": "Los servicios deben solicitarse con mínimo 2 horas de anticipación", "no_provider": "No hay Heroes disponibles por la zona", "valid_address": "Ingrese una dirección válida", + "select_date_time": "Selecciona fecha y hora del servicio", "categories_maxtime": "Los servicios deben solicitarse con máximo 2 días de anticipación", "categories_success": "Servicio solicitado, espere a que un Heroe se postule", "error": "Por favor contacte a soporte técnico, Estatus:", diff --git a/src/index.html b/src/index.html index 6237f61..3d3a227 100755 --- a/src/index.html +++ b/src/index.html @@ -7,7 +7,7 @@ - +