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 && (