11import { PaymentMethodResult , Stripe , StripeCardNumberElement } from '@stripe/stripe-js'
22
33import { FormCard , GenericDataObject , Page , textFormatMoneyLocaleString , UserProfile } from '../../../../../lib'
4+ import { isJsonString } from '../../../../../utils/string'
45// this has to be imported directly from the file bc the order of operations
56// that items are loaded in the barrel file this config is empty and throws an error
67// eslint-disable-next-line ordered-imports/ordered-imports
@@ -17,6 +18,8 @@ import {
1718import {
1819 ActivateWorkRequest ,
1920 Challenge ,
21+ ChallengeMetadata ,
22+ ChallengeMetadataName ,
2023 CreateWorkRequest ,
2124 CustomerPayment ,
2225 CustomerPaymentRequest ,
@@ -41,11 +44,21 @@ import {
4144 WorkTypeConfig ,
4245 WorkTypeConfigs ,
4346} from './work-store'
47+ import { findMetadata } from './work-factory/work.factory'
4448
4549export async function createAsync ( type : WorkType ) : Promise < Challenge > {
4650 const workConfig : WorkTypeConfig = WorkTypeConfigs [ type ]
4751 const body : CreateWorkRequest = workFactoryBuildCreateReqeuest ( workConfig )
48- return workStoreCreateAsync ( body )
52+ const result : Challenge = await workStoreCreateAsync ( body )
53+
54+ const intakeFormResponse : ChallengeMetadata | undefined
55+ = findMetadata ( result , ChallengeMetadataName . intakeForm ) || undefined
56+ if ( ! ! intakeFormResponse ?. value && ! isJsonString ( intakeFormResponse . value ) ) {
57+ const bodyIntakeForm : ChallengeMetadata | undefined = findMetadata ( body , ChallengeMetadataName . intakeForm )
58+ intakeFormResponse . value = bodyIntakeForm ?. value || '{}'
59+ }
60+
61+ return result
4962}
5063
5164export async function createCustomerPaymentAsync (
0 commit comments