Skip to content

Commit 59c036f

Browse files
committed
Integrate user login query
1 parent 4c3768e commit 59c036f

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/components/MaintainerDashboard/index.jsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { useLocation } from "@docusaurus/router";
22
import { useColorMode } from '@docusaurus/theme-common';
33
import { urls } from "@site/src/constants";
44
import { React, useEffect, useState } from "react";
5-
import { gql, useQuery, useApolloClient } from '@apollo/client';
5+
import { gql, useApolloClient, useLazyQuery, useQuery } from '@apollo/client';
66

77
const GET_USER = gql`
88
query {
@@ -41,19 +41,19 @@ const GET_TEAMS = gql`
4141
`;
4242

4343
export default function MaintainerDashboard() {
44-
// const {loading, error, data} = useQuery(GET_USER);
45-
// if (loading) return 'Loading...';
46-
// if (error) return `Error! ${error.message}`;
44+
const user = useQuery(GET_USER);
4745

48-
// const login = data.viewer.login;
46+
const [getTeams, teamData] = useLazyQuery(GET_TEAMS);
4947

50-
const login = "zklaus";
48+
useEffect(() => {
49+
if (user?.data?.viewer?.login) {
50+
getTeams({ variables: { login: user.data.viewer.login } });
51+
}
52+
}, [user]);
5153

52-
const {loading, error, data} = useQuery(GET_TEAMS, {variables: { login } });
53-
if (loading) return 'Loading...';
54-
if (error) return `Error! ${error.message}`;
54+
if (teamData.loading || !teamData.called) return 'Loading...';
5555

56-
const all_teams = data.organization.teams.nodes;
56+
const all_teams = teamData.data.organization.teams.nodes;
5757
const empty_teams = all_teams.filter(team => team.repositories.edges.length === 0);
5858
const overfull_teams = all_teams.filter(team => team.repositories.edges.length > 1);
5959
const regular_teams = all_teams.filter(team => (

0 commit comments

Comments
 (0)