-
Notifications
You must be signed in to change notification settings - Fork 471
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main'
- Loading branch information
Showing
5 changed files
with
38 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,57 @@ | ||
'use client'; | ||
|
||
import { getCommunityPlugin } from '@/src/actions/plugins/get-community-plugins'; | ||
import { CommunityPlugin } from '@/src/types/plugins/plugins.types'; | ||
import Image from 'next/image'; | ||
import { Fragment, useEffect, useState } from 'react'; | ||
import ErrorIdentifyPlugin from './error-identify-plugin'; | ||
import IdentifyPluginLoader from './identify-plugin-loader'; | ||
|
||
interface IndentifyPluginProps { | ||
pluginId: string; | ||
} | ||
|
||
export default async function IndentifyPlugin({ pluginId }: IndentifyPluginProps) { | ||
const pluginCommunity = await getCommunityPlugin(pluginId); | ||
if (!pluginCommunity) throw new Error('Plugin not found'); | ||
export default function IndentifyPlugin({ pluginId }: IndentifyPluginProps) { | ||
const [pluginCommunity, setPluginCommunity] = useState<CommunityPlugin | undefined>( | ||
undefined, | ||
); | ||
const [loading, setLoading] = useState(true); | ||
|
||
useEffect(() => { | ||
getCommunityPlugin(pluginId) | ||
.then((plugin) => { | ||
setPluginCommunity(plugin); | ||
}) | ||
.finally(() => setLoading(false)); | ||
}, []); | ||
|
||
if (loading) { | ||
return <IdentifyPluginLoader />; | ||
} | ||
|
||
if (!pluginCommunity) { | ||
return <ErrorIdentifyPlugin />; | ||
} | ||
|
||
|
||
return ( | ||
<div className="sticky top-[4rem] z-[50] mb-3 flex items-center gap-2 border-b border-solid border-zinc-900 bg-[#0f0f0f] bg-opacity-90 px-4 py-3 shadow-sm backdrop-blur-sm md:px-12"> | ||
<Fragment> | ||
<div className="sticky top-[4rem] z-[50] mb-3 flex items-center gap-2 border-b border-solid border-zinc-900 bg-[#0f0f0f] bg-opacity-90 px-4 py-3 shadow-sm backdrop-blur-sm md:px-12"> | ||
<Image | ||
className="grid h-9 w-9 min-w-[36px] place-items-center rounded-full bg-zinc-700" | ||
src={`https://raw.githubusercontent.com/BasedHardware/Friend/main/${pluginCommunity.image}`} | ||
src={`https://raw.githubusercontent.com/BasedHardware/Friend/main/${pluginCommunity?.image}`} | ||
alt={''} | ||
width={50} | ||
height={50} | ||
/> | ||
<div> | ||
<h3 className="text-base font-semibold md:text-base">{pluginCommunity.name}</h3> | ||
<h3 className="text-base font-semibold md:text-base">{pluginCommunity?.name}</h3> | ||
<p className="line-clamp-1 text-sm text-gray-500 md:text-base"> | ||
{pluginCommunity.description} | ||
</p> | ||
</div> | ||
</div> | ||
</Fragment> | ||
|
||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters