import { useState } from "react"; import NewInput from "../NewInput"; import NewButton from "../NewButton"; import useModalStore from "../../stores/useModalStore"; import { IServer } from "../../types/IServer"; import { useQueryClient } from "@tanstack/react-query"; import { useMutation } from "@tanstack/react-query"; import api from "../../utils/api"; function EditTable({ table }: { table: IServer }) { 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 символов, например «Расположен в офисе»
Сохранить изменения
Отменить