@@ -60,6 +60,7 @@ export type PollGroup = {
6060 title : string
6161 titleExt : string
6262 pollIds : number [ ]
63+ slug : string
6364}
6465
6566export type PollCategoryList = Record < FilterType , PollCategory >
@@ -285,6 +286,7 @@ export const usePollsStore = defineStore('polls', {
285286 pollsWithGroups ( state : PollList ) : Poll [ ] {
286287 return state . polls . filter ( ( poll : Poll ) => poll . pollGroups . length > 0 )
287288 } ,
289+
288290 currentCategory ( state : PollList ) : PollCategory {
289291 const sessionStore = useSessionStore ( )
290292
@@ -297,10 +299,34 @@ export const usePollsStore = defineStore('polls', {
297299 return state . categories [ FilterType . Relevant ]
298300 } ,
299301
302+ currentGroup ( state : PollList ) : PollGroup | undefined {
303+ const sessionStore = useSessionStore ( )
304+ if ( sessionStore . route . name === 'group' ) {
305+ return state . pollGroups . find (
306+ ( group ) => group . slug === sessionStore . route . params . slug ,
307+ )
308+ }
309+ return undefined
310+ } ,
311+
312+ groupPolls ( state : PollList ) : Poll [ ] {
313+ if ( ! this . currentGroup ) {
314+ return [ ]
315+ }
316+ return state . polls . filter ( ( poll ) =>
317+ this . currentGroup ?. pollIds . includes ( poll . id ) ,
318+ )
319+ } ,
320+
300321 /*
301322 * polls list, filtered by current category and sorted
302323 */
303324 pollsFilteredSorted ( state : PollList ) : Poll [ ] {
325+ const sessionStore = useSessionStore ( )
326+ if ( sessionStore . route . name === 'group' ) {
327+ return this . groupPolls
328+ }
329+
304330 return orderBy (
305331 state . polls . filter ( ( poll : Poll ) =>
306332 this . currentCategory ?. filterCondition ( poll ) ,
0 commit comments