Skip to content

Commit

Permalink
fix page redirection
Browse files Browse the repository at this point in the history
  • Loading branch information
tsirysndr committed Aug 30, 2024
1 parent c36649b commit 6d34f3f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
17 changes: 12 additions & 5 deletions webui/src/Containers/LinkProject/LinkProject.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Navbar from "../../Components/Navbar";
import MainContent from "./MainContent";
import AskAI from "../../Components/AskAI";
import { useNavigate, useParams } from "react-router-dom";
import { useCreateProjectMutation } from "../../Hooks/GraphQL";

const Container = styled.div`
height: calc(100vh - 30px);
Expand All @@ -16,17 +17,23 @@ const Container = styled.div`
const LinkProject: FC = () => {
const navigate = useNavigate();
const { id } = useParams();

const [createProject] = useCreateProjectMutation();

useEffect(() => {
if (!id || !navigate) {
if (!id || !navigate || !createProject) {
return;
}
const fromNewProject = localStorage.getItem("redirected_from_new_project");
if (fromNewProject) {
const fromRepository = localStorage.getItem("redirected_from_new_project");
if (fromRepository) {
localStorage.removeItem("redirected_from_new_project");
createProject({
variables: {
fromRepository,
},
});
navigate(`/project/${id}`);
}
}, [navigate, id]);
}, [navigate, id, createProject]);

return (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@ const MainContentWithData: FC = () => {
if (
(response.data?.organizations || []).filter(
(x) => x.name === user?.username
).length === 0
).length === 0 &&
example?.repoUrl
) {
await createProject();
localStorage.setItem("redirected_from_new_project", "1");
localStorage.setItem("redirected_from_new_project", example.repoUrl);
window.location.href =
"https://github.com/apps/fluentci-io/installations/new";
return;
Expand Down

0 comments on commit 6d34f3f

Please sign in to comment.