Skip to content

Commit

Permalink
DEVPROD-7833: Prevent 422 on downstream project page (#186)
Browse files Browse the repository at this point in the history
  • Loading branch information
SupaJoon authored Jun 18, 2024
1 parent 2948bc3 commit f2fd8f4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
1 change: 1 addition & 0 deletions apps/spruce/src/analytics/patch/usePatchAnalytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ type Action =

export const usePatchAnalytics = (id: string) => {
const { data: eventData } = useQuery<PatchQuery, PatchQueryVariables>(PATCH, {
skip: !id,
variables: { id },
fetchPolicy: "cache-first",
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ export const DownstreamProjectAccordion: React.FC<
childPatchId={childPatchId}
count={count}
dispatch={dispatch}
// @ts-expect-error: FIXME. This comment was added by an automated script.
isPatch={isPatch}
limit={limit}
loading={showSkeleton}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import TableWrapper from "components/Table/TableWrapper";
import { onChangeHandler } from "components/Table/utils";
import { getColumnsTemplate } from "components/TasksTable/Columns";
import { TaskTableInfo } from "components/TasksTable/types";
import { slugs } from "constants/routes";
import { SortDirection, TaskSortCategory } from "gql/generated/types";
import { useTaskStatuses } from "hooks";
import { Action } from "./reducer";
Expand All @@ -27,7 +28,7 @@ interface DownstreamTasksTableProps {
childPatchId: string;
count: number;
dispatch: (action: Action) => void;
isPatch: boolean;
isPatch?: boolean;
limit: number;
loading: boolean;
page: number;
Expand All @@ -46,11 +47,17 @@ export const DownstreamTasksTable: React.FC<DownstreamTasksTableProps> = ({
taskCount,
tasks,
}) => {
const { id: versionId } = useParams<{ id: string }>();
const { sendEvent } = (isPatch ? usePatchAnalytics : useVersionAnalytics)(
// @ts-expect-error: FIXME. This comment was added by an automated script.
versionId,
const { [slugs.versionId]: versionId } = useParams<{
[slugs.versionId]: string;
}>();
const { sendEvent: sendPatchEvent } = usePatchAnalytics(
isPatch === true && versionId ? versionId : "",
);
const { sendEvent: sendVersionEvent } = useVersionAnalytics(
isPatch === false && versionId ? versionId : "",
);

const sendEvent = isPatch ? sendPatchEvent : sendVersionEvent;

const { baseStatuses: baseStatusOptions, currentStatuses: statusOptions } =
useTaskStatuses({ versionId: childPatchId });
Expand Down

0 comments on commit f2fd8f4

Please sign in to comment.