Skip to content

Commit

Permalink
PR comments addressed
Browse files Browse the repository at this point in the history
Signed-off-by: ibolton336 <[email protected]>
  • Loading branch information
ibolton336 committed Sep 20, 2023
1 parent d5569a2 commit 93753ae
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 31 deletions.
19 changes: 5 additions & 14 deletions client/src/app/pages/archetypes/archetypes-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ const Archetypes: React.FC = () => {
const [archetypeToEdit, setArchetypeToEdit] = useState<Archetype | null>(
null
);
const [reviewToEdit, setReviewToEdit] = React.useState<number | null>(null);

const [archetypeToDuplicate, setArchetypeToDuplicate] =
useState<Archetype | null>(null);
Expand Down Expand Up @@ -183,18 +182,6 @@ const Archetypes: React.FC = () => {
setArchetypeToAssess(null);
}
};
const reviewSelectedArchetype = (archetype: Archetype) => {
if (archetype.review) {
setReviewToEdit(archetype.id);
} else {
history.push(
formatPath(Paths.archetypeReview, {
archetypeId: archetype.id,
})
);
}
};

return (
<>
<PageSection variant={PageSectionVariants.light}>
Expand Down Expand Up @@ -306,7 +293,11 @@ const Archetypes: React.FC = () => {
{
title: t("actions.review"),
onClick: () =>
reviewSelectedArchetype(archetype),
history.push(
formatPath(Paths.archetypeReview, {
archetypeId: archetype.id,
})
),
},
{
title: t("actions.edit"),
Expand Down
15 changes: 2 additions & 13 deletions client/src/app/pages/review/components/review-form/review-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,9 @@ import {
} from "@app/components/HookFormPFFields";
import { OptionWithValue, SimpleSelect } from "@app/components/SimpleSelect";
import {
reviewsByItemIdQueryKey,
useCreateReviewMutation,
useUpdateReviewMutation,
} from "@app/queries/reviews";
import { useQueryClient } from "@tanstack/react-query";
import { useHistory } from "react-router-dom";
import { Paths } from "@app/Paths";
import { NotificationsContext } from "@app/components/NotificationsContext";
Expand Down Expand Up @@ -112,17 +110,8 @@ export const ReviewForm: React.FC<IReviewFormProps> = ({
console.log("Invalid form", errors);
};

const queryClient = useQueryClient();
const onHandleUpdateReviewSuccess = () => {
queryClient.invalidateQueries([
reviewsByItemIdQueryKey,
application?.review?.id,
]);
};
const createReviewMutation = useCreateReviewMutation();
const updateReviewMutation = useUpdateReviewMutation(
onHandleUpdateReviewSuccess
);
const updateReviewMutation = useUpdateReviewMutation();

const onSubmit = async (formValues: FormValues) => {
const payload: New<Review> = {
Expand Down Expand Up @@ -251,7 +240,7 @@ export const ReviewForm: React.FC<IReviewFormProps> = ({
label={t("composed.workPriority")}
fieldId="priority"
isRequired
renderInput={({ field: { value, name, onChange } }) => (
renderInput={({ field: { value, onChange } }) => (
<NumberInput
inputName="priority"
inputAriaLabel="priority"
Expand Down
5 changes: 1 addition & 4 deletions client/src/app/queries/reviews.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,7 @@ export const useDeleteReviewMutation = (
});
};

export function useGetReviewByItemId(
id?: string | number,
isArchetype?: boolean
) {
export function useGetReviewByItemId(id?: string | number) {
const {
application,
isFetching: isApplicationFetching,
Expand Down

0 comments on commit 93753ae

Please sign in to comment.