Skip to content

Commit

Permalink
Fix request
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbeno committed Nov 21, 2024
1 parent 5b9a469 commit f4d1327
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
11 changes: 9 additions & 2 deletions src/_pages/ProjectDetails/ProjectEdition/EditContext.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { zodResolver } from "@hookform/resolvers/zod";
import { projectsCategoriesApiClient } from "api-client/resources/project-categories";
import { bootstrap } from "core/bootstrap";
import { uniqWith } from "lodash";
import { useRouter, useSearchParams } from "next/navigation";
import { createContext, useEffect, useMemo, useRef, useState } from "react";
Expand Down Expand Up @@ -95,6 +96,7 @@ const SESSION_KEY = "edit-project-";

export function EditProvider({ children, project }: EditContextProps) {
const { T } = useIntl();
const projectStoragePort = bootstrap.getProjectStoragePortForClient();

const validationSchema = useEditValidationSchema();
const lastAddedRepoStorage = useProjectDetailsLastAddedRepoStorage(project.slug);
Expand Down Expand Up @@ -298,6 +300,7 @@ export function EditProvider({ children, project }: EditContextProps) {
formStorage.removeValue();
showToaster(T("form.toast.success"));
clearSession();
form.reset();

// Replace the current path on the history stack if different

Expand All @@ -308,9 +311,13 @@ export function EditProvider({ children, project }: EditContextProps) {
router.push(newPathname);

queryClient.invalidateQueries({ queryKey: MeApi.tags.all });
queryClient.invalidateQueries({ queryKey: ProjectApi.tags.detail_by_slug(data.projectSlug) });
await queryClient.invalidateQueries({
queryKey: projectStoragePort.getProjectBySlug({ pathParams: { slug: data.projectSlug } }).tag,
});
} else {
queryClient.invalidateQueries({ queryKey: ProjectApi.tags.detail_by_slug(data.projectSlug) });
await queryClient.invalidateQueries({
queryKey: projectStoragePort.getProjectBySlug({ pathParams: { slug: data.projectSlug } }).tag,
});
router.push(NEXT_ROUTER.projects.details.root(project.slug));
}
},
Expand Down
6 changes: 3 additions & 3 deletions src/_pages/ProjectDetails/ProjectEdition/ProjectEdition.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"use client";

import { ProjectReactQueryAdapter } from "core/application/react-query-adapter/project";
import { useParams, useSearchParams } from "next/navigation";
import { PropsWithChildren, useContext, useEffect, useMemo, useState } from "react";
import { useFormState } from "react-hook-form";
import { useMediaQuery } from "usehooks-ts";

import ErrorFallback from "src/ErrorFallback";
import ProjectApi from "src/api/Project";
import Button, { ButtonOnBackground, ButtonSize, ButtonType } from "src/components/Button";
import Card from "src/components/Card";
import { FormStatus } from "src/components/FormStatus/FormStatus";
Expand Down Expand Up @@ -193,8 +193,8 @@ export default function ProjectEdition() {
});

const { slug = "" } = useParams<{ slug: string }>();
const { data, isLoading, isError, isRefetching } = ProjectApi.queries.useGetProjectBySlug({
params: { slug },
const { data, isLoading, isError, isRefetching } = ProjectReactQueryAdapter.client.useGetProjectBySlug({
pathParams: { slug },
options: {
retry: 1,
refetchOnWindowFocus,
Expand Down

0 comments on commit f4d1327

Please sign in to comment.