From 8df4f6d88bcdb2f40553b181e1a6ef1631fa36a8 Mon Sep 17 00:00:00 2001 From: Mohamed Khelif Date: Wed, 18 Oct 2023 14:50:21 -0400 Subject: [PATCH] Refactor query param usage ot use hook --- src/analytics/task/useTaskAnalytics.ts | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/analytics/task/useTaskAnalytics.ts b/src/analytics/task/useTaskAnalytics.ts index 7eacf4f043..81c5e80ae8 100644 --- a/src/analytics/task/useTaskAnalytics.ts +++ b/src/analytics/task/useTaskAnalytics.ts @@ -1,5 +1,5 @@ import { useQuery } from "@apollo/client"; -import { useParams, useLocation } from "react-router-dom"; +import { useParams } from "react-router-dom"; import { useAnalyticsRoot } from "analytics/useAnalyticsRoot"; import { SaveSubscriptionForUserMutationVariables, @@ -9,11 +9,9 @@ import { TestSortCategory, } from "gql/generated/types"; import { TASK } from "gql/queries"; +import { useQueryParam } from "hooks/useQueryParam"; import { CommitType } from "pages/task/actionButtons/previousCommits/types"; import { RequiredQueryParams, LogTypes } from "types/task"; -import { queryString } from "utils"; - -const { parseQueryString } = queryString; type LogViewer = "raw" | "html" | "parsley" | "lobster"; type Action = @@ -72,10 +70,8 @@ type Action = export const useTaskAnalytics = () => { const { id } = useParams<{ id: string }>(); - const location = useLocation(); - const parsed = parseQueryString(location.search); - const execution = Number(parsed[RequiredQueryParams.Execution]); + const [execution] = useQueryParam(RequiredQueryParams.Execution, 0); const { data: eventData } = useQuery(TASK, { variables: { taskId: id, execution }, fetchPolicy: "cache-first",