feat: Implement all Frontend stubs
This commit is contained in:
parent
8b6bfb681b
commit
28160e329b
@ -31,6 +31,14 @@ userRouter.get("/logout", async (req, res) => {
|
||||
});
|
||||
});
|
||||
|
||||
// TODO: This should be shared with the frontend, to remove code duplication
|
||||
export enum VocabType {
|
||||
NOMEN = 0,
|
||||
VERB = 1,
|
||||
ADJEKTIV = 2,
|
||||
ADVERB = 3,
|
||||
};
|
||||
|
||||
// Gets the user's review queue
|
||||
userRouter.get("/queue", async (req, res) => {
|
||||
console.log("STUB: /user/queue");
|
||||
@ -38,7 +46,19 @@ userRouter.get("/queue", async (req, res) => {
|
||||
// TODO: Stub
|
||||
res.send({
|
||||
error: "0",
|
||||
data: {},
|
||||
data: {
|
||||
queue: [{
|
||||
german: ["Wein"],
|
||||
hint: "Worte auf '-um' sind meistens NeutrUM",
|
||||
type: VocabType.NOMEN,
|
||||
latin: {
|
||||
grundform: "Vinum",
|
||||
genitiv: "Vini",
|
||||
genus: "Neutrum"
|
||||
},
|
||||
id: 0
|
||||
}]
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -82,67 +82,36 @@ export default class Application extends React.Component<IProps> {
|
||||
}
|
||||
|
||||
setLastReview = (meta: IReviewMetadata) => {
|
||||
console.log("STUB: Application::setLastReview");
|
||||
|
||||
// TODO: Send this to the server
|
||||
/* this.setState({
|
||||
* lastReview: meta,
|
||||
* }); */
|
||||
}
|
||||
|
||||
getReviewQueue = (): Promise<IVocab[]> => {
|
||||
console.log("STUB: Application::getReviewQueue");
|
||||
|
||||
// TODO: Implement
|
||||
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}/api/user/lastReview`, {
|
||||
headers: new Headers({
|
||||
"Content-Type": "application/json",
|
||||
"Token": this.props.user.sessionToken,
|
||||
}),
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
meta,
|
||||
}),
|
||||
}).then(resp => resp.json(), err => {
|
||||
console.log("Application::setLastReview: POSTing last results failed");
|
||||
});
|
||||
}
|
||||
|
||||
getLearners(): ILearner[] {
|
||||
console.log("STUB: Application::getLearners");
|
||||
|
||||
// TODO: Implement
|
||||
return [{
|
||||
username: "Polynomdivision",
|
||||
level: 5,
|
||||
score: 400,
|
||||
}, {
|
||||
username: "Polynomdivision2",
|
||||
level: 3,
|
||||
score: 500,
|
||||
}, {
|
||||
username: "Der eine Typ",
|
||||
level: 7,
|
||||
score: 100,
|
||||
}];
|
||||
getReviewQueue = (): Promise<IVocab[]> => {
|
||||
return new Promise((res, rej) => {
|
||||
fetch(`${BACKEND_URL}/api/user/queue`, {
|
||||
headers: new Headers({
|
||||
"Content-Type": "application/json",
|
||||
"Token": this.props.user.sessionToken,
|
||||
}),
|
||||
}).then(resp => resp.json(), err => rej(err))
|
||||
.then(data => {
|
||||
if (data.error === "0") {
|
||||
res(data.data.queue);
|
||||
} else {
|
||||
rej(data);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
getTopTenLearners = (): Promise<TopTen[]> => {
|
||||
|
@ -4,10 +4,10 @@ export enum ReviewMode {
|
||||
};
|
||||
|
||||
export enum VocabType {
|
||||
NOMEN,
|
||||
VERB,
|
||||
ADJEKTIV,
|
||||
ADVERB
|
||||
NOMEN = 0,
|
||||
VERB = 1,
|
||||
ADJEKTIV = 2,
|
||||
ADVERB = 3,
|
||||
};
|
||||
|
||||
export interface INomenData {
|
||||
|
Reference in New Issue
Block a user