import { useState } from "react"; import NewInput from "../NewInput"; import Button from "../Button"; import useModalStore from "../../stores/useModalStore"; import { Server } from "../../types/Server"; import { useQueryClient } from "@tanstack/react-query"; import { useMutation } from "@tanstack/react-query"; import api from "../../utils/api"; function EditTable({ table }: { table: Server }) { const [tableName, setTableName] = useState(table.name); const [tableDescription, setTableDescription] = useState(table.location); const { setModal } = useModalStore(); const queryClient = useQueryClient(); const { mutate: updateTable } = useMutation({ mutationFn: () => { return api.put(`servers/${table.id}`, { json: { name: tableName, location: tableDescription, }, }); }, onSuccess: () => { queryClient.invalidateQueries({ queryKey: ["servers"] }); setModal(null); }, }); return (
Придумайте название до 16 символов, например «Тузик»
)}Придумайте описание до 20 символов, например «Расположен в офисе»
)}