import { useEffect } from "react"; import { Controller, useForm } from "react-hook-form"; import { zodResolver } from "@hookform/resolvers/zod"; import { z } from "zod"; import { createNotification } from "@app/components/notifications"; import { ProjectPermissionCan } from "@app/components/permissions"; import { Button, FormControl, Input, TextArea } from "@app/components/v2"; import { ProjectPermissionActions, ProjectPermissionSub, useWorkspace } from "@app/context"; import { useUpdateProject } from "@app/hooks/api"; import { CopyButton } from "./CopyButton"; const formSchema = z.object({ name: z.string().min(1, "Required").max(64, "Too long, maximum length is 64 characters"), description: z .string() .trim() .max(256, "Description too long, max length is 256 characters") .optional() }); type FormData = z.infer; export const ProjectOverviewChangeSection = () => { const { currentWorkspace } = useWorkspace(); const { mutateAsync, isPending } = useUpdateProject(); const { handleSubmit, control, reset } = useForm({ resolver: zodResolver(formSchema) }); useEffect(() => { if (currentWorkspace) { reset({ name: currentWorkspace.name, description: currentWorkspace.description ?? "" }); } }, [currentWorkspace]); const onFormSubmit = async ({ name, description }: FormData) => { try { if (!currentWorkspace?.id) return; await mutateAsync({ projectID: currentWorkspace.id, newProjectName: name, newProjectDescription: description }); createNotification({ text: "Successfully updated project overview", type: "success" }); } catch (err) { console.error(err); createNotification({ text: "Failed to update project overview", type: "error" }); } }; return (

Project Overview

Copy Project Slug Copy Project ID
{(isAllowed) => ( ( )} control={control} name="name" /> )}
{(isAllowed) => ( (