@@ -20,20 +20,23 @@ import {
2020 TransactionService ,
2121 WebhookEndpointService ,
2222 TopupService ,
23+ ConfigService ,
2324} from '../../../data' ;
2425import {
26+ BusinessProfileFormComponent ,
2527 ExternalWalletFormComponent ,
2628 PersonFormComponent ,
2729 SettingsCardComponent ,
30+ SlidePanelComponent ,
2831} from '../../../shared' ;
29- import { SlidePanelComponent } from '../../../shared' ;
3032
3133@Component ( {
3234 selector : 'app-settings' ,
3335 imports : [
3436 SlidePanelComponent ,
3537 PersonFormComponent ,
3638 ExternalWalletFormComponent ,
39+ BusinessProfileFormComponent ,
3740 SettingsCardComponent ,
3841 ] ,
3942 templateUrl : './settings.component.html' ,
@@ -43,6 +46,8 @@ import { SlidePanelComponent } from '../../../shared';
4346export class SettingsComponent implements OnInit {
4447 @ViewChild ( 'editPersonForm' ) editPersonForm ! : PersonFormComponent ;
4548 @ViewChild ( 'editWalletForm' ) editWalletForm ! : ExternalWalletFormComponent ;
49+ @ViewChild ( 'editBusinessForm' )
50+ editBusinessForm ! : BusinessProfileFormComponent ;
4651
4752 readonly personService = inject ( PersonService ) ;
4853 readonly externalWalletService = inject ( ExternalWalletService ) ;
@@ -53,6 +58,7 @@ export class SettingsComponent implements OnInit {
5358 readonly webhookEndpointService = inject ( WebhookEndpointService ) ;
5459 readonly apiKeyService = inject ( ApiKeyService ) ;
5560 readonly topupService = inject ( TopupService ) ;
61+ readonly configService = inject ( ConfigService ) ;
5662 readonly router = inject ( Router ) ;
5763 private readonly metaService = inject ( MetaService ) ;
5864
@@ -67,10 +73,54 @@ export class SettingsComponent implements OnInit {
6773 editWalletShowErrors : WritableSignal < boolean > = signal ( false ) ;
6874 walletFormValid : WritableSignal < boolean > = signal ( false ) ;
6975
76+ // Edit business details panel state
77+ editBusinessPanelOpen : WritableSignal < boolean > = signal ( false ) ;
78+ editBusinessLoading : WritableSignal < boolean > = signal ( false ) ;
79+ editBusinessShowErrors : WritableSignal < boolean > = signal ( false ) ;
80+
7081 ngOnInit ( ) : void {
7182 this . metaService . SetMetaTitle ( 'Settings' ) ;
7283 }
7384
85+ // Edit Business Panel
86+ OnEditBusinessClick ( ) : void {
87+ this . editBusinessShowErrors . set ( false ) ;
88+ this . editBusinessPanelOpen . set ( true ) ;
89+ }
90+
91+ OnEditBusinessPanelClosed ( ) : void {
92+ this . editBusinessPanelOpen . set ( false ) ;
93+ this . editBusinessShowErrors . set ( false ) ;
94+ }
95+
96+ async OnEditBusinessSubmit ( ) : Promise < void > {
97+ if ( ! this . editBusinessForm ) return ;
98+
99+ this . editBusinessShowErrors . set ( true ) ;
100+
101+ if ( ! this . editBusinessForm . ValidateAll ( ) ) {
102+ return ;
103+ }
104+
105+ const account = this . GetAccount ( ) ;
106+ if ( ! account ) return ;
107+
108+ this . editBusinessLoading . set ( true ) ;
109+
110+ try {
111+ const updateData = this . editBusinessForm . GetUpdateData ( ) ;
112+ await this . accountService . UpdateAccount ( account . id , updateData ) ;
113+ this . configService . ClearConfig ( ) ;
114+ await this . configService . LoadConfig ( ) ;
115+ this . editBusinessPanelOpen . set ( false ) ;
116+ this . editBusinessShowErrors . set ( false ) ;
117+ } catch ( error ) {
118+ console . error ( 'Failed to update business details:' , error ) ;
119+ } finally {
120+ this . editBusinessLoading . set ( false ) ;
121+ }
122+ }
123+
74124 // Edit Person Panel
75125 OnEditPersonClick ( ) : void {
76126 this . editPersonShowErrors . set ( false ) ;
0 commit comments