Browse Source

Removed comments and refactor code

pull/6130/head
omkarg01 1 week ago
parent
commit
ce3823b0b3
  1. 13
      apps/client/src/app/pages/accounts/create-or-update-account-dialog/create-or-update-account-dialog.component.ts
  2. 8
      apps/client/src/app/services/data.service.ts

13
apps/client/src/app/pages/accounts/create-or-update-account-dialog/create-or-update-account-dialog.component.ts

@ -81,22 +81,23 @@ export class GfCreateOrUpdateAccountDialogComponent implements OnDestroy {
currency: [this.data.account.currency, Validators.required], currency: [this.data.account.currency, Validators.required],
isExcluded: [this.data.account.isExcluded], isExcluded: [this.data.account.isExcluded],
name: [this.data.account.name, Validators.required], name: [this.data.account.name, Validators.required],
platformId: [null, this.autocompleteObjectValidator()] // Initialize as null platformId: [null, this.autocompleteObjectValidator()]
}); });
this.dataService.fetchPlatforms().subscribe(({ platforms }) => { this.dataService.fetchPlatforms().subscribe(({ platforms }) => {
this.platforms = platforms; this.platforms = platforms;
// Update platformId after platforms are loaded
const selectedPlatform = this.platforms.find(({ id }) => { const selectedPlatform = this.platforms.find(({ id }) => {
return id === this.data.account.platformId; return id === this.data.account.platformId;
}); });
this.accountForm.patchValue({ this.accountForm.patchValue(
platformId: selectedPlatform {
}); platformId: selectedPlatform
},
{ emitEvent: false }
);
// Set up filteredPlatforms observable
this.filteredPlatforms = this.accountForm this.filteredPlatforms = this.accountForm
.get('platformId') .get('platformId')
.valueChanges.pipe( .valueChanges.pipe(

8
apps/client/src/app/services/data.service.ts

@ -198,10 +198,6 @@ export class DataService {
); );
} }
public fetchPlatforms(): Observable<PlatformsResponse> {
return this.http.get<PlatformsResponse>('/api/v1/platforms');
}
public fetchAccounts({ filters }: { filters?: Filter[] } = {}) { public fetchAccounts({ filters }: { filters?: Filter[] } = {}) {
const params = this.buildFiltersAsQueryParams({ filters }); const params = this.buildFiltersAsQueryParams({ filters });
@ -526,6 +522,10 @@ export class DataService {
); );
} }
public fetchPlatforms() {
return this.http.get<PlatformsResponse>('/api/v1/platforms');
}
public fetchPortfolioDetails({ public fetchPortfolioDetails({
filters, filters,
withMarkets = false withMarkets = false

Loading…
Cancel
Save