@@ -4,7 +4,7 @@ import { useRouter } from 'next/router';
44import React , { ComponentType , useMemo , useState } from 'react' ;
55import { Cookies } from 'react-cookie' ;
66import { Trans , useTranslation } from 'react-i18next' ;
7- import { useQueryClient , UseQueryResult } from 'react-query' ;
7+ import { useQueryClient } from 'react-query' ;
88import { dehydrate } from 'react-query/hydration' ;
99
1010import { CalendarType } from '@/constants/CalendarType' ;
@@ -15,12 +15,12 @@ import {
1515 useDeleteEventByIdMutation ,
1616 useGetEventsByCreatorQuery ,
1717} from '@/hooks/api/events' ;
18+ import { useGetOffersByCreatorQuery } from '@/hooks/api/offers' ;
1819import {
1920 prefetchGetOrganizersByCreatorQuery ,
2021 useDeleteOrganizerByIdMutation ,
2122 useGetOrganizersByCreatorQuery ,
2223 useGetOrganizersByQueryQuery ,
23- useGetSuggestedOrganizersQuery ,
2424} from '@/hooks/api/organizers' ;
2525import {
2626 prefetchGetPlacesByCreatorQuery ,
@@ -47,7 +47,6 @@ import { Alert, AlertVariants } from '@/ui/Alert';
4747import { Box } from '@/ui/Box' ;
4848import { Button , ButtonVariants } from '@/ui/Button' ;
4949import { Dropdown } from '@/ui/Dropdown' ;
50- import { Icons } from '@/ui/Icon' ;
5150import type { InlineProps } from '@/ui/Inline' ;
5251import { getInlineProps , Inline } from '@/ui/Inline' ;
5352import { LabelPositions } from '@/ui/Label' ;
@@ -224,11 +223,6 @@ const OfferRow = ({ item: offer, onDelete, ...props }: OfferRowProps) => {
224223 ? t ( `eventTypes*${ typeId } ` , { keySeparator : '*' } )
225224 : undefined ;
226225
227- const period =
228- offer . calendarSummary ?. [ i18n . language ] ?. text ?. [
229- offer . calendarType === CalendarType . SINGLE ? 'lg' : 'sm'
230- ] ;
231-
232226 const rowStatus = useMemo < RowStatus > ( ( ) => {
233227 if ( isPlanned ) {
234228 return 'PLANNED' ;
@@ -580,21 +574,42 @@ const Dashboard = (): any => {
580574 ) ;
581575 } ;
582576
583- const suggestedOrganizerIds = useGetSuggestedOrganizersQuery (
584- { } ,
577+ const getOffersByCreatorQuery = useGetOffersByCreatorQuery (
578+ {
579+ advancedQuery : '_exists_:organizer.id' ,
580+ creator : user ,
581+ paginationOptions : { start : 0 , limit : 30 } ,
582+ } ,
585583 { enabled : tab === 'organizers' } ,
586584 ) ;
587585
588- suggestedOrganizerIds . data ;
586+ const recentUsedOrganizers = useMemo ( ( ) => {
587+ const recentOrganizers : Organizer [ ] = [ ] ;
588+
589+ getOffersByCreatorQuery . data ?. member . forEach ( ( event ) => {
590+ if (
591+ event . organizer &&
592+ ! recentOrganizers . some (
593+ ( recentOrganizer ) =>
594+ recentOrganizer [ '@id' ] === event . organizer [ '@id' ] ,
595+ )
596+ )
597+ recentOrganizers . push ( event . organizer ) ;
598+ } ) ;
599+
600+ return recentOrganizers . slice ( 0 , 10 ) ;
601+ } , [ getOffersByCreatorQuery . data ?. member ] ) ;
589602
590603 const suggestedOrganizers = useGetOrganizersByQueryQuery (
591604 {
592- q : suggestedOrganizerIds . data ?. member
593- . map ( ( result ) => `id:${ parseOfferId ( result [ '@id' ] ) } ` )
594- . join ( ' OR ' ) ,
605+ q :
606+ recentUsedOrganizers
607+ . map ( ( organizer ) => `id:${ parseOfferId ( organizer [ '@id' ] ) } ` )
608+ . join ( ' OR ' ) +
609+ ` NOT creator:"${ user ?. [ 'https://publiq.be/uitidv1id' ] ?? user ?. sub } "` ,
595610 } ,
596611 {
597- enabled : suggestedOrganizerIds . data ?. member ? .length > 0 ,
612+ enabled : tab === 'organizers' && recentUsedOrganizers . length > 0 ,
598613 } ,
599614 ) ;
600615
0 commit comments