Mejoras en solicitud de servicios y registro de proveedores

- Actualizar API key de Google Maps
- Corregir búsqueda de categorías en dashboard (ionInput + ev.detail.value)
- Limitar solicitud de servicios a máximo 2 días de anticipación
- Agregar validación de fecha y hora antes de crear postulación
- Corregir visualización de categorías en registro de héroe
- Agregar traducción select_date_time

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
CarlosTorres
2026-01-27 04:08:01 +00:00
parent 103f7f45a0
commit e7ad9e1d26
8 changed files with 40 additions and 18 deletions

View File

@@ -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;

View File

@@ -29,8 +29,8 @@ ion-item:active:after {
<ion-content padding>
<div class="autocomplete">
<ion-searchbar
(ionChange)="search($event)"
debounce=500
(ionInput)="search($event)"
debounce="300"
placeholder="{{'dashboard.searchbox_placeholder' | translate}}">
</ion-searchbar>
<ion-list *ngIf="showList">

View File

@@ -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

View File

@@ -19,7 +19,7 @@
<ion-item>
<ion-label>{{'hero.categories' | translate}}</ion-label>
<ion-select [(ngModel)]="categories_input" multiple="true" okText="Aceptar" cancelText="Cancelar" placeholder="{{'hero.categories_placeholder' | translate}}">
<ion-select-option *ngFor="let category of categories" [value]="category.value">{{category.display}}</ion-select-option>
<ion-select-option *ngFor="let category of categories" [value]="category">{{category}}</ion-select-option>
</ion-select>
</ion-item>
<br>