diff --git a/my-app/src/views/ReviewView.jsx b/my-app/src/views/ReviewView.jsx index 6ae5d42..b57e551 100644 --- a/my-app/src/views/ReviewView.jsx +++ b/my-app/src/views/ReviewView.jsx @@ -1,284 +1,238 @@ import React, { useState, useRef, useEffect } from "react"; - - import RatingComponent from "../views/Components/RatingComponent.jsx"; export function ReviewView(props) { - const grades = ["🅰️", "B", "C", "D", "E", "F"]; - const {formData, setFormData} = props; - const [showGradeOptions, setShowGradeOptions] = useState(false); - const [showRecommendOptions, setShowRecommendOptions] = useState(false); - const gradeRef = useRef(null); - const recommendRef = useRef(null); - - - useEffect(() => { - function handleClickOutside(event) { - if (gradeRef.current && !gradeRef.current.contains(event.target)) { - setShowGradeOptions(false); - } - if (recommendRef.current && !recommendRef.current.contains(event.target)) { - setShowRecommendOptions(false); - } - } - - document.addEventListener("mousedown", handleClickOutside); - return () => { - document.removeEventListener("mousedown", handleClickOutside); - }; - }, []); - - - return ( -
-
-
- -
- {/* Overall Rating */} -
-

Overall rating

- setFormData({ ...formData, overallRating: val })} - /> -
+ const grades = ["A", "B", "C", "D", "E", "F"]; + const { formData, setFormData } = props; + const [showGradeOptions, setShowGradeOptions] = useState(false); + const [showRecommendOptions, setShowRecommendOptions] = useState(false); + const gradeRef = useRef(null); + const recommendRef = useRef(null); + + useEffect(() => { + function handleClickOutside(event) { + if (gradeRef.current && !gradeRef.current.contains(event.target)) { + setShowGradeOptions(false); + } + if (recommendRef.current && !recommendRef.current.contains(event.target)) { + setShowRecommendOptions(false); + } + } + + document.addEventListener("mousedown", handleClickOutside); + return () => { + document.removeEventListener("mousedown", handleClickOutside); + }; + }, []); + + return ( +
+
+
+
+ {/* Overall Rating */} +
+

Overall Rating

+ setFormData({ ...formData, overallRating: val })} + /> +
+ + {/* Difficulty Rating */} +
+

Difficulty Rating

+ setFormData({ ...formData, difficultyRating: val })} + /> +
+ + {/* Professor Rating */} +
+

Professor Rating

+ setFormData({ ...formData, professorRating: val })} + /> +
+ + {/* Grade Section */} +
+
+

Grade:

+
+
setShowGradeOptions((prev) => !prev)} + > + {formData.grade || "Select"} +
+ {showGradeOptions && ( +
+ {grades.map((grade) => ( + + ))} +
+ )} +
+
+
+ + {/* Recommend Section */} +
+
+

Recommend?

+
+
setShowRecommendOptions((prev) => !prev)} + > + {formData.recommend === null ? "Select" : formData.recommend ? "Yes" : "No"} +
+ {showRecommendOptions && ( +
+ + +
+ )} +
+
+
+
- {/* Difficulty Rating */} -
-

Difficulty rating

- setFormData({ ...formData, difficultyRating: val })} - /> -
+
+ setFormData({ ...formData, professorName: e.target.value })} + /> +
- {/* Professor Rating */} -
-

Professor rating

- setFormData({ ...formData, professorRating: val })} - /> -
+
+