1
1
import { CATEGORY_MAPPING_KEYS , QUERY_PARAMS_STATS_RANGE_VALUES , QUERY_PARAMS_CHANNELS_SORT_VALUES ,
2
- QUERY_PARAMS_CHANNELS_TYPE_VALUES , getTotalPages ,
3
- QueryParamsChannelsType ,
4
- QueryParamsChannelsSort ,
5
- QueryParamsStatsRange } from "podverse-helpers" ;
2
+ QUERY_PARAMS_CHANNELS_TYPE_VALUES , getTotalPages , QueryParamsChannelsType ,
3
+ QueryParamsChannelsSort , QueryParamsStatsRange } from "podverse-helpers" ;
6
4
import { z } from "zod" ;
5
+ import { getDropdownConfig } from "./PodcastsDropdownConfig" ;
7
6
import PodcastsClient from "./PodcastsClient" ;
8
7
import { getSSRAuthService } from "../../utils/auth/ssrAuth" ;
9
8
@@ -53,7 +52,6 @@ export default async function Podcasts({ searchParams }: { searchParams?: Promis
53
52
async function parseSearchParams ( params : PodcastPageProps , isAuthenticated : boolean ) {
54
53
const parsed = searchParamsSchema . safeParse ( params ) ;
55
54
if ( ! parsed . success ) {
56
- console . warn ( "Invalid search parameters:" , parsed . error ) ;
57
55
return { } ;
58
56
}
59
57
const data = parsed . data ;
@@ -62,51 +60,3 @@ async function parseSearchParams(params: PodcastPageProps, isAuthenticated: bool
62
60
}
63
61
return data ;
64
62
}
65
-
66
- const typeDropdownMenuItems = [
67
- { label : "All" , param : "type" , value : "all" } ,
68
- { label : "Subscribed" , param : "type" , value : "subscribed" } ,
69
- { label : "Category" , param : "type" , value : "category" }
70
- ] ;
71
-
72
- const sortDropdownMenuItems = [
73
- { label : "Recent" , param : "sort" , value : "recent" } ,
74
- { label : "Oldest" , param : "sort" , value : "oldest" } ,
75
- { label : "A - Z" , param : "sort" , value : "alphabetical" } ,
76
- { label : "Top" , param : "sort" , value : "top" } ,
77
- ] ;
78
-
79
- const rangeDropdownMenuItems = [
80
- { label : "Day" , param : "range" , value : "day" } ,
81
- { label : "Week" , param : "range" , value : "week" } ,
82
- { label : "Month" , param : "range" , value : "month" } ,
83
- { label : "All Time" , param : "range" , value : "all-time" } ,
84
- ] ;
85
-
86
- function getDropdownConfig ( type ?: QueryParamsChannelsType , sort ?: QueryParamsChannelsSort , range ?: QueryParamsStatsRange ) {
87
- let currentSort = sort ;
88
- let currentRange = range ;
89
- let showRangeDropdown = false ;
90
-
91
- let typeMenuItems = typeDropdownMenuItems ;
92
- let sortMenuItems = sortDropdownMenuItems ;
93
- let rangeMenuItems = rangeDropdownMenuItems ;
94
-
95
- if ( type === "all" || type === "category" ) {
96
- sortMenuItems = [ { label : "Top" , param : "sort" , value : "top" } ] ;
97
- currentSort = "top" ;
98
- currentRange = currentRange || "day" ;
99
- } else if ( type === "subscribed" ) {
100
- sortMenuItems = sortDropdownMenuItems ;
101
- currentSort = currentSort || "alphabetical" ;
102
- }
103
-
104
- if ( currentSort !== "top" ) {
105
- showRangeDropdown = false ;
106
- rangeMenuItems = [ ] ;
107
- } else {
108
- showRangeDropdown = true ;
109
- }
110
-
111
- return { typeMenuItems, sortMenuItems, rangeMenuItems, currentSort, currentRange, showRangeDropdown } ;
112
- }
0 commit comments