@@ -3,7 +3,7 @@ import { FC, useEffect, useState } from 'react';
3
3
import SubReview from '../../component/Review/SubReview' ;
4
4
import Button from 'react-bootstrap/Button' ;
5
5
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' ;
7
7
import './UserReviews.scss' ;
8
8
import { useCookies } from 'react-cookie' ;
9
9
import { useAppDispatch } from '../../store/hooks' ;
@@ -18,7 +18,6 @@ const UserReviews: FC = () => {
18
18
//edit review states
19
19
const [ professorData ] = useState < Map < string , ProfessorGQLData > > ( new Map ( ) ) ;
20
20
const [ courseData ] = useState < Map < string , CourseGQLData > > ( new Map ( ) ) ;
21
- const [ voteColors , setVoteColors ] = useState ( [ ] ) ;
22
21
const [ courseToEdit , setCourseToEdit ] = useState < CourseGQLData > ( ) ;
23
22
const [ professorToEdit , setProfessorToEdit ] = useState < ProfessorGQLData > ( ) ;
24
23
const [ reviewToEdit , setReviewToEdit ] = useState < ReviewData > ( ) ;
@@ -34,39 +33,6 @@ const UserReviews: FC = () => {
34
33
setLoaded ( true ) ;
35
34
} ;
36
35
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
- } ;
70
36
useEffect ( ( ) => {
71
37
getUserReviews ( ) ;
72
38
} , [ ] ) ;
@@ -115,8 +81,6 @@ const UserReviews: FC = () => {
115
81
review = { review }
116
82
course = { courseData . get ( review . courseID ) }
117
83
professor = { professorData . get ( review . professorID ) }
118
- colors = { getU ( review . _id ) }
119
- colorUpdater = { updateVoteColors }
120
84
editable = { true }
121
85
editReview = { editReview }
122
86
/>
0 commit comments