{"version":3,"file":"registrationStore.VUe_66X8.js","sources":["../../../../../../app/stores/step0Store.ts","../../../../../../app/services/RegistrationService.ts","../../../../../../app/stores/registrationStore.ts"],"sourcesContent":["import { defineStore } from \"pinia\";\nimport { RegistrationService } from \"~/services/RegistrationService\";\nimport type { RegistrationStep0 } from \"@/models/RegistrationStep0\";\n\nconst CLEAR_STORAGE_DELAY = 300000;\n\nexport const useStep0Store = defineStore(\"step0\", {\n state: () => {\n return {\n isLoading: false,\n emailAddress: \"\"\n };\n },\n persist: {\n storage: persistedState.localStorage\n },\n actions: {\n async postData(registrationStep0: RegistrationStep0): Promise {\n try {\n this.isLoading = true;\n await RegistrationService.registerStep0(registrationStep0);\n this.emailAddress = registrationStep0.emailAddress;\n this.scheduleStorageClear();\n } catch (error) {\n this.isLoading = false;\n console.error(error);\n throw error;\n } finally {\n this.isLoading = false;\n }\n },\n scheduleStorageClear() {\n setTimeout(() => {\n localStorage.removeItem(\"pinia\");\n this.emailAddress = \"\";\n }, CLEAR_STORAGE_DELAY);\n }\n }\n});\n","import type { Registration } from \"@/models/Registration\";\nimport { createSnackbarNotification } from \"@frontiers/brink-ui\";\nimport ErrorMessages from \"~/helpers/ErrorMessages\";\nimport type { PositionResponse } from \"~/models/PositionResponse\";\nimport { TimerService } from \"~/services/TimerService\";\nimport { useStep0Store } from \"~/stores/step0Store\";\nimport { ErrorCode } from \"~/enum/ErrorCode\";\nimport { useRegistrationStore } from \"~/stores/registrationStore\";\nimport type { GetInvitationDataResponse } from \"~/models/GetInvitationDataResponse\";\nimport type { GetRegistrationDataResponse } from \"~/models/GetRegistrationDataResponse\";\nimport type { RegistrationStep0 } from \"@/models/RegistrationStep0\";\nimport { useJourneyConfigurationStore } from \"~/stores/journeyConfigurationStore\";\nimport { QueryStringHelper } from \"~/helpers/QueryStringHelper\";\n\nconst timerService = new TimerService();\n\nexport class RegistrationService {\n public static async register(registration: Registration): Promise {\n const step0Store = useStep0Store();\n const registrationStore = useRegistrationStore();\n try {\n const response = await fetch(\"/api/onboarding-ui/v1/registration/register\", {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\"\n },\n body: JSON.stringify(registration)\n });\n const currentParams = QueryStringHelper.GetAllQueryStringParameters();\n\n if (response.ok) {\n timerService.resetTimer();\n const successResult = await response.json();\n registrationStore.verificationEmail = registration.email;\n registrationStore.initial = registration.firstName[0] + registration.lastName[0];\n if (successResult.HasBeenActivated) {\n if (successResult.IsInvitation && successResult.JourneyId > 0) {\n const journeyConfigurationStore = useJourneyConfigurationStore();\n await journeyConfigurationStore.fetchData(successResult.JourneyId);\n\n }\n\n window.location.href = successResult.ReturnUrl;\n }\n else {\n if (currentParams == '') {\n await navigateTo(\"/register/code-validation\");\n }\n else {\n await navigateTo(\"/register/code-validation?\" + currentParams);\n }\n }\n\n } else {\n\n const errorResult = await response.json();\n const errorCode = errorResult.Code;\n const errorMessage = ErrorMessages.getMessage(errorCode);\n\n if (errorCode === ErrorCode.UserSuspended || errorCode === ErrorCode.AlreadyExistingAccount || errorCode === ErrorCode.UserNotLinkedToTenant) {\n step0Store.emailAddress = registration.email;\n if (currentParams == '') {\n await navigateTo(\"/people/login\");\n }\n else {\n await navigateTo(\"/people/login?\" + currentParams);\n }\n const errorMessage =\n ErrorMessages.getMessage(ErrorCode.AlreadyExistingAccount);\n createSnackbarNotification({\n message: errorMessage,\n type: \"error\",\n showCloseIcon: true\n });\n }\n else if (errorCode == ErrorCode.AccountInactiveOrNotVerified) {\n registrationStore.verificationEmail = registration.email;\n if (currentParams == '') {\n await navigateTo(\"/register/code-validation\");\n }\n else {\n await navigateTo(\"/register/code-validation?\" + currentParams);\n }\n }\n else {\n createSnackbarNotification({\n message: errorMessage,\n type: \"error\",\n autoDismiss: true,\n showCloseIcon: true\n });\n const error = new Error(errorMessage);\n newrelic.noticeError(error);\n }\n }\n } catch (e) {\n console.error(\"Error posting registration: \" + e);\n throw e;\n }\n }\n\n public static async getPositions(): Promise {\n try {\n const response = await fetch(\"/api/onboarding-ui/v1/registration/positions\", {\n method: \"GET\",\n headers: {\n \"Content-Type\": \"application/json\"\n }\n });\n\n if (!response.ok) {\n throw new Error(`HTTP error! Status: ${response.status}`);\n }\n\n const responseData: PositionResponse = await response.json();\n return responseData;\n } catch (error) {\n console.error(\"Error fetching positions: \" + error);\n throw error;\n }\n }\n\n public static async registerStep0(registrationStep0: RegistrationStep0): Promise {\n try {\n const response = await fetch(\"/api/onboarding-ui/v1/registration/register/step0\", {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\"\n },\n body: JSON.stringify(registrationStep0)\n });\n\n const currentParams = QueryStringHelper.GetAllQueryStringParameters();\n\n if (response.ok) {\n if (currentParams == '') {\n await navigateTo(\"/register/step-1\");\n }\n else {\n await navigateTo(\"/register/step-1?\" + currentParams);\n }\n } else {\n\n const errorResult = await response.json();\n const errorCode = errorResult.Code;\n const errorMessage = ErrorMessages.getMessage(errorCode);\n\n if (errorCode === ErrorCode.UserSuspended || errorCode === ErrorCode.AlreadyExistingAccount || errorCode === ErrorCode.UserNotLinkedToTenant) {\n if (currentParams == '') {\n await navigateTo(\"/people/login\");\n }\n else {\n await navigateTo(\"/people/login?\" + currentParams);\n }\n const errorMessage =\n ErrorMessages.getMessage(ErrorCode.AlreadyExistingAccount);\n createSnackbarNotification({\n message: errorMessage,\n type: \"error\",\n showCloseIcon: true\n });\n }\n else {\n createSnackbarNotification({\n message: errorMessage,\n type: \"error\",\n autoDismiss: true,\n showCloseIcon: true\n });\n const error = new Error(errorMessage);\n newrelic.noticeError(error);\n }\n\n }\n } catch (e) {\n console.error(\"Error posting registration step 0: \" + e);\n throw e;\n }\n }\n\n public static async getInvitationData(requestAuthToken: string): Promise {\n try {\n\n if (requestAuthToken == null || requestAuthToken.length == 0) {\n const journeyConfigurationStore = useJourneyConfigurationStore();\n await journeyConfigurationStore.fetchData(null);\n\n return null;\n }\n\n const response = await fetch(\"/api/onboarding-ui/v1/invitation/invitation-info?RequestAuthToken=\" + requestAuthToken, {\n method: \"GET\",\n headers: {\n \"Content-Type\": \"application/json\"\n }\n });\n\n if (!response.ok) {\n throw new Error(`HTTP error! Status: ${response.status}`);\n }\n\n const responseData: GetInvitationDataResponse = await response.json();\n\n const journeyConfigurationStore = useJourneyConfigurationStore();\n await journeyConfigurationStore.fetchData(responseData.journeyId);\n\n return responseData;\n } catch (error) {\n console.error(\"Error fetching invitation data: \" + error);\n throw error;\n }\n }\n\n public static async getRegistrationData(): Promise {\n try {\n const response = await fetch(\"/api/onboarding-ui/v1/registration/data\");\n if (!response.ok) {\n throw new Error(`HTTP error! Status: ${response.status}`);\n }\n const responseData: GetRegistrationDataResponse = await response.json();\n return responseData;\n } catch (e) {\n console.error(\"Error fetching user registration data: \" + e);\n throw e;\n }\n }\n}","import type { Registration } from \"@/models/Registration\";\nimport { RegistrationService } from \"@/services/RegistrationService\";\nimport { defineStore } from \"pinia\";\n\ninterface RegistrationState {\n isLoading: boolean;\n verificationEmail: string | null;\n initial: string | undefined;\n}\n\nexport const useRegistrationStore = defineStore(\"register\", {\n state: (): RegistrationState => {\n return {\n isLoading: false,\n verificationEmail: null,\n initial: undefined\n };\n },\n\n persist: {\n storage: persistedState.localStorage,\n },\n\n getters: {},\n\n actions: {\n async postData(registration: Registration): Promise {\n try {\n this.isLoading = true;\n await RegistrationService.register(registration);\n } catch (error) {\n this.isLoading = false;\n console.error(error);\n throw error;\n } finally {\n this.isLoading = false;\n }\n },\n async resetData(): Promise {\n try {\n this.isLoading = true;\n const data = await RegistrationService.getRegistrationData();\n this.verificationEmail = data.emailAddress;\n } catch (error) {\n this.isLoading = false;\n console.error(error);\n throw error;\n } finally {\n this.isLoading = false;\n }\n },\n\n },\n});\n\n"],"names":["CLEAR_STORAGE_DELAY","useStep0Store","defineStore","persistedState","registrationStep0","RegistrationService","error","timerService","TimerService","registration","step0Store","registrationStore","useRegistrationStore","response","currentParams","QueryStringHelper","successResult","useJourneyConfigurationStore","navigateTo","errorCode","errorMessage","ErrorMessages","ErrorCode","createSnackbarNotification","e","requestAuthToken","journeyConfigurationStore","responseData","data"],"mappings":"kNAIA,MAAMA,EAAsB,IAEfC,EAAgBC,EAAY,QAAS,CAC9C,MAAO,KACI,CACH,UAAW,GACX,aAAc,EAAA,GAGtB,QAAS,CACL,QAASC,EAAe,YAC5B,EACA,QAAS,CACL,MAAM,SAASC,EAAqD,CAC5D,GAAA,CACA,KAAK,UAAY,GACX,MAAAC,EAAoB,cAAcD,CAAiB,EACzD,KAAK,aAAeA,EAAkB,aACtC,KAAK,qBAAqB,QACrBE,EAAO,CACZ,WAAK,UAAY,GACjB,QAAQ,MAAMA,CAAK,EACbA,CAAA,QACR,CACE,KAAK,UAAY,EACrB,CACJ,EACA,sBAAuB,CACnB,WAAW,IAAM,CACb,aAAa,WAAW,OAAO,EAC/B,KAAK,aAAe,IACrBN,CAAmB,CAC1B,CACJ,CACJ,CAAC,ECxBKO,EAAe,IAAIC,EAElB,MAAMH,CAAoB,CAC7B,aAAoB,SAASI,EAA2C,CACpE,MAAMC,EAAaT,IACbU,EAAoBC,IACtB,GAAA,CACM,MAAAC,EAAW,MAAM,MAAM,8CAA+C,CACxE,OAAQ,OACR,QAAS,CACL,eAAgB,kBACpB,EACA,KAAM,KAAK,UAAUJ,CAAY,CAAA,CACpC,EACKK,EAAgBC,EAAkB,8BAExC,GAAIF,EAAS,GAAI,CACbN,EAAa,WAAW,EAClB,MAAAS,EAAgB,MAAMH,EAAS,OACrCF,EAAkB,kBAAoBF,EAAa,MACnDE,EAAkB,QAAUF,EAAa,UAAU,CAAC,EAAIA,EAAa,SAAS,CAAC,EAC3EO,EAAc,kBACVA,EAAc,cAAgBA,EAAc,UAAY,GAElD,MAD4BC,IACF,UAAUD,EAAc,SAAS,EAI9D,OAAA,SAAS,KAAOA,EAAc,WAGjCF,GAAiB,GACjB,MAAMI,EAAW,2BAA2B,EAGtC,MAAAA,EAAW,6BAA+BJ,CAAa,CAErE,KAEG,CAGH,MAAMK,GADc,MAAMN,EAAS,QACL,K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