1+ // @flow
2+ import React , { Component , Fragment } from "react" ;
3+ import { TransitionGroup , CSSTransition } from "react-transition-group" ;
4+ import { Form , Field } from "react-final-form" ;
5+ import gql from "graphql-tag" ;
6+ import { Query , withApollo } from "react-apollo" ;
7+ import Loading from "../../components/Loading" ;
8+ import UserSidebar from "../../components/UserSidebar" ;
9+ import FollowingsWrapper from './styles' ;
10+
11+ const GET_FOLLOWINGS = gql `
12+ query($username: String!, $nextPage: String) {
13+ repositoryOwner(login: $username) {
14+ login
15+ ... on User {
16+ bio
17+ avatarUrl
18+ name
19+ email
20+ websiteUrl
21+ location
22+ company
23+ followers {
24+ totalCount
25+ }
26+ following(first: 100, after: $nextPage) {
27+ totalCount
28+ nodes {
29+ name
30+ login
31+ avatarUrl
32+ repositories {
33+ totalCount
34+ }
35+ }
36+ }
37+ }
38+ }
39+ }
40+ ` ;
41+
42+
43+ const FollowingsPage = ( props : any ) => {
44+ const {
45+ match : {
46+ params : { username }
47+ }
48+ } = props ;
49+ return (
50+ < FollowingsWrapper >
51+ < Query query = { GET_FOLLOWINGS } variables = { { username, nextPage : null } } >
52+ { ( { loading, error, data, fetchMore } ) => {
53+ if ( loading ) return < Loading /> ;
54+ if ( error ) return `Error! ${ error . message } ` ;
55+
56+ if ( data ) {
57+ const { repositoryOwner } = data ;
58+ if ( repositoryOwner ) {
59+ return (
60+ < Fragment >
61+ < UserSidebar data = { repositoryOwner } isFollowingsPage />
62+ < div id = "repositories-container" >
63+ < header id = "repositories--header" >
64+ < h3 > Followings</ h3 >
65+ </ header >
66+
67+ </ div >
68+ </ Fragment >
69+ ) ;
70+ }
71+ }
72+ return true ;
73+ } }
74+ </ Query >
75+ </ FollowingsWrapper >
76+ ) ;
77+ }
78+
79+ export default FollowingsPage ;
0 commit comments