diff --git a/src/app/@config/menus.ts b/src/app/@config/menus.ts index 299d3f4..369ea93 100644 --- a/src/app/@config/menus.ts +++ b/src/app/@config/menus.ts @@ -37,6 +37,16 @@ export const MENU: MENU[] = [ badge: '', roles: [ROLE_ADMIN], }, + { + name: 'User', + link: 'manage/user', + permission: 'user', + type: 'link', + icon: '', + params: [], + badge: '', + roles: [ROLE_ADMIN], + }, ] }, { diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 0a01bd6..7710882 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -6,75 +6,79 @@ import { AppGuard } from "./app.guard"; const routes: Routes = [ - { - path: '', - redirectTo: 'pages', - pathMatch: 'full' - }, - { - path: 'auth', - loadChildren: () => import('./auth/auth.module').then(m => m.AuthModule) - }, - { - path: 'pages', - component: PagesLayoutsComponent, - canActivate: [AppGuard], - canActivateChild: [AppGuard], + { + path: '', + redirectTo: 'pages', + pathMatch: 'full' + }, + { + path: 'auth', + loadChildren: () => import('./auth/auth.module').then(m => m.AuthModule) + }, + { + path: 'pages', + component: PagesLayoutsComponent, + canActivate: [AppGuard], + canActivateChild: [AppGuard], + children: [ + { path: '', redirectTo: 'dashboard', pathMatch: 'full' }, + { + path: 'dashboard', + loadChildren: () => import('./pages/dashboard/dashboard.module').then(m => m.DashboardModule) + }, + { + path: 'manage', children: [ - { path: '', redirectTo: 'dashboard', pathMatch: 'full' }, - { - path: 'dashboard', - loadChildren: () => import('./pages/dashboard/dashboard.module').then(m => m.DashboardModule) - }, - { - path: 'manage', - children: [ - { - path: 'kyc', - loadChildren: () => import('./pages/manage/kyc/kyc.module').then(m => m.KycModule) - }, - ] - }, - { - path: 'report', - children: [ - { - path: 'transactions', - loadChildren: () => import('./pages/report/transactions/transactions.module').then(m => m.TransactionsModule) - }, - ] - }, - { - path: 'setting', - children: [ - { - path: 'banner', - loadChildren: () => import('./pages/setting/banner/banner.module').then(m => m.BannerModule) - }, - { - path: 'promotion', - loadChildren: () => import('./pages/setting/promotion/promotion.module').then(m => m.PromotionModule) - }, - ] - }, - { - path: 'not-found', - loadChildren: () => import('./pages/errors/errors.module').then(m => m.ErrorsModule) - }, + { + path: 'kyc', + loadChildren: () => import('./pages/manage/kyc/kyc.module').then(m => m.KycModule) + }, + { + path: "user", + loadChildren: () => import('./pages/manage/users/users.module').then(m => m.UsersModule) + } ] - }, + }, + { + path: 'report', + children: [ + { + path: 'transactions', + loadChildren: () => import('./pages/report/transactions/transactions.module').then(m => m.TransactionsModule) + }, + ] + }, + { + path: 'setting', + children: [ + { + path: 'banner', + loadChildren: () => import('./pages/setting/banner/banner.module').then(m => m.BannerModule) + }, + { + path: 'promotion', + loadChildren: () => import('./pages/setting/promotion/promotion.module').then(m => m.PromotionModule) + }, + ] + }, + { + path: 'not-found', + loadChildren: () => import('./pages/errors/errors.module').then(m => m.ErrorsModule) + }, + ] + }, - { path: '**', redirectTo: 'pages/not-found' } + { path: '**', redirectTo: 'pages/not-found' } ]; @NgModule({ - imports: [RouterModule.forRoot(routes, { useHash: true })], - exports: [RouterModule] + imports: [RouterModule.forRoot(routes, { useHash: true })], + exports: [RouterModule] }) export class AppRoutingModule { } export const AppRoutingComponents = [ - ComingsoonComponent, - PagesLayoutsComponent + ComingsoonComponent, + PagesLayoutsComponent ]; diff --git a/src/app/app.component.ts b/src/app/app.component.ts index f621e2e..f69eaa3 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,3 +1,4 @@ +import { HttpClient } from '@angular/common/http'; import { Component } from '@angular/core'; @Component({ @@ -5,4 +6,6 @@ import { Component } from '@angular/core'; templateUrl: './app.component.html', styleUrls: [] }) -export class AppComponent {} +export class AppComponent { + +} diff --git a/src/app/app.request.interceptor.ts b/src/app/app.request.interceptor.ts index 9f12762..8d178ed 100644 --- a/src/app/app.request.interceptor.ts +++ b/src/app/app.request.interceptor.ts @@ -1,15 +1,18 @@ -import {Injectable} from '@angular/core'; -import {HttpErrorResponse, HttpEvent, HttpHandler, HttpInterceptor, HttpRequest} from '@angular/common/http'; -import {Router} from '@angular/router'; -import {AppService} from './app.service'; -import {catchError, Observable, throwError} from 'rxjs'; +import { Injectable } from '@angular/core'; +import { HttpErrorResponse, HttpEvent, HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http'; +import { Router } from '@angular/router'; +import { AppService } from './app.service'; +import { catchError, Observable, throwError } from 'rxjs'; +import { environment } from 'src/environments/environment'; +import { SathonCathayPayService } from './sathon-cathay-pay.service'; @Injectable() export class AppRequestInterceptor implements HttpInterceptor { constructor( private router: Router, - private appService: AppService + private appService: AppService, + private sathonSV: SathonCathayPayService ) { } @@ -18,7 +21,7 @@ export class AppRequestInterceptor implements HttpInterceptor { if (token) { request = request.clone({ - setHeaders: {Authorization: `Bearer ${token}`} + setHeaders: { Authorization: `Bearer ${this.generateToken(request.url)}` } }); } @@ -33,4 +36,10 @@ export class AppRequestInterceptor implements HttpInterceptor { }) ) } + + + generateToken(url: string) { + if (url.includes('71dev')) return this.appService.token() + if (url.includes('cathay-pay')) return this.appService.getsathonToken() + } } diff --git a/src/app/app.service.ts b/src/app/app.service.ts index 2eb1952..f0db129 100644 --- a/src/app/app.service.ts +++ b/src/app/app.service.ts @@ -1,9 +1,9 @@ -import {Inject, Injectable} from '@angular/core'; -import {HttpClient} from '@angular/common/http'; -import {DOCUMENT, Location} from '@angular/common'; -import {from, Observable} from 'rxjs'; -import Swal, {SweetAlertResult} from 'sweetalert2' -import {EAction} from "./@config/app"; +import { Inject, Injectable } from '@angular/core'; +import { HttpClient } from '@angular/common/http'; +import { DOCUMENT, Location } from '@angular/common'; +import { from, Observable } from 'rxjs'; +import Swal, { SweetAlertResult } from 'sweetalert2' +import { EAction } from "./@config/app"; @Injectable() @@ -25,6 +25,14 @@ export class AppService { localStorage.setItem('user', JSON.stringify(data)); } + setSathonToken(data) { + localStorage.setItem('sathontoken', data); + } + + getsathonToken() { + return localStorage.getItem('sathontoken'); + } + token() { const token = localStorage.getItem('token'); if (!token) return null; @@ -42,6 +50,7 @@ export class AppService { async logout() { localStorage.removeItem('token'); localStorage.removeItem('user'); + localStorage.removeItem('sathontoken'); localStorage.clear(); // await lastValueFrom( this.get(this.LOGOUT_API) ) } @@ -51,7 +60,7 @@ export class AppService { return this.httpClient.get(url); } - post(url: string, value: any, options? : any): Observable { + post(url: string, value: any, options?: any): Observable { return this.httpClient.post(url, value, options); } @@ -60,11 +69,11 @@ export class AppService { } message(action: any = 'info', msg: string = 'กรุณาตรวจสอบข้อมูล') { - Swal.fire({icon: action, text: msg, heightAuto: false}); + Swal.fire({ icon: action, text: msg, heightAuto: false }); } html(action: any = 'info', msg: string = 'กรุณาตรวจสอบข้อมูล') { - Swal.fire({icon: action, html: msg, heightAuto: false}); + Swal.fire({ icon: action, html: msg, heightAuto: false }); } confirm(action: string = '', confirmButtonText: string = 'ตกลง', cancelButtonText: string = 'ยกเลิก'): Observable> { diff --git a/src/app/auth/login/login.component.ts b/src/app/auth/login/login.component.ts index 184a528..6846de7 100644 --- a/src/app/auth/login/login.component.ts +++ b/src/app/auth/login/login.component.ts @@ -7,6 +7,7 @@ import { lastValueFrom } from 'rxjs'; import { EAction, EText } from 'src/app/@config/app'; import { CathayAuthService } from 'src/app/core/service/auth/cathay-auth.service'; import { ROLE_ADMIN } from 'src/app/@config/menus'; +import { SathonCathayPayService } from 'src/app/sathon-cathay-pay.service'; @Component({ @@ -27,7 +28,8 @@ export class LoginComponent implements OnInit { private router: Router, private appService: AppService, private authService: AuthService, - private cathayAuthService: CathayAuthService + private cathayAuthService: CathayAuthService, + private sathonSV: SathonCathayPayService ) { } @@ -46,6 +48,7 @@ export class LoginComponent implements OnInit { try { // const result = await lastValueFrom(this.authService.login(this.dataForm)); let cathayResult: any = await lastValueFrom(this.cathayAuthService.login(this.cathayForm)); + let sathonToken: any = await lastValueFrom(this.cathayAuthService.genToken()); let isAdmin = cathayResult.userName == ROLE_ADMIN ? true : false cathayResult = { ...cathayResult, @@ -53,6 +56,7 @@ export class LoginComponent implements OnInit { } this.appService.setToken(cathayResult.token.token) + this.appService.setSathonToken(sathonToken.token) this.appService.setAuth(cathayResult); if (isAdmin) { diff --git a/src/app/core/service/auth/cathay-auth.service.ts b/src/app/core/service/auth/cathay-auth.service.ts index c47dac2..6db09e2 100644 --- a/src/app/core/service/auth/cathay-auth.service.ts +++ b/src/app/core/service/auth/cathay-auth.service.ts @@ -6,16 +6,21 @@ import { environment } from 'src/environments/environment'; @Injectable({ providedIn: 'root' }) -export class CathayAuthService extends BaseService{ - API_URL = environment.CATHAYAPIURL - constructor( - public http: HttpClient - ) { - super('', http) - super.fullUrl = `${this.API_URL}/v1/User` - } +export class CathayAuthService extends BaseService { + API_URL = environment.CATHAYAPIURL + constructor( + public http: HttpClient + ) { + super('', http) + super.fullUrl = `${this.API_URL}/v1/User` + } - login(payload : {'mobileDeviceId': string , 'userName': string , 'password' : string}){ - return this.http.post(`${this.fullUrl}/login`, payload) - } + login(payload: { 'mobileDeviceId': string, 'userName': string, 'password': string }) { + return this.http.post(`${this.fullUrl}/login`, payload) + } + + + genToken() { + return this.http.get(`${environment.APIURL}/api/common/user_login/token`) + } } diff --git a/src/app/pages/@layouts/layouts.component.ts b/src/app/pages/@layouts/layouts.component.ts index 4009de3..09546ed 100644 --- a/src/app/pages/@layouts/layouts.component.ts +++ b/src/app/pages/@layouts/layouts.component.ts @@ -35,8 +35,8 @@ export class PagesLayoutsComponent implements OnInit { } async initAuth() { this.auth = this.app.auth(); - console.log(this.auth) - console.log(this.auth.isAdmin) + // console.log(this.auth) + // console.log(this.auth.isAdmin) this.menus = this.menus.map(r => { if (this.auth.isAdmin) { if (r.roles.includes(ROLE_ADMIN)) return { diff --git a/src/app/pages/manage/users/container/users/users.container.html b/src/app/pages/manage/users/container/users/users.container.html new file mode 100644 index 0000000..f091fe9 --- /dev/null +++ b/src/app/pages/manage/users/container/users/users.container.html @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/app/pages/manage/users/container/users/users.container.scss b/src/app/pages/manage/users/container/users/users.container.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/app/pages/manage/users/container/users/users.container.spec.ts b/src/app/pages/manage/users/container/users/users.container.spec.ts new file mode 100644 index 0000000..ba52070 --- /dev/null +++ b/src/app/pages/manage/users/container/users/users.container.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { UsersContainer } from './users.container'; + +describe('UsersContainer', () => { + let component: UsersContainer; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ UsersContainer ] + }) + .compileComponents(); + + fixture = TestBed.createComponent(UsersContainer); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/pages/manage/users/container/users/users.container.ts b/src/app/pages/manage/users/container/users/users.container.ts new file mode 100644 index 0000000..a7515a3 --- /dev/null +++ b/src/app/pages/manage/users/container/users/users.container.ts @@ -0,0 +1,41 @@ +import { ChangeDetectorRef, Component } from '@angular/core'; +import { catchError, filter, Observable, switchMap, tap, throwError } from 'rxjs'; +import { IDialogConfig, CDialogConfig } from 'src/app/@common/interface/Dialog'; +import { EAction, EText } from 'src/app/@config/app'; +import { SathonCathayPayService } from 'src/app/sathon-cathay-pay.service'; +import { DialogComponent } from '../../../kyc/presenter/dialog/dialog.component'; +import { MatDialog } from '@angular/material/dialog'; +import { AppService } from 'src/app/app.service'; +import { ModalComponent } from '../../presenter/modal/modal.component'; + +@Component({ + selector: 'app-users', + templateUrl: './users.container.html', + styleUrls: ['./users.container.scss'] +}) +export class UsersContainer { + userList$ = new Observable() + dialogConfig: IDialogConfig = CDialogConfig + constructor( + private sathonSV: SathonCathayPayService, + private dialog: MatDialog, + private appService: AppService, + private cdr: ChangeDetectorRef + ) { + this.userList$ = this.sathonSV.getAllUsers() + } + + + edit(user) { + this.dialogConfig.data.action = EAction.UPDATE; + this.dialogConfig.data = user + const dialogRef = this.dialog.open(ModalComponent, this.dialogConfig); + dialogRef.afterClosed().pipe( + filter(isRefresh => isRefresh), + tap(() => { + this.userList$ = this.sathonSV.getAllUsers() + this.cdr.detectChanges() + }) + ).subscribe() + } +} diff --git a/src/app/pages/manage/users/presenter/modal/modal.component.html b/src/app/pages/manage/users/presenter/modal/modal.component.html new file mode 100644 index 0000000..731ae60 --- /dev/null +++ b/src/app/pages/manage/users/presenter/modal/modal.component.html @@ -0,0 +1,80 @@ +
+
+
+

More Detail

+ clear +
+
+
+ +
+
+ เลขประจำตัวประชาชน + + + + +
+
+ +
+
+ ชื่อ นามสกุล + + + + +
+
+ +
+
+ Username + + + + +
+
+ +
+
+ เบอร์โทร + + + +
+
+ +
+
+ อีเมล + + + +
+
+ + +
+
+ Lock/Unlock + + +
+
+ +
+
+ + +
+
+ +
+
+
+
+ + \ No newline at end of file diff --git a/src/app/pages/manage/users/presenter/modal/modal.component.scss b/src/app/pages/manage/users/presenter/modal/modal.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/app/pages/manage/users/presenter/modal/modal.component.spec.ts b/src/app/pages/manage/users/presenter/modal/modal.component.spec.ts new file mode 100644 index 0000000..1b71c6b --- /dev/null +++ b/src/app/pages/manage/users/presenter/modal/modal.component.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ModalComponent } from './modal.component'; + +describe('ModalComponent', () => { + let component: ModalComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ ModalComponent ] + }) + .compileComponents(); + + fixture = TestBed.createComponent(ModalComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/pages/manage/users/presenter/modal/modal.component.ts b/src/app/pages/manage/users/presenter/modal/modal.component.ts new file mode 100644 index 0000000..486af50 --- /dev/null +++ b/src/app/pages/manage/users/presenter/modal/modal.component.ts @@ -0,0 +1,70 @@ +import { ChangeDetectorRef, Component, Inject, OnInit } from '@angular/core'; +import { FormBuilder, FormGroup, Validators } from '@angular/forms'; +import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; +import { Router, ActivatedRoute } from '@angular/router'; +import { tap, catchError, throwError, lastValueFrom, filter, switchMap } from 'rxjs'; +import { IDialogConfigData } from 'src/app/@common/interface/Dialog'; +import { EAction, EText } from 'src/app/@config/app'; +import { AppService } from 'src/app/app.service'; +import { BaseForm } from 'src/app/core/base/base-form'; +import { PromotionService } from 'src/app/core/service/common/promotion.service'; +import { UploadService } from 'src/app/core/service/common/upload.service'; +import { DialogComponent } from '../../../kyc/presenter/dialog/dialog.component'; +import { Location } from '@angular/common'; +import { SathonCathayPayService } from 'src/app/sathon-cathay-pay.service'; + +@Component({ + selector: 'app-modal', + templateUrl: './modal.component.html', + styleUrls: ['./modal.component.scss'] +}) +export class ModalComponent implements OnInit { + IsRefresh: boolean = false + constructor( + public dialogRef: MatDialogRef, + @Inject(MAT_DIALOG_DATA) public dialog: any, + private sathonSV: SathonCathayPayService, + private appsv: AppService + ) { } + + ngOnInit(): void { + } + + changeUserLock({ checked },) { + let userId = this.dialog.id + console.log(checked) + const msg = checked ? 'Unlock' : 'Lock' + this.sathonSV.lockUnlockUser(userId).pipe( + tap(event => { + this.appsv.message(EAction.SUCCESS, `${msg} สำเร็จแล้ว`) + this.IsRefresh = true + }), + tap(() => this.closeDialog()), + catchError(err => { + this.IsRefresh = false + return throwError(err) + }) + ).subscribe() + } + + save() { + let userId = this.dialog.id + this.appsv.confirm(EAction.UPDATE).pipe( + filter(r => r.isConfirmed), + switchMap(() => this.sathonSV.convertToCoperate(userId)), + tap(() => this.IsRefresh = true), + tap(() => this.closeDialog()), + catchError(err => { + this.IsRefresh = false + this.appsv.message('error', 'เกิดข้อผิดพลาด') + return throwError(err) + }) + ).subscribe() + // this.sathonSV.convertToCoperate(userId).subscribe() + } + + closeDialog() { + this.dialogRef.close(this.IsRefresh) + } + +} diff --git a/src/app/pages/manage/users/presenter/user-list/user-list.component.html b/src/app/pages/manage/users/presenter/user-list/user-list.component.html new file mode 100644 index 0000000..627ce02 --- /dev/null +++ b/src/app/pages/manage/users/presenter/user-list/user-list.component.html @@ -0,0 +1,69 @@ +
+ +
+
+
+ + + + +
+
+ + + + +
+
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ลำดับ{{getIndex(i)}}เลขบัตรประชาชน + {{item.personalCardId}} + ชื่อ นามสกุล{{item.fullName}}Username{{item.userName }}Email{{item.email}}More Detail +
+
+ +
+
+
+
+ + +
+
\ No newline at end of file diff --git a/src/app/pages/manage/users/presenter/user-list/user-list.component.scss b/src/app/pages/manage/users/presenter/user-list/user-list.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/app/pages/manage/users/presenter/user-list/user-list.component.spec.ts b/src/app/pages/manage/users/presenter/user-list/user-list.component.spec.ts new file mode 100644 index 0000000..0a4f83a --- /dev/null +++ b/src/app/pages/manage/users/presenter/user-list/user-list.component.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { UserListComponent } from './user-list.component'; + +describe('UserListComponent', () => { + let component: UserListComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ UserListComponent ] + }) + .compileComponents(); + + fixture = TestBed.createComponent(UserListComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/pages/manage/users/presenter/user-list/user-list.component.ts b/src/app/pages/manage/users/presenter/user-list/user-list.component.ts new file mode 100644 index 0000000..923545e --- /dev/null +++ b/src/app/pages/manage/users/presenter/user-list/user-list.component.ts @@ -0,0 +1,57 @@ +import { Component, EventEmitter, Input, OnChanges, Output } from '@angular/core'; +import { Subject, debounceTime, distinctUntilChanged } from 'rxjs'; +import { BaseList } from 'src/app/core/base/base-list'; + +@Component({ + selector: 'app-user-list', + templateUrl: './user-list.component.html', + styleUrls: ['./user-list.component.scss'] +}) +export class UserListComponent extends BaseList implements OnChanges { + @Input() userList: any = []; + @Output() edit = new EventEmitter(); + @Output() search = new EventEmitter(); + @Output() OnDelete = new EventEmitter() + query = { + name: null, + card: null + } + name: string; + filterCard: Subject = new Subject(); + constructor() { + super() + this.filterCard.pipe( + debounceTime(500), + distinctUntilChanged() + ).subscribe(() => this.onSearch()) + } + + ngOnChanges(): void { + this.userList = this.updateMatTable(this.userList ? this.userList : []) + } + + onEdit(user) { + this.edit.emit(user) + } + + onDeleteKyc(uid: string) { + // console.log(uid) + this.OnDelete.emit(uid) + } + + onFilterCard($event) { + const filterValue = this.query.card; + this.userList.filter = filterValue.trim().toLowerCase(); + } + + onFilterName($event) { + const filterValue = this.query.name; + this.userList.filter = filterValue.trim().toLowerCase(); + } + + onSearch() { + const filterValue = this.query.card; + this.userList.filter = filterValue.trim().toLowerCase(); + } + +} diff --git a/src/app/pages/manage/users/router/users-router/users-router.container.ts b/src/app/pages/manage/users/router/users-router/users-router.container.ts new file mode 100644 index 0000000..2a928e2 --- /dev/null +++ b/src/app/pages/manage/users/router/users-router/users-router.container.ts @@ -0,0 +1,9 @@ +import { Component } from '@angular/core'; + +@Component({ + selector: 'app-users-router', + template: '', +}) +export class UsersRouterContainer { + +} diff --git a/src/app/pages/manage/users/users.module.ts b/src/app/pages/manage/users/users.module.ts new file mode 100644 index 0000000..f6b666f --- /dev/null +++ b/src/app/pages/manage/users/users.module.ts @@ -0,0 +1,37 @@ +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { RouterModule, Routes } from '@angular/router'; +import { UsersRouterContainer } from './router/users-router/users-router.container'; +import { UsersContainer } from './container/users/users.container'; +import { ModalComponent } from './presenter/modal/modal.component'; +import { UserListComponent } from './presenter/user-list/user-list.component'; +import { AppSharedModule } from 'src/app/app.shared'; + +const routes: Routes = [ + { + path: '', + component: UsersRouterContainer, + children: [ + { + path: '', + component: UsersContainer + } + ] + } +] + + +@NgModule({ + declarations: [ + UsersRouterContainer, + UsersContainer, + ModalComponent, + UserListComponent + ], + imports: [ + CommonModule, + RouterModule.forChild(routes), + AppSharedModule + ] +}) +export class UsersModule { } diff --git a/src/app/sathon-cathay-pay.service.spec.ts b/src/app/sathon-cathay-pay.service.spec.ts new file mode 100644 index 0000000..fc49643 --- /dev/null +++ b/src/app/sathon-cathay-pay.service.spec.ts @@ -0,0 +1,16 @@ +import { TestBed } from '@angular/core/testing'; + +import { SathonCathayPayService } from './sathon-cathay-pay.service'; + +describe('SathonCathayPayService', () => { + let service: SathonCathayPayService; + + beforeEach(() => { + TestBed.configureTestingModule({}); + service = TestBed.inject(SathonCathayPayService); + }); + + it('should be created', () => { + expect(service).toBeTruthy(); + }); +}); diff --git a/src/app/sathon-cathay-pay.service.ts b/src/app/sathon-cathay-pay.service.ts new file mode 100644 index 0000000..1f93df2 --- /dev/null +++ b/src/app/sathon-cathay-pay.service.ts @@ -0,0 +1,31 @@ +import { HttpClient } from '@angular/common/http'; +import { Injectable } from '@angular/core'; +import { map, Observable } from 'rxjs'; +import { environment } from 'src/environments/environment'; + +@Injectable({ + providedIn: 'root' +}) +export class SathonCathayPayService { + endpoint: string = environment.CATHAYAPIURL + constructor( + private http: HttpClient + ) { } + + getAllUsers(): Observable<[]> { + return this.http.get<[]>(`${this.endpoint}/v1/user`).pipe(map((d: any) => d.data)) + } + + + + lockUnlockUser(id: string): Observable { + const request = { userId: id } + return this.http.post(`${this.endpoint}/v2/Authentication/LockUnlock`, request) + } + + + convertToCoperate(id: string): Observable { + const request = { id } + return this.http.post(`${this.endpoint}/v1/User/convert2coperateType`, request) + } +}