Skip to content

Commit e23a9bc

Browse files
committed
Fixed " Don't use Object as a type"
1 parent 810001c commit e23a9bc

File tree

1 file changed

+1
-37
lines changed

1 file changed

+1
-37
lines changed

site/src/component/UserReviews/UserReviews.tsx

+1-37
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { FC, useEffect, useState } from 'react';
33
import SubReview from '../../component/Review/SubReview';
44
import Button from 'react-bootstrap/Button';
55
import { Divider } from 'semantic-ui-react';
6-
import { CourseGQLData, ProfessorGQLData, ReviewData, VoteColorsRequest } from '../../../src/types/types';
6+
import { CourseGQLData, ProfessorGQLData, ReviewData } from '../../../src/types/types';
77
import './UserReviews.scss';
88
import { useCookies } from 'react-cookie';
99
import { useAppDispatch } from '../../store/hooks';
@@ -18,7 +18,6 @@ const UserReviews: FC = () => {
1818
//edit review states
1919
const [professorData] = useState<Map<string, ProfessorGQLData>>(new Map());
2020
const [courseData] = useState<Map<string, CourseGQLData>>(new Map());
21-
const [voteColors, setVoteColors] = useState([]);
2221
const [courseToEdit, setCourseToEdit] = useState<CourseGQLData>();
2322
const [professorToEdit, setProfessorToEdit] = useState<ProfessorGQLData>();
2423
const [reviewToEdit, setReviewToEdit] = useState<ReviewData>();
@@ -34,39 +33,6 @@ const UserReviews: FC = () => {
3433
setLoaded(true);
3534
};
3635

37-
const getColors = async (vote: VoteColorsRequest) => {
38-
const res = await axios.patch('/api/reviews/getVoteColors', vote);
39-
return res.data;
40-
};
41-
42-
const updateVoteColors = async () => {
43-
const reviewIDs = [];
44-
for (let i = 0; i < reviews.length; i++) {
45-
reviewIDs.push(reviews[i]._id);
46-
}
47-
const req = {
48-
ids: reviewIDs as string[],
49-
};
50-
const colors = await getColors(req);
51-
setVoteColors(colors);
52-
};
53-
54-
const getU = (id: string | undefined) => {
55-
const temp = voteColors as Object;
56-
const v = temp[id as keyof typeof temp] as unknown as number;
57-
if (v == 1) {
58-
return {
59-
colors: [true, false],
60-
};
61-
} else if (v == -1) {
62-
return {
63-
colors: [false, true],
64-
};
65-
}
66-
return {
67-
colors: [false, false],
68-
};
69-
};
7036
useEffect(() => {
7137
getUserReviews();
7238
}, []);
@@ -115,8 +81,6 @@ const UserReviews: FC = () => {
11581
review={review}
11682
course={courseData.get(review.courseID)}
11783
professor={professorData.get(review.professorID)}
118-
colors={getU(review._id)}
119-
colorUpdater={updateVoteColors}
12084
editable={true}
12185
editReview={editReview}
12286
/>

0 commit comments

Comments
 (0)