All Downloads are FREE. Search and download functionalities are using the official Maven repository.

theme.keycloak.v2.admin.resources.assets.UserProfileContext-BkGsi2EQ.js.map Maven / Gradle / Ivy

There is a newer version: 26.0.7
Show newest version
{"version":3,"file":"UserProfileContext-BkGsi2EQ.js","sources":["../../src/realm-settings/user-profile/UserProfileContext.tsx"],"sourcesContent":["import type { UserProfileConfig } from \"@keycloak/keycloak-admin-client/lib/defs/userProfileMetadata\";\nimport { AlertVariant } from \"@patternfly/react-core\";\nimport { PropsWithChildren, useState } from \"react\";\nimport { useTranslation } from \"react-i18next\";\nimport {\n  createNamedContext,\n  useRequiredContext,\n} from \"@keycloak/keycloak-ui-shared\";\nimport { useAdminClient } from \"../../admin-client\";\nimport { useAlerts } from \"../../components/alert/Alerts\";\nimport { useRealm } from \"../../context/realm-context/RealmContext\";\nimport { useFetch } from \"../../utils/useFetch\";\n\ntype UserProfileProps = {\n  config: UserProfileConfig | null;\n  save: SaveCallback;\n  isSaving: boolean;\n};\n\nexport type SaveCallback = (\n  updatedConfig: UserProfileConfig,\n  options?: SaveOptions,\n) => Promise;\n\nexport type SaveOptions = {\n  successMessageKey?: string;\n  errorMessageKey?: string;\n};\n\nexport const UserProfileContext = createNamedContext<\n  UserProfileProps | undefined\n>(\"UserProfileContext\", undefined);\n\nexport const UserProfileProvider = ({ children }: PropsWithChildren) => {\n  const { adminClient } = useAdminClient();\n\n  const { realm } = useRealm();\n  const { addAlert, addError } = useAlerts();\n  const { t } = useTranslation();\n  const [config, setConfig] = useState(null);\n  const [refreshCount, setRefreshCount] = useState(0);\n  const [isSaving, setIsSaving] = useState(false);\n\n  useFetch(\n    () => adminClient.users.getProfile({ realm }),\n    (config) => setConfig(config),\n    [refreshCount],\n  );\n\n  const save: SaveCallback = async (updatedConfig, options) => {\n    setIsSaving(true);\n\n    try {\n      await adminClient.users.updateProfile({\n        ...updatedConfig,\n        realm,\n      });\n\n      setIsSaving(false);\n      setRefreshCount(refreshCount + 1);\n      addAlert(\n        t(options?.successMessageKey ?? \"userProfileSuccess\"),\n        AlertVariant.success,\n      );\n\n      return true;\n    } catch (error) {\n      setIsSaving(false);\n      addError(options?.errorMessageKey ?? \"userProfileError\", error);\n\n      return false;\n    }\n  };\n\n  return (\n    \n      {children}\n    \n  );\n};\n\nexport const useUserProfile = () => useRequiredContext(UserProfileContext);\n"],"names":["UserProfileContext","createNamedContext","UserProfileProvider","children","adminClient","useAdminClient","realm","useRealm","addAlert","addError","useAlerts","t","useTranslation","config","setConfig","useState","refreshCount","setRefreshCount","isSaving","setIsSaving","useFetch","save","updatedConfig","options","AlertVariant","error","jsx","useUserProfile","useRequiredContext"],"mappings":"mKA6Ba,MAAAA,EAAqBC,EAEhC,qBAAsB,MAAS,EAEpBC,EAAsB,CAAC,CAAE,SAAAC,KAAkC,CAChE,KAAA,CAAE,YAAAC,GAAgBC,IAElB,CAAE,MAAAC,GAAUC,IACZ,CAAE,SAAAC,EAAU,SAAAC,CAAS,EAAIC,EAAU,EACnC,CAAE,EAAAC,GAAMC,IACR,CAACC,EAAQC,CAAS,EAAIC,EAAmC,IAAI,EAC7D,CAACC,EAAcC,CAAe,EAAIF,EAAS,CAAC,EAC5C,CAACG,EAAUC,CAAW,EAAIJ,EAAS,EAAK,EAE9CK,EACE,IAAMhB,EAAY,MAAM,WAAW,CAAE,MAAAE,EAAO,EAC3CO,GAAWC,EAAUD,CAAM,EAC5B,CAACG,CAAY,CAAA,EAGT,MAAAK,EAAqB,MAAOC,EAAeC,IAAY,CAC3DJ,EAAY,EAAI,EAEZ,GAAA,CACI,aAAAf,EAAY,MAAM,cAAc,CACpC,GAAGkB,EACH,MAAAhB,CAAA,CACD,EAEDa,EAAY,EAAK,EACjBF,EAAgBD,EAAe,CAAC,EAChCR,EACEG,EAAEY,GAAS,mBAAqB,oBAAoB,EACpDC,EAAa,OAAA,EAGR,SACAC,EAAO,CACd,OAAAN,EAAY,EAAK,EACRV,EAAAc,GAAS,iBAAmB,mBAAoBE,CAAK,EAEvD,EACT,CAAA,EAIA,OAAAC,EAAC1B,EAAmB,SAAnB,CAA4B,MAAO,CAAE,OAAAa,EAAQ,KAAAQ,EAAM,SAAAH,GACjD,SAAAf,CACH,CAAA,CAEJ,EAEawB,EAAiB,IAAMC,EAAmB5B,CAAkB"}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy