Skip to content

Commit 6464c54

Browse files
authored
Merge pull request #103 from yennanliu/assignment-dev-07-more-biz-logic-on-codeReview-page
assignment-dev-07 : Add more biz logic on codeReview page
2 parents ee17ce9 + e2ce6b6 commit 6464c54

File tree

5 files changed

+42
-7
lines changed

5 files changed

+42
-7
lines changed

springAssignmentSystem/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
- Part 27 : https://youtu.be/1s0oommR7qY?si=1g3zfpbJLFCMwM_V
5454
- Part 28 : https://youtu.be/mEdWzE4-sLg?si=hzkrmArO8zjn7PXc
5555
- Part 29 : https://youtu.be/utXVb3R1yuE?si=zbKXVhG7VMa214L4
56+
- Part 30 : https://youtu.be/iYchh7v7P1Q?si=mDFJUFlhijuH83CN
5657

5758

5859
- Spring JWT

springAssignmentSystem/backend/SpringAssignmentSystem/src/main/java/com/yen/SpringAssignmentSystem/domain/Assignment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public class Assignment {
3939

4040
//@ManyToOne(cascade = CascadeType.MERGE, fetch = FetchType.EAGER)
4141
//@Column(name="code_reviewer")
42-
@ManyToOne
42+
@ManyToOne(cascade = CascadeType.PERSIST) // https://blog.csdn.net/wsaicyj/article/details/123966389
4343
private User codeReviewer;
4444

4545
@Column(name="submitted_date")

springAssignmentSystem/doc/progress.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,9 @@
8585

8686
- 20231008
8787
- https://youtu.be/mEdWzE4-sLg?si=hzkrmArO8zjn7PXc
88-
- https://youtu.be/utXVb3R1yuE?si=zbKXVhG7VMa214L4
88+
- https://youtu.be/utXVb3R1yuE?si=zbKXVhG7VMa214L4
89+
- progress : 17:44
90+
91+
- 20231009
92+
- https://youtu.be/utXVb3R1yuE?si=zbKXVhG7VMa214L4
93+
- https://youtu.be/iYchh7v7P1Q?si=mDFJUFlhijuH83CN

springAssignmentSystem/frontend/frontend_app/src/CodeReviewerDashBoard/index.js

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,37 @@ const CodeReviewerDashboard = () => {
1515
const [getJwt, setJwt] = useLocalState("", "jwt"); // getter, setter
1616
const [assignments, setAssignment] = useState(null);
1717

18+
// https://youtu.be/utXVb3R1yuE?si=4Hv8qBS_gQ8mJVfF&t=408
19+
function claimAssignment(assignment) {
20+
//const decodedJwt = jwt_decode(getJwt);
21+
const user = {
22+
id: null,
23+
username: "my_code_reivewer",
24+
authorities: ["ROLE_CODE_REVIEWER"],
25+
};
26+
assignment.codeReviewer = user;
27+
// TODO : fix this hardcode status
28+
assignment.status = "In Review";
29+
console.log("claim assignment : " + JSON.stringify(assignment));
30+
ajax(`/api/assignments/${assignment.id}`, "PUT", getJwt, assignment).then(
31+
(updatedAssignment) => {
32+
// TODO : update view for assignment that changed
33+
// copy an array syntax [...oldArray]
34+
// https://youtu.be/utXVb3R1yuE?si=MkVbNb5R8imKjtkw&t=1947
35+
const assignmentsCopied = [...assignments];
36+
const i = assignmentsCopied.findIndex((x) => x.id === assignment.id);
37+
assignmentsCopied[i] = updatedAssignment;
38+
setAssignment(assignmentsCopied);
39+
}
40+
);
41+
}
42+
1843
useEffect(() => {
19-
ajax("/api/assignments/", "GET", getJwt).then((assignmentsData) => {
20-
setAssignment(assignmentsData);
21-
});
44+
ajax("/api/assignments/to_review", "GET", getJwt).then(
45+
(assignmentsData) => {
46+
setAssignment(assignmentsData);
47+
}
48+
);
2249
}, []);
2350

2451
function createAssignment() {
@@ -108,10 +135,11 @@ const CodeReviewerDashboard = () => {
108135
<Button
109136
variant="secondary"
110137
onClick={() => {
111-
navigate(`/assignments/${assignment.id}`);
138+
//navigate(`/assignments/${assignment.id}`);
139+
claimAssignment(assignment);
112140
}}
113141
>
114-
Edit
142+
Claim
115143
</Button>
116144
)}
117145
</Card.Body>

springAssignmentSystem/frontend/frontend_app/src/StatusBadge/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const StatusBadge = (props) => {
1111
else if (text === "Needs Update") return "danger";
1212
else if (text === "Pending Submission") return "warning";
1313
else if (text === "Resubmitted") return "primary";
14+
else if (text === "In Review") return "primary";
1415
else return "info";
1516
}
1617
return (

0 commit comments

Comments
 (0)