import { Button, Modal, useToast, Icon, Tabs, Item } from 'react-basics'; import { useEffect, useState } from 'react'; import useApi from 'hooks/useApi'; import PasswordEditForm from 'components/pages/settings/account/PasswordEditForm'; import PageHeader from 'components/layout/PageHeader'; import AccountEditForm from 'components/pages/settings/account/AccountEditForm'; import Lock from 'assets/lock.svg'; import Page from 'components/layout/Page'; import ApiKeysList from 'components/pages/settings/account/ApiKeysList'; import useUser from 'hooks/useUser'; export default function AccountDetails() { const { user } = useUser(); const [values, setValues] = useState(null); const [tab, setTab] = useState('detail'); const [showForm, setShowForm] = useState(false); const { get, useQuery } = useApi(); const { data, isLoading } = useQuery(['account'], () => get(`/accounts/${user.id}`), { cacheTime: 0, }); const { toast, showToast } = useToast(); const handleChangePassword = () => setShowForm(true); const handleClose = () => { setShowForm(false); }; const handleSave = data => { setValues(data); showToast({ message: 'Saved successfully.', variant: 'success' }); }; const handlePasswordSave = () => { setShowForm(false); showToast({ message: 'Password successfully changed', variant: 'success' }); }; useEffect(() => { if (data) { setValues(data); } }, [data]); return ( {toast} Details API Keys {tab === 'detail' && } {tab === 'apiKey' && } {data && showForm && ( {close => } )} ); }