import React from 'react'; import { Field, Form, Formik, FormikHelpers } from 'formik'; import { object, string } from 'yup'; import FormikFieldWrapper from '@/components/elements/FormikFieldWrapper'; import SpinnerOverlay from '@/components/elements/SpinnerOverlay'; import tw from 'twin.macro'; import Button from '@/components/elements/Button'; import Input, { Textarea } from '@/components/elements/Input'; import styled from 'styled-components/macro'; import { useFlashKey } from '@/plugins/useFlash'; import { createSSHKey, useSSHKeys } from '@/api/account/ssh-keys'; interface Values { name: string; publicKey: string; } const CustomTextarea = styled(Textarea)` ${tw`h-32`} `; export default () => { const { clearAndAddHttpError } = useFlashKey('account'); const { mutate } = useSSHKeys(); const submit = (values: Values, { setSubmitting, resetForm }: FormikHelpers) => { clearAndAddHttpError(); createSSHKey(values.name, values.publicKey) .then((key) => { resetForm(); mutate((data) => (data || []).concat(key)); }) .catch((error) => clearAndAddHttpError(error)) .then(() => setSubmitting(false)); }; return ( <> {({ isSubmitting }) => (
)}
); };