@@ -8,7 +8,6 @@ import { Route, Routes } from 'react-router-dom';
88import { AppContext } from '@/providers/AppProvider/AppContext' ;
99import { AuthContext } from '@/providers/AuthProvider/AuthContext' ;
1010import { WCIFContext } from '@/providers/WCIFProvider' ;
11- import { getSelectedFixture } from '@/storybook/fixtures' ;
1211import {
1312 storybookCompetitionApiFixture ,
1413 storybookCompetitionFixture ,
@@ -42,7 +41,7 @@ interface CompetitionRouteDecoratorOptions extends CompetitionPageDecoratorOptio
4241 path : string ;
4342}
4443
45- interface CompetitionStorybookParameters extends CompetitionPageDecoratorOptions {
44+ export interface CompetitionStorybookParameters extends CompetitionPageDecoratorOptions {
4645 competitionFixture ?: Competition ;
4746}
4847
@@ -65,32 +64,20 @@ const createStorybookQueryClient = (competition: Competition, competitionData?:
6564const resolveCompetitionOptions = (
6665 defaults : CompetitionPageDecoratorOptions ,
6766 parameters ?: CompetitionStorybookParameters ,
68- fixture ?: Record < string , unknown > ,
6967) : Required < CompetitionPageDecoratorOptions > => ( {
7068 competition :
71- ( fixture ?. competitionFixture as Competition | undefined ) ||
7269 parameters ?. competitionFixture ||
7370 parameters ?. competition ||
7471 defaults . competition ||
7572 storybookCompetitionFixture ,
7673 competitionData :
77- ( fixture ?. competitionData as ApiCompetition | undefined ) ||
78- parameters ?. competitionData ||
79- defaults . competitionData ||
80- storybookCompetitionApiFixture ,
81- currentUser :
82- ( fixture ?. currentUser as User | null | undefined ) ??
83- parameters ?. currentUser ??
84- defaults . currentUser ??
85- storybookCurrentUser ,
74+ parameters ?. competitionData || defaults . competitionData || storybookCompetitionApiFixture ,
75+ currentUser : parameters ?. currentUser ?? defaults . currentUser ?? storybookCurrentUser ,
8676 ongoingActivities :
87- ( fixture ?. ongoingActivities as CompetitionPageDecoratorOptions [ 'ongoingActivities' ] ) ||
8877 parameters ?. ongoingActivities ||
8978 defaults . ongoingActivities ||
9079 storybookOngoingActivitiesFixture ,
91- pinnedPersons : ( fixture ?. pinnedPersons as number [ ] | undefined ) ||
92- parameters ?. pinnedPersons ||
93- defaults . pinnedPersons || [ 2 , 3 ] ,
80+ pinnedPersons : parameters ?. pinnedPersons || defaults . pinnedPersons || [ 2 , 3 ] ,
9481} ) ;
9582
9683const StorybookCompetitionProviders = ( {
@@ -167,11 +154,9 @@ export const makeCompetitionPageDecorator = ({
167154 pinnedPersons = [ 2 , 3 ] ,
168155} : CompetitionPageDecoratorOptions = { } ) =>
169156 ( ( Story , context ) => {
170- const [ , fixture ] = getSelectedFixture ( context ) || [ ] ;
171157 const options = resolveCompetitionOptions (
172158 { competition, competitionData, currentUser, ongoingActivities, pinnedPersons } ,
173159 context . parameters as CompetitionStorybookParameters ,
174- fixture ,
175160 ) ;
176161
177162 return (
@@ -182,10 +167,7 @@ export const makeCompetitionPageDecorator = ({
182167 ongoingActivities = { options . ongoingActivities }
183168 pinnedPersons = { options . pinnedPersons } >
184169 < Routes >
185- < Route
186- path = "/competitions/:competitionId/*"
187- element = { < Story args = { { ...context . args , ...( fixture ?. args || { } ) } } /> }
188- />
170+ < Route path = "/competitions/:competitionId/*" element = { < Story args = { context . args } /> } />
189171 </ Routes >
190172 </ StorybookCompetitionProviders >
191173 ) ;
@@ -199,11 +181,9 @@ export const makeCompetitionContainerDecorator = ({
199181 pinnedPersons = [ 2 , 3 ] ,
200182} : CompetitionPageDecoratorOptions = { } ) =>
201183 ( ( Story , context ) => {
202- const [ , fixture ] = getSelectedFixture ( context ) || [ ] ;
203184 const options = resolveCompetitionOptions (
204185 { competition, competitionData, currentUser, ongoingActivities, pinnedPersons } ,
205186 context . parameters as CompetitionStorybookParameters ,
206- fixture ,
207187 ) ;
208188
209189 return (
@@ -213,7 +193,7 @@ export const makeCompetitionContainerDecorator = ({
213193 currentUser = { options . currentUser }
214194 ongoingActivities = { options . ongoingActivities }
215195 pinnedPersons = { options . pinnedPersons } >
216- < Story args = { { ... context . args , ... ( fixture ?. args || { } ) } } />
196+ < Story args = { context . args } />
217197 </ StorybookCompetitionProviders >
218198 ) ;
219199 } ) satisfies Decorator ;
@@ -223,7 +203,6 @@ export const makeCompetitionRouteDecorator = ({
223203 ...options
224204} : CompetitionRouteDecoratorOptions ) =>
225205 ( ( Story , context ) => {
226- const [ , fixture ] = getSelectedFixture ( context ) || [ ] ;
227206 const resolvedOptions = resolveCompetitionOptions (
228207 {
229208 competition : options . competition ,
@@ -233,7 +212,6 @@ export const makeCompetitionRouteDecorator = ({
233212 pinnedPersons : options . pinnedPersons ,
234213 } ,
235214 context . parameters as CompetitionStorybookParameters ,
236- fixture ,
237215 ) ;
238216
239217 return (
@@ -248,10 +226,7 @@ export const makeCompetitionRouteDecorator = ({
248226 path = "/competitions/:competitionId/*"
249227 element = {
250228 < Routes >
251- < Route
252- path = { path }
253- element = { < Story args = { { ...context . args , ...( fixture ?. args || { } ) } } /> }
254- />
229+ < Route path = { path } element = { < Story args = { context . args } /> } />
255230 </ Routes >
256231 }
257232 />
0 commit comments