Skip to content

Commit

Permalink
chore: ssr search
Browse files Browse the repository at this point in the history
  • Loading branch information
gaboesquivel committed Apr 11, 2024
1 parent 3f841fb commit b961d22
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 17 deletions.
2 changes: 1 addition & 1 deletion apps/masterbots.ai/app/(browse)/[category]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default async function CategoryPage({
const categories = await getCategories()
const categoryId = categories.find(
c => toSlug(c.name) === params.category
).categoryId
)?.categoryId
if (!categoryId) throw new Error('Category not foud')

const query = searchParams.query ? decodeQuery(searchParams.query) : null
Expand Down
1 change: 0 additions & 1 deletion apps/masterbots.ai/app/(browse)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { Card } from '@/components/ui/card'
import { decodeQuery } from '@/lib/url'

export default async function HomePage({ searchParams }: HomePageProps) {
console.log(searchParams.query)
const categories = await getCategories()
const query = searchParams.query ? decodeQuery(searchParams.query) : null
const threads = await getBrowseThreads({
Expand Down
20 changes: 5 additions & 15 deletions apps/masterbots.ai/components/shared/search-input.tsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,19 @@
/* eslint-disable react/no-unescaped-entities */
'use client'

import { useEffect, useState } from 'react'
import { useState } from 'react'

import { Button } from '@/components/ui/button'
import { IconClose } from '@/components/ui/icons'
import { Input } from '@/components/ui/input'
import { usePathname, useSearchParams } from 'next/navigation'
import { usePathname } from 'next/navigation'
import { useRouter } from 'next/navigation'
import { encodeQuery } from '@/lib/url'

export function SearchInput() {
// const params = useSearchParams()
const router = useRouter()
const pathname = usePathname()
const [query, setSearchQuery] = useState('')

// Sync the query state with the query URL query parameter
// useEffect(() => {
// const searchQuery = params.get('query')
// if (searchQuery !== query) {
// setSearchQuery(searchQuery || '')
// }
// }, [params])

const handleSubmit = e => {
e.preventDefault()
router.refresh()
Expand All @@ -48,7 +38,7 @@ export function SearchInput() {
placeholder="Search any chat with any Bot"
value={query || ''}
/>
{/* {query ? (
{query ? (
<Button
aria-label="Clear query"
className="absolute right-0 px-3 -translate-y-1/2 cursor-pointer top-1/2"
Expand All @@ -57,9 +47,9 @@ export function SearchInput() {
>
<IconClose className="!h-4 !w-4" />
</Button>
) : null} */}
) : null}
</div>
<Button type="submit">Search</Button>
{/* <Button type="submit">Search</Button> */}
<div className="w-full text-center">
<p className="dark:text-[#83E56A] text-[#BE17E8] text-xs font-medium pt-4">
Masterbots isn't infallible; verify crucial facts. Responses are for
Expand Down

0 comments on commit b961d22

Please sign in to comment.