import { useMutation, useQueryClient } from "@tanstack/react-query"; import type { AxiosError } from "axios"; import { useState } from "react"; import { useOutletContext } from "react-router-dom"; import { Button } from "../../../components/ui/button"; import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "../../../components/ui/card"; import { Input } from "../../../components/ui/input"; import { Label } from "../../../components/ui/label"; import { Textarea } from "../../../components/ui/textarea"; import { type TenantGroupSummary, updateTenantGroup, } from "../../../lib/adminApi"; function TenantGroupProfileTab() { const { group, refetch } = useOutletContext<{ group: TenantGroupSummary; refetch: () => void; }>(); const queryClient = useQueryClient(); const [name, setName] = useState(group?.name ?? ""); const [description, setDescription] = useState(group?.description ?? ""); const mutation = useMutation({ mutationFn: () => updateTenantGroup(group.id, { name, description }), onSuccess: () => { refetch(); queryClient.invalidateQueries({ queryKey: ["tenant-groups"] }); }, }); const errorMsg = (mutation.error as AxiosError<{ error?: string }>)?.response ?.data?.error; if (!group) return null; return (
그룹 정보 수정 그룹의 기본 이름과 설명을 변경할 수 있습니다. 식별자(Slug)는 변경할 수 없습니다.
setName(e.target.value)} />