diff --git a/dev-share-ui/app/search/page.tsx b/dev-share-ui/app/search/page.tsx index ad888d4..576efdf 100644 --- a/dev-share-ui/app/search/page.tsx +++ b/dev-share-ui/app/search/page.tsx @@ -1,64 +1,9 @@ -'use client'; - -import { useState } from 'react'; import HeroSection from '@/components/HeroSection'; -import { mockResources } from '@/lib/data'; -import ResourceCard from '@/components/ResourceCard'; -import FromAISearchResourceCard from '@/components/FromAISearchResourceCard'; -import { handleGlobalSearch, searchResources } from '@/services/search-service'; export default function SearchPage() { - const [resources, setResources] = useState(mockResources); - const [isSearching, setIsSearching] = useState(false); - const [SearchQuery, setSearchQuery] = useState(''); - const topRelative = 6; - - const handleSearch = async (query: string) => { - setIsSearching(true); - setSearchQuery(query); - setResources([]); - - const result = await searchResources(query); - if (result.length === 0) { - await handleGlobalSearch(); - } else { - setResources(result); - } - setIsSearching(false); - }; - - const handleResourceAction = (id: string, action: 'like' | 'bookmark') => { - // TODO: Integrate with feedback loop API - // Integration point for feedback loop: - // 1. Send user action to your API - // 2. Update resource in your database - // 3. Use this data to improve recommendations - - setResources((prevResources) => - prevResources.map((resource) => { - if (resource.id === id) { - if (action === 'like') { - return { - ...resource, - likes: resource.isLiked ? resource.likes - 1 : resource.likes + 1, - isLiked: !resource.isLiked, - }; - } else { - return { ...resource, isBookmarked: !resource.isBookmarked }; - } - } - return resource; - }) - ); - }; - - const handleSearchSuggestion = (suggestion: string) => { - handleSearch(suggestion); - }; - return (
- +
); } diff --git a/dev-share-ui/components/HeroSection.tsx b/dev-share-ui/components/HeroSection.tsx index e80c9d0..9830661 100644 --- a/dev-share-ui/components/HeroSection.tsx +++ b/dev-share-ui/components/HeroSection.tsx @@ -1,56 +1,17 @@ 'use client'; import { useState, useEffect } from 'react'; -import { Search, Plus } from 'lucide-react'; -import { Button } from '@/components/ui/button'; -import { Input } from '@/components/ui/input'; import { Particles } from '@/components/magicui/particles'; import { useTheme } from 'next-themes'; -import { useRouter } from 'next/navigation'; import SearchBar from './SearchBar'; -interface HeroSectionProps { - onSearch: (query: string) => void; - isSearching: boolean; -} - -export default function HeroSection({ - onSearch, - isSearching, -}: HeroSectionProps) { - const [query, setQuery] = useState(''); - const [placeholderIndex, setPlaceholderIndex] = useState(0); +export default function HeroSection() { const { resolvedTheme } = useTheme(); const [color, setColor] = useState('#ffffff'); - const router = useRouter(); + useEffect(() => { setColor(resolvedTheme === 'dark' ? '#ffffff' : '#000000'); }, [resolvedTheme]); - const placeholders = [ - 'Search resources, tools, guides...', - 'TypeScript tutorials for beginners', - 'How to optimize Next.js performance', - 'GraphQL resources for frontend developers', - 'Learn CSS Grid and Flexbox', - 'Node.js backend architecture patterns', - ]; - - // Rotate placeholder text every 5 seconds - useEffect(() => { - const interval = setInterval(() => { - setPlaceholderIndex((prev) => (prev + 1) % placeholders.length); - }, 5000); - - return () => clearInterval(interval); - }, [placeholders.length]); - - const handleSubmit = (e: React.FormEvent) => { - e.preventDefault(); - if (query.trim()) { - onSearch(query); - router.push(`/result`); - } - }; return (
@@ -64,7 +25,7 @@ export default function HeroSection({
-

+

Discover Resources

@@ -72,19 +33,6 @@ export default function HeroSection({

- {/*
-
- - setQuery(e.target.value)} - className="pl-10 h-11 rounded-lg bg-card transition-all duration-300 focus:ring-2 focus:ring-primary/20 w-3/5" - disabled={isSearching} - /> -
-
*/}
diff --git a/dev-share-ui/components/Navbar.tsx b/dev-share-ui/components/Navbar.tsx index 0f85992..a753f19 100644 --- a/dev-share-ui/components/Navbar.tsx +++ b/dev-share-ui/components/Navbar.tsx @@ -2,19 +2,12 @@ import Link from 'next/link'; import { BookMarked } from 'lucide-react'; -import { Button } from '@/components/ui/button'; -import { - DropdownMenu, - DropdownMenuContent, - DropdownMenuItem, - DropdownMenuTrigger, -} from '@/components/ui/dropdown-menu'; import { ThemeToggle } from '@/components/ThemeToggle'; export default function Navbar() { return ( -
-
+
+
@@ -23,68 +16,14 @@ export default function Navbar() {
- -
-
- -
- - - - - - - Discover - - - Share - - - Collections - - - Sign In - - - -
+
); diff --git a/dev-share-ui/components/ResourceCard.tsx b/dev-share-ui/components/ResourceCard.tsx index ede612f..c36ad27 100644 --- a/dev-share-ui/components/ResourceCard.tsx +++ b/dev-share-ui/components/ResourceCard.tsx @@ -5,132 +5,68 @@ import { ThumbsUp, Bookmark, Link as LinkIcon, - MessageSquare, } from 'lucide-react'; import { Card } from '@/components/ui/card'; import { Button } from '@/components/ui/button'; import { Badge } from '@/components/ui/badge'; import { Resource } from '@/lib/types'; -import { - Tooltip, - TooltipContent, - TooltipProvider, - TooltipTrigger, -} from '@/components/ui/tooltip'; import ReadMoreArea from '@foxeian/react-read-more'; interface ResourceCardProps { resource: Resource; onAction: (id: string, action: 'like' | 'bookmark') => void; - isAIGenerated?: boolean; -} -const buttonStyle = {}; - -function timeAgo(dateString: string) { - const now = new Date(); - const date = new Date(dateString); - const diff = now.getTime() - date.getTime(); - const years = Math.floor(diff / (1000 * 60 * 60 * 24 * 365)); - if (years > 0) return `over ${years} year${years > 1 ? 's' : ''} ago`; - const months = Math.floor(diff / (1000 * 60 * 60 * 24 * 30)); - if (months > 0) return `${months} month${months > 1 ? 's' : ''} ago`; - const days = Math.floor(diff / (1000 * 60 * 60 * 24)); - if (days > 0) return `${days} day${days > 1 ? 's' : ''} ago`; - return 'recently'; } export default function ResourceCard({ resource, onAction, - isAIGenerated = false, }: ResourceCardProps) { return ( - {/* AI Generated badge */} - {isAIGenerated && ( - - +
+

+ {resource.title} +

+ - {/* Author and meta */} -
- {/* {resource.authorName} */} -
-
- - {resource.authorName} - - - {timeAgo(resource.createdAt)} - + +
-
- {/* User comment (collapsed, tooltip on hover) */} - {resource.comment && ( - - - -
- - - {resource.comment} - -
-
- - {resource.comment} - -
-
- )} - {/* Title and description */} -
-

- {resource.title} -

+ {/* AI Generated badge */} + {resource.isAIGenerated && ( + + + + + Searched with AI + + )} {resource.description} @@ -143,6 +79,7 @@ export default function ResourceCard({ ))}
+ {/* Footer actions */}
@@ -165,7 +102,7 @@ export default function ResourceCard({