{"version":3,"file":"setProfileSetting.a7f47c23.js","sources":["../../../../../../src/grpc/profile/setProfileSetting.ts"],"sourcesContent":["import * as grpcWeb from '@improbable-eng/grpc-web';\nimport {\n\tOnboardingStatusMap,\n\tSetUserFontendParametersReply,\n\tSetUserFontendParametersRequest\n} from '@aymeric_henry_sr/svelte-proto/profile_pb';\nimport {\n\tProfile,\n\tProfileSetUserFontendParameters\n} from '@aymeric_henry_sr/svelte-proto/profile_pb_service';\nimport { GRPC_HOST } from '../../constants/env.constants';\nimport { unaryTransport } from '../transport';\nimport { grpcError } from '$lib/utils/grpcError';\nconst { grpc } = grpcWeb;\n\nexport type ProfileSettings = {\n\thasFinishedOnboarding: OnboardingStatusMap[keyof OnboardingStatusMap];\n\thasCompletedSuspiciousActivityCheck: boolean;\n};\n\nexport function setProfileSetting(\n\tsetting: T,\n\tvalue: ProfileSettings[T]\n) {\n\treturn new Promise<{ status: grpcWeb.grpc.Code; message: SetUserFontendParametersReply }>(\n\t\t(resolve, reject) => {\n\t\t\tconst req = new SetUserFontendParametersRequest();\n\t\t\tif (setting === 'hasFinishedOnboarding') {\n\t\t\t\treq.setHasfinishedonboarding(value as ProfileSettings['hasFinishedOnboarding']);\n\t\t\t}\n\t\t\tif (setting === 'hasCompletedSuspiciousActivityCheck') {\n\t\t\t\treq.setHascompletedsuspiciousactivitycheck(\n\t\t\t\t\tvalue as ProfileSettings['hasCompletedSuspiciousActivityCheck']\n\t\t\t\t);\n\t\t\t}\n\t\t\tgrpc.unary<\n\t\t\t\tSetUserFontendParametersRequest,\n\t\t\t\tSetUserFontendParametersReply,\n\t\t\t\tProfileSetUserFontendParameters\n\t\t\t>(Profile.SetUserFontendParameters, {\n\t\t\t\trequest: req,\n\t\t\t\thost: GRPC_HOST,\n\t\t\t\ttransport: unaryTransport,\n\t\t\t\tonEnd: (res) => {\n\t\t\t\t\tconst { status, message } = res;\n\t\t\t\t\tif (status === grpc.Code.OK && message !== null) {\n\t\t\t\t\t\tresolve({\n\t\t\t\t\t\t\tstatus,\n\t\t\t\t\t\t\tmessage\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\treject(grpcError(`setProfileSetting ${setting}`, arguments, res));\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t);\n}\n"],"names":["grpc","grpcWeb","setProfileSetting","setting","value","resolve","reject","req","SetUserFontendParametersRequest","Profile","GRPC_HOST","unaryTransport","res","status","message","grpcError"],"mappings":"ohBAaA,KAAM,CAAE,KAAAA,CAAS,EAAAC,EAOD,SAAAC,EACfC,EACAC,EACC,CACD,OAAO,IAAI,QACV,CAACC,EAASC,IAAW,CACd,MAAAC,EAAM,IAAIC,EAAAA,gCACZL,IAAY,yBACfI,EAAI,yBAAyBH,CAAiD,EAE3ED,IAAY,uCACXI,EAAA,uCACHH,CAAA,EAGGJ,EAAA,MAIHS,EAAQ,yBAA0B,CACnC,QAASF,EACT,KAAMG,EACN,UAAWC,EACX,MAAQC,GAAQ,CACT,KAAA,CAAE,OAAAC,EAAQ,QAAAC,CAAY,EAAAF,EACxBC,IAAWb,EAAK,KAAK,IAAMc,IAAY,MAClCT,EAAA,CACP,OAAAQ,EACA,QAAAC,CAAA,CACA,EAEFR,EAAOS,EAAU,qBAAqBZ,CAAO,GAAI,UAAWS,CAAG,CAAC,CACjE,CAAA,CACA,CACF,CAAA,CAEF"}