Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release v1.0.5 #130

Merged
merged 23 commits into from
Apr 2, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Full flow works
  • Loading branch information
liadaram1 committed Mar 26, 2022
commit 9a9f32eaa4117825ab4d434257dad15b5272aecc
3 changes: 1 addition & 2 deletions packages/server/src/api/students.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,6 @@ pub async fn compute_degree_status(
course_list = user_details.degree_status.set_in_progress_to_complete();
}

println!("{:#?}", course_list);

user_details
.degree_status
.compute(catalog, course::vec_to_map(vec_courses), malag_courses);
Expand Down Expand Up @@ -197,6 +195,7 @@ pub async fn update_settings(
) -> Result<HttpResponse, Error> {
let user_id = user.sub.clone();
user.settings = settings.into_inner();
user.settings.modified = false;
let document = doc! {"$set" : user.into_document()};
db::services::find_and_update_user(&user_id, document, &client).await?;
Ok(HttpResponse::Ok().finish())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
import { Button, Card, CardContent, Typography, Switch } from "@mui/material";
import {
Button,
Card,
CardContent,
Typography,
Switch,
Grid,
} from "@mui/material";
import { DegreeStatusBar } from "./DegreeStatusBar";
import { useState, useEffect, useCallback } from "react";
import { useStore } from "../../../hooks/useStore";
import { observer } from "mobx-react-lite";
import { UserSettings } from "../../../types/data-types";
import useUpdateUserSettings from "../../../hooks/apiHooks/useUpdateUserSettings";
import { useAuth } from "../../../hooks/useAuth";

const DegreeMainStatusComp: React.FC = () => {
const {
dataStore: { userDetails, userSettings },
dataStore: {
userDetails,
userSettings,
updateComputeInProgressInUserSettings,
},
} = useStore();

const { userAuthToken } = useAuth();
Expand All @@ -21,7 +31,7 @@ const DegreeMainStatusComp: React.FC = () => {

const [showMainStatus, setShowMainStatus] = useState<boolean>(false);
const [computeInProgress, setComputeInProgress] = useState<boolean>(
userSettings.compute_in_progress
userSettings ? userSettings.compute_in_progress : false
);

// TODO: loading? or loading to all the banner!
Expand All @@ -46,30 +56,35 @@ const DegreeMainStatusComp: React.FC = () => {
userDetails,
userDetails?.degree_status?.course_statuses,
userSettings,
userSettings?.compute_in_progress,
]);

const progress =
pointsDone / totalCredit >= 1 ? 100 : (pointsDone / totalCredit) * 100;

const handleChange = useCallback(
(_: React.SyntheticEvent, computeInProgress: boolean) => {
setComputeInProgress(computeInProgress);
let newUserSettings = {
...userSettings,
compute_in_progress: computeInProgress,
} as UserSettings;
mutate(newUserSettings);
},
[mutate]
);
const handleChange = (
_: React.SyntheticEvent,
computeInProgress: boolean
) => {
let newUserSettings =
updateComputeInProgressInUserSettings(computeInProgress);
mutate(newUserSettings);
};

return showMainStatus ? (
<Card sx={{ minWidth: 275, maxHeight: 150 }}>
<CardContent>
<Typography sx={{ fontSize: 18 }} color="text.secondary" gutterBottom>
<Typography
sx={{ fontSize: 18 }}
color="text.secondary"
gutterBottom
display="inline"
>
סטאטוס תואר
</Typography>
<Switch onChange={handleChange} checked={computeInProgress} />
<Typography display="inline">
<Switch onChange={handleChange} checked={computeInProgress} />
</Typography>
{/* TODO: work on design */}
<DegreeStatusBar progress={progress} />
<Typography sx={{ fontSize: 22 }} color="text.primary">
Expand Down
38 changes: 27 additions & 11 deletions packages/sogrim-app/src/components/Toasts/ModifiedToast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { useStore } from "../../hooks/useStore";

const ModifiedToastComp = () => {
const {
dataStore: { modifiedStatus },
dataStore: { modifiedStatus, modifiedSettings },
uiStore: { endGameRefetch },
} = useStore();

Expand All @@ -30,7 +30,7 @@ const ModifiedToastComp = () => {

return (
<>
{modifiedStatus ? (
{modifiedStatus || modifiedSettings ? (
<Snackbar
sx={{ mt: "-12px" }}
anchorOrigin={{ vertical: "top", horizontal: "center" }}
Expand All @@ -43,7 +43,11 @@ const ModifiedToastComp = () => {
}}
severity="info"
>
סטאטוס התואר שלך אינו מעודכן - עלייך להריץ שוב את חישוב סגירת התואר.
{modifiedStatus
? "סטאטוס התואר שלך אינו מעודכן - עלייך להריץ שוב את חישוב סגירת התואר."
: modifiedSettings
? "עדכנת את ההגדרות - עלייך להריך שוב את חישוב סגירת התואר"
: ""}
<Button
onClick={triggerComputeEndGame}
sx={{ margin: "0px 5px 0px 5px", fontWeight: "bold" }}
Expand All @@ -55,14 +59,26 @@ const ModifiedToastComp = () => {
<Tooltip
arrow
title={
<Typography>
לאחר עריכת קורסים, המידע שלכם נשמר - אך סטאטוס התואר אינו
מתעדכן.
<br />
כאשר תסיימו לערוך ולעדכן את הקורסים שלכם, לחצו על{" "}
<b>סגור את התואר</b> ואנו נפעיל את חישוב סגירת התואר בהתאם
לקטלוג שבחרתם :)
</Typography>
modifiedStatus ? (
<Typography>
לאחר עריכת קורסים, המידע שלכם נשמר - אך סטאטוס התואר אינו
מתעדכן.
<br />
כאשר תסיימו לערוך ולעדכן את הקורסים שלכם, לחצו על{" "}
<b>סגור את התואר</b> ואנו נפעיל את חישוב סגירת התואר בהתאם
לקטלוג שבחרתם :)
</Typography>
) : modifiedSettings ? (
<Typography>
ישנן הגדרות שמשפיעות על דרך החישוב, למשל "חישוב עם קורסים
בתהליך".
<br />
לכן כאשר מעדכנים את אחת ההגדרות, יש להריץ שוב את חישוב
סגירות התואר על ידי לחיצה על <b>סגור את התואר</b>{" "}
</Typography>
) : (
<Typography></Typography>
)
}
>
<Button
Expand Down
12 changes: 12 additions & 0 deletions packages/sogrim-app/src/stores/DataStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ export class DataStore {
);
}

get modifiedSettings() {
return this.userSettings?.modified;
}

getAllUserSemesters = (courseList: CourseStatus[]): string[] => {
const allSemestersSet = new Set<string>();
courseList.forEach((course) =>
Expand Down Expand Up @@ -274,4 +278,12 @@ export class DataStore {

return this.userDetails;
};

updateComputeInProgressInUserSettings = (
computeInProgress: boolean
): UserSettings => {
this.userSettings.compute_in_progress = computeInProgress;
this.userSettings.modified = true;
return this.userSettings;
};
}