fix: create update view modal fix (#842)

This commit is contained in:
Anmol Singh Bhatia 2023-04-17 12:24:30 +05:30 committed by GitHub
parent ac98381f23
commit 365c758a25
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 5 deletions

View File

@ -364,7 +364,7 @@ export const IssuesView: React.FC<Props> = ({
<CreateUpdateViewModal
isOpen={createViewModal !== null}
handleClose={() => setCreateViewModal(null)}
data={createViewModal}
preLoadedData={createViewModal}
/>
<CreateUpdateIssueModal
isOpen={createIssueModal && preloadedData?.actionType === "createIssue"}

View File

@ -1,6 +1,5 @@
import { useEffect } from "react";
import { useForm } from "react-hook-form";
// ui
import { Input, PrimaryButton, SecondaryButton, TextArea } from "components/ui";
@ -16,6 +15,7 @@ type Props = {
handleClose: () => void;
status: boolean;
data?: IView | null;
preLoadedData?: Partial<IView> | null;
};
const defaultValues: Partial<IView> = {
@ -23,7 +23,13 @@ const defaultValues: Partial<IView> = {
description: "",
};
export const ViewForm: React.FC<Props> = ({ handleFormSubmit, handleClose, status, data }) => {
export const ViewForm: React.FC<Props> = ({
handleFormSubmit,
handleClose,
status,
data,
preLoadedData,
}) => {
const {
register,
formState: { errors, isSubmitting },
@ -47,9 +53,10 @@ export const ViewForm: React.FC<Props> = ({ handleFormSubmit, handleClose, statu
useEffect(() => {
reset({
...defaultValues,
...preLoadedData,
...data,
});
}, [data, reset]);
}, [data, preLoadedData, reset]);
useEffect(() => {
if (status && data) {

View File

@ -21,9 +21,10 @@ type Props = {
isOpen: boolean;
handleClose: () => void;
data?: IView | null;
preLoadedData?: Partial<IView> | null ;
};
export const CreateUpdateViewModal: React.FC<Props> = ({ isOpen, handleClose, data }) => {
export const CreateUpdateViewModal: React.FC<Props> = ({ isOpen, handleClose, data, preLoadedData }) => {
const router = useRouter();
const { workspaceSlug, projectId } = router.query;
@ -133,6 +134,7 @@ export const CreateUpdateViewModal: React.FC<Props> = ({ isOpen, handleClose, da
handleClose={handleClose}
status={data ? true : false}
data={data}
preLoadedData={preLoadedData}
/>
</Dialog.Panel>
</Transition.Child>