diff --git a/apps/app/components/issues/form.tsx b/apps/app/components/issues/form.tsx index 5faa4073b..872d6def2 100644 --- a/apps/app/components/issues/form.tsx +++ b/apps/app/components/issues/form.tsx @@ -254,6 +254,10 @@ export const IssueForm: FC = ({ handleClose={() => setLabelModal(false)} projectId={projectId} user={user} + onSuccess={(response) => { + setValue("labels", [...watch("labels"), response.id]); + setValue("labels_list", [...watch("labels_list"), response.id]); + }} /> )} diff --git a/apps/app/components/labels/create-label-modal.tsx b/apps/app/components/labels/create-label-modal.tsx index c420e45b4..7af86888d 100644 --- a/apps/app/components/labels/create-label-modal.tsx +++ b/apps/app/components/labels/create-label-modal.tsx @@ -26,6 +26,7 @@ type Props = { isOpen: boolean; projectId: string; handleClose: () => void; + onSuccess?: (response: IIssueLabels) => void; user: ICurrentUserResponse | undefined; }; @@ -34,7 +35,13 @@ const defaultValues: Partial = { color: "rgb(var(--color-text-200))", }; -export const CreateLabelModal: React.FC = ({ isOpen, projectId, handleClose, user }) => { +export const CreateLabelModal: React.FC = ({ + isOpen, + projectId, + handleClose, + user, + onSuccess, +}) => { const router = useRouter(); const { workspaceSlug } = router.query; @@ -66,6 +73,7 @@ export const CreateLabelModal: React.FC = ({ isOpen, projectId, handleClo false ); onClose(); + if (onSuccess) onSuccess(res); }) .catch((error) => { console.log(error); diff --git a/apps/app/pages/[workspaceSlug]/projects/[projectId]/pages/[pageId].tsx b/apps/app/pages/[workspaceSlug]/projects/[projectId]/pages/[pageId].tsx index 659437ce3..334799663 100644 --- a/apps/app/pages/[workspaceSlug]/projects/[projectId]/pages/[pageId].tsx +++ b/apps/app/pages/[workspaceSlug]/projects/[projectId]/pages/[pageId].tsx @@ -553,6 +553,11 @@ const SinglePage: NextPage = () => { handleClose={() => setLabelModal(false)} projectId={projectId} user={user} + onSuccess={(response) => { + partialUpdatePage({ + labels_list: [...(pageDetails.labels ?? []), response.id], + }); + }} /> )}