From 4a67afdd3a76a4a70951b06c52fed22304611650 Mon Sep 17 00:00:00 2001 From: Ridham Khandar Date: Sun, 10 Aug 2025 01:05:29 +0530 Subject: [PATCH] fix: add new created label to selected label (#136) --- .../components/DeleteLabelConfirmation.tsx | 8 +++-- apps/web/src/components/LabelForm.tsx | 6 ++-- apps/web/src/providers/modal.tsx | 15 +++++++++ .../views/board/components/NewCardForm.tsx | 31 ++++++++++++++++++- 4 files changed, 54 insertions(+), 6 deletions(-) diff --git a/apps/web/src/components/DeleteLabelConfirmation.tsx b/apps/web/src/components/DeleteLabelConfirmation.tsx index 95bfd242..29a5c288 100644 --- a/apps/web/src/components/DeleteLabelConfirmation.tsx +++ b/apps/web/src/components/DeleteLabelConfirmation.tsx @@ -12,11 +12,14 @@ export function DeleteLabelConfirmation({ labelPublicId: string; refetch: () => void; }) { - const { closeModal } = useModal(); + const { closeModal, closeModals } = useModal(); const { showPopup } = usePopup(); const deleteLabelMutation = api.label.delete.useMutation({ - onSuccess: () => refetch(), + onSuccess: () => { + refetch(); + closeModals(2); + }, onError: () => showPopup({ header: t`Error deleting label`, @@ -26,7 +29,6 @@ export function DeleteLabelConfirmation({ }); const handleDeleteLabel = () => { - closeModal(); deleteLabelMutation.mutate({ labelPublicId, }); diff --git a/apps/web/src/components/LabelForm.tsx b/apps/web/src/components/LabelForm.tsx index e2539955..780bb07f 100644 --- a/apps/web/src/components/LabelForm.tsx +++ b/apps/web/src/components/LabelForm.tsx @@ -32,7 +32,7 @@ export function LabelForm({ refetch: () => void; isEdit?: boolean; }) { - const { closeModal, entityId, openModal } = useModal(); + const { closeModal, entityId, openModal, setModalState } = useModal(); const label = api.label.byPublicId.useQuery( { @@ -57,12 +57,13 @@ export function LabelForm({ const isCreateAnotherEnabled = watch("isCreateAnotherEnabled"); const createLabel = api.label.create.useMutation({ - onSuccess: () => { + onSuccess: (newLabel) => { const currentColourIndex = colours.findIndex( (c) => c.code === watch("colour").code, ); try { refetch(); + setModalState("NEW_LABEL_CREATED", newLabel.publicId); if (!isCreateAnotherEnabled) { closeModal(); } else { @@ -220,6 +221,7 @@ export function LabelForm({
{isEdit && (