@@ -31,6 +31,7 @@ import { TranslateService } from '@ngx-translate/core';
3131import { DeleteDialogComponent } from '../../../shared/delete-dialog/delete-dialog.component' ;
3232
3333/** Custom Services */
34+ import { AlertService } from 'app/core/alert/alert.service' ;
3435import { OrganizationService } from '../../organization.service' ;
3536import { PopoverService } from '../../../configuration-wizard/popover/popover.service' ;
3637import { ConfigurationWizardService } from '../../../configuration-wizard/configuration-wizard.service' ;
@@ -66,6 +67,7 @@ export class ManageCurrenciesComponent implements OnInit, AfterViewInit, OnChang
6667 private route = inject ( ActivatedRoute ) ;
6768 private formBuilder = inject ( FormBuilder ) ;
6869 private organizationservice = inject ( OrganizationService ) ;
70+ private alertService = inject ( AlertService ) ;
6971 dialog = inject ( MatDialog ) ;
7072 private router = inject ( Router ) ;
7173 private translateService = inject ( TranslateService ) ;
@@ -157,20 +159,26 @@ export class ManageCurrenciesComponent implements OnInit, AfterViewInit, OnChang
157159 addCurrency ( ) {
158160 const newCurrency = this . currencyForm . value . currency ;
159161 const selectedCurrencyCodes : any [ ] = this . selectedCurrencies . map ( ( currency ) => currency . code ) ;
160- if ( ! selectedCurrencyCodes . includes ( newCurrency . code ) ) {
161- selectedCurrencyCodes . push ( newCurrency . code ) ;
162- this . organizationservice
163- . updateCurrencies ( selectedCurrencyCodes )
164- . pipe ( take ( 1 ) )
165- . subscribe ( ( response : any ) => {
166- this . selectedCurrencies . push ( newCurrency ) ;
167- this . formRef . resetForm ( ) ;
168- if ( this . configurationWizardService . showCurrencyForm ) {
169- this . configurationWizardService . showCurrencyForm = false ;
170- this . openDialog ( ) ;
171- }
172- } ) ;
162+ if ( selectedCurrencyCodes . includes ( newCurrency . code ) ) {
163+ this . alertService . alert ( {
164+ type : 'error' ,
165+ message : this . translateService . instant ( 'labels.text.This currency has already been added' )
166+ } ) ;
167+ this . formRef . resetForm ( ) ;
168+ return ;
173169 }
170+ selectedCurrencyCodes . push ( newCurrency . code ) ;
171+ this . organizationservice
172+ . updateCurrencies ( selectedCurrencyCodes )
173+ . pipe ( take ( 1 ) )
174+ . subscribe ( ( response : any ) => {
175+ this . selectedCurrencies . push ( newCurrency ) ;
176+ this . formRef . resetForm ( ) ;
177+ if ( this . configurationWizardService . showCurrencyForm ) {
178+ this . configurationWizardService . showCurrencyForm = false ;
179+ this . openDialog ( ) ;
180+ }
181+ } ) ;
174182 }
175183
176184 /**
0 commit comments