Skip to content

Commit

Permalink
add refetch
Browse files Browse the repository at this point in the history
  • Loading branch information
maciaszczykm committed Oct 18, 2024
1 parent 4ba3ef4 commit aff4998
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@ export function EditPluralOIDCClientModal({
instanceName,
provider,
insideModal = false,
refetch,
}: {
open: boolean
onClose: () => void
instanceName: string
provider?: OidcProviderFragment
insideModal?: boolean
refetch: () => void
}) {
return (
<Modal
Expand All @@ -43,6 +45,7 @@ export function EditPluralOIDCClientModal({
<EditPluralOIDCClient
onClose={onClose}
provider={provider}
refetch={refetch}
/>
</Modal>
)
Expand All @@ -51,9 +54,11 @@ export function EditPluralOIDCClientModal({
function EditPluralOIDCClient({
onClose,
provider,
refetch,
}: {
onClose: () => void
provider?: OidcProviderFragment
refetch: () => void
}) {
const theme = useTheme()
const [name, setName] = useState(provider?.name ?? '')
Expand Down Expand Up @@ -92,7 +97,8 @@ function EditPluralOIDCClient({
const onCompleted = useCallback(() => {
// TODO: How to show client ID and client secret?
onClose()
}, [onClose])
refetch()
}, [onClose, refetch])

const [mutation, { loading, error }] = !provider
? useCreateProviderMutation({ variables: { attributes }, onCompleted })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export function EditPluralOIDCClientsModal({
type TableMetaT = {
instanceName: string
insideModal?: boolean
refetch: () => void
}

const columnHelper = createColumnHelper<OidcProviderFragment>()
Expand Down Expand Up @@ -110,7 +111,8 @@ const columns = [
meta: { gridTemplate: 'max-content' },
cell: function Cell({ row: { original: provider }, table }) {
const [editOpen, setEditOpen] = useState(false)
const { instanceName, insideModal } = table.options.meta as TableMetaT
const { instanceName, insideModal, refetch } = table.options
.meta as TableMetaT

return (
<>
Expand All @@ -125,6 +127,7 @@ const columns = [
instanceName={instanceName}
insideModal={insideModal}
provider={provider}
refetch={refetch}
/>
</>
)
Expand All @@ -141,7 +144,7 @@ export function EditPluralOIDCClients({
}) {
const theme = useTheme()
const [createOpen, setCreateOpen] = useState(false)
const { data, loading, pageInfo, setVirtualSlice, fetchNextPage } =
const { data, loading, pageInfo, setVirtualSlice, fetchNextPage, refetch } =
useFetchPaginatedData(
{ queryHook: useOidcProvidersQuery, keyPath: ['oidcProviders'] },
{}
Expand Down Expand Up @@ -183,7 +186,7 @@ export function EditPluralOIDCClients({
onVirtualSliceChange={setVirtualSlice}
reactVirtualOptions={DEFAULT_REACT_VIRTUAL_OPTIONS}
reactTableOptions={{
meta: { instanceName, insideModal } as TableMetaT,
meta: { instanceName, insideModal, refetch } as TableMetaT,
}}
style={{
border: 'none',
Expand Down

0 comments on commit aff4998

Please sign in to comment.