fix: complete InvesteMoz validation and error corrections
This commit is contained in:
@@ -1,13 +1,40 @@
|
||||
import { Link } from '@inertiajs/react';
|
||||
import { usePortalQuery } from '@/hooks/use-portal-query';
|
||||
import SearchState from '@/components/search-state';
|
||||
export default function PartnershipSearchResults({query}: {query:string}) {
|
||||
const result = usePortalQuery<{data:{id:number;title:string}[]; total?:number}>('/api/v1/partnerships?q=' + encodeURIComponent(query), 250);
|
||||
export default function PartnershipSearchResults({ query }: { query: string }) {
|
||||
const result = usePortalQuery<{
|
||||
data: { id: number; title: string }[];
|
||||
total?: number;
|
||||
}>('/api/v1/partnerships?q=' + encodeURIComponent(query), 250);
|
||||
const items = result.data?.data ?? [];
|
||||
if (!query.trim()) return null;
|
||||
return <section className="my-5 space-y-3 rounded border p-4"><h2 className="text-xl font-bold">Parcerias nesta pesquisa</h2>
|
||||
<SearchState loading={result.loading} error={result.error} total={result.data?.total ?? items.length} retry={result.retry}/>
|
||||
{!result.error && !result.loading && items.slice(0,5).map(item => <p key={item.id}><Link className="underline" href={'/parcerias/'+item.id}>{item.title}</Link></p>)}
|
||||
<Link className="underline" href={'/parcerias?q='+encodeURIComponent(query)}>Ver todas as parcerias correspondentes</Link>
|
||||
</section>;
|
||||
return (
|
||||
<section className="my-5 space-y-3 rounded border p-4">
|
||||
<h2 className="text-xl font-bold">Parcerias nesta pesquisa</h2>
|
||||
<SearchState
|
||||
loading={result.loading}
|
||||
error={result.error}
|
||||
total={result.data?.total ?? items.length}
|
||||
retry={result.retry}
|
||||
/>
|
||||
{!result.error &&
|
||||
!result.loading &&
|
||||
items.slice(0, 5).map((item) => (
|
||||
<p key={item.id}>
|
||||
<Link
|
||||
className="underline"
|
||||
href={'/parcerias/' + item.id}
|
||||
>
|
||||
{item.title}
|
||||
</Link>
|
||||
</p>
|
||||
))}
|
||||
<Link
|
||||
className="underline"
|
||||
href={'/parcerias?q=' + encodeURIComponent(query)}
|
||||
>
|
||||
Ver todas as parcerias correspondentes
|
||||
</Link>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user