iptdevs-design-system 1.3.6 → 1.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,10 +1,11 @@
1
1
  import * as i0 from '@angular/core';
2
- import { EventEmitter, Component, Input, Output, NgModule, Injectable } from '@angular/core';
2
+ import { EventEmitter, Component, Input, Output, Injectable, NgModule } from '@angular/core';
3
3
  import { BrowserModule } from '@angular/platform-browser';
4
4
  import * as i1 from '@angular/common';
5
5
  import { CommonModule } from '@angular/common';
6
6
  import * as i1$1 from '@angular/forms';
7
7
  import { Validators, FormsModule, ReactiveFormsModule } from '@angular/forms';
8
+ import Swal from 'sweetalert2';
8
9
  import * as i1$2 from '@angular/common/http';
9
10
  import { HttpHeaders } from '@angular/common/http';
10
11
  import * as i1$3 from '@angular/router';
@@ -599,8 +600,175 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.3", ngImpor
599
600
  type: Output
600
601
  }] } });
601
602
 
603
+ class UserService {
604
+ constructor(http) {
605
+ this.http = http;
606
+ this.SERVICE_URL = 'https://iptdev.com.co/lab/users/api/';
607
+ }
608
+ login(userLogin) {
609
+ let serviceUrl = this.SERVICE_URL + 'post/login';
610
+ this.generateRequestParams(userLogin);
611
+ return this.http.post(serviceUrl, this.httpOptions);
612
+ }
613
+ resetPassword(resetPassword) {
614
+ let serviceUrl = this.SERVICE_URL + 'reset/password';
615
+ this.generateRequestParams(resetPassword);
616
+ return this.http.post(serviceUrl, this.httpOptions);
617
+ }
618
+ register(user) {
619
+ let serviceUrl = this.SERVICE_URL + 'post/create/web';
620
+ this.generateRequestParams(user);
621
+ return this.http.post(serviceUrl, this.httpOptions);
622
+ }
623
+ registerIndex(register) {
624
+ let serviceUrl = this.SERVICE_URL + 'post/create/marketing';
625
+ this.generateRequestParams(register);
626
+ return this.http.post(serviceUrl, this.httpOptions);
627
+ }
628
+ registerDashboard(user) {
629
+ let serviceUrl = this.SERVICE_URL + 'post/create/dashboard';
630
+ this.generateRequestParams(user);
631
+ return this.http.post(serviceUrl, this.httpOptions);
632
+ }
633
+ getAvailableTeachers(token) {
634
+ let serviceUrl = this.SERVICE_URL + 'post/obtain/teachers';
635
+ this.generateRequestParams(token);
636
+ return this.http.post(serviceUrl, this.httpOptions);
637
+ }
638
+ getUserByIdCard(value) {
639
+ let serviceUrl = this.SERVICE_URL + 'user/id_card/' + value;
640
+ return this.http.get(serviceUrl);
641
+ }
642
+ generateRequestParams(param) {
643
+ this.httpOptions = {
644
+ header: new HttpHeaders(),
645
+ params: param,
646
+ };
647
+ }
648
+ }
649
+ UserService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: UserService, deps: [{ token: i1$2.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
650
+ UserService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: UserService, providedIn: 'root' });
651
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: UserService, decorators: [{
652
+ type: Injectable,
653
+ args: [{
654
+ providedIn: 'root',
655
+ }]
656
+ }], ctorParameters: function () { return [{ type: i1$2.HttpClient }]; } });
657
+
658
+ class StorageService {
659
+ constructor() {
660
+ this.currentSession = null;
661
+ this.localStorageService = localStorage;
662
+ this.currentSession = this.loadSessionData();
663
+ }
664
+ setCurrentSession(session) {
665
+ this.currentSession = session;
666
+ this.localStorageService.setItem('606a7d4e73650b75ebb06972e77d6cc4', JSON.stringify(session));
667
+ }
668
+ loadSessionData() {
669
+ var sessionStr = this.localStorageService.getItem('606a7d4e73650b75ebb06972e77d6cc4');
670
+ return (sessionStr) ? JSON.parse(sessionStr) : null;
671
+ }
672
+ getCurrentSession() {
673
+ return this.currentSession;
674
+ }
675
+ removeCurrentSession() {
676
+ this.localStorageService.removeItem('606a7d4e73650b75ebb06972e77d6cc4');
677
+ this.currentSession = null;
678
+ }
679
+ getCurrentUser() {
680
+ var session = this.getCurrentSession();
681
+ return (session && session.user) ? session.user : null;
682
+ }
683
+ ;
684
+ isAuthenticated() {
685
+ return (this.getCurrentToken() != null) ? true : false;
686
+ }
687
+ ;
688
+ getCurrentToken() {
689
+ var session = this.getCurrentSession();
690
+ return (session && session.token) ? session.token : null;
691
+ }
692
+ ;
693
+ logout() {
694
+ this.removeCurrentSession();
695
+ }
696
+ }
697
+ StorageService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: StorageService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
698
+ StorageService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: StorageService, providedIn: 'root' });
699
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: StorageService, decorators: [{
700
+ type: Injectable,
701
+ args: [{
702
+ providedIn: 'root',
703
+ }]
704
+ }], ctorParameters: function () { return []; } });
705
+
706
+ class BaseService {
707
+ constructor(userService, storageService) {
708
+ this.userService = userService;
709
+ this.storageService = storageService;
710
+ }
711
+ async webLogin(user, password) {
712
+ let request = {
713
+ user: user,
714
+ password: password
715
+ };
716
+ this.userService.login(request).subscribe(response => {
717
+ switch (response.message.code) {
718
+ case 1:
719
+ Swal.fire({
720
+ 'title': '<p style="font-family: Poppins"">Perfect!</p>',
721
+ 'html': '<p style="font-family: Poppins"">Succesfull login</p>',
722
+ 'icon': 'success',
723
+ });
724
+ const loginRegisterUser = {
725
+ token: response.data.token,
726
+ user: response.data,
727
+ };
728
+ this.storageService.setCurrentSession(loginRegisterUser);
729
+ break;
730
+ case 2:
731
+ Swal.fire({
732
+ 'title': '<p style="font-family: Poppins"">Warning!</p>',
733
+ 'html': '<p style="font-family: Poppins"">The data does not correspond to a user registered in our system, please review them.</p>',
734
+ 'icon': 'warning',
735
+ });
736
+ break;
737
+ case 3:
738
+ Swal.fire({
739
+ 'title': '<p style="font-family: Poppins"">Error!</p>',
740
+ 'html': '<p style="font-family: Poppins"">The input data does not meet the established parameters.</p>',
741
+ 'icon': 'error',
742
+ });
743
+ break;
744
+ default:
745
+ Swal.fire({
746
+ 'title': '<p style="font-family: Poppins"">Error!</p>',
747
+ 'html': '<p style="font-family: Poppins"">An unexpected error has occurred</p>',
748
+ 'icon': 'error',
749
+ });
750
+ break;
751
+ }
752
+ return true;
753
+ });
754
+ }
755
+ getUserRole() {
756
+ let user = this.storageService.getCurrentUser()?.role;
757
+ return user === undefined ? -1 : Math.floor(user / 10);
758
+ }
759
+ }
760
+ BaseService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: BaseService, deps: [{ token: UserService }, { token: StorageService }], target: i0.ɵɵFactoryTarget.Injectable });
761
+ BaseService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: BaseService, providedIn: 'root' });
762
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: BaseService, decorators: [{
763
+ type: Injectable,
764
+ args: [{
765
+ providedIn: 'root',
766
+ }]
767
+ }], ctorParameters: function () { return [{ type: UserService }, { type: StorageService }]; } });
768
+
602
769
  class LoginFormComponent {
603
- constructor(fb) {
770
+ constructor(fb, baseService) {
771
+ this.baseService = baseService;
604
772
  this.background = true;
605
773
  this.email = new EventEmitter();
606
774
  this.password = new EventEmitter();
@@ -610,13 +778,14 @@ class LoginFormComponent {
610
778
  });
611
779
  }
612
780
  login(data) {
781
+ this.baseService.webLogin(data.controls['email'].value, data.controls['password'].value);
613
782
  this.email.emit(data.controls['email'].value);
614
783
  this.password.emit(data.controls['password'].value);
615
784
  this.loginForm.controls['email'].setValue('');
616
785
  this.loginForm.controls['password'].setValue('');
617
786
  }
618
787
  }
619
- LoginFormComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: LoginFormComponent, deps: [{ token: i1$1.FormBuilder }], target: i0.ɵɵFactoryTarget.Component });
788
+ LoginFormComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: LoginFormComponent, deps: [{ token: i1$1.FormBuilder }, { token: BaseService }], target: i0.ɵɵFactoryTarget.Component });
620
789
  LoginFormComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.1.3", type: LoginFormComponent, selector: "ipt-login-form", inputs: { background: "background", image: "image" }, outputs: { email: "email", password: "password" }, ngImport: i0, template: `
621
790
  <div [ngClass]="{'with-background': background}" class="form-container">
622
791
 
@@ -703,7 +872,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.3", ngImpor
703
872
 
704
873
  </div>
705
874
  `, styles: [".form-container{display:grid;grid-template-columns:1fr;justify-items:center;width:350px}.with-background{background-color:#fff;border-radius:25px;box-shadow:#32325d40 0 50px 100px -20px,#0000004d 0 30px 60px -30px}h2{color:#1c77f7}hr{width:80%}form{margin-bottom:60px;display:grid;grid-template-columns:1fr;grid-gap:30px;gap:30px;width:100%}.button-container{margin-bottom:70px;align-items:center;display:flex;gap:50px}footer{background-color:#1c77f7;border-top-left-radius:25px;border-top-right-radius:25px;width:100%;height:100px;display:flex;align-items:center;justify-content:center}\n"] }]
706
- }], ctorParameters: function () { return [{ type: i1$1.FormBuilder }]; }, propDecorators: { background: [{
875
+ }], ctorParameters: function () { return [{ type: i1$1.FormBuilder }, { type: BaseService }]; }, propDecorators: { background: [{
707
876
  type: Input
708
877
  }], image: [{
709
878
  type: Input
@@ -944,54 +1113,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.3", ngImpor
944
1113
  type: Injectable
945
1114
  }], ctorParameters: function () { return [{ type: i1$3.Router }]; } });
946
1115
 
947
- class StorageService {
948
- constructor() {
949
- this.currentSession = null;
950
- this.localStorageService = localStorage;
951
- this.currentSession = this.loadSessionData();
952
- }
953
- setCurrentSession(session) {
954
- this.currentSession = session;
955
- this.localStorageService.setItem('606a7d4e73650b75ebb06972e77d6cc4', JSON.stringify(session));
956
- }
957
- loadSessionData() {
958
- var sessionStr = this.localStorageService.getItem('606a7d4e73650b75ebb06972e77d6cc4');
959
- return (sessionStr) ? JSON.parse(sessionStr) : null;
960
- }
961
- getCurrentSession() {
962
- return this.currentSession;
963
- }
964
- removeCurrentSession() {
965
- this.localStorageService.removeItem('606a7d4e73650b75ebb06972e77d6cc4');
966
- this.currentSession = null;
967
- }
968
- getCurrentUser() {
969
- var session = this.getCurrentSession();
970
- return (session && session.user) ? session.user : null;
971
- }
972
- ;
973
- isAuthenticated() {
974
- return (this.getCurrentToken() != null) ? true : false;
975
- }
976
- ;
977
- getCurrentToken() {
978
- var session = this.getCurrentSession();
979
- return (session && session.token) ? session.token : null;
980
- }
981
- ;
982
- logout() {
983
- this.removeCurrentSession();
984
- }
985
- }
986
- StorageService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: StorageService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
987
- StorageService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: StorageService, providedIn: 'root' });
988
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: StorageService, decorators: [{
989
- type: Injectable,
990
- args: [{
991
- providedIn: 'root',
992
- }]
993
- }], ctorParameters: function () { return []; } });
994
-
995
1116
  class SwitchService {
996
1117
  constructor() {
997
1118
  this.$modal = new EventEmitter();
@@ -1006,61 +1127,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.3", ngImpor
1006
1127
  }]
1007
1128
  }], ctorParameters: function () { return []; } });
1008
1129
 
1009
- class UserService {
1010
- constructor(http) {
1011
- this.http = http;
1012
- this.SERVICE_URL = 'https://iptdev.com.co/lab/users/api/';
1013
- }
1014
- login(userLogin) {
1015
- let serviceUrl = this.SERVICE_URL + 'post/login';
1016
- this.generateRequestParams(userLogin);
1017
- return this.http.post(serviceUrl, this.httpOptions);
1018
- }
1019
- resetPassword(resetPassword) {
1020
- let serviceUrl = this.SERVICE_URL + 'reset/password';
1021
- this.generateRequestParams(resetPassword);
1022
- return this.http.post(serviceUrl, this.httpOptions);
1023
- }
1024
- register(user) {
1025
- let serviceUrl = this.SERVICE_URL + 'post/create/web';
1026
- this.generateRequestParams(user);
1027
- return this.http.post(serviceUrl, this.httpOptions);
1028
- }
1029
- registerIndex(register) {
1030
- let serviceUrl = this.SERVICE_URL + 'post/create/marketing';
1031
- this.generateRequestParams(register);
1032
- return this.http.post(serviceUrl, this.httpOptions);
1033
- }
1034
- registerDashboard(user) {
1035
- let serviceUrl = this.SERVICE_URL + 'post/create/dashboard';
1036
- this.generateRequestParams(user);
1037
- return this.http.post(serviceUrl, this.httpOptions);
1038
- }
1039
- getAvailableTeachers(token) {
1040
- let serviceUrl = this.SERVICE_URL + 'post/obtain/teachers';
1041
- this.generateRequestParams(token);
1042
- return this.http.post(serviceUrl, this.httpOptions);
1043
- }
1044
- getUserByIdCard(value) {
1045
- let serviceUrl = this.SERVICE_URL + 'user/id_card/' + value;
1046
- return this.http.get(serviceUrl);
1047
- }
1048
- generateRequestParams(param) {
1049
- this.httpOptions = {
1050
- header: new HttpHeaders(),
1051
- params: param,
1052
- };
1053
- }
1054
- }
1055
- UserService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: UserService, deps: [{ token: i1$2.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
1056
- UserService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: UserService, providedIn: 'root' });
1057
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: UserService, decorators: [{
1058
- type: Injectable,
1059
- args: [{
1060
- providedIn: 'root',
1061
- }]
1062
- }], ctorParameters: function () { return [{ type: i1$2.HttpClient }]; } });
1063
-
1064
1130
  class CoreModule {
1065
1131
  }
1066
1132
  CoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: CoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });