Redirect to experiments page after deleting experiment (#21)

This commit is contained in:
arcticfly
2023-07-07 18:01:38 -07:00
committed by GitHub
parent b2dc1ff58b
commit 0415a04dc6
2 changed files with 2 additions and 14 deletions

View File

@@ -41,12 +41,9 @@ const DeleteButton = () => {
const [onDeleteConfirm] = useHandledAsyncCallback(async () => {
if (!experiment.data?.id) return;
const nextExperiment = await mutation.mutateAsync({ id: experiment.data.id });
await mutation.mutateAsync({ id: experiment.data.id });
await utils.experiments.list.invalidate();
if (nextExperiment) {
await router.push({ pathname: "/experiments/[id]", query: { id: nextExperiment } });
}
await router.push({ pathname: "/experiments" });
onClose();
}, [mutation, experiment.data?.id, router]);

View File

@@ -110,14 +110,5 @@ export const experimentsRouter = createTRPCRouter({
id: input.id,
},
});
// Return the ID of the newest existing experiment so the client can redirect to it
const newestExperiment = await prisma.experiment.findFirst({
orderBy: {
sortIndex: "desc",
},
});
return newestExperiment?.id;
}),
});