feat: Implement updating the done levels
This commit is contained in:
@@ -195,6 +195,22 @@ export default class Application extends React.Component<IProps> {
|
||||
});
|
||||
}
|
||||
|
||||
introDontShowAgain = (): void => {
|
||||
// NOTE: This is not a promise, as we do not care about any response
|
||||
// being sent, since we don't need to update any client-side
|
||||
// state.
|
||||
fetch(`${BACKEND_URL}/api/user/showWelcome`, {
|
||||
headers: new Headers({
|
||||
"Content-Type": "application/json",
|
||||
"Token": this.props.user.sessionToken,
|
||||
}),
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
state: false,
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
// TODO: Type?
|
||||
getDashboard = (): Promise<any> => {
|
||||
return new Promise((res, rej) => {
|
||||
@@ -216,6 +232,16 @@ export default class Application extends React.Component<IProps> {
|
||||
});
|
||||
}
|
||||
|
||||
updateDoneLevels = (id: string): void => {
|
||||
fetch(`${BACKEND_URL}/api/user/level/${id}`, {
|
||||
headers: new Headers({
|
||||
"Content-Type": "application/json",
|
||||
"Token": this.props.user.sessionToken,
|
||||
}),
|
||||
method: "POST",
|
||||
});
|
||||
}
|
||||
|
||||
login = (username: string, password: string): Promise<IUser | IResponse> => {
|
||||
return new Promise((res, rej) => {
|
||||
fetch(`${BACKEND_URL}/api/login`, {
|
||||
@@ -282,7 +308,8 @@ export default class Application extends React.Component<IProps> {
|
||||
isAuth={this.isAuthenticated}
|
||||
path="/welcome"
|
||||
component={() => {
|
||||
return <WelcomePage />
|
||||
return <WelcomePage
|
||||
dontShowAgain={this.introDontShowAgain} />
|
||||
}} />
|
||||
<AuthRoute
|
||||
isAuth={this.isAuthenticated}
|
||||
@@ -297,7 +324,7 @@ export default class Application extends React.Component<IProps> {
|
||||
return <LevelPage
|
||||
id={match.params.id}
|
||||
levelVocab={this.getLevelVocab}
|
||||
drawerButtonState={this.drawerButtonState}
|
||||
updateDoneLevels={this.updateDoneLevels}
|
||||
setLastReview={this.setLastReview} />;
|
||||
} else {
|
||||
return <Redirect to="/login" />;
|
||||
|
||||
Reference in New Issue
Block a user