From 70a1448d73b460730006cfed9508895f035d1cb1 Mon Sep 17 00:00:00 2001 From: Kyle Corbitt Date: Fri, 7 Jul 2023 06:34:00 -0700 Subject: [PATCH] header bar improvements --- src/components/nav/AppShell.tsx | 1 + src/pages/experiments/[id].tsx | 66 +++++++++++++++++++++++++++------ 2 files changed, 55 insertions(+), 12 deletions(-) diff --git a/src/components/nav/AppShell.tsx b/src/components/nav/AppShell.tsx index b05b49b..95bada6 100644 --- a/src/components/nav/AppShell.tsx +++ b/src/components/nav/AppShell.tsx @@ -122,6 +122,7 @@ export default function AppShell(props: { children: React.ReactNode; title?: str return ( { +const DeleteButton = () => { + const experiment = useExperiment(); const mutation = api.experiments.delete.useMutation(); const utils = api.useContext(); const router = useRouter(); - const [onClick] = useHandledAsyncCallback(async () => { - const nextExperiment = await mutation.mutateAsync({ id: props.experimentId }); + const { isOpen, onOpen, onClose } = useDisclosure(); + const cancelRef = useRef(null); + + const [onDeleteConfirm] = useHandledAsyncCallback(async () => { + if (!experiment.data?.id) return; + const nextExperiment = await mutation.mutateAsync({ id: experiment.data.id }); await utils.experiments.list.invalidate(); if (nextExperiment) { await router.push({ pathname: "/experiments/[id]", query: { id: nextExperiment } }); } - }, [mutation, props.experimentId]); + onClose(); + }, [mutation, experiment.data?.id, router]); return ( - + <> + + + + + + + Delete Experiment + + + + If you delete this experiment all the associated prompts and scenarios will be deleted + as well. Are you sure? + + + + + + + + + + ); }; @@ -94,7 +134,7 @@ export default function Experiment() { borderColor="transparent" fontSize={16} px={0} - minW={400} + minW={300} flex={1} _hover={{ borderColor: "gray.300" }} _focus={{ borderColor: "blue.500", outline: "none" }} @@ -111,10 +151,12 @@ export default function Experiment() { > Edit Vars & Evals - + - + + + );