diff --git a/src/app/app.routing.ts b/src/app/app.routing.ts index 8eaf09b..047c476 100644 --- a/src/app/app.routing.ts +++ b/src/app/app.routing.ts @@ -213,13 +213,13 @@ export const appRoutes: Route[] = [ // 'app/modules/admin/member/partner-store/partner-store.module' // ).then((m: any) => m.PartnerStoreModule), // }, - // { - // path: 'partner-recommendation', - // loadChildren: () => - // import( - // 'app/modules/admin/member/partner-recommendation/partner-recommendation.module' - // ).then((m: any) => m.PartnerRecommendationModule), - // }, + { + path: 'recommendation', + loadChildren: () => + import( + 'app/modules/admin/member/recommendation/recommendation.module' + ).then((m: any) => m.RecommendationModule), + }, { path: 'coupon', loadChildren: () => diff --git a/src/app/mock-api/apps/member/partner-recommendation/data.ts b/src/app/mock-api/apps/member/partner-recommendation/data.ts deleted file mode 100644 index e9a512b..0000000 --- a/src/app/mock-api/apps/member/partner-recommendation/data.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* eslint-disable */ - -export const partnerRecommendations = [ - { - id: 'on00', - totalPartnerCount: '5', - totalHoldingMoney: 303675, - totalComp: 108933, - total: 412608, - branchCount: 1, - divisionCount: 1, - officeCount: 1, - storeCount: 1, - memberCount: 1, - nickname: 'on00', - accountHolder: '11', - phoneNumber: '010-1111-1111', - calculateType: '롤링', - ownCash: 50000, - ownComp: 1711, - ownCoupon: 50000, - gameMoney: 0, - todayComp: 0, - totalDeposit: 0, - totalWithdraw: 0, - balance: 0, - registDate: '2022-06-12 15:38', - finalSigninDate: '', - ip: '', - state: '정상', - note: '', - }, -]; diff --git a/src/app/mock-api/apps/member/partner-recommendation/api.ts b/src/app/mock-api/apps/member/recommendation/api.ts similarity index 57% rename from src/app/mock-api/apps/member/partner-recommendation/api.ts rename to src/app/mock-api/apps/member/recommendation/api.ts index 6411665..6670b2b 100644 --- a/src/app/mock-api/apps/member/partner-recommendation/api.ts +++ b/src/app/mock-api/apps/member/recommendation/api.ts @@ -1,13 +1,13 @@ import { Injectable } from '@angular/core'; import { assign, cloneDeep } from 'lodash-es'; import { FuseMockApiService, FuseMockApiUtils } from '@fuse/lib/mock-api'; -import { partnerRecommendations as partnerRecommendationsData } from './data'; +import { recommendations as recommendationsData } from './data'; @Injectable({ providedIn: 'root', }) -export class MemberPartnerRecommendationMockApi { - private _partnerRecommendations: any[] = partnerRecommendationsData; +export class MemberRecommendationMockApi { + private _recommendations: any[] = recommendationsData; /** * Constructor @@ -26,29 +26,24 @@ export class MemberPartnerRecommendationMockApi { */ registerHandlers(): void { // ----------------------------------------------------------------------------------------------------- - // @ PartnerRecommendations - GET + // @ Recommendations - GET // ----------------------------------------------------------------------------------------------------- this._fuseMockApiService - .onGet( - 'api/apps/member/partner-recommendation/partner-recommendations', - 300 - ) + .onGet('api/apps/member/recommendation/recommendations', 300) .reply(({ request }) => { // Get available queries const search = request.params.get('search'); - const sort = request.params.get('sort') || 'name'; + const sort = request.params.get('sort') || 'signinId'; const order = request.params.get('order') || 'asc'; const page = parseInt(request.params.get('page') ?? '1', 10); const size = parseInt(request.params.get('size') ?? '10', 10); - // Clone the partnerRecommendations - let partnerRecommendations: any[] | null = cloneDeep( - this._partnerRecommendations - ); + // Clone the recommendations + let recommendations: any[] | null = cloneDeep(this._recommendations); - // Sort the partnerRecommendations - if (sort === 'sku' || sort === 'name' || sort === 'active') { - partnerRecommendations.sort((a, b) => { + // Sort the recommendations + if (sort === 'signinId' || sort === 'nickname' || sort === 'state') { + recommendations.sort((a, b) => { const fieldA = a[sort].toString().toUpperCase(); const fieldB = b[sort].toString().toUpperCase(); return order === 'asc' @@ -56,15 +51,15 @@ export class MemberPartnerRecommendationMockApi { : fieldB.localeCompare(fieldA); }); } else { - partnerRecommendations.sort((a, b) => + recommendations.sort((a, b) => order === 'asc' ? a[sort] - b[sort] : b[sort] - a[sort] ); } // If search exists... if (search) { - // Filter the partnerRecommendations - partnerRecommendations = partnerRecommendations.filter( + // Filter the recommendations + recommendations = recommendations.filter( (contact: any) => contact.name && contact.name.toLowerCase().includes(search.toLowerCase()) @@ -72,35 +67,32 @@ export class MemberPartnerRecommendationMockApi { } // Paginate - Start - const partnerRecommendationsLength = partnerRecommendations.length; + const recommendationsLength = recommendations.length; // Calculate pagination details const begin = page * size; - const end = Math.min(size * (page + 1), partnerRecommendationsLength); - const lastPage = Math.max( - Math.ceil(partnerRecommendationsLength / size), - 1 - ); + const end = Math.min(size * (page + 1), recommendationsLength); + const lastPage = Math.max(Math.ceil(recommendationsLength / size), 1); // Prepare the pagination object let pagination = {}; // If the requested page number is bigger than // the last possible page number, return null for - // partnerRecommendations but also send the last possible page so + // recommendations but also send the last possible page so // the app can navigate to there if (page > lastPage) { - partnerRecommendations = null; + recommendations = null; pagination = { lastPage, }; } else { // Paginate the results by size - partnerRecommendations = partnerRecommendations.slice(begin, end); + recommendations = recommendations.slice(begin, end); // Prepare the pagination mock-api pagination = { - length: partnerRecommendationsLength, + length: recommendationsLength, size: size, page: page, lastPage: lastPage, @@ -113,41 +105,41 @@ export class MemberPartnerRecommendationMockApi { return [ 200, { - partnerRecommendations, + recommendations, pagination, }, ]; }); // ----------------------------------------------------------------------------------------------------- - // @ PartnerRecommendation - GET + // @ Recommendation - GET // ----------------------------------------------------------------------------------------------------- this._fuseMockApiService - .onGet('api/apps/member/partne-recommendation/partner-recommendation') + .onGet('api/apps/member/recommendation/recommendation') .reply(({ request }) => { // Get the id from the params const id = request.params.get('id'); - // Clone the partnerRecommendations - const partnerRecommendations = cloneDeep(this._partnerRecommendations); + // Clone the recommendations + const recommendations = cloneDeep(this._recommendations); - // Find the partnerRecommendation - const partnerRecommendation = partnerRecommendations.find( + // Find the recommendation + const recommendation = recommendations.find( (item: any) => item.id === id ); // Return the response - return [200, partnerRecommendation]; + return [200, recommendation]; }); // ----------------------------------------------------------------------------------------------------- - // @ PartnerRecommendation - POST + // @ Recommendation - POST // ----------------------------------------------------------------------------------------------------- this._fuseMockApiService - .onPost('api/apps/member/partner-recommendation/partner-recommendation') + .onPost('api/apps/member/recommendation/recommendation') .reply(() => { - // Generate a new partnerRecommendation - const newPartnerRecommendation = { + // Generate a new recommendation + const newRecommendation = { id: FuseMockApiUtils.guid(), category: '', name: 'A New User', @@ -169,62 +161,58 @@ export class MemberPartnerRecommendationMockApi { active: false, }; - // Unshift the new partnerRecommendation - this._partnerRecommendations.unshift(newPartnerRecommendation); + // Unshift the new recommendation + this._recommendations.unshift(newRecommendation); // Return the response - return [200, newPartnerRecommendation]; + return [200, newRecommendation]; }); // ----------------------------------------------------------------------------------------------------- - // @ PartnerRecommendation - PATCH + // @ Recommendation - PATCH // ----------------------------------------------------------------------------------------------------- this._fuseMockApiService - .onPatch('api/apps/member/partner-recommendation/partner-recommendation') + .onPatch('api/apps/member/recommendation/recommendation') .reply(({ request }) => { - // Get the id and partnerRecommendation + // Get the id and recommendation const id = request.body.id; - const partnerRecommendation = cloneDeep( - request.body.partnerRecommendation - ); + const recommendation = cloneDeep(request.body.recommendation); - // Prepare the updated partnerRecommendation - let updatedPartnerRecommendation = null; + // Prepare the updated recommendation + let updatedRecommendation = null; - // Find the partnerRecommendation and update it - this._partnerRecommendations.forEach( - (item, index, partnerRecommendations) => { - if (item.id === id) { - // Update the partnerRecommendation - partnerRecommendations[index] = assign( - {}, - partnerRecommendations[index], - partnerRecommendation - ); + // Find the recommendation and update it + this._recommendations.forEach((item, index, recommendations) => { + if (item.id === id) { + // Update the recommendation + recommendations[index] = assign( + {}, + recommendations[index], + recommendation + ); - // Store the updated partnerRecommendation - updatedPartnerRecommendation = partnerRecommendations[index]; - } + // Store the updated recommendation + updatedRecommendation = recommendations[index]; } - ); + }); // Return the response - return [200, updatedPartnerRecommendation]; + return [200, updatedRecommendation]; }); // ----------------------------------------------------------------------------------------------------- - // @ PartnerRecommendation - DELETE + // @ Recommendation - DELETE // ----------------------------------------------------------------------------------------------------- this._fuseMockApiService - .onDelete('api/apps/member/partner-recommendation/partner-recommendation') + .onDelete('api/apps/member/recommendation/recommendation') .reply(({ request }) => { // Get the id const id = request.params.get('id'); - // Find the partnerRecommendation and delete it - this._partnerRecommendations.forEach((item, index) => { + // Find the recommendation and delete it + this._recommendations.forEach((item, index) => { if (item.id === id) { - this._partnerRecommendations.splice(index, 1); + this._recommendations.splice(index, 1); } }); diff --git a/src/app/mock-api/apps/member/recommendation/data.ts b/src/app/mock-api/apps/member/recommendation/data.ts new file mode 100644 index 0000000..5655c24 --- /dev/null +++ b/src/app/mock-api/apps/member/recommendation/data.ts @@ -0,0 +1,18 @@ +/* eslint-disable */ + +export const recommendations = [ + { + id: '7eb7c859-1347-4317-96b6-9476a7e2ba3c', + signinId: 'on04', + nickname: '가가가', + rank: '매장', + highRank: 'on03', + accountHolder: '국민은행4444444', + holdingMoney: 0, + ownComp: 1649, + state: '정상', + siteAddress: 'web4.nova114.com', + useOrNot: 'Y', + memberCount: 1, + }, +]; diff --git a/src/app/mock-api/common/navigation/data.ts b/src/app/mock-api/common/navigation/data.ts index 409a8b9..48954f6 100644 --- a/src/app/mock-api/common/navigation/data.ts +++ b/src/app/mock-api/common/navigation/data.ts @@ -75,11 +75,11 @@ export const defaultNavigation: FuseNavigationItem[] = [ link: '/member/partner', }, { - id: 'member.partner-recommendation', - title: 'Partner Recommendation', + id: 'member.recommendation', + title: 'Recommendation', type: 'basic', icon: 'heroicons_outline:academic-cap', - link: '/member/partner/recommendation', + link: '/member/recommendation', }, { diff --git a/src/app/mock-api/index.ts b/src/app/mock-api/index.ts index 60ef8ad..94da709 100644 --- a/src/app/mock-api/index.ts +++ b/src/app/mock-api/index.ts @@ -21,7 +21,7 @@ import { MemberPartnerBranchMockApi } from './apps/member/partner-branch/api'; import { MemberPartnerDivisionMockApi } from './apps/member/partner-division/api'; import { MemberPartnerOfficeMockApi } from './apps/member/partner-office/api'; import { MemberPartnerStoreMockApi } from './apps/member/partner-store/api'; -import { MemberPartnerRecommendationMockApi } from './apps/member/partner-recommendation/api'; +import { MemberRecommendationMockApi } from './apps/member/recommendation/api'; import { MemberCouponMockApi } from './apps/member/coupon/api'; import { MemberCouponMoneyLogMockApi } from './apps/member/coupon-money-log/api'; import { MemberCouponLogMockApi } from './apps/member/coupon-log/api'; @@ -94,7 +94,7 @@ export const mockApiServices = [ MemberPartnerDivisionMockApi, MemberPartnerOfficeMockApi, MemberPartnerStoreMockApi, - MemberPartnerRecommendationMockApi, + MemberRecommendationMockApi, MemberCouponMockApi, MemberCouponMoneyLogMockApi, MemberCouponLogMockApi, diff --git a/src/app/modules/admin/member/partner/components/index.ts b/src/app/modules/admin/member/partner/components/index.ts index 49b691e..04759eb 100644 --- a/src/app/modules/admin/member/partner/components/index.ts +++ b/src/app/modules/admin/member/partner/components/index.ts @@ -1,4 +1,3 @@ import { ListComponent } from './list.component'; -import { RecommendationListComponent } from './recommendation-list.component'; -export const COMPONENTS = [ListComponent, RecommendationListComponent]; +export const COMPONENTS = [ListComponent]; diff --git a/src/app/modules/admin/member/partner/components/recommendation-list.component.html b/src/app/modules/admin/member/partner/components/recommendation-list.component.html deleted file mode 100644 index a8fb09c..0000000 --- a/src/app/modules/admin/member/partner/components/recommendation-list.component.html +++ /dev/null @@ -1,372 +0,0 @@ -
- -
- -
- -
- -
추천코드등록
- -
- - - - - - - 40 - 60 - 80 - 100 - - - - - LV.1 - LV.2 - LV.3 - LV.4 - - - - - 정상 - 대기 - 탈퇴 - 휴면 - 블랙 - 정지 - - - - - 카지노제한 - 슬롯제한 - - - - - 계좌입금 - - - - - 카지노콤프 - 슬롯콤프 - 배팅콤프 - 첫충콤프 - - - - - - - - - - - - -
-
- - -
- -
- - -
- -
- - - - - - - - - - - - - - - - - - - - -
- - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-
-
- - -
-
- - -
- There are no partner recommendations! -
-
-
-
-
diff --git a/src/app/modules/admin/member/partner/partner.routing.ts b/src/app/modules/admin/member/partner/partner.routing.ts index 302a340..d80a846 100644 --- a/src/app/modules/admin/member/partner/partner.routing.ts +++ b/src/app/modules/admin/member/partner/partner.routing.ts @@ -1,7 +1,6 @@ import { Route } from '@angular/router'; import { ListComponent } from './components/list.component'; -import { RecommendationListComponent } from './components/recommendation-list.component'; import { PartnersResolver } from './resolvers/partner.resolver'; @@ -18,11 +17,4 @@ export const partnerRoutes: Route[] = [ Partners: PartnersResolver, }, }, - { - path: '', - component: RecommendationListComponent, - resolve: { - Partners: PartnersResolver, - }, - }, ]; diff --git a/src/app/modules/admin/member/recommendation/components/index.ts b/src/app/modules/admin/member/recommendation/components/index.ts new file mode 100644 index 0000000..04759eb --- /dev/null +++ b/src/app/modules/admin/member/recommendation/components/index.ts @@ -0,0 +1,3 @@ +import { ListComponent } from './list.component'; + +export const COMPONENTS = [ListComponent]; diff --git a/src/app/modules/admin/member/recommendation/components/list.component.html b/src/app/modules/admin/member/recommendation/components/list.component.html new file mode 100644 index 0000000..27cb53c --- /dev/null +++ b/src/app/modules/admin/member/recommendation/components/list.component.html @@ -0,0 +1,300 @@ +
+ +
+ +
+ +
+ +
추천코드등록
+ +
+ +
+
+ +
+ +
+ + + + 검색어 + 매장아이디 + 매장닉네임 + + + + + + + + + +
+
+ + +
+ +
+ + +
+ +
+
선택
+
상부
+
+ 아이디 +
+ 닉네임 +
+ 상태 +
+
등급
+ + + +
+ + + +
+
+ +
+
{{ recommendation.highRank }}
+
+ {{ recommendation.signinId }} +
+ {{ recommendation.nickname }} +
+ {{ recommendation.state }} +
+
+ {{ recommendation.rank }} +
+
{{ recommendation.accountHolder }}
+ + +
+
+
+
+
+ +
+ + +
+
+ + +
+ There are no data! +
+
+ + +
+ +
+
+ +
+ +
+ + + + 매장아이디 + 매장닉네임 + + + + + + + + + +
+
+ +
+ + +
+ +
+
선택
+
상부
+
+ 아이디 +
+ 닉네임 +
+ 상태 +
+
등급
+ + +
+ + + +
+
+ +
+
{{ recommendation.highRank }}
+
+ {{ recommendation.signinId }} +
+ {{ recommendation.nickname }} +
+ {{ recommendation.state }} +
+
+ {{ recommendation.rank }} +
+
{{ recommendation.useOrNot }}
+ + +
+
+
+
+
+ +
+ + +
+
+ + +
+ There are no data! +
+
+
+
+
diff --git a/src/app/modules/admin/member/partner/components/recommendation-list.component.ts b/src/app/modules/admin/member/recommendation/components/list.component.ts similarity index 70% rename from src/app/modules/admin/member/partner/components/recommendation-list.component.ts rename to src/app/modules/admin/member/recommendation/components/list.component.ts index 7e05f5b..9fed294 100644 --- a/src/app/modules/admin/member/partner/components/recommendation-list.component.ts +++ b/src/app/modules/admin/member/recommendation/components/list.component.ts @@ -31,9 +31,9 @@ import { FuseConfirmationService } from '@fuse/services/confirmation'; import { User } from '../../user/models/user'; -import { Partner as PartnerRecommendation } from '../models/partner'; -import { PartnerPagination as PartnerRecommendationPagination } from '../models/partner-pagination'; -import { PartnerService as PartnerRecommendationService } from '../services/partner.service'; +import { Recommendation as Recommendation } from '../models/recommendation'; +import { RecommendationPagination as RecommendationPagination } from '../models/recommendation-pagination'; +import { RecommendationService as RecommendationService } from '../services/recommendation.service'; import { Router } from '@angular/router'; @@ -41,23 +41,27 @@ import { MatDialog } from '@angular/material/dialog'; import { RegistComposeComponent } from '../compose/regist-compose.component'; @Component({ selector: 'recommendation-list', - templateUrl: './recommendation-list.component.html', + templateUrl: './list.component.html', styles: [ /* language=SCSS */ ` .inventory-grid { - grid-template-columns: 60px auto 40px; + /* CB 상부 아이디 등급 계좌정보 */ + grid-template-columns: 20px 140px auto 100px 200px; @screen sm { - grid-template-columns: 60px 60px 60px 60px 60px 60px auto 60px; + /* CB 상부 아이디 등급 계좌정보 머니 사이트 사용여부*/ + grid-template-columns: 20px 140px auto 100px 200px 140px 200px 140px; } @screen md { - grid-template-columns: 60px 60px 60px 60px 60px 60px auto 60px 60px; + /* CB 상부 아이디 등급 계좌정보 머니 사이트 사용여부 회원수 */ + grid-template-columns: 20px 140px auto 100px 200px 140px 200px 140px 140px; } @screen lg { - grid-template-columns: 60px 70px 70px 70px 70px 100px 60px 60px auto 60px 60px 60px 60px; + /* CB 상부 아이디 등급 계좌정보 머니 사이트 사용여부 회원수 */ + grid-template-columns: 20px 100px auto 100px 200px 140px 200px 140px 140px; } } `, @@ -66,19 +70,19 @@ import { RegistComposeComponent } from '../compose/regist-compose.component'; changeDetection: ChangeDetectionStrategy.OnPush, animations: fuseAnimations, }) -export class RecommendationListComponent - implements OnInit, AfterViewInit, OnDestroy -{ +export class ListComponent implements OnInit, AfterViewInit, OnDestroy { @ViewChild(MatPaginator) private _paginator!: MatPaginator; @ViewChild(MatSort) private _sort!: MatSort; - partnerRecommendations$!: Observable; + recommendations$!: Observable; users$!: Observable; + __isSearchOpened1 = false; + __isSearchOpened2 = false; isLoading = false; searchInputControl = new FormControl(); - selectedPartnerRecommendation?: PartnerRecommendation; - pagination?: PartnerRecommendationPagination; + selectedRecommendation?: Recommendation; + pagination?: RecommendationPagination; private _unsubscribeAll: Subject = new Subject(); @@ -89,7 +93,7 @@ export class RecommendationListComponent private _changeDetectorRef: ChangeDetectorRef, private _fuseConfirmationService: FuseConfirmationService, private _formBuilder: FormBuilder, - private _partnerRecommendationService: PartnerRecommendationService, + private _recommendationService: RecommendationService, private router: Router, private _matDialog: MatDialog ) {} @@ -103,9 +107,9 @@ export class RecommendationListComponent */ ngOnInit(): void { // Get the pagination - this._partnerRecommendationService.pagination$ + this._recommendationService.pagination$ .pipe(takeUntil(this._unsubscribeAll)) - .subscribe((pagination: PartnerRecommendationPagination | undefined) => { + .subscribe((pagination: RecommendationPagination | undefined) => { // Update the pagination this.pagination = pagination; @@ -114,7 +118,7 @@ export class RecommendationListComponent }); // Get the products - this.partnerRecommendations$ = this._partnerRecommendationService.partners$; + this.recommendations$ = this._recommendationService.recommendations$; } /** @@ -132,7 +136,7 @@ export class RecommendationListComponent // Mark for check this._changeDetectorRef.markForCheck(); - // If the partnerRecommendation changes the sort order... + // If the recommendation changes the sort order... this._sort.sortChange .pipe(takeUntil(this._unsubscribeAll)) .subscribe(() => { @@ -145,7 +149,7 @@ export class RecommendationListComponent .pipe( switchMap(() => { this.isLoading = true; - return this._partnerRecommendationService.getPartners( + return this._recommendationService.getRecommendations( this._paginator.pageIndex, this._paginator.pageSize, this._sort.active, @@ -193,6 +197,17 @@ export class RecommendationListComponent */ __toggleDetails(productId: string): void {} + /** + * toggle the search + * Used in 'bar' + */ + __onClickSearch1(): void { + this.__isSearchOpened1 = !this.__isSearchOpened1; + } + __onClickSearch2(): void { + this.__isSearchOpened2 = !this.__isSearchOpened2; + } + /** * Track by function for ngFor loops * diff --git a/src/app/modules/admin/member/recommendation/compose/index.ts b/src/app/modules/admin/member/recommendation/compose/index.ts new file mode 100644 index 0000000..593e5ce --- /dev/null +++ b/src/app/modules/admin/member/recommendation/compose/index.ts @@ -0,0 +1,3 @@ +import { RegistComposeComponent } from './regist-compose.component'; + +export const COMPOSE = [RegistComposeComponent]; diff --git a/src/app/modules/admin/member/recommendation/compose/regist-compose.component.html b/src/app/modules/admin/member/recommendation/compose/regist-compose.component.html new file mode 100644 index 0000000..109a5cd --- /dev/null +++ b/src/app/modules/admin/member/recommendation/compose/regist-compose.component.html @@ -0,0 +1,111 @@ +
+ +
+
대본사 생성
+ +
+ + +
+ + + 파트너아이디 + + + + + + 사이트명 + + + + + + 회원 아이디 + + + + + + 비밀번호 + + + + + 환전 비밀번호 + + + + + 닉네임 + + + + + 정산종류 + + + + + 휴대폰번호 + + + + + 은행명 + + + + + 계좌번호 + + + + + 예금주 + + + + + + + +
+
+ + + + + + +
+
+
+
diff --git a/src/app/modules/admin/member/recommendation/compose/regist-compose.component.ts b/src/app/modules/admin/member/recommendation/compose/regist-compose.component.ts new file mode 100644 index 0000000..3f0319b --- /dev/null +++ b/src/app/modules/admin/member/recommendation/compose/regist-compose.component.ts @@ -0,0 +1,100 @@ +import { Component, OnInit, ViewEncapsulation } from '@angular/core'; +import { FormBuilder, FormGroup, Validators } from '@angular/forms'; +import { MatDialogRef } from '@angular/material/dialog'; + +@Component({ + selector: 'app-regist-compose', + templateUrl: './regist-compose.component.html', + encapsulation: ViewEncapsulation.None, +}) +export class RegistComposeComponent implements OnInit { + composeForm!: FormGroup; + copyFields: { cc: boolean; bcc: boolean } = { + cc: false, + bcc: false, + }; + // quillModules: any = { + // toolbar: [ + // ['bold', 'italic', 'underline'], + // [{ align: [] }, { list: 'ordered' }, { list: 'bullet' }], + // ['clean'], + // ], + // }; + + /** + * Constructor + */ + constructor( + public matDialogRef: MatDialogRef, + private _formBuilder: FormBuilder + ) {} + + // ----------------------------------------------------------------------------------------------------- + // @ Lifecycle hooks + // ----------------------------------------------------------------------------------------------------- + + /** + * On init + */ + ngOnInit(): void { + // Create the form + this.composeForm = this._formBuilder.group({ + partnerId: [{ value: 'kgon4', disabled: true }], + siteName: [''], + signinId: [''], + password: [''], + exchangePw: [''], + nickname: [''], + calculateType: [''], + phoneNumber: [''], + bankName: [''], + accountNumber: [''], + accountHolder: [''], + }); + } + + // ----------------------------------------------------------------------------------------------------- + // @ Public methods + // ----------------------------------------------------------------------------------------------------- + + /** + * Show the copy field with the given field name + * + * @param name + */ + showCopyField(name: string): void { + // Return if the name is not one of the available names + if (name !== 'cc' && name !== 'bcc') { + return; + } + + // Show the field + this.copyFields[name] = true; + } + + /** + * Save and close + */ + saveAndClose(): void { + // Save the message as a draft + this.saveAsDraft(); + + // Close the dialog + this.matDialogRef.close(); + } + + /** + * Discard the message + */ + discard(): void {} + + /** + * Save the message as a draft + */ + saveAsDraft(): void {} + + /** + * Send the message + */ + send(): void {} +} diff --git a/src/app/modules/admin/member/recommendation/models/recommendation-pagination.ts b/src/app/modules/admin/member/recommendation/models/recommendation-pagination.ts new file mode 100644 index 0000000..842c3bf --- /dev/null +++ b/src/app/modules/admin/member/recommendation/models/recommendation-pagination.ts @@ -0,0 +1,8 @@ +export interface RecommendationPagination { + length: number; + size: number; + page: number; + lastPage: number; + startIndex: number; + endIndex: number; +} diff --git a/src/app/modules/admin/member/recommendation/models/recommendation.ts b/src/app/modules/admin/member/recommendation/models/recommendation.ts new file mode 100644 index 0000000..184be2b --- /dev/null +++ b/src/app/modules/admin/member/recommendation/models/recommendation.ts @@ -0,0 +1,16 @@ +import { NumberValueAccessor } from '@angular/forms'; + +export interface Recommendation { + id: string; + signinId?: string; + nickname?: string; + rank?: string; + highRank?: string; + accountHolder?: string; + holdingMoney?: number; + ownComp?: number; + state?: string; + siteAddress?: string; + useOrNot?: string; + memberCount?: number; +} diff --git a/src/app/modules/admin/member/recommendation/recommendation.module.ts b/src/app/modules/admin/member/recommendation/recommendation.module.ts new file mode 100644 index 0000000..4475008 --- /dev/null +++ b/src/app/modules/admin/member/recommendation/recommendation.module.ts @@ -0,0 +1,51 @@ +import { NgModule } from '@angular/core'; +import { RouterModule } from '@angular/router'; + +import { MatButtonModule } from '@angular/material/button'; +import { MatFormFieldModule } from '@angular/material/form-field'; +import { MatIconModule } from '@angular/material/icon'; +import { MatInputModule } from '@angular/material/input'; +import { MatPaginatorModule } from '@angular/material/paginator'; +import { MatProgressBarModule } from '@angular/material/progress-bar'; +import { MatRippleModule } from '@angular/material/core'; +import { MatSortModule } from '@angular/material/sort'; +import { MatSelectModule } from '@angular/material/select'; +import { MatTooltipModule } from '@angular/material/tooltip'; +import { MatGridListModule } from '@angular/material/grid-list'; +import { MatSlideToggleModule } from '@angular/material/slide-toggle'; +import { MatRadioModule } from '@angular/material/radio'; +import { MatCheckboxModule } from '@angular/material/checkbox'; + +import { TranslocoModule } from '@ngneat/transloco'; + +import { SharedModule } from 'app/shared/shared.module'; + +import { COMPONENTS } from './components'; +import { COMPOSE } from './compose'; + +import { recommendationRoutes } from './recommendation.routing'; + +@NgModule({ + declarations: [COMPONENTS, COMPOSE], + imports: [ + TranslocoModule, + SharedModule, + RouterModule.forChild(recommendationRoutes), + + MatButtonModule, + MatFormFieldModule, + MatIconModule, + MatInputModule, + MatPaginatorModule, + MatProgressBarModule, + MatRippleModule, + MatSortModule, + MatSelectModule, + MatTooltipModule, + MatGridListModule, + MatSlideToggleModule, + MatRadioModule, + MatCheckboxModule, + ], +}) +export class RecommendationModule {} diff --git a/src/app/modules/admin/member/recommendation/recommendation.routing.ts b/src/app/modules/admin/member/recommendation/recommendation.routing.ts new file mode 100644 index 0000000..556d226 --- /dev/null +++ b/src/app/modules/admin/member/recommendation/recommendation.routing.ts @@ -0,0 +1,20 @@ +import { Route } from '@angular/router'; + +import { ListComponent } from './components/list.component'; + +import { RecommendationsResolver } from './resolvers/recommendation.resolver'; + +export const recommendationRoutes: Route[] = [ + // { + // path: '', + // pathMatch: 'full', + // redirectTo: 'all', + // }, + { + path: '', + component: ListComponent, + resolve: { + Recommendations: RecommendationsResolver, + }, + }, +]; diff --git a/src/app/modules/admin/member/recommendation/resolvers/recommendation.resolver.ts b/src/app/modules/admin/member/recommendation/resolvers/recommendation.resolver.ts new file mode 100644 index 0000000..bd52abf --- /dev/null +++ b/src/app/modules/admin/member/recommendation/resolvers/recommendation.resolver.ts @@ -0,0 +1,89 @@ +import { Injectable } from '@angular/core'; +import { + ActivatedRouteSnapshot, + Resolve, + Router, + RouterStateSnapshot, +} from '@angular/router'; +import { catchError, Observable, throwError } from 'rxjs'; + +import { Recommendation } from '../models/recommendation'; +import { RecommendationPagination } from '../models/recommendation-pagination'; +import { RecommendationService } from '../services/recommendation.service'; + +@Injectable({ + providedIn: 'root', +}) +export class RecommendationResolver implements Resolve { + /** + * Constructor + */ + constructor( + private _recommendationServiceService: RecommendationService, + private _router: Router + ) {} + + // ----------------------------------------------------------------------------------------------------- + // @ Public methods + // ----------------------------------------------------------------------------------------------------- + + /** + * Resolver + * + * @param route + * @param state + */ + resolve( + route: ActivatedRouteSnapshot, + state: RouterStateSnapshot + ): Observable { + return this._recommendationServiceService + .getRecommendationById(route.paramMap.get('id')) + .pipe( + // Error here means the requested product is not available + catchError((error) => { + // Log the error + console.error(error); + + // Get the parent url + const parentUrl = state.url.split('/').slice(0, -1).join('/'); + + // Navigate to there + this._router.navigateByUrl(parentUrl); + + // Throw an error + return throwError(error); + }) + ); + } +} + +@Injectable({ + providedIn: 'root', +}) +export class RecommendationsResolver implements Resolve { + /** + * Constructor + */ + constructor(private _recommendationService: RecommendationService) {} + + // ----------------------------------------------------------------------------------------------------- + // @ Public methods + // ----------------------------------------------------------------------------------------------------- + + /** + * Resolver + * + * @param route + * @param state + */ + resolve( + route: ActivatedRouteSnapshot, + state: RouterStateSnapshot + ): Observable<{ + pagination: RecommendationPagination; + recommendations: Recommendation[]; + }> { + return this._recommendationService.getRecommendations(); + } +} diff --git a/src/app/modules/admin/member/recommendation/services/recommendation.service.ts b/src/app/modules/admin/member/recommendation/services/recommendation.service.ts new file mode 100644 index 0000000..73eac28 --- /dev/null +++ b/src/app/modules/admin/member/recommendation/services/recommendation.service.ts @@ -0,0 +1,161 @@ +import { Injectable } from '@angular/core'; +import { HttpClient } from '@angular/common/http'; +import { + BehaviorSubject, + filter, + map, + Observable, + of, + switchMap, + take, + tap, + throwError, +} from 'rxjs'; + +import { Recommendation } from '../models/recommendation'; +import { RecommendationPagination } from '../models/recommendation-pagination'; + +@Injectable({ + providedIn: 'root', +}) +export class RecommendationService { + // Private + private __pagination = new BehaviorSubject< + RecommendationPagination | undefined + >(undefined); + private __recommendation = new BehaviorSubject( + undefined + ); + private __recommendations = new BehaviorSubject( + undefined + ); + + /** + * Constructor + */ + constructor(private _httpClient: HttpClient) {} + + // ----------------------------------------------------------------------------------------------------- + // @ Accessors + // ----------------------------------------------------------------------------------------------------- + + /** + * Getter for pagination + */ + get pagination$(): Observable { + return this.__pagination.asObservable(); + } + + /** + * Getter for recommendation + */ + get recommendation$(): Observable { + return this.__recommendation.asObservable(); + } + + /** + * Getter for recommendations + */ + get recommendations$(): Observable { + return this.__recommendations.asObservable(); + } + + // ----------------------------------------------------------------------------------------------------- + // @ Public methods + // ----------------------------------------------------------------------------------------------------- + + /** + * Get recommendations + * + * + * @param page + * @param size + * @param sort + * @param order + * @param search + */ + getRecommendations( + page: number = 0, + size: number = 10, + sort: string = 'name', + order: 'asc' | 'desc' | '' = 'asc', + search: string = '' + ): Observable<{ + pagination: RecommendationPagination; + recommendations: Recommendation[]; + }> { + return this._httpClient + .get<{ + pagination: RecommendationPagination; + recommendations: Recommendation[]; + }>('api/apps/member/recommendation/recommendations', { + params: { + page: '' + page, + size: '' + size, + sort, + order, + search, + }, + }) + .pipe( + tap((response) => { + this.__pagination.next(response.pagination); + this.__recommendations.next(response.recommendations); + }) + ); + } + + /** + * Get product by id + */ + getRecommendationById(id: string | null): Observable { + return this.__recommendations.pipe( + take(1), + map((recommendations) => { + // Find the product + const recommendation = + recommendations?.find((item) => item.id === id) || undefined; + + // Update the product + this.__recommendation.next(recommendation); + + // Return the product + return recommendation; + }), + switchMap((product) => { + if (!product) { + return throwError('Could not found product with id of ' + id + '!'); + } + + return of(product); + }) + ); + } + + /** + * Create product + */ + createRecommendation(): Observable { + return this.recommendations$.pipe( + take(1), + switchMap((recommendations) => + this._httpClient + .post('api/apps/member/recommendation/product', {}) + .pipe( + map((newRecommendation) => { + // Update the recommendations with the new product + if (!!recommendations) { + this.__recommendations.next([ + newRecommendation, + ...recommendations, + ]); + } + + // Return the new product + return newRecommendation; + }) + ) + ) + ); + } +} diff --git a/src/assets/i18n/en.json b/src/assets/i18n/en.json index 0f919dc..93deb7c 100644 --- a/src/assets/i18n/en.json +++ b/src/assets/i18n/en.json @@ -7,7 +7,7 @@ "Unconnected": "Unconnected", "Project": "Project", "Partner": "Partner", - "Partner Recommendation": "Partner Recommendation", + "Recommendation": "Recommendation", "Coupon": "Coupon", "Coupon Money Log": "Coupon Money Log", "Coupon Log": "Coupon Log", diff --git a/src/assets/i18n/ko.json b/src/assets/i18n/ko.json index 8352274..59bf5e3 100644 --- a/src/assets/i18n/ko.json +++ b/src/assets/i18n/ko.json @@ -8,7 +8,7 @@ "Project": "프로젝트", "partner-management": "파트너관리", "Partner": "파트너", - "Partner Recommendation": "추천코드등록", + "Recommendation": "추천코드등록", "Coupon": "쿠폰발행리스트", "Coupon Money Log": "쿠폰발행머니로그", "Coupon Log": "쿠폰발행 로그",