Skip to content

Commit 0d04934

Browse files
committed
made difficulty work with 5 levels
1 parent b791100 commit 0d04934

1 file changed

Lines changed: 15 additions & 26 deletions

File tree

my-app/src/views/ReviewView.jsx

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import RatingComponent from "../views/Components/RatingComponent.jsx";
33

44
export function ReviewView(props) {
55
const grades = ["A", "B", "C", "D", "E", "F"];
6-
const difficulties = ["Easy", "Medium", "Hard"];
6+
const difficulties = ["Very Easy", "Easy", "Medium", "Hard", "Very Hard"];
77
const { formData, setFormData } = props;
88
const [showGradeOptions, setShowGradeOptions] = useState(false);
99
const [showRecommendOptions, setShowRecommendOptions] = useState(false);
@@ -26,14 +26,6 @@ export function ReviewView(props) {
2626
}`;
2727
};
2828

29-
// Function to map numeric difficultyRating to Easy/Medium/Hard
30-
const mapDifficultyRating = (rating) => {
31-
if (!rating || rating === 0) return "N/A";
32-
if (rating <= 2) return "Easy";
33-
if (rating === 3) return "Medium";
34-
return "Hard";
35-
};
36-
3729
useEffect(() => {
3830
function handleClickOutside(event) {
3931
if (gradeRef.current && !gradeRef.current.contains(event.target)) {
@@ -87,8 +79,6 @@ export function ReviewView(props) {
8779
/>
8880
</div>
8981

90-
91-
9282
{/* Professor Rating */}
9383
<div className="text-center">
9484
<p className="font-semibold text-gray-700 text-sm mb-1">
@@ -338,46 +328,45 @@ export function ReviewView(props) {
338328
</p>
339329
</div>
340330
<div className="grid grid-cols-2 md:grid-cols-3 gap-4 mb-2">
341-
<div>
331+
<div className="flex flex-col items-start">
342332
<p className="text-sm font-semibold text-gray-700">Overall Rating</p>
343333
{rev.overallRating > 0 ? (
344334
<RatingComponent
345-
className="flex space-x-1 text-sm"
335+
className="flex space-x-1 text-sm mt-1"
346336
value={rev.overallRating}
347337
readOnly={true}
348338
/>
349339
) : (
350-
<p className="text-sm text-gray-600">N/A</p>
340+
<p className="text-sm text-gray-600 mt-1">N/A</p>
351341
)}
352342
</div>
353-
354-
<div>
343+
<div className="flex flex-col items-start">
355344
<p className="text-sm font-semibold text-gray-700">Professor Rating</p>
356345
{rev.professorRating > 0 ? (
357346
<RatingComponent
358-
className="flex space-x-1 text-sm"
347+
className="flex space-x-1 text-sm mt-1"
359348
value={rev.professorRating}
360349
readOnly={true}
361350
/>
362351
) : (
363-
<p className="text-sm text-gray-600">N/A</p>
352+
<p className="text-sm text-gray-600 mt-1">N/A</p>
364353
)}
365354
</div>
366-
<div>
355+
<div className="flex flex-col items-start">
367356
<p className="text-sm font-semibold text-gray-700">Difficulty</p>
368-
<p className="text-sm text-gray-600">{mapDifficultyRating(rev.difficultyRating)}</p>
357+
<p className="text-sm text-gray-600 mt-1">{rev.difficultyRating || "N/A"}</p>
369358
</div>
370-
<div>
359+
<div className="flex flex-col items-start">
371360
<p className="text-sm font-semibold text-gray-700">Professor</p>
372-
<p className="text-sm text-gray-600">{rev.professorName || "N/A"}</p>
361+
<p className="text-sm text-gray-600 mt-1">{rev.professorName || "N/A"}</p>
373362
</div>
374-
<div>
363+
<div className="flex flex-col items-start">
375364
<p className="text-sm font-semibold text-gray-700">Grade</p>
376-
<p className="text-sm text-gray-600">{rev.grade || "N/A"}</p>
365+
<p className="text-sm text-gray-600 mt-1">{rev.grade || "N/A"}</p>
377366
</div>
378-
<div>
367+
<div className="flex flex-col items-start">
379368
<p className="text-sm font-semibold text-gray-700">Recommended</p>
380-
<p className="text-sm text-gray-600">
369+
<p className="text-sm text-gray-600 mt-1">
381370
{rev.recommend === true ? "Yes" : rev.recommend === false ? "No" : "N/A"}
382371
</p>
383372
</div>

0 commit comments

Comments
 (0)