| 1 |
import { |
| 2 |
ContentGathering, |
| 3 |
state as contentGatheringState, |
| 4 |
} from '@launch/pages/ContentGathering'; |
| 5 |
import { HomeSelect, state as homeSelectState } from '@launch/pages/HomeSelect'; |
| 6 |
import { |
| 7 |
ObjectiveSelection, |
| 8 |
state as objectiveSelectionState, |
| 9 |
} from '@launch/pages/ObjectiveSelection'; |
| 10 |
import { |
| 11 |
PagesSelect, |
| 12 |
state as pagesSelectState, |
| 13 |
} from '@launch/pages/PagesSelect'; |
| 14 |
import { |
| 15 |
SiteInformation, |
| 16 |
state as siteInfoState, |
| 17 |
} from '@launch/pages/SiteInformation'; |
| 18 |
import { SitePrep, state as sitePrepState } from '@launch/pages/SitePrep'; |
| 19 |
import { |
| 20 |
SiteQuestions, |
| 21 |
state as siteQuestionsState, |
| 22 |
} from '@launch/pages/SiteQuestions'; |
| 23 |
import { |
| 24 |
SiteStructure, |
| 25 |
state as siteStructureState, |
| 26 |
} from '@launch/pages/SiteStructure'; |
| 27 |
import { useUserSelectionStore } from '@launch/state/user-selections'; |
| 28 |
|
| 29 |
const showSiteQuestions = window.extSharedData?.showSiteQuestions ?? false; |
| 30 |
|
| 31 |
// This is the default pages array |
| 32 |
// You can add pre-fetch functions to start fetching data for the next page |
| 33 |
// Supports both [] and single fetcher functions |
| 34 |
const initialPagesList = { |
| 35 |
'website-objective': { |
| 36 |
component: ObjectiveSelection, |
| 37 |
state: objectiveSelectionState, |
| 38 |
condition: () => !showSiteQuestions, |
| 39 |
}, |
| 40 |
'site-information': { |
| 41 |
component: SiteInformation, |
| 42 |
state: siteInfoState, |
| 43 |
}, |
| 44 |
'site-prep': { |
| 45 |
component: SitePrep, |
| 46 |
state: sitePrepState, |
| 47 |
}, |
| 48 |
'site-questions': { |
| 49 |
component: SiteQuestions, |
| 50 |
state: siteQuestionsState, |
| 51 |
condition: () => showSiteQuestions, |
| 52 |
}, |
| 53 |
'site-structure': { |
| 54 |
component: SiteStructure, |
| 55 |
state: siteStructureState, |
| 56 |
condition: ({ siteObjective }) => |
| 57 |
siteObjective !== 'landing-page' || !showSiteQuestions, |
| 58 |
}, |
| 59 |
'content-fetching': { |
| 60 |
component: ContentGathering, |
| 61 |
state: contentGatheringState, |
| 62 |
}, |
| 63 |
layout: { |
| 64 |
component: HomeSelect, |
| 65 |
state: homeSelectState, |
| 66 |
}, |
| 67 |
'page-select': { |
| 68 |
component: PagesSelect, |
| 69 |
state: pagesSelectState, |
| 70 |
condition: ({ siteStructure }) => siteStructure === 'multi-page', |
| 71 |
}, |
| 72 |
}; |
| 73 |
|
| 74 |
export const getPages = () => { |
| 75 |
const { siteStructure, siteObjective } = |
| 76 |
useUserSelectionStore?.getState() ?? {}; |
| 77 |
const conditionData = { siteStructure, siteObjective }; |
| 78 |
|
| 79 |
return Object.entries(initialPagesList).filter( |
| 80 |
([_, page]) => !page.condition || page.condition(conditionData), |
| 81 |
); |
| 82 |
}; |
| 83 |
|
| 84 |
export const pages = getPages(); |
| 85 |
|