import { Form, FormField, FormSubmitButton, Row, TextField, Button, Text, Label, Column, Icon, Loading, } from '@umami/react-zen'; import { useConfig, useLinkQuery } from '@/components/hooks'; import { useMessages } from '@/components/hooks'; import { Refresh } from '@/components/icons'; import { getRandomChars } from '@/lib/crypto'; import { useUpdateQuery } from '@/components/hooks/queries/useUpdateQuery'; const generateId = () => getRandomChars(9); export function LinkEditForm({ linkId, teamId, onSave, onClose, }: { linkId?: string; teamId?: string; onSave?: () => void; onClose?: () => void; }) { const { formatMessage, labels } = useMessages(); const { mutate, error, isPending } = useUpdateQuery('/links', { id: linkId, teamId }); const { linkDomain } = useConfig(); const { data, isLoading } = useLinkQuery(linkId); const handleSubmit = async (data: any) => { mutate(data, { onSuccess: async () => { onSave?.(); onClose?.(); }, }); }; if (linkId && !isLoading) { return ; } return (
{({ setValue }) => { return ( <> {linkDomain || window.location.origin}/ {onClose && ( )} {formatMessage(labels.save)} ); }}
); }