FRONTEND-535: Strict global variable names (#444)

This commit is contained in:
Rinat Arsaev 2021-04-26 18:17:59 +03:00 committed by GitHub
parent 42b8c1389d
commit e6908909fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
155 changed files with 433 additions and 373 deletions

View File

@ -48,10 +48,27 @@ module.exports = {
// Naming conversation
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'default',
format: ['camelCase'],
leadingUnderscore: 'allow',
},
{
selector: 'typeLike',
format: ['StrictPascalCase'],
},
{
selector: 'variable',
modifiers: ['const', 'global'],
format: ['UPPER_CASE'],
},
{
selector: 'variable',
modifiers: ['const', 'global'],
// Objects are functions too
types: ['function'],
format: ['UPPER_CASE', 'camelCase'],
},
{
selector: 'enumMember',
format: ['StrictPascalCase'],

View File

@ -5,5 +5,6 @@ import { AnalyticsService as BaseAnalyticsService } from './swagger-codegen/api/
@Injectable()
export class AnalyticsService extends BaseAnalyticsService {
// eslint-disable-next-line @typescript-eslint/naming-convention
defaultHeaders = new HttpHeaders({ 'Content-Type': 'application/json; charset=utf-8' });
}

View File

@ -5,5 +5,6 @@ import { ReportsService as BaseReportsService } from './swagger-codegen/api/repo
@Injectable()
export class ReportsService extends BaseReportsService {
// eslint-disable-next-line @typescript-eslint/naming-convention
defaultHeaders = new HttpHeaders({ 'Content-Type': 'application/json; charset=utf-8' });
}

View File

@ -5,5 +5,6 @@ import { InvoicesService as BaseInvoicesService } from './swagger-codegen/api/in
@Injectable()
export class InvoicesService extends BaseInvoicesService {
// eslint-disable-next-line @typescript-eslint/naming-convention
defaultHeaders = new HttpHeaders({ 'Content-Type': 'application/json; charset=utf-8' });
}

View File

@ -5,5 +5,6 @@ import { ShopsService as BaseShopsService } from './swagger-codegen/api/shops.se
@Injectable()
export class ShopsService extends BaseShopsService {
// eslint-disable-next-line @typescript-eslint/naming-convention
defaultHeaders = new HttpHeaders({ 'Content-Type': 'application/json; charset=utf-8' });
}

View File

@ -5,5 +5,6 @@ import { ClaimsService as BaseClaimsService } from './swagger-codegen/api/claims
@Injectable()
export class ClaimsService extends BaseClaimsService {
// eslint-disable-next-line @typescript-eslint/naming-convention
defaultHeaders = new HttpHeaders({ 'Content-Type': 'application/json; charset=utf-8' });
}

View File

@ -8,6 +8,7 @@ import { Configuration } from './swagger-codegen';
export class DarkApiConfigService extends Configuration {
constructor(keycloakService: KeycloakService, { apiEndpoint }: ConfigService) {
super({
// eslint-disable-next-line @typescript-eslint/naming-convention
apiKeys: { Authorization: `Bearer ${keycloakService.getKeycloakInstance().token}` },
basePath: `${apiEndpoint}/dark-api/v1`,
});

View File

@ -5,5 +5,6 @@ import { FilesService as BaseFilesService } from './swagger-codegen/api/files.se
@Injectable()
export class FilesService extends BaseFilesService {
// eslint-disable-next-line @typescript-eslint/naming-convention
defaultHeaders = new HttpHeaders({ 'Content-Type': 'application/json' });
}

View File

@ -12,6 +12,7 @@ export class GetQuestionaryService extends DefaultService {
@Optional() configuration: Configuration
) {
super(httpClient, basePath, configuration);
// eslint-disable-next-line @typescript-eslint/naming-convention
this.defaultHeaders = new HttpHeaders({ 'Content-Type': 'application/json; charset=utf-8' });
}
}

View File

@ -5,5 +5,6 @@ import { WalletsService as BaseWalletsService } from './swagger-codegen/api/wall
@Injectable()
export class WalletService extends BaseWalletsService {
// eslint-disable-next-line @typescript-eslint/naming-convention
defaultHeaders = new HttpHeaders({ 'Content-Type': 'application/json; charset=utf-8' });
}

View File

@ -17,7 +17,7 @@ import {
ShopLocationUrl,
} from '@dsh/api-codegen/capi';
const defaultClaimContractor: RussianLegalEntity = {
const DEFAULT_CLAIM_CONTRACTOR: RussianLegalEntity = {
contractorType: 'LegalEntity',
entityType: 'RussianLegalEntity',
registeredName: 'Test registered name',
@ -36,7 +36,7 @@ const defaultClaimContractor: RussianLegalEntity = {
},
};
const defaultPayoutToolDetails: PayoutToolDetailsBankAccount = {
const DEFAULT_PAYOUT_TOOL_DETAILS: PayoutToolDetailsBankAccount = {
detailsType: 'PayoutToolDetailsBankAccount',
account: '00000000000000000000',
bankName: 'Test bank name',
@ -44,7 +44,7 @@ const defaultPayoutToolDetails: PayoutToolDetailsBankAccount = {
bankBik: '000000000',
};
const defaultLegalAgreement: LegalAgreement = {
const DEFAULT_LEGAL_AGREEMENT: LegalAgreement = {
id: '000000/00',
signedAt: moment().subtract(1, 'days').utc().format() as any,
};
@ -59,7 +59,7 @@ const contractCreationChange = (
contractID,
contractModificationType: 'ContractCreation',
paymentInstitutionID,
contractor: contractor || defaultClaimContractor,
contractor: contractor || DEFAULT_CLAIM_CONTRACTOR,
};
};
@ -75,7 +75,7 @@ const contractPayoutToolCreationChange = (
contractModificationType: 'ContractPayoutToolCreation',
payoutToolID,
currency,
details: details || defaultPayoutToolDetails,
details: details || DEFAULT_PAYOUT_TOOL_DETAILS,
} as ContractPayoutToolCreation;
};
@ -87,7 +87,7 @@ const contractLegalAgreementBindingChange = (
partyModificationType: 'ContractModification',
contractID,
contractModificationType: 'ContractLegalAgreementBinding',
legalAgreement: legalAgreement || defaultLegalAgreement,
legalAgreement: legalAgreement || DEFAULT_LEGAL_AGREEMENT,
};
};

View File

@ -18,14 +18,14 @@ import {
} from '../claim-contractor-modification';
import { createShopCreationModification, makeShopLocation } from '../claim-shop-modification';
const testRussianBankAccount: Omit<RussianBankAccount, 'payoutToolType'> = {
const TEST_RUSSIAN_BANK_ACCOUNT: Omit<RussianBankAccount, 'payoutToolType'> = {
account: '00000000000000000000',
bankName: 'Test bank name',
bankPostAccount: '00000000000000000000',
bankBik: '000000000',
};
const testRussianLegalEntity: Omit<RussianLegalEntity, 'legalEntityType'> = {
const TEST_RUSSIAN_LEGAL_ENTITY: Omit<RussianLegalEntity, 'legalEntityType'> = {
registeredName: 'Test registered name',
registeredNumber: '0000000000000',
inn: '0000000000',
@ -34,7 +34,7 @@ const testRussianLegalEntity: Omit<RussianLegalEntity, 'legalEntityType'> = {
representativePosition: 'Test representative position',
representativeFullName: 'Test representative full name',
representativeDocument: 'Test representative document',
russianBankAccount: createRussianBankAccountModification(testRussianBankAccount),
russianBankAccount: createRussianBankAccountModification(TEST_RUSSIAN_BANK_ACCOUNT),
};
const createTestLegalAgreement = (): LegalAgreement => ({
@ -42,7 +42,7 @@ const createTestLegalAgreement = (): LegalAgreement => ({
legalAgreementID: '000000/00',
});
const testShopCreation: Omit<ShopCreationModification, 'shopModificationType' | 'contractID' | 'payoutToolID'> = {
const TEST_SHOP_CREATION: Omit<ShopCreationModification, 'shopModificationType' | 'contractID' | 'payoutToolID'> = {
category: {
categoryID: 1,
},
@ -64,9 +64,9 @@ export const createTestShopModifications = ({
shopID: string;
payoutToolID: string;
}): Modification[] => [
createRussianLegalEntityModification(contractorID, testRussianLegalEntity),
createRussianLegalEntityModification(contractorID, TEST_RUSSIAN_LEGAL_ENTITY),
createContractCreationModification(contractID, { contractorID }),
createContractLegalAgreementBindingModification(contractID, createTestLegalAgreement()),
createRussianContractPayoutToolModification(contractID, payoutToolID, testRussianBankAccount),
createShopCreationModification(shopID, { ...testShopCreation, contractID, payoutToolID }),
createRussianContractPayoutToolModification(contractID, payoutToolID, TEST_RUSSIAN_BANK_ACCOUNT),
createShopCreationModification(shopID, { ...TEST_SHOP_CREATION, contractID, payoutToolID }),
];

View File

@ -13,7 +13,7 @@ import {
import { mapResult, noContinuationToken } from '../../custom-operators';
import { genXRequestID } from '../utils';
export const ClaimStatus = StatusModificationUnit.StatusEnum;
export const CLAIM_STATUS = StatusModificationUnit.StatusEnum;
// TODO: refactor this service as claim requests service
@Injectable()

View File

@ -8,10 +8,10 @@ import {
import { createUnionTypeGuardCreator } from '../../utils';
const Type = ClaimModificationType.ClaimModificationTypeEnum;
const TYPE = ClaimModificationType.ClaimModificationTypeEnum;
const createTypeGuard = createUnionTypeGuardCreator<ClaimModificationType>('claimModificationType');
export const isFileModificationUnit = createTypeGuard<FileModificationUnit>(Type.FileModificationUnit);
export const isCommentModificationUnit = createTypeGuard<CommentModificationUnit>(Type.CommentModificationUnit);
export const isStatusModificationUnit = createTypeGuard<StatusModificationUnit>(Type.StatusModificationUnit);
export const isDocumentModificationUnit = createTypeGuard<DocumentModificationUnit>(Type.DocumentModificationUnit);
export const isFileModificationUnit = createTypeGuard<FileModificationUnit>(TYPE.FileModificationUnit);
export const isCommentModificationUnit = createTypeGuard<CommentModificationUnit>(TYPE.CommentModificationUnit);
export const isStatusModificationUnit = createTypeGuard<StatusModificationUnit>(TYPE.StatusModificationUnit);
export const isDocumentModificationUnit = createTypeGuard<DocumentModificationUnit>(TYPE.DocumentModificationUnit);

View File

@ -2,7 +2,7 @@ import { DocumentCreated, DocumentModification } from '@dsh/api-codegen/claim-ma
import { createUnionTypeGuardCreator } from '../../utils';
const Type = DocumentModification.DocumentModificationTypeEnum;
const TYPE = DocumentModification.DocumentModificationTypeEnum;
const createTypeGuard = createUnionTypeGuardCreator<DocumentModification>('documentModificationType');
export const isDocumentCreated = createTypeGuard<DocumentCreated>(Type.DocumentCreated);
export const isDocumentCreated = createTypeGuard<DocumentCreated>(TYPE.DocumentCreated);

View File

@ -2,8 +2,8 @@ import { ClaimModification, Modification, PartyModification } from '@dsh/api-cod
import { createUnionTypeGuardCreator } from '../../utils';
const Type = Modification.ModificationTypeEnum;
const TYPE = Modification.ModificationTypeEnum;
const createTypeGuard = createUnionTypeGuardCreator<Modification>('modificationType');
export const isClaimModification = createTypeGuard<ClaimModification>(Type.ClaimModification);
export const isPartyModification = createTypeGuard<PartyModification>(Type.PartyModification);
export const isClaimModification = createTypeGuard<ClaimModification>(TYPE.ClaimModification);
export const isPartyModification = createTypeGuard<PartyModification>(TYPE.PartyModification);

View File

@ -2,6 +2,7 @@ import { FileModification, FileModificationUnit } from '@dsh/api-codegen/claim-m
import { SpecificClaimModificationUnit } from './specific-claim-modification-unit';
// eslint-disable-next-line @typescript-eslint/naming-convention
const FileModificationType = FileModification.FileModificationTypeEnum;
type FileModificationType = FileModification.FileModificationTypeEnum;

View File

@ -16,12 +16,14 @@ type FullParamsByRequestType = Mapping<
RequestType,
DaDataRequest,
{
/* eslint-disable @typescript-eslint/naming-convention */
AddressQuery: AddressQuery;
BankQuery: BankQuery;
FioQuery: FioQuery;
FmsUnitQuery: FmsUnitQuery;
OkvedQuery: OkvedQuery;
PartyQuery: PartyQuery;
/* eslint-enable @typescript-eslint/naming-convention */
}
>;

View File

@ -11,19 +11,20 @@ import {
import { Mapping } from '../../../type-utils';
const RequestType = DaDataRequest.DaDataRequestTypeEnum; // can be safely removed
type RequestType = DaDataRequest.DaDataRequestTypeEnum;
export type ResponseByRequestType = Mapping<
RequestType,
DaDataResponse,
{
/* eslint-disable @typescript-eslint/naming-convention */
AddressQuery: AddressResponse;
BankQuery: BankResponse;
FioQuery: FioResponse;
FmsUnitQuery: FmsUnitResponse;
OkvedQuery: OkvedResponse;
PartyQuery: PartyResponse;
/* eslint-enable @typescript-eslint/naming-convention */
}
>;

View File

@ -41,8 +41,10 @@ export class FilesService {
private uploadFileToUrl(file: File, url: string): Observable<any> {
return this.http.put(url, file, {
headers: {
/* eslint-disable @typescript-eslint/naming-convention */
'Content-Disposition': `attachment;filename=${encodeURI(file.name)}`,
'Content-Type': '',
/* eslint-enable @typescript-eslint/naming-convention */
},
});
}

View File

@ -18,17 +18,18 @@ import {
import { Mapping } from '../../../type-utils';
const RequestType = KonturFocusRequest.KonturFocusRequestTypeEnum;
type RequestType = KonturFocusRequest.KonturFocusRequestTypeEnum;
type ParamsByRequestType = Mapping<
RequestType,
KonturFocusRequest,
{
/* eslint-disable @typescript-eslint/naming-convention */
ReqQuery: ReqQuery;
EgrDetailsQuery: EgrDetailsQuery;
LicencesQuery: LicencesQuery;
BeneficialOwnerQuery: BeneficialOwnerQuery;
/* eslint-enable @typescript-eslint/naming-convention */
}
>;
@ -36,10 +37,12 @@ export type ResponsesByRequestType = Mapping<
RequestType,
KonturFocusResponse,
{
/* eslint-disable @typescript-eslint/naming-convention */
ReqQuery: ReqResponses;
EgrDetailsQuery: EgrDetailsResponses;
LicencesQuery: LicencesResponses;
BeneficialOwnerQuery: BeneficialOwnerResponses;
/* eslint-enable @typescript-eslint/naming-convention */
}
>;

View File

@ -1,10 +1,10 @@
import { Injectable } from '@angular/core';
import { BaseConfig } from './config';
import { BASE_CONFIG } from './config';
import { config as appConfig } from './config-stub';
@Injectable()
export class ConfigStubService extends BaseConfig {
export class ConfigStubService extends BASE_CONFIG {
constructor() {
super();
for (const [name, config] of Object.entries(appConfig)) {

View File

@ -1,10 +1,10 @@
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { BaseConfig, Config } from './config';
import { BASE_CONFIG, Config } from './config';
@Injectable()
export class ConfigService extends BaseConfig {
export class ConfigService extends BASE_CONFIG {
constructor(private http: HttpClient) {
super();
}

View File

@ -2,4 +2,4 @@ import type AppConfig from '../../appConfig.json';
import { getBaseClass } from '../../utils';
export type Config = typeof AppConfig;
export const BaseConfig = getBaseClass<Config>();
export const BASE_CONFIG = getBaseClass<Config>();

View File

@ -23,18 +23,18 @@ interface Option<S extends Suggestion> {
value: S;
}
const ReqType = DaDataRequest.DaDataRequestTypeEnum;
const REQ_TYPE = DaDataRequest.DaDataRequestTypeEnum;
type ReqType = DaDataRequest.DaDataRequestTypeEnum;
const requestTypeByType: { [name in Type]: ReqType } = {
address: ReqType.AddressQuery,
bank: ReqType.BankQuery,
fio: ReqType.FioQuery,
fmsUnit: ReqType.FmsUnitQuery,
okved: ReqType.OkvedQuery,
party: ReqType.PartyQuery,
const REQUEST_TYPE_BY_TYPE: { [name in Type]: ReqType } = {
address: REQ_TYPE.AddressQuery,
bank: REQ_TYPE.BankQuery,
fio: REQ_TYPE.FioQuery,
fmsUnit: REQ_TYPE.FmsUnitQuery,
okved: REQ_TYPE.OkvedQuery,
party: REQ_TYPE.PartyQuery,
};
type RequestTypeByType = typeof requestTypeByType;
type RequestTypeByType = typeof REQUEST_TYPE_BY_TYPE;
@Component({
selector: 'dsh-dadata-autocomplete',
@ -100,7 +100,7 @@ export class DaDataAutocompleteComponent<
private loadSuggestions() {
const params = { query: this.formControl.value as string } as ParamsByRequestType[R];
return this.daDataService.suggest(requestTypeByType[this.type], this.withSpecificParams(params));
return this.daDataService.suggest(REQUEST_TYPE_BY_TYPE[this.type], this.withSpecificParams(params));
}
private withSpecificParams(params: ParamsByRequestType[R]): ParamsByRequestType[R] {

View File

@ -1,2 +1,2 @@
export const type = ['address', 'party', 'bank', 'fio', 'fmsUnit', 'okved'] as const;
export type Type = typeof type[number];
export const TYPE = ['address', 'party', 'bank', 'fio', 'fmsUnit', 'okved'] as const;
export type Type = typeof TYPE[number];

View File

@ -14,11 +14,13 @@ export interface HumanizeConfig extends humanizeDuration.HumanizerOptions {
@Injectable()
export class HumanizeDurationService {
/* eslint-disable @typescript-eslint/naming-convention */
static HOUR_MS = 3600000;
static MIN_HUMANIZE_DURATION_UPDATE_MS = 1000;
static MOMENT_HUMANIZE_ALLOWED_DELAY_BETWEEN_UPDATES_FOR_MINUTE_UPDATES_MS = 20000;
static MOMENT_HUMANIZE_ALLOWED_DELAY_BETWEEN_UPDATES_FOR_HOURLY_AND_LONGER_UPDATES_MS = 600000;
static LESS_THAN_FEW_SECONDS = 3000;
/* eslint-enable @typescript-eslint/naming-convention */
private get duration() {
return humanizeDuration.humanizer({

View File

@ -3,7 +3,7 @@ import localeRu from '@angular/common/locales/ru';
import { Language } from './language';
export const angularLocaleData: { [language in Language]: any } = {
export const ANGULAR_LOCALE_DATA: { [language in Language]: any } = {
[Language.Ru]: localeRu,
[Language.En]: localeEn,
};

View File

@ -4,11 +4,12 @@ import { TranslocoService } from '@ngneat/transloco';
import * as moment from 'moment';
import { SettingsService } from '../settings';
import { angularLocaleData } from './angular-locale-data';
import { ANGULAR_LOCALE_DATA } from './angular-locale-data';
import { Language } from './language';
@Injectable()
export class LanguageService {
// eslint-disable-next-line @typescript-eslint/naming-convention
private static readonly KEY = 'language';
active: Language;
@ -22,7 +23,7 @@ export class LanguageService {
}
async change(language: Language) {
registerLocaleData(angularLocaleData[language], language);
registerLocaleData(ANGULAR_LOCALE_DATA[language], language);
if (language !== Language.En) {
await import(`moment/locale/${language}`);
}

View File

@ -3,7 +3,7 @@ import { RouterModule, Routes } from '@angular/router';
import { ClaimComponent } from './claim.component';
const claimRoutes: Routes = [
const CLAIM_ROUTES: Routes = [
{
path: ':claimId',
component: ClaimComponent,
@ -11,7 +11,7 @@ const claimRoutes: Routes = [
];
@NgModule({
imports: [RouterModule.forChild(claimRoutes)],
imports: [RouterModule.forChild(CLAIM_ROUTES)],
exports: [RouterModule],
})
export class ClaimRoutingModule {}

View File

@ -14,29 +14,29 @@ import {
import { TimelineAction } from './model';
function getStatusModificationTimelineAction(unit: StatusModificationUnit): TimelineAction | null {
const Status = StatusModificationUnit.StatusEnum;
const status = StatusModificationUnit.StatusEnum;
switch (unit.status) {
case Status.Accepted:
case status.Accepted:
return TimelineAction.StatusAccepted;
case Status.Denied:
case status.Denied:
return TimelineAction.StatusDenied;
case Status.Pending:
case status.Pending:
return TimelineAction.StatusPending;
case Status.Review:
case status.Review:
return TimelineAction.StatusReview;
case Status.Revoked:
case status.Revoked:
return TimelineAction.StatusRevoked;
case Status.PendingAcceptance:
case status.PendingAcceptance:
return null;
}
}
function getFileModificationTimelineAction(unit: FileModificationUnit): TimelineAction {
const Type = FileModification.FileModificationTypeEnum;
const type = FileModification.FileModificationTypeEnum;
switch (unit.fileModification.fileModificationType) {
case Type.FileCreated:
case type.FileCreated:
return TimelineAction.FilesAdded;
case Type.FileDeleted:
case type.FileDeleted:
return TimelineAction.FilesDeleted;
}
}

View File

@ -7,7 +7,7 @@ import { RowModule } from '@dsh/components/layout';
import * as ru from '../../../../../../assets/i18n/ru.json';
import { ClaimRowHeaderComponent } from './claim-row-header.component';
const translationConfig = {
const TRANSLATION_CONFIG = {
ru,
};
@ -19,7 +19,7 @@ describe('ClaimRowHeaderComponent', () => {
TestBed.configureTestingModule({
imports: [
RowModule,
TranslocoTestingModule.withLangs(translationConfig, {
TranslocoTestingModule.withLangs(TRANSLATION_CONFIG, {
availableLangs: ['ru'],
defaultLang: 'ru',
}),

View File

@ -12,7 +12,7 @@ import * as ru from '../../../../../../assets/i18n/ru.json';
import { generateMockClaim } from '../../../tests/generate-mock-claim';
import { ClaimRowComponent } from './claim-row.component';
const translationConfig = {
const TRANSLATION_CONFIG = {
ru,
};
@ -24,7 +24,7 @@ describe('ClaimRowComponent', () => {
TestBed.configureTestingModule({
imports: [
RowModule,
TranslocoTestingModule.withLangs(translationConfig, {
TranslocoTestingModule.withLangs(TRANSLATION_CONFIG, {
availableLangs: ['ru'],
defaultLang: 'ru',
}),

View File

@ -3,7 +3,7 @@ import { RouterModule, Routes } from '@angular/router';
import { ClaimsComponent } from './claims.component';
const routes: Routes = [
const ROUTES: Routes = [
{
path: '',
component: ClaimsComponent,
@ -11,7 +11,7 @@ const routes: Routes = [
];
@NgModule({
imports: [RouterModule.forChild(routes)],
imports: [RouterModule.forChild(ROUTES)],
exports: [RouterModule],
})
export class ClaimsRoutingModule {}

View File

@ -8,7 +8,7 @@ import { FetchClaimsService } from './services/fetch-claims/fetch-claims.service
class MockApiClaimsService {}
const translationConfig = {
const TRANSLATION_CONFIG = {
ru,
};
@ -24,7 +24,7 @@ describe('FetchClaimsService', () => {
TestBed.configureTestingModule({
imports: [
MatSnackBarModule,
TranslocoTestingModule.withLangs(translationConfig, {
TranslocoTestingModule.withLangs(TRANSLATION_CONFIG, {
availableLangs: ['ru'],
defaultLang: 'ru',
}),

View File

@ -5,7 +5,7 @@ import moment from 'moment';
import { InvoiceLineTaxVAT, InvoiceTemplateAndToken, Shop } from '@dsh/api-codegen/capi';
import { CostType, CreateInvoiceTemplateService, TemplateType, withoutVAT } from './create-invoice-template.service';
import { CostType, CreateInvoiceTemplateService, TemplateType, WITHOUT_VAT } from './create-invoice-template.service';
@Component({
selector: 'dsh-create-invoice-template',
@ -23,7 +23,7 @@ export class CreateInvoiceTemplateComponent implements OnInit {
minDate = moment().add('1', 'day').startOf('day').toDate();
taxModes = Object.values(InvoiceLineTaxVAT.RateEnum);
withoutVAT = withoutVAT;
withoutVAT = WITHOUT_VAT;
templateType = TemplateType;
costType = CostType;

View File

@ -38,7 +38,7 @@ export enum CostType {
Range = 'InvoiceTemplateLineCostRange',
}
export const withoutVAT = Symbol('without VAT');
export const WITHOUT_VAT = Symbol('without VAT');
@Injectable()
export class CreateInvoiceTemplateService {
@ -165,7 +165,7 @@ export class CreateInvoiceTemplateService {
costType: CostType.Unlim,
templateType: TemplateType.SingleLine,
product: '',
taxMode: withoutVAT,
taxMode: WITHOUT_VAT,
cart: this.fb.array([this.createProductFormGroup()]),
range: this.fb.group({
lowerBound: null,
@ -180,7 +180,7 @@ export class CreateInvoiceTemplateService {
product: '',
quantity: null,
price: null,
taxMode: withoutVAT,
taxMode: WITHOUT_VAT,
});
}
@ -256,8 +256,8 @@ export class CreateInvoiceTemplateService {
}
}
private getInvoiceLineTaxMode(rate: typeof withoutVAT | InvoiceLineTaxVAT.RateEnum) {
return rate === withoutVAT
private getInvoiceLineTaxMode(rate: typeof WITHOUT_VAT | InvoiceLineTaxVAT.RateEnum) {
return rate === WITHOUT_VAT
? {}
: {
taxMode: {

View File

@ -9,7 +9,7 @@ import { coerceBoolean } from '../../../utils';
import { CreatePaymentLinkService } from './services/create-payment-link.service';
import { HoldExpiration } from './types/hold-expiration';
import { InvoiceType } from './types/invoice-type';
import { orderedPaymentMethodsNames } from './types/ordered-payment-methods-names';
import { ORDERED_PAYMENT_METHODS_NAMES } from './types/ordered-payment-methods-names';
@Component({
selector: 'dsh-create-payment-link',
@ -53,7 +53,7 @@ export class CreatePaymentLinkComponent implements OnInit {
link$ = this.createPaymentLinkService.paymentLink$;
isLoading$ = this.createPaymentLinkService.isLoading$;
orderedPaymentMethodsNames = orderedPaymentMethodsNames;
orderedPaymentMethodsNames = ORDERED_PAYMENT_METHODS_NAMES;
paymentMethodsEnabled = Object.fromEntries(
Object.entries(this.createPaymentLinkService.paymentMethodsFormGroup.controls).map(([k, v]) => [

View File

@ -34,7 +34,7 @@ import { ConfigService } from '../../../config';
import { filterError, filterPayload, replaceError } from '../../../custom-operators';
import { HoldExpiration } from '../types/hold-expiration';
import { InvoiceType } from '../types/invoice-type';
import { orderedPaymentMethodsNames } from '../types/ordered-payment-methods-names';
import { ORDERED_PAYMENT_METHODS_NAMES } from '../types/ordered-payment-methods-names';
export class PaymentLinkParams {
invoiceID?: string;
@ -57,9 +57,9 @@ export class PaymentLinkParams {
yandexPay?: boolean;
}
const Method = PaymentMethod.MethodEnum;
const TokenProvider = BankCard.TokenProvidersEnum;
const TerminalProvider = PaymentTerminal.ProvidersEnum;
const METHOD = PaymentMethod.MethodEnum;
const TOKEN_PROVIDER = BankCard.TokenProvidersEnum;
const TERMINAL_PROVIDER = PaymentTerminal.ProvidersEnum;
@Injectable()
export class CreatePaymentLinkService {
@ -214,7 +214,7 @@ export class CreatePaymentLinkService {
redirectUrl: '',
paymentMethods: this.fb.group(
Object.fromEntries(
orderedPaymentMethodsNames.map((name) => [name, { value: name === 'bankCard', disabled: true }])
ORDERED_PAYMENT_METHODS_NAMES.map((name) => [name, { value: name === 'bankCard', disabled: true }])
)
),
paymentFlowHold: false,
@ -227,21 +227,21 @@ export class CreatePaymentLinkService {
Object.values(paymentMethodsControls).forEach((c) => c.disable());
paymentMethods.forEach((item) => {
switch (item.method) {
case Method.BankCard: {
case METHOD.BankCard: {
const bankCard = item as BankCard;
if (Array.isArray(bankCard.tokenProviders) && bankCard.tokenProviders.length) {
for (const provider of bankCard.tokenProviders) {
switch (provider) {
case TokenProvider.Applepay:
case TOKEN_PROVIDER.Applepay:
paymentMethodsControls.applePay.enable();
break;
case TokenProvider.Googlepay:
case TOKEN_PROVIDER.Googlepay:
paymentMethodsControls.googlePay.enable();
break;
case TokenProvider.Samsungpay:
case TOKEN_PROVIDER.Samsungpay:
paymentMethodsControls.samsungPay.enable();
break;
case TokenProvider.Yandexpay:
case TOKEN_PROVIDER.Yandexpay:
paymentMethodsControls.yandexPay.enable();
break;
default:
@ -254,19 +254,19 @@ export class CreatePaymentLinkService {
}
break;
}
case Method.DigitalWallet:
case METHOD.DigitalWallet:
paymentMethodsControls.wallets.enable();
break;
case Method.PaymentTerminal:
case METHOD.PaymentTerminal:
(item as PaymentTerminal).providers.forEach((p) => {
switch (p) {
case TerminalProvider.Euroset:
case TERMINAL_PROVIDER.Euroset:
paymentMethodsControls.euroset.enable();
break;
case TerminalProvider.Qps:
case TERMINAL_PROVIDER.Qps:
paymentMethodsControls.qps.enable();
break;
case TerminalProvider.Uzcard:
case TERMINAL_PROVIDER.Uzcard:
paymentMethodsControls.uzcard.enable();
break;
default:
@ -275,7 +275,7 @@ export class CreatePaymentLinkService {
}
});
break;
case Method.MobileCommerce:
case METHOD.MobileCommerce:
paymentMethodsControls.mobileCommerce.enable();
break;
default:

View File

@ -1,4 +1,4 @@
export const orderedPaymentMethodsNames = [
export const ORDERED_PAYMENT_METHODS_NAMES = [
'bankCard',
'yandexPay',
'applePay',

View File

@ -3,7 +3,7 @@ import { RouterModule, Routes } from '@angular/router';
import { InvoiceDetailsComponent } from './invoice-details.component';
const invoiceDetailsRoutes: Routes = [
const INVOICE_DETAILS_ROUTES: Routes = [
{
path: ':invoiceID',
component: InvoiceDetailsComponent,
@ -11,7 +11,7 @@ const invoiceDetailsRoutes: Routes = [
];
@NgModule({
imports: [RouterModule.forChild(invoiceDetailsRoutes)],
imports: [RouterModule.forChild(INVOICE_DETAILS_ROUTES)],
exports: [RouterModule],
})
export class InvoiceDetailsRoutingModule {}

View File

@ -4,7 +4,7 @@ import { TranslocoService } from '@ngneat/transloco';
import { combineLatest, Observable } from 'rxjs';
import { pluck } from 'rxjs/operators';
import { ClaimsService, ClaimStatus } from '@dsh/api/claims';
import { ClaimsService, CLAIM_STATUS } from '@dsh/api/claims';
import { ApiShopsService } from '@dsh/api/shop';
import { booleanDelay, takeError } from '../../../../custom-operators';
@ -25,9 +25,9 @@ export class PaymentsService {
private transloco: TranslocoService
) {
const claims = this.claimService.search1000Claims([
ClaimStatus.Pending,
ClaimStatus.PendingAcceptance,
ClaimStatus.Review,
CLAIM_STATUS.Pending,
CLAIM_STATUS.PendingAcceptance,
CLAIM_STATUS.Review,
]);
const contentConfig = toContentConf(this.shopService.shops$, claims);
this.actionBtnContent$ = contentConfig.pipe(pluck('actionBtnContent'));

View File

@ -1,14 +1,14 @@
import { combineLatest, Observable } from 'rxjs';
import { Claim } from '@dsh/api-codegen/claim-management';
import { ClaimStatus } from '@dsh/api/claims';
import { CLAIM_STATUS } from '@dsh/api/claims';
import { filterByProp } from '../../../../../custom-operators';
import { filterQuestionaryClaims, takeClaimByPriority } from '../operators';
export const mapToTargetClaim = (s: Observable<Claim[]>): Observable<Claim> => {
const questionaryClaims = s.pipe(filterQuestionaryClaims);
const pendingClaims = questionaryClaims.pipe(filterByProp('status', ClaimStatus.Pending));
const reviewClaims = questionaryClaims.pipe(filterByProp('status', ClaimStatus.Review));
const pendingClaims = questionaryClaims.pipe(filterByProp('status', CLAIM_STATUS.Pending));
const reviewClaims = questionaryClaims.pipe(filterByProp('status', CLAIM_STATUS.Review));
return combineLatest([pendingClaims, reviewClaims]).pipe(takeClaimByPriority);
};

View File

@ -14,7 +14,7 @@ import { mapToSubheading } from './map-to-subheading';
import { mapToTargetClaim } from './map-to-target-claim';
import { mapToTestEnvBtnContent } from './map-to-test-env-btn-content';
const initialConf = {
const INITIAL_CONF = {
subheading: `pristine`,
actionBtnContent: {
actionLabel: `details`,
@ -35,11 +35,11 @@ export const toContentConf = (shops: Observable<Shop[]>, claims: Observable<Clai
const testEnvBtnContent$ = shops.pipe(
map(toTestShops),
map(negate(isEmpty)),
mapToTestEnvBtnContent(initialConf.testEnvBtnContent)
mapToTestEnvBtnContent(INITIAL_CONF.testEnvBtnContent)
);
const state = new BehaviorSubject<ContentConfig>(initialConf);
const state = new BehaviorSubject<ContentConfig>(INITIAL_CONF);
return applyToSate(state.asObservable(), actionBtnContent$, subheading$, testEnvBtnContent$).pipe(
startWith(initialConf),
startWith(INITIAL_CONF),
tap((r) => state.next(r)),
shareReplay(1)
);

View File

@ -13,7 +13,7 @@ import {
} from './forms';
import { StepName } from './step-flow';
export const routes: Routes = [
export const ROUTES: Routes = [
{
path: 'step',
component: DataFlowComponent,
@ -51,7 +51,7 @@ export const routes: Routes = [
];
@NgModule({
imports: [RouterModule.forChild(routes)],
imports: [RouterModule.forChild(ROUTES)],
exports: [RouterModule],
})
export class DataFlowRoutingModule {}

View File

@ -18,7 +18,7 @@ import { toFormValue } from './to-form-value';
type AccountantInfoType = AccountantInfo.AccountantInfoTypeEnum;
const accountantTypes: AccountantInfoType[] = [
const ACCOUNTANT_TYPES: AccountantInfoType[] = [
'WithoutChiefHeadAccounting',
'WithoutChiefIndividualAccountant',
'WithoutChiefAccountingOrganization',
@ -32,7 +32,7 @@ export class FinancialAndEconomicActivityService extends QuestionaryFormService
private form: FormGroup;
readonly accountantOptionTypes = accountantTypes;
readonly accountantOptionTypes = ACCOUNTANT_TYPES;
isAccountantInfoVisible$ = this.accountantInfoVisible$.asObservable();
isAccountantOrgInnVisible$ = this.accountantOrgInnVisible$.asObservable();
isResidencyInfoVisible$ = this.residencyInfoVisible$.asObservable();

View File

@ -3,6 +3,7 @@ import { FormBuilder, FormGroup } from '@angular/forms';
@Injectable()
export class AuthorityConfirmingDocumentService {
// eslint-disable-next-line @typescript-eslint/naming-convention
static readonly CustomType = Symbol('custom');
constructor(private fb: FormBuilder) {}

View File

@ -4,7 +4,7 @@ import { map } from 'rxjs/operators';
import { Contractor, QuestionaryData } from '@dsh/api-codegen/questionary';
import { IndividualEntityStepFlow, LegalEntityStepFlow } from './step-flows';
import { INDIVIDUAL_ENTITY_STEP_FLOW, LEGAL_ENTITY_STEP_FLOW } from './step-flows';
import { StepName } from './step-name';
export const mapToStepFlow = (s: Observable<QuestionaryData>): Observable<StepName[] | null> =>
@ -14,9 +14,9 @@ export const mapToStepFlow = (s: Observable<QuestionaryData>): Observable<StepNa
const t = Contractor.ContractorTypeEnum;
switch (contractorType) {
case t.LegalEntityContractor:
return LegalEntityStepFlow;
return LEGAL_ENTITY_STEP_FLOW;
case t.IndividualEntityContractor:
return IndividualEntityStepFlow;
return INDIVIDUAL_ENTITY_STEP_FLOW;
}
return null;
})

View File

@ -1,6 +1,6 @@
import { StepName } from './step-name';
const BasicStepFlow = [
const BASIC_STEP_FLOW = [
StepName.BasicInfo,
null,
StepName.FinancialAndEconomicActivity,
@ -9,7 +9,7 @@ const BasicStepFlow = [
StepName.UploadDocuments,
];
const insertStepToBasicFlow = (step: StepName): StepName[] => BasicStepFlow.map((s) => (s === null ? step : s));
const insertStepToBasicFlow = (step: StepName): StepName[] => BASIC_STEP_FLOW.map((s) => (s === null ? step : s));
export const IndividualEntityStepFlow = insertStepToBasicFlow(StepName.RussianPrivateEntity);
export const LegalEntityStepFlow = insertStepToBasicFlow(StepName.RussianLegalOwner);
export const INDIVIDUAL_ENTITY_STEP_FLOW = insertStepToBasicFlow(StepName.RussianPrivateEntity);
export const LEGAL_ENTITY_STEP_FLOW = insertStepToBasicFlow(StepName.RussianLegalOwner);

View File

@ -3,7 +3,7 @@ import { RouterModule, Routes } from '@angular/router';
import { CompanySearchComponent } from './company-search';
export const routes: Routes = [
export const ROUTES: Routes = [
{
path: '',
component: CompanySearchComponent,
@ -15,7 +15,7 @@ export const routes: Routes = [
];
@NgModule({
imports: [RouterModule.forChild(routes)],
imports: [RouterModule.forChild(ROUTES)],
exports: [RouterModule],
})
export class OnboardingRoutingModule {}

View File

@ -44,6 +44,7 @@ export class ChangeRolesTableComponent implements OnInit {
roleIds: RoleId[] = [];
shops$ = this.shopsService.shops$;
// eslint-disable-next-line @typescript-eslint/naming-convention
RoleId = RoleId;
get availableRoles(): RoleId[] {

View File

@ -26,8 +26,8 @@ describe('CreateInvitationDialogComponent', () => {
let mockErrorService: ErrorService;
let mockShopsService: ApiShopsService;
const SHOP_ID = 'shop_id';
const SOME_EMAIL = 'some@ema.il';
const shopId = 'shop_id';
const someEmail = 'some@ema.il';
beforeEach(() => {
mockDialogRef = mock(MatDialogRef);
@ -36,7 +36,7 @@ describe('CreateInvitationDialogComponent', () => {
mockErrorService = mock(ErrorService);
mockShopsService = mock(ApiShopsService);
when(mockShopsService.shops$).thenReturn(of([{ id: SHOP_ID } as Shop]));
when(mockShopsService.shops$).thenReturn(of([{ id: shopId } as Shop]));
when(mockOrganizationsService.createInvitation(MOCK_ORG.id, anything())).thenReturn(of(MOCK_INVITATION));
TestBed.configureTestingModule({
@ -75,7 +75,7 @@ describe('CreateInvitationDialogComponent', () => {
describe('create', () => {
it('should be created', () => {
component.emailControl.patchValue(SOME_EMAIL);
component.emailControl.patchValue(someEmail);
component.create();
verify(
mockOrganizationsService.createInvitation(
@ -84,7 +84,7 @@ describe('CreateInvitationDialogComponent', () => {
invitee: {
contact: {
type: InviteeContact.TypeEnum.EMail,
email: SOME_EMAIL,
email: someEmail,
},
roles: [],
},
@ -98,7 +98,7 @@ describe('CreateInvitationDialogComponent', () => {
it("shouldn't create", () => {
const error = new Error('Error 1');
component.emailControl.patchValue(SOME_EMAIL);
component.emailControl.patchValue(someEmail);
when(mockOrganizationsService.createInvitation(MOCK_ORG.id, anything())).thenReturn(throwError(error));
component.create();
verify(mockErrorService.error(error)).once();

View File

@ -3,10 +3,10 @@ import { RouterModule, Routes } from '@angular/router';
import { InvitationsComponent } from './invitations.component';
const routes: Routes = [{ path: '', component: InvitationsComponent }];
const ROUTES: Routes = [{ path: '', component: InvitationsComponent }];
@NgModule({
imports: [RouterModule.forChild(routes)],
imports: [RouterModule.forChild(ROUTES)],
exports: [RouterModule],
})
export class InvitationsRoutingModule {}

View File

@ -23,7 +23,7 @@ describe('InvitationsComponent', () => {
let mockOrganizationsService: OrganizationsService;
let mockDialog: MatDialog;
const MOCK_INVITATIONS_RESULT: InvitationListResult = {
const mockInvitationsResult: InvitationListResult = {
result: new Array(5).fill(MOCK_INVITATION),
};
@ -45,7 +45,7 @@ describe('InvitationsComponent', () => {
when(mockRoute.params).thenReturn(of({ orgId: MOCK_ORG.id }));
when(mockOrganizationsService.getOrg(MOCK_ORG.id)).thenReturn(of(MOCK_ORG));
when(mockOrganizationsService.listInvitations(MOCK_ORG.id)).thenReturn(of(MOCK_INVITATIONS_RESULT));
when(mockOrganizationsService.listInvitations(MOCK_ORG.id)).thenReturn(of(mockInvitationsResult));
fixture = TestBed.createComponent(InvitationsComponent);
component = fixture.componentInstance;
@ -65,7 +65,7 @@ describe('InvitationsComponent', () => {
});
it('should load invitations$', () => {
const expected$ = cold('(a)', { a: MOCK_INVITATIONS_RESULT.result });
const expected$ = cold('(a)', { a: mockInvitationsResult.result });
expect(component.invitations$).toBeObservable(expected$);
});
@ -80,7 +80,7 @@ describe('InvitationsComponent', () => {
component.invitations$.subscribe();
component.refresh();
verify(mockOrganizationsService.listInvitations(MOCK_ORG.id)).twice();
const expected$ = cold('(a)', { a: MOCK_INVITATIONS_RESULT.result });
const expected$ = cold('(a)', { a: mockInvitationsResult.result });
expect(component.invitations$).toBeObservable(expected$);
});
});

View File

@ -3,10 +3,10 @@ import { RouterModule, Routes } from '@angular/router';
import { MembersComponent } from './members.component';
const routes: Routes = [{ path: '', component: MembersComponent }];
const ROUTES: Routes = [{ path: '', component: MembersComponent }];
@NgModule({
imports: [RouterModule.forChild(routes)],
imports: [RouterModule.forChild(ROUTES)],
exports: [RouterModule],
})
export class MembersRoutingModule {}

View File

@ -28,7 +28,7 @@ describe('MembersComponent', () => {
let mockOrganizationsService: OrganizationsService;
let mockRoute: ActivatedRoute;
const MOCK_MEMBERS: MemberOrgListResult = {
const mockMembers: MemberOrgListResult = {
result: new Array(11).fill(MOCK_MEMBER),
};
@ -47,7 +47,7 @@ describe('MembersComponent', () => {
when(mockRoute.params).thenReturn(of({ orgId: MOCK_ORG.id }));
when(mockOrganizationsService.getOrg(MOCK_ORG.id)).thenReturn(of(MOCK_ORG));
when(mockOrganizationsService.listOrgMembers(MOCK_ORG.id)).thenReturn(of(MOCK_MEMBERS));
when(mockOrganizationsService.listOrgMembers(MOCK_ORG.id)).thenReturn(of(mockMembers));
fixture = TestBed.createComponent(HostComponent);
debugElement = fixture.debugElement.query(By.directive(MembersComponent));
@ -69,7 +69,7 @@ describe('MembersComponent', () => {
});
it('should load members$', () => {
const expected$ = cold('(a)', { a: MOCK_MEMBERS.result });
const expected$ = cold('(a)', { a: mockMembers.result });
expect(component.members$).toBeObservable(expected$);
});
@ -84,7 +84,7 @@ describe('MembersComponent', () => {
component.members$.subscribe();
component.refresh();
verify(mockOrganizationsService.listOrgMembers(MOCK_ORG.id)).twice();
const expected$ = cold('(a)', { a: MOCK_MEMBERS.result });
const expected$ = cold('(a)', { a: mockMembers.result });
expect(component.members$).toBeObservable(expected$);
});
});

View File

@ -3,7 +3,7 @@ import { RouterModule, Routes } from '@angular/router';
import { OrganizationDetailsComponent } from './organization-details.component';
const routes: Routes = [
const ROUTES: Routes = [
{
path: '',
component: OrganizationDetailsComponent,
@ -25,7 +25,7 @@ const routes: Routes = [
];
@NgModule({
imports: [RouterModule.forChild(routes)],
imports: [RouterModule.forChild(ROUTES)],
exports: [RouterModule],
})
export class OrganizationDetailsRoutingModule {}

View File

@ -3,10 +3,10 @@ import { RouterModule, Routes } from '@angular/router';
import { AcceptInvitationComponent } from './accept-invitation.component';
const routes: Routes = [{ path: ':token', component: AcceptInvitationComponent }];
const ROUTES: Routes = [{ path: ':token', component: AcceptInvitationComponent }];
@NgModule({
imports: [RouterModule.forChild(routes)],
imports: [RouterModule.forChild(ROUTES)],
exports: [RouterModule],
})
export class AcceptInvitationRoutingModule {}

View File

@ -3,7 +3,7 @@ import { RouterModule, Routes } from '@angular/router';
import { OrganizationsComponent } from './organizations.component';
export const routes: Routes = [
export const ROUTES: Routes = [
{
path: '',
children: [
@ -20,7 +20,7 @@ export const routes: Routes = [
];
@NgModule({
imports: [RouterModule.forChild(routes)],
imports: [RouterModule.forChild(ROUTES)],
exports: [RouterModule],
})
export class OrganizationsRoutingModule {}

View File

@ -3,7 +3,7 @@ import { RouterModule, Routes } from '@angular/router';
import { PageNotFoundComponent } from './page-not-found.component';
export const routes: Routes = [
export const ROUTES: Routes = [
{
path: '',
component: PageNotFoundComponent,
@ -11,7 +11,7 @@ export const routes: Routes = [
];
@NgModule({
imports: [RouterModule.forChild(routes)],
imports: [RouterModule.forChild(ROUTES)],
exports: [RouterModule],
})
export class PageNotFoundRoutingModule {}

View File

@ -6,8 +6,8 @@ import { PaymentFlowHold, PaymentSearchResult, PaymentStatus } from '@dsh/api-co
import { CancelHoldComponent, CancelHoldData } from './cancel-hold/cancel-hold.component';
import { ConfirmHoldComponent, ConfirmHoldData } from './confirm-hold/confirm-hold.component';
const paymentStatusEnum = PaymentStatus.StatusEnum;
const onHoldExpirationEnum = PaymentFlowHold.OnHoldExpirationEnum;
const PAYMENT_STATUS_ENUM = PaymentStatus.StatusEnum;
const ON_HOLD_EXPIRATION_ENUM = PaymentFlowHold.OnHoldExpirationEnum;
@Component({
selector: 'dsh-hold-details',
@ -26,18 +26,18 @@ export class HoldDetailsComponent {
getActiveHoldText(): string {
switch (this.flowHold.onHoldExpiration) {
case onHoldExpirationEnum.Capture:
case ON_HOLD_EXPIRATION_ENUM.Capture:
return 'holdWithCapture';
case onHoldExpirationEnum.Cancel:
case ON_HOLD_EXPIRATION_ENUM.Cancel:
return 'holdWithCancel';
}
}
getExpiredHoldText(): string {
switch (this.payment.status) {
case paymentStatusEnum.Captured:
case PAYMENT_STATUS_ENUM.Captured:
return 'capturedHoldMessage';
case paymentStatusEnum.Cancelled:
case PAYMENT_STATUS_ENUM.Cancelled:
return 'cancelledHoldMessage';
}
}

View File

@ -15,6 +15,7 @@ export enum PayerType {
export class PayerDetailsComponent {
@Input() payer: Payer;
// eslint-disable-next-line @typescript-eslint/naming-convention
PayerType = PayerType;
payerEmail: string;

View File

@ -3,7 +3,7 @@ import { RouterModule, Routes } from '@angular/router';
import { PaymentDetailsComponent } from './payment-details.component';
const paymentDetailsRoutes: Routes = [
const PAYMENT_DETAILS_ROUTES: Routes = [
{
path: ':paymentID',
component: PaymentDetailsComponent,
@ -11,7 +11,7 @@ const paymentDetailsRoutes: Routes = [
];
@NgModule({
imports: [RouterModule.forChild(paymentDetailsRoutes)],
imports: [RouterModule.forChild(PAYMENT_DETAILS_ROUTES)],
exports: [RouterModule],
})
export class PaymentDetailsRoutingModule {}

View File

@ -15,7 +15,9 @@ export class PaymentDetailsComponent {
payment$ = this.receivePaymentService.payment$;
isLoading$ = this.receivePaymentService.isLoading$;
// eslint-disable-next-line @typescript-eslint/naming-convention
PayerType = PayerType;
// eslint-disable-next-line @typescript-eslint/naming-convention
PaymentFlow = PaymentFlow.TypeEnum;
constructor(private receivePaymentService: ReceivePaymentService) {}

View File

@ -10,5 +10,6 @@ import { PaymentToolDetailsType } from '@dsh/api/capi';
export class PaymentToolComponent {
@Input() paymentToolDetails: PaymentToolDetails;
// eslint-disable-next-line @typescript-eslint/naming-convention
Type = PaymentToolDetailsType;
}

View File

@ -10,7 +10,7 @@ import { Duration, PaymentSearchService } from '@dsh/api/search';
import { filterError, filterPayload, progress, replaceError, SHARE_REPLAY_CONF } from '../../custom-operators';
const completedStatuses: PaymentSearchResult.StatusEnum[] = [
const COMPLETED_STATUSES: PaymentSearchResult.StatusEnum[] = [
PaymentSearchResult.StatusEnum.Captured,
PaymentSearchResult.StatusEnum.Cancelled,
];
@ -39,7 +39,7 @@ export class ReceivePaymentService {
return type === ReceivePaymentType.Hold
? timer(TIME_UNTIL_START, TIMER_PERIOD).pipe(
switchMap(() => this.paymentSearchService.getPaymentByDuration(duration, invoiceID, paymentID)),
filter((p) => completedStatuses.includes(p?.status)),
filter((p) => COMPLETED_STATUSES.includes(p?.status)),
first(),
timeout(TIMER_TIMEOUT)
)

View File

@ -7,7 +7,7 @@ import { PaymentSearchResult } from '@dsh/api-codegen/anapi/swagger-codegen';
import { RefundsService } from './refunds.service';
const PaymentStatuses = PaymentSearchResult.StatusEnum;
const PAYMENT_STATUSES = PaymentSearchResult.StatusEnum;
@Component({
selector: 'dsh-refunds',
@ -58,6 +58,6 @@ export class RefundsComponent implements OnChanges {
}
refundAvailable(): boolean {
return this.status === PaymentStatuses.Captured;
return this.status === PAYMENT_STATUSES.Captured;
}
}

View File

@ -3,7 +3,7 @@ import { RouterModule, Routes } from '@angular/router';
import { AnalyticsComponent } from './analytics.component';
const operationsRoutes: Routes = [
const OPERATIONS_ROUTES: Routes = [
{
path: '',
component: AnalyticsComponent,
@ -11,7 +11,7 @@ const operationsRoutes: Routes = [
];
@NgModule({
imports: [RouterModule.forChild(operationsRoutes)],
imports: [RouterModule.forChild(OPERATIONS_ROUTES)],
exports: [RouterModule],
})
export class AnalyticsRoutingModule {}

View File

@ -5,7 +5,7 @@ import { OffsetCount, SplitCountResult, SplitUnit, StatusOffsetCount } from '@ds
import { getOffsets } from '../utils';
const statuses: StatusOffsetCount.StatusEnum[] = ['captured', 'cancelled', 'failed'];
const STATUSES: StatusOffsetCount.StatusEnum[] = ['captured', 'cancelled', 'failed'];
const fixExtraInterval = (offsetCounts: OffsetCount[]): OffsetCount[] =>
sortBy(offsetCounts, 'offset').reduce(
@ -52,7 +52,7 @@ export const prepareSplitCount = (
splitCounts.map(({ splitUnit, currency, statusOffsetCounts }) => ({
splitUnit,
currency,
statusOffsetCounts: statuses.map((status) => ({
statusOffsetCounts: STATUSES.map((status) => ({
status,
offsetCount: fillSplitCountByZeroValues(
statusOffsetCounts.find((o) => o.status === status)?.offsetCount,

View File

@ -1,4 +1,4 @@
export const knownErrors = [
export const KNOWN_ERRORS = [
'operation_timeout',
'authorization_failed',
'preauthorization_failed',

View File

@ -2,10 +2,10 @@ import { PaymentsSubErrorsDistributionResult } from '@dsh/api-codegen/anapi/swag
import { SubError } from '@dsh/api-codegen/capi/swagger-codegen';
import { ErrorDistribution } from './error-distribution';
import { knownErrors } from './known-errors';
import { KNOWN_ERRORS } from './known-errors';
const subErrorToDistribution = (error: SubError, percents: number): ErrorDistribution => ({
errorCode: knownErrors.includes(error.code) ? error.code : 'other',
errorCode: KNOWN_ERRORS.includes(error.code) ? error.code : 'other',
subErrors: error.subError ? [subErrorToDistribution(error.subError, percents)] : [],
percents,
});
@ -31,7 +31,7 @@ const groupDistribution = (distribution: ErrorDistribution[]): ErrorDistribution
export const subErrorsToErrorDistribution = (errors: PaymentsSubErrorsDistributionResult[]): ErrorDistribution[] => {
const errorDistribution: ErrorDistribution[] = errors.map(({ error, percents }) => ({
errorCode: knownErrors.includes(error.code) ? error.code : 'other',
errorCode: KNOWN_ERRORS.includes(error.code) ? error.code : 'other',
subErrors: error.subError ? [subErrorToDistribution(error.subError, percents)] : [],
percents,
}));

View File

@ -3,7 +3,7 @@ import { RouterModule, Routes } from '@angular/router';
import { ApiKeyComponent } from './api-key.component';
const routes: Routes = [
const ROUTES: Routes = [
{
path: '',
component: ApiKeyComponent,
@ -11,6 +11,6 @@ const routes: Routes = [
];
@NgModule({
imports: [RouterModule.forChild(routes)],
imports: [RouterModule.forChild(ROUTES)],
})
export class ApiKeyRoutingModule {}

View File

@ -3,7 +3,7 @@ import { RouterModule, Routes } from '@angular/router';
import { IntegrationsComponent } from './integrations.component';
const routes: Routes = [
const ROUTES: Routes = [
{
path: '',
component: IntegrationsComponent,
@ -33,7 +33,7 @@ const routes: Routes = [
];
@NgModule({
imports: [RouterModule.forChild(routes)],
imports: [RouterModule.forChild(ROUTES)],
exports: [RouterModule],
})
export class IntegrationsRoutingModule {}

View File

@ -3,7 +3,7 @@ import { RouterModule, Routes } from '@angular/router';
import { PaymentLinkComponent } from './payment-link.component';
const routes: Routes = [
const ROUTES: Routes = [
{
path: '',
component: PaymentLinkComponent,
@ -11,6 +11,6 @@ const routes: Routes = [
];
@NgModule({
imports: [RouterModule.forChild(routes)],
imports: [RouterModule.forChild(ROUTES)],
})
export class PaymentLinkRoutingModule {}

View File

@ -11,7 +11,7 @@ describe('ShopSelectorService', () => {
let service: ShopOptionsSelectionService;
let mockFetchShopsService: FetchShopsService;
const MAIN_CONFIG = {
const mainConfig = {
providers: [
ShopOptionsSelectionService,
{
@ -22,7 +22,7 @@ describe('ShopSelectorService', () => {
};
function configureTestingModule() {
TestBed.configureTestingModule(MAIN_CONFIG);
TestBed.configureTestingModule(mainConfig);
service = TestBed.inject(ShopOptionsSelectionService);
}

View File

@ -7,7 +7,7 @@ import { RowModule } from '@dsh/components/layout';
import { ShopRowHeaderComponent } from './shop-row-header.component';
const translationConfig = {
const TRANSLATION_CONFIG = {
en: {
shops: {
panel: {
@ -26,7 +26,7 @@ describe('ShopRowHeaderComponent', () => {
await TestBed.configureTestingModule({
imports: [
RowModule,
TranslocoTestingModule.withLangs(translationConfig, {
TranslocoTestingModule.withLangs(TRANSLATION_CONFIG, {
availableLangs: ['en'],
defaultLang: 'en',
}),
@ -55,8 +55,8 @@ describe('ShopRowHeaderComponent', () => {
it('should render columns with names from translation config', () => {
const columns = fixture.debugElement.queryAll(By.css('dsh-row dsh-row-header-label'));
expect(columns[0].nativeElement.textContent.trim()).toBe(translationConfig.en.shops.panel.name);
expect(columns[1].nativeElement.textContent.trim()).toBe(translationConfig.en.shops.panel.balance);
expect(columns[0].nativeElement.textContent.trim()).toBe(TRANSLATION_CONFIG.en.shops.panel.name);
expect(columns[1].nativeElement.textContent.trim()).toBe(TRANSLATION_CONFIG.en.shops.panel.balance);
});
});
});

View File

@ -21,7 +21,7 @@ import { ShopBalanceModule } from './shop-balance';
import { ShopDetailsModule } from './shop-details';
import { ShopsListComponent } from './shops-list.component';
const translationConfig = {
const TRANSLATION_CONFIG = {
en: {
shops: {
panel: {
@ -56,7 +56,7 @@ describe('ShopsListComponent', () => {
SpinnerModule,
ShopDetailsModule,
FlexLayoutModule,
TranslocoTestingModule.withLangs(translationConfig, {
TranslocoTestingModule.withLangs(TRANSLATION_CONFIG, {
availableLangs: ['en'],
defaultLang: 'en',
}),

View File

@ -3,7 +3,7 @@ import { RouterModule, Routes } from '@angular/router';
import { ShopsComponent } from './shops.component';
const routes: Routes = [
const ROUTES: Routes = [
{
path: '',
component: ShopsComponent,
@ -11,6 +11,6 @@ const routes: Routes = [
];
@NgModule({
imports: [RouterModule.forChild(routes)],
imports: [RouterModule.forChild(ROUTES)],
})
export class ShopsRoutingModule {}

View File

@ -3,7 +3,7 @@ import { RouterModule, Routes } from '@angular/router';
import { WebhooksComponent } from './webhooks.component';
const routes: Routes = [
const ROUTES: Routes = [
{
path: '',
component: WebhooksComponent,
@ -11,6 +11,6 @@ const routes: Routes = [
];
@NgModule({
imports: [RouterModule.forChild(routes)],
imports: [RouterModule.forChild(ROUTES)],
})
export class WebhooksRoutingModule {}

View File

@ -3,10 +3,10 @@ import { RouterModule, Routes } from '@angular/router';
import { InvoicesComponent } from './invoices.component';
const invoicesRoutes: Routes = [{ path: '', component: InvoicesComponent }];
const INVOICES_ROUTES: Routes = [{ path: '', component: InvoicesComponent }];
@NgModule({
imports: [RouterModule.forChild(invoicesRoutes)],
imports: [RouterModule.forChild(INVOICES_ROUTES)],
exports: [RouterModule],
})
export class InvoicesRoutingModule {}

View File

@ -3,7 +3,7 @@ import { RouterModule, Routes } from '@angular/router';
import { OperationsComponent } from './operations.component';
const operationsRoutes: Routes = [
const OPERATIONS_ROUTES: Routes = [
{
path: '',
component: OperationsComponent,
@ -29,7 +29,7 @@ const operationsRoutes: Routes = [
];
@NgModule({
imports: [RouterModule.forChild(operationsRoutes)],
imports: [RouterModule.forChild(OPERATIONS_ROUTES)],
exports: [RouterModule],
})
export class OperationsRoutingModule {}

View File

@ -7,7 +7,7 @@ import { RowModule } from '@dsh/components/layout';
import { PaymentsRowHeaderComponent } from './payments-row-header.component';
const translationConfig = {
const TRANSLATION_CONFIG = {
ru: {
operations: {
payments: {
@ -31,7 +31,7 @@ describe('PaymentsRowHeaderComponent', () => {
await TestBed.configureTestingModule({
imports: [
RowModule,
TranslocoTestingModule.withLangs(translationConfig, {
TranslocoTestingModule.withLangs(TRANSLATION_CONFIG, {
availableLangs: ['ru'],
defaultLang: 'ru',
}),

View File

@ -3,7 +3,7 @@ import { PaymentSearchResult } from '@dsh/api-codegen/capi';
import { StatusColor } from '../../../../../../../../theme-manager';
import { PaymentStatusColorPipe } from './status-color.pipe';
const statusEnum = PaymentSearchResult.StatusEnum;
const STATUS_ENUM = PaymentSearchResult.StatusEnum;
describe('PaymentStatusColorPipe', () => {
let pipe: PaymentStatusColorPipe;
@ -18,21 +18,21 @@ describe('PaymentStatusColorPipe', () => {
describe('transform', () => {
it('should return "success" color for Captured or Processed statuses', () => {
expect(pipe.transform(statusEnum.Captured)).toBe(StatusColor.Success);
expect(pipe.transform(statusEnum.Processed)).toBe(StatusColor.Success);
expect(pipe.transform(STATUS_ENUM.Captured)).toBe(StatusColor.Success);
expect(pipe.transform(STATUS_ENUM.Processed)).toBe(StatusColor.Success);
});
it('should return "warn" color for Failed or Cancelled statuses', () => {
expect(pipe.transform(statusEnum.Failed)).toBe(StatusColor.Warn);
expect(pipe.transform(statusEnum.Cancelled)).toBe(StatusColor.Warn);
expect(pipe.transform(STATUS_ENUM.Failed)).toBe(StatusColor.Warn);
expect(pipe.transform(STATUS_ENUM.Cancelled)).toBe(StatusColor.Warn);
});
it('should return "pending" color for Pending status', () => {
expect(pipe.transform(statusEnum.Pending)).toBe(StatusColor.Pending);
expect(pipe.transform(STATUS_ENUM.Pending)).toBe(StatusColor.Pending);
});
it('should return "neutral" color for Refunded status', () => {
expect(pipe.transform(statusEnum.Refunded)).toBe(StatusColor.Neutral);
expect(pipe.transform(STATUS_ENUM.Refunded)).toBe(StatusColor.Neutral);
});
});
});

View File

@ -10,5 +10,6 @@ import { PaymentToolDetailsType } from '@dsh/api/capi';
export class PaymentToolComponent {
@Input() paymentToolDetails: PaymentToolDetails;
// eslint-disable-next-line @typescript-eslint/naming-convention
Type = PaymentToolDetailsType;
}

View File

@ -3,10 +3,10 @@ import { RouterModule, Routes } from '@angular/router';
import { PaymentsComponent } from './payments.component';
const paymentsRoutes: Routes = [{ path: '', component: PaymentsComponent }];
const PAYMENTS_ROUTES: Routes = [{ path: '', component: PaymentsComponent }];
@NgModule({
imports: [RouterModule.forChild(paymentsRoutes)],
imports: [RouterModule.forChild(PAYMENTS_ROUTES)],
exports: [RouterModule],
})
export class PaymentsRoutingModule {}

View File

@ -3,10 +3,10 @@ import { RouterModule, Routes } from '@angular/router';
import { RefundsComponent } from './refunds.component';
const refundsRoutes: Routes = [{ path: '', component: RefundsComponent }];
const REFUNDS_ROUTES: Routes = [{ path: '', component: RefundsComponent }];
@NgModule({
imports: [RouterModule.forChild(refundsRoutes)],
imports: [RouterModule.forChild(REFUNDS_ROUTES)],
exports: [RouterModule],
})
export class RefundsRoutingModule {}

View File

@ -3,7 +3,7 @@ import { RouterModule, Routes } from '@angular/router';
import { PaymentSectionComponent } from './payment-section.component';
const paymentSectionRoutes: Routes = [
const PAYMENT_SECTION_ROUTES: Routes = [
{
path: 'realm/:realm',
component: PaymentSectionComponent,
@ -33,7 +33,7 @@ const paymentSectionRoutes: Routes = [
];
@NgModule({
imports: [RouterModule.forChild(paymentSectionRoutes)],
imports: [RouterModule.forChild(PAYMENT_SECTION_ROUTES)],
exports: [RouterModule],
})
export class PaymentSectionRoutingModule {}

View File

@ -3,7 +3,7 @@ import { RouterModule, Routes } from '@angular/router';
import { PayoutsComponent } from './payouts.component';
const routes: Routes = [
const ROUTES: Routes = [
{
path: '',
component: PayoutsComponent,
@ -11,7 +11,7 @@ const routes: Routes = [
];
@NgModule({
imports: [RouterModule.forChild(routes)],
imports: [RouterModule.forChild(ROUTES)],
exports: [RouterModule],
})
export class PayoutsRoutingModule {}

View File

@ -11,7 +11,7 @@ import { ApiShopsService } from '@dsh/api/shop';
import { filterShopsByRealm, mapToShopInfo } from '../../operations/operators';
import { CreateReportDialogService } from './create-report-dialog.service';
const timePattern = /^([0-9]|0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]$/;
const TIME_PATTERN = /^([0-9]|0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]$/;
@Component({
templateUrl: 'create-report-dialog.component.html',
@ -24,9 +24,9 @@ export class CreateReportDialogComponent implements OnInit {
shopsInfo$ = of(this.data.realm).pipe(filterShopsByRealm(this.shopService.shops$), mapToShopInfo);
form = this.fb.group({
fromDate: [moment().startOf('month').format(), Validators.required],
fromTime: ['00:00:00', Validators.pattern(timePattern)],
fromTime: ['00:00:00', Validators.pattern(TIME_PATTERN)],
toDate: [moment().endOf('month').add(1).format(), Validators.required],
toTime: ['00:00:00', Validators.pattern(timePattern)],
toTime: ['00:00:00', Validators.pattern(TIME_PATTERN)],
shopID: null,
});

View File

@ -3,7 +3,7 @@ import { RouterModule, Routes } from '@angular/router';
import { ReportsComponent } from './reports.component';
const routes: Routes = [
const ROUTES: Routes = [
{
path: '',
component: ReportsComponent,
@ -11,7 +11,7 @@ const routes: Routes = [
];
@NgModule({
imports: [RouterModule.forChild(routes)],
imports: [RouterModule.forChild(ROUTES)],
exports: [RouterModule],
})
export class ReportsRoutingModule {}

View File

@ -3,7 +3,7 @@ import { RouterModule, Routes } from '@angular/router';
import { MainComponent } from './main';
const routes: Routes = [
const ROUTES: Routes = [
{
path: '',
component: MainComponent,
@ -51,7 +51,7 @@ const routes: Routes = [
];
@NgModule({
imports: [RouterModule.forRoot(routes, { paramsInheritanceStrategy: 'always', relativeLinkResolution: 'legacy' })],
imports: [RouterModule.forRoot(ROUTES, { paramsInheritanceStrategy: 'always', relativeLinkResolution: 'legacy' })],
exports: [RouterModule],
})
export class SectionsRoutingModule {}

View File

@ -8,15 +8,15 @@ export const DEFAULT_SEARCH_LIMIT = 10;
export type DialogConfig = { small: MatDialogConfig; medium: MatDialogConfig; large: MatDialogConfig };
export const DIALOG_CONFIG = new InjectionToken<DialogConfig>('dialogConfig');
const baseConfig: MatDialogConfig = {
const BASE_CONFIG: MatDialogConfig = {
maxHeight: '90vh',
disableClose: true,
autoFocus: false,
};
export const DEFAULT_DIALOG_CONFIG: DialogConfig = {
small: { ...baseConfig, width: '360px' },
medium: { ...baseConfig, width: '552px' },
large: { ...baseConfig, width: '648px' },
small: { ...BASE_CONFIG, width: '360px' },
medium: { ...BASE_CONFIG, width: '552px' },
large: { ...BASE_CONFIG, width: '648px' },
};
export const DEFAULT_CHARTS_THEME: ChartsThemeProvider = {

View File

@ -3,7 +3,7 @@ import { RouterModule, Routes } from '@angular/router';
import { WalletDetailsComponent } from './wallet-details.component';
const walletDetailsRoutes: Routes = [
const WALLET_DETAILS_ROUTES: Routes = [
{
path: ':walletID',
component: WalletDetailsComponent,
@ -11,7 +11,7 @@ const walletDetailsRoutes: Routes = [
];
@NgModule({
imports: [RouterModule.forChild(walletDetailsRoutes)],
imports: [RouterModule.forChild(WALLET_DETAILS_ROUTES)],
exports: [RouterModule],
})
export class WalletDetailsRoutingModule {}

View File

@ -3,7 +3,7 @@ import { RouterModule, Routes } from '@angular/router';
import { DepositsComponent } from './deposits.component';
const routes: Routes = [
const ROUTES: Routes = [
{
path: '',
component: DepositsComponent,
@ -11,7 +11,7 @@ const routes: Routes = [
];
@NgModule({
imports: [RouterModule.forChild(routes)],
imports: [RouterModule.forChild(ROUTES)],
exports: [RouterModule],
})
export class DepositsRoutingModule {}

View File

@ -3,7 +3,7 @@ import { RouterModule, Routes } from '@angular/router';
import { IntegrationsComponent } from './integrations.component';
const routes: Routes = [
const ROUTES: Routes = [
{
path: '',
component: IntegrationsComponent,
@ -21,7 +21,7 @@ const routes: Routes = [
];
@NgModule({
imports: [RouterModule.forChild(routes)],
imports: [RouterModule.forChild(ROUTES)],
exports: [RouterModule],
})
export class IntegrationsRoutingModule {}

View File

@ -3,7 +3,7 @@ import { RouterModule, Routes } from '@angular/router';
import { WebhooksComponent } from './webhooks.component';
const routes: Routes = [
const ROUTES: Routes = [
{
path: '',
component: WebhooksComponent,
@ -11,6 +11,6 @@ const routes: Routes = [
];
@NgModule({
imports: [RouterModule.forChild(routes)],
imports: [RouterModule.forChild(ROUTES)],
})
export class WebhooksRoutingModule {}

View File

@ -3,7 +3,7 @@ import { RouterModule, Routes } from '@angular/router';
import { WalletSectionComponent } from './wallet-section.component';
const walletSectionRoutes: Routes = [
const WALLET_SECTION_ROUTES: Routes = [
{
path: '',
component: WalletSectionComponent,
@ -33,7 +33,7 @@ const walletSectionRoutes: Routes = [
];
@NgModule({
imports: [RouterModule.forChild(walletSectionRoutes)],
imports: [RouterModule.forChild(WALLET_SECTION_ROUTES)],
exports: [RouterModule],
})
export class WalletSectionRoutingModule {}

View File

@ -3,7 +3,7 @@ import { RouterModule, Routes } from '@angular/router';
import { WalletsComponent } from './wallets.component';
const routes: Routes = [
const ROUTES: Routes = [
{
path: '',
component: WalletsComponent,
@ -11,7 +11,7 @@ const routes: Routes = [
];
@NgModule({
imports: [RouterModule.forChild(routes)],
imports: [RouterModule.forChild(ROUTES)],
exports: [RouterModule],
})
export class WalletsRoutingModule {}

View File

@ -3,7 +3,7 @@ import { RouterModule, Routes } from '@angular/router';
import { WithdrawalsComponent } from './withdrawals.component';
const routes: Routes = [
const ROUTES: Routes = [
{
path: '',
component: WithdrawalsComponent,
@ -11,7 +11,7 @@ const routes: Routes = [
];
@NgModule({
imports: [RouterModule.forChild(routes)],
imports: [RouterModule.forChild(ROUTES)],
exports: [RouterModule],
})
export class WithdrawalsRoutingModule {}

View File

@ -1,10 +1,12 @@
import { RoleId } from '@dsh/api-codegen/organizations';
export const ROLE_PRIORITY_DESC: Record<RoleId, number> = {
/* eslint-disable @typescript-eslint/naming-convention */
Administrator: 0,
Manager: 1,
Accountant: 2,
Integrator: 3,
/* eslint-enable @typescript-eslint/naming-convention */
};
export function sortRoleIds(a: RoleId, b: RoleId) {

Some files were not shown because too many files have changed in this diff Show More