feat: Implement the new /dashboard API
This commit is contained in:
@@ -173,6 +173,27 @@ export default class Application extends React.Component<IProps> {
|
||||
});
|
||||
}
|
||||
|
||||
// TODO: Type?
|
||||
getDashboard = (): Promise<any> => {
|
||||
return new Promise((res, rej) => {
|
||||
fetch(`${BACKEND_URL}/api/user/dashboard`, {
|
||||
headers: new Headers({
|
||||
"Content-Type": "application/json",
|
||||
"Token": this.props.user.sessionToken,
|
||||
}),
|
||||
})
|
||||
.then(resp => resp.json(), err => rej(err))
|
||||
.then(data => {
|
||||
if (data.error === "200") {
|
||||
res(data.data);
|
||||
} else {
|
||||
console.log("Application::getDashboard: Failed to get dashboard");
|
||||
rej(data);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
login = (username: string, password: string): Promise<IUser | IResponse> => {
|
||||
return new Promise((res, rej) => {
|
||||
fetch(`${BACKEND_URL}/api/login`, {
|
||||
@@ -233,9 +254,7 @@ export default class Application extends React.Component<IProps> {
|
||||
path="/dashboard"
|
||||
component={() => {
|
||||
return <Dashboard
|
||||
getNextLevel={this.getNextLevel}
|
||||
getLastReview={this.getLastReview}
|
||||
getTopTen={this.getTopTenLearners} />
|
||||
getDashboard={this.getDashboard} />
|
||||
}} />
|
||||
<AuthRoute
|
||||
isAuth={this.isAuthenticated}
|
||||
|
||||
Reference in New Issue
Block a user