import { useRouter } from "next/navigation"; import { useState } from "react"; import { Controller, useForm } from "react-hook-form"; import z from "zod"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { useRouterQuery } from "@calcom/lib/hooks/useRouterQuery"; import { trpc } from "@calcom/trpc/react"; import { Alert, Avatar, Button, Form, ImageUploader, Label, TextAreaField } from "@calcom/ui"; import { ArrowRight, Plus } from "@calcom/ui/components/icon"; const querySchema = z.object({ id: z.string(), }); export const AboutOrganizationForm = () => { const { t } = useLocale(); const router = useRouter(); const routerQuery = useRouterQuery(); const { id: orgId } = querySchema.parse(routerQuery); const [serverErrorMessage, setServerErrorMessage] = useState(null); const [image, setImage] = useState(""); const aboutOrganizationFormMethods = useForm<{ logo: string; bio: string; }>(); const updateOrganizationMutation = trpc.viewer.organizations.update.useMutation({ onSuccess: (data) => { if (data.update) { router.push(`/settings/organizations/${orgId}/onboard-admins`); } }, onError: (err) => { setServerErrorMessage(err.message); }, }); return ( <>
{ if (!updateOrganizationMutation.isLoading) { setServerErrorMessage(null); updateOrganizationMutation.mutate({ ...v, orgId }); } }}> {serverErrorMessage && (
)}
( <>
} className="items-center" imageSrc={image} size="lg" />
{ setImage(newAvatar); aboutOrganizationFormMethods.setValue("logo", newAvatar); }} imageSrc={image} />
)} />
( <> { aboutOrganizationFormMethods.setValue("bio", e?.target.value); }} />

{t("organization_about_description")}

)} />
); };