diff --git a/src/personalAccessTokens/PersonalAccessTokens.component.js b/src/personalAccessTokens/PersonalAccessTokens.component.js index 39753368..5cba7253 100644 --- a/src/personalAccessTokens/PersonalAccessTokens.component.js +++ b/src/personalAccessTokens/PersonalAccessTokens.component.js @@ -2,6 +2,7 @@ import { useDataQuery } from '@dhis2/app-runtime' import { Card, Button } from '@dhis2/ui' import React, { useState } from 'react' import i18n from '../locales/index.js' +import userProfileStore from '../profile/profile.store.js' import GenerateTokenModal from './generateTokenModal/GenerateTokenModal.component.js' import styles from './PersonalAccessTokens.module.css' import TokensList from './TokensList.component.js' @@ -10,16 +11,20 @@ import { useModal } from './use-modal.js' const query = { tokens: { resource: 'apiToken', - params: { + params: ({ userId }) => ({ fields: ['id', 'created', 'expire', 'attributes'], paging: false, - }, + filter: `createdBy.id:eq:${userId}`, + }), }, } const PersonalAccessTokens = () => { + const userId = userProfileStore.state.id const [tokenKeys, setTokenKeys] = useState(new Map()) - const { loading, error, data, refetch } = useDataQuery(query) + const { loading, error, data, refetch } = useDataQuery(query, { + variables: { userId }, + }) const generateTokenModal = useModal() const tokens = data?.tokens.apiToken