import { useMutation } from "@tanstack/react-query"; import type { AxiosError } from "axios"; import { Building2, Sparkles } from "lucide-react"; import { useState } from "react"; import { useNavigate } from "react-router-dom"; import { Badge } from "../../../components/ui/badge"; 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 { createTenant } from "../../../lib/adminApi"; import { t } from "../../../lib/i18n"; function TenantCreatePage() { const navigate = useNavigate(); const [name, setName] = useState(""); const [slug, setSlug] = useState(""); const [description, setDescription] = useState(""); const [status, setStatus] = useState("active"); const [domains, setDomains] = useState(""); const mutation = useMutation({ mutationFn: () => createTenant({ name, slug: slug || undefined, description: description || undefined, status, domains: domains .split(",") .map((d) => d.trim()) .filter((d) => d !== ""), }), onSuccess: () => { navigate("/tenants"); }, }); const errorMsg = (mutation.error as AxiosError<{ error?: string }>)?.response ?.data?.error; return (
{t( "msg.admin.tenants.create.subtitle", "글로벌 운영 기준의 신규 테넌트를 등록합니다.", )}
{t( "msg.admin.tenants.create.form.domains_help", "Users with these email domains will be automatically assigned to this tenant.", )}