feat: Tick all levels that the user has completed
This commit is contained in:
parent
d6f5ef4cc5
commit
26407b6cb7
@ -30,6 +30,9 @@ userRouter.get("/me", async (req: LRequest, res) => {
|
|||||||
delete copy._id;
|
delete copy._id;
|
||||||
delete copy.hash;
|
delete copy.hash;
|
||||||
delete copy.salt;
|
delete copy.salt;
|
||||||
|
delete copy.lastReview;
|
||||||
|
delete copy.lastLevel;
|
||||||
|
delete copy.vocabMetadata;
|
||||||
|
|
||||||
res.send({
|
res.send({
|
||||||
error: "0",
|
error: "0",
|
||||||
|
@ -27,15 +27,19 @@ export async function performLogin(username: string, password: string, db: Db):
|
|||||||
token: sessionToken,
|
token: sessionToken,
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
// Return the user, but remove all undeeded data
|
||||||
username: user.username,
|
let copy = Object.assign({}, user, {
|
||||||
uid: user.uid,
|
|
||||||
showWelcome: user.showWelcome,
|
|
||||||
score: user.score,
|
|
||||||
classId: user.classId,
|
|
||||||
|
|
||||||
sessionToken,
|
sessionToken,
|
||||||
};
|
});
|
||||||
|
delete copy._id;
|
||||||
|
delete copy.hash;
|
||||||
|
delete copy.salt;
|
||||||
|
delete copy.lastReview;
|
||||||
|
delete copy.lastLevel;
|
||||||
|
delete copy.vocabMetadata;
|
||||||
|
|
||||||
|
|
||||||
|
return copy;
|
||||||
} else {
|
} else {
|
||||||
// It does not matter what we throw
|
// It does not matter what we throw
|
||||||
throw new Error("LOL");
|
throw new Error("LOL");
|
||||||
|
@ -10,6 +10,7 @@ const mapStateToProps = state => {
|
|||||||
return {
|
return {
|
||||||
levels: state.levels,
|
levels: state.levels,
|
||||||
loading: state.levelList.loading,
|
loading: state.levelList.loading,
|
||||||
|
user: state.user,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
const mapDispatchToProps = dispatch => {
|
const mapDispatchToProps = dispatch => {
|
||||||
|
@ -5,6 +5,9 @@ export interface IUser {
|
|||||||
score: number;
|
score: number;
|
||||||
classId: string;
|
classId: string;
|
||||||
|
|
||||||
|
// Levels that the user has completed
|
||||||
|
levels: number[];
|
||||||
|
|
||||||
sessionToken: string;
|
sessionToken: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -12,10 +12,12 @@ import CircularProgress from "@material-ui/core/CircularProgress";
|
|||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
|
|
||||||
import { ILevel } from "../models/level";
|
import { ILevel } from "../models/level";
|
||||||
|
import { IUser } from "../models/user";
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
getLevels: () => Promise<ILevel[]>;
|
getLevels: () => Promise<ILevel[]>;
|
||||||
|
|
||||||
|
user: IUser;
|
||||||
setLevels: (levels: ILevel[]) => void;
|
setLevels: (levels: ILevel[]) => void;
|
||||||
setLoading: (state: boolean) => void;
|
setLoading: (state: boolean) => void;
|
||||||
loading: boolean;
|
loading: boolean;
|
||||||
@ -59,12 +61,13 @@ export default class Dashboard extends React.Component<IProps> {
|
|||||||
|
|
||||||
let key = 0;
|
let key = 0;
|
||||||
const levelToCard = (level: ILevel) => {
|
const levelToCard = (level: ILevel) => {
|
||||||
|
const suffix = level.level in this.props.user.levels ? " ✔" : "";
|
||||||
return <Grid item key={key++}>
|
return <Grid item key={key++}>
|
||||||
<Card style={{
|
<Card style={{
|
||||||
width: small ? window.width - 32 : "300px"
|
width: small ? window.width - 32 : "300px"
|
||||||
}}>
|
}}>
|
||||||
<CardContent className={cName}>
|
<CardContent className={cName}>
|
||||||
<Typography variant="title">{`Level ${level.level}`}</Typography>
|
<Typography variant="title">{`Level ${level.level}${suffix}`}</Typography>
|
||||||
<Typography variant="title" component="p">{level.name}</Typography>
|
<Typography variant="title" component="p">{level.name}</Typography>
|
||||||
<br />
|
<br />
|
||||||
<Typography component="p">
|
<Typography component="p">
|
||||||
|
Reference in New Issue
Block a user