Compare commits

...

2 Commits

Author SHA1 Message Date
aa8b0061c9 feat: Actualización general de la aplicación
- Contratos, tarjetas, postulaciones, categorías y reportes
- Servicios: auth, ichamba, env, language, firebase, interceptor
- Guards, modelos, componentes y páginas de verificación
- Configuración: angular.json, tsconfig, polyfills, environments
- Capacitor: capacitor.config.json y android settings

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-17 08:18:40 -06:00
db0d0001fa feat: Side menu dinámico, login social y traducciones hero
- app.component: menú lateral con roles de usuario, ChangeDetectorRef
  para re-render tras login, integración OneSignal al iniciar sesión
- auth/login: botones Google y Apple con estilos, navegación corregida
- auth/register y forgot: mejoras de UX y navegación
- landing: sombra en botones del footer
- i18n: claves hero (select, bank, bank_account, fee, required) en es/en

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-17 08:18:12 -06:00
77 changed files with 13812 additions and 9896 deletions

View File

@@ -9,7 +9,6 @@ android {
apply from: "../capacitor-cordova-android-plugins/cordova.variables.gradle"
dependencies {
implementation project(':capacitor-community-facebook-login')
implementation project(':capacitor-community-http')
implementation project(':capacitor-app')
implementation project(':capacitor-browser')
@@ -21,9 +20,7 @@ dependencies {
implementation project(':capacitor-preferences')
implementation project(':capacitor-splash-screen')
implementation project(':capacitor-status-bar')
implementation project(':codetrix-studio-capacitor-google-auth')
implementation "com.onesignal:OneSignal:5.1.38"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.10"
implementation "com.onesignal:OneSignal:5.9.4"
}
apply from: "../../node_modules/onesignal-cordova-plugin/build-extras-onesignal.gradle"

View File

@@ -2,9 +2,6 @@
include ':capacitor-android'
project(':capacitor-android').projectDir = new File('../node_modules/@capacitor/android/capacitor')
include ':capacitor-community-facebook-login'
project(':capacitor-community-facebook-login').projectDir = new File('../node_modules/@capacitor-community/facebook-login/android')
include ':capacitor-community-http'
project(':capacitor-community-http').projectDir = new File('../node_modules/@capacitor-community/http/android')
@@ -37,6 +34,3 @@ project(':capacitor-splash-screen').projectDir = new File('../node_modules/@capa
include ':capacitor-status-bar'
project(':capacitor-status-bar').projectDir = new File('../node_modules/@capacitor/status-bar/android')
include ':codetrix-studio-capacitor-google-auth'
project(':codetrix-studio-capacitor-google-auth').projectDir = new File('../node_modules/@codetrix-studio/capacitor-google-auth/android')

View File

@@ -177,7 +177,8 @@
}
},
"cli": {
"defaultCollection": "@ionic/angular-toolkit"
"defaultCollection": "@ionic/angular-toolkit",
"analytics": false
},
"schematics": {
"@ionic/angular-toolkit:component": {

1
capacitor.config.json Normal file
View File

@@ -0,0 +1 @@
{}

22070
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -12,15 +12,14 @@
},
"private": true,
"dependencies": {
"@angular/animations": "~18.2.14",
"@angular/common": "~18.2.14",
"@angular/compiler": "~18.2.14",
"@angular/core": "~18.2.14",
"@angular/forms": "~18.2.14",
"@angular/platform-browser": "~18.2.14",
"@angular/platform-browser-dynamic": "~18.2.14",
"@angular/router": "~18.2.14",
"@capacitor-community/facebook-login": "^7.0.1",
"@angular/animations": "~22.0.1",
"@angular/common": "~22.0.1",
"@angular/compiler": "~22.0.1",
"@angular/core": "~22.0.1",
"@angular/forms": "~22.0.1",
"@angular/platform-browser": "~22.0.1",
"@angular/platform-browser-dynamic": "~22.0.1",
"@angular/router": "~22.0.1",
"@capacitor-community/http": "^1.4.1",
"@capacitor/android": "^6.0.0",
"@capacitor/app": "^6.0.0",
@@ -34,40 +33,40 @@
"@capacitor/preferences": "^6.0.0",
"@capacitor/splash-screen": "^6.0.0",
"@capacitor/status-bar": "^6.0.0",
"@codetrix-studio/capacitor-google-auth": "^3.4.0-rc.4",
"@ionic/angular": "^8.7.17",
"@ionic/angular": "^8.8.10",
"@ngx-translate/core": "~14.0.0",
"@ngx-translate/http-loader": "~7.0.0",
"onesignal-cordova-plugin": "^5.2.19",
"firebase": "^12.14.0",
"onesignal-cordova-plugin": "^5.3.12",
"rxjs": "~7.8.1",
"swiper": "^11.2.10",
"tslib": "^2.6.0",
"zone.js": "~0.14.10"
"zone.js": "~0.15.0"
},
"devDependencies": {
"@angular-devkit/build-angular": "~18.2.21",
"@angular-eslint/builder": "^21.1.0",
"@angular-eslint/eslint-plugin": "^21.1.0",
"@angular-eslint/eslint-plugin-template": "^21.1.0",
"@angular-eslint/schematics": "^21.1.0",
"@angular-eslint/template-parser": "^21.1.0",
"@angular/cli": "~18.2.21",
"@angular/compiler-cli": "~18.2.14",
"@angular/language-service": "~18.2.14",
"@angular-devkit/build-angular": "~22.0.1",
"@angular-eslint/builder": "^22.0.0",
"@angular-eslint/eslint-plugin": "^22.0.0",
"@angular-eslint/eslint-plugin-template": "^22.0.0",
"@angular-eslint/schematics": "^22.0.0",
"@angular-eslint/template-parser": "^22.0.0",
"@angular/cli": "~22.0.1",
"@angular/compiler-cli": "~22.0.1",
"@angular/language-service": "~22.0.1",
"@capacitor/cli": "5.2.1",
"@ionic/angular-toolkit": "^12.3.0",
"@types/jasmine": "~4.3.0",
"@types/node": "~18.18.0",
"@typescript-eslint/eslint-plugin": "^8.53.0",
"@typescript-eslint/parser": "^8.53.0",
"eslint": "^8.57.1",
"@types/node": "^20.0.0",
"@typescript-eslint/eslint-plugin": "^8.61.0",
"@typescript-eslint/parser": "^8.61.0",
"eslint": "^10.0.0",
"jasmine-core": "~4.6.0",
"karma": "~6.4.0",
"karma-chrome-launcher": "~3.2.0",
"karma-coverage": "~2.2.0",
"karma-jasmine": "~5.1.0",
"karma-jasmine-html-reporter": "~2.0.0",
"typescript": "~5.4.5"
"typescript": "~6.0.3"
},
"description": "An Ionic project"
}

View File

@@ -8,12 +8,46 @@
</ion-header>
<ion-content>
<ion-list>
<ion-menu-toggle auto-hide="false" *ngFor="let p of appPages">
<ion-item [routerDirection]="'root'" [routerLink]="[p.url]">
<ion-icon slot="start" [name]="p.icon"></ion-icon>
<ion-label>
{{p.title}}
</ion-label>
<ion-menu-toggle auto-hide="false" [class.ion-hide]="userRole === 0">
<ion-item [routerDirection]="'root'" [routerLink]="['/dashboard']">
<ion-icon slot="start" name="home"></ion-icon>
<ion-label>{{'menu.home' | translate}}</ion-label>
</ion-item>
</ion-menu-toggle>
<ion-menu-toggle auto-hide="false" [class.ion-hide]="userRole === 0">
<ion-item [routerDirection]="'root'" [routerLink]="['/cards']">
<ion-icon slot="start" name="card"></ion-icon>
<ion-label>{{'menu.cards' | translate}}</ion-label>
</ion-item>
</ion-menu-toggle>
<ion-menu-toggle auto-hide="false" [class.ion-hide]="userRole < 2">
<ion-item [routerDirection]="'root'" [routerLink]="['/postulations']">
<ion-icon slot="start" name="hammer"></ion-icon>
<ion-label>{{'menu.postulations' | translate}}</ion-label>
</ion-item>
</ion-menu-toggle>
<ion-menu-toggle auto-hide="false" [class.ion-hide]="userRole === 0">
<ion-item [routerDirection]="'root'" [routerLink]="['/contracts']">
<ion-icon slot="start" name="file-tray-full"></ion-icon>
<ion-label>{{'menu.contracts' | translate}}</ion-label>
</ion-item>
</ion-menu-toggle>
<ion-menu-toggle auto-hide="false" [class.ion-hide]="userRole === 0">
<ion-item [routerDirection]="'root'" [routerLink]="['/faq']">
<ion-icon slot="start" name="information-circle"></ion-icon>
<ion-label>{{'menu.faq' | translate}}</ion-label>
</ion-item>
</ion-menu-toggle>
<ion-menu-toggle auto-hide="false" [class.ion-hide]="userRole < 2">
<ion-item [routerDirection]="'root'" [routerLink]="['/start']">
<ion-icon slot="start" name="send"></ion-icon>
<ion-label>{{'menu.start' | translate}}</ion-label>
</ion-item>
</ion-menu-toggle>
<ion-menu-toggle auto-hide="false" [class.ion-hide]="userRole !== 1">
<ion-item [routerDirection]="'root'" [routerLink]="['/hero']">
<ion-icon slot="start" name="ribbon"></ion-icon>
<ion-label>{{'menu.hero' | translate}}</ion-label>
</ion-item>
</ion-menu-toggle>
<ion-item (click)="logout()">

View File

@@ -1,4 +1,4 @@
import { Component } from '@angular/core';
import { Component, OnInit, ChangeDetectorRef } from '@angular/core';
import { Platform, NavController, LoadingController } from '@ionic/angular';
import { EventService } from './services/event.service';
import { StatusBar, Style } from '@capacitor/status-bar';
@@ -13,17 +13,17 @@ import { OneSignalService } from './services/onesignal.service';
@Component({
selector: 'app-root',
templateUrl: 'app.component.html'
templateUrl: 'app.component.html',
standalone: false
})
export class AppComponent {
export class AppComponent implements OnInit {
private loading: any;
public appPages: any[] = [];
userRole: number = 0;
constructor(
private platform: Platform,
private authService: AuthService,
public authService: AuthService,
private languageService: LanguageService,
private translateService: TranslateService,
private navCtrl: NavController,
@@ -31,75 +31,20 @@ export class AppComponent {
private alertService: AlertService,
private loadingCtrl: LoadingController,
private oneSignalService: OneSignalService,
private cdr: ChangeDetectorRef,
) {
this.initializeApp();
this.events.subscribe('set_role', role => {
// Set OneSignal user tags when role is set (user logged in)
this.userRole = role ?? 0;
this.cdr.detectChanges();
this.setupOneSignalUser(role);
if (role >= 2){
this.appPages = [
{
title: this.translateService.instant('menu.home'),
url: '/dashboard',
icon: 'home'
},
{
title: this.translateService.instant('menu.cards'),
url: '/cards',
icon: 'card'
},
{
title: this.translateService.instant('menu.postulations'),
url: '/postulations',
icon: 'hammer'
},
{
title: this.translateService.instant('menu.contracts'),
url: '/contracts',
icon: 'filing'
},
{
title: this.translateService.instant('menu.faq'),
url: '/faq',
icon: 'information-circle'
},
{
title: this.translateService.instant('menu.start'),
url: '/start',
icon: 'send'
}
];
} else {
this.appPages = [
{
title: this.translateService.instant('menu.home'),
url: '/dashboard',
icon: 'home'
},
{
title: this.translateService.instant('menu.cards'),
url: '/cards',
icon: 'card'
},
{
title: this.translateService.instant('menu.contracts'),
url: '/contracts',
icon: 'filing'
},
{
title: this.translateService.instant('menu.faq'),
url: '/faq',
icon: 'information-circle'
},
{
title: this.translateService.instant('menu.hero'),
url: '/hero',
icon: 'ribbon'
}
];
}
});
}
ngOnInit() {
this.userRole = this.authService.userRole;
}
async initializeApp() {
await this.platform.ready();
@@ -114,7 +59,6 @@ export class AppComponent {
}
this.languageService.getDefaultLanguage();
this.authService.getToken();
}
private async setupOneSignalUser(role: number) {

View File

@@ -1,4 +1,5 @@
import { NgModule } from '@angular/core';
import { NgModule, APP_INITIALIZER } from '@angular/core';
import { AuthService } from './services/auth.service';
import { BrowserModule } from '@angular/platform-browser';
import { RouteReuseStrategy } from '@angular/router';
@@ -6,7 +7,8 @@ import { IonicModule, IonicRouteStrategy } from '@ionic/angular';
import { AppComponent } from './app.component';
import { AppRoutingModule } from './app-routing.module';
import { HttpClient, provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
import { HttpClient, provideHttpClient, withInterceptorsFromDi, HTTP_INTERCEPTORS } from '@angular/common/http';
import { AuthInterceptorService } from './services/auth-interceptor.service';
import { TranslateModule, TranslateLoader } from '@ngx-translate/core';
import { TranslateHttpLoader } from '@ngx-translate/http-loader';
@@ -16,6 +18,10 @@ export function createTranslateLoader(http: HttpClient) {
return new TranslateHttpLoader(http, 'assets/i18n/', '.json');
}
function initAuth(authService: AuthService): () => Promise<void> {
return () => authService.initialize();
}
@NgModule({
declarations: [AppComponent],
bootstrap: [AppComponent],
@@ -34,6 +40,8 @@ export function createTranslateLoader(http: HttpClient) {
],
providers: [
{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy },
{ provide: HTTP_INTERCEPTORS, useClass: AuthInterceptorService, multi: true },
{ provide: APP_INITIALIZER, useFactory: initAuth, deps: [AuthService], multi: true },
provideHttpClient(withInterceptorsFromDi())
]
})

View File

@@ -44,7 +44,8 @@ import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
useExisting: forwardRef(() => RatingComponent),
multi: true
}
]
],
standalone: false
})
export class RatingComponent implements ControlValueAccessor {
@Input() readonly: string = 'false';

View File

@@ -1,7 +1,5 @@
import { Injectable } from '@angular/core';
import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, Router } from '@angular/router';
import { Observable } from 'rxjs';
import { User } from 'src/app/models/user';
import { AuthService } from '../services/auth.service';
@Injectable({
@@ -9,34 +7,24 @@ import { AuthService } from '../services/auth.service';
})
export class AuthGuard implements CanActivate {
user: User;
constructor(
private router: Router,
private authService: AuthService
) {}
canActivate(
next: ActivatedRouteSnapshot,
state: RouterStateSnapshot): Observable<boolean> | Promise<boolean> | boolean {
state: RouterStateSnapshot): boolean {
const currentUser = this.authService.isLoggedIn;
const userVerified = this.authService.isVerified;
const userReported = this.authService.isReported;
//if (userVerified == false) {
//this.router.navigate(['/verify']);
// return false;
//} else if (userReported == true) {
if (userReported == true) {
if (this.authService.isReported) {
this.router.navigate(['/landing']);
return false;
} else {
if (currentUser) {
// authorised so return true
}
if (this.authService.isLoggedIn) {
return true;
}
}
// not logged in so redirect to login page with the return url
this.router.navigate(['/landing']);
return false;
}

View File

@@ -9,7 +9,7 @@ import { AuthService } from '../services/auth.service';
})
export class AuthoriginGuard implements CanActivate {
user: User;
user!: User;
constructor(
private router: Router,

View File

@@ -4,6 +4,7 @@ import { Component } from '@angular/core';
selector: 'app-home',
templateUrl: 'home.page.html',
styleUrls: ['home.page.scss'],
standalone: false
})
export class HomePage {

View File

@@ -1,8 +1,8 @@
export class User {
id: number;
name: string;
email: string;
phone: string;
phone_verified_at: string;
reported: boolean;
id!: number;
name!: string;
email!: string;
phone!: string;
phone_verified_at!: string;
reported!: boolean;
}

View File

@@ -8,8 +8,8 @@
<ion-title>{{'auth.forgot' | translate}}</ion-title>
</ion-toolbar>
</ion-header>
<ion-content padding>
<p text-wrap>{{'auth.forgot_instructions' | translate}}</p><br>
<ion-content class="ion-padding">
<p class="ion-text-wrap">{{'auth.forgot_instructions' | translate}}</p><br>
<form #form="ngForm" (ngSubmit)="forgot(form)" method="post">
<ion-item>
<ion-label position="floating">{{'auth.email' | translate}}</ion-label>

View File

@@ -1,52 +1,52 @@
import { Component, OnInit } from '@angular/core';
import { NavController, LoadingController } from '@ionic/angular';
import { NgForm } from '@angular/forms';
import { AuthService } from 'src/app/services/auth.service';
import { AlertService } from 'src/app/services/alert.service';
import { TranslateService } from '@ngx-translate/core';
import { FirebaseAuthService } from 'src/app/services/firebase-auth.service';
@Component({
selector: 'app-forgot',
templateUrl: './forgot.page.html',
styleUrls: ['./forgot.page.scss'],
standalone: false
})
export class ForgotPage implements OnInit {
private loading;
private loading: HTMLIonLoadingElement | null = null;
constructor(
private authService: AuthService,
private firebaseAuthService: FirebaseAuthService,
private navCtrl: NavController,
private alertService: AlertService,
private translateService: TranslateService,
private loadingCtrl: LoadingController
) { }
ngOnInit() {
}
// Dismiss Forgot Modal
ngOnInit() { }
dismissForgot() {
this.navCtrl.back();
}
// On Register button tap, dismiss login modal and open register modal
forgot(form: NgForm) {
this.loadingCtrl.create().then((overlay) => {
this.loading = overlay;
this.loading.present();
});
this.authService.forgot(form.value.email).subscribe(
data => {
this.loading.dismiss();
async forgot(form: NgForm) {
this.loading = await this.loadingCtrl.create();
await this.loading.present();
try {
await this.firebaseAuthService.sendPasswordReset(form.value.email);
if (this.loading) this.loading.dismiss();
this.alertService.presentToast(this.translateService.instant('alerts.reset_pass'));
},
error => {
this.loading.dismiss();
this.alertService.presentToast(this.translateService.instant('alerts.error') + error['message']);
console.log(error);
},
() => {
this.dismissForgot();
} catch (e: any) {
if (this.loading) this.loading.dismiss();
if (e.code === 'auth/user-not-found') {
// Por seguridad mostramos el mismo mensaje aunque no exista el usuario
this.alertService.presentToast(this.translateService.instant('alerts.reset_pass'));
this.dismissForgot();
} else {
this.alertService.presentToast(this.translateService.instant('alerts.error') + e.message);
}
}
);
}
}

View File

@@ -8,7 +8,7 @@
<ion-title>{{'auth.login' | translate}}</ion-title>
</ion-toolbar>
</ion-header>
<ion-content padding>
<ion-content class="ion-padding">
<form #form="ngForm" (ngSubmit)="login(form)" method="post">
<ion-item>
<ion-label position="floating">{{'auth.email' | translate}}</ion-label>
@@ -22,11 +22,27 @@
<br>
<ion-button type="submit" expand="full" color="primary">{{'auth.login' | translate}}</ion-button>
</form>
<ion-text><p text-center (click)="forgotModal()"><u>{{'auth.forgot' | translate}}</u></p></ion-text>
<ion-text><p class="ion-text-center" (click)="forgotModal()"><u>{{'auth.forgot' | translate}}</u></p></ion-text>
<br><br>
<ion-button expand="full" color="facebook" (click)="loginFacebook()">{{'auth.fb_login' | translate}}</ion-button>
<ion-button expand="full" color="danger" (click)="loginGoogle()">{{'auth.google_login' | translate}}</ion-button>
<p text-center>{{'auth.signup_ad' | translate}}</p>
<!-- Google Sign-In — branding oficial: fondo blanco, logo G coloreado, borde gris -->
<button class="btn-social btn-google" (click)="loginGoogle()">
<svg class="btn-social__icon" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<path d="M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z" fill="#4285F4"/>
<path d="M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z" fill="#34A853"/>
<path d="M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l3.66-2.84z" fill="#FBBC05"/>
<path d="M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z" fill="#EA4335"/>
</svg>
<span class="btn-social__label">{{'auth.google_login' | translate}}</span>
</button>
<!-- Apple Sign-In — branding oficial: fondo negro, logo Apple blanco, SF font -->
<button class="btn-social btn-apple" (click)="loginApple()">
<svg class="btn-social__icon btn-social__icon--apple" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<path d="M17.05 20.28c-.98.95-2.05.8-3.08.35-1.09-.46-2.09-.48-3.24 0-1.44.62-2.2.44-3.06-.35C2.79 15.25 3.51 7.7 9.05 7.4c1.42.07 2.4.78 3.23.8 1.22-.24 2.39-.93 3.68-.84 1.56.12 2.73.72 3.5 1.9-3.22 1.93-2.46 5.91.59 7.03-.69 1.55-1.6 3.08-3 4zM12.03 7.25c-.15-2.23 1.66-4.07 3.74-4.25.29 2.58-2.34 4.5-3.74 4.25z" fill="#FFFFFF"/>
</svg>
<span class="btn-social__label">{{'auth.apple_login' | translate}}</span>
</button>
<p class="ion-text-center">{{'auth.signup_ad' | translate}}</p>
<ion-button expand="full" color="secondary" (click)="registerModal()">{{'auth.signup' | translate}}</ion-button>
<ion-text><p text-center>{{'auth.terms_1' | translate}}<u (click)="openTerms()">{{'auth.terms_2' | translate}}</u>{{'auth.terms_3' | translate}}</p></ion-text>
<ion-text><p class="ion-text-center">{{'auth.terms_1' | translate}}<u (click)="openTerms()">{{'auth.terms_2' | translate}}</u>{{'auth.terms_3' | translate}}</p></ion-text>
</ion-content>

View File

@@ -0,0 +1,63 @@
.btn-social {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 44px;
border-radius: 4px;
border: none;
cursor: pointer;
font-size: 14px;
font-weight: 500;
letter-spacing: 0.06em;
margin-bottom: 12px;
padding: 0 12px;
transition: box-shadow 0.2s ease;
&__icon {
width: 20px;
height: 20px;
margin-right: 12px;
flex-shrink: 0;
&--apple {
width: 18px;
height: 18px;
}
}
&__label {
flex: 1;
text-align: center;
margin-right: 32px; // compensa el ancho del icono para centrar visualmente
text-transform: uppercase;
}
&:active {
box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.15);
}
}
// Google: fondo blanco, borde gris, texto oscuro
.btn-google {
background-color: #ffffff;
border: 1px solid #DADCE0;
color: #3c4043;
font-family: 'Roboto', sans-serif;
&:hover {
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
}
// Apple: fondo negro, texto blanco, font del sistema
.btn-apple {
background-color: #000000;
color: #ffffff;
font-family: -apple-system, 'SF Pro Display', BlinkMacSystemFont, sans-serif;
border-radius: 6px;
&:hover {
background-color: #1a1a1a;
}
}

View File

@@ -4,22 +4,24 @@ import { NgForm } from '@angular/forms';
import { AuthService } from 'src/app/services/auth.service';
import { AlertService } from 'src/app/services/alert.service';
import { TranslateService } from '@ngx-translate/core';
import { FacebookLogin, FacebookLoginResponse } from '@capacitor-community/facebook-login';
import { GoogleAuth } from '@codetrix-studio/capacitor-google-auth';
import { FirebaseAuthService } from 'src/app/services/firebase-auth.service';
import { Browser } from '@capacitor/browser';
import { firstValueFrom } from 'rxjs';
@Component({
selector: 'app-login',
templateUrl: './login.page.html',
styleUrls: ['./login.page.scss']
styleUrls: ['./login.page.scss'],
standalone: false
})
export class LoginPage implements OnInit {
private loading: any;
private loading: HTMLIonLoadingElement | null = null;
constructor(
private authService: AuthService,
private firebaseAuthService: FirebaseAuthService,
private navCtrl: NavController,
private alertService: AlertService,
private translateService: TranslateService,
@@ -45,66 +47,71 @@ export class LoginPage implements OnInit {
this.loading = await this.loadingCtrl.create();
await this.loading.present();
this.authService.login(form.value.email, form.value.password).subscribe(
data => {
if (this.loading) this.loading.dismiss();
},
error => {
try {
const idToken = await this.firebaseAuthService.signInWithEmail(
form.value.email,
form.value.password
);
this.authService.loginWithFirebase(idToken).subscribe(
(data: any) => {},
(error: any) => {
if (this.loading) this.loading.dismiss();
if (JSON.stringify(error['status']) == '401') {
this.alertService.presentToast(this.translateService.instant('alerts.login_error'));
}
else {
} else {
this.alertService.presentToast(this.translateService.instant('alerts.error') + error['message']);
console.log(error);
}
},
() => {
() => { this.navigateAfterLogin(); }
);
} catch (e: any) {
if (this.loading) this.loading.dismiss();
const msg = this.getFirebaseErrorMessage(e.code);
this.alertService.presentToast(msg);
}
}
private async navigateAfterLogin() {
try {
await firstValueFrom(this.authService.user());
} catch { }
if (this.loading) this.loading.dismiss();
this.dismissLogin();
this.navCtrl.navigateRoot('/dashboard');
this.alertService.presentToast(this.translateService.instant('alerts.login'));
}
);
private getFirebaseErrorMessage(code: string): string {
switch (code) {
case 'auth/wrong-password':
case 'auth/user-not-found':
case 'auth/invalid-credential':
return this.translateService.instant('alerts.login_error');
case 'auth/too-many-requests':
return this.translateService.instant('alerts.too_many_requests');
default:
return this.translateService.instant('alerts.error') + code;
}
}
async loginFacebook() {
async loginApple() {
this.loading = await this.loadingCtrl.create();
await this.loading.present();
try {
// Login with permissions
const result = await FacebookLogin.login({ permissions: ['public_profile', 'email'] });
const idToken = await this.firebaseAuthService.signInWithApple();
if (result.accessToken) {
// Get user ID and Token
const fb_id = result.accessToken.userId;
const fb_token = result.accessToken.token;
console.log("ID: " + fb_id);
console.log("Token: " + fb_token);
this.authService.login_register_fb(fb_token, fb_id).subscribe(
data => {
},
error => {
this.loading.dismiss();
this.authService.loginWithFirebase(idToken).subscribe(
(data: any) => {},
(error: any) => {
if (this.loading) this.loading.dismiss();
this.alertService.presentToast(this.translateService.instant('alerts.error') + error);
console.log(error);
},
() => {
this.loading.dismiss();
this.dismissLogin();
this.navCtrl.navigateRoot('/dashboard');
this.alertService.presentToast(this.translateService.instant('alerts.login'));
}
() => { this.navigateAfterLogin(); }
);
} else {
this.loading.dismiss();
this.alertService.presentToast(this.translateService.instant('alerts.timeout_error'));
}
} catch (e) {
this.loading.dismiss();
if (this.loading) this.loading.dismiss();
this.alertService.presentToast(this.translateService.instant('alerts.error') + e);
}
}
@@ -114,32 +121,19 @@ export class LoginPage implements OnInit {
await this.loading.present();
try {
const res = await GoogleAuth.signIn();
console.log(res);
const idToken = await this.firebaseAuthService.signInWithGoogle();
const google_id = res.id;
const google_token = res.authentication.accessToken;
console.log("ID: " + google_id);
console.log("Token: " + google_token);
this.authService.login_register_googlePlus(google_token, google_id).subscribe(
data => {
},
error => {
this.loading.dismiss();
this.authService.loginWithFirebase(idToken).subscribe(
(data: any) => {},
(error: any) => {
if (this.loading) this.loading.dismiss();
this.alertService.presentToast(this.translateService.instant('alerts.error') + error);
console.log(error);
},
() => {
this.loading.dismiss();
this.dismissLogin();
this.navCtrl.navigateRoot('/dashboard');
this.alertService.presentToast(this.translateService.instant('alerts.login'));
}
() => { this.navigateAfterLogin(); }
);
} catch (err) {
this.loading.dismiss();
if (this.loading) this.loading.dismiss();
this.alertService.presentToast(this.translateService.instant('alerts.error') + err);
console.log(err);
}

View File

@@ -8,7 +8,7 @@
<ion-title>{{'auth.signup' | translate}}</ion-title>
</ion-toolbar>
</ion-header>
<ion-content padding>
<ion-content class="ion-padding">
<form #form="ngForm" (ngSubmit)="register(form)" method="post">
<ion-item>
<ion-label position="floating">{{'auth.name' | translate}}</ion-label>
@@ -37,7 +37,7 @@
<br><br>
<ion-row>
<ion-col size="9.5">
<p text-center style="margin-bottom:0;margin-top:0.25em;color:#4d4d4d">{{'auth.terms_1' | translate}}<u (click)="openTerms()">{{'auth.terms_2' | translate}}</u>{{'auth.terms_3' | translate}}</p>
<p class="ion-text-center" style="margin-bottom:0;margin-top:0.25em;color:#4d4d4d">{{'auth.terms_1' | translate}}<u (click)="openTerms()">{{'auth.terms_2' | translate}}</u>{{'auth.terms_3' | translate}}</p>
</ion-col>
<ion-col size="2.5">
<ion-item lines="none">
@@ -48,6 +48,6 @@
<br>
<ion-button type="submit" expand="full" color="secondary">{{'auth.signup' | translate}}</ion-button>
</form>
<br><p text-center>{{'auth.login_ad' | translate}}</p>
<br><p class="ion-text-center">{{'auth.login_ad' | translate}}</p>
<ion-button expand="full" color="primary" (click)="loginModal()">{{'auth.login' | translate}}</ion-button>
</ion-content>

View File

@@ -4,85 +4,93 @@ import { AuthService } from 'src/app/services/auth.service';
import { NgForm } from '@angular/forms';
import { AlertService } from 'src/app/services/alert.service';
import { TranslateService } from '@ngx-translate/core';
import { FirebaseAuthService } from 'src/app/services/firebase-auth.service';
import { Browser } from '@capacitor/browser';
@Component({
selector: 'app-register',
templateUrl: './register.page.html',
styleUrls: ['./register.page.scss'],
standalone: false
})
export class RegisterPage implements OnInit {
loading: any = null;
loading: HTMLIonLoadingElement | null = null;
terms = false;
constructor(
private authService: AuthService,
private firebaseAuthService: FirebaseAuthService,
private translateService: TranslateService,
private navCtrl: NavController,
private loadingCtrl: LoadingController,
private alertService: AlertService
) { }
ngOnInit() {
}
// Dismiss Register Modal
ngOnInit() { }
dismissRegister() {
this.navCtrl.navigateRoot('/landing');
}
// On Login button tap, dismiss Register modal and open login Modal
loginModal() {
this.navCtrl.navigateForward('/login');
}
updateChecked () {
if (this.terms == true) {
this.terms = false;
console.log(this.terms);
} else {
this.terms = true;
console.log(this.terms);
}
updateChecked() {
this.terms = !this.terms;
}
register(form: NgForm) {
async register(form: NgForm) {
if (!this.terms) {
this.alertService.presentToast(this.translateService.instant('alerts.signup_error_3'));
return;
}
if (this.terms == true) {
if (form.value.name && form.value.email && form.value.phone && form.value.password && form.value.password1) {
if (form.value.password == form.value.password1) {
this.loadingCtrl.create().then((overlay) => {
this.loading = overlay;
this.loading.present();
});
this.authService.register(form.value.name, form.value.email, form.value.phone, form.value.password).subscribe(
data => {
this.loading.dismiss();
this.alertService.presentToast(this.translateService.instant('alerts.signup'));
},
error => {
if (JSON.stringify(error['status']) == '422') {
this.loading.dismiss();
const { name, email, phone, password, password1 } = form.value;
if (!name || !email || !phone || !password || !password1) {
this.alertService.presentToast(this.translateService.instant('alerts.signup_error_2'));
return;
}
if (password !== password1) {
this.alertService.presentToast(this.translateService.instant('alerts.signup_error_1'));
return;
}
this.loading = await this.loadingCtrl.create();
await this.loading.present();
try {
// Firebase crea la cuenta con email + password
const idToken = await this.firebaseAuthService.registerWithEmail(email, password);
// Backend crea el perfil y devuelve el token de la app
this.authService.registerWithFirebase(idToken, name, phone, email).subscribe(
(data: any) => {},
(error: any) => {
if (this.loading) this.loading.dismiss();
if (error['status'] === 422) {
this.alertService.presentToast(this.translateService.instant('alerts.signup_error'));
}
else {
this.loading.dismiss();
console.log(error);
} else {
this.alertService.presentToast(this.translateService.instant('alerts.error') + error['message']);
}
},
() => {
if (this.loading) this.loading.dismiss();
this.alertService.presentToast(this.translateService.instant('alerts.signup'));
this.navCtrl.navigateRoot('/dashboard');
}
);
} catch (e: any) {
if (this.loading) this.loading.dismiss();
if (e.code === 'auth/email-already-in-use') {
this.alertService.presentToast(this.translateService.instant('alerts.signup_error'));
} else {
this.alertService.presentToast(this.translateService.instant('alerts.signup_error_1'));
this.alertService.presentToast(this.translateService.instant('alerts.error') + e.message);
}
} else {
this.alertService.presentToast(this.translateService.instant('alerts.signup_error_2'));
}
} else {
this.alertService.presentToast(this.translateService.instant('alerts.signup_error_3'));
}
}
async openTerms() {

View File

@@ -6,7 +6,7 @@
<ion-title>{{'cards.add' | translate}}</ion-title>
</ion-toolbar>
</ion-header>
<ion-content padding>
<ion-content class="ion-padding">
<form #form="ngForm" id="card_form" (ngSubmit)="addcard(form)" method="post">
<ion-item [class.ng-invalid]="!holder_check">
@@ -52,10 +52,10 @@
</ion-row>
<ion-row>
<ion-col size="6">
<p text-center>{{'cards.openpay_2' | translate}}<p>
<p class="ion-text-center">{{'cards.openpay_2' | translate}}<p>
</ion-col>
<ion-col size="6" style="border-left: 1px solid #d0d0d0">
<p text-center>{{'cards.openpay_3' | translate}}<p>
<p class="ion-text-center">{{'cards.openpay_3' | translate}}<p>
</ion-col>
</ion-row>
<ion-row>

View File

@@ -14,22 +14,23 @@ declare var OpenPay: any;
selector: 'app-addcard',
templateUrl: './addcard.page.html',
styleUrls: ['./addcard.page.scss'],
standalone: false
})
export class AddcardPage implements OnInit {
private loading;
private loading: HTMLIonLoadingElement | null = null;
card_check = true;
date_check = true;
cvv_check = true;
holder_check = null;
line1_check = null;
line2_check = null;
line3_check = null;
postal_code_check = null;
city_check = null;
state_check = null;
month_number = null;
year_number = null;
holder_check: boolean | null = null;
line1_check: boolean | null = null;
line2_check: boolean | null = null;
line3_check: boolean | null = null;
postal_code_check: boolean | null = null;
city_check: boolean | null = null;
state_check: boolean | null = null;
month_number: any = null;
year_number: any = null;
constructor(
private modalController: ModalController,
@@ -147,28 +148,28 @@ export class AddcardPage implements OnInit {
"country_code":"MX"
}*/
},
onSuccess => {
(onSuccess: any) => {
let token = onSuccess.data.id;
let device_id = (<HTMLInputElement>document.getElementById('deviceDataId')).value;
this.ichambaService.addCard(token, device_id).subscribe(
data => {
(data: any) => {
if (data['type'] == "error") {
this.loading.dismiss();
if (this.loading) this.loading.dismiss();
this.alertService.presentToast(data['message']);
} else {
this.events.publish('refreshcards', 'data');
this.loading.dismiss();
if (this.loading) this.loading.dismiss();
this.dismissAddcard();
this.alertService.presentToast(this.translateService.instant('alerts.added_card'));
}
}, error => {
this.loading.dismiss();
}, (error: any) => {
if (this.loading) this.loading.dismiss();
this.alertService.presentToast(this.translateService.instant('alerts.error') + error['status']);
});
//console.log(onSuccess.data.id);
//console.log(document.getElementById('deviceDataId').value);
}, onError => {
this.loading.dismiss();
}, (onError: any) => {
if (this.loading) this.loading.dismiss();
this.alertService.presentToast(this.translateService.instant('alerts.geo_error') + onError['status']);
});
}

View File

@@ -6,11 +6,11 @@
<ion-title>{{'cards.header' | translate}}</ion-title>
</ion-toolbar>
</ion-header>
<ion-content padding>
<ion-content class="ion-padding">
<ion-card *ngFor="let card of cards">
<ion-item>
<ion-label>
<h2 text-capitalize>{{ card.brand }}</h2>
<h2 class="ion-text-capitalize">{{ card.brand }}</h2>
<p>{{card.card_number}}</p>
</ion-label>
<ion-button color="danger" (click)="deletecard(card.id)">

View File

@@ -12,10 +12,11 @@ import { AlertService } from 'src/app/services/alert.service';
selector: 'app-cards',
templateUrl: './cards.page.html',
styleUrls: ['./cards.page.scss'],
standalone: false
})
export class CardsPage implements OnInit {
cards = [];
cards: any[] = [];
constructor(
private modalController: ModalController,

View File

@@ -13,6 +13,7 @@ declare var google: any;
selector: 'app-category',
templateUrl: './category.page.html',
styleUrls: ['./category.page.scss'],
standalone: false
})
export class CategoryPage implements OnInit {
@@ -22,20 +23,20 @@ export class CategoryPage implements OnInit {
//amount: number = null;
//amount_check = true;
minyear: string = (new Date().getFullYear() + '-' + ((new Date().getMonth() + 1) < 10 ? '0' : '') + (new Date().getMonth() + 1) + '-' + (new Date().getDate() < 10 ? '0' : '') + new Date().getDate()).toString();
maxyear: string = null;
mintime: number;
maxtime: number;
maxyear: string | null = null;
mintime: number = 0;
maxtime: number = 0;
setHour: any;
setDate: any;
references: string;
details: string;
differenceDate: number;
differenceHour: number;
references: string = '';
details: string = '';
differenceDate: number = 0;
differenceHour: number = 0;
myPosition: any = {};
myAddress: string = null;
myIntnumber: string = null;
myAddress: string | null = null;
myIntnumber: string | null = null;
addressAutocomplete: string = '';
placesSearch: string = '';
placesSearch: any = '';
showif = true;
constructor(
@@ -54,7 +55,7 @@ export class CategoryPage implements OnInit {
ngOnInit() {
this.category = this.activatedRoute.snapshot.paramMap.get('category');
this.ichambaService.getParameters()
.subscribe( data => {
.subscribe( (data: any) => {
this.mintime = data['min_time'];
this.maxtime = data['max_time'];
});
@@ -135,7 +136,7 @@ export class CategoryPage implements OnInit {
this.placesSearch = null;
}
console.log(this.addressAutocomplete)
new google.maps.places.AutocompleteService().getPredictions({ input: this.addressAutocomplete }, predictions => {
new google.maps.places.AutocompleteService().getPredictions({ input: this.addressAutocomplete }, (predictions: any) => {
this.ngZone.run(() => {
this.placesSearch = predictions;
console.log(predictions);
@@ -148,7 +149,7 @@ export class CategoryPage implements OnInit {
this.addressAutocomplete = place_description; // Sincronizar con el input
console.log(place_id);
this.hidelist();
new google.maps.Geocoder().geocode({ placeId: place_id }, coordinates => {
new google.maps.Geocoder().geocode({ placeId: place_id }, (coordinates: any) => {
this.ngZone.run(() => {
console.log(coordinates[0].geometry.location.lat() + ", " + coordinates[0].geometry.location.lng());
this.myPosition = {
@@ -194,20 +195,20 @@ export class CategoryPage implements OnInit {
this.loading.present();
});
if (!Number.isInteger(parseInt(this.myIntnumber))) {
if (!Number.isInteger(parseInt(this.myIntnumber ?? ''))) {
this.myIntnumber = null;
}
this.ichambaService.addPostulation(this.category, this.myAddress, this.myIntnumber, this.references, this.myPosition.latitude, this.myPosition.longitude, this.setDate, this.setHour, this.details).subscribe(
data => {
this.loading.dismiss();
this.ichambaService.addPostulation(this.category, this.myAddress!, this.myIntnumber ?? '', this.references, this.myPosition.latitude, this.myPosition.longitude, this.setDate, this.setHour, this.details).subscribe(
(data: any) => {
if (this.loading) this.loading.dismiss();
if (data['message'] == 'No providers') {
this.alertService.presentToast(this.translateService.instant('alerts.no_provider'));
} else {
this.navCtrl.navigateRoot('/dashboard');
this.alertService.presentToast(this.translateService.instant('alerts.categories_success'));
}
}, error => {
this.loading.dismiss();
}, (error: any) => {
if (this.loading) this.loading.dismiss();
this.alertService.presentToast(this.translateService.instant('alerts.error') + error['status']);
});
} else {

View File

@@ -6,8 +6,8 @@
<ion-title>{{'contracts.header' | translate}}</ion-title>
</ion-toolbar>
</ion-header>
<ion-content padding>
<h2 text-capitalize style="padding-bottom: 0.5em">{{'contracts.header_2' | translate}}</h2>
<ion-content class="ion-padding">
<h2 class="ion-text-capitalize" style="padding-bottom: 0.5em">{{'contracts.header_2' | translate}}</h2>
<ion-refresher slot="fixed" (ionRefresh)="refresh($event)">
<ion-refresher-content></ion-refresher-content>
</ion-refresher>
@@ -15,15 +15,15 @@
<ion-card *ngIf="ccontract.status==1">
<ion-item style="--border-color: #fff">
<ion-label>
<h2 *ngIf="lang===true"text-capitalize>{{ ccontract.category }}</h2>
<h2 *ngIf="lang===false"text-capitalize>{{ ccontract.en_category }}</h2>
<p text-wrap>{{ ccontract.address }}</p>
<p text-wrap text-capitalize>{{ ccontracts_dates[i] }}</p>
<p text-wrap text-capitalize>{{'contracts.supplier' | translate}}: {{ ccontract.supplier }}</p>
<p text-wrap>{{'contracts.phone' | translate}}: <a href="tel:{{ ccontract.phone }}">{{ ccontract.phone }}</a></p>
<p text-wrap text-capitalize>{{'contracts.amount' | translate}}: ${{ ccontract.amount }}</p>
<h2 text-wrap>{{'contracts.start_pin' | translate}}<b>{{ ccontract.code }}</b></h2>
<p text-wrap>{{'contracts.info_pin' | translate}}</p>
<h2 *ngIf="lang===true" class="ion-text-capitalize">{{ ccontract.category }}</h2>
<h2 *ngIf="lang===false" class="ion-text-capitalize">{{ ccontract.en_category }}</h2>
<p class="ion-text-wrap">{{ ccontract.address }}</p>
<p class="ion-text-wrap ion-text-capitalize">{{ ccontracts_dates[i] }}</p>
<p class="ion-text-wrap ion-text-capitalize">{{'contracts.supplier' | translate}}: {{ ccontract.supplier }}</p>
<p class="ion-text-wrap">{{'contracts.phone' | translate}}: <a href="tel:{{ ccontract.phone }}">{{ ccontract.phone }}</a></p>
<p class="ion-text-wrap ion-text-capitalize">{{'contracts.amount' | translate}}: ${{ ccontract.amount }}</p>
<h2 class="ion-text-wrap">{{'contracts.start_pin' | translate}}<b>{{ ccontract.code }}</b></h2>
<p class="ion-text-wrap">{{'contracts.info_pin' | translate}}</p>
</ion-label>
</ion-item>
<ion-button *ngIf="ccontract.past_due < 0" style="height: 4.0em; padding-right: 1.0em; padding-bottom:1.0em; float: right" color="danger" (click)="cancelContract(ccontract.id, ccontract.date)">{{'contracts.cancel_1.1' | translate}}<br>{{'contracts.cancel_1.2' | translate}}</ion-button>

View File

@@ -13,12 +13,13 @@ import { AlertController } from '@ionic/angular';
selector: 'app-contracted',
templateUrl: './contracted.page.html',
styleUrls: ['./contracted.page.scss'],
standalone: false
})
export class ContractedPage implements OnInit {
ccontracts = [];
ccontracts_dates = [];
lang: boolean;
ccontracts: any[] = [];
ccontracts_dates: any[] = [];
lang: boolean = false;
constructor(
private modalController: ModalController,
@@ -47,7 +48,7 @@ export class ContractedPage implements OnInit {
}
}
refresh(event) {
refresh(event: any) {
this.ichambaService.getCurrentcontracts().subscribe(
data => {
this.ccontracts = data;
@@ -90,10 +91,10 @@ export class ContractedPage implements OnInit {
this.presentAlert(id)
} else { */
this.ichambaService.cancelContract(id).subscribe(
data => {
(data: any) => {
this.getccontracts();
this.alertService.presentToast(data['message']);
}, error => {
}, (error: any) => {
this.alertService.presentToast(this.translateService.instant('alerts.error') + error['status']);
});
//}
@@ -114,10 +115,10 @@ export class ContractedPage implements OnInit {
text: 'Confirmar',
handler: () => {
this.ichambaService.cancelContract(id).subscribe(
data => {
(data: any) => {
this.getccontracts();
this.alertService.presentToast(data['message']);
}, error => {
}, (error: any) => {
this.alertService.presentToast(this.translateService.instant('alerts.error') + error['status']);
});
}

View File

@@ -10,6 +10,7 @@ import { AlertService } from 'src/app/services/alert.service';
selector: 'app-contracts',
templateUrl: './contracts.page.html',
styleUrls: ['./contracts.page.scss'],
standalone: false
})
export class ContractsPage implements OnInit {

View File

@@ -6,8 +6,8 @@
<ion-title>Añadir Fondos</ion-title>
</ion-toolbar>
</ion-header>
<ion-content padding>
<p text-wrap>Está por añadir un fondo extra al servicio realizado por <b>{{ supplier }}</b>.
<ion-content class="ion-padding">
<p class="ion-text-wrap">Está por añadir un fondo extra al servicio realizado por <b>{{ supplier }}</b>.
Para continuar, seleccione la tarjeta con la que desee pagar el servicio e ingrese el código
de seguridad de la tarjeta.</p><br>
<ion-item [class.ng-invalid]="!amount_check">

View File

@@ -15,18 +15,19 @@ declare var OpenPay: any;
selector: 'app-extra',
templateUrl: './extra.page.html',
styleUrls: ['./extra.page.scss'],
standalone: false
})
export class ExtraPage implements OnInit {
private loading;
amount: number = null;
private loading: HTMLIonLoadingElement | null = null;
amount: number | null = null;
amount_check = true;
code_check = true;
cards = [];
card_id = null;
supplier = null;
cards_menu = null;
contract_id: number = null;
cards: any[] = [];
card_id: any = null;
supplier: any = null;
cards_menu: any = null;
contract_id: number | null = null;
constructor(
private modalController: ModalController,
@@ -104,16 +105,16 @@ export class ExtraPage implements OnInit {
this.loading = overlay;
this.loading.present();
});
this.ichambaService.addExtra(this.contract_id, this.amount, this.card_id, code, device_id).subscribe(
data => {
this.loading.dismiss();
if (data['message'] = 'extra_added') {
this.ichambaService.addExtra(this.contract_id!, this.amount!, this.card_id, code, device_id).subscribe(
(data: any) => {
if (this.loading) this.loading.dismiss();
if (data['message'] == 'extra_added') {
this.alertService.presentToast("Fondo extra añadido con éxito");
}
this.events.publish('refreshpcontracts', 'data');
this.navCtrl.navigateRoot('/contracts/contracted');
}, error => {
this.loading.dismiss();
}, (error: any) => {
if (this.loading) this.loading.dismiss();
this.alertService.presentToast("Por favor contacte a soporte técnico, Estatus:" + error['status']);
});
//console.log(onSuccess.data.id);

View File

@@ -6,8 +6,8 @@
<ion-title>{{'contract.header' | translate}}</ion-title>
</ion-toolbar>
</ion-header>
<ion-content padding>
<h2 text-capitalize style="padding-bottom: 0.5em">{{'contracts.header_3' | translate}}</h2>
<ion-content class="ion-padding">
<h2 class="ion-text-capitalize" style="padding-bottom: 0.5em">{{'contracts.header_3' | translate}}</h2>
<ion-refresher slot="fixed" (ionRefresh)="refresh($event)">
<ion-refresher-content></ion-refresher-content>
</ion-refresher>
@@ -15,13 +15,13 @@
<ion-card>
<ion-item style="--border-color: #fff">
<ion-label>
<h2 text-capitalize *ngIf="lang===true">{{ fcontract.category }}</h2>
<h2 text-capitalize *ngIf="lang===false">{{ fcontract.en_category }}</h2>
<h2 text-capitalize *ngIf="fcontract.parent">{{'contracts.parent' | translate}}</h2>
<p text-wrap>{{ fcontract.address }}</p>
<p text-wrap text-capitalize>{{ fcontracts_dates[i] }}</p>
<p text-wrap text-capitalize>{{'contracts.supplier' | translate}}: {{ fcontract.supplier }}</p>
<p text-wrap text-capitalize>{{'contracts.amount' | translate}}: ${{ fcontract.amount }}</p>
<h2 class="ion-text-capitalize" *ngIf="lang===true">{{ fcontract.category }}</h2>
<h2 class="ion-text-capitalize" *ngIf="lang===false">{{ fcontract.en_category }}</h2>
<h2 class="ion-text-capitalize" *ngIf="fcontract.parent">{{'contracts.parent' | translate}}</h2>
<p class="ion-text-wrap">{{ fcontract.address }}</p>
<p class="ion-text-wrap ion-text-capitalize">{{ fcontracts_dates[i] }}</p>
<p class="ion-text-wrap ion-text-capitalize">{{'contracts.supplier' | translate}}: {{ fcontract.supplier }}</p>
<p class="ion-text-wrap ion-text-capitalize">{{'contracts.amount' | translate}}: ${{ fcontract.amount }}</p>
<p>{{'contracts.status' | translate}}: {{ fcontract.status }}</p>
</ion-label>
</ion-item>

View File

@@ -15,12 +15,13 @@ import { AlertController } from '@ionic/angular';
selector: 'app-finished',
templateUrl: './finished.page.html',
styleUrls: ['./finished.page.scss'],
standalone: false
})
export class FinishedPage implements OnInit {
fcontracts = [];
fcontracts_dates = [];
lang: boolean;
fcontracts: any[] = [];
fcontracts_dates: any[] = [];
lang: boolean = false;
constructor(
private modalController: ModalController,
@@ -51,7 +52,7 @@ export class FinishedPage implements OnInit {
}
}
refresh(event) {
refresh(event: any) {
this.ichambaService.getFinishedcontracts().subscribe(
data => {
this.fcontracts = data;

View File

@@ -6,31 +6,31 @@
<ion-title>{{'contracts.hire' | translate}}</ion-title>
</ion-toolbar>
</ion-header>
<ion-content padding>
<p text-wrap>{{'contracts.hire_info_1' | translate}} <b>{{ supplier }}</b> {{'contracts.hire_info_2' | translate}}<br>
<ion-content class="ion-padding">
<p class="ion-text-wrap">{{'contracts.hire_info_1' | translate}} <b>{{ supplier }}</b> {{'contracts.hire_info_2' | translate}}<br>
{{'contracts.hire_pay' | translate}}</p><br>
<ion-row>
<ion-col size="9">
<p text-left style="margin:0">{{'contracts.fee_amount' | translate}}:</p>
<p class="ion-text-start" style="margin:0">{{'contracts.fee_amount' | translate}}:</p>
</ion-col>
<ion-col size="3">
<p text-right style="margin:0">${{ fee | number: '1.2-2'}}</p>
<p class="ion-text-end" style="margin:0">${{ fee | number: '1.2-2'}}</p>
</ion-col>
</ion-row>
<ion-row>
<ion-col size="9">
<p text-left style="margin:0">{{'contracts.discount_amount' | translate}}:</p>
<p class="ion-text-start" style="margin:0">{{'contracts.discount_amount' | translate}}:</p>
</ion-col>
<ion-col size="3">
<p text-right style="margin:0">${{ discount | number: '1.2-2'}}</p>
<p class="ion-text-end" style="margin:0">${{ discount | number: '1.2-2'}}</p>
</ion-col>
</ion-row>
<ion-row>
<ion-col size="9">
<p text-left style="margin:0"><b>{{'contracts.final_amount' | translate}}:</b></p>
<p class="ion-text-start" style="margin:0"><b>{{'contracts.final_amount' | translate}}:</b></p>
</ion-col>
<ion-col size="3">
<p text-right style="margin:0"><b>${{ final_amount | number: '1.2-2'}}</b></p>
<p class="ion-text-end" style="margin:0"><b>${{ final_amount | number: '1.2-2'}}</b></p>
</ion-col>
</ion-row>
<br>
@@ -71,10 +71,10 @@
</ion-row>
<ion-row>
<ion-col size="6">
<p text-center>{{'cards.openpay_2' | translate}}<p>
<p class="ion-text-center">{{'cards.openpay_2' | translate}}<p>
</ion-col>
<ion-col size="6" style="border-left: 1px solid #d0d0d0">
<p text-center>{{'cards.openpay_3' | translate}}<p>
<p class="ion-text-center">{{'cards.openpay_3' | translate}}<p>
</ion-col>
</ion-row>
<ion-row>

View File

@@ -16,23 +16,24 @@ declare var OpenPay: any;
selector: 'app-hire',
templateUrl: './hire.page.html',
styleUrls: ['./hire.page.scss'],
standalone: false
})
export class HirePage implements OnInit {
private loading;
private loading: HTMLIonLoadingElement | null = null;
code_check = true;
cards = [];
code= null;
device_id = null;
card_id = null;
supplier = null;
supplier_id = null;
postulation_id = null;
fee = null;
cards: any[] = [];
code: any = null;
device_id: any = null;
card_id: any = null;
supplier: any = null;
supplier_id: any = null;
postulation_id: any = null;
fee: any = null;
discount = 0;
final_amount = null;
coupon = null;
cards_menu = null;
final_amount: any = null;
coupon: any = null;
cards_menu: any = null;
paymentBypass = false;
constructor(
@@ -109,16 +110,16 @@ export class HirePage implements OnInit {
this.loading.present();
});
this.ichambaService.checkCoupon(this.postulation_id, this.supplier_id, this.coupon).subscribe(
data => {
(data: any) => {
if (data) {
if (data['name'] == "used") {
this.loading.dismiss();
if (this.loading) this.loading.dismiss();
this.alertService.presentToast(this.translateService.instant('alerts.coupon_used'));
} else if (data['name'] == "expired") {
this.loading.dismiss();
if (this.loading) this.loading.dismiss();
this.alertService.presentToast(this.translateService.instant('alerts.coupon_expired'));
} else if (data['name'] == this.coupon) {
this.loading.dismiss();
if (this.loading) this.loading.dismiss();
this.discount = (data['amount'] + (this.fee * (data['percentage']/100)));
console.log(this.discount);
if (this.discount > this.fee){
@@ -128,17 +129,17 @@ export class HirePage implements OnInit {
console.log(this.final_amount);
this.alertService.presentToast(this.translateService.instant('alerts.coupon_valid'));
} else if (data['name'] == "success") {
this.loading.dismiss();
if (this.loading) this.loading.dismiss();
this.events.publish('refreshpcontracts', 'data');
this.navCtrl.navigateRoot('/contracts/contracted');
this.alertService.presentToast(this.translateService.instant('alerts.hire'));
}
} else {
this.loading.dismiss();
if (this.loading) this.loading.dismiss();
this.alertService.presentToast(this.translateService.instant('alerts.nocoupon'));
}
}, error => {
this.loading.dismiss();
}, (error: any) => {
if (this.loading) this.loading.dismiss();
this.alertService.presentToast(this.translateService.instant('alerts.error') + error['status']);
});
}
@@ -152,24 +153,24 @@ export class HirePage implements OnInit {
this.loading.present();
});
this.ichambaService.createContract(this.postulation_id, this.supplier_id, 'BYPASS', this.coupon, '000', 'BYPASS').subscribe(
data => {
(data: any) => {
if (data['type'] == "error") {
this.loading.dismiss();
if (this.loading) this.loading.dismiss();
this.alertService.presentToast(data['message']);
} else if (data['name'] == "used") {
this.loading.dismiss();
if (this.loading) this.loading.dismiss();
this.alertService.presentToast(this.translateService.instant('contracts.coupon_used'));
} else if (data['name'] == "expired") {
this.loading.dismiss();
if (this.loading) this.loading.dismiss();
this.alertService.presentToast(this.translateService.instant('contracts.coupon_expired'));
} else {
this.loading.dismiss();
if (this.loading) this.loading.dismiss();
this.events.publish('refreshpcontracts', 'data');
this.navCtrl.navigateRoot('/contracts/contracted');
this.alertService.presentToast(this.translateService.instant('alerts.hire'));
}
}, error => {
this.loading.dismiss();
}, (error: any) => {
if (this.loading) this.loading.dismiss();
this.alertService.presentToast(this.translateService.instant('alerts.error') + error['status']);
});
return;
@@ -186,24 +187,24 @@ export class HirePage implements OnInit {
this.loading.present();
});
this.ichambaService.createContract(this.postulation_id, this.supplier_id, this.card_id, this.coupon, code, device_id).subscribe(
data => {
(data: any) => {
if (data['type'] == "error") {
this.loading.dismiss();
if (this.loading) this.loading.dismiss();
this.alertService.presentToast(data['message']);
} else if (data['name'] == "used") {
this.loading.dismiss();
if (this.loading) this.loading.dismiss();
this.alertService.presentToast(this.translateService.instant('contracts.coupon_used'));
} else if (data['name'] == "expired") {
this.loading.dismiss();
if (this.loading) this.loading.dismiss();
this.alertService.presentToast(this.translateService.instant('contracts.coupon_expired'));
} else {
this.loading.dismiss();
if (this.loading) this.loading.dismiss();
this.events.publish('refreshpcontracts', 'data');
this.navCtrl.navigateRoot('/contracts/contracted');
this.alertService.presentToast(this.translateService.instant('alerts.hire'));
}
}, error => {
this.loading.dismiss();
}, (error: any) => {
if (this.loading) this.loading.dismiss();
this.alertService.presentToast(this.translateService.instant('alerts.error') + error['status']);
});
//console.log(onSuccess.data.id);

View File

@@ -12,6 +12,7 @@ import { DomSanitizer } from '@angular/platform-browser';
selector: 'app-nohome',
templateUrl: './nohome.page.html',
styleUrls: ['./nohome.page.scss'],
standalone: false
})
export class NohomePage implements OnInit {
@@ -81,7 +82,7 @@ export class NohomePage implements OnInit {
send() {
this.ichambaService.noHomeConfirm(this.contract_id, this.myPosition.latitude, this.myPosition.longitude, this.description).subscribe(
data => {
(data: any) => {
this.alertService.presentToast(data['message']);
this.navCtrl.navigateRoot('/dashboard');
}, error => {

View File

@@ -6,18 +6,18 @@
<ion-title>{{'contracts.header' | translate}}</ion-title>
</ion-toolbar>
</ion-header>
<ion-content padding>
<h2 text-capitalize style="padding-bottom: 0.5em">{{'contracts.header_1' | translate}}</h2>
<ion-content class="ion-padding">
<h2 class="ion-text-capitalize" style="padding-bottom: 0.5em">{{'contracts.header_1' | translate}}</h2>
<ion-refresher slot="fixed" (ionRefresh)="refresh($event)">
<ion-refresher-content></ion-refresher-content>
</ion-refresher>
<ion-card *ngFor="let pcontract of pcontracts; let i = index">
<ion-item>
<ion-label>
<h2 *ngIf="lang===true" text-capitalize>{{ pcontract.category }}</h2>
<h2 *ngIf="lang===false" text-capitalize>{{ pcontract.en_category }}</h2>
<p text-wrap>{{pcontract.address}}</p>
<p text-wrap text-capitalize>{{pcontracts_dates[i]}}</p>
<h2 *ngIf="lang===true" class="ion-text-capitalize">{{ pcontract.category }}</h2>
<h2 *ngIf="lang===false" class="ion-text-capitalize">{{ pcontract.en_category }}</h2>
<p class="ion-text-wrap">{{pcontract.address}}</p>
<p class="ion-text-wrap ion-text-capitalize">{{pcontracts_dates[i]}}</p>
</ion-label>
<ion-button style="height: 3em; padding-left: 0.5em;" color="secondary" (click)="viewsuppliers(pcontract.id)">{{'contracts.viewsuppliers_1.1' | translate}}<br>{{'contracts.viewsuppliers_1.2' | translate}}</ion-button>
</ion-item>

View File

@@ -12,12 +12,13 @@ import { AlertService } from 'src/app/services/alert.service';
selector: 'app-pending',
templateUrl: './pending.page.html',
styleUrls: ['./pending.page.scss'],
standalone: false
})
export class PendingPage implements OnInit {
pcontracts = [];
pcontracts_dates = [];
lang: boolean;
pcontracts: any[] = [];
pcontracts_dates: any[] = [];
lang: boolean = false;
constructor(
private modalController: ModalController,
@@ -45,7 +46,7 @@ export class PendingPage implements OnInit {
}
}
refresh (event) {
refresh (event: any) {
this.ichambaService.getPendingcontracts().subscribe(
data => {
this.pcontracts = data;

View File

@@ -6,18 +6,18 @@
<ion-title>Contratos</ion-title>
</ion-toolbar>
</ion-header>
<ion-content padding>
<h2 text-capitalize style="padding-bottom: 0.5em">Reagendados</h2>
<ion-content class="ion-padding">
<h2 class="ion-text-capitalize" style="padding-bottom: 0.5em">Reagendados</h2>
<ng-container *ngFor="let ccontract of ccontracts; let i = index">
<ion-card *ngIf="ccontract.status==2">
<ion-item>
<ion-label>
<h2 text-capitalize>{{ ccontract.category }}</h2>
<p text-wrap>{{ ccontract.address }}</p>
<p text-wrap text-capitalize>{{ ccontracts_dates[i] }}</p>
<p text-wrap text-capitalize>Proveedor: {{ ccontract.supplier }}</p>
<h2 class="ion-text-capitalize">{{ ccontract.category }}</h2>
<p class="ion-text-wrap">{{ ccontract.address }}</p>
<p class="ion-text-wrap ion-text-capitalize">{{ ccontracts_dates[i] }}</p>
<p class="ion-text-wrap ion-text-capitalize">Proveedor: {{ ccontract.supplier }}</p>
<p>Monto: ${{ ccontract.amount }}</p>
<p *ngIf="ccontract.time_limit < 10" text-wrap>Código de inicio de servicio: ${{ ccontract.code }} (Por favor, dar este código
<p *ngIf="ccontract.time_limit < 10" class="ion-text-wrap">Código de inicio de servicio: ${{ ccontract.code }} (Por favor, dar este código
al proveedor para iniciar el servicio)</p>
</ion-label>
<ion-button style="height: 3em; padding-left: 0.5em;" color="danger">Cancelar<br>contrato</ion-button>

View File

@@ -10,11 +10,12 @@ import { AlertService } from 'src/app/services/alert.service';
selector: 'app-redated',
templateUrl: './redated.page.html',
styleUrls: ['./redated.page.scss'],
standalone: false
})
export class RedatedPage implements OnInit {
ccontracts = [];
ccontracts_dates = [];
ccontracts: any[] = [];
ccontracts_dates: any[] = [];
constructor(
private modalController: ModalController,

View File

@@ -6,8 +6,8 @@
<ion-title>{{'contracts.report_header' | translate}}</ion-title>
</ion-toolbar>
</ion-header>
<ion-content padding>
<h2 text-center>{{'contracts.report_description' | translate}}</h2>
<ion-content class="ion-padding">
<h2 class="ion-text-center">{{'contracts.report_description' | translate}}</h2>
<ion-item>
<ion-textarea [(ngModel)]="comment">{{'contracts.report_commentaries' | translate}}</ion-textarea>
</ion-item>

View File

@@ -12,11 +12,12 @@ import { AlertService } from 'src/app/services/alert.service';
selector: 'app-report',
templateUrl: './report.page.html',
styleUrls: ['./report.page.scss'],
standalone: false
})
export class ReportPage implements OnInit {
private loading;
contract_id: number = null;
private loading: HTMLIonLoadingElement | null = null;
contract_id: number | null = null;
comment: any;
constructor(
@@ -40,13 +41,13 @@ export class ReportPage implements OnInit {
this.loading = overlay;
this.loading.present();
});
this.ichambaService.reportContract(this.contract_id, this.comment).subscribe(
data => {
this.loading.dismiss();
this.ichambaService.reportContract(this.contract_id!, this.comment).subscribe(
(data: any) => {
if (this.loading) this.loading.dismiss();
this.alertService.presentToast(this.translateService.instant('alerts.report_send'));
this.navCtrl.navigateRoot('/dashboard');
}, error => {
this.loading.dismiss();
}, (error: any) => {
if (this.loading) this.loading.dismiss();
this.alertService.presentToast("Por favor contacte a soporte técnico, Estatus:" + error['status']);
});
} else {

View File

@@ -6,8 +6,8 @@
<ion-title>{{'contracts.review_header' | translate}}</ion-title>
</ion-toolbar>
</ion-header>
<ion-content padding>
<h2 text-center>{{'contracts.review_description' | translate}}</h2>
<ion-content class="ion-padding">
<h2 class="ion-text-center">{{'contracts.review_description' | translate}}</h2>
<div class="rate_div">
<rating [(ngModel)]="rate"
readonly="false"

View File

@@ -11,12 +11,13 @@ import { AlertService } from 'src/app/services/alert.service';
selector: 'app-review',
templateUrl: './review.page.html',
styleUrls: ['./review.page.scss'],
standalone: false
})
export class ReviewPage implements OnInit {
private loading;
private loading: HTMLIonLoadingElement | null = null;
rate: any;
contract_id: number = null;
contract_id: number | null = null;
comment: any;
constructor(
@@ -33,7 +34,7 @@ export class ReviewPage implements OnInit {
this.contract_id = Number(this.activatedRoute.snapshot.paramMap.get('contract_id'));
}
onRateChange(rating){
onRateChange(rating: any){
console.log("changed rating: " + rating);
// do your stuff
}
@@ -44,13 +45,13 @@ export class ReviewPage implements OnInit {
this.loading = overlay;
this.loading.present();
});
this.ichambaService.reviewContract(this.contract_id, this.rate, this.comment).subscribe(
data => {
this.loading.dismiss();
this.ichambaService.reviewContract(this.contract_id!, this.rate, this.comment).subscribe(
(data: any) => {
if (this.loading) this.loading.dismiss();
this.alertService.presentToast(data['message']);
this.navCtrl.navigateRoot('/dashboard');
}, error => {
this.loading.dismiss();
}, (error: any) => {
if (this.loading) this.loading.dismiss();
this.alertService.presentToast(this.translateService.instant('alerts.error') + error['status']);
});
} else {

View File

@@ -18,10 +18,10 @@ ion-input{
<ion-title>{{'contracts.start_header' | translate}}</ion-title>
</ion-toolbar>
</ion-header>
<ion-content padding>
<ion-content class="ion-padding">
<form #form="ngForm" id="start_form" (ngSubmit)="startservice(form)" method="post">
<h1 text-center>{{'contracts.start_description_1.1' | translate}}</h1>
<ion-row text-center>
<h1 class="ion-text-center">{{'contracts.start_description_1.1' | translate}}</h1>
<ion-row class="ion-text-center">
<ion-col>
<ion-input ngModel name="otp1" #otp1 required maxLength="1" type="number" (keyup)="otpController($event,otp2,'')">
</ion-input>
@@ -37,7 +37,7 @@ ion-input{
</ion-input>
</ion-col>
</ion-row>
<p text-justify>{{'contracts.start_description_1.2' | translate}}</p>
<p class="ion-text-justify">{{'contracts.start_description_1.2' | translate}}</p>
<br>
<ion-button type="submit" expand="full" color="primary">{{'contracts.start_send' | translate}}</ion-button>
</form>

View File

@@ -10,11 +10,12 @@ import { AlertService } from 'src/app/services/alert.service';
selector: 'app-start',
templateUrl: './start.page.html',
styleUrls: ['./start.page.scss'],
standalone: false
})
export class StartPage implements OnInit {
private loading;
pin: number = null;
private loading: HTMLIonLoadingElement | null = null;
pin: number | null = null;
constructor(
private authService: AuthService,
@@ -28,7 +29,7 @@ export class StartPage implements OnInit {
ngOnInit() {
}
otpController(event,next,prev){
otpController(event: any, next: any, prev: any){
if (event.target.value.length > 1){
event.target.value = event.target.value.slice(-1);
next.setFocus();
@@ -49,18 +50,18 @@ export class StartPage implements OnInit {
this.loading = overlay;
this.loading.present();
});
this.ichambaService.startContract(this.pin).subscribe(
data => {
this.ichambaService.startContract(this.pin!).subscribe(
(data: any) => {
if (data['message'] == "No service") {
this.loading.dismiss();
if (this.loading) this.loading.dismiss();
this.alertService.presentToast("No hay ningún servicio agendado a esta hora");
} else {
this.loading.dismiss();
if (this.loading) this.loading.dismiss();
this.alertService.presentToast(data['message']);
this.navCtrl.navigateRoot('/dashboard');
}
}, error => {
this.loading.dismiss();
}, (error: any) => {
if (this.loading) this.loading.dismiss();
this.alertService.presentToast("Por favor contacte a soporte técnico, Estatus:" + error['status']);
});
console.log(form.value.otp1 + form.value.otp2 + form.value.otp3 + form.value.otp4 + form.value.otp5 + form.value.otp6)
@@ -72,19 +73,19 @@ export class StartPage implements OnInit {
this.loading.present();
});
this.ichambaService.noHomeCheck().subscribe(
data => {
(data: any) => {
if (data['message'] == "wait") {
this.loading.dismiss();
if (this.loading) this.loading.dismiss();
this.alertService.presentToast("Por favor espere a los 10 minutos de tolerancia de la hora acordada");
} else if (data['message'] == "no-contract") {
this.loading.dismiss();
if (this.loading) this.loading.dismiss();
this.alertService.presentToast("No hay contratos citados a esta hora");
} else {
this.loading.dismiss();
if (this.loading) this.loading.dismiss();
this.navCtrl.navigateForward(['/nohome/', data['id']]);
}
}, error => {
this.loading.dismiss();
}, (error: any) => {
if (this.loading) this.loading.dismiss();
this.alertService.presentToast("Por favor contacte a soporte técnico, Estatus:" + error['status']);
}
);

View File

@@ -4,6 +4,7 @@ import { Component, OnInit } from '@angular/core';
selector: 'app-comments',
templateUrl: './comments.page.html',
styleUrls: ['./comments.page.scss'],
standalone: false
})
export class CommentsPage implements OnInit {

View File

@@ -6,11 +6,11 @@
<ion-title>{{'contracts.viewsuppliers_header' | translate}}</ion-title>
</ion-toolbar>
</ion-header>
<ion-content padding>
<h3 *ngIf="lang===true" text-capitalize>{{ pcontractssuppliers_category[0] }}</h3>
<h3 *ngIf="lang===false" text-capitalize>{{ pcontractssuppliers_en_category[0] }}</h3>
<p text-capitalize>{{ pcontractssuppliers_address[0] }}</p>
<p text-capitalize style="margin-top: -0.6em">{{ pcontractssuppliers_dates[0] }}</p>
<ion-content class="ion-padding">
<h3 *ngIf="lang===true" class="ion-text-capitalize">{{ pcontractssuppliers_category[0] }}</h3>
<h3 *ngIf="lang===false" class="ion-text-capitalize">{{ pcontractssuppliers_en_category[0] }}</h3>
<p class="ion-text-capitalize">{{ pcontractssuppliers_address[0] }}</p>
<p class="ion-text-capitalize" style="margin-top: -0.6em">{{ pcontractssuppliers_dates[0] }}</p>
<ion-refresher slot="fixed" (ionRefresh)="refresh($event)">
<ion-refresher-content></ion-refresher-content>
</ion-refresher>
@@ -20,11 +20,11 @@
</ion-card-header>
<ion-item *ngIf="pcontractsupplier.supplier != null">
<ion-label>
<h2 text-wrap text-capitalize *ngIf="pcontractsupplier.supplier != null">{{ pcontractsupplier.supplier }}</h2>
<p text-wrap *ngIf="pcontractsupplier.supplier != null"><ion-icon name="checkmark-circle" color="secondary" *ngIf="pcontractsupplier.membership != false"></ion-icon> {{ pcontractssuppliers_certified[i] }}</p>
<p text-wrap *ngIf="pcontractsupplier.supplier != null">{{'contracts.viewsuppliers_tags' | translate}}: {{ pcontractsupplier.tags }}</p>
<p text-wrap *ngIf="pcontractsupplier.supplier != null">{{'contracts.viewsuppliers_fee' | translate}}: ${{ pcontractsupplier.fee }}</p>
<p text-wrap *ngIf="pcontractsupplier.supplier != null">{{'contracts.viewsuppliers_rate' | translate}}: {{ pcontractsupplier.score }} de 5 <ion-icon name="star"></ion-icon></p>
<h2 class="ion-text-wrap ion-text-capitalize" *ngIf="pcontractsupplier.supplier != null">{{ pcontractsupplier.supplier }}</h2>
<p class="ion-text-wrap" *ngIf="pcontractsupplier.supplier != null"><ion-icon name="checkmark-circle" color="secondary" *ngIf="pcontractsupplier.membership != false"></ion-icon> {{ pcontractssuppliers_certified[i] }}</p>
<p class="ion-text-wrap" *ngIf="pcontractsupplier.supplier != null">{{'contracts.viewsuppliers_tags' | translate}}: {{ pcontractsupplier.tags }}</p>
<p class="ion-text-wrap" *ngIf="pcontractsupplier.supplier != null">{{'contracts.viewsuppliers_fee' | translate}}: ${{ pcontractsupplier.fee }}</p>
<p class="ion-text-wrap" *ngIf="pcontractsupplier.supplier != null">{{'contracts.viewsuppliers_rate' | translate}}: {{ pcontractsupplier.score }} de 5 <ion-icon name="star"></ion-icon></p>
</ion-label>
<ion-button style="height: 3em; padding-left: 0.5em;" color="secondary" (click)="hiresupplier(pcontractsupplier.supplier_id, pcontractsupplier.id, pcontractsupplier.supplier, pcontractsupplier.fee)">{{'contracts.viewsuppliers_hire' | translate}}</ion-button>
</ion-item>

View File

@@ -14,19 +14,20 @@ import { HirePage } from '../hire/hire.page';
selector: 'app-viewsuppliers',
templateUrl: './viewsuppliers.page.html',
styleUrls: ['./viewsuppliers.page.scss'],
standalone: false
})
export class ViewsuppliersPage implements OnInit {
postulation_id = null;
pcontractssuppliers = [];
pcontractssuppliers_dates = [];
pcontractssuppliers_certified = [];
pcontractssuppliers_category = [];
pcontractssuppliers_en_category = [];
pcontractssuppliers_address = [];
pcontractssuppliers_amount = [];
pcontractssuppliers_fee = [];
lang: boolean;
postulation_id: string | null = null;
pcontractssuppliers: any[] = [];
pcontractssuppliers_dates: any[] = [];
pcontractssuppliers_certified: any[] = [];
pcontractssuppliers_category: any[] = [];
pcontractssuppliers_en_category: any[] = [];
pcontractssuppliers_address: any[] = [];
pcontractssuppliers_amount: any[] = [];
pcontractssuppliers_fee: any[] = [];
lang: boolean = false;
constructor(
private modalController: ModalController,
@@ -45,7 +46,7 @@ export class ViewsuppliersPage implements OnInit {
ngOnInit() {
this.postulation_id = this.activatedRoute.snapshot.paramMap.get('postulation_id');
this.getPostulants(this.postulation_id);
this.getPostulants(this.postulation_id ?? '');
if (this.languageService.getDefaultLanguage() == 'es') {
this.lang = true;
} else {
@@ -53,9 +54,9 @@ export class ViewsuppliersPage implements OnInit {
}
}
refresh(event) {
this.ichambaService.getPostulants(this.postulation_id).subscribe(
data => {
refresh(event: any) {
this.ichambaService.getPostulants(this.postulation_id ?? '').subscribe(
(data: any) => {
this.pcontractssuppliers = data;
for (var i of this.pcontractssuppliers) {
if (this.languageService.getDefaultLanguage() == 'es') {
@@ -80,7 +81,7 @@ export class ViewsuppliersPage implements OnInit {
getPostulants(postulation_id: String) {
this.ichambaService.getPostulants(postulation_id).subscribe(
data => {
(data: any) => {
this.pcontractssuppliers = data;
for (var i of this.pcontractssuppliers) {
if (this.languageService.getDefaultLanguage() == 'es') {

View File

@@ -26,7 +26,7 @@ ion-item:active:after {
<ion-title>{{'dashboard.header' | translate}}</ion-title>
</ion-toolbar>
</ion-header>
<ion-content padding>
<ion-content class="ion-padding">
<div class="autocomplete">
<ion-searchbar
(ionInput)="search($event)"
@@ -42,47 +42,47 @@ ion-item:active:after {
<ion-refresher slot="fixed" (ionRefresh)="refresh($event)">
<ion-refresher-content></ion-refresher-content>
</ion-refresher>
<ng-container *ngIf="user != undefined">
<ng-container *ngIf="authService.isLoggedIn">
<div *ngIf="!isContract">
<ion-card style="box-shadow:none">
<img class="ion-justify-content-center" src="/assets/slides/ic_dashboard.svg" style="max-width:22.5em; margin:auto"/>
<ion-text color="dark" class="ion-text-center"><h2>{{'dashboard.slogan' | translate}}</h2></ion-text>
<h3 class="ion-text-center" color="medium">{{'dashboard.welcome' | translate}} {{ user["name"] }}</h3>
<h3 class="ion-text-center" color="medium">{{'dashboard.welcome' | translate}} {{ authService.userName }}</h3>
</ion-card>
</div>
</ng-container>
<ng-container *ngIf="pcontracts?.length > 0">
<h2 text-capitalize style="padding-bottom: 0.5em">{{'contracts.header_1' | translate}}</h2>
<h2 class="ion-text-capitalize" style="padding-bottom: 0.5em">{{'contracts.header_1' | translate}}</h2>
</ng-container>
<ion-card *ngFor="let pcontract of pcontracts; let i = index">
<ion-item>
<ion-label>
<h2 text-capitalize>{{ pcontract.category }}</h2>
<h2 class="ion-text-capitalize">{{ pcontract.category }}</h2>
<ion-progress-bar type="indeterminate"></ion-progress-bar>
<p text-wrap><ion-icon name="search"></ion-icon> {{'contracts.postulating' | translate}}</p>
<p text-wrap>{{pcontract.address}}</p>
<p text-wrap text-capitalize>{{pcontracts_dates[i]}}</p>
<p class="ion-text-wrap"><ion-icon name="search"></ion-icon> {{'contracts.postulating' | translate}}</p>
<p class="ion-text-wrap">{{pcontract.address}}</p>
<p class="ion-text-wrap ion-text-capitalize">{{pcontracts_dates[i]}}</p>
</ion-label>
<ion-button style="height: 3em; padding-left: 0.5em;" color="secondary" (click)="viewsuppliers(pcontract.id)">{{'contracts.viewsuppliers_1.1' | translate}}<br>{{'contracts.viewsuppliers_1.2' | translate}}</ion-button>
</ion-item>
</ion-card>
<ng-container *ngIf="ccontracts?.length > 0">
<h2 text-capitalize style="padding-bottom: 0.5em">{{'contracts.header_2' | translate}}</h2>
<h2 class="ion-text-capitalize" style="padding-bottom: 0.5em">{{'contracts.header_2' | translate}}</h2>
</ng-container>
<ng-container *ngFor="let ccontract of ccontracts; let i = index">
<ion-card *ngIf="ccontract.status==1">
<ion-item style="--border-color: #fff">
<ion-label>
<h2 *ngIf="lang===true" text-capitalize>{{ ccontract.category }}</h2>
<h2 *ngIf="lang===false" text-capitalize>{{ ccontract.en_category }}</h2>
<p text-wrap><ion-icon name="briefcase"></ion-icon> {{'contracts.hired' | translate}}</p>
<p text-wrap>{{ ccontract.address }}</p>
<p text-wrap text-capitalize>{{ ccontracts_dates[i] }}</p>
<p text-wrap text-capitalize>{{'contracts.supplier' | translate}}: {{ ccontract.supplier }}</p>
<p text-wrap>{{'contracts.phone' | translate}}: <a href="tel:{{ ccontract.phone }}">{{ ccontract.phone }}</a></p>
<p text-wrap>{{'contracts.amount' | translate}}: ${{ ccontract.amount }}</p>
<h2 text-wrap>{{'contracts.start_pin' | translate}}<b>{{ ccontract.code }}</b></h2>
<p text-wrap>{{'contracts.info_pin' | translate}}</p>
<h2 *ngIf="lang===true" class="ion-text-capitalize">{{ ccontract.category }}</h2>
<h2 *ngIf="lang===false" class="ion-text-capitalize">{{ ccontract.en_category }}</h2>
<p class="ion-text-wrap"><ion-icon name="briefcase"></ion-icon> {{'contracts.hired' | translate}}</p>
<p class="ion-text-wrap">{{ ccontract.address }}</p>
<p class="ion-text-wrap ion-text-capitalize">{{ ccontracts_dates[i] }}</p>
<p class="ion-text-wrap ion-text-capitalize">{{'contracts.supplier' | translate}}: {{ ccontract.supplier }}</p>
<p class="ion-text-wrap">{{'contracts.phone' | translate}}: <a href="tel:{{ ccontract.phone }}">{{ ccontract.phone }}</a></p>
<p class="ion-text-wrap">{{'contracts.amount' | translate}}: ${{ ccontract.amount }}</p>
<h2 class="ion-text-wrap">{{'contracts.start_pin' | translate}}<b>{{ ccontract.code }}</b></h2>
<p class="ion-text-wrap">{{'contracts.info_pin' | translate}}</p>
</ion-label>
</ion-item>
<ion-button *ngIf="ccontract.past_due < 0" style="height: 4.0em; padding-right: 1.0em; padding-bottom:1.0em; float: right" color="danger" (click)="cancelContract(ccontract.id, ccontract.date)">{{'contracts.cancel_1.1' | translate}}<br>{{'contracts.cancel_1.2' | translate}}</ion-button>

View File

@@ -13,11 +13,13 @@ import { User } from 'src/app/models/user';
selector: 'app-dashboard',
templateUrl: './dashboard.page.html',
styleUrls: ['./dashboard.page.scss'],
standalone: false
})
export class DashboardPage implements OnInit {
private loading: any;
user!: User;
userName: string = '';
categories: any[] = [];
aux_categories: any[] = [];
showList: boolean = false;
@@ -31,7 +33,7 @@ export class DashboardPage implements OnInit {
constructor(
private menu: MenuController,
private navCtrl: NavController,
private authService: AuthService,
public authService: AuthService,
private ichambaService: IchambaService,
private alertService: AlertService,
private translateService: TranslateService,
@@ -62,7 +64,7 @@ export class DashboardPage implements OnInit {
this.getccontracts();
}
refresh(event) {
refresh(event: any) {
this.getpcontracts();
this.ichambaService.getCurrentcontracts().subscribe(
data => {
@@ -144,10 +146,10 @@ export class DashboardPage implements OnInit {
this.presentAlert(id)
} else { */
this.ichambaService.cancelContract(id).subscribe(
data => {
(data: any) => {
this.getccontracts();
this.alertService.presentToast(data['message']);
}, error => {
}, (error: any) => {
this.alertService.presentToast(this.translateService.instant('alerts.error') + error['status']);
});
//}
@@ -188,7 +190,7 @@ check(category_string: String) {
this.navCtrl.navigateForward(['/category/', category_string])
} else {
this.loading.dismiss();
this.alertService.presentToast(this.translateService.instant('alerts.error'));
this.alertService.presentToast(this.translateService.instant('alerts.no_service'));
}
}, error => {
this.loading.dismiss();
@@ -198,12 +200,6 @@ check(category_string: String) {
}
ionViewWillEnter() {
this.authService.user().subscribe(
user => {
this.user = user;
// TODO: Send OneSignal tag when Capacitor plugin is configured
// OneSignal.sendTag("iChamba_ID", user['id'].toString());
}
);
this.authService.user().subscribe({ error: () => {} });
}
}

View File

@@ -8,7 +8,7 @@
</ion-header>
<ion-content>
<h2 padding text-capitalize style="padding-bottom: 0.25em">{{'faq.header' | translate}}</h2>
<h2 class="ion-padding ion-text-capitalize" style="padding-bottom: 0.25em">{{'faq.header' | translate}}</h2>
<ion-accordion-group [multiple]="true" [value]="['first', 'third']">
<ion-accordion>
<ion-item slot="header" color="light">
@@ -18,49 +18,49 @@
</ion-accordion>
<ion-accordion>
<ion-item slot="header" color="light">
<ion-label>{{'faq.faq_2' | translate}}®</ion-label>
<ion-label>{{'faq.faq_2' | translate}}</ion-label>
</ion-item>
<div class="ion-padding" slot="content">{{'faq.faq_2.1' | translate}}</div>
</ion-accordion>
<ion-accordion>
<ion-item slot="header" color="light">
<ion-label>{{'faq.faq_3' | translate}}®</ion-label>
<ion-label>{{'faq.faq_3' | translate}}</ion-label>
</ion-item>
<div class="ion-padding" slot="content">{{'faq.faq_3.1' | translate}}</div>
</ion-accordion>
<ion-accordion>
<ion-item slot="header" color="light">
<ion-label>{{'faq.faq_4' | translate}}®</ion-label>
<ion-label>{{'faq.faq_4' | translate}}</ion-label>
</ion-item>
<div class="ion-padding" slot="content">{{'faq.faq_4.1' | translate}}</div>
</ion-accordion>
<ion-accordion>
<ion-item slot="header" color="light">
<ion-label>{{'faq.faq_5' | translate}}®</ion-label>
<ion-label>{{'faq.faq_5' | translate}}</ion-label>
</ion-item>
<div class="ion-padding" slot="content">{{'faq.faq_5.1' | translate}}</div>
</ion-accordion>
<ion-accordion>
<ion-item slot="header" color="light">
<ion-label>{{'faq.faq_6' | translate}}®</ion-label>
<ion-label>{{'faq.faq_6' | translate}}</ion-label>
</ion-item>
<div class="ion-padding" slot="content">{{'faq.faq_6.1' | translate}}</div>
</ion-accordion>
<ion-accordion>
<ion-item slot="header" color="light">
<ion-label>{{'faq.faq_7' | translate}}®</ion-label>
<ion-label>{{'faq.faq_7' | translate}}</ion-label>
</ion-item>
<div class="ion-padding" slot="content">{{'faq.faq_7.1' | translate}}</div>
</ion-accordion>
<ion-accordion>
<ion-item slot="header" color="light">
<ion-label>{{'faq.faq_8' | translate}}®</ion-label>
<ion-label>{{'faq.faq_8' | translate}}</ion-label>
</ion-item>
<div class="ion-padding" slot="content">{{'faq.faq_8.1' | translate}}</div>
</ion-accordion>
<ion-accordion>
<ion-item slot="header" color="light">
<ion-label>{{'faq.faq_9' | translate}}®</ion-label>
<ion-label>{{'faq.faq_9' | translate}}</ion-label>
</ion-item>
<div class="ion-padding" slot="content">{{'faq.faq_9.1' | translate}}</div>
</ion-accordion>

View File

@@ -4,6 +4,7 @@ import { Component, OnInit } from '@angular/core';
selector: 'app-faq',
templateUrl: './faq.page.html',
styleUrls: ['./faq.page.scss'],
standalone: false
})
export class FaqPage implements OnInit {

View File

@@ -6,6 +6,10 @@ ion-footer {
--ion-background-color: #175ccc;
}
ion-footer ion-button::part(native) {
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}
ion-header ion-toolbar {
--min-height: 60px;
}

View File

@@ -11,6 +11,7 @@ register();
selector: 'app-landing',
templateUrl: './landing.page.html',
styleUrls: ['./landing.page.scss'],
standalone: false
})
export class LandingPage implements OnInit {

View File

@@ -6,8 +6,8 @@
<ion-title>Postulaciones</ion-title>
</ion-toolbar>
</ion-header>
<ion-content padding>
<h2 text-capitalize style="padding-bottom: 0.5em">Ya contratado</h2>
<ion-content class="ion-padding">
<h2 class="ion-text-capitalize" style="padding-bottom: 0.5em">Ya contratado</h2>
<ion-refresher slot="fixed" (ionRefresh)="refresh($event)">
<ion-refresher-content></ion-refresher-content>
</ion-refresher>
@@ -15,13 +15,13 @@
<ion-card>
<ion-item>
<ion-label>
<h2 text-capitalize>{{ postulation.category }}</h2>
<ion-text color="primary"><p text-wrap (click)="openMaps(postulation.lat, postulation.lng)"><b><u>{{postulation.address}}</u></b></p></ion-text>
<p text-wrap>Télefono: <a href="tel:{{ postulation.phone }}">{{ postulation.phone }}</a></p>
<p text-wrap>Referencias: {{postulation.references}}</p>
<p text-wrap text-capitalize>{{postulations_dates[i]}}</p>
<p text-wrap>Monto: {{postulation.amount}}</p>
<p text-wrap>Detalles: {{postulation.details}}</p>
<h2 class="ion-text-capitalize">{{ postulation.category }}</h2>
<ion-text color="primary"><p class="ion-text-wrap" (click)="openMaps(postulation.lat, postulation.lng)"><b><u>{{postulation.address}}</u></b></p></ion-text>
<p class="ion-text-wrap">Télefono: <a href="tel:{{ postulation.phone }}">{{ postulation.phone }}</a></p>
<p class="ion-text-wrap">Referencias: {{postulation.references}}</p>
<p class="ion-text-wrap ion-text-capitalize">{{postulations_dates[i]}}</p>
<p class="ion-text-wrap">Monto: {{postulation.amount}}</p>
<p class="ion-text-wrap">Detalles: {{postulation.details}}</p>
</ion-label>
</ion-item>
</ion-card>

View File

@@ -11,6 +11,7 @@ import { Browser } from '@capacitor/browser';
selector: 'app-already',
templateUrl: './already.page.html',
styleUrls: ['./already.page.scss'],
standalone: false
})
export class AlreadyPage implements OnInit {

View File

@@ -6,8 +6,8 @@
<ion-title>Postulaciones</ion-title>
</ion-toolbar>
</ion-header>
<ion-content padding>
<h2 text-capitalize style="padding-bottom: 0.5em">Por postularse</h2>
<ion-content class="ion-padding">
<h2 class="ion-text-capitalize" style="padding-bottom: 0.5em">Por postularse</h2>
<ion-refresher slot="fixed" (ionRefresh)="refresh($event)">
<ion-refresher-content></ion-refresher-content>
</ion-refresher>
@@ -15,12 +15,12 @@
<ion-card *ngIf="!postulation.already_post">
<ion-item>
<ion-label>
<h2 text-capitalize>{{ postulation.category }}</h2>
<ion-text color="primary"><p text-wrap (click)="openMaps(postulation.lat, postulation.lng)"><b><u>{{postulation.address}}</u></b></p></ion-text>
<p text-wrap>Referencias: {{postulation.references}}</p>
<p text-wrap text-capitalize>{{postulations_dates[i]}}</p>
<p text-wrap>Detalles: {{postulation.details}}</p>
<p text-wrap>Tiempo restante: {{postulation.time_limit}} minutos</p>
<h2 class="ion-text-capitalize">{{ postulation.category }}</h2>
<ion-text color="primary"><p class="ion-text-wrap" (click)="openMaps(postulation.lat, postulation.lng)"><b><u>{{postulation.address}}</u></b></p></ion-text>
<p class="ion-text-wrap">Referencias: {{postulation.references}}</p>
<p class="ion-text-wrap ion-text-capitalize">{{postulations_dates[i]}}</p>
<p class="ion-text-wrap">Detalles: {{postulation.details}}</p>
<p class="ion-text-wrap">Tiempo restante: {{postulation.time_limit}} minutos</p>
</ion-label>
<ion-button style="height: 3em; padding-left: 0.5em;" color="secondary" (click)="addpostulation(postulation.id)">Postularse</ion-button>
</ion-item>

View File

@@ -11,6 +11,7 @@ import { Browser } from '@capacitor/browser';
selector: 'app-current',
templateUrl: './current.page.html',
styleUrls: ['./current.page.scss'],
standalone: false
})
export class CurrentPage implements OnInit {
@@ -35,7 +36,7 @@ export class CurrentPage implements OnInit {
this.getpostulations();
}
refresh(event) {
refresh(event: any) {
this.ichambaService.getPostulation().subscribe(
data => {
this.postulations = data;
@@ -63,10 +64,10 @@ export class CurrentPage implements OnInit {
addpostulation(id: String) {
this.ichambaService.setPostulation(id).subscribe(
data => {
(data: any) => {
this.getpostulations();
this.alertService.presentToast(data['message']);
}, error => {
}, (error: any) => {
this.alertService.presentToast("Por favor contacte a soporte técnico, Estatus:" + error['status']);
});
}

View File

@@ -6,8 +6,8 @@
<ion-title>Postulaciones</ion-title>
</ion-toolbar>
</ion-header>
<ion-content padding>
<h2 text-capitalize style="padding-bottom: 0.5em">Finalizadas</h2>
<ion-content class="ion-padding">
<h2 class="ion-text-capitalize" style="padding-bottom: 0.5em">Finalizadas</h2>
<ion-refresher slot="fixed" (ionRefresh)="refresh($event)">
<ion-refresher-content></ion-refresher-content>
</ion-refresher>
@@ -15,10 +15,10 @@
<ion-card>
<ion-item>
<ion-label>
<h2 text-capitalize>{{ postulation.category }}</h2>
<p text-wrap>{{ postulation.address }}</p>
<p text-wrap text-capitalize>{{ postulations_dates[i] }}</p>
<p text-wrap text-capitalize>Estado: {{ postulation.status }}</p>
<h2 class="ion-text-capitalize">{{ postulation.category }}</h2>
<p class="ion-text-wrap">{{ postulation.address }}</p>
<p class="ion-text-wrap ion-text-capitalize">{{ postulations_dates[i] }}</p>
<p class="ion-text-wrap ion-text-capitalize">Estado: {{ postulation.status }}</p>
</ion-label>
<br>
</ion-item>

View File

@@ -10,11 +10,12 @@ import { AlertService } from 'src/app/services/alert.service';
selector: 'app-ended',
templateUrl: './ended.page.html',
styleUrls: ['./ended.page.scss'],
standalone: false
})
export class EndedPage implements OnInit {
postulations = [];
postulations_dates = [];
postulations: any[] = [];
postulations_dates: any[] = [];
constructor(
private modalController: ModalController,
@@ -35,7 +36,7 @@ export class EndedPage implements OnInit {
this.getfinishedpostulations();
}
refresh(event) {
refresh(event: any) {
this.ichambaService.getFinishedPostulation().subscribe(
data => {
this.postulations = data;

View File

@@ -10,6 +10,7 @@ import { AlertService } from 'src/app/services/alert.service';
selector: 'app-postulations',
templateUrl: './postulations.page.html',
styleUrls: ['./postulations.page.scss'],
standalone: false
})
export class PostulationsPage implements OnInit {

View File

@@ -4,6 +4,7 @@ import { Component, OnInit } from '@angular/core';
selector: 'app-reports',
templateUrl: './reports.page.html',
styleUrls: ['./reports.page.scss'],
standalone: false
})
export class ReportsPage implements OnInit {

View File

@@ -0,0 +1,33 @@
import { Injectable } from '@angular/core';
import { HttpInterceptor, HttpRequest, HttpHandler, HttpEvent, HttpErrorResponse } from '@angular/common/http';
import { Observable, throwError } from 'rxjs';
import { catchError } from 'rxjs/operators';
import { NavController } from '@ionic/angular';
import { Preferences } from '@capacitor/preferences';
import { getApps } from 'firebase/app';
import { getAuth, signOut as firebaseSignOut } from 'firebase/auth';
@Injectable({ providedIn: 'root' })
export class AuthInterceptorService implements HttpInterceptor {
constructor(private navCtrl: NavController) {}
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
return next.handle(req).pipe(
catchError((error: HttpErrorResponse) => {
if (error.status === 401) {
this.clearAndRedirect();
}
return throwError(() => error);
})
);
}
private clearAndRedirect() {
Preferences.remove({ key: 'token' });
if (getApps().length > 0) {
firebaseSignOut(getAuth()).catch(() => {});
}
this.navCtrl.navigateRoot('/login');
}
}

View File

@@ -1,11 +1,14 @@
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { EventService } from './event.service';
import { tap } from 'rxjs/operators';
import { of, firstValueFrom } from 'rxjs';
import { tap, catchError } from 'rxjs/operators';
import { Router } from '@angular/router';
import { Preferences } from '@capacitor/preferences';
import { EnvService } from './env.service';
import { User } from '../models/user';
import { getAuth, signOut as firebaseSignOut } from 'firebase/auth';
import { getApps } from 'firebase/app';
@Injectable({
providedIn: 'root'
@@ -15,9 +18,12 @@ export class AuthService {
isLoggedIn = false;
isVerified = false;
isReported = false;
userName: string = '';
userRole: number = 0;
role: any;
token:any;
userInfo:any;
token: any;
userInfo: any;
private initPromise: Promise<void> | null = null;
constructor(
private http: HttpClient,
@@ -26,11 +32,11 @@ export class AuthService {
private router: Router
) { }
login(email: String, password: String) {
return this.http.post(this.env.API_URL + 'auth/login',
{email: email, password: password}
loginWithFirebase(idToken: string) {
return this.http.post(this.env.API_URL + 'auth/firebase',
{ firebase_token: idToken }
).pipe(
tap(token => {
tap((token: any) => {
if (token['verified'] != null) {
this.isVerified = true;
}
@@ -38,101 +44,90 @@ export class AuthService {
this.isReported = true;
}
Preferences.set({ key: 'token', value: JSON.stringify(token) })
.then(
() => {
.then(() => {
console.log('Token Stored');
}
).catch(error => console.error('Error storing item', error));
}).catch(error => console.error('Error storing item', error));
this.token = token;
this.isLoggedIn = true;
this.userRole = token['role'] ?? 0;
this.events.publish('set_role', token['role']);
return token;
}),
);
}
login_register_fb(fb_token: String, fb_id: String) {
return this.http.post(this.env.API_URL + 'auth/fb',
{access_token: fb_token, social_id: fb_id + "_facebook"}
).pipe(
tap(token => {
if (token['verified'] != null) {
this.isVerified = true;
}
if (token['reported'] == 1) {
this.isReported = true;
}
Preferences.set({ key: 'token', value: JSON.stringify(token) })
.then(
() => {
console.log('Token Stored');
}
).catch(error => console.error('Error storing item', error));
this.token = token;
this.isLoggedIn = true;
this.events.publish('set_role', token['role']);
return token;
}),
);
}
login_register_googlePlus(google_token: String, google_id: String) {
return this.http.post(this.env.API_URL + 'auth/google',
{access_token: google_token}
).pipe(
tap(token => {
if (token['verified'] != null) {
this.isVerified = true;
}
if (token['reported'] == 1) {
this.isReported = true;
}
Preferences.set({ key: 'token', value: JSON.stringify(token) })
.then(
() => {
console.log('Token Stored');
}
).catch(error => console.error('Error storing item', error));
this.token = token;
this.isLoggedIn = true;
this.events.publish('set_role', token['role']);
return token;
}),
);
}
register(name: String, email: String, phone: Number, password: String) {
registerWithFirebase(idToken: string, name: string, phone: string, email: string) {
return this.http.post(this.env.API_URL + 'auth/register',
{name: name, email: email, phone: phone, password: password, secret: this.env.SECRET}
)
{ firebase_token: idToken, name: name, phone: phone, email: email }
).pipe(
tap((token: any) => {
if (token['verified'] != null) {
this.isVerified = true;
}
Preferences.set({ key: 'token', value: JSON.stringify(token) })
.catch(error => console.error('Error storing item', error));
this.token = token;
this.isLoggedIn = true;
this.events.publish('set_role', token['role']);
return token;
})
);
}
logout() {
const headers = new HttpHeaders({
'Authorization': this.token["token_type"]+" "+this.token["access_token"]
});
return this.http.get(this.env.API_URL + 'auth/logout', { headers: headers })
.pipe(
tap(data => {
this.clearSession();
const tokenType = this.token?.['token_type'];
const accessToken = this.token?.['access_token'];
if (!tokenType || !accessToken) {
return of(null);
}
const headers = new HttpHeaders({ 'Authorization': `${tokenType} ${accessToken}` });
return this.http.get(this.env.API_URL + 'auth/logout', { headers }).pipe(
catchError(() => of(null))
);
}
initialize(): Promise<void> {
if (!this.initPromise) {
this.initPromise = this.runInitialize();
}
return this.initPromise;
}
private async runInitialize(): Promise<void> {
await this.getToken();
if (this.isLoggedIn) {
try {
await firstValueFrom(this.user());
} catch {
this.clearSession();
}
}
}
clearSession() {
this.initPromise = null;
if (getApps().length > 0) {
firebaseSignOut(getAuth()).catch(() => {});
}
Preferences.remove({ key: 'token' });
this.isLoggedIn = false;
this.isVerified = false;
this.userName = '';
this.userRole = 0;
delete this.token;
return data;
},
error => {
Preferences.remove({ key: 'token' });
this.isLoggedIn = false;
this.isVerified = false;
})
)
}
user() {
if (!this.token?.['token_type'] || !this.token?.['access_token']) {
return of(null);
}
const headers = new HttpHeaders({
'Authorization': this.token["token_type"]+" "+this.token["access_token"]
});
return this.http.get<User>(this.env.API_URL + 'auth/user', { headers: headers })
.pipe(
tap(user => {
tap((user: any) => {
if (user['phone_verified_at'] != null) {
this.isVerified = true;
} else {
@@ -143,9 +138,10 @@ export class AuthService {
} else {
this.isReported = false;
}
this.userName = user['name'] ?? '';
this.userRole = user['role_id'] ?? 0;
this.events.publish('set_role', user['role_id']);
console.log("after login:", user);
return user;
})
)
}
@@ -177,8 +173,4 @@ export class AuthService {
{ phone: phone_string }, { headers: headers });
}
forgot(email: String) {
return this.http.post(this.env.API_URL + 'auth/forgot/password',
{ email: email });
}
}

View File

@@ -4,7 +4,7 @@ import { Injectable } from '@angular/core';
providedIn: 'root'
})
export class EnvService {
API_URL = 'https://jobhero-api.consultoria-as.com/api/';
API_URL = 'http://jobhero.test/api/';
SECRET = 'wBIIKuDbrxNKzQhAUGiZLoaoQ4MichAN3wP2AP7B';
MERCHANT_ID = 'm9k4beuso5az0wjqztvt';
PUBLIC_API_KEY = 'pk_9465179493384689a8d2da9adc825411';

View File

@@ -0,0 +1,63 @@
import { Injectable } from '@angular/core';
import { initializeApp, getApps, FirebaseApp } from 'firebase/app';
import {
getAuth,
Auth,
GoogleAuthProvider,
OAuthProvider,
signInWithPopup,
signInWithEmailAndPassword,
createUserWithEmailAndPassword,
sendPasswordResetEmail,
signOut,
UserCredential
} from 'firebase/auth';
import { environment } from 'src/environments/environment';
@Injectable({
providedIn: 'root'
})
export class FirebaseAuthService {
private app: FirebaseApp;
private auth: Auth;
constructor() {
// Avoid re-initializing if Firebase is already initialized
this.app = getApps().length > 0
? getApps()[0]
: initializeApp(environment.firebaseConfig);
this.auth = getAuth(this.app);
}
async signInWithGoogle(): Promise<string> {
const provider = new GoogleAuthProvider();
const credential: UserCredential = await signInWithPopup(this.auth, provider);
return credential.user.getIdToken();
}
async signInWithApple(): Promise<string> {
const provider = new OAuthProvider('apple.com');
provider.addScope('email');
provider.addScope('name');
const credential: UserCredential = await signInWithPopup(this.auth, provider);
return credential.user.getIdToken();
}
async signInWithEmail(email: string, password: string): Promise<string> {
const credential: UserCredential = await signInWithEmailAndPassword(this.auth, email, password);
return credential.user.getIdToken();
}
async registerWithEmail(email: string, password: string): Promise<string> {
const credential: UserCredential = await createUserWithEmailAndPassword(this.auth, email, password);
return credential.user.getIdToken();
}
async sendPasswordReset(email: string): Promise<void> {
return sendPasswordResetEmail(this.auth, email);
}
async signOut(): Promise<void> {
return signOut(this.auth);
}
}

View File

@@ -26,6 +26,10 @@ export class IchambaService {
return this.http.get<any[]>(this.env.API_URL + 'parameters');
}
getBanks() {
return this.http.get<any[]>(this.env.API_URL + 'banks');
}
checkCategories(category_string: String) {
const headers = new HttpHeaders({
'Authorization': this.authService.token["token_type"]+" "+this.authService.token["access_token"]
@@ -201,11 +205,11 @@ export class IchambaService {
{ contract_id: contract_id, amount: amount, card_id: card_id, code: code, device_id: device_id }, { headers: headers });
}
addHero(name: String, categories: String, tags: String, address: String, lat: Number, lng: Number, reference_options: Number, reference: String) {
addHero(name: String, rfc: String, categories: String, tags: String, address: String, lat: Number, lng: Number, bank: Number, bank_account: Number, fee: Number, reference_options: Number, reference: String) {
const headers = new HttpHeaders({
'Authorization': this.authService.token["token_type"]+" "+this.authService.token["access_token"]
});
return this.http.post(this.env.API_URL + 'add-hero',
{name: name, categories: categories, tags: tags, address: address, lat: lat, lng: lng, reference_options: reference_options, reference: reference}, { headers: headers });
{name: name, rfc: rfc, categories: categories, tags: tags, address: address, lat: lat, lng: lng, bank: bank, bank_account: bank_account, fee: fee, reference_options: reference_options, reference: reference}, { headers: headers });
}
}

View File

@@ -11,13 +11,13 @@ export class LanguageService {
) { }
getDefaultLanguage() {
let language = this.translate.getBrowserLang();
let language = this.translate.getBrowserLang() ?? 'es';
this.translate.setDefaultLang(language);
console.log(language);
return language;
}
setLanguage(setLang) {
setLanguage(setLang: string) {
this.translate.use(setLang);
}
}

View File

@@ -6,7 +6,7 @@
<ion-title>Verificar Telefono</ion-title>
</ion-toolbar>
</ion-header>
<ion-content padding>
<ion-content class="ion-padding">
<form #form="ngForm" (ngSubmit)="verifyMe(form)" method="post">
<ion-button type="submit" expand="full" color="facebook">Verificame</ion-button>
</form>

View File

@@ -8,7 +8,8 @@ import { AlertService } from 'src/app/services/alert.service';
@Component({
selector: 'app-verify',
templateUrl: 'verify.page.html',
styleUrls: ['verify.page.scss']
styleUrls: ['verify.page.scss'],
standalone: false
})
export class VerifyPage implements OnInit {
@@ -28,12 +29,12 @@ export class VerifyPage implements OnInit {
// auth.service.ts
verifyMe(form: NgForm) {
this.authService.verifyUser(this.phone_string).subscribe(
data => {
(data: any) => {
console.log(data);
this.authService.isVerified = true
this.navCtrl.navigateRoot('/dashboard')
},
error => {
(error: any) => {
console.log(error);
}
);
@@ -44,11 +45,11 @@ export class VerifyPage implements OnInit {
await this.loading.present();
this.authService.logout().subscribe(
data => {
(data: any) => {
this.alertService.presentToast("Sesión finalizada");
// TODO: Clear OneSignal tag when Capacitor plugin is configured
},
error => {
(error: any) => {
if (this.loading) this.loading.dismiss();
console.log(error);
},

View File

@@ -14,7 +14,7 @@
"login": "Log in",
"signup": "Sign up",
"forgot": "Forgot your password?",
"fb_login": "Continue with Facebook",
"apple_login": "Continue with Apple",
"google_login": "Continue with Google",
"email": "Email",
"password": "Password",
@@ -142,7 +142,12 @@
"keywords_hint": "Separate keywords with commas",
"address": "Address",
"discover": "How did you hear about us?",
"select": "Select",
"discover_details": "Please specify how you found out about us",
"bank": "Bank",
"bank_account": "Bank account",
"fee": "Minimum fee",
"required": "Field required",
"signup": "Sign up",
"radio": "Radio",
"tv": "TV",

View File

@@ -14,7 +14,7 @@
"login": "Iniciar sesión",
"signup": "Registrate",
"forgot": "¿Olvidó su contraseña?",
"fb_login": "Iniciar sesión con Facebook",
"apple_login": "Iniciar sesión con Apple",
"google_login": "Iniciar sesión con Google",
"email": "Correo electrónico",
"password": "Contraseña",
@@ -142,7 +142,12 @@
"keywords_hint": "Separa las palabras clave con comas",
"address": "Dirección",
"discover": "¿Cómo supiste de nosotros?",
"select": "Seleccionar",
"discover_details": "Específica como supiste de nosotros",
"bank": "Banco",
"bank_account": "CLABE Interbancaria",
"fee": "Cuota mínima",
"required": "Campo requerido",
"signup": "Registrarse",
"radio": "Radio",
"tv": "TV",

View File

@@ -1,3 +1,12 @@
export const environment = {
production: true
production: true,
firebaseConfig: {
apiKey: 'AIzaSyAX-O73xSGMAXL6OaQYyTEsZ6ykxPG2ZOo',
authDomain: 'ichamba-1562349005909.firebaseapp.com',
databaseURL: 'https://ichamba-1562349005909.firebaseio.com',
projectId: 'ichamba-1562349005909',
storageBucket: 'ichamba-1562349005909.firebasestorage.app',
messagingSenderId: '679874302148',
appId: '1:679874302148:web:ffb4c82c0f94e412007991'
}
};

View File

@@ -1,16 +1,12 @@
// This file can be replaced during build by using the `fileReplacements` array.
// `ng build --prod` replaces `environment.ts` with `environment.prod.ts`.
// The list of file replacements can be found in `angular.json`.
export const environment = {
production: false
production: false,
firebaseConfig: {
apiKey: 'AIzaSyAX-O73xSGMAXL6OaQYyTEsZ6ykxPG2ZOo',
authDomain: 'ichamba-1562349005909.firebaseapp.com',
databaseURL: 'https://ichamba-1562349005909.firebaseio.com',
projectId: 'ichamba-1562349005909',
storageBucket: 'ichamba-1562349005909.firebasestorage.app',
messagingSenderId: '679874302148',
appId: '1:679874302148:web:ffb4c82c0f94e412007991'
}
};
/*
* For easier debugging in development mode, you can import the following file
* to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`.
*
* This import should be commented out in production mode because it will have a negative impact
* on performance if an error is thrown.
*/
// import 'zone.js/dist/zone-error'; // Included with Angular CLI.

View File

@@ -35,7 +35,7 @@
* will put import in the top of bundle, so user need to create a separate file
* in this directory (for example: zone-flags.ts), and put the following flags
* into that file, and then add the following code before importing zone.js.
* import './zone-flags.ts';
* import './zone-flags';
*
* The flags allowed in zone-flags.ts are listed here.
*
@@ -52,7 +52,7 @@
*
*/
import './zone-flags.ts';
import './zone-flags';
/***************************************************************************************************
* Zone JS is required by default for Angular itself.

View File

@@ -1,22 +1,24 @@
{
"compileOnSave": false,
"compilerOptions": {
"skipLibCheck": true,
"baseUrl": "./",
"skipLibCheck": true,
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"module": "esnext",
"moduleResolution": "node",
"module": "ES2022",
"moduleResolution": "bundler",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"importHelpers": true,
"target": "es5",
"target": "ES2022",
"useDefineForClassFields": false,
"ignoreDeprecations": "6.0",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2018",
"ES2022",
"dom"
]
},