fix: search fetch order

This commit is contained in:
ner committed 2024-09-30 19:44:35 +03:00
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 { Input } from '@/components/ui/input';
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs'; import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
import useDistinctUntilChanged from '@/hooks/useDistinctUntilChanged'; import useDistinctUntilChanged from '@/hooks/useDistinctUntilChanged';
import { cn } from '@/lib/utils';
import useSearch from './useSearch'; import useSearch from './useSearch';
@@ -36,13 +35,15 @@ export const showSearchModal = create(({ onResolve }) => {
{ title: 'Series', data: series, type: 'tv' as const } { title: 'Series', data: series, type: 'tv' as const }
].filter(({ data: { shows } }) => shows.length); ].filter(({ data: { shows } }) => shows.length);
const isFetched = movies.isFetched && series.isFetched;
return ( return (
<Modal className='block p-0 max-w-[932px]' onClose={onResolve} scrollRef={scrollRef}> <Modal className='block p-0 max-w-[932px]' onClose={onResolve} scrollRef={scrollRef}>
<div className='relative p-2'> <div className='relative p-2'>
<Input <Input
autoFocus autoFocus
ref={inputRef} ref={inputRef}
placeholder='Start entering title...' placeholder='Start typing title...'
value={title} value={title}
onChange={handleChangeTitle} onChange={handleChangeTitle}
className='pr-10 focus-visible:ring-0' className='pr-10 focus-visible:ring-0'
@@ -58,8 +59,10 @@ export const showSearchModal = create(({ onResolve }) => {
<XCircle /> <XCircle />
</Button> </Button>
</div> </div>
{isFetched && (
<div className='px-2'>
{tabs.length > 1 ? ( {tabs.length > 1 ? (
<Tabs defaultValue='movie' className={cn('w-full px-2')}> <Tabs defaultValue='movie'>
<TabsList className='grid w-full grid-cols-2'> <TabsList className='grid w-full grid-cols-2'>
{tabs.map(({ type, title }) => ( {tabs.map(({ type, title }) => (
<TabsTrigger key={type} value={type}> <TabsTrigger key={type} value={type}>
@@ -89,6 +92,8 @@ export const showSearchModal = create(({ onResolve }) => {
/> />
)) ))
)} )}
</div>
)}
</Modal> </Modal>
); );
}); });
+1
View File
@@ -175,6 +175,7 @@ const Modal: React.FC<{
</DialogHeader> </DialogHeader>
<DialogContent style={style} scrollRef={scrollRef} forceMount onClose={handleClose} className={className}> <DialogContent style={style} scrollRef={scrollRef} forceMount onClose={handleClose} className={className}>
{children} {children}
<DialogDescription />
</DialogContent> </DialogContent>
</Dialog> </Dialog>
); );