import React, { useState } from 'react';
import { Search, BookOpen, Clock, Users, Star, ChevronRight, Filter } from 'lucide-react';
import AuthenticatedLayout from '@/Layouts/AuthenticatedLayout';
import { PageProps } from '@/types';
import { Head, usePage } from '@inertiajs/react';
function App({ pelatihans }: {pelatihans: any}) {
const user = usePage<PageProps>().props.auth.user;
const [searchTerm, setSearchTerm] = useState('');
const [selectedLevel, setSelectedLevel] = useState('all');
const filteredCourses = pelatihans != null? pelatihans?.filter((course:any) => {
const matchesSearch = course.title.toLowerCase().includes(searchTerm.toLowerCase());
const matchesLevel = selectedLevel === 'all' || course.level.toLowerCase() === selectedLevel.toLowerCase();
return matchesSearch && matchesLevel;
}) : [];
return (
<AuthenticatedLayout
user={user}
header={<h2 className="font-semibold text-xl text-gray-800 leading-tight">Dashboard</h2>}
>
<Head title='Cari Pelatihan'/>
<main className="max-w-7xl mx-auto px-4 py-8">
{/* Search and Filter Section */}
<div className="flex flex-col md:flex-row gap-4 mb-8">
<div className="flex-1 relative">
<Search className="absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 h-5 w-5" />
<input
type="text"
placeholder="Search courses..."
className="w-full pl-10 pr-4 py-3 rounded-lg border border-gray-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent"
value={searchTerm}
onChange={(e) => setSearchTerm(e.target.value)}
/>
</div>
<div className="flex items-center gap-2">
<Filter className="text-gray-500 h-5 w-5" />
<select
className="px-4 py-3 rounded-lg border border-gray-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white"
value={selectedLevel}
onChange={(e) => setSelectedLevel(e.target.value)}
>
<option value="all">All Levels</option>
<option value="beginner">Beginner</option>
<option value="intermediate">Intermediate</option>
<option value="advanced">Advanced</option>
</select>
</div>
</div>
{/* Course Grid */}
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
{filteredCourses.map((course:any) => (
<div key={course.id} className="bg-white rounded-xl shadow-sm hover:shadow-md transition-shadow duration-300">
<img
src={route('course.thumbnail',course.id)}
alt={course.title}
className="w-full h-48 object-cover rounded-t-xl"
/>
<div className="p-6">
<div className="flex items-start justify-between">
<h2 className="text-xl font-semibold text-gray-900 mb-2">{course.title}</h2>
<span className="flex items-center text-yellow-500">
<Star className="h-4 w-4 fill-current" />
<span className="ml-1 text-sm">{4}</span>
</span>
</div>
<p className="text-gray-600 mb-4">by {course.instructor.nama}</p>
{/* <div className="flex flex-wrap gap-2 mb-4">
{course.tags.map(tag => (
<span key={tag} className="px-2 py-1 bg-blue-50 text-blue-600 rounded-full text-sm">
{tag}
</span>
))}
</div> */}
<div className="flex items-center justify-between text-sm text-gray-500 mb-4">
<span className="flex items-center">
<Clock className="h-4 w-4 mr-1" />
{course.duration}
</span>
<span className="flex items-center">
<Users className="h-4 w-4 mr-1" />
{course.pesertas_count.toLocaleString()} students
</span>
<span className="flex items-center">
<BookOpen className="h-4 w-4 mr-1" />
{course.level}
</span>
</div>
<button className="w-full flex items-center justify-center px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors duration-300">
View Course
<ChevronRight className="h-4 w-4 ml-2" />
</button>
</div>
</div>
))}
</div>
{filteredCourses.length === 0 && (
<div className="text-center py-12">
<p className="text-gray-500 text-lg">No courses found matching your criteria.</p>
</div>
)}
</main>
</AuthenticatedLayout>
);
}
export default App;
Anons79 File Manager Version 1.0, Coded By Anons79
Email: [email protected]