mirror of
https://github.com/formbricks/formbricks.git
synced 2025-12-31 08:59:40 -06:00
fix: changing project name doesn't update in the sidebar and project selector (#6130)
Co-authored-by: Dhruwang Jariwala <67850763+Dhruwang@users.noreply.github.com> Co-authored-by: Piyush Gupta <piyushguptaa2z123@gmail.com>
This commit is contained in:
@@ -15,6 +15,7 @@ import {
|
||||
import { Input } from "@/modules/ui/components/input";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { useTranslate } from "@tolgee/react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { SubmitHandler, useForm } from "react-hook-form";
|
||||
import toast from "react-hot-toast";
|
||||
import { z } from "zod";
|
||||
@@ -31,6 +32,7 @@ type TEditProjectName = z.infer<typeof ZProjectNameInput>;
|
||||
|
||||
export const EditProjectNameForm: React.FC<EditProjectNameProps> = ({ project, isReadOnly }) => {
|
||||
const { t } = useTranslate();
|
||||
const router = useRouter();
|
||||
const form = useForm<TEditProjectName>({
|
||||
defaultValues: {
|
||||
name: project.name,
|
||||
@@ -62,6 +64,7 @@ export const EditProjectNameForm: React.FC<EditProjectNameProps> = ({ project, i
|
||||
if (updatedProjectResponse?.data) {
|
||||
toast.success(t("environments.project.general.project_name_updated_successfully"));
|
||||
form.resetField("name", { defaultValue: updatedProjectResponse.data.name });
|
||||
router.refresh();
|
||||
} else {
|
||||
const errorMessage = getFormattedErrorMessage(updatedProjectResponse);
|
||||
toast.error(errorMessage);
|
||||
|
||||
Reference in New Issue
Block a user