diff --git a/apps/web/src/app/(private)/projects/[projectId]/versions/[commitUuid]/documents/[documentUuid]/evaluations/[evaluationId]/_components/Actions/index.tsx b/apps/web/src/app/(private)/projects/[projectId]/versions/[commitUuid]/documents/[documentUuid]/evaluations/[evaluationId]/_components/Actions/index.tsx index 13ef38a46..8a00d57fa 100644 --- a/apps/web/src/app/(private)/projects/[projectId]/versions/[commitUuid]/documents/[documentUuid]/evaluations/[evaluationId]/_components/Actions/index.tsx +++ b/apps/web/src/app/(private)/projects/[projectId]/versions/[commitUuid]/documents/[documentUuid]/evaluations/[evaluationId]/_components/Actions/index.tsx @@ -1,9 +1,8 @@ 'use client' -import { useCallback, useState } from 'react' - import { EvaluationDto } from '@latitude-data/core/browser' import { TableWithHeader, useCurrentDocument } from '@latitude-data/web-ui' +import { useToggleModal } from '$/hooks/useToogleModal' import CreateBatchEvaluationModal from './CreateBatchEvaluationModal' import LiveEvaluationToggle from './LiveEvaluationToggle' @@ -20,9 +19,7 @@ export function Actions({ documentUuid: string }) { const document = useCurrentDocument() - const [open, setOpen] = useState(false) - const onClose = useCallback(() => setOpen(false), []) - const onOpen = useCallback(() => setOpen(true), []) + const { open, onClose, onOpen } = useToggleModal() return (
(undefined) + const { open, onClose, onOpen } = useToggleModal() const { data: providerLog } = useProviderLog(selectedResult?.providerLogId) const searchParams = useSearchParams() const page = searchParams.get('page') @@ -89,20 +90,9 @@ export function EvaluationResults({ - - Run the evaluation - - + + Run the evaluation + } /> )} @@ -127,6 +117,14 @@ export function EvaluationResults({
)} + ) } diff --git a/apps/web/src/hooks/useToogleModal.ts b/apps/web/src/hooks/useToogleModal.ts new file mode 100644 index 000000000..14ba703c1 --- /dev/null +++ b/apps/web/src/hooks/useToogleModal.ts @@ -0,0 +1,11 @@ +import { useCallback, useState } from 'react' + +export function useToggleModal({ + initialState = false, +}: { initialState?: boolean } = {}) { + const [open, setOpen] = useState(initialState) + const onClose = useCallback(() => setOpen(false), []) + const onOpen = useCallback(() => setOpen(true), []) + + return { open, onClose, onOpen } +}