import { useState } from 'react'
import { Link } from 'react-router-dom'
import { useAuth } from '../contexts/AuthContext'
import { useSSHKeys, useAddSSHKey, useDeleteSSHKey } from '../api/queries/sshkeys'
export default function SettingsPage() {
const { user, logout } = useAuth()
const [currentPw, setCurrentPw] = useState('')
const [newPw, setNewPw] = useState('')
return (
Settings
{/* Account info */}
{/* Change password */}
{/* Danger zone */}
Danger zone
Sign out
End your current session on this device.
)
}
function Row({ label, value }: { label: string; value?: string }) {
return (
{label}
{value}
)
}
function SSHKeySection() {
const { data: keys } = useSSHKeys()
const addKey = useAddSSHKey()
const deleteKey = useDeleteSSHKey()
const [showAdd, setShowAdd] = useState(false)
const [title, setTitle] = useState('')
const [publicKey, setPublicKey] = useState('')
const handleAdd = async (e: React.FormEvent) => {
e.preventDefault()
await addKey.mutateAsync({ title, publicKey })
setTitle(''); setPublicKey(''); setShowAdd(false)
}
return (
SSH keys
{showAdd && (
)}
{!keys?.length ? (
No SSH keys added yet.
) : (
{keys.map(key => (
-
{key.title}
{key.fingerprint}
))}
)}
)
}