1
1
'use client' ;
2
2
3
- import {
4
- FeaturedSongsDtoType ,
5
- SongPreviewDtoType ,
6
- TimespanType ,
7
- } from '@nbw/database' ;
3
+ import { TIMESPANS } from '@nbw/config' ;
4
+ import { type FeaturedSongsDto , type SongPreviewDto } from '@nbw/database' ;
8
5
import { createContext , useContext , useEffect , useState } from 'react' ;
6
+ type TimespanType = ( typeof TIMESPANS ) [ number ] ;
9
7
10
8
type FeaturedSongsContextType = {
11
- featuredSongsPage : SongPreviewDtoType [ ] ;
9
+ featuredSongsPage : SongPreviewDto [ ] ;
12
10
timespan : TimespanType ;
13
11
setTimespan : ( timespan : TimespanType ) => void ;
14
12
timespanEmpty : Record < string , boolean > ;
@@ -23,14 +21,14 @@ export function FeaturedSongsProvider({
23
21
initialFeaturedSongs,
24
22
} : {
25
23
children : React . ReactNode ;
26
- initialFeaturedSongs : FeaturedSongsDtoType ;
24
+ initialFeaturedSongs : FeaturedSongsDto ;
27
25
} ) {
28
26
// Featured songs
29
- const [ featuredSongs ] = useState < FeaturedSongsDtoType > ( initialFeaturedSongs ) ;
27
+ const [ featuredSongs ] = useState < FeaturedSongsDto > ( initialFeaturedSongs ) ;
30
28
31
- const [ featuredSongsPage , setFeaturedSongsPage ] = useState <
32
- SongPreviewDtoType [ ]
33
- > ( initialFeaturedSongs . week ) ;
29
+ const [ featuredSongsPage , setFeaturedSongsPage ] = useState < SongPreviewDto [ ] > (
30
+ initialFeaturedSongs . week ,
31
+ ) ;
34
32
35
33
const [ timespan , setTimespan ] = useState < TimespanType > ( 'week' ) ;
36
34
@@ -43,7 +41,6 @@ export function FeaturedSongsProvider({
43
41
) ;
44
42
45
43
useEffect ( ( ) => {
46
- // eslint-disable-next-line react-hooks/exhaustive-deps
47
44
setFeaturedSongsPage ( featuredSongs [ timespan ] ) ;
48
45
} , [ featuredSongs , timespan ] ) ;
49
46
0 commit comments