File tree Expand file tree Collapse file tree 2 files changed +43
-0
lines changed
Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Original file line number Diff line number Diff line change 1+ import { useSettingsStore } from '@/app/store/useSettingsStore' ;
2+ import { audioService } from '@/shared/lib/audio-service' ;
3+ import { useCallback } from 'react' ;
4+
5+ export const useNotificationSound = ( ) => {
6+ const { soundEnabled } = useSettingsStore ( ) ;
7+
8+ const playNotificationSound = useCallback ( ( ) => {
9+ if ( soundEnabled ) {
10+ audioService . play ( ) ;
11+ }
12+ } , [ soundEnabled ] ) ;
13+
14+ return { playNotificationSound } ;
15+ } ;
Original file line number Diff line number Diff line change 1+ import { api } from '@/shared/api/api' ;
2+ import type { components } from '@/shared/types/api-types' ;
3+ import { useQuery } from '@tanstack/react-query' ;
4+
5+ type UserListItem = components [ 'schemas' ] [ 'SanitizedUserDto' ] ;
6+ type TeamListItem = components [ 'schemas' ] [ 'TeamDto' ] ;
7+ type ListData = ( UserListItem | TeamListItem ) [ ] ;
8+
9+ export const useSearchableList = ( type : 'user' | 'team' , searchTerm : string ) => {
10+ const queryKey = [ `search-${ type } s` , searchTerm ] ;
11+ const endpoint = type === 'user' ? '/users' : '/teams' ;
12+ const isSearchEnabled = searchTerm . length === 0 || searchTerm . length >= 2 ;
13+
14+ return useQuery ( {
15+ queryKey,
16+ queryFn : async ( ) => {
17+ const queryParams : Record < string , any > = { page : 1 , limit : 100 } ;
18+ if ( searchTerm ) {
19+ queryParams . search = searchTerm ;
20+ }
21+ const response = await api . get < ListData > ( endpoint , {
22+ params : queryParams ,
23+ } ) ;
24+ return response . data ;
25+ } ,
26+ enabled : isSearchEnabled ,
27+ } ) ;
28+ } ;
You can’t perform that action at this time.
0 commit comments