diff --git a/frontend/components/StudyGroupSearchCard/StudyGroupSearchCard.tsx b/frontend/components/StudyGroupSearchCard/StudyGroupSearchCard.tsx new file mode 100644 index 0000000..6aaeb05 --- /dev/null +++ b/frontend/components/StudyGroupSearchCard/StudyGroupSearchCard.tsx @@ -0,0 +1,242 @@ +/** + * StudyGroupSearchCard Component + * ------------------------------ + * Search and filter interface for study groups + */ +'use client'; + +import { useState, useRef } from 'react'; +import type { MouseEvent } from 'react'; + +import { Pane, Text } from 'evergreen-ui'; + +interface StudyGroupSearchCardProps { + onSearchChange?: (query: string) => void; + onDateChange?: (date: string) => void; + onCategoryChange?: (category: string) => void; +} + +const categories = [ + 'All Groups', + 'Science', + 'Mathematics', + 'Humanities', + 'Engineering', + 'Social Sciences', +]; + +export function StudyGroupSearchCard({ + onSearchChange, + onDateChange, + onCategoryChange, +}: StudyGroupSearchCardProps) { + const [searchQuery, setSearchQuery] = useState(''); + const [selectedCategory, setSelectedCategory] = useState('All Groups'); + const [selectedDate, setSelectedDate] = useState(''); + const dateInputRef = useRef(null); + + const handleSearchChange = (value: string) => { + setSearchQuery(value); + onSearchChange?.(value); + }; + + const handleDateChange = (value: string) => { + setSelectedDate(value); + onDateChange?.(value); + }; + + const formatDateForDisplay = (dateString: string): string => { + if (!dateString) return ''; + const date = new Date(dateString); + const month = date.toLocaleDateString('en-US', { month: 'short' }); + const day = date.getDate(); + const year = date.getFullYear(); + return `${month} ${day}, ${year}`; + }; + + const handleDateInputClick = () => { + if (dateInputRef.current) { + if (typeof dateInputRef.current.showPicker === 'function') { + dateInputRef.current.showPicker(); + } else { + dateInputRef.current.click(); + } + } + }; + + const handleCategoryChange = (category: string) => { + setSelectedCategory(category); + onCategoryChange?.(category); + }; + + return ( + + {/* Search and Date Filters */} + + {/* Search Bar */} + + + + + + handleSearchChange(e.target.value)} + style={{ + width: '100%', + padding: '12px 12px 12px 44px', + border: '1px solid #D1D5DB', + borderRadius: '6px', + fontSize: '14px', + outline: 'none', + fontFamily: 'inherit', + }} + onFocus={(e) => { + e.target.style.borderColor = '#9CA3AF'; + }} + onBlur={(e) => { + e.target.style.borderColor = '#D1D5DB'; + }} + /> + + + {/* Date Picker */} + + {/* Hidden date input */} + handleDateChange(e.target.value)} + style={{ + position: 'absolute', + opacity: 0, + pointerEvents: 'none', + width: 0, + height: 0, + }} + /> + {/* Visible styled input */} + { + e.target.style.borderColor = '#9CA3AF'; + }} + onBlur={(e) => { + e.target.style.borderColor = '#D1D5DB'; + }} + /> + + + + + + + {/* Category Filters */} + + {categories.map((category) => ( + handleCategoryChange(category)} + style={{ + transition: 'all 0.2s ease', + borderColor: selectedCategory === category ? '#EF4343' : '#D1D5DB', + }} + onMouseEnter={(e: MouseEvent) => { + if (selectedCategory !== category) { + e.currentTarget.style.borderColor = '#9CA3AF'; + } + }} + onMouseLeave={(e: MouseEvent) => { + if (selectedCategory !== category) { + e.currentTarget.style.borderColor = '#D1D5DB'; + } + }} + > + + {category} + + + ))} + + + ); +} + +export default StudyGroupSearchCard;