feat: Implement getLevelVocab

This commit is contained in:
Alexander Polynomdivision 2018-09-20 21:03:46 +02:00
parent f26ce20e13
commit d452088253
2 changed files with 17 additions and 30 deletions

View File

@ -27,6 +27,7 @@ import { IResponse } from "../models/server";
interface IProps {
authenticated: boolean;
user: IUser;
setAuthenticated: (status: boolean) => void;
setUser: (user: IUser) => void;
};
@ -162,37 +163,22 @@ export default class Application extends React.Component<IProps> {
};
}
getLevelVocab(id: number): Promise<IVocab[]> {
console.log("STUB: Application::getLevelVocab");
// TODO: Actually implement this
getLevelVocab = (id: number): Promise<IVocab[]> => {
return new Promise((res, rej) => {
setTimeout(() => {
res([{
german: ["Wein"],
hint: "Worte auf '-um' sind meistens NeutrUM",
type: VocabType.NOMEN,
latin: {
grundform: "Vinum",
genitiv: "Vini",
genus: "Neutrum"
},
id: 0
}/* , {
* latin: "Vici",
* german: "<Wortbedeutung>",
* hint: "Wird \"Viki\" und nicht \"Vichi\" ausgesprochen",
* mnemonic: "Merk dir das Wort mit Caesars berühmten Worten: \"Veni Vidi Vici\"; Er kam, sah und siegte",
* type: VocabType.NOMEN,
* id: 2
}, {
* latin: "fuga",
* german: "Flucht",
* hint: "Worte auf \"-a\" sind FeminA",
* type: VocabType.NOMEN,
* id: 3
} */]);
}, 2000);
fetch(`${BACKEND_URL}/auth/level/${id}/vocab`, {
method: "GET",
headers: new Headers({
"Content-Type": "application/json",
"Token": this.props.user.sessionToken,
}),
}).then(data => data.json())
.then((resp: IResponse) => {
if (resp.error === "0") {
res(resp.data.vocab);
} else {
rej(resp);
}
});
});
}

View File

@ -9,6 +9,7 @@ import { setAuthenticated, setUser } from "../actions";
const mapStateToProps = state => {
return {
authenticated: state.authenticated,
user: state.user,
};
};
const mapDispatchToProps = dispatch => {