Epic 4: Chemins Narratifs, Challenge & Contact Stories implementees: - 4.1: Composant ChoiceCards pour choix narratifs binaires - 4.2: Sequence d'intro narrative avec Le Bug - 4.3: Chemins narratifs differencies avec useNarrativePath - 4.4: Table easter_eggs et systeme de detection (API + composable) - 4.5: Easter eggs UI (popup, notification, collection) - 4.6: Page challenge avec puzzle de code - 4.7: Page revelation "Monde de Code" - 4.8: Page contact avec formulaire et stats Fichiers crees: - Frontend: ChoiceCards, IntroSequence, ZoneEndChoice, EasterEggPopup, CodePuzzle, ChallengeSuccess, CodeWorld, et pages intro/challenge/revelation - API: EasterEggController, Model, Migration, Seeder Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
57 lines
1.3 KiB
TypeScript
57 lines
1.3 KiB
TypeScript
export type NarratorContext =
|
|
| 'intro'
|
|
| 'intro_sequence_1'
|
|
| 'intro_sequence_2'
|
|
| 'intro_sequence_3'
|
|
| 'transition_projects'
|
|
| 'transition_skills'
|
|
| 'transition_testimonials'
|
|
| 'transition_journey'
|
|
| 'hint'
|
|
| 'encouragement_25'
|
|
| 'encouragement_50'
|
|
| 'encouragement_75'
|
|
| 'contact_unlocked'
|
|
| 'welcome_back'
|
|
|
|
export type HeroType = 'recruteur' | 'client' | 'dev'
|
|
|
|
export interface NarratorTextData {
|
|
context: string
|
|
text: string
|
|
variant: number
|
|
hero_type: HeroType | null
|
|
}
|
|
|
|
interface NarratorTextResponse {
|
|
data: NarratorTextData
|
|
meta: { lang: string }
|
|
}
|
|
|
|
export function useFetchNarratorText() {
|
|
const config = useRuntimeConfig()
|
|
const { locale } = useI18n()
|
|
|
|
async function fetchText(context: NarratorContext, heroType?: HeroType): Promise<NarratorTextData | null> {
|
|
try {
|
|
const url = heroType
|
|
? `/narrator/${context}?hero=${heroType}`
|
|
: `/narrator/${context}`
|
|
|
|
const response = await $fetch<NarratorTextResponse>(url, {
|
|
baseURL: config.public.apiUrl as string,
|
|
headers: {
|
|
'X-API-Key': config.public.apiKey as string,
|
|
'Accept-Language': locale.value,
|
|
},
|
|
})
|
|
|
|
return response.data
|
|
} catch {
|
|
return null
|
|
}
|
|
}
|
|
|
|
return { fetchText }
|
|
}
|