// Copyright (c) 2025-2026 Probo Inc . // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. import { formatError } from "@probo/helpers"; import { Button, Card, Field, IconChevronLeft, PageHeader, useToast, } from "@probo/ui"; import type { FormEventHandler } from "react"; import { useTranslation } from "react-i18next"; import { graphql, useMutation } from "react-relay"; import { Link, useLocation, useNavigate } from "react-router"; import type { NewOrganizationPageMutation } from "#/__generated__/iam/NewOrganizationPageMutation.graphql"; import { IAMRelayProvider } from "#/providers/IAMRelayProvider"; const createOrganizationMutation = graphql` mutation NewOrganizationPageMutation($input: CreateOrganizationInput!) { createOrganization(input: $input) { organization { id name } } } `; function NewOrganizationPageInner() { const location = useLocation(); const navigate = useNavigate(); const { toast } = useToast(); const { t } = useTranslation(); const [createOrganization, isCreating] = useMutation(createOrganizationMutation); const handleSubmit: FormEventHandler = (e) => { e.preventDefault(); const formData = new FormData(e.currentTarget); const name = formData.get("name") ? (formData.get("name") as string).toString() : ""; if (!name) { toast({ title: t("common.error"), description: t("newOrganizationPage.errors.nameRequired"), variant: "error", }); return; } void createOrganization({ variables: { input: { name, }, }, onCompleted: (r, e) => { if (e) { toast({ title: t("common.error"), description: formatError(t("newOrganizationPage.errors.create"), e), variant: "error", }); return; } const org = r.createOrganization!.organization; void navigate(`/organizations/${org!.id}`); toast({ title: t("common.success"), description: t("newOrganizationPage.messages.created"), variant: "success", }); }, onError: (e) => { toast({ title: t("common.error"), description: e.message, variant: "error", }); }, }); }; return (
{t("newOrganizationPage.actions.back")}
void handleSubmit(e)} className="space-y-4">

{t("newOrganizationPage.details")}

{t("newOrganizationPage.detailsDescription")}

); } export default function NewOrganizationPage() { return ( ); }