1 |
- {"version":3,"file":"static/chunks/82526.8459b3184d233bd9.js","mappings":"qQAYMA,EAAeC,KAAQ,W,OAAM,mCAAiD,C,wDAmDpF,UA7CiC,Y,IAAGC,EAAe,EAAfA,gBAC5B,GAAaC,EAAAA,EAAAA,MAAXC,OACF,GAAQC,EAAAA,EAAAA,GAAe,UAArBC,EACFC,GAAQC,EAAAA,EAAAA,YACoBC,GAAAA,EAAAA,EAAAA,WAAS,GAApCC,EAA2BD,EAAe,GAA/BE,EAAgBF,EAAe,GAE3CG,EAAc,W,OAAA,iBAAOC,EAA0BC,G,iDACnDH,GAAa,IACbI,EAAAA,EAAAA,IAAkB,CAChBF,YAAAA,EACAC,UAAAA,IAECE,MAAK,WACJZ,GACEa,EAAAA,EAAAA,OACA,SAACC,GACC,OAAO,kBACFA,GAAkB,CACrBC,UAAU,kBAAKD,EAAmBC,WAAU,UAACN,EAAcC,QAG/D,CACEM,YAAY,OAIjBC,OAAM,WACLd,EAAMD,EAAE,wBAAyB,CAC/BgB,OAAQC,EAAAA,YAAAA,WAGXC,SAAQ,WACPb,GAAa,M,0BA1BQE,EAA0BC,G,gCAAjC,GA8BpB,OACE,SAACd,EAAY,CACXU,UAAWA,EACXG,YAAaX,EAAgB,GAC7BU,YAAaA","sources":["webpack://_N_E/./src/components/Auth/Consents/ConsentModalBodyResolver.tsx"],"sourcesContent":["import { useState } from 'react';\n\nimport dynamic from 'next/dynamic';\nimport useTranslation from 'next-translate/useTranslation';\nimport { useSWRConfig } from 'swr';\n\nimport { ToastStatus, useToast } from '@/dls/Toast/Toast';\nimport ConsentType from '@/types/auth/ConsentType';\nimport { updateUserConsent } from '@/utils/auth/api';\nimport { makeUserProfileUrl } from '@/utils/auth/apiPaths';\nimport UserProfile from 'types/auth/UserProfile';\n\nconst ConsentModal = dynamic(() => import('@/components/Auth/Consents/ConsentModal'));\n\ntype Props = {\n missingConsents: ConsentType[];\n};\n\nconst ConsentModalBodyResolver = ({ missingConsents }: Props) => {\n const { mutate } = useSWRConfig();\n const { t } = useTranslation('common');\n const toast = useToast();\n const [isLoading, setIsLoading] = useState(false);\n\n const onCompleted = async (consentType: ConsentType, consented: boolean) => {\n setIsLoading(true);\n updateUserConsent({\n consentType,\n consented,\n })\n .then(() => {\n mutate(\n makeUserProfileUrl(),\n (currentProfileData: UserProfile) => {\n return {\n ...currentProfileData,\n consents: { ...currentProfileData.consents, [consentType]: consented },\n };\n },\n {\n revalidate: false,\n },\n );\n })\n .catch(() => {\n toast(t('common:error.general'), {\n status: ToastStatus.Error,\n });\n })\n .finally(() => {\n setIsLoading(false);\n });\n };\n\n return (\n <ConsentModal\n isLoading={isLoading}\n consentType={missingConsents[0]}\n onCompleted={onCompleted}\n />\n );\n};\n\nexport default ConsentModalBodyResolver;\n"],"names":["ConsentModal","dynamic","missingConsents","useSWRConfig","mutate","useTranslation","t","toast","useToast","useState","isLoading","setIsLoading","onCompleted","consentType","consented","updateUserConsent","then","makeUserProfileUrl","currentProfileData","consents","revalidate","catch","status","ToastStatus","finally"],"sourceRoot":""}
|