diff --git a/src/user-federation/ldap/mappers/LdapMapperDetails.tsx b/src/user-federation/ldap/mappers/LdapMapperDetails.tsx index 269b6861b8..c29444dc11 100644 --- a/src/user-federation/ldap/mappers/LdapMapperDetails.tsx +++ b/src/user-federation/ldap/mappers/LdapMapperDetails.tsx @@ -39,11 +39,9 @@ export const LdapMapperDetails = () => { const [mapping, setMapping] = useState(); const adminClient = useAdminClient(); - const { mapperId } = useParams<{ mapperId: string }>(); + const { id, mapperId } = useParams<{ id: string; mapperId: string }>(); const history = useHistory(); - const { realm } = useRealm(); - const id = mapperId; const { t } = useTranslation("user-federation"); const helpText = useTranslation("user-federation-help").t; const { addAlert } = useAlerts(); @@ -54,13 +52,10 @@ export const LdapMapperDetails = () => { (async () => { if (mapperId !== "new") { if (mapperId) { - const fetchedMapper = await adminClient.components.findOne({ id }); + const fetchedMapper = await adminClient.components.findOne({ + id: mapperId, + }); if (fetchedMapper) { - // TODO: remove after adding all mapper types - console.log("LdapMapperDetails: id used in findOne(id) call::"); - console.log(id); - console.log("fetchedMapper is:"); - console.log(fetchedMapper); setMapping(fetchedMapper); setupForm(fetchedMapper); } @@ -87,24 +82,24 @@ export const LdapMapperDetails = () => { const map = { ...mapper, config }; try { - if (id) { - if (id === "new") { + if (mapperId) { + if (mapperId === "new") { await adminClient.components.create(map); history.push( `/${realm}/user-federation/ldap/${mapper!.parentId}/mappers` ); } else { - await adminClient.components.update({ id }, map); + await adminClient.components.update({ id: mapperId }, map); } } setupForm(map as ComponentRepresentation); addAlert( - t(id === "new" ? "createSuccess" : "saveSuccess"), + t(mapperId === "new" ? "createSuccess" : "saveSuccess"), AlertVariant.success ); } catch (error) { addAlert( - `${t(id === "new" ? "createError" : "saveError")} '${error}'`, + `${t(mapperId === "new" ? "createError" : "saveError")} '${error}'`, AlertVariant.danger ); } @@ -160,7 +155,7 @@ export const LdapMapperDetails = () => { />