diff --git a/resources/scripts/api/account/getApiKeys.ts b/resources/scripts/api/account/getApiKeys.ts index 759fc75a2..f8937ddd6 100644 --- a/resources/scripts/api/account/getApiKeys.ts +++ b/resources/scripts/api/account/getApiKeys.ts @@ -19,7 +19,7 @@ export const rawDataToApiKey = (data: any): ApiKey => ({ export default (): Promise => { return new Promise((resolve, reject) => { http.get('/api/client/account/api-keys') - .then(({ data }) => resolve((data.data || []).map(rawDataToApiKey))) + .then(({ data }) => resolve((data.data || []).map((d: any) => rawDataToApiKey(d.attributes)))) .catch(reject); }); }; diff --git a/resources/scripts/components/dashboard/AccountApiContainer.tsx b/resources/scripts/components/dashboard/AccountApiContainer.tsx index 99063fa7e..07f819518 100644 --- a/resources/scripts/components/dashboard/AccountApiContainer.tsx +++ b/resources/scripts/components/dashboard/AccountApiContainer.tsx @@ -1,15 +1,54 @@ -import React from 'react'; +import React, { useEffect, useState } from 'react'; import ContentBox from '@/components/elements/ContentBox'; import CreateApiKeyForm from '@/components/dashboard/forms/CreateApiKeyForm'; +import getApiKeys, { ApiKey } from '@/api/account/getApiKeys'; +import SpinnerOverlay from '@/components/elements/SpinnerOverlay'; +import { Simulate } from 'react-dom/test-utils'; +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; +import { faKey } from '@fortawesome/free-solid-svg-icons/faKey'; +import { faTrashAlt } from '@fortawesome/free-solid-svg-icons/faTrashAlt'; export default () => { + const [ keys, setKeys ] = useState([]); + const [ loading, setLoading ] = useState(true); + + useEffect(() => { + getApiKeys() + .then(keys => setKeys(keys)) + .then(() => setLoading(false)) + .catch(error => { + console.error(error); + }); + }, []); + return (
-

Testing

+ + { + keys.map(key => ( +
+ +

+ {key.description} +

+

+ + {key.identifier} + +

+ +
+ )) + }
);