Compare commits
7 Commits
dev_alex
...
aa8b0061c9
| Author | SHA1 | Date | |
|---|---|---|---|
| aa8b0061c9 | |||
| db0d0001fa | |||
| 0efe318db3 | |||
|
|
9f2a0d62e0 | ||
|
|
22e4585bb9 | ||
| 4afaf69d10 | |||
| 68673baf99 |
@@ -16,8 +16,17 @@ android {
|
||||
ignoreAssetsPattern '!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~'
|
||||
}
|
||||
}
|
||||
signingConfigs {
|
||||
release {
|
||||
storeFile file('../../jobhero-release.keystore')
|
||||
storePassword 'JobHero2024!'
|
||||
keyAlias 'jobhero'
|
||||
keyPassword 'JobHero2024!'
|
||||
}
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
signingConfig signingConfigs.release
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -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
1
capacitor.config.json
Normal file
@@ -0,0 +1 @@
|
||||
{}
|
||||
22092
package-lock.json
generated
22092
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
53
package.json
53
package.json
@@ -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"
|
||||
}
|
||||
|
||||
@@ -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()">
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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())
|
||||
]
|
||||
})
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -2,15 +2,12 @@ import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { IonicModule } from '@ionic/angular';
|
||||
|
||||
|
||||
|
||||
@NgModule({
|
||||
declarations: [AccordionComponent],
|
||||
declarations: [],
|
||||
imports: [
|
||||
CommonModule,
|
||||
IonicModule
|
||||
],
|
||||
exports: [
|
||||
]
|
||||
exports: []
|
||||
})
|
||||
export class SharedComponentsModule { }
|
||||
|
||||
@@ -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
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// not logged in so redirect to login page with the return url
|
||||
|
||||
if (this.authService.isLoggedIn) {
|
||||
return true;
|
||||
}
|
||||
|
||||
this.router.navigate(['/landing']);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import { AuthService } from '../services/auth.service';
|
||||
})
|
||||
export class AuthoriginGuard implements CanActivate {
|
||||
|
||||
user: User;
|
||||
user!: User;
|
||||
|
||||
constructor(
|
||||
private router: Router,
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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'));
|
||||
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'));
|
||||
},
|
||||
error => {
|
||||
this.loading.dismiss();
|
||||
this.alertService.presentToast(this.translateService.instant('alerts.error') + error['message']);
|
||||
console.log(error);
|
||||
},
|
||||
() => {
|
||||
this.dismissForgot();
|
||||
} else {
|
||||
this.alertService.presentToast(this.translateService.instant('alerts.error') + e.message);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,68 +47,73 @@ 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 => {
|
||||
if (this.loading) this.loading.dismiss();
|
||||
if (JSON.stringify(error['status']) == '401') {
|
||||
this.alertService.presentToast(this.translateService.instant('alerts.login_error'));
|
||||
}
|
||||
else {
|
||||
this.alertService.presentToast(this.translateService.instant('alerts.error') + error['message']);
|
||||
console.log(error);
|
||||
}
|
||||
},
|
||||
() => {
|
||||
if (this.loading) this.loading.dismiss();
|
||||
this.dismissLogin();
|
||||
this.navCtrl.navigateRoot('/dashboard');
|
||||
this.alertService.presentToast(this.translateService.instant('alerts.login'));
|
||||
}
|
||||
);
|
||||
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 {
|
||||
this.alertService.presentToast(this.translateService.instant('alerts.error') + error['message']);
|
||||
}
|
||||
},
|
||||
() => { this.navigateAfterLogin(); }
|
||||
);
|
||||
} catch (e: any) {
|
||||
if (this.loading) this.loading.dismiss();
|
||||
const msg = this.getFirebaseErrorMessage(e.code);
|
||||
this.alertService.presentToast(msg);
|
||||
}
|
||||
}
|
||||
|
||||
async loginFacebook() {
|
||||
this.loading = await this.loadingCtrl.create();
|
||||
await this.loading.present();
|
||||
private async navigateAfterLogin() {
|
||||
try {
|
||||
await firstValueFrom(this.authService.user());
|
||||
} catch { }
|
||||
if (this.loading) this.loading.dismiss();
|
||||
this.navCtrl.navigateRoot('/dashboard');
|
||||
this.alertService.presentToast(this.translateService.instant('alerts.login'));
|
||||
}
|
||||
|
||||
try {
|
||||
// Login with permissions
|
||||
const result = await FacebookLogin.login({ permissions: ['public_profile', 'email'] });
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
if (result.accessToken) {
|
||||
// Get user ID and Token
|
||||
const fb_id = result.accessToken.userId;
|
||||
const fb_token = result.accessToken.token;
|
||||
async loginApple() {
|
||||
this.loading = await this.loadingCtrl.create();
|
||||
await this.loading.present();
|
||||
|
||||
console.log("ID: " + fb_id);
|
||||
console.log("Token: " + fb_token);
|
||||
try {
|
||||
const idToken = await this.firebaseAuthService.signInWithApple();
|
||||
|
||||
this.authService.login_register_fb(fb_token, fb_id).subscribe(
|
||||
data => {
|
||||
},
|
||||
error => {
|
||||
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'));
|
||||
}
|
||||
);
|
||||
} else {
|
||||
this.loading.dismiss();
|
||||
this.alertService.presentToast(this.translateService.instant('alerts.timeout_error'));
|
||||
}
|
||||
} catch (e) {
|
||||
this.loading.dismiss();
|
||||
this.alertService.presentToast(this.translateService.instant('alerts.error') + e);
|
||||
}
|
||||
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.navigateAfterLogin(); }
|
||||
);
|
||||
} catch (e) {
|
||||
if (this.loading) this.loading.dismiss();
|
||||
this.alertService.presentToast(this.translateService.instant('alerts.error') + e);
|
||||
}
|
||||
}
|
||||
|
||||
async loginGoogle() {
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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) {
|
||||
|
||||
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();
|
||||
this.alertService.presentToast(this.translateService.instant('alerts.signup_error'));
|
||||
}
|
||||
else {
|
||||
this.loading.dismiss();
|
||||
console.log(error);
|
||||
this.alertService.presentToast(this.translateService.instant('alerts.error') + error['message']);
|
||||
}
|
||||
},
|
||||
() => {
|
||||
|
||||
}
|
||||
);
|
||||
} else {
|
||||
this.alertService.presentToast(this.translateService.instant('alerts.signup_error_1'));
|
||||
}
|
||||
} else {
|
||||
this.alertService.presentToast(this.translateService.instant('alerts.signup_error_2'));
|
||||
}
|
||||
} else {
|
||||
async register(form: NgForm) {
|
||||
if (!this.terms) {
|
||||
this.alertService.presentToast(this.translateService.instant('alerts.signup_error_3'));
|
||||
return;
|
||||
}
|
||||
|
||||
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.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.error') + e.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async openTerms() {
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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']);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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)">
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -25,16 +25,16 @@
|
||||
</ion-item>
|
||||
<ion-item>
|
||||
<ion-label position="fixed">{{'categories.address' | translate}}</ion-label>
|
||||
<ion-input [(ngModel)]="addressAutocomplete" (ionChange)="autocomplete($event)" value="{{ myAddress }}" (ionFocus)="showlist()"></ion-input>
|
||||
<ion-input [(ngModel)]="addressAutocomplete" (ionInput)="autocomplete($event)" (ionFocus)="showlist()"></ion-input>
|
||||
</ion-item>
|
||||
<ion-list *ngIf="showif">
|
||||
<ion-item button=true (click)="geoloc(places.place_id, places.description, places.terms[1].value)" *ngFor="let places of placesSearch" class="place">
|
||||
<ion-list *ngIf="showif && placesSearch && placesSearch.length > 0">
|
||||
<ion-item button=true (click)="geoloc(places.place_id, places.description)" *ngFor="let places of placesSearch" class="place">
|
||||
{{ places.description }}
|
||||
</ion-item>
|
||||
</ion-list>
|
||||
<ion-item hidden>
|
||||
<ion-item>
|
||||
<ion-label position="fixed">{{'categories.int_number' | translate}}</ion-label>
|
||||
<ion-input value="{{ myIntnumber }}" disabled></ion-input>
|
||||
<ion-input [(ngModel)]="myIntnumber" placeholder="Opcional"></ion-input>
|
||||
</ion-item>
|
||||
<ion-item>
|
||||
<ion-label position="fixed">{{'categories.references' | translate}}</ion-label>
|
||||
|
||||
@@ -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'];
|
||||
});
|
||||
@@ -102,6 +103,7 @@ export class CategoryPage implements OnInit {
|
||||
const address = results[0].formatted_address;
|
||||
console.log("data_: ", address);
|
||||
this.myAddress = address;
|
||||
this.addressAutocomplete = address; // Sincronizar con el input
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -134,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);
|
||||
@@ -142,12 +144,12 @@ export class CategoryPage implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
geoloc(place_id: string, place_description: string, place_intnumber: string) {
|
||||
geoloc(place_id: string, place_description: string) {
|
||||
this.myAddress = place_description;
|
||||
this.myIntnumber = place_intnumber;
|
||||
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 = {
|
||||
@@ -193,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 {
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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']);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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">
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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>
|
||||
@@ -41,7 +41,7 @@
|
||||
<ion-button style="height: 3em" item-end (click)="checkCoupon()" expand="full" color="primary">{{'contracts.validate' | translate}}</ion-button>
|
||||
</ion-item>
|
||||
</ion-list>
|
||||
<ion-item>
|
||||
<ion-item *ngIf="!paymentBypass">
|
||||
<ion-label>{{'cards.card' | translate}}</ion-label>
|
||||
<ion-select style="max-width:90%" interface="action-sheet" [(ngModel)]="cards_menu" (ionChange)="selected_card($event)">
|
||||
<ion-select-option>Agregar tarjeta</ion-select-option>
|
||||
@@ -49,13 +49,18 @@
|
||||
</ion-select>
|
||||
</ion-item>
|
||||
<form #form="ngForm" id="card_form" (ngSubmit)="createContract(form)" method="post">
|
||||
<ion-item [class.ng-invalid]="!code_check">
|
||||
<ion-item *ngIf="!paymentBypass" [class.ng-invalid]="!code_check">
|
||||
<ion-label position="floating">CVV</ion-label>
|
||||
<ion-input type="password" ngModel name="code" (ionChange)="code_checker($event)" [class.ng-invalid]="!code_check" size="3" maxlength="4"></ion-input>
|
||||
</ion-item><br><br>
|
||||
</ion-item>
|
||||
<ion-note *ngIf="paymentBypass" color="warning" style="display: block; text-align: center; margin: 1em 0;">
|
||||
<b>MODO DE PRUEBA:</b> El pago será simulado
|
||||
</ion-note>
|
||||
<br><br>
|
||||
<ion-button type="submit" expand="full" color="secondary">{{'contracts.hire_confirm' | translate}}</ion-button>
|
||||
</form>
|
||||
<br>
|
||||
<div *ngIf="!paymentBypass">
|
||||
<ion-row class="ion-align-items-center">
|
||||
<ion-col size="4">
|
||||
<img src="/assets/openpay/openpay_color.png" style="padding:0.25em 0.5em"/>
|
||||
@@ -66,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>
|
||||
@@ -106,4 +111,5 @@
|
||||
<img src="/assets/openpay/bbva.png"/>
|
||||
</ion-col>
|
||||
</ion-row>
|
||||
</div>
|
||||
</ion-content>
|
||||
|
||||
@@ -16,23 +16,25 @@ 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(
|
||||
private modalController: ModalController,
|
||||
@@ -59,11 +61,14 @@ export class HirePage implements OnInit {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
OpenPay.setId(this.env.MERCHANT_ID);
|
||||
OpenPay.setApiKey(this.env.PUBLIC_API_KEY);
|
||||
console.log(OpenPay.getSandboxMode());
|
||||
var deviceDataId = OpenPay.deviceData.setup("card_form");
|
||||
this.getcards();
|
||||
this.paymentBypass = this.env.PAYMENT_BYPASS;
|
||||
if (!this.paymentBypass) {
|
||||
OpenPay.setId(this.env.MERCHANT_ID);
|
||||
OpenPay.setApiKey(this.env.PUBLIC_API_KEY);
|
||||
console.log(OpenPay.getSandboxMode());
|
||||
var deviceDataId = OpenPay.deviceData.setup("card_form");
|
||||
this.getcards();
|
||||
}
|
||||
}
|
||||
|
||||
newcard() {
|
||||
@@ -105,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){
|
||||
@@ -124,23 +129,53 @@ 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']);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
createContract(form: NgForm) {
|
||||
// Si el bypass está activo, enviar con valores dummy
|
||||
if (this.paymentBypass) {
|
||||
this.loadingCtrl.create().then((overlay) => {
|
||||
this.loading = overlay;
|
||||
this.loading.present();
|
||||
});
|
||||
this.ichambaService.createContract(this.postulation_id, this.supplier_id, 'BYPASS', this.coupon, '000', 'BYPASS').subscribe(
|
||||
(data: any) => {
|
||||
if (data['type'] == "error") {
|
||||
if (this.loading) this.loading.dismiss();
|
||||
this.alertService.presentToast(data['message']);
|
||||
} else if (data['name'] == "used") {
|
||||
if (this.loading) this.loading.dismiss();
|
||||
this.alertService.presentToast(this.translateService.instant('contracts.coupon_used'));
|
||||
} else if (data['name'] == "expired") {
|
||||
if (this.loading) this.loading.dismiss();
|
||||
this.alertService.presentToast(this.translateService.instant('contracts.coupon_expired'));
|
||||
} else {
|
||||
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: any) => {
|
||||
if (this.loading) this.loading.dismiss();
|
||||
this.alertService.presentToast(this.translateService.instant('alerts.error') + error['status']);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.card_id != "Agregar tarjeta") {
|
||||
if (this.code_check) {
|
||||
let code = form.value.code;
|
||||
@@ -152,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);
|
||||
|
||||
@@ -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 => {
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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']);
|
||||
}
|
||||
);
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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') {
|
||||
|
||||
@@ -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-progress-bar type="indeterminate"></ion-progress-bar>
|
||||
<ion-label>
|
||||
<h2 text-capitalize>{{ pcontract.category }}</h2>
|
||||
<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>
|
||||
<h2 class="ion-text-capitalize">{{ pcontract.category }}</h2>
|
||||
<ion-progress-bar type="indeterminate"></ion-progress-bar>
|
||||
<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>
|
||||
|
||||
@@ -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: () => {} });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
ion-accordion.accordion-expanding ion-item[slot='header'],
|
||||
ion-accordion.accordion-expanded ion-item[slot='header'] {
|
||||
--background: var(--ion-color-primary);
|
||||
--color: var(--ion-color-primary-contrast);
|
||||
--ion-color-base: var(--ion-color-primary) !important;
|
||||
--ion-color-contrast: var(--ion-color-primary-contrast) !important;
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -9,60 +9,124 @@
|
||||
</ion-toolbar>
|
||||
</ion-header>
|
||||
|
||||
<ion-content padding>
|
||||
<ion-item>
|
||||
<ion-content class="ion-padding">
|
||||
<ion-item [class.ion-invalid]="(submitted || touched['name']) && !name" [class.ion-touched]="submitted || touched['name']">
|
||||
<ion-label position="floating">{{'hero.name' | translate}}</ion-label>
|
||||
<ion-input [(ngModel)]="name"></ion-input>
|
||||
<ion-input [(ngModel)]="name" (ionBlur)="markTouched('name')"></ion-input>
|
||||
</ion-item>
|
||||
<br>
|
||||
<span class="error-msg" *ngIf="(submitted || touched['name']) && !name">{{'hero.required' | translate}}</span>
|
||||
|
||||
<ion-item>
|
||||
<ion-label>{{'hero.categories' | translate}}</ion-label>
|
||||
<ion-select [(ngModel)]="categories_input" multiple="true" okText="Aceptar" cancelText="Cancelar" placeholder="{{'hero.categories_placeholder' | translate}}">
|
||||
<ion-select-option *ngFor="let category of categories" [value]="category">{{category}}</ion-select-option>
|
||||
</ion-select>
|
||||
<ion-item [class.ion-invalid]="(submitted || touched['rfc']) && !rfc" [class.ion-touched]="submitted || touched['rfc']">
|
||||
<ion-label position="floating">RFC</ion-label>
|
||||
<ion-input [(ngModel)]="rfc" (ionBlur)="markTouched('rfc')"></ion-input>
|
||||
</ion-item>
|
||||
<br>
|
||||
<span class="error-msg" *ngIf="(submitted || touched['rfc']) && !rfc">{{'hero.required' | translate}}</span>
|
||||
|
||||
<ion-item>
|
||||
<ion-label position="floating">{{'hero.keywords' | translate}}</ion-label>
|
||||
<ion-input [(ngModel)]="keywords_text" placeholder="{{'hero.keywords_placeholder' | translate}}"></ion-input>
|
||||
</ion-item>
|
||||
<ion-note padding>{{'hero.keywords_hint' | translate}}</ion-note>
|
||||
|
||||
<ion-label color="light">_</ion-label>
|
||||
|
||||
<ion-item>
|
||||
<ion-label position="floating">Dirección</ion-label>
|
||||
<ion-input [(ngModel)]="addressAutocomplete" (ionChange)="autocomplete($event)" value="{{ myAddress }}" (ionFocus)="showlist()"></ion-input>
|
||||
</ion-item>
|
||||
<ion-list *ngIf="showif">
|
||||
<ion-item button=true (click)="geoloc(places.place_id, places.description, places.terms[1].value)" *ngFor="let places of placesSearch" class="place">
|
||||
{{ places.description }}
|
||||
<!-- CATEGORÍAS CON CHIPS -->
|
||||
<div class="dropdown-container">
|
||||
<ion-item class="tags-item" [class.ion-invalid]="(submitted || touched['categories']) && categories_input.length === 0" [class.ion-touched]="submitted || touched['categories']">
|
||||
<div class="tags-row">
|
||||
<span class="chip-section-label">{{'hero.categories' | translate}}</span>
|
||||
<ion-chip *ngFor="let cat of categories_input" color="primary">
|
||||
<ion-label>{{cat}}</ion-label>
|
||||
<ion-icon name="close-circle" (click)="removeCategory(cat)"></ion-icon>
|
||||
</ion-chip>
|
||||
<ion-input
|
||||
[(ngModel)]="categorySearchText"
|
||||
(ionInput)="filterCategories($event)"
|
||||
(ionBlur)="hideCategoryList()"
|
||||
[clearInput]="true"
|
||||
placeholder="{{'hero.categories_placeholder' | translate}}">
|
||||
</ion-input>
|
||||
</div>
|
||||
</ion-item>
|
||||
</ion-list>
|
||||
<ion-item hidden>
|
||||
<span class="error-msg" *ngIf="(submitted || touched['categories']) && categories_input.length === 0">Selecciona al menos una categoría</span>
|
||||
<ion-list *ngIf="showCategoryDropdown && filteredCategories.length > 0" class="dropdown-list">
|
||||
<ion-item *ngFor="let category of filteredCategories" button (click)="selectCategory(category)">
|
||||
{{category}}
|
||||
</ion-item>
|
||||
</ion-list>
|
||||
</div>
|
||||
|
||||
<!-- PALABRAS CLAVE CON CHIPS -->
|
||||
<ion-item class="tags-item">
|
||||
<div class="tags-row">
|
||||
<span class="chip-section-label">{{'hero.keywords' | translate}}</span>
|
||||
<ion-chip *ngFor="let keyword of keywords" color="primary">
|
||||
<ion-label>{{keyword}}</ion-label>
|
||||
<ion-icon name="close-circle" (click)="removeKeyword(keyword)"></ion-icon>
|
||||
</ion-chip>
|
||||
<ion-input
|
||||
[(ngModel)]="keywordInput"
|
||||
(keydown)="onKeywordKeydown($event)"
|
||||
(ionBlur)="addKeyword($event)"
|
||||
placeholder="{{'hero.keywords_placeholder' | translate}}">
|
||||
</ion-input>
|
||||
</div>
|
||||
</ion-item>
|
||||
<ion-note class="ion-padding">{{'hero.keywords_hint' | translate}}</ion-note>
|
||||
|
||||
<!-- DIRECCIÓN CON AUTOCOMPLETE FLOTANTE -->
|
||||
<div class="dropdown-container">
|
||||
<ion-item [class.ion-invalid]="(submitted || touched['address']) && !myAddress" [class.ion-touched]="submitted || touched['address']">
|
||||
<ion-label position="floating">{{'categories.address' | translate}}</ion-label>
|
||||
<ion-input [(ngModel)]="addressAutocomplete" (ionInput)="autocomplete($event)" (ionFocus)="showlist()" (ionBlur)="blurAddressList()" [clearInput]="true"></ion-input>
|
||||
</ion-item>
|
||||
<span class="error-msg" *ngIf="(submitted || touched['address']) && !myAddress">{{'alerts.valid_address' | translate}}</span>
|
||||
<ion-list *ngIf="showif && placesSearch?.length" class="dropdown-list">
|
||||
<ion-item button=true (click)="geoloc(places.place_id, places.description, places.terms[1].value)" *ngFor="let places of placesSearch" class="place">
|
||||
{{ places.description }}
|
||||
</ion-item>
|
||||
</ion-list>
|
||||
</div>
|
||||
|
||||
<ion-item class="ion-hide">
|
||||
<ion-label position="fixed">Latitud</ion-label>
|
||||
<ion-input value="{{ myPosition.latitude }}" disabled></ion-input>
|
||||
</ion-item>
|
||||
<ion-item hidden>
|
||||
<ion-item class="ion-hide">
|
||||
<ion-label position="fixed">Longitud</ion-label>
|
||||
<ion-input value="{{ myPosition.longitude }}" disabled></ion-input>
|
||||
</ion-item>
|
||||
<ion-item>
|
||||
<ion-label>{{'hero.discover' | translate}}</ion-label>
|
||||
<ion-select value={selectedReference} okText="Aceptar" cancelText="Cancelar" (ionChange)="selected_reference($event)">
|
||||
<ion-select-option value="1">{{'hero.radio' | translate}}</ion-select-option>
|
||||
<ion-select-option value="2">{{'hero.tv' | translate}}</ion-select-option>
|
||||
<ion-select-option value="3">{{'hero.social' | translate}}</ion-select-option>
|
||||
<ion-select-option value="4">{{'hero.friends' | translate}}</ion-select-option>
|
||||
<ion-select-option value="5">{{'hero.other' | translate}}</ion-select-option>
|
||||
|
||||
<ion-item [class.ion-invalid]="(submitted || touched['bank']) && selectedBank === null" [class.ion-touched]="submitted || touched['bank']">
|
||||
<ion-label>{{'hero.bank' | translate}}</ion-label>
|
||||
<ion-select [(ngModel)]="selectedBank" placeholder="{{'hero.select' | translate}}" okText="Aceptar" cancelText="Cancelar" (ionBlur)="markTouched('bank')">
|
||||
<ion-select-option *ngFor="let bank of banks" [value]="bank.id">{{bank.name}}</ion-select-option>
|
||||
</ion-select>
|
||||
</ion-item>
|
||||
<ion-item *ngIf="showinput">
|
||||
<ion-label position="floating">{{'hero.discover_details' | translate}}</ion-label>
|
||||
<ion-input [(ngModel)]="reference"></ion-input>
|
||||
<span class="error-msg" *ngIf="(submitted || touched['bank']) && selectedBank === null">{{'hero.required' | translate}}</span>
|
||||
|
||||
<ion-item [class.ion-invalid]="(submitted || touched['bankAccount']) && !bankAccount" [class.ion-touched]="submitted || touched['bankAccount']">
|
||||
<ion-label position="floating">{{'hero.bank_account' | translate}}</ion-label>
|
||||
<ion-input [(ngModel)]="bankAccount" type="number" (ionBlur)="markTouched('bankAccount')"></ion-input>
|
||||
</ion-item>
|
||||
<span class="error-msg" *ngIf="(submitted || touched['bankAccount']) && !bankAccount">{{'hero.required' | translate}}</span>
|
||||
|
||||
<ion-item [class.ion-invalid]="(submitted || touched['fee']) && fee === null" [class.ion-touched]="submitted || touched['fee']">
|
||||
<ion-label position="floating">{{'hero.fee' | translate}}</ion-label>
|
||||
<ion-input [(ngModel)]="feeDisplay" (ionInput)="onFeeInput($event)" (ionBlur)="markTouched('fee')" type="text" inputmode="decimal"></ion-input>
|
||||
</ion-item>
|
||||
<span class="error-msg" *ngIf="(submitted || touched['fee']) && fee === null">{{'hero.required' | translate}}</span>
|
||||
|
||||
<ion-item [class.ion-invalid]="(submitted || touched['reference']) && !selectedReference" [class.ion-touched]="submitted || touched['reference']">
|
||||
<ion-label>{{'hero.discover' | translate}}</ion-label>
|
||||
<ion-select [(ngModel)]="selectedReference" placeholder="{{'hero.select' | translate}}" okText="Aceptar" cancelText="Cancelar" (ionChange)="selected_reference($event)" (ionBlur)="markTouched('reference')">
|
||||
<ion-select-option [value]="1">{{'hero.radio' | translate}}</ion-select-option>
|
||||
<ion-select-option [value]="2">{{'hero.tv' | translate}}</ion-select-option>
|
||||
<ion-select-option [value]="3">{{'hero.social' | translate}}</ion-select-option>
|
||||
<ion-select-option [value]="4">{{'hero.friends' | translate}}</ion-select-option>
|
||||
<ion-select-option [value]="5">{{'hero.other' | translate}}</ion-select-option>
|
||||
</ion-select>
|
||||
</ion-item>
|
||||
<span class="error-msg" *ngIf="(submitted || touched['reference']) && !selectedReference">{{'hero.required' | translate}}</span>
|
||||
|
||||
<ion-item *ngIf="showinput" [class.ion-invalid]="(submitted || touched['referenceDetail']) && !reference" [class.ion-touched]="submitted || touched['referenceDetail']">
|
||||
<ion-label position="floating">{{'hero.discover_details' | translate}}</ion-label>
|
||||
<ion-input [(ngModel)]="reference" (ionBlur)="markTouched('referenceDetail')"></ion-input>
|
||||
</ion-item>
|
||||
<span class="error-msg" *ngIf="(submitted || touched['referenceDetail']) && showinput && !reference">{{'hero.required' | translate}}</span>
|
||||
|
||||
<br>
|
||||
<br>
|
||||
<ion-button type="submit" expand="full" color="secondary" (click)="addHero()">{{'hero.signup' | translate}}</ion-button>
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
.tags-item {
|
||||
--inner-padding-end: 8px;
|
||||
--padding-top: 4px;
|
||||
--padding-bottom: 4px;
|
||||
}
|
||||
|
||||
.chip-section-label {
|
||||
flex-basis: 100%;
|
||||
font-size: 12px;
|
||||
padding-top: 8px;
|
||||
padding-bottom: 2px;
|
||||
}
|
||||
|
||||
.tags-row {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
padding: 0 0 6px;
|
||||
width: 100%;
|
||||
|
||||
ion-chip {
|
||||
margin: 0;
|
||||
height: 30px;
|
||||
flex-shrink: 0;
|
||||
|
||||
ion-label {
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
ion-icon {
|
||||
cursor: pointer;
|
||||
font-size: 18px;
|
||||
}
|
||||
}
|
||||
|
||||
ion-input {
|
||||
min-width: 120px;
|
||||
flex: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.dropdown-container {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.dropdown-list {
|
||||
position: absolute;
|
||||
top: 100%;
|
||||
left: 16px;
|
||||
right: 16px;
|
||||
z-index: 100;
|
||||
max-height: 200px;
|
||||
overflow-y: auto;
|
||||
border: 1px solid var(--ion-color-light-shade);
|
||||
border-radius: 8px;
|
||||
background: var(--ion-background-color, #fff);
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
||||
|
||||
ion-item {
|
||||
--min-height: 40px;
|
||||
font-size: 14px;
|
||||
cursor: pointer;
|
||||
|
||||
&:hover {
|
||||
--background: var(--ion-color-light);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ion-item.ion-invalid.ion-touched {
|
||||
--border-color: var(--ion-color-danger);
|
||||
--highlight-color-invalid: var(--ion-color-danger);
|
||||
|
||||
ion-label {
|
||||
color: var(--ion-color-danger) !important;
|
||||
}
|
||||
}
|
||||
|
||||
.error-msg {
|
||||
display: block;
|
||||
font-size: 12px;
|
||||
color: var(--ion-color-danger);
|
||||
padding: 2px 16px 4px;
|
||||
}
|
||||
|
||||
ion-chip[color="primary"] {
|
||||
--background: var(--ion-color-primary);
|
||||
--color: var(--ion-color-primary-contrast);
|
||||
}
|
||||
|
||||
ion-chip[color="secondary"] {
|
||||
--background: var(--ion-color-secondary);
|
||||
--color: var(--ion-color-secondary-contrast);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { Component, OnInit, NgZone } from '@angular/core';
|
||||
import { NavController, LoadingController } from '@ionic/angular';
|
||||
import { AuthService } from 'src/app/services/auth.service';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { LanguageService } from 'src/app/services/language.service';
|
||||
import { IchambaService } from 'src/app/services/ichamba.service';
|
||||
import { AlertService } from 'src/app/services/alert.service';
|
||||
|
||||
@@ -10,6 +12,7 @@ declare var google: any;
|
||||
selector: 'app-hero',
|
||||
templateUrl: './hero.page.html',
|
||||
styleUrls: ['./hero.page.scss'],
|
||||
standalone: false
|
||||
})
|
||||
export class HeroPage implements OnInit {
|
||||
|
||||
@@ -17,139 +20,224 @@ export class HeroPage implements OnInit {
|
||||
categories: any[] = [];
|
||||
categories_input: any[] = [];
|
||||
categories_rearranged: any[] = [];
|
||||
keywords: any[] = [];
|
||||
keywords_string: any[] = [];
|
||||
keywords_text: string = '';
|
||||
aux_categories: any[] = [];
|
||||
filteredCategories: any[] = [];
|
||||
categorySearchText: string = '';
|
||||
showCategoryDropdown: boolean = false;
|
||||
keywords: string[] = [];
|
||||
keywordInput: string = '';
|
||||
myPosition: any = {};
|
||||
myAddress: string | null = null;
|
||||
myIntnumber: string | null = null;
|
||||
banks: any[] = [];
|
||||
reference: string | null = null;
|
||||
name: string | null = null;
|
||||
rfc: string | null = null;
|
||||
selectedBank: number | null = null;
|
||||
bankAccount: number | null = null;
|
||||
fee: number | null = null;
|
||||
feeDisplay: string = '';
|
||||
selectedReference: number = 0;
|
||||
addressAutocomplete: string = '';
|
||||
placesSearch: any = '';
|
||||
showinput: boolean = false;
|
||||
showif = true;
|
||||
submitted: boolean = false;
|
||||
touched: { [key: string]: boolean } = {};
|
||||
|
||||
constructor(
|
||||
private navCtrl: NavController,
|
||||
private loadingCtrl: LoadingController,
|
||||
private authService: AuthService,
|
||||
private alertService: AlertService,
|
||||
private translateService: TranslateService,
|
||||
private languageService: LanguageService,
|
||||
private ichambaService: IchambaService,
|
||||
private ngZone: NgZone,
|
||||
) { }
|
||||
|
||||
ngOnInit() {
|
||||
/*this.categories = ["carpintero","jardinero","abogado","administrador","agente inmobiliario","agente de seguros","albañil",
|
||||
"arquitecto","asistente personal","becario","cerrajero","chef","chofer","contratista","contador","diseñador de interiores",
|
||||
"cantante","diseñador grafico","edecan","electricista","estilista","servicios financieros","fontanero","fotografo","produccion de videos",
|
||||
"hostess","lavado de tapicerias","aire acondicionado","almacenista","ayudante","azulejero","cerrajero automotriz","cortinas metalicas",
|
||||
"electrico automotriz","entretenimiento","fisioterapeuta","grua","herrero","ingeniero civil","laminado automotriz","limpieza","limpieza del hogar",
|
||||
"mantenimiento","mariachi","masajista","marmolero","mecanico","mercadotecnia","mesero","modelo","musico","niñera","pintor","pintura automotriz",
|
||||
"plomero","programador","publicista","recepcionista","remodelacion","repartidor","reparacion de celulares","reparacion de electronicos","soldador",
|
||||
"tabla roquero","tapicero","tecnico en gas","tuneame la nave","traductor","tutor","vendedor","veterinario","vidrio y aluminio","reparacion de computadoras",
|
||||
"mantenimiento de camiones","consultor","capacitacion","maestro","barbero","agencia de colocacion","agencia de viajes","paseador de perros","banquete",
|
||||
"almacenaje","impermeabilizacion","redes de internet"];*/
|
||||
this.ichambaService.getCategories()
|
||||
.subscribe( categories => {
|
||||
this.categories = categories;
|
||||
this.aux_categories = categories;
|
||||
this.filteredCategories = categories;
|
||||
})
|
||||
this.ichambaService.getBanks()
|
||||
.subscribe( banks => {
|
||||
this.banks = banks;
|
||||
})
|
||||
}
|
||||
|
||||
// ========== CATEGORÍAS CON CHIPS ==========
|
||||
filterCategories(event: any) {
|
||||
const searchTerm = (event.detail?.value || event.target?.value || '').toLowerCase();
|
||||
this.categorySearchText = searchTerm;
|
||||
if (searchTerm.length > 0) {
|
||||
this.filteredCategories = this.categories.filter(cat =>
|
||||
cat.toLowerCase().includes(searchTerm) && !this.categories_input.includes(cat)
|
||||
);
|
||||
this.showCategoryDropdown = true;
|
||||
} else {
|
||||
this.filteredCategories = this.categories.filter(cat => !this.categories_input.includes(cat));
|
||||
this.showCategoryDropdown = false;
|
||||
}
|
||||
}
|
||||
|
||||
selectCategory(category: string) {
|
||||
if (!this.categories_input.includes(category)) {
|
||||
this.categories_input.push(category);
|
||||
}
|
||||
this.categorySearchText = '';
|
||||
this.showCategoryDropdown = false;
|
||||
this.filteredCategories = this.categories.filter(cat => !this.categories_input.includes(cat));
|
||||
}
|
||||
|
||||
removeCategory(category: string) {
|
||||
const index = this.categories_input.indexOf(category);
|
||||
if (index > -1) {
|
||||
this.categories_input.splice(index, 1);
|
||||
}
|
||||
this.filteredCategories = this.categories.filter(cat => !this.categories_input.includes(cat));
|
||||
}
|
||||
|
||||
hideCategoryList() {
|
||||
setTimeout(() => {
|
||||
this.showCategoryDropdown = false;
|
||||
this.touched['categories'] = true;
|
||||
}, 200);
|
||||
}
|
||||
|
||||
// ========== PALABRAS CLAVE CON CHIPS ==========
|
||||
addKeyword(event?: any) {
|
||||
this.touched['keywords'] = true;
|
||||
const value = this.keywordInput?.trim();
|
||||
if (value && value.length > 0) {
|
||||
// Separar por comas si hay varias palabras
|
||||
const newKeywords = value.split(',').map((k: string) => k.trim()).filter((k: string) => k.length > 0);
|
||||
newKeywords.forEach((keyword: string) => {
|
||||
if (!this.keywords.includes(keyword)) {
|
||||
this.keywords.push(keyword);
|
||||
}
|
||||
});
|
||||
this.keywordInput = '';
|
||||
}
|
||||
}
|
||||
|
||||
onKeywordKeydown(event: KeyboardEvent) {
|
||||
if (event.key === 'Enter' || event.key === ',') {
|
||||
event.preventDefault();
|
||||
this.addKeyword();
|
||||
} else if (event.key === 'Backspace' && !this.keywordInput && this.keywords.length > 0) {
|
||||
this.keywords.pop();
|
||||
}
|
||||
}
|
||||
|
||||
removeKeyword(keyword: string) {
|
||||
const index = this.keywords.indexOf(keyword);
|
||||
if (index > -1) {
|
||||
this.keywords.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
dismissHero() {
|
||||
this.navCtrl.navigateRoot('/landing');
|
||||
this.navCtrl.navigateRoot('/dashboard');
|
||||
}
|
||||
|
||||
autocomplete(ev: any) {
|
||||
if (!this.addressAutocomplete.trim().length) {
|
||||
const value = (ev.detail?.value ?? this.addressAutocomplete).trim();
|
||||
this.myAddress = null;
|
||||
if (!value.length) {
|
||||
this.placesSearch = null;
|
||||
return;
|
||||
}
|
||||
console.log(this.addressAutocomplete)
|
||||
new google.maps.places.AutocompleteService().getPredictions({ input: this.addressAutocomplete }, predictions => {
|
||||
new google.maps.places.AutocompleteService().getPredictions({ input: value }, (predictions: any) => {
|
||||
this.ngZone.run(() => {
|
||||
this.placesSearch = predictions;
|
||||
console.log(predictions);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
geoloc(place_id: string, place_description: string, place_intnumber: string) {
|
||||
this.myAddress = place_description;
|
||||
this.addressAutocomplete = place_description;
|
||||
this.myIntnumber = place_intnumber;
|
||||
console.log(place_id);
|
||||
this.placesSearch = null;
|
||||
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());
|
||||
const result = coordinates[0];
|
||||
this.myPosition = {
|
||||
latitude: coordinates[0].geometry.location.lat(),
|
||||
longitude: coordinates[0].geometry.location.lng()
|
||||
}
|
||||
latitude: result.geometry.location.lat(),
|
||||
longitude: result.geometry.location.lng()
|
||||
};
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
selected_reference(ev: any) {
|
||||
console.log(ev.target.value);
|
||||
this.selectedReference = ev.target.value;
|
||||
if (this.selectedReference == 5) {
|
||||
this.showinput = true;
|
||||
} else {
|
||||
this.showinput = false;
|
||||
}
|
||||
this.showinput = ev.detail.value === 5;
|
||||
}
|
||||
|
||||
onFeeInput(ev: any) {
|
||||
const raw = (ev.detail?.value ?? '').replace(/[^0-9.]/g, '');
|
||||
const parts = raw.split('.');
|
||||
const integer = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
||||
const decimal = parts.length > 1 ? '.' + parts[1].slice(0, 2) : '';
|
||||
this.feeDisplay = raw ? `$${integer}${decimal}` : '';
|
||||
this.fee = raw ? parseFloat(raw) : null;
|
||||
}
|
||||
|
||||
addHero(){
|
||||
// categories_input is now an array of values directly from ion-select
|
||||
this.categories_rearranged = this.categories_input.slice();
|
||||
this.submitted = true;
|
||||
const categoriesString = this.categories_input.join(',');
|
||||
const keywordsString = this.keywords.length > 0 ? this.keywords.join(', ') : '';
|
||||
|
||||
// keywords_text is now a string, split by comma
|
||||
if (this.keywords_text && this.keywords_text.trim().length > 0) {
|
||||
this.keywords_string = this.keywords_text.split(',').map(k => k.trim()).filter(k => k.length > 0);
|
||||
}
|
||||
|
||||
if (this.name && this.categories_input && this.myAddress && this.myPosition.latitude && this.myPosition.longitude && this.selectedReference){
|
||||
if (this.selectedReference == 5 && this.reference) {
|
||||
this.loadingCtrl.create().then((overlay) => {
|
||||
this.loading = overlay;
|
||||
this.loading.present();
|
||||
});
|
||||
|
||||
this.ichambaService.addHero(this.name, this.categories_rearranged.join(','), (this.keywords_string.join(', ') == "" ? null : this.keywords_string.join(', ')), this.myAddress, this.myPosition.latitude, this.myPosition.longitude, this.selectedReference, this.reference).subscribe(
|
||||
data => {
|
||||
this.loading.dismiss();
|
||||
this.alertService.presentToast(data['message']);
|
||||
this.navCtrl.navigateRoot('/dashboard');
|
||||
}, error => {
|
||||
this.loading.dismiss();
|
||||
this.alertService.presentToast("Por favor contacte a soporte técnico, Estatus:" + error['status']);
|
||||
});
|
||||
} else if (this.selectedReference !== 5) {
|
||||
this.loadingCtrl.create().then((overlay) => {
|
||||
this.loading = overlay;
|
||||
this.loading.present();
|
||||
});
|
||||
|
||||
this.ichambaService.addHero(this.name, this.categories_rearranged.join(','), (this.keywords_string.join(', ') == "" ? null : this.keywords_string.join(', ')), this.myAddress, this.myPosition.latitude, this.myPosition.longitude, this.selectedReference, this.reference).subscribe(
|
||||
data => {
|
||||
this.loading.dismiss();
|
||||
this.alertService.presentToast(data['message']);
|
||||
this.navCtrl.navigateRoot('/dashboard');
|
||||
}, error => {
|
||||
this.loading.dismiss();
|
||||
this.alertService.presentToast("Por favor contacte a soporte técnico, Estatus:" + error['status']);
|
||||
});
|
||||
} else {
|
||||
if (
|
||||
this.name &&
|
||||
this.rfc &&
|
||||
this.categories_input.length > 0 &&
|
||||
this.myAddress &&
|
||||
this.myPosition.latitude &&
|
||||
this.myPosition.longitude &&
|
||||
this.selectedBank !== null &&
|
||||
this.bankAccount &&
|
||||
this.fee !== null &&
|
||||
this.selectedReference
|
||||
) {
|
||||
if (this.selectedReference === 5 && !this.reference) {
|
||||
this.alertService.presentToast("Por favor, específique cómo supo de nosotros");
|
||||
return;
|
||||
}
|
||||
|
||||
this.loadingCtrl.create().then((overlay) => {
|
||||
this.loading = overlay;
|
||||
this.loading.present();
|
||||
});
|
||||
|
||||
this.ichambaService.addHero(this.name!, this.rfc!, categoriesString, keywordsString, this.myAddress!, this.myPosition.latitude, this.myPosition.longitude, this.selectedBank ?? 0, this.bankAccount ?? 0, this.fee ?? 0, this.selectedReference, this.reference ?? '').subscribe(
|
||||
(data: any) => {
|
||||
if (this.loading) this.loading.dismiss();
|
||||
this.alertService.presentToast(data['message']);
|
||||
this.navCtrl.navigateRoot('/dashboard');
|
||||
}, (error: any) => {
|
||||
if (this.loading) this.loading.dismiss();
|
||||
this.alertService.presentToast(this.translateService.instant('alerts.error') + error['status']);
|
||||
});
|
||||
} else {
|
||||
this.alertService.presentToast("Llene todos los datos solicitados");
|
||||
}
|
||||
}
|
||||
|
||||
markTouched(field: string) {
|
||||
this.touched[field] = true;
|
||||
}
|
||||
|
||||
blurAddressList() {
|
||||
setTimeout(() => {
|
||||
this.hidelist();
|
||||
this.touched['address'] = true;
|
||||
}, 200);
|
||||
}
|
||||
|
||||
showlist() {
|
||||
this.showif = true;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ register();
|
||||
selector: 'app-landing',
|
||||
templateUrl: './landing.page.html',
|
||||
styleUrls: ['./landing.page.scss'],
|
||||
standalone: false
|
||||
})
|
||||
export class LandingPage implements OnInit {
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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']);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
33
src/app/services/auth-interceptor.service.ts
Normal file
33
src/app/services/auth-interceptor.service.ts
Normal 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');
|
||||
}
|
||||
}
|
||||
@@ -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(
|
||||
() => {
|
||||
console.log('Token Stored');
|
||||
}
|
||||
).catch(error => console.error('Error storing item', error));
|
||||
.then(() => {
|
||||
console.log('Token Stored');
|
||||
}).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 => {
|
||||
Preferences.remove({ key: 'token' });
|
||||
this.isLoggedIn = false;
|
||||
this.isVerified = false;
|
||||
delete this.token;
|
||||
return data;
|
||||
},
|
||||
error => {
|
||||
Preferences.remove({ key: 'token' });
|
||||
this.isLoggedIn = false;
|
||||
this.isVerified = false;
|
||||
})
|
||||
)
|
||||
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;
|
||||
}
|
||||
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 });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,11 +4,14 @@ import { Injectable } from '@angular/core';
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class EnvService {
|
||||
API_URL = 'http://192.168.10.207:8080/api/';
|
||||
API_URL = 'http://jobhero.test/api/';
|
||||
SECRET = 'wBIIKuDbrxNKzQhAUGiZLoaoQ4MichAN3wP2AP7B';
|
||||
MERCHANT_ID = 'm9k4beuso5az0wjqztvt';
|
||||
PUBLIC_API_KEY = 'pk_9465179493384689a8d2da9adc825411';
|
||||
ONESIGNAL_APP_ID = 'c854ae89-7ff7-4216-a70e-5fdff0cd8e10';
|
||||
|
||||
// Bypass de pago para pruebas (cambiar a false para producción)
|
||||
PAYMENT_BYPASS = true;
|
||||
|
||||
constructor() { }
|
||||
}
|
||||
|
||||
63
src/app/services/firebase-auth.service.ts
Normal file
63
src/app/services/firebase-auth.service.ts
Normal 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);
|
||||
}
|
||||
}
|
||||
@@ -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 });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Injectable, NgZone } from '@angular/core';
|
||||
import { Capacitor } from '@capacitor/core';
|
||||
import { NavController } from '@ionic/angular';
|
||||
import { EnvService } from './env.service';
|
||||
import { Router } from '@angular/router';
|
||||
import { AlertService } from './alert.service';
|
||||
import { EventService } from './event.service';
|
||||
|
||||
declare var OneSignalPlugin: any;
|
||||
|
||||
@@ -13,78 +15,78 @@ export class OneSignalService {
|
||||
|
||||
constructor(
|
||||
private env: EnvService,
|
||||
private router: Router
|
||||
private navCtrl: NavController,
|
||||
private alertService: AlertService,
|
||||
private events: EventService,
|
||||
private ngZone: NgZone,
|
||||
) { }
|
||||
|
||||
async init(): Promise<void> {
|
||||
if (this.initialized || !Capacitor.isNativePlatform()) {
|
||||
return;
|
||||
}
|
||||
if (this.initialized || !Capacitor.isNativePlatform()) return;
|
||||
|
||||
try {
|
||||
// Initialize OneSignal
|
||||
OneSignalPlugin.initialize(this.env.ONESIGNAL_APP_ID);
|
||||
|
||||
// Request notification permission
|
||||
OneSignalPlugin.Notifications.requestPermission(true).then((accepted: boolean) => {
|
||||
console.log('OneSignal notification permission:', accepted ? 'accepted' : 'denied');
|
||||
console.log('OneSignal permission:', accepted ? 'accepted' : 'denied');
|
||||
});
|
||||
|
||||
// Handle notification clicks
|
||||
OneSignalPlugin.Notifications.addEventListener('click', (event: any) => {
|
||||
console.log('OneSignal notification clicked:', event);
|
||||
this.handleNotificationClick(event);
|
||||
});
|
||||
|
||||
// Handle foreground notifications
|
||||
// Foreground: show alert + navigate
|
||||
OneSignalPlugin.Notifications.addEventListener('foregroundWillDisplay', (event: any) => {
|
||||
console.log('OneSignal notification received in foreground:', event);
|
||||
// Display the notification
|
||||
event.getNotification().display();
|
||||
const notification = event.getNotification();
|
||||
notification.display();
|
||||
this.ngZone.run(() => {
|
||||
this.alertService.presentAlert(notification.title, notification.body, ['OK']);
|
||||
this.navigateByTitle(notification.title);
|
||||
});
|
||||
});
|
||||
|
||||
// Tap on notification: navigate only
|
||||
OneSignalPlugin.Notifications.addEventListener('click', (event: any) => {
|
||||
const title = event.notification?.title;
|
||||
this.ngZone.run(() => this.navigateByTitle(title));
|
||||
});
|
||||
|
||||
this.initialized = true;
|
||||
console.log('OneSignal initialized successfully');
|
||||
} catch (error) {
|
||||
console.error('Error initializing OneSignal:', error);
|
||||
}
|
||||
}
|
||||
|
||||
async setUserId(userId: number | string): Promise<void> {
|
||||
if (!Capacitor.isNativePlatform()) {
|
||||
return;
|
||||
private navigateByTitle(title: string): void {
|
||||
if (title === 'Proveedor: hay nueva postulación' || title === 'Hero: there is a new postulation') {
|
||||
this.navCtrl.navigateRoot('/postulations');
|
||||
this.events.publish('refreshpostulations', 'data');
|
||||
} else if (title === 'Búsqueda Finalizada' || title === 'Search finished') {
|
||||
this.navCtrl.navigateRoot('/contracts');
|
||||
} else if (title === 'Usuario: el proveedor ha iniciado el servicio' || title === 'User: the Hero has started the service') {
|
||||
this.navCtrl.navigateRoot('/contracts');
|
||||
}
|
||||
}
|
||||
|
||||
async setUserId(userId: number | string): Promise<void> {
|
||||
if (!Capacitor.isNativePlatform()) return;
|
||||
try {
|
||||
// Set user tag for targeting
|
||||
OneSignalPlugin.login(String(userId));
|
||||
OneSignalPlugin.User.addTag('iChamba_ID', String(userId));
|
||||
console.log('OneSignal user tag set:', userId);
|
||||
} catch (error) {
|
||||
console.error('Error setting OneSignal user tag:', error);
|
||||
console.error('Error setting OneSignal user:', error);
|
||||
}
|
||||
}
|
||||
|
||||
async setUserRole(roleId: number | string): Promise<void> {
|
||||
if (!Capacitor.isNativePlatform()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Capacitor.isNativePlatform()) return;
|
||||
try {
|
||||
OneSignalPlugin.User.addTag('iChamba_Role', String(roleId));
|
||||
console.log('OneSignal role tag set:', roleId);
|
||||
} catch (error) {
|
||||
console.error('Error setting OneSignal role tag:', error);
|
||||
}
|
||||
}
|
||||
|
||||
async clearTags(): Promise<void> {
|
||||
if (!Capacitor.isNativePlatform()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Capacitor.isNativePlatform()) return;
|
||||
try {
|
||||
OneSignalPlugin.User.removeTags(['iChamba_ID', 'iChamba_Role']);
|
||||
console.log('OneSignal tags cleared');
|
||||
} catch (error) {
|
||||
console.error('Error clearing OneSignal tags:', error);
|
||||
}
|
||||
@@ -92,38 +94,20 @@ export class OneSignalService {
|
||||
|
||||
async logout(): Promise<void> {
|
||||
await this.clearTags();
|
||||
}
|
||||
|
||||
private handleNotificationClick(event: any): void {
|
||||
const data = event?.notification?.additionalData;
|
||||
|
||||
if (data) {
|
||||
// Handle navigation based on notification data
|
||||
if (data.route) {
|
||||
this.router.navigate([data.route]);
|
||||
} else if (data.type) {
|
||||
switch (data.type) {
|
||||
case 'contract':
|
||||
this.router.navigate(['/contracts']);
|
||||
break;
|
||||
case 'postulation':
|
||||
this.router.navigate(['/postulations']);
|
||||
break;
|
||||
default:
|
||||
this.router.navigate(['/dashboard']);
|
||||
}
|
||||
if (Capacitor.isNativePlatform()) {
|
||||
try {
|
||||
OneSignalPlugin.logout();
|
||||
} catch (error) {
|
||||
console.error('Error logging out OneSignal:', error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async getPlayerId(): Promise<string | null> {
|
||||
if (!Capacitor.isNativePlatform()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!Capacitor.isNativePlatform()) return null;
|
||||
try {
|
||||
const deviceState = await OneSignalPlugin.User.pushSubscription.getId();
|
||||
return deviceState || null;
|
||||
const id = await OneSignalPlugin.User.pushSubscription.getId();
|
||||
return id || null;
|
||||
} catch (error) {
|
||||
console.error('Error getting OneSignal player ID:', error);
|
||||
return null;
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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);
|
||||
},
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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'
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -74,6 +74,24 @@ ion-app {
|
||||
}
|
||||
}
|
||||
|
||||
// Consistent button styling to match social login buttons
|
||||
ion-button::part(native) {
|
||||
border-radius: 6px;
|
||||
font-weight: 500;
|
||||
letter-spacing: 0.06em;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
// Border for light-colored buttons so they don't blend into white backgrounds
|
||||
ion-button[color="light"]::part(native) {
|
||||
border: 1px solid #DADCE0;
|
||||
}
|
||||
|
||||
// No border when light button is inside a colored toolbar
|
||||
ion-toolbar:not([color="light"]):not([color=""]) ion-button[color="light"]::part(native) {
|
||||
border: none;
|
||||
}
|
||||
|
||||
.rate_div {
|
||||
|
||||
rating {
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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"
|
||||
]
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user