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