Skip to content
This repository has been archived by the owner on Jul 2, 2024. It is now read-only.

Commit

Permalink
Refactor query param usage ot use hook
Browse files Browse the repository at this point in the history
  • Loading branch information
khelif96 committed Oct 18, 2023
1 parent 7802237 commit 8df4f6d
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/analytics/task/useTaskAnalytics.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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 =
Expand Down Expand Up @@ -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<TaskQuery, TaskQueryVariables>(TASK, {
variables: { taskId: id, execution },
fetchPolicy: "cache-first",
Expand Down

0 comments on commit 8df4f6d

Please sign in to comment.