|  | 
| 1 | 1 | import React from 'react'; | 
| 2 | 2 | 
 | 
| 3 |  | -import { Link } from 'react-router-dom'; | 
|  | 3 | +import { Endpoints } from '../constants/Endpoints'; | 
|  | 4 | +import useFetchPlugins from '../hooks/useFetchPlugins'; | 
| 4 | 5 | 
 | 
|  | 6 | +import Skeleton from 'react-loading-skeleton'; | 
|  | 7 | +import { PluginCard } from '../components/Plugins/PluginCard'; | 
|  | 8 | +import PluginSearchBar from '../components/Plugins/PluginSearchBar'; | 
|  | 9 | +import { useSearchParams } from 'react-router-dom'; | 
| 5 | 10 | /** | 
| 6 | 11 |  * Displays plugins for users to search, browse and rate. | 
| 7 | 12 |  * // todo: dynamically load plugins as user scrolls instead of fetching wholesale from backend | 
| 8 | 13 |  */ | 
| 9 | 14 | const Plugins: React.FC = () => { | 
|  | 15 | +	const [searchParams] = useSearchParams() | 
|  | 16 | +	const searchQuery = searchParams.get('searchQuery') || ""; | 
|  | 17 | + | 
|  | 18 | +	const { plugins, isLoading, error } = useFetchPlugins(Endpoints.fetchApiPlugins, 30, 1,searchQuery ); | 
|  | 19 | +   | 
| 10 | 20 | 	return ( | 
| 11 |  | -		<div className="flex items-center justify-center h-screen bg-black"> | 
| 12 |  | -			<div className="bg-white p-10 rounded-lg shadow-lg text-center max-w-screen-md"> | 
| 13 |  | -				<h1 className="text-4xl font-bold mb-4 text-gray-800">Coming Soon</h1> | 
| 14 |  | -				<p className="text-lg text-gray-600 mb-8"> | 
| 15 |  | -					Plugins are not ready. Please check back later! | 
| 16 |  | -				</p> | 
| 17 |  | -				<p className="text-md text-gray-500 mb-4"> | 
| 18 |  | -					In the meantime, feel free to browse our available themes. | 
| 19 |  | -				</p> | 
| 20 |  | -				<Link | 
| 21 |  | -					to="/themes" | 
| 22 |  | -					className="inline-block bg-blue-500 text-white py-2 px-4 rounded-lg | 
| 23 |  | -						hover:bg-blue-600 transition duration-300" | 
| 24 |  | -				> | 
| 25 |  | -					Browse Themes | 
| 26 |  | -				</Link> | 
|  | 21 | +		<div className=" min-h-screen bg-black"> | 
|  | 22 | +			<div className='p-8 flex flex-col gap-8 max-w-[1024px] m-auto'> | 
|  | 23 | +				<PluginSearchBar /> | 
|  | 24 | +				<div className='grid xs:grid-cols-1  sm:grid-cols-2 lg:grid-cols-3 gap-x-16 gap-y-8'> | 
|  | 25 | +					{isLoading ? Array.from({length : 9}).map((_ , i)=><Skeleton key={i} width="280px" containerClassName='m-auto' height="300px" />) : | 
|  | 26 | +						plugins.length > 0 && plugins.map(plugin =>{ | 
|  | 27 | +							return <PluginCard key={plugin.id} plugin={plugin} /> | 
|  | 28 | +						})} | 
|  | 29 | +				</div> | 
|  | 30 | +				{!isLoading && error && <h1 className='text-white text-lg flex items-center justify-center '>{error}</h1> | 
|  | 31 | +	 } | 
|  | 32 | +				{ | 
|  | 33 | +					!error && !isLoading && plugins.length == 0 && | 
|  | 34 | +					<h1 className='text-white text-lg flex items-center justify-center '>No search results found...</h1> | 
|  | 35 | +				} | 
| 27 | 36 | 			</div> | 
| 28 | 37 | 		</div> | 
| 29 | 38 | 	); | 
|  | 
0 commit comments