Browse Source

feat(client): improve on submit method type safety

pull/6722/head
KenTandrian 1 month ago
parent
commit
94e2da07fa
  1. 18
      apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.component.ts

18
apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.component.ts

@ -502,18 +502,18 @@ export class GfAssetProfileDialogComponent implements OnInit {
} }
protected async onSubmitAssetProfileForm() { protected async onSubmitAssetProfileForm() {
let countries = []; let countries: Prisma.InputJsonArray = [];
let scraperConfiguration: Prisma.InputJsonObject | undefined = { let scraperConfiguration: Prisma.InputJsonObject | undefined = {
selector: '', selector: '',
url: '' url: ''
}; };
let sectors = []; let sectors: Prisma.InputJsonArray = [];
let symbolMapping = {}; let symbolMapping: Record<string, string> = {};
try { try {
countries = JSON.parse( countries = JSON.parse(
this.assetProfileForm.get('countries')?.value ?? '[]' this.assetProfileForm.get('countries')?.value ?? '[]'
); ) as Prisma.InputJsonArray;
} catch {} } catch {}
try { try {
@ -526,7 +526,7 @@ export class GfAssetProfileDialogComponent implements OnInit {
this.assetProfileForm.controls['scraperConfiguration'].controls[ this.assetProfileForm.controls['scraperConfiguration'].controls[
'headers' 'headers'
].value ?? '{}' ].value ?? '{}'
), ) as Record<string, string>,
locale: locale:
this.assetProfileForm.controls['scraperConfiguration'].controls[ this.assetProfileForm.controls['scraperConfiguration'].controls[
'locale' 'locale'
@ -562,13 +562,15 @@ export class GfAssetProfileDialogComponent implements OnInit {
} }
try { try {
sectors = JSON.parse(this.assetProfileForm.get('sectors')?.value ?? '[]'); sectors = JSON.parse(
this.assetProfileForm.get('sectors')?.value ?? '[]'
) as Prisma.InputJsonArray;
} catch {} } catch {}
try { try {
symbolMapping = JSON.parse( symbolMapping = JSON.parse(
this.assetProfileForm.get('symbolMapping')?.value ?? '{}' this.assetProfileForm.get('symbolMapping')?.value ?? '{}'
); ) as Record<string, string>;
} catch {} } catch {}
const isActive = this.assetProfileForm.get('isActive')?.value; const isActive = this.assetProfileForm.get('isActive')?.value;
@ -716,7 +718,7 @@ export class GfAssetProfileDialogComponent implements OnInit {
this.assetProfileForm.controls['scraperConfiguration'].controls[ this.assetProfileForm.controls['scraperConfiguration'].controls[
'headers' 'headers'
]?.value ?? '{}' ]?.value ?? '{}'
), ) as Record<string, string>,
locale: locale:
this.assetProfileForm.controls['scraperConfiguration'].controls[ this.assetProfileForm.controls['scraperConfiguration'].controls[
'locale' 'locale'

Loading…
Cancel
Save