From e9104df9f8c9f099982708bc4e395a3c0a0a4b19 Mon Sep 17 00:00:00 2001 From: Pavlo Ostrozhynskyi Date: Tue, 7 Jun 2022 19:25:16 +0300 Subject: [PATCH 1/5] add insstitution type data --- .../provider-info.component.html | 4 ++-- .../provider-info/provider-info.component.ts | 24 ++++--------------- src/app/shared/enum/provider.ts | 6 +++++ src/app/shared/models/provider.model.ts | 1 + 4 files changed, 13 insertions(+), 22 deletions(-) diff --git a/src/app/shared/components/provider-info/provider-info.component.html b/src/app/shared/components/provider-info/provider-info.component.html index cc3ff4dfc2..e9dd4af5e1 100644 --- a/src/app/shared/components/provider-info/provider-info.component.html +++ b/src/app/shared/components/provider-info/provider-info.component.html @@ -70,8 +70,8 @@
Будинок
-
Статус
-

{{ this.currentStatus }}

+
Тип закладу
+

{{ institutionType[provider.institutionType] }}

Про заклад

{{ provider?.description }}

diff --git a/src/app/shared/components/provider-info/provider-info.component.ts b/src/app/shared/components/provider-info/provider-info.component.ts index 1130562165..299da689d9 100644 --- a/src/app/shared/components/provider-info/provider-info.component.ts +++ b/src/app/shared/components/provider-info/provider-info.component.ts @@ -1,8 +1,9 @@ -import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; +import { Component, EventEmitter, Input, Output } from '@angular/core'; import { Constants } from 'src/app/shared/constants/constants'; import { MatTabChangeEvent } from '@angular/material/tabs'; import { CreateProviderSteps, + InstitutionType, OwnershipType, OwnershipTypeUkr, ProviderType, @@ -10,12 +11,9 @@ import { } from '../../enum/provider'; import { Provider } from '../../models/provider.model'; import { Select, Store } from '@ngxs/store'; -import { GetInstitutionStatus } from '../../store/meta-data.actions'; import { MetaDataState } from '../../store/meta-data.state'; import { Observable, Subject } from 'rxjs'; import { InstitutionStatus } from '../../models/institutionStatus.model'; -import { filter, takeUntil } from 'rxjs/operators'; -import { RegistrationState } from '../../store/registration.state'; import { ActivateEditMode } from 'src/app/shared/store/app.actions'; @Component({ @@ -23,12 +21,13 @@ import { ActivateEditMode } from 'src/app/shared/store/app.actions'; templateUrl: './provider-info.component.html', styleUrls: ['./provider-info.component.scss'], }) -export class ProviderInfoComponent implements OnInit { +export class ProviderInfoComponent { readonly constants: typeof Constants = Constants; readonly providerType: typeof ProviderType = ProviderType; readonly ownershipType: typeof OwnershipType = OwnershipType; readonly ownershipTypeUkr = OwnershipTypeUkr; readonly providerTypeUkr = ProviderTypeUkr; + readonly institutionType = InstitutionType; editLink: string = CreateProviderSteps[0]; @Input() provider: Provider; @@ -44,21 +43,6 @@ export class ProviderInfoComponent implements OnInit { constructor(private store: Store) {} - ngOnInit(): void { - this.store.dispatch(new GetInstitutionStatus()); - this.institutionStatuses$ - .pipe( - filter((institutionStatuses) => !!institutionStatuses.length), - takeUntil(this.destroy$) - ).subscribe((institutionStatuses) => { - const provider = this.store.selectSnapshot(RegistrationState.provider); - this.currentStatus = - institutionStatuses - .find((item) => +item.id === provider?.institutionStatusId) - ?.name.toString() ?? 'Відсутній'; - }); - } - onTabChanged(tabChangeEvent: MatTabChangeEvent): void { this.editLink = CreateProviderSteps[tabChangeEvent.index]; this.tabChanged.emit(tabChangeEvent); diff --git a/src/app/shared/enum/provider.ts b/src/app/shared/enum/provider.ts index 223b0ca274..c5fa248e45 100644 --- a/src/app/shared/enum/provider.ts +++ b/src/app/shared/enum/provider.ts @@ -52,4 +52,10 @@ export enum ProviderWorkshopSameValues { website = 'website', facebook = 'facebook', instagram = 'instagram' +} + +export enum InstitutionType { + Complex = 'Комплексний', + Profile = 'Профільний', + Specialized = 'Спеціалізований' } \ No newline at end of file diff --git a/src/app/shared/models/provider.model.ts b/src/app/shared/models/provider.model.ts index 53e7909611..4e7c6602f3 100644 --- a/src/app/shared/models/provider.model.ts +++ b/src/app/shared/models/provider.model.ts @@ -26,6 +26,7 @@ export class Provider { image?: File[]; imageIds?: string[]; institutionStatusId?: number | null; + institutionType: string; constructor(info, legalAddress: Address, actualAddress: Address, description, user: User, provider?: Provider) { this.shortTitle = info.shortTitle; From 1b4c9ba0ab1f879448d94364ff06047b2bda39df Mon Sep 17 00:00:00 2001 From: Pavlo Ostrozhynskyi Date: Sat, 11 Jun 2022 21:49:34 +0300 Subject: [PATCH 2/5] bug fixed --- .../provider-info.component.html | 4 ++- .../provider-info/provider-info.component.ts | 28 +++++++++++++++---- src/app/shared/enum/provider.ts | 2 +- src/app/shared/models/provider.model.ts | 1 + .../create-photo-form.component.html | 11 ++++++++ .../create-photo-form.component.ts | 20 ++++++++----- 6 files changed, 52 insertions(+), 14 deletions(-) diff --git a/src/app/shared/components/provider-info/provider-info.component.html b/src/app/shared/components/provider-info/provider-info.component.html index e9dd4af5e1..c5d1e18226 100644 --- a/src/app/shared/components/provider-info/provider-info.component.html +++ b/src/app/shared/components/provider-info/provider-info.component.html @@ -70,8 +70,10 @@
Будинок
+
Статус
+

{{ this.currentStatus }}

Тип закладу
-

{{ institutionType[provider.institutionType] }}

+

{{ institutionTypes[provider.institutionType] }}

Про заклад

{{ provider?.description }}

diff --git a/src/app/shared/components/provider-info/provider-info.component.ts b/src/app/shared/components/provider-info/provider-info.component.ts index 299da689d9..611e01031a 100644 --- a/src/app/shared/components/provider-info/provider-info.component.ts +++ b/src/app/shared/components/provider-info/provider-info.component.ts @@ -1,33 +1,36 @@ -import { Component, EventEmitter, Input, Output } from '@angular/core'; +import { Component, EventEmitter, Input, Output, OnInit } from '@angular/core'; import { Constants } from 'src/app/shared/constants/constants'; import { MatTabChangeEvent } from '@angular/material/tabs'; import { CreateProviderSteps, - InstitutionType, + InstitutionTypes, OwnershipType, OwnershipTypeUkr, ProviderType, ProviderTypeUkr, } from '../../enum/provider'; import { Provider } from '../../models/provider.model'; -import { Select, Store } from '@ngxs/store'; +import { NgxsOnInit, Select, Store } from '@ngxs/store'; import { MetaDataState } from '../../store/meta-data.state'; import { Observable, Subject } from 'rxjs'; import { InstitutionStatus } from '../../models/institutionStatus.model'; import { ActivateEditMode } from 'src/app/shared/store/app.actions'; +import { GetInstitutionStatus } from '../../store/meta-data.actions'; +import { filter, takeUntil } from 'rxjs/operators'; +import { RegistrationState } from '../../store/registration.state'; @Component({ selector: 'app-provider-info', templateUrl: './provider-info.component.html', styleUrls: ['./provider-info.component.scss'], }) -export class ProviderInfoComponent { +export class ProviderInfoComponent implements OnInit { readonly constants: typeof Constants = Constants; readonly providerType: typeof ProviderType = ProviderType; readonly ownershipType: typeof OwnershipType = OwnershipType; readonly ownershipTypeUkr = OwnershipTypeUkr; readonly providerTypeUkr = ProviderTypeUkr; - readonly institutionType = InstitutionType; + readonly institutionTypes = InstitutionTypes; editLink: string = CreateProviderSteps[0]; @Input() provider: Provider; @@ -43,6 +46,21 @@ export class ProviderInfoComponent { constructor(private store: Store) {} + ngOnInit(): void { + this.store.dispatch(new GetInstitutionStatus()); + this.institutionStatuses$ + .pipe( + filter((institutionStatuses) => !!institutionStatuses.length), + takeUntil(this.destroy$) + ).subscribe((institutionStatuses) => { + const provider = this.store.selectSnapshot(RegistrationState.provider); + this.currentStatus = + institutionStatuses + .find((item) => +item.id === provider?.institutionStatusId) + ?.name.toString() ?? 'Відсутній'; + }); + } + onTabChanged(tabChangeEvent: MatTabChangeEvent): void { this.editLink = CreateProviderSteps[tabChangeEvent.index]; this.tabChanged.emit(tabChangeEvent); diff --git a/src/app/shared/enum/provider.ts b/src/app/shared/enum/provider.ts index c5fa248e45..1dd01cce52 100644 --- a/src/app/shared/enum/provider.ts +++ b/src/app/shared/enum/provider.ts @@ -54,7 +54,7 @@ export enum ProviderWorkshopSameValues { instagram = 'instagram' } -export enum InstitutionType { +export enum InstitutionTypes { Complex = 'Комплексний', Profile = 'Профільний', Specialized = 'Спеціалізований' diff --git a/src/app/shared/models/provider.model.ts b/src/app/shared/models/provider.model.ts index 4e7c6602f3..9b6f584b1a 100644 --- a/src/app/shared/models/provider.model.ts +++ b/src/app/shared/models/provider.model.ts @@ -46,6 +46,7 @@ export class Provider { this.actualAddress = actualAddress; this.description = description.description; this.institutionStatusId = description.institutionStatusId || null; + this.institutionType = description.institutionType; this.userId = user.id; if (provider?.id) { this.id = provider.id; diff --git a/src/app/shell/personal-cabinet/provider/create-provider/create-photo-form/create-photo-form.component.html b/src/app/shell/personal-cabinet/provider/create-provider/create-photo-form/create-photo-form.component.html index 66b0f0cad8..00337fb7da 100644 --- a/src/app/shell/personal-cabinet/provider/create-provider/create-photo-form/create-photo-form.component.html +++ b/src/app/shell/personal-cabinet/provider/create-provider/create-photo-form/create-photo-form.component.html @@ -13,6 +13,17 @@ + + + + + {{type.value}} + + + + +