From 08dbad8d53bef6c8e5fa9bcd560ef568ebf4036e Mon Sep 17 00:00:00 2001 From: KumariAnjali Date: Tue, 27 Aug 2024 18:04:35 +0530 Subject: [PATCH] professor rating page is done --- public/review.json | 126 ++++++++++++++++++++ review.json | 124 -------------------- src/app/(routes)/scrape/page.tsx | 0 src/components/Professor.tsx | 146 ++++++++++++------------ src/components/ui/card-hover-effect.tsx | 111 ++++++++++++++++++ 5 files changed, 310 insertions(+), 197 deletions(-) create mode 100644 public/review.json delete mode 100644 review.json delete mode 100644 src/app/(routes)/scrape/page.tsx create mode 100644 src/components/ui/card-hover-effect.tsx diff --git a/public/review.json b/public/review.json new file mode 100644 index 0000000..c99e802 --- /dev/null +++ b/public/review.json @@ -0,0 +1,126 @@ +{ + "reviews": [ + { + "professor": "Dr. Emily Parker", + "subject": "Molecular Biology", + "review": "Complex biological concepts made accessible and interesting.", + "star": 4 + + + }, + { + "professor": "Prof. John Smith", + "subject": "World History", + "review": "Covers a broad range of historical events, but lacks depth.", + "star": 3 + }, + { + "professor": "Dr. Maria Rodriguez", + "subject": "Quantum Physics", + "review": "Mind-bending theories explained with clarity and enthusiasm.", + "star": 5 + }, + { + "professor": "Prof. David Lee", + "subject": "Literature", + "review": "Insightful analysis of classic and contemporary works.", + "star": 4 + }, + { + "professor": "Dr. Sarah Johnson", + "subject": "Psychology", + "review": "Fascinating exploration of human behavior and cognition.", + "star": 5 + }, + { + "professor": "Prof. Michael Brown", + "subject": "Computer Science", + "review": "Programming concepts not explained clearly enough.", + "star": 2 + }, + { + "professor": "Dr. Laura White", + "subject": "Economics", + "review": "Makes macroeconomic principles relevant to everyday life.", + "star": 4 + }, + { + "professor": "Prof. Robert Green", + "subject": "Environmental Science", + "review": "Important topics covered, but lectures lack engagement.", + "star": 3 + }, + { + "professor": "Dr. Lisa Chen", + "subject": "Organic Chemistry", + "review": "Difficult subject made manageable through clear explanations.", + "star": 5 + }, + { + "professor": "Prof. James Wilson", + "subject": "Political Science", + "review": "Thought-provoking discussions on current political systems.", + "star": 4 + }, + { + "professor": "Dr. Thomas Anderson", + "subject": "Calculus", + "review": "Advanced mathematical concepts rushed through too quickly.", + "star": 2 + }, + { + "professor": "Prof. Anna Kim", + "subject": "Art History", + "review": "Brings historical artworks and their contexts to life.", + "star": 5 + }, + { + "professor": "Dr. Kevin Patel", + "subject": "Biochemistry", + "review": "Solid content but struggles to simplify complex reactions.", + "star": 3 + }, + { + "professor": "Prof. Rachel Turner", + "subject": "Sociology", + "review": "Eye-opening perspectives on social structures and interactions.", + "star": 4 + }, + { + "professor": "Dr. Daniel Martinez", + "subject": "Statistics", + "review": "Transforms dry numbers into meaningful insights.", + "star": 5 + }, + { + "professor": "Prof. Olivia Taylor", + "subject": "Marketing", + "review": "Good real-world examples, but lacks theoretical depth.", + "star": 3 + }, + { + "professor": "Dr. Christopher Lee", + "subject": "Astronomy", + "review": "Captivating journey through the cosmos and its phenomena.", + "star": 4 + }, + { + "professor": "Prof. Elizabeth Wright", + "subject": "Philosophy", + "review": "Challenges students to question fundamental assumptions.", + "star": 5 + }, + { + "professor": "Dr. Steven Harris", + "subject": "Neuroscience", + "review": "Fascinating subject matter, but poorly communicated.", + "star": 2 + }, + { + "professor": "Prof. Melissa Chang", + "subject": "International Relations", + "review": "Insightful analysis of global political dynamics.", + "star": 4 + } + ] + } \ No newline at end of file diff --git a/review.json b/review.json deleted file mode 100644 index 3162c77..0000000 --- a/review.json +++ /dev/null @@ -1,124 +0,0 @@ -{ - "reviews": [ - { - "professor": "Dr. Emily Parker", - "subject": "Molecular Biology", - "star": 4, - "review": "Complex biological concepts made accessible and interesting." - }, - { - "professor": "Prof. John Smith", - "subject": "World History", - "star": 3, - "review": "Covers a broad range of historical events, but lacks depth." - }, - { - "professor": "Dr. Maria Rodriguez", - "subject": "Quantum Physics", - "star": 5, - "review": "Mind-bending theories explained with clarity and enthusiasm." - }, - { - "professor": "Prof. David Lee", - "subject": "Literature", - "star": 4, - "review": "Insightful analysis of classic and contemporary works." - }, - { - "professor": "Dr. Sarah Johnson", - "subject": "Psychology", - "star": 5, - "review": "Fascinating exploration of human behavior and cognition." - }, - { - "professor": "Prof. Michael Brown", - "subject": "Computer Science", - "star": 2, - "review": "Programming concepts not explained clearly enough." - }, - { - "professor": "Dr. Laura White", - "subject": "Economics", - "star": 4, - "review": "Makes macroeconomic principles relevant to everyday life." - }, - { - "professor": "Prof. Robert Green", - "subject": "Environmental Science", - "star": 3, - "review": "Important topics covered, but lectures lack engagement." - }, - { - "professor": "Dr. Lisa Chen", - "subject": "Organic Chemistry", - "star": 5, - "review": "Difficult subject made manageable through clear explanations." - }, - { - "professor": "Prof. James Wilson", - "subject": "Political Science", - "star": 4, - "review": "Thought-provoking discussions on current political systems." - }, - { - "professor": "Dr. Thomas Anderson", - "subject": "Calculus", - "star": 2, - "review": "Advanced mathematical concepts rushed through too quickly." - }, - { - "professor": "Prof. Anna Kim", - "subject": "Art History", - "star": 5, - "review": "Brings historical artworks and their contexts to life." - }, - { - "professor": "Dr. Kevin Patel", - "subject": "Biochemistry", - "star": 3, - "review": "Solid content but struggles to simplify complex reactions." - }, - { - "professor": "Prof. Rachel Turner", - "subject": "Sociology", - "star": 4, - "review": "Eye-opening perspectives on social structures and interactions." - }, - { - "professor": "Dr. Daniel Martinez", - "subject": "Statistics", - "star": 5, - "review": "Transforms dry numbers into meaningful insights." - }, - { - "professor": "Prof. Olivia Taylor", - "subject": "Marketing", - "star": 3, - "review": "Good real-world examples, but lacks theoretical depth." - }, - { - "professor": "Dr. Christopher Lee", - "subject": "Astronomy", - "star": 4, - "review": "Captivating journey through the cosmos and its phenomena." - }, - { - "professor": "Prof. Elizabeth Wright", - "subject": "Philosophy", - "star": 5, - "review": "Challenges students to question fundamental assumptions." - }, - { - "professor": "Dr. Steven Harris", - "subject": "Neuroscience", - "star": 2, - "review": "Fascinating subject matter, but poorly communicated." - }, - { - "professor": "Prof. Melissa Chang", - "subject": "International Relations", - "star": 4, - "review": "Insightful analysis of global political dynamics." - } - ] -} \ No newline at end of file diff --git a/src/app/(routes)/scrape/page.tsx b/src/app/(routes)/scrape/page.tsx deleted file mode 100644 index e69de29..0000000 diff --git a/src/components/Professor.tsx b/src/components/Professor.tsx index b29f2a3..f40122f 100644 --- a/src/components/Professor.tsx +++ b/src/components/Professor.tsx @@ -1,95 +1,95 @@ -"use client"; // Enable Client-side rendering -import React from "react"; -import { FaSearch } from "react-icons/fa"; +'use client'; +import React, { useState, useEffect, ChangeEvent } from 'react'; +import { FaSearch, FaStar } from 'react-icons/fa'; +import { HoverEffect } from '../components/ui/card-hover-effect'; + +interface Professor { + professor: string; + subject: string; + review: string; + star: number; +} export function Professor() { - // Dummy data for professors - const professors = [ - { - name: "Professor1", - rating: 4.8, - img: "https://via.placeholder.com/150", - }, - { - name: "Professor2", - rating: 4.5, - img: "https://via.placeholder.com/150", - }, - { - name: "Professor3", - rating: 4.7, - img: "https://via.placeholder.com/150", - }, - { - name: "Professor4", - rating: 4.6, - img: "https://via.placeholder.com/150", - }, - { - name: "Professor5", - rating: 4.9, - img: "https://via.placeholder.com/150", - }, - { - name: "Professor6", - rating: 4.4, - img: "https://via.placeholder.com/150", - }, - { - name: "Professor7", - rating: 4.8, - img: "https://via.placeholder.com/150", - }, - { - name: "Professor8", - rating: 4.7, - img: "https://via.placeholder.com/150", - }, - ]; + const [searchQuery, setSearchQuery] = useState(''); + const [isClient, setIsClient] = useState(false); + const [professors, setProfessors] = useState([]); + + useEffect(() => { + // Ensure the component renders only on the client side + setIsClient(true); + + // Fetch data from review.json + const fetchProfessors = async () => { + const response = await fetch('/review.json'); + const data = await response.json(); + setProfessors(data.reviews); + }; + + fetchProfessors(); + }, []); + + // Handle search input + const handleSearchChange = (e: ChangeEvent) => { + setSearchQuery(e.target.value.toLowerCase()); + }; + + // Filter professors based on search query + const filteredProfessors = professors.filter(prof => + prof.professor.toLowerCase().includes(searchQuery) + ); + + if (!isClient) { + return null; // Prevent server-side rendering of the dynamic content + } return ( -
+
{/* Search Bar */} -
+
-
- {/* Professors Grid */} -
- {professors.map((prof, index) => ( -
- {prof.name} -

{prof.name}

-

- {Array.from({ length: Math.floor(prof.rating) }, (_, i) => ( - - ))} -

-

Rating: {prof.rating}

-
- ))} + {/* Professors Grid with HoverEffect */} +
+ ({ + title: ` ${prof.professor}`, + description: ( +
+

Subject: {prof.subject}

+

Review: {prof.review}

+
+ Stars: +
+ {/* Render stars based on the rating */} + {Array.from({ length: prof.star }, (_, i) => ( + + ))} +
+
+
+ ), + link: 'https://via.placeholder.com/150', // Placeholder image, replace with actual link if available + img: 'https://via.placeholder.com/150', // Placeholder image, replace with actual image if available + }))} + />
); } export default Professor; - diff --git a/src/components/ui/card-hover-effect.tsx b/src/components/ui/card-hover-effect.tsx new file mode 100644 index 0000000..ff11087 --- /dev/null +++ b/src/components/ui/card-hover-effect.tsx @@ -0,0 +1,111 @@ +import { cn } from "@/lib/utils"; +import { AnimatePresence, motion } from "framer-motion"; +import Link from "next/link"; +import { useState } from "react"; + +export const HoverEffect = ({ + items, + className, +}: { + items: { + title: string; + description: string; + link: string; + }[]; + className?: string; +}) => { + let [hoveredIndex, setHoveredIndex] = useState(null); + + return ( +
+ {items.map((item, idx) => ( + setHoveredIndex(idx)} + onMouseLeave={() => setHoveredIndex(null)} + > + + {hoveredIndex === idx && ( + + )} + + + {item.title} + {item.description} + + + ))} +
+ ); +}; + +export const Card = ({ + className, + children, +}: { + className?: string; + children: React.ReactNode; +}) => { + return ( +
+
+
{children}
+
+
+ ); +}; +export const CardTitle = ({ + className, + children, +}: { + className?: string; + children: React.ReactNode; +}) => { + return ( +

+ {children} +

+ ); +}; +export const CardDescription = ({ + className, + children, +}: { + className?: string; + children: React.ReactNode; +}) => { + return ( +

+ {children} +

+ ); +};