fix: search fetch order
This commit is contained in:
1 parent
ebf599eed6
commit
6788dea0cd
2 files changed
+9
-3
No files matched your search
@@ -10,7 +10,6 @@ import { Modal } from '@/components/ui/dialog';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
|
||||
import useDistinctUntilChanged from '@/hooks/useDistinctUntilChanged';
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
import useSearch from './useSearch';
|
||||
|
||||
@@ -36,13 +35,15 @@ export const showSearchModal = create(({ onResolve }) => {
|
||||
{ title: 'Series', data: series, type: 'tv' as const }
|
||||
].filter(({ data: { shows } }) => shows.length);
|
||||
|
||||
const isFetched = movies.isFetched && series.isFetched;
|
||||
|
||||
return (
|
||||
<Modal className='block p-0 max-w-[932px]' onClose={onResolve} scrollRef={scrollRef}>
|
||||
<div className='relative p-2'>
|
||||
<Input
|
||||
autoFocus
|
||||
ref={inputRef}
|
||||
placeholder='Start entering title...'
|
||||
placeholder='Start typing title...'
|
||||
value={title}
|
||||
onChange={handleChangeTitle}
|
||||
className='pr-10 focus-visible:ring-0'
|
||||
@@ -58,8 +59,10 @@ export const showSearchModal = create(({ onResolve }) => {
|
||||
<XCircle />
|
||||
</Button>
|
||||
</div>
|
||||
{isFetched && (
|
||||
<div className='px-2'>
|
||||
{tabs.length > 1 ? (
|
||||
<Tabs defaultValue='movie' className={cn('w-full px-2')}>
|
||||
<Tabs defaultValue='movie'>
|
||||
<TabsList className='grid w-full grid-cols-2'>
|
||||
{tabs.map(({ type, title }) => (
|
||||
<TabsTrigger key={type} value={type}>
|
||||
@@ -89,6 +92,8 @@ export const showSearchModal = create(({ onResolve }) => {
|
||||
/>
|
||||
))
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</Modal>
|
||||
);
|
||||
});
|
||||
|
||||
@@ -175,6 +175,7 @@ const Modal: React.FC<{
|
||||
</DialogHeader>
|
||||
<DialogContent style={style} scrollRef={scrollRef} forceMount onClose={handleClose} className={className}>
|
||||
{children}
|
||||
<DialogDescription />
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user