Skip to content

Commit de160ee

Browse files
Amir SohelAmir Sohel
authored andcommitted
error handling
1 parent 4205938 commit de160ee

File tree

3 files changed

+16
-13
lines changed

3 files changed

+16
-13
lines changed

src/App.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ $buttonPrimary: #54A3FF;
8787

8888
header {
8989
background: $blueheader;
90+
z-index: 99;
91+
position: sticky;
92+
top: 0;
93+
border-bottom: solid 1px #9b9ea01c;
9094
}
9195

9296
button {

src/Components/Extras/Loader.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ import React from "react"
22
export default{
33
text_loading: <i className="fa fa-spinner fa-pulse"></i>,
44
section_loading: <div className="p-5"> <i className="fa fa-spinner fa-pulse"></i> Loading...</div>,
5-
search_icon:<i class="fa fa-search" aria-hidden="true"></i>
5+
search_icon:<i class="fa fa-search" aria-hidden="true"></i>,
6+
user_not_found : <p className="text-center mt-4 text-muted">User not found on Github !</p>
67
}

src/Components/Views/Home.js

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,12 @@ class Home extends React.Component {
5050

5151
// API CALL TO GET BASIC USER INFO
5252
DataProvider.getUserInfo(this.state.username).then((userData) => {
53-
this.setState({
54-
basicInfo: userData,
55-
user_id: userData.data.user.id,
56-
basicLoaded: true,
57-
})
53+
if (userData.errors) return;
54+
this.setState({
55+
basicInfo: userData,
56+
user_id: userData.data.user.id,
57+
basicLoaded: true,
58+
});
5859

5960
// API CALL TO GET ALL REPO INFO // NESTED BECAUSE USER_ID HAS DEPENDENCY ON FIRST API CALL (getUserInfo)
6061
DataProvider.getRepositoryInfo(this.state.username, this.state.user_id).then((repoData) => {
@@ -101,23 +102,21 @@ class Home extends React.Component {
101102
})
102103
})
103104
})
104-
105-
106105
})
107106
})
108-
109107
// API CALL TO GET PINNED REPOS
110108
DataProvider.getPinnedRepo(this.state.username).then((pinnedData) => {
111109
this.setState({ pinnedInfo: pinnedData, pinnedLoaded: true })
112110
}
113111
)
114-
115-
116112
}
117113

118114
render() {
119115
return (
116+
117+
120118
<div>
119+
{this.state.basicLoaded && this.state.basicInfo ?
121120
<Layout>
122121
{/* CONDITIONAL REDERING OF BASIC INFO */}
123122
{this.state.basicLoaded ? <BasicInformation basicInfo={this.state.basicInfo} aggregateData={this.state.aggregateData} /> : Loader.section_loading}
@@ -191,8 +190,7 @@ class Home extends React.Component {
191190
</div>
192191
</div>
193192
</section>
194-
195-
</Layout>
193+
</Layout> : Loader.user_not_found}
196194
</div>
197195
);
198196
}

0 commit comments

Comments
 (0)