From f20380187b3aacf07b9493ac6ad5eb0adfca089a Mon Sep 17 00:00:00 2001 From: Rinat Arsaev <11846445+KrickRay@users.noreply.github.com> Date: Wed, 1 Sep 2021 15:38:56 +0300 Subject: [PATCH] FR-737: Refactor create claim selection (#563) --- .idea/prettier.xml | 2 +- .idea/watcherTasks.xml | 4 +++ package.json | 2 +- .../create-shop-dialog.component.html | 14 ++------- .../create-shop-dialog.component.scss | 2 +- .../create-shop-dialog.component.spec.ts | 31 +------------------ .../create-shop-dialog.component.ts | 10 +----- .../create-shop-dialog/types/shop-type.ts | 1 - .../shop-creation/shop-creation.module.ts | 2 ++ src/assets/i18n/create-shop/ru.json | 7 ++--- 10 files changed, 17 insertions(+), 58 deletions(-) create mode 100644 .idea/watcherTasks.xml diff --git a/.idea/prettier.xml b/.idea/prettier.xml index 34f5cf1b..17c9eb37 100644 --- a/.idea/prettier.xml +++ b/.idea/prettier.xml @@ -2,6 +2,6 @@ \ No newline at end of file diff --git a/.idea/watcherTasks.xml b/.idea/watcherTasks.xml new file mode 100644 index 00000000..fb0d65a4 --- /dev/null +++ b/.idea/watcherTasks.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/package.json b/package.json index f59a2e19..14e8ca39 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "build": "ng build --extra-webpack-config webpack.extra.js", "test": "ng test", "coverage": "npx http-server -c-1 -o -p 9875 ./coverage", - "lint-cmd": "eslint \"src/**/*.{ts,js,html}\" --max-warnings 1665", + "lint-cmd": "eslint \"src/**/*.{ts,js,html}\" --max-warnings 1653", "lint-cache-cmd": "npm run lint-cmd -- --cache", "lint": "npm run lint-cache-cmd", "lint-fix": "npm run lint-cache-cmd -- --fix", diff --git a/src/app/shared/components/shop-creation/components/create-shop-dialog/create-shop-dialog.component.html b/src/app/shared/components/shop-creation/components/create-shop-dialog/create-shop-dialog.component.html index 33d3a1e3..4638361f 100644 --- a/src/app/shared/components/shop-creation/components/create-shop-dialog/create-shop-dialog.component.html +++ b/src/app/shared/components/shop-creation/components/create-shop-dialog/create-shop-dialog.component.html @@ -10,12 +10,6 @@ (change)="onTypeChange($event.value)" >{{ t('russianLegalEntityType') }} - {{ t('newLegalEntityType') }} -
+ -
+ diff --git a/src/app/shared/components/shop-creation/components/create-shop-dialog/create-shop-dialog.component.scss b/src/app/shared/components/shop-creation/components/create-shop-dialog/create-shop-dialog.component.scss index 257162f0..4c1abae7 100644 --- a/src/app/shared/components/shop-creation/components/create-shop-dialog/create-shop-dialog.component.scss +++ b/src/app/shared/components/shop-creation/components/create-shop-dialog/create-shop-dialog.component.scss @@ -1,5 +1,5 @@ .dsh-next-button { - min-width: 100px; + min-width: 160px; } .dsh-wrap-mat-radio-label { diff --git a/src/app/shared/components/shop-creation/components/create-shop-dialog/create-shop-dialog.component.spec.ts b/src/app/shared/components/shop-creation/components/create-shop-dialog/create-shop-dialog.component.spec.ts index e0ce0d52..7682aefc 100644 --- a/src/app/shared/components/shop-creation/components/create-shop-dialog/create-shop-dialog.component.spec.ts +++ b/src/app/shared/components/shop-creation/components/create-shop-dialog/create-shop-dialog.component.spec.ts @@ -2,10 +2,9 @@ import { ChangeDetectionStrategy, Component } from '@angular/core'; import { ComponentFixture, TestBed } from '@angular/core/testing'; import { MatDialogRef } from '@angular/material/dialog'; import { MatRadioModule } from '@angular/material/radio'; -import { Router } from '@angular/router'; import { RouterTestingModule } from '@angular/router/testing'; import { TranslocoTestingModule } from '@ngneat/transloco'; -import { instance, mock, verify } from 'ts-mockito'; +import { instance, mock } from 'ts-mockito'; import { CreateShopDialogComponent } from './create-shop-dialog.component'; import { ShopType } from './types/shop-type'; @@ -17,7 +16,6 @@ describe('CreateShopDialogComponent', () => { let component: CreateShopDialogComponent; let fixture: ComponentFixture; let mockDialogRef: MatDialogRef; - let router: Router; beforeEach(() => { mockDialogRef = mock>(MatDialogRef); @@ -64,7 +62,6 @@ describe('CreateShopDialogComponent', () => { beforeEach(() => { fixture = TestBed.createComponent(CreateShopDialogComponent); component = fixture.componentInstance; - router = TestBed.inject(Router); fixture.detectChanges(); }); @@ -77,9 +74,6 @@ describe('CreateShopDialogComponent', () => { component.onTypeChange(ShopType.International); expect(component.selectedShopType).toBe(ShopType.International); - component.onTypeChange(ShopType.New); - expect(component.selectedShopType).toBe(ShopType.New); - component.onTypeChange(ShopType.Russian); expect(component.selectedShopType).toBe(ShopType.Russian); }); @@ -93,28 +87,5 @@ describe('CreateShopDialogComponent', () => { expect(component.selectionConfirmed).toBe(true); }); - - it('should close dialog if selectedShopType is new', () => { - component.onTypeChange(ShopType.New); - - fixture.ngZone.run(() => { - component.next(); - }); - - expect().nothing(); - verify(mockDialogRef.close()).once(); - }); - - it('should navigate to onboarding if selectedShopType is new', () => { - const spyOnNavigate = spyOn(router, 'navigate').and.callThrough(); - - component.onTypeChange(ShopType.New); - fixture.ngZone.run(() => { - component.next(); - }); - - expect(spyOnNavigate).toHaveBeenCalledTimes(1); - expect(spyOnNavigate).toHaveBeenCalledWith(['claim-section', 'onboarding']); - }); }); }); diff --git a/src/app/shared/components/shop-creation/components/create-shop-dialog/create-shop-dialog.component.ts b/src/app/shared/components/shop-creation/components/create-shop-dialog/create-shop-dialog.component.ts index e5d6b0e5..dae2dd86 100644 --- a/src/app/shared/components/shop-creation/components/create-shop-dialog/create-shop-dialog.component.ts +++ b/src/app/shared/components/shop-creation/components/create-shop-dialog/create-shop-dialog.component.ts @@ -1,6 +1,5 @@ import { Component } from '@angular/core'; import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; -import { Router } from '@angular/router'; import { Observable } from 'rxjs'; import { Shop } from '@dsh/api-codegen/capi'; @@ -30,20 +29,13 @@ export class CreateShopDialogComponent { selectionConfirmed = false; shopType = ShopType; - constructor( - public dialogRef: MatDialogRef, - private router: Router - ) {} + constructor(public dialogRef: MatDialogRef) {} onTypeChange(type: ShopType): void { this.selectedShopType = type; } next(): void { - if (this.selectedShopType === ShopType.New) { - this.dialogRef.close(); - void this.router.navigate(['claim-section', 'onboarding']); - } this.selectionConfirmed = true; } diff --git a/src/app/shared/components/shop-creation/components/create-shop-dialog/types/shop-type.ts b/src/app/shared/components/shop-creation/components/create-shop-dialog/types/shop-type.ts index 36b5efce..c638e903 100644 --- a/src/app/shared/components/shop-creation/components/create-shop-dialog/types/shop-type.ts +++ b/src/app/shared/components/shop-creation/components/create-shop-dialog/types/shop-type.ts @@ -1,5 +1,4 @@ export enum ShopType { Russian = 'RussianLegalEntity', - New = 'NewLegalEntity', International = 'InternationalLegalEntity', } diff --git a/src/app/shared/components/shop-creation/shop-creation.module.ts b/src/app/shared/components/shop-creation/shop-creation.module.ts index 59f657df..6fa93681 100644 --- a/src/app/shared/components/shop-creation/shop-creation.module.ts +++ b/src/app/shared/components/shop-creation/shop-creation.module.ts @@ -6,6 +6,7 @@ import { MatRadioModule } from '@angular/material/radio'; import { TranslocoModule } from '@ngneat/transloco'; import { PayoutsModule } from '@dsh/api/payouts'; +import { ActionsModule } from '@dsh/app/shared/components/actions'; import { BaseDialogModule } from '@dsh/app/shared/components/dialog/base-dialog'; import { ShopCreationService } from '@dsh/app/shared/components/shop-creation/shop-creation.service'; import { ShopContractDetailsModule } from '@dsh/app/shared/services/shop-contract-details'; @@ -28,6 +29,7 @@ import { CreateRussianShopEntityModule } from './create-russian-shop-entity'; PayoutsModule, BaseDialogModule, ShopContractDetailsModule, + ActionsModule, ], declarations: [CreateShopDialogComponent], providers: [ShopCreationService], diff --git a/src/assets/i18n/create-shop/ru.json b/src/assets/i18n/create-shop/ru.json index 7d57f606..52ae8646 100644 --- a/src/assets/i18n/create-shop/ru.json +++ b/src/assets/i18n/create-shop/ru.json @@ -1,9 +1,8 @@ { "title": "Новая заявка", - "type": "Выберите тип заявки", - "russianLegalEntityType": "Создание магазина (текущее ЮЛ)", - "newLegalEntityType": "Создание магазина (новое ЮЛ)", - "internationalLegalEntityType": "Создание магазина (международное ЮЛ)", + "type": "Создание магазина", + "russianLegalEntityType": "Российское ЮЛ", + "internationalLegalEntityType": "Международное ЮЛ", "russianLegalEntity": { "title": "Заявка на создание магазина", "orgDetails": {