Skip to content

Commit

Permalink
fix attributes format
Browse files Browse the repository at this point in the history
  • Loading branch information
maciaszczykm committed Oct 18, 2024
1 parent bed3cf3 commit 46fc377
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
OidcAttributes,
OidcAuthMethod,
OidcProviderFragment,
PolicyBinding,
useCreateProviderMutation,
useUpdateProviderMutation,
} from 'generated/graphql'
Expand Down Expand Up @@ -51,6 +52,16 @@ export function EditPluralOIDCClientModal({
)
}

export const bindingsToBindingAttributes = (
bindings: Nullable<PolicyBinding>[]
) =>
bindings?.map((binding) => {
if (binding?.group?.id) return { groupId: binding.group.id }
if (binding?.user?.id) return { userId: binding.user.id }

return null
})

function EditPluralOIDCClient({
onClose,
provider,
Expand Down Expand Up @@ -91,7 +102,7 @@ function EditPluralOIDCClient({
const attributes: OidcAttributes = useMemo(
() => ({
name,
bindings,
bindings: bindingsToBindingAttributes(bindings),
redirectUris,
authMethod: OidcAuthMethod.Basic, // TODO
description,
Expand Down Expand Up @@ -160,7 +171,7 @@ function EditPluralOIDCClient({
placeholder="Search for group"
bindings={bindings
.filter(({ group }) => !!group)
.map(({ group }) => group?.name)}
.map(({ group: { name } }) => name)}
fetcher={fetchGroups}
add={(group) => setBindings([...bindings, { group }])}
remove={(name) =>
Expand Down

0 comments on commit 46fc377

Please sign in to comment.