Skip to content

Commit

Permalink
refactor: perform id construction on client
Browse files Browse the repository at this point in the history
  • Loading branch information
bryson-g committed Feb 19, 2025
1 parent da82b3f commit db730b8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import { useWfRun } from '@/app/hooks/useWfRun'
import { WfRunId, WfRunVariableAccessLevel } from 'littlehorse-client/proto'
import { isExternal } from 'util/types'

export const WfRun: FC<{ wfRunId: WfRunId, tenantId: string }> = ({ wfRunId, tenantId }) => {
export const WfRun: FC<{ ids: string[], tenantId: string }> = ({ ids, tenantId }) => {
const wfRunId: WfRunId = ids.reduce((wfRunId, id, i) => (i === 0 ? { id } : { id, parentWfRunId: wfRunId }), {} as WfRunId);
const searchParams = useSearchParams()
const threadRunNumber = Number(searchParams.get('threadRunNumber'))
const { wfRunData, isLoading, isError } = useWfRun({ wfRunId, tenantId })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,12 @@ import { Metadata } from 'next'
import { notFound } from 'next/navigation'
import { ClientError, Status } from 'nice-grpc-common'
import { WfRun } from './components/WfRun'
import { getWfRun } from '../../../../../actions/getWfRun'
import { WfRunId } from 'littlehorse-client/proto'

type Props = { params: { ids: string[]; tenantId: string } }

export default async function Page({ params: { ids, tenantId } }: Props) {
const wfRunId: WfRunId = ids.reduce((wfRunId, id, i) => (i === 0 ? { id } : { id, parentWfRunId: wfRunId }), {} as WfRunId);

try {
return <WfRun wfRunId={wfRunId} tenantId={tenantId} />
return <WfRun ids={ids} tenantId={tenantId} />
} catch (error) {
if (error instanceof ClientError && error.code === Status.NOT_FOUND) return notFound()
throw error
Expand Down

0 comments on commit db730b8

Please sign in to comment.