사이드메뉴-파트너관리 정리
This commit is contained in:
parent
b82b13bc30
commit
74afc90896
|
@ -214,11 +214,11 @@ export const appRoutes: Route[] = [
|
||||||
// ).then((m: any) => m.PartnerStoreModule),
|
// ).then((m: any) => m.PartnerStoreModule),
|
||||||
// },
|
// },
|
||||||
{
|
{
|
||||||
path: 'recommendation',
|
path: 'partner-recommendation',
|
||||||
loadChildren: () =>
|
loadChildren: () =>
|
||||||
import(
|
import(
|
||||||
'app/modules/admin/member/recommendation/recommendation.module'
|
'app/modules/admin/member/partner-recommendation/partner-recommendation.module'
|
||||||
).then((m: any) => m.RecommendationModule),
|
).then((m: any) => m.PartnerRecommendationModule),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'coupon',
|
path: 'coupon',
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { assign, cloneDeep } from 'lodash-es';
|
import { assign, cloneDeep } from 'lodash-es';
|
||||||
import { FuseMockApiService, FuseMockApiUtils } from '@fuse/lib/mock-api';
|
import { FuseMockApiService, FuseMockApiUtils } from '@fuse/lib/mock-api';
|
||||||
import { recommendations as recommendationsData } from './data';
|
import { partnerRecommendations as partnerRecommendationsData } from './data';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
})
|
})
|
||||||
export class MemberRecommendationMockApi {
|
export class MemberPartnerRecommendationMockApi {
|
||||||
private _recommendations: any[] = recommendationsData;
|
private _partnerRecommendations: any[] = partnerRecommendationsData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
|
@ -26,10 +26,13 @@ export class MemberRecommendationMockApi {
|
||||||
*/
|
*/
|
||||||
registerHandlers(): void {
|
registerHandlers(): void {
|
||||||
// -----------------------------------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------------------------------
|
||||||
// @ Recommendations - GET
|
// @ PartnerRecommendations - GET
|
||||||
// -----------------------------------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------------------------------
|
||||||
this._fuseMockApiService
|
this._fuseMockApiService
|
||||||
.onGet('api/apps/member/recommendation/recommendations', 300)
|
.onGet(
|
||||||
|
'api/apps/member/partner-recommendation/partner-recommendations',
|
||||||
|
300
|
||||||
|
)
|
||||||
.reply(({ request }) => {
|
.reply(({ request }) => {
|
||||||
// Get available queries
|
// Get available queries
|
||||||
const search = request.params.get('search');
|
const search = request.params.get('search');
|
||||||
|
@ -38,12 +41,14 @@ export class MemberRecommendationMockApi {
|
||||||
const page = parseInt(request.params.get('page') ?? '1', 10);
|
const page = parseInt(request.params.get('page') ?? '1', 10);
|
||||||
const size = parseInt(request.params.get('size') ?? '10', 10);
|
const size = parseInt(request.params.get('size') ?? '10', 10);
|
||||||
|
|
||||||
// Clone the recommendations
|
// Clone the partnerRecommendations
|
||||||
let recommendations: any[] | null = cloneDeep(this._recommendations);
|
let partnerRecommendations: any[] | null = cloneDeep(
|
||||||
|
this._partnerRecommendations
|
||||||
|
);
|
||||||
|
|
||||||
// Sort the recommendations
|
// Sort the partnerRecommendations
|
||||||
if (sort === 'signinId' || sort === 'nickname' || sort === 'state') {
|
if (sort === 'signinId' || sort === 'nickname' || sort === 'state') {
|
||||||
recommendations.sort((a, b) => {
|
partnerRecommendations.sort((a, b) => {
|
||||||
const fieldA = a[sort].toString().toUpperCase();
|
const fieldA = a[sort].toString().toUpperCase();
|
||||||
const fieldB = b[sort].toString().toUpperCase();
|
const fieldB = b[sort].toString().toUpperCase();
|
||||||
return order === 'asc'
|
return order === 'asc'
|
||||||
|
@ -51,15 +56,15 @@ export class MemberRecommendationMockApi {
|
||||||
: fieldB.localeCompare(fieldA);
|
: fieldB.localeCompare(fieldA);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
recommendations.sort((a, b) =>
|
partnerRecommendations.sort((a, b) =>
|
||||||
order === 'asc' ? a[sort] - b[sort] : b[sort] - a[sort]
|
order === 'asc' ? a[sort] - b[sort] : b[sort] - a[sort]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If search exists...
|
// If search exists...
|
||||||
if (search) {
|
if (search) {
|
||||||
// Filter the recommendations
|
// Filter the partnerRecommendations
|
||||||
recommendations = recommendations.filter(
|
partnerRecommendations = partnerRecommendations.filter(
|
||||||
(contact: any) =>
|
(contact: any) =>
|
||||||
contact.name &&
|
contact.name &&
|
||||||
contact.name.toLowerCase().includes(search.toLowerCase())
|
contact.name.toLowerCase().includes(search.toLowerCase())
|
||||||
|
@ -67,32 +72,35 @@ export class MemberRecommendationMockApi {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Paginate - Start
|
// Paginate - Start
|
||||||
const recommendationsLength = recommendations.length;
|
const partnerRecommendationsLength = partnerRecommendations.length;
|
||||||
|
|
||||||
// Calculate pagination details
|
// Calculate pagination details
|
||||||
const begin = page * size;
|
const begin = page * size;
|
||||||
const end = Math.min(size * (page + 1), recommendationsLength);
|
const end = Math.min(size * (page + 1), partnerRecommendationsLength);
|
||||||
const lastPage = Math.max(Math.ceil(recommendationsLength / size), 1);
|
const lastPage = Math.max(
|
||||||
|
Math.ceil(partnerRecommendationsLength / size),
|
||||||
|
1
|
||||||
|
);
|
||||||
|
|
||||||
// Prepare the pagination object
|
// Prepare the pagination object
|
||||||
let pagination = {};
|
let pagination = {};
|
||||||
|
|
||||||
// If the requested page number is bigger than
|
// If the requested page number is bigger than
|
||||||
// the last possible page number, return null for
|
// the last possible page number, return null for
|
||||||
// recommendations but also send the last possible page so
|
// partnerRecommendations but also send the last possible page so
|
||||||
// the app can navigate to there
|
// the app can navigate to there
|
||||||
if (page > lastPage) {
|
if (page > lastPage) {
|
||||||
recommendations = null;
|
partnerRecommendations = null;
|
||||||
pagination = {
|
pagination = {
|
||||||
lastPage,
|
lastPage,
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
// Paginate the results by size
|
// Paginate the results by size
|
||||||
recommendations = recommendations.slice(begin, end);
|
partnerRecommendations = partnerRecommendations.slice(begin, end);
|
||||||
|
|
||||||
// Prepare the pagination mock-api
|
// Prepare the pagination mock-api
|
||||||
pagination = {
|
pagination = {
|
||||||
length: recommendationsLength,
|
length: partnerRecommendationsLength,
|
||||||
size: size,
|
size: size,
|
||||||
page: page,
|
page: page,
|
||||||
lastPage: lastPage,
|
lastPage: lastPage,
|
||||||
|
@ -105,41 +113,41 @@ export class MemberRecommendationMockApi {
|
||||||
return [
|
return [
|
||||||
200,
|
200,
|
||||||
{
|
{
|
||||||
recommendations,
|
partnerRecommendations,
|
||||||
pagination,
|
pagination,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------------------------------
|
||||||
// @ Recommendation - GET
|
// @ PartnerRecommendation - GET
|
||||||
// -----------------------------------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------------------------------
|
||||||
this._fuseMockApiService
|
this._fuseMockApiService
|
||||||
.onGet('api/apps/member/recommendation/recommendation')
|
.onGet('api/apps/member/partner-recommendation/partner-recommendation')
|
||||||
.reply(({ request }) => {
|
.reply(({ request }) => {
|
||||||
// Get the id from the params
|
// Get the id from the params
|
||||||
const id = request.params.get('id');
|
const id = request.params.get('id');
|
||||||
|
|
||||||
// Clone the recommendations
|
// Clone the partnerRecommendations
|
||||||
const recommendations = cloneDeep(this._recommendations);
|
const partnerRecommendations = cloneDeep(this._partnerRecommendations);
|
||||||
|
|
||||||
// Find the recommendation
|
// Find the partnerRecommendation
|
||||||
const recommendation = recommendations.find(
|
const partnerRecommendation = partnerRecommendations.find(
|
||||||
(item: any) => item.id === id
|
(item: any) => item.id === id
|
||||||
);
|
);
|
||||||
|
|
||||||
// Return the response
|
// Return the response
|
||||||
return [200, recommendation];
|
return [200, partnerRecommendation];
|
||||||
});
|
});
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------------------------------
|
||||||
// @ Recommendation - POST
|
// @ PartnerRecommendation - POST
|
||||||
// -----------------------------------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------------------------------
|
||||||
this._fuseMockApiService
|
this._fuseMockApiService
|
||||||
.onPost('api/apps/member/recommendation/recommendation')
|
.onPost('api/apps/member/partner-recommendation/partner-recommendation')
|
||||||
.reply(() => {
|
.reply(() => {
|
||||||
// Generate a new recommendation
|
// Generate a new partnerRecommendation
|
||||||
const newRecommendation = {
|
const newPartnerRecommendation = {
|
||||||
id: FuseMockApiUtils.guid(),
|
id: FuseMockApiUtils.guid(),
|
||||||
category: '',
|
category: '',
|
||||||
name: 'A New User',
|
name: 'A New User',
|
||||||
|
@ -161,58 +169,62 @@ export class MemberRecommendationMockApi {
|
||||||
active: false,
|
active: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Unshift the new recommendation
|
// Unshift the new partnerRecommendation
|
||||||
this._recommendations.unshift(newRecommendation);
|
this._partnerRecommendations.unshift(newPartnerRecommendation);
|
||||||
|
|
||||||
// Return the response
|
// Return the response
|
||||||
return [200, newRecommendation];
|
return [200, newPartnerRecommendation];
|
||||||
});
|
});
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------------------------------
|
||||||
// @ Recommendation - PATCH
|
// @ PartnerRecommendation - PATCH
|
||||||
// -----------------------------------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------------------------------
|
||||||
this._fuseMockApiService
|
this._fuseMockApiService
|
||||||
.onPatch('api/apps/member/recommendation/recommendation')
|
.onPatch('api/apps/member/partner-recommendation/partner-recommendation')
|
||||||
.reply(({ request }) => {
|
.reply(({ request }) => {
|
||||||
// Get the id and recommendation
|
// Get the id and partnerRecommendation
|
||||||
const id = request.body.id;
|
const id = request.body.id;
|
||||||
const recommendation = cloneDeep(request.body.recommendation);
|
const partnerRecommendation = cloneDeep(
|
||||||
|
request.body.partnerRecommendation
|
||||||
|
);
|
||||||
|
|
||||||
// Prepare the updated recommendation
|
// Prepare the updated partnerRecommendation
|
||||||
let updatedRecommendation = null;
|
let updatedPartnerRecommendation = null;
|
||||||
|
|
||||||
// Find the recommendation and update it
|
// Find the partnerRecommendation and update it
|
||||||
this._recommendations.forEach((item, index, recommendations) => {
|
this._partnerRecommendations.forEach(
|
||||||
if (item.id === id) {
|
(item, index, partnerRecommendations) => {
|
||||||
// Update the recommendation
|
if (item.id === id) {
|
||||||
recommendations[index] = assign(
|
// Update the partnerRecommendation
|
||||||
{},
|
partnerRecommendations[index] = assign(
|
||||||
recommendations[index],
|
{},
|
||||||
recommendation
|
partnerRecommendations[index],
|
||||||
);
|
partnerRecommendation
|
||||||
|
);
|
||||||
|
|
||||||
// Store the updated recommendation
|
// Store the updated partnerRecommendation
|
||||||
updatedRecommendation = recommendations[index];
|
updatedPartnerRecommendation = partnerRecommendations[index];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
);
|
||||||
|
|
||||||
// Return the response
|
// Return the response
|
||||||
return [200, updatedRecommendation];
|
return [200, updatedPartnerRecommendation];
|
||||||
});
|
});
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------------------------------
|
||||||
// @ Recommendation - DELETE
|
// @ PartnerRecommendation - DELETE
|
||||||
// -----------------------------------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------------------------------
|
||||||
this._fuseMockApiService
|
this._fuseMockApiService
|
||||||
.onDelete('api/apps/member/recommendation/recommendation')
|
.onDelete('api/apps/member/partner-recommendation/partner-recommendation')
|
||||||
.reply(({ request }) => {
|
.reply(({ request }) => {
|
||||||
// Get the id
|
// Get the id
|
||||||
const id = request.params.get('id');
|
const id = request.params.get('id');
|
||||||
|
|
||||||
// Find the recommendation and delete it
|
// Find the partnerRecommendation and delete it
|
||||||
this._recommendations.forEach((item, index) => {
|
this._partnerRecommendations.forEach((item, index) => {
|
||||||
if (item.id === id) {
|
if (item.id === id) {
|
||||||
this._recommendations.splice(index, 1);
|
this._partnerRecommendations.splice(index, 1);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
|
|
||||||
export const recommendations = [
|
export const partnerRecommendations = [
|
||||||
{
|
{
|
||||||
id: '7eb7c859-1347-4317-96b6-9476a7e2ba3c',
|
id: '7eb7c859-1347-4317-96b6-9476a7e2ba3c',
|
||||||
signinId: 'on04',
|
signinId: 'on04',
|
|
@ -68,18 +68,61 @@ export const defaultNavigation: FuseNavigationItem[] = [
|
||||||
link: '/member/current-user',
|
link: '/member/current-user',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'member.partner',
|
id: 'apps.ecommerce',
|
||||||
title: 'Partner',
|
title: 'partner-management',
|
||||||
type: 'basic',
|
type: 'collapsable',
|
||||||
icon: 'heroicons_outline:academic-cap',
|
icon: 'heroicons_outline:shopping-cart',
|
||||||
link: '/member/partner',
|
children: [
|
||||||
},
|
{
|
||||||
{
|
id: 'member.partner',
|
||||||
id: 'member.recommendation',
|
title: 'All Partner',
|
||||||
title: 'Recommendation',
|
type: 'basic',
|
||||||
type: 'basic',
|
icon: 'heroicons_outline:academic-cap',
|
||||||
icon: 'heroicons_outline:academic-cap',
|
link: '/member/partner/all',
|
||||||
link: '/member/recommendation',
|
},
|
||||||
|
{
|
||||||
|
id: 'member.partner-mainoffice',
|
||||||
|
title: 'Partner Mainoffice',
|
||||||
|
type: 'basic',
|
||||||
|
icon: 'heroicons_outline:academic-cap',
|
||||||
|
link: '/member/partner/main-office',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'member.partner-branch',
|
||||||
|
title: 'Partner Branch',
|
||||||
|
type: 'basic',
|
||||||
|
icon: 'heroicons_outline:academic-cap',
|
||||||
|
link: '/member/partner/branch',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'member.partner-division',
|
||||||
|
title: 'Partner Division',
|
||||||
|
type: 'basic',
|
||||||
|
icon: 'heroicons_outline:academic-cap',
|
||||||
|
link: '/member/partner/division',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'member.partner-office',
|
||||||
|
title: 'Partner Office',
|
||||||
|
type: 'basic',
|
||||||
|
icon: 'heroicons_outline:academic-cap',
|
||||||
|
link: '/member/partner/office',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'member.partner-store',
|
||||||
|
title: 'Partner Store',
|
||||||
|
type: 'basic',
|
||||||
|
icon: 'heroicons_outline:academic-cap',
|
||||||
|
link: '/member/partner/store',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'member.partner-recommendation',
|
||||||
|
title: 'Partner Recommendation',
|
||||||
|
type: 'basic',
|
||||||
|
icon: 'heroicons_outline:academic-cap',
|
||||||
|
link: '/member/partner/recommendation',
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
|
@ -21,7 +21,7 @@ import { MemberPartnerBranchMockApi } from './apps/member/partner-branch/api';
|
||||||
import { MemberPartnerDivisionMockApi } from './apps/member/partner-division/api';
|
import { MemberPartnerDivisionMockApi } from './apps/member/partner-division/api';
|
||||||
import { MemberPartnerOfficeMockApi } from './apps/member/partner-office/api';
|
import { MemberPartnerOfficeMockApi } from './apps/member/partner-office/api';
|
||||||
import { MemberPartnerStoreMockApi } from './apps/member/partner-store/api';
|
import { MemberPartnerStoreMockApi } from './apps/member/partner-store/api';
|
||||||
import { MemberRecommendationMockApi } from './apps/member/recommendation/api';
|
import { MemberPartnerRecommendationMockApi } from './apps/member/partner-recommendation/api';
|
||||||
import { MemberCouponMockApi } from './apps/member/coupon/api';
|
import { MemberCouponMockApi } from './apps/member/coupon/api';
|
||||||
import { MemberCouponMoneyLogMockApi } from './apps/member/coupon-money-log/api';
|
import { MemberCouponMoneyLogMockApi } from './apps/member/coupon-money-log/api';
|
||||||
import { MemberCouponLogMockApi } from './apps/member/coupon-log/api';
|
import { MemberCouponLogMockApi } from './apps/member/coupon-log/api';
|
||||||
|
@ -94,7 +94,7 @@ export const mockApiServices = [
|
||||||
MemberPartnerDivisionMockApi,
|
MemberPartnerDivisionMockApi,
|
||||||
MemberPartnerOfficeMockApi,
|
MemberPartnerOfficeMockApi,
|
||||||
MemberPartnerStoreMockApi,
|
MemberPartnerStoreMockApi,
|
||||||
MemberRecommendationMockApi,
|
MemberPartnerRecommendationMockApi,
|
||||||
MemberCouponMockApi,
|
MemberCouponMockApi,
|
||||||
MemberCouponMoneyLogMockApi,
|
MemberCouponMoneyLogMockApi,
|
||||||
MemberCouponLogMockApi,
|
MemberCouponLogMockApi,
|
||||||
|
|
|
@ -70,8 +70,15 @@
|
||||||
<div
|
<div
|
||||||
class="flex flex-col flex-auto sm:mb-18 overflow-hidden sm:overflow-y-auto"
|
class="flex flex-col flex-auto sm:mb-18 overflow-hidden sm:overflow-y-auto"
|
||||||
>
|
>
|
||||||
<ng-container *ngIf="recommendations$ | async as recommendations">
|
<ng-container
|
||||||
<ng-container *ngIf="recommendations.length > 0; else noRecommendation">
|
*ngIf="partnerRecommendations$ | async as partnerRecommendations"
|
||||||
|
>
|
||||||
|
<ng-container
|
||||||
|
*ngIf="
|
||||||
|
partnerRecommendations.length > 0;
|
||||||
|
else noPartnerRecommendation
|
||||||
|
"
|
||||||
|
>
|
||||||
<div class="grid">
|
<div class="grid">
|
||||||
<!-- Header -->
|
<!-- Header -->
|
||||||
<div
|
<div
|
||||||
|
@ -96,10 +103,12 @@
|
||||||
<div class="hidden md:block">사이트</div>
|
<div class="hidden md:block">사이트</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- Rows -->
|
<!-- Rows -->
|
||||||
<ng-container *ngIf="recommendations$ | async as recommendations">
|
<ng-container
|
||||||
|
*ngIf="partnerRecommendations$ | async as partnerRecommendations"
|
||||||
|
>
|
||||||
<ng-container
|
<ng-container
|
||||||
*ngFor="
|
*ngFor="
|
||||||
let recommendation of recommendations;
|
let partnerRecommendation of partnerRecommendations;
|
||||||
trackBy: __trackByFn
|
trackBy: __trackByFn
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
|
@ -109,25 +118,25 @@
|
||||||
<div>
|
<div>
|
||||||
<mat-checkbox></mat-checkbox>
|
<mat-checkbox></mat-checkbox>
|
||||||
</div>
|
</div>
|
||||||
<div>{{ recommendation.highRank }}</div>
|
<div>{{ partnerRecommendation.highRank }}</div>
|
||||||
<div>
|
<div>
|
||||||
{{ recommendation.signinId }}
|
{{ partnerRecommendation.signinId }}
|
||||||
<hr style="margin: 7px 0px" />
|
<hr style="margin: 7px 0px" />
|
||||||
{{ recommendation.nickname }}
|
{{ partnerRecommendation.nickname }}
|
||||||
<hr style="margin: 7px 0px" />
|
<hr style="margin: 7px 0px" />
|
||||||
{{ recommendation.state }}
|
{{ partnerRecommendation.state }}
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
{{ recommendation.rank }}
|
{{ partnerRecommendation.rank }}
|
||||||
</div>
|
</div>
|
||||||
<div>{{ recommendation.accountHolder }}</div>
|
<div>{{ partnerRecommendation.accountHolder }}</div>
|
||||||
<div class="hidden sm:block">
|
<div class="hidden sm:block">
|
||||||
{{ recommendation.holdingMoney }}
|
{{ partnerRecommendation.holdingMoney }}
|
||||||
<hr style="margin: 7px 0px" />
|
<hr style="margin: 7px 0px" />
|
||||||
{{ recommendation.ownComp }}
|
{{ partnerRecommendation.ownComp }}
|
||||||
</div>
|
</div>
|
||||||
<div class="hidden lg:block">
|
<div class="hidden lg:block">
|
||||||
{{ recommendation.siteAddress }}
|
{{ partnerRecommendation.siteAddress }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
@ -151,7 +160,7 @@
|
||||||
</ng-container>
|
</ng-container>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<ng-template #noRecommendation>
|
<ng-template #noPartnerRecommendation>
|
||||||
<div
|
<div
|
||||||
class="p-8 sm:p-16 border-t text-4xl font-semibold tracking-tight text-center"
|
class="p-8 sm:p-16 border-t text-4xl font-semibold tracking-tight text-center"
|
||||||
>
|
>
|
||||||
|
@ -214,8 +223,15 @@
|
||||||
<div
|
<div
|
||||||
class="flex flex-col flex-auto sm:mb-18 overflow-hidden sm:overflow-y-auto"
|
class="flex flex-col flex-auto sm:mb-18 overflow-hidden sm:overflow-y-auto"
|
||||||
>
|
>
|
||||||
<ng-container *ngIf="recommendations$ | async as recommendations">
|
<ng-container
|
||||||
<ng-container *ngIf="recommendations.length > 0; else noRecommendation">
|
*ngIf="partnerRecommendations$ | async as partnerRecommendations"
|
||||||
|
>
|
||||||
|
<ng-container
|
||||||
|
*ngIf="
|
||||||
|
partnerRecommendations.length > 0;
|
||||||
|
else noPartnerRecommendation
|
||||||
|
"
|
||||||
|
>
|
||||||
<div class="grid">
|
<div class="grid">
|
||||||
<!-- Header -->
|
<!-- Header -->
|
||||||
<div
|
<div
|
||||||
|
@ -235,10 +251,12 @@
|
||||||
<div class="hidden sm:block">회원수</div>
|
<div class="hidden sm:block">회원수</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- Rows -->
|
<!-- Rows -->
|
||||||
<ng-container *ngIf="recommendations$ | async as recommendations">
|
<ng-container
|
||||||
|
*ngIf="partnerRecommendations$ | async as partnerRecommendations"
|
||||||
|
>
|
||||||
<ng-container
|
<ng-container
|
||||||
*ngFor="
|
*ngFor="
|
||||||
let recommendation of recommendations;
|
let partnerRecommendation of partnerRecommendations;
|
||||||
trackBy: __trackByFn
|
trackBy: __trackByFn
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
|
@ -248,23 +266,23 @@
|
||||||
<div>
|
<div>
|
||||||
<mat-checkbox></mat-checkbox>
|
<mat-checkbox></mat-checkbox>
|
||||||
</div>
|
</div>
|
||||||
<div>{{ recommendation.highRank }}</div>
|
<div>{{ partnerRecommendation.highRank }}</div>
|
||||||
<div>
|
<div>
|
||||||
{{ recommendation.signinId }}
|
{{ partnerRecommendation.signinId }}
|
||||||
<hr style="margin: 7px 0px" />
|
<hr style="margin: 7px 0px" />
|
||||||
{{ recommendation.nickname }}
|
{{ partnerRecommendation.nickname }}
|
||||||
<hr style="margin: 7px 0px" />
|
<hr style="margin: 7px 0px" />
|
||||||
{{ recommendation.state }}
|
{{ partnerRecommendation.state }}
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
{{ recommendation.rank }}
|
{{ partnerRecommendation.rank }}
|
||||||
</div>
|
</div>
|
||||||
<div>{{ recommendation.useOrNot }}</div>
|
<div>{{ partnerRecommendation.useOrNot }}</div>
|
||||||
<div class="hidden sm:block">
|
<div class="hidden sm:block">
|
||||||
{{ recommendation.memberCount }}
|
{{ partnerRecommendation.memberCount }}
|
||||||
</div>
|
</div>
|
||||||
<div class="hidden lg:block">
|
<div class="hidden lg:block">
|
||||||
{{ recommendation.siteAddress }}
|
{{ partnerRecommendation.siteAddress }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
@ -288,7 +306,7 @@
|
||||||
</ng-container>
|
</ng-container>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<ng-template #noRecommendation>
|
<ng-template #noPartnerRecommendation>
|
||||||
<div
|
<div
|
||||||
class="p-8 sm:p-16 border-t text-4xl font-semibold tracking-tight text-center"
|
class="p-8 sm:p-16 border-t text-4xl font-semibold tracking-tight text-center"
|
||||||
>
|
>
|
|
@ -31,16 +31,16 @@ import { FuseConfirmationService } from '@fuse/services/confirmation';
|
||||||
|
|
||||||
import { User } from '../../user/models/user';
|
import { User } from '../../user/models/user';
|
||||||
|
|
||||||
import { Recommendation as Recommendation } from '../models/recommendation';
|
import { PartnerRecommendation as PartnerRecommendation } from '../models/partner-recommendation';
|
||||||
import { RecommendationPagination as RecommendationPagination } from '../models/recommendation-pagination';
|
import { PartnerRecommendationPagination as PartnerRecommendationPagination } from '../models/partner-recommendation-pagination';
|
||||||
import { RecommendationService as RecommendationService } from '../services/recommendation.service';
|
import { PartnerRecommendationService as PartnerRecommendationService } from '../services/partner-recommendation.service';
|
||||||
|
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
|
|
||||||
import { MatDialog } from '@angular/material/dialog';
|
import { MatDialog } from '@angular/material/dialog';
|
||||||
import { RegistComposeComponent } from '../compose/regist-compose.component';
|
import { RegistComposeComponent } from '../compose/regist-compose.component';
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'recommendation-list',
|
selector: 'partner-recommendation-list',
|
||||||
templateUrl: './list.component.html',
|
templateUrl: './list.component.html',
|
||||||
styles: [
|
styles: [
|
||||||
/* language=SCSS */
|
/* language=SCSS */
|
||||||
|
@ -74,15 +74,15 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||||
@ViewChild(MatPaginator) private _paginator!: MatPaginator;
|
@ViewChild(MatPaginator) private _paginator!: MatPaginator;
|
||||||
@ViewChild(MatSort) private _sort!: MatSort;
|
@ViewChild(MatSort) private _sort!: MatSort;
|
||||||
|
|
||||||
recommendations$!: Observable<Recommendation[] | undefined>;
|
partnerRecommendations$!: Observable<PartnerRecommendation[] | undefined>;
|
||||||
users$!: Observable<User[] | undefined>;
|
users$!: Observable<User[] | undefined>;
|
||||||
|
|
||||||
__isSearchOpened1 = false;
|
__isSearchOpened1 = false;
|
||||||
__isSearchOpened2 = false;
|
__isSearchOpened2 = false;
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
searchInputControl = new FormControl();
|
searchInputControl = new FormControl();
|
||||||
selectedRecommendation?: Recommendation;
|
selectedPartnerRecommendation?: PartnerRecommendation;
|
||||||
pagination?: RecommendationPagination;
|
pagination?: PartnerRecommendationPagination;
|
||||||
|
|
||||||
private _unsubscribeAll: Subject<any> = new Subject<any>();
|
private _unsubscribeAll: Subject<any> = new Subject<any>();
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||||
private _changeDetectorRef: ChangeDetectorRef,
|
private _changeDetectorRef: ChangeDetectorRef,
|
||||||
private _fuseConfirmationService: FuseConfirmationService,
|
private _fuseConfirmationService: FuseConfirmationService,
|
||||||
private _formBuilder: FormBuilder,
|
private _formBuilder: FormBuilder,
|
||||||
private _recommendationService: RecommendationService,
|
private _partnerRecommendationService: PartnerRecommendationService,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private _matDialog: MatDialog
|
private _matDialog: MatDialog
|
||||||
) {}
|
) {}
|
||||||
|
@ -107,9 +107,9 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||||
*/
|
*/
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
// Get the pagination
|
// Get the pagination
|
||||||
this._recommendationService.pagination$
|
this._partnerRecommendationService.pagination$
|
||||||
.pipe(takeUntil(this._unsubscribeAll))
|
.pipe(takeUntil(this._unsubscribeAll))
|
||||||
.subscribe((pagination: RecommendationPagination | undefined) => {
|
.subscribe((pagination: PartnerRecommendationPagination | undefined) => {
|
||||||
// Update the pagination
|
// Update the pagination
|
||||||
this.pagination = pagination;
|
this.pagination = pagination;
|
||||||
|
|
||||||
|
@ -118,7 +118,8 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Get the products
|
// Get the products
|
||||||
this.recommendations$ = this._recommendationService.recommendations$;
|
this.partnerRecommendations$ =
|
||||||
|
this._partnerRecommendationService.partnerRecommendations$;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -136,7 +137,7 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||||
// Mark for check
|
// Mark for check
|
||||||
this._changeDetectorRef.markForCheck();
|
this._changeDetectorRef.markForCheck();
|
||||||
|
|
||||||
// If the recommendation changes the sort order...
|
// If the partnerRecommendation changes the sort order...
|
||||||
this._sort.sortChange
|
this._sort.sortChange
|
||||||
.pipe(takeUntil(this._unsubscribeAll))
|
.pipe(takeUntil(this._unsubscribeAll))
|
||||||
.subscribe(() => {
|
.subscribe(() => {
|
||||||
|
@ -149,7 +150,7 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||||
.pipe(
|
.pipe(
|
||||||
switchMap(() => {
|
switchMap(() => {
|
||||||
this.isLoading = true;
|
this.isLoading = true;
|
||||||
return this._recommendationService.getRecommendations(
|
return this._partnerRecommendationService.getPartnerRecommendations(
|
||||||
this._paginator.pageIndex,
|
this._paginator.pageIndex,
|
||||||
this._paginator.pageSize,
|
this._paginator.pageSize,
|
||||||
this._sort.active,
|
this._sort.active,
|
|
@ -1,4 +1,4 @@
|
||||||
export interface RecommendationPagination {
|
export interface PartnerRecommendationPagination {
|
||||||
length: number;
|
length: number;
|
||||||
size: number;
|
size: number;
|
||||||
page: number;
|
page: number;
|
|
@ -1,6 +1,6 @@
|
||||||
import { NumberValueAccessor } from '@angular/forms';
|
import { NumberValueAccessor } from '@angular/forms';
|
||||||
|
|
||||||
export interface Recommendation {
|
export interface PartnerRecommendation {
|
||||||
id: string;
|
id: string;
|
||||||
signinId?: string;
|
signinId?: string;
|
||||||
nickname?: string;
|
nickname?: string;
|
|
@ -23,14 +23,14 @@ import { SharedModule } from 'app/shared/shared.module';
|
||||||
import { COMPONENTS } from './components';
|
import { COMPONENTS } from './components';
|
||||||
import { COMPOSE } from './compose';
|
import { COMPOSE } from './compose';
|
||||||
|
|
||||||
import { recommendationRoutes } from './recommendation.routing';
|
import { partnerRecommendationRoutes } from './partner-recommendation.routing';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [COMPONENTS, COMPOSE],
|
declarations: [COMPONENTS, COMPOSE],
|
||||||
imports: [
|
imports: [
|
||||||
TranslocoModule,
|
TranslocoModule,
|
||||||
SharedModule,
|
SharedModule,
|
||||||
RouterModule.forChild(recommendationRoutes),
|
RouterModule.forChild(partnerRecommendationRoutes),
|
||||||
|
|
||||||
MatButtonModule,
|
MatButtonModule,
|
||||||
MatFormFieldModule,
|
MatFormFieldModule,
|
||||||
|
@ -48,4 +48,4 @@ import { recommendationRoutes } from './recommendation.routing';
|
||||||
MatCheckboxModule,
|
MatCheckboxModule,
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
export class RecommendationModule {}
|
export class PartnerRecommendationModule {}
|
|
@ -2,9 +2,9 @@ import { Route } from '@angular/router';
|
||||||
|
|
||||||
import { ListComponent } from './components/list.component';
|
import { ListComponent } from './components/list.component';
|
||||||
|
|
||||||
import { RecommendationsResolver } from './resolvers/recommendation.resolver';
|
import { PartnerRecommendationsResolver } from './resolvers/partner-recommendation.resolver';
|
||||||
|
|
||||||
export const recommendationRoutes: Route[] = [
|
export const partnerRecommendationRoutes: Route[] = [
|
||||||
// {
|
// {
|
||||||
// path: '',
|
// path: '',
|
||||||
// pathMatch: 'full',
|
// pathMatch: 'full',
|
||||||
|
@ -14,7 +14,7 @@ export const recommendationRoutes: Route[] = [
|
||||||
path: '',
|
path: '',
|
||||||
component: ListComponent,
|
component: ListComponent,
|
||||||
resolve: {
|
resolve: {
|
||||||
Recommendations: RecommendationsResolver,
|
PartnerRecommendations: PartnerRecommendationsResolver,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
];
|
];
|
|
@ -7,19 +7,19 @@ import {
|
||||||
} from '@angular/router';
|
} from '@angular/router';
|
||||||
import { catchError, Observable, throwError } from 'rxjs';
|
import { catchError, Observable, throwError } from 'rxjs';
|
||||||
|
|
||||||
import { Recommendation } from '../models/recommendation';
|
import { PartnerRecommendation } from '../models/partner-recommendation';
|
||||||
import { RecommendationPagination } from '../models/recommendation-pagination';
|
import { PartnerRecommendationPagination } from '../models/partner-recommendation-pagination';
|
||||||
import { RecommendationService } from '../services/recommendation.service';
|
import { PartnerRecommendationService } from '../services/partner-recommendation.service';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
})
|
})
|
||||||
export class RecommendationResolver implements Resolve<any> {
|
export class PartnerRecommendationResolver implements Resolve<any> {
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
constructor(
|
constructor(
|
||||||
private _recommendationServiceService: RecommendationService,
|
private _partnerRecommendationServiceService: PartnerRecommendationService,
|
||||||
private _router: Router
|
private _router: Router
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
|
@ -36,9 +36,9 @@ export class RecommendationResolver implements Resolve<any> {
|
||||||
resolve(
|
resolve(
|
||||||
route: ActivatedRouteSnapshot,
|
route: ActivatedRouteSnapshot,
|
||||||
state: RouterStateSnapshot
|
state: RouterStateSnapshot
|
||||||
): Observable<Recommendation | undefined> {
|
): Observable<PartnerRecommendation | undefined> {
|
||||||
return this._recommendationServiceService
|
return this._partnerRecommendationServiceService
|
||||||
.getRecommendationById(route.paramMap.get('id'))
|
.getPartnerRecommendationById(route.paramMap.get('id'))
|
||||||
.pipe(
|
.pipe(
|
||||||
// Error here means the requested product is not available
|
// Error here means the requested product is not available
|
||||||
catchError((error) => {
|
catchError((error) => {
|
||||||
|
@ -61,11 +61,13 @@ export class RecommendationResolver implements Resolve<any> {
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
})
|
})
|
||||||
export class RecommendationsResolver implements Resolve<any> {
|
export class PartnerRecommendationsResolver implements Resolve<any> {
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
constructor(private _recommendationService: RecommendationService) {}
|
constructor(
|
||||||
|
private _partnerRecommendationService: PartnerRecommendationService
|
||||||
|
) {}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------------------------------
|
||||||
// @ Public methods
|
// @ Public methods
|
||||||
|
@ -81,9 +83,9 @@ export class RecommendationsResolver implements Resolve<any> {
|
||||||
route: ActivatedRouteSnapshot,
|
route: ActivatedRouteSnapshot,
|
||||||
state: RouterStateSnapshot
|
state: RouterStateSnapshot
|
||||||
): Observable<{
|
): Observable<{
|
||||||
pagination: RecommendationPagination;
|
pagination: PartnerRecommendationPagination;
|
||||||
recommendations: Recommendation[];
|
partnerRecommendations: PartnerRecommendation[];
|
||||||
}> {
|
}> {
|
||||||
return this._recommendationService.getRecommendations();
|
return this._partnerRecommendationService.getPartnerRecommendations();
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,168 @@
|
||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import { HttpClient } from '@angular/common/http';
|
||||||
|
import {
|
||||||
|
BehaviorSubject,
|
||||||
|
filter,
|
||||||
|
map,
|
||||||
|
Observable,
|
||||||
|
of,
|
||||||
|
switchMap,
|
||||||
|
take,
|
||||||
|
tap,
|
||||||
|
throwError,
|
||||||
|
} from 'rxjs';
|
||||||
|
|
||||||
|
import { PartnerRecommendation } from '../models/partner-recommendation';
|
||||||
|
import { PartnerRecommendationPagination } from '../models/partner-recommendation-pagination';
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root',
|
||||||
|
})
|
||||||
|
export class PartnerRecommendationService {
|
||||||
|
// Private
|
||||||
|
private __pagination = new BehaviorSubject<
|
||||||
|
PartnerRecommendationPagination | undefined
|
||||||
|
>(undefined);
|
||||||
|
private __partnerRecommendation = new BehaviorSubject<
|
||||||
|
PartnerRecommendation | undefined
|
||||||
|
>(undefined);
|
||||||
|
private __partnerRecommendations = new BehaviorSubject<
|
||||||
|
PartnerRecommendation[] | undefined
|
||||||
|
>(undefined);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*/
|
||||||
|
constructor(private _httpClient: HttpClient) {}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------------------------
|
||||||
|
// @ Accessors
|
||||||
|
// -----------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter for pagination
|
||||||
|
*/
|
||||||
|
get pagination$(): Observable<PartnerRecommendationPagination | undefined> {
|
||||||
|
return this.__pagination.asObservable();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter for partnerRecommendation
|
||||||
|
*/
|
||||||
|
get partnerRecommendation$(): Observable<PartnerRecommendation | undefined> {
|
||||||
|
return this.__partnerRecommendation.asObservable();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter for partnerRecommendations
|
||||||
|
*/
|
||||||
|
get partnerRecommendations$(): Observable<
|
||||||
|
PartnerRecommendation[] | undefined
|
||||||
|
> {
|
||||||
|
return this.__partnerRecommendations.asObservable();
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------------------------
|
||||||
|
// @ Public methods
|
||||||
|
// -----------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get partnerRecommendations
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param page
|
||||||
|
* @param size
|
||||||
|
* @param sort
|
||||||
|
* @param order
|
||||||
|
* @param search
|
||||||
|
*/
|
||||||
|
getPartnerRecommendations(
|
||||||
|
page: number = 0,
|
||||||
|
size: number = 10,
|
||||||
|
sort: string = 'name',
|
||||||
|
order: 'asc' | 'desc' | '' = 'asc',
|
||||||
|
search: string = ''
|
||||||
|
): Observable<{
|
||||||
|
pagination: PartnerRecommendationPagination;
|
||||||
|
partnerRecommendations: PartnerRecommendation[];
|
||||||
|
}> {
|
||||||
|
return this._httpClient
|
||||||
|
.get<{
|
||||||
|
pagination: PartnerRecommendationPagination;
|
||||||
|
partnerRecommendations: PartnerRecommendation[];
|
||||||
|
}>('api/apps/member/partner-recommendation/partner-recommendations', {
|
||||||
|
params: {
|
||||||
|
page: '' + page,
|
||||||
|
size: '' + size,
|
||||||
|
sort,
|
||||||
|
order,
|
||||||
|
search,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.pipe(
|
||||||
|
tap((response) => {
|
||||||
|
this.__pagination.next(response.pagination);
|
||||||
|
this.__partnerRecommendations.next(response.partnerRecommendations);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get product by id
|
||||||
|
*/
|
||||||
|
getPartnerRecommendationById(
|
||||||
|
id: string | null
|
||||||
|
): Observable<PartnerRecommendation> {
|
||||||
|
return this.__partnerRecommendations.pipe(
|
||||||
|
take(1),
|
||||||
|
map((partnerRecommendations) => {
|
||||||
|
// Find the product
|
||||||
|
const partnerRecommendation =
|
||||||
|
partnerRecommendations?.find((item) => item.id === id) || undefined;
|
||||||
|
|
||||||
|
// Update the product
|
||||||
|
this.__partnerRecommendation.next(partnerRecommendation);
|
||||||
|
|
||||||
|
// Return the product
|
||||||
|
return partnerRecommendation;
|
||||||
|
}),
|
||||||
|
switchMap((product) => {
|
||||||
|
if (!product) {
|
||||||
|
return throwError('Could not found product with id of ' + id + '!');
|
||||||
|
}
|
||||||
|
|
||||||
|
return of(product);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create product
|
||||||
|
*/
|
||||||
|
createPartnerRecommendation(): Observable<PartnerRecommendation> {
|
||||||
|
return this.partnerRecommendations$.pipe(
|
||||||
|
take(1),
|
||||||
|
switchMap((partnerRecommendations) =>
|
||||||
|
this._httpClient
|
||||||
|
.post<PartnerRecommendation>(
|
||||||
|
'api/apps/member/partner-recommendation/product',
|
||||||
|
{}
|
||||||
|
)
|
||||||
|
.pipe(
|
||||||
|
map((newPartnerRecommendation) => {
|
||||||
|
// Update the partnerRecommendations with the new product
|
||||||
|
if (!!partnerRecommendations) {
|
||||||
|
this.__partnerRecommendations.next([
|
||||||
|
newPartnerRecommendation,
|
||||||
|
...partnerRecommendations,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return the new product
|
||||||
|
return newPartnerRecommendation;
|
||||||
|
})
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -11,7 +11,7 @@ export const partnerRoutes: Route[] = [
|
||||||
// redirectTo: 'all',
|
// redirectTo: 'all',
|
||||||
// },
|
// },
|
||||||
{
|
{
|
||||||
path: '',
|
path: 'all',
|
||||||
component: ListComponent,
|
component: ListComponent,
|
||||||
resolve: {
|
resolve: {
|
||||||
Partners: PartnersResolver,
|
Partners: PartnersResolver,
|
||||||
|
|
|
@ -1,161 +0,0 @@
|
||||||
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<Recommendation | undefined>(
|
|
||||||
undefined
|
|
||||||
);
|
|
||||||
private __recommendations = new BehaviorSubject<Recommendation[] | undefined>(
|
|
||||||
undefined
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
*/
|
|
||||||
constructor(private _httpClient: HttpClient) {}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------------------------
|
|
||||||
// @ Accessors
|
|
||||||
// -----------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Getter for pagination
|
|
||||||
*/
|
|
||||||
get pagination$(): Observable<RecommendationPagination | undefined> {
|
|
||||||
return this.__pagination.asObservable();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Getter for recommendation
|
|
||||||
*/
|
|
||||||
get recommendation$(): Observable<Recommendation | undefined> {
|
|
||||||
return this.__recommendation.asObservable();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Getter for recommendations
|
|
||||||
*/
|
|
||||||
get recommendations$(): Observable<Recommendation[] | undefined> {
|
|
||||||
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<Recommendation> {
|
|
||||||
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<Recommendation> {
|
|
||||||
return this.recommendations$.pipe(
|
|
||||||
take(1),
|
|
||||||
switchMap((recommendations) =>
|
|
||||||
this._httpClient
|
|
||||||
.post<Recommendation>('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;
|
|
||||||
})
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -6,8 +6,14 @@
|
||||||
"Casino Money": "Casino Money",
|
"Casino Money": "Casino Money",
|
||||||
"Unconnected": "Unconnected",
|
"Unconnected": "Unconnected",
|
||||||
"Project": "Project",
|
"Project": "Project",
|
||||||
"Partner": "Partner",
|
"partner-management": "partner-management",
|
||||||
"Recommendation": "Recommendation",
|
"All Partner": "All Partner",
|
||||||
|
"Partner Mainoffice": "Partner Mainoffice",
|
||||||
|
"Partner Branch": "Partner Branch",
|
||||||
|
"Partner Division": "Partner Division",
|
||||||
|
"Partner Office": "Partner Office",
|
||||||
|
"Partner Store": "Partner Store",
|
||||||
|
"Partner Recommendation": "Recommendation",
|
||||||
"Coupon": "Coupon",
|
"Coupon": "Coupon",
|
||||||
"Coupon Money Log": "Coupon Money Log",
|
"Coupon Money Log": "Coupon Money Log",
|
||||||
"Coupon Log": "Coupon Log",
|
"Coupon Log": "Coupon Log",
|
||||||
|
|
|
@ -7,8 +7,13 @@
|
||||||
"Unconnected": "장기미접속회원",
|
"Unconnected": "장기미접속회원",
|
||||||
"Project": "프로젝트",
|
"Project": "프로젝트",
|
||||||
"partner-management": "파트너관리",
|
"partner-management": "파트너관리",
|
||||||
"Partner": "파트너",
|
"All Partner": "전체파트너",
|
||||||
"Recommendation": "추천코드등록",
|
"Partner Mainoffice": "본사",
|
||||||
|
"Partner Branch": "대본",
|
||||||
|
"Partner Division": "부본",
|
||||||
|
"Partner Office": "총판",
|
||||||
|
"Partner Store": "매장",
|
||||||
|
"Partner Recommendation": "추천코드등록",
|
||||||
"Coupon": "쿠폰발행리스트",
|
"Coupon": "쿠폰발행리스트",
|
||||||
"Coupon Money Log": "쿠폰발행머니로그",
|
"Coupon Money Log": "쿠폰발행머니로그",
|
||||||
"Coupon Log": "쿠폰발행 로그",
|
"Coupon Log": "쿠폰발행 로그",
|
||||||
|
|
Loading…
Reference in New Issue
Block a user