feat: categories and popups #171
@ -43,8 +43,7 @@ import { useCuratedSet } from 'hooks/useCuratedSet'
|
||||
enum SearchKindEnum {
|
||||
Mods = 'Mods',
|
||||
Games = 'Games',
|
||||
Users = 'Users',
|
||||
Categories = 'Categories'
|
||||
Users = 'Users'
|
||||
}
|
||||
|
||||
export const SearchPage = () => {
|
||||
@ -133,10 +132,6 @@ export const SearchPage = () => {
|
||||
{searchKind === SearchKindEnum.Games && (
|
||||
<GamesResult searchTerm={searchTerm} />
|
||||
)}
|
||||
|
||||
{searchKind === SearchKindEnum.Categories && (
|
||||
<CategoriesResult searchTerm={searchTerm} />
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -543,44 +538,3 @@ function dedup(event1: NDKEvent, event2: NDKEvent) {
|
||||
|
||||
return event2
|
||||
}
|
||||
|
||||
interface CategoriesResultProps {
|
||||
searchTerm: string
|
||||
}
|
||||
|
||||
const CategoriesResult = ({ searchTerm }: CategoriesResultProps) => {
|
||||
const { ndk } = useNDKContext()
|
||||
const [mods, setMods] = useState<ModDetails[]>()
|
||||
|
||||
useEffect(() => {
|
||||
const call = async () => {
|
||||
const filter: NDKFilter = {
|
||||
kinds: [NDKKind.Classified],
|
||||
'#l': [`com.degmods:${searchTerm}`]
|
||||
}
|
||||
|
||||
const ndkEventSet = await ndk.fetchEvents(filter)
|
||||
const events = Array.from(ndkEventSet)
|
||||
const mods: ModDetails[] = []
|
||||
events.map((e) => {
|
||||
if (isModDataComplete(e)) {
|
||||
const mod = extractModData(e)
|
||||
mods.push(mod)
|
||||
}
|
||||
})
|
||||
setMods(mods)
|
||||
}
|
||||
|
||||
call()
|
||||
}, [ndk, searchTerm])
|
||||
|
||||
return (
|
||||
<div className='IBMSecMain IBMSMListWrapper'>
|
||||
<div className='IBMSMList'>
|
||||
{mods?.map((mod) => (
|
||||
<ModCard key={mod.id} {...mod} />
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user