Merge pull request #3290 from makeplane/develop

fix: project settings form not loading new data while switching between projects
This commit is contained in:
sriram veeraghanta 2023-12-30 21:33:40 +05:30 committed by GitHub
commit c3ba9f61d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 2 deletions

View File

@ -1,4 +1,4 @@
import { FC } from "react"; import { FC, useEffect } from "react";
import { Controller, useForm } from "react-hook-form"; import { Controller, useForm } from "react-hook-form";
// components // components
import EmojiIconPicker from "components/emoji-icon-picker"; import EmojiIconPicker from "components/emoji-icon-picker";
@ -42,6 +42,7 @@ export const ProjectDetailsForm: FC<IProjectDetailsForm> = (props) => {
control, control,
setValue, setValue,
setError, setError,
reset,
formState: { errors, isSubmitting }, formState: { errors, isSubmitting },
} = useForm<IProject>({ } = useForm<IProject>({
defaultValues: { defaultValues: {
@ -51,6 +52,15 @@ export const ProjectDetailsForm: FC<IProjectDetailsForm> = (props) => {
}, },
}); });
useEffect(() => {
if (!project) return;
reset({
...project,
emoji_and_icon: project.emoji ?? project.icon_prop,
workspace: (project.workspace as IWorkspace).id,
});
}, [project, reset]);
const handleIdentifierChange = (event: React.ChangeEvent<HTMLInputElement>) => { const handleIdentifierChange = (event: React.ChangeEvent<HTMLInputElement>) => {
const { value } = event.target; const { value } = event.target;

View File

@ -29,7 +29,7 @@ const GeneralSettingsPage: NextPageWithLayout = observer(() => {
const { workspaceSlug, projectId } = router.query; const { workspaceSlug, projectId } = router.query;
// api call to fetch project details // api call to fetch project details
useSWR( useSWR(
workspaceSlug && projectId ? "PROJECT_DETAILS" : null, workspaceSlug && projectId ? `PROJECT_DETAILS_${projectId}` : null,
workspaceSlug && projectId workspaceSlug && projectId
? () => projectStore.fetchProjectDetails(workspaceSlug.toString(), projectId.toString()) ? () => projectStore.fetchProjectDetails(workspaceSlug.toString(), projectId.toString())
: null : null