Skip to content

Commit

Permalink
fix: filter user github organization
Browse files Browse the repository at this point in the history
  • Loading branch information
tsirysndr committed Aug 30, 2024
1 parent 2b864e2 commit c36649b
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
useGetOrganizationsLazyQuery,
} from "../../../Hooks/GraphQL";
import { useNavigate } from "react-router-dom";
import { useUser } from "@clerk/clerk-react";

const chakraTheme = extendTheme({
config: {
Expand All @@ -24,6 +25,7 @@ const chakraTheme = extendTheme({

const MainContentWithData: FC = () => {
const navigate = useNavigate();
const { user } = useUser();
const [createProject] = useCreateProjectMutation();
const [getOrganizations] = useGetOrganizationsLazyQuery({
variables: {
Expand All @@ -35,7 +37,11 @@ const MainContentWithData: FC = () => {
const onNewProject = async (example?: { id: string; repoUrl: string }) => {
if (window.location.href.includes("app.fluentci.io")) {
const response = await getOrganizations();
if ((response.data?.organizations || []).length === 0) {
if (
(response.data?.organizations || []).filter(
(x) => x.name === user?.username
).length === 0
) {
await createProject();
localStorage.setItem("redirected_from_new_project", "1");
window.location.href =
Expand Down

0 comments on commit c36649b

Please sign in to comment.