{"version":3,"file":"GetProfessionalAffirmationSplashData-D11UN68u-chunk.js","sources":["../../../src/components/utility/api/GetProfessionalAffirmationSplashData.ts"],"sourcesContent":["import ky from \"ky-universal\";\n\ntype SuccessStatus = \"success\";\ntype FailedStatus = \"failed\";\ntype ProfessionalAffirmationAPIData = {\n\taffirmations: {\n\t\taffirmationButtonText: string;\n\t\tcheckBoxText: string;\n\t\tdescription: string;\n\t\tlanguage: string;\n\t\ttitle: string;\n\t}[];\n\tapiUrl: string;\n\tcontinueAffirmationNotes: string;\n\tcontinueAffirmationTitle: string;\n\ttitle: string;\n\taction: string;\n\tstatus: SuccessStatus | FailedStatus;\n} & Error;\n\nconst getProfessionalAffirmationSplashData = async (source: string) => {\n\tconst data = window[source] || {};\n\tlet baseUrl = window.location.origin + data.apiUrl;\n\tlet countryKeyJSON = data.countryKey ? JSON.stringify({ countryKey: data.countryKey }) : \"\";\n\n\tif (process.env.NODE_ENV !== \"production\") {\n\t\tbaseUrl = \"http://localhost:7000/audience-selector-api/get-professional-affirmation-data\";\n\t}\n\tconst resData:\n\t\t| {\n\t\t\t\tstatus: SuccessStatus;\n\t\t\t\tdata: ProfessionalAffirmationAPIData;\n\t\t }\n\t\t| {\n\t\t\t\tstatus: SuccessStatus;\n\t\t\t\tdata: string;\n\t\t }\n\t\t| {\n\t\t\t\tstatus: FailedStatus;\n\t\t\t\tdata: Error;\n\t\t } = await ky\n\t\t.post(baseUrl, {\n\t\t\theaders: new Headers({\n\t\t\t\t\"Content-Type\": \"application/json\"\n\t\t\t}),\n\t\t\tbody: countryKeyJSON\n\t\t})\n\t\t.json()\n\t\t.then((data) => {\n\t\t\tif (data.hasOwnProperty(\"status\")) {\n\t\t\t\tif (data.status === (\"failed\" as FailedStatus)) {\n\t\t\t\t\tconsole.error(data);\n\t\t\t\t\t// { \"status\": \"failed\", \"action\": \"none\" }\n\t\t\t\t\treturn {\n\t\t\t\t\t\tstatus: data.status,\n\t\t\t\t\t\tdata: data\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tif (data.action === \"reload\") {\n\t\t\t\t\t// { status: \"success\", action: \"reload\" }\n\t\t\t\t\treturn {\n\t\t\t\t\t\tstatus: data.status as SuccessStatus,\n\t\t\t\t\t\tdata: data.action\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\tstatus: \"success\" as SuccessStatus,\n\t\t\t\t\tdata: data\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tstatus: \"success\" as SuccessStatus,\n\t\t\t\tdata: data\n\t\t\t};\n\t\t})\n\t\t.catch((error: Error) => {\n\t\t\tconsole.error(error);\n\t\t\treturn {\n\t\t\t\tstatus: \"failed\" as FailedStatus,\n\t\t\t\tdata: error\n\t\t\t};\n\t\t});\n\treturn resData;\n};\nexport default getProfessionalAffirmationSplashData;\n"],"names":["getProfessionalAffirmationSplashData","source","data","baseUrl","countryKeyJSON","ky","error"],"mappings":"uCAoBM,MAAAA,EAAuC,MAAOC,GAAmB,CACtE,MAAMC,EAAO,OAAOD,CAAM,GAAK,CAAC,EAChC,IAAIE,EAAU,OAAO,SAAS,OAASD,EAAK,OACxCE,EAAiBF,EAAK,WAAa,KAAK,UAAU,CAAE,WAAYA,EAAK,UAAY,CAAA,EAAI,GA2DlF,OA1CA,MAAMG,EACX,KAAKF,EAAS,CACd,QAAS,IAAI,QAAQ,CACpB,eAAgB,kBAAA,CAChB,EACD,KAAMC,CACN,CAAA,EACA,KAAA,EACA,KAAMF,GACFA,EAAK,eAAe,QAAQ,EAC3BA,EAAK,SAAY,UACpB,QAAQ,MAAMA,CAAI,EAEX,CACN,OAAQA,EAAK,OACb,KAAMA,CACP,GAEGA,EAAK,SAAW,SAEZ,CACN,OAAQA,EAAK,OACb,KAAMA,EAAK,MACZ,EAEM,CACN,OAAQ,UACR,KAAMA,CACP,EAEM,CACN,OAAQ,UACR,KAAMA,CACP,CACA,EACA,MAAOI,IACP,QAAQ,MAAMA,CAAK,EACZ,CACN,OAAQ,SACR,KAAMA,CACP,EACA,CAEH"}