@@ -15,6 +15,7 @@ import { BudgetService } from '../../service/localStorage/budget.service';
1515import { UserData } from '../../component/settings-components/download-component/download-component.component' ;
1616import { GlobalLoaderService } from '../../service/global-loader/global-loader.service' ;
1717import { PostApiService } from '../../service/backend-api/post/post-api.service' ;
18+ import { SectionService } from '../../service/section/section.service' ;
1819/**
1920 * @component
2021 * @description
@@ -102,6 +103,7 @@ export class SettingsComponent {
102103 private toastService : ToastService ,
103104 private globalLoaderService : GlobalLoaderService ,
104105 private postApiService : PostApiService ,
106+ private sectionService : SectionService
105107 ) { }
106108
107109 /**
@@ -200,19 +202,21 @@ export class SettingsComponent {
200202 this . deleteCategoryForm . markAllAsTouched ( ) ;
201203 return ;
202204 }
203- const category_id = this . deleteCategoryForm . value ;
204- this . categoryService . delete ( category_id . category_id ) ;
205- this . toastService . show ( `Category deleted succesfully.` , 'success' ) ;
206- this . closeDeleteCategoryModal ( ) ;
207- const existingCategories : Category [ ] = this . categoryService . getAll ( ) ;
208- let userId = this . userService . getValue < string > ( 'id' ) || '0' ;
209- if ( existingCategories . some ( cat => cat . user_id === userId ) ) {
210- this . showEditCategoryOption = true ;
211- this . showDeleteCategoryOption = true ;
212- }
213- else {
214- this . showEditCategoryOption = false ;
215- this . showDeleteCategoryOption = false ;
205+ if ( confirm ( 'Are you sure you want to delete this category?' ) ) {
206+ const category_id = this . deleteCategoryForm . value ;
207+ this . categoryService . delete ( category_id . category_id ) ;
208+ this . toastService . show ( `Category deleted succesfully.` , 'success' ) ;
209+ this . closeDeleteCategoryModal ( ) ;
210+ const existingCategories : Category [ ] = this . categoryService . getAll ( ) ;
211+ let userId = this . userService . getValue < string > ( 'id' ) || '0' ;
212+ if ( existingCategories . some ( cat => cat . user_id === userId ) ) {
213+ this . showEditCategoryOption = true ;
214+ this . showDeleteCategoryOption = true ;
215+ }
216+ else {
217+ this . showEditCategoryOption = false ;
218+ this . showDeleteCategoryOption = false ;
219+ }
216220 }
217221 }
218222
@@ -537,4 +541,9 @@ export class SettingsComponent {
537541 backupData ( ) : void {
538542 this . postApiService . postUserData ( true ) ;
539543 }
544+
545+ openHelpCenter ( section : string , event : Event ) : void {
546+ event . preventDefault ( ) ;
547+ this . sectionService . setSection ( section ) ;
548+ }
540549}
0 commit comments