You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
RTL/src/app/cln/transactions/offers/offers-table/offers-table.component.ts

249 lines
31 KiB
TypeScript

/* eslint-disable max-len */
import { Component, OnInit, OnDestroy, ViewChild, AfterViewInit } from '@angular/core';
import { DecimalPipe, DatePipe } from '@angular/common';
import { Subject } from 'rxjs';
import { take, takeUntil } from 'rxjs/operators';
import { Store } from '@ngrx/store';
import { faHistory } from '@fortawesome/free-solid-svg-icons';
import { MatPaginator, MatPaginatorIntl } from '@angular/material/paginator';
import { MatSort } from '@angular/material/sort';
import { MatTableDataSource } from '@angular/material/table';
import * as pdfMake from 'pdfmake/build/pdfmake';
import * as pdfFonts from 'pdfmake/build/vfs_fonts';
import { PAGE_SIZE, PAGE_SIZE_OPTIONS, getPaginatorLabel, ScreenSizeEnum, APICallStatusEnum, AlertTypeEnum } from '../../../../shared/services/consts-enums-functions';
import { ApiCallStatusPayload } from '../../../../shared/models/apiCallsPayload';
import { SelNodeChild } from '../../../../shared/models/RTLconfig';
import { GetInfo, Offer, OfferRequest } from '../../../../shared/models/clnModels';
import { DataService } from '../../../../shared/services/data.service';
import { LoggerService } from '../../../../shared/services/logger.service';
import { CommonService } from '../../../../shared/services/common.service';
import { CLNCreateOfferComponent } from '../create-offer-modal/create-offer.component';
import { CLNOfferInformationComponent } from '../offer-information-modal/offer-information.component';
import { RTLEffects } from '../../../../store/rtl.effects';
import { RTLState } from '../../../../store/rtl.state';
import { openAlert, openConfirmation } from '../../../../store/rtl.actions';
import { disableOffer } from '../../../store/cln.actions';
import { clnNodeInformation, clnNodeSettings, offers } from '../../../store/cln.selector';
@Component({
selector: 'rtl-cln-offers-table',
templateUrl: './offers-table.component.html',
styleUrls: ['./offers-table.component.scss'],
providers: [
{ provide: MatPaginatorIntl, useValue: getPaginatorLabel('Offers') }
]
})
export class CLNOffersTableComponent implements OnInit, AfterViewInit, OnDestroy {
@ViewChild(MatSort, { static: false }) sort: MatSort | undefined;
@ViewChild(MatPaginator, { static: false }) paginator: MatPaginator | undefined;
faHistory = faHistory;
public selNode: SelNodeChild = {};
public newlyAddedOfferMemo = '';
public newlyAddedOfferValue = 0;
public description = '';
public expiry: number;
public offerValue: number = null;
public offerValueHint = '';
public displayedColumns: any[] = [];
public offerPaymentReq = '';
public offers: any;
public offerJSONArr: Offer[] = [];
public information: GetInfo = {};
public flgSticky = false;
public private = false;
public expiryStep = 100;
public pageSize = PAGE_SIZE;
public pageSizeOptions = PAGE_SIZE_OPTIONS;
public screenSize = '';
public screenSizeEnum = ScreenSizeEnum;
public errorMessage = '';
public selFilter = '';
public apiCallStatus: ApiCallStatusPayload | null = null;
public apiCallStatusEnum = APICallStatusEnum;
private unSubs: Array<Subject<void>> = [new Subject(), new Subject(), new Subject(), new Subject(), new Subject(), new Subject(), new Subject()];
constructor(private logger: LoggerService, private store: Store<RTLState>, private commonService: CommonService, private rtlEffects: RTLEffects, private dataService: DataService, private decimalPipe: DecimalPipe, private datePipe: DatePipe) {
this.screenSize = this.commonService.getScreenSize();
if (this.screenSize === ScreenSizeEnum.XS) {
this.flgSticky = false;
this.displayedColumns = ['offer_id', 'single_use', 'actions'];
} else if (this.screenSize === ScreenSizeEnum.SM) {
this.flgSticky = false;
this.displayedColumns = ['offer_id', 'single_use', 'used', 'actions'];
} else if (this.screenSize === ScreenSizeEnum.MD) {
this.flgSticky = false;
this.displayedColumns = ['offer_id', 'single_use', 'used', 'actions'];
} else {
this.flgSticky = true;
this.displayedColumns = ['offer_id', 'single_use', 'used', 'actions'];
}
}
ngOnInit() {
this.store.select(clnNodeSettings).pipe(takeUntil(this.unSubs[0])).subscribe((nodeSettings: SelNodeChild) => {
this.selNode = nodeSettings;
});
this.store.select(clnNodeInformation).pipe(takeUntil(this.unSubs[1])).subscribe((nodeInfo: GetInfo) => {
this.information = nodeInfo;
});
this.store.select(offers).pipe(takeUntil(this.unSubs[2])).
subscribe((offersSeletor: { offers: Offer[], apiCallStatus: ApiCallStatusPayload }) => {
this.errorMessage = '';
this.apiCallStatus = offersSeletor.apiCallStatus;
if (this.apiCallStatus.status === APICallStatusEnum.ERROR) {
this.errorMessage = !this.apiCallStatus.message ? '' : (typeof (this.apiCallStatus.message) === 'object') ? JSON.stringify(this.apiCallStatus.message) : this.apiCallStatus.message;
}
this.offerJSONArr = offersSeletor.offers || [];
if (this.offerJSONArr && this.offerJSONArr.length > 0 && this.sort && this.paginator) {
this.loadOffersTable(this.offerJSONArr);
}
this.logger.info(offersSeletor);
});
}
ngAfterViewInit() {
if (this.offerJSONArr && this.offerJSONArr.length > 0 && this.sort && this.paginator) {
this.loadOffersTable(this.offerJSONArr);
}
}
openCreateOfferModal() {
this.store.dispatch(openAlert({
payload: {
data: {
pageSize: this.pageSize,
component: CLNCreateOfferComponent
}
}
}));
}
onOfferClick(selOffer: Offer) {
const reCreatedOffer: Offer = {
used: selOffer.used,
single_use: selOffer.single_use,
active: selOffer.active,
offer_id: selOffer.offer_id,
bolt12: selOffer.bolt12,
bolt12_unsigned: selOffer.bolt12_unsigned
};
this.store.dispatch(openAlert({
payload: {
data: {
offer: reCreatedOffer,
newlyAdded: false,
component: CLNOfferInformationComponent
}
}
}));
}
onDisableOffer(selOffer: Offer) {
this.store.dispatch(openConfirmation({
payload: {
data: {
type: AlertTypeEnum.CONFIRM,
alertTitle: 'Disable Offer',
titleMessage: 'Disabling Offer: ' + (selOffer.offer_id || selOffer.bolt12),
noBtnText: 'Cancel',
yesBtnText: 'Disable'
}
}
}));
this.rtlEffects.closeConfirm.pipe(takeUntil(this.unSubs[3])).subscribe((confirmRes) => {
if (confirmRes) {
this.store.dispatch(disableOffer({ payload: { offer_id: selOffer.offer_id } }));
}
});
}
onPrintOffer(selOffer: Offer) {
this.dataService.decodePayment(selOffer.bolt12, false).
pipe(take(1)).subscribe((offerDecoded: OfferRequest) => {
if (offerDecoded.offer_id && !offerDecoded.amount_msat) {
offerDecoded.amount_msat = '0msat';
offerDecoded.amount = 0;
} else {
offerDecoded.amount = +(offerDecoded.amount || offerDecoded.amount_msat.slice(0, -4));
}
const documentDefinition = {
pageSize: 'A5',
pageOrientation: 'portrait',
pageMargins: [10, 50, 10, 50],
background: {
svg: `
<svg width="249" height="333" viewBox="0 0 249 333" fill="none" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<rect width="249" height="333" rx="17" fill="black"/>
<rect x="8" y="8" width="233" height="251" rx="12" fill="white"/>
<rect x="78" width="89" height="25" rx="9" fill="black"/>
<path d="M101.051 18L102.534 9.46875L105.036 9.47461C105.907 9.47461 106.559 9.66992 106.993 10.0605C107.426 10.4512 107.616 10.9961 107.561 11.6953C107.491 12.5117 106.977 13.127 106.02 13.541C106.403 13.6895 106.688 13.9434 106.875 14.3027C107.067 14.6621 107.145 15.0586 107.11 15.4922C107.051 16.2617 106.743 16.873 106.184 17.3262C105.625 17.7754 104.903 18 104.016 18H101.051ZM102.844 14.0098L102.311 17.0801L104.051 17.0859C104.582 17.0859 105.028 16.9434 105.387 16.6582C105.746 16.373 105.955 15.9883 106.014 15.5039C106.069 15.043 105.989 14.6836 105.774 14.4258C105.559 14.168 105.221 14.0312 104.76 14.0156L102.844 14.0098ZM103.002 13.1074L104.59 13.1133C105.086 13.1133 105.504 12.9863 105.844 12.7324C106.188 12.4785 106.389 12.1289 106.448 11.6836C106.498 11.2695 106.416 10.957 106.202 10.7461C105.991 10.5352 105.639 10.4199 105.147 10.4004L103.471 10.3945L103.002 13.1074ZM112.153 18.1172C111.61 18.1055 111.137 17.9746 110.735 17.7246C110.336 17.4746 110.022 17.1074 109.791 16.623C109.561 16.1348 109.434 15.5879 109.41 14.9824C109.387 14.5098 109.44 13.9258 109.569 13.2305C109.697 12.5352 109.92 11.9082 110.237 11.3496C110.553 10.791 110.938 10.3438 111.391 10.0078C112.004 9.55469 112.703 9.33594 113.489 9.35156C114.321 9.36719 114.977 9.65625 115.457 10.2188C115.938 10.7773 116.196 11.5352 116.231 12.4922C116.246 12.9023 116.203 13.4238 116.102 14.0566C116.004 14.6895 115.826 15.2773 115.569 15.8203C115.315 16.3633 114.99 16.8184 114.596 17.1855C113.908 17.8262 113.094 18.1367 112.153 18.1172ZM115.147 12.7617C115.17 11.9922 115.035 11.3965 114.742 10.9746C114.449 10.5488 114.014 10.3281 113.436 10.3125C112.912 10.2969 112.444 10.4375 112.03 10.7344C111.619 11.0312 111.281 11.4766 111.016 12.0703C110.754 12.6602 110.588 13.4082 110.518 14.3145L110.5 14.6953C110.477 15.4609 110.614 16.0605 110.91 16.4941C111.207 16.9277 111.639 17.1523 112.205 17.168C112.944 17.1875 113.555 16.9219 114.039 16.3711C114.528 15.8164 114.852 15.0391 115.012 14.0391C115.09 13.5469 115.135 13.1211 115.147 12.7617ZM119.012 17.0801H122.938L122.774 18H117.746L119.229 9.46875H120.336L119.012 17.0801ZM130.16 10.3945H127.506L126.187 18H125.092L126.41 10.3945H123.756L123.92 9.46875H130.324L130.16 10.3945ZM133.978 18H132.912L134.166 10.8047L131.898 11.6016L132.08 10.5703L135.244 9.42773H135.431L133.978 18ZM143.263 18H137.832L137.961 17.1738L141.107 14.1152L141.681 13.5469C142.341 12.8867 142.707 12.2773 142.777 11.7188C142.828 11.2891 142.744 10.9395 142.525 10.6699C142.306 10.3965 141.998 10.252 141.599 10.2363C141.087 10.2207 140.66 10.3711 140.316 10.6875C139.972 11 139.763 11.4297 139.689 11.9766L138.64 11.9824C138.691 11.459 138.851 10.9961 139.121 10.5938C139.394 10.1875 139.752 9.87695 140.193 9.66211C140.638 9.44336 141.121 9.33984 141.64 9.35156C142.347 9.36719 142.908 9.58203 143.322 9.99609C143.74 10.4062 143.92 10.9395 143.861 11.5957C143.795 12.3457 143.363 13.1348 142.566 13.9629L142.027 14.5078L139.285 17.1152H143.404L143.263 18Z" fill="white"/>
</svg>`,
width: 249,
height: 333,
absolutePosition: { x: 84, y: 160 }
},
header: { text: (offerDecoded.vendor || offerDecoded.issuer || ''), alignment: 'center', fontSize: 25, color: '#272727', margin: [0, 20, 0, 0] },
content: [
{
svg: '<svg width="249" height="2" viewBox="0 0 249 2" fill="none" xmlns="http://www.w3.org/2000/svg"><rect y="0.283203" width="249" height="1" fill="#EAEAEA"/></svg>',
width: 249,
height: 40,
alignment: 'center'
},
{ text: offerDecoded.description ? offerDecoded.description.substring(0, 160) : '', alignment: 'center', fontSize: 16, color: '#5C5C5C' },
{ qr: selOffer.bolt12, eccLevel: 'M', fit: '227', alignment: 'center', absolutePosition: { x: 7, y: 205 } },
{ text: (!offerDecoded?.amount_msat || offerDecoded?.amount === 0 ? 'Open amount' : (this.decimalPipe.transform(offerDecoded.amount / 1000) + ' SATS')), fontSize: 20, bold: false, color: 'white', alignment: 'center', absolutePosition: { x: 0, y: 430 } },
{ text: 'SCAN TO PAY', fontSize: 22, bold: true, color: 'white', alignment: 'center', absolutePosition: { x: 0, y: 455 } }
],
footer: {
svg: `
<svg width="183" height="15" viewBox="0 0 183 15" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M1.74609 7.52539L1.14258 11H0.427734L1.91016 2.46875L4.6875 2.47461C5.48438 2.49805 6.09961 2.73437 6.5332 3.18359C6.9668 3.62891 7.15039 4.22656 7.08398 4.97656C7.00586 5.77344 6.68359 6.39844 6.11719 6.85156C5.55078 7.30469 4.8125 7.53125 3.90234 7.53125L1.74609 7.52539ZM1.85156 6.91602L3.93164 6.92188C4.60742 6.92188 5.16406 6.75 5.60156 6.40625C6.03906 6.0625 6.29492 5.58789 6.36914 4.98242C6.43164 4.4043 6.30664 3.94922 5.99414 3.61719C5.68555 3.28125 5.24414 3.10547 4.66992 3.08984L2.51953 3.08398L1.85156 6.91602ZM7.58789 7.77148C7.6582 7.1582 7.8457 6.59766 8.15039 6.08984C8.45508 5.57812 8.83398 5.18945 9.28711 4.92383C9.74414 4.6582 10.2383 4.53125 10.7695 4.54297C11.293 4.55078 11.7383 4.69531 12.1055 4.97656C12.4766 5.25391 12.7461 5.63477 12.9141 6.11914C13.0859 6.59961 13.1445 7.13281 13.0898 7.71875L13.0781 7.83008C12.9609 8.83008 12.6055 9.63281 12.0117 10.2383C11.4219 10.8438 10.7129 11.1367 9.88477 11.1172C9.17383 11.1055 8.60547 10.8438 8.17969 10.332C7.75391 9.82031 7.54492 9.14453 7.55273 8.30469L7.57031 7.9707L7.58789 7.77148ZM8.26758 7.9707C8.2168 8.43555 8.25 8.86523 8.36719 9.25977C8.48828 9.65039 8.67969 9.95703 8.94141 10.1797C9.20312 10.4023 9.5293 10.5195 9.91992 10.5312C10.3418 10.5391 10.7266 10.4316 11.0742 10.209C11.4258 9.98633 11.7148 9.67188 11.9414 9.26562C12.168 8.85938 12.3145 8.41016 12.3809 7.91797L12.3984 7.72461C12.4688 6.9707 12.3516 6.35547 12.0469 5.87891C11.7461 5.39844 11.3086 5.15234 10.7344 5.14062C10.1094 5.12109 9.56836 5.36328 9.11133 5.86719C8.6582 6.36719 8.38086 7.0332 8.2793 7.86523L8.26758 7.9707ZM15.7383 9.54102V10.0391L15.9668 9.49414L18.2812 4.66016H18.8789L19.5059 9.50586L19.541 10.1035L19.7812 9.5L21.8789 4.66016H22.623L19.7285 11H19.1309L18.4336 5.97266L18.4277 5.62109L18.293 5.97852L15.8672 11H15.2695L14.5957 4.66016L15.252 4.6543L15.7383 9.54102ZM25.3535 11.1172C24.8457 11.1094 24.4062 10.9688 24.0352 10.6953C23.6641 10.418 23.3906 10.043 23.2148 9.57031C23.043 9.09375 22.9824 8.58008 23.0332 8.0293L23.0508 7.83008C23.1055 7.24414 23.2793 6.6875 23.5723 6.16016C23.8652 5.62891 24.2363 5.22461 24.6855 4.94727C25.1348 4.66602 25.6152 4.53125 26.127 4.54297C26.5996 4.55078 26.998 4.67969 27.3223 4.92969C27.6504 5.17969 27.8887 5.52734 28.0371 5.97266C28.1855 6.41797 28.2324 6.91016 28.1777 7.44922L28.1309 7.87695H23.7422L23.7246 8.01758C23.666 8.44336 23.6973 8.85156 23.8184 9.24219C23.9395 9.62891 24.1367 9.9375 24.4102 10.168C24.6875 10.3945 25.0195 10.5117 25.4062 10.5195C25.7812 10.5312 26.1191 10.459 26.4199 10.3027C26.7207 10.1465 26.998 9.9375 27.252 9.67578L27.6621 10.0098C27.377 10.377 27.0371 10.6562 26.6426 10.8477C26.252 11.0352 25.8223 11.125 25.3535 11.1172ZM26.0918 5.14062C25.584 5.12109 25.1289 5.30078 24.7266 5.67969C24.3242 6.05859 24.0215 6.5918 23.8184 7.2793L27.498 7.28516L27.5156 7.19727C27.5859 6.64258 27.4883 6.16602 27.2227 5.76758C26.957 5.36523 26.5801 5.15625 26.0918 5.14062ZM32.7832 5.25195C32.6309 5.2207 32.4766 5.20312 32.3203 5.19922C31.875 5.19922 31.4668 5.33594 31.0957 5.60938C30.7246 5.87891 30.4766 6.22266 30.3516 6.64062L29.6016 11H28.9102L30.0117 4.66016H30.6973L30.4863 5.66797C30.7168 5.29297 30.9941 5.00781 31.3184 4.8125C31.6465 4.61719 32.0059 4.52344 32.3965 4.53125C32.5332 4.53125 32.6934 4.55859 32.877 4.61328L32.7832 5.25195ZM35.2793 11.1172C34.7715 11.1094 34.332 10.9688 33.9609 10.6953C33.5898 10.418 33.3164 10.043 33.1406 9.57031C32.9688 9.09375 32.9082 8.58008 32.959 8.0293L32.9766 7.83008C33.0312 7.24414 33.2051 6.6875 33.498 6.16016C33.791 5.62891 34.1621 5.22461 34.6113 4.94727C35.0605 4.66602 35.541 4.53125 36.0527 4.54297C36.5254 4.55078 36.9238 4.67969 37.248 4.92969C37.5762 5.17969 37.8145 5.52734 37.9629 5.97266C38.1113 6.41797 38.1582 6.91016 38.1035 7.44922L38.0566 7.87695H33.668L33.6504 8.01758C33.5918 8.44336 33.623 8.85156 33.7441 9.24219C33.8652 9.62891 34.0625 9.9375 34.3359 10.168C34.6133 10.3945 34.9453 10.5117 35.332 10.5195C35.707 10.5312 36.0449 10.459 36.3457 10.3027C36.6465 10.1465 36.9238 9.9375 37.1777 9.67578L37.5879 10.0098C37.3027 10.377 36.9629 10.6562 36.568
<path fill-rule="evenodd" clip-rule="evenodd" d="M180.233 2.8383C180.3 2.99917 180.326 3.12628 180.322 3.19621C180.066 3.03702 179.68 2.90169 179.47 2.8629C179.333 2.8376 179.781 2.72551 180.233 2.8383ZM180.606 8.75656C180.685 8.73926 180.765 8.72273 180.845 8.70662C180.928 8.68974 181.012 8.67356 181.096 8.65828C181.028 8.6146 180.961 8.57133 180.893 8.52873C180.029 7.98743 179.109 7.5278 178.199 7.08296C177.625 6.80221 177.041 6.52314 176.446 6.27161C176.965 5.56601 177.63 4.96718 178.34 4.45423C178.341 4.45381 178.344 4.45175 178.348 4.4485C178.504 4.66718 178.7 4.81599 178.799 4.87191C178.992 4.9813 179.234 5.08353 179.458 5.11478C179.896 5.17625 180.259 5.16678 180.66 5.09559C180.696 5.08919 180.732 5.08465 180.768 5.07843C181.025 5.03415 181.19 5.02744 181.34 5.02454C181.54 5.02069 181.639 5.0642 181.662 5.07049C181.733 5.08947 181.794 5.12089 181.828 5.16304C181.867 5.21435 181.908 5.26275 181.953 5.30707C182.087 5.44466 182.221 5.52085 182.414 5.5427C182.663 5.5708 182.839 5.47053 182.963 5.30406C183.022 5.22546 182.994 5.10202 182.988 5.0778C182.955 4.95397 182.879 4.77384 182.825 4.60615C182.811 4.56282 182.742 4.42959 182.66 4.33917C182.632 4.30926 182.605 4.27941 182.578 4.2496C182.45 4.10997 182.32 3.9714 182.192 3.83188C181.681 3.27555 181.128 2.76333 180.557 2.27358C180.498 2.22283 180.438 2.17195 180.379 2.12116C180.336 2.08429 180.293 2.04763 180.25 2.0109C180.228 1.99223 180.206 1.97361 180.184 1.95498C180.137 1.91563 180.091 1.87655 180.044 1.83751C180.026 1.82213 180.007 1.80686 179.989 1.79152C179.96 1.7674 179.893 1.70984 179.837 1.66374C180.023 1.47355 180.172 1.35514 180.437 1.17609C180.475 1.15044 180.68 1.03783 180.673 1.00924C180.669 0.991976 180.332 0.99589 179.947 1.04706C179.811 1.06502 179.052 1.18049 178.531 1.29751C177.976 1.42203 177.39 1.59612 176.851 1.77111C175.292 2.27662 173.804 2.9617 172.441 3.89276C171.658 4.42784 170.925 5.01831 170.217 5.6545C169.888 5.95091 169.56 6.25207 169.24 6.56155C169.19 6.61003 169.14 6.65892 169.09 6.70785C169.158 6.72099 169.226 6.73473 169.294 6.74913C169.858 6.86837 170.415 7.02774 170.957 7.18732C171.62 7.38248 172.291 7.59288 172.939 7.85116C172.569 8.21327 172.209 8.5843 171.866 8.97692C171.22 9.71614 170.617 10.4971 170.055 11.3058C169.323 12.3594 168.698 13.4958 168.153 14.6668C168.101 14.7776 168.05 14.8887 168 15C168.101 14.9169 168.202 14.8344 168.304 14.7528C169.187 14.0478 170.117 13.396 171.046 12.7662C172.353 11.88 173.756 11.148 175.211 10.5589C176.966 9.8487 178.758 9.15974 180.606 8.75656Z" fill="#5C5C5C"/>
</svg>
`,
alignment: 'center'
}
};
pdfMake.createPdf(documentDefinition, null, null, pdfFonts.pdfMake.vfs).download('Offer-' + (offerDecoded && offerDecoded.description ? offerDecoded.description : selOffer.bolt12));
});
}
applyFilter() {
this.offers.filter = this.selFilter.trim().toLowerCase();
}
loadOffersTable(offrs: Offer[]) {
this.offers = (offrs) ? new MatTableDataSource<Offer>([...offrs]) : new MatTableDataSource([]);
this.offers.sortingDataAccessor = (data: any, sortHeaderId: string) => ((data[sortHeaderId] && isNaN(data[sortHeaderId])) ? data[sortHeaderId].toLocaleLowerCase() : data[sortHeaderId] ? +data[sortHeaderId] : null);
this.offers.sort = this.sort;
this.offers.filterPredicate = (rowData: Offer, fltr: string) => {
const newRowData = ((rowData.active) ? ' active' : ' inactive') + ((rowData.used) ? ' used' : ' unused') + ((rowData.single_use) ? ' single' : ' multiple') + JSON.stringify(rowData).toLowerCase();
if (fltr === 'active' || fltr === 'inactive' || fltr === 'used' || fltr === 'unused' || fltr === 'single' || fltr === 'multiple') {
fltr = ' ' + fltr;
}
return newRowData.includes(fltr);
};
this.offers.paginator = this.paginator;
this.applyFilter();
}
onDownloadCSV() {
if (this.offers.data && this.offers.data.length > 0) {
this.commonService.downloadFile(this.offers.data, 'Offers');
}
}
ngOnDestroy() {
this.unSubs.forEach((completeSub) => {
completeSub.next(<any>null);
completeSub.complete();
});
}
}