import React, { useCallback, useState } from 'react' import { StyleSheet, Text, View } from 'react-native' import { useGlobal } from 'reactn' import { background } from '../assets' import BorderGradientButton from '../components/BorderGradientButton' import GradientButton from '../components/GradientButton' import ItemContainer from '../components/ItemContainer/ItemContainer' import { isWeb } from '../hooks/useLayoutType' import Page from '../layouts/Page' import { Routes } from '../navigation' import { navigate, reset } from '../navigation/NavigationService' import { Palette } from '../styles' import { FONT_FAMILY } from '../styles/Fonts' import { completeRegistrationFlow, getExperienceReset, isGlobalListeningLaunchPeriodActive, } from '../utils/registrationFlow' const RegistrationChoice = () => { const [loadingChoice, setLoadingChoice] = useState(null) const [, setTooltip] = useGlobal('_tooltip') const openPayment = useCallback((experience) => { navigate(Routes.Payments, { registrationFlow: true, registrationChoice: experience, }) }, []) const handleListen = useCallback(async () => { if (!isGlobalListeningLaunchPeriodActive()) { openPayment('listen') return } try { setLoadingChoice('listen') await completeRegistrationFlow('listen') reset(getExperienceReset('listen')) } catch (error) { setTooltip({ type: 'error', text: error?.message || 'Impossible d’ouvrir l’espace Écoute', }) } finally { setLoadingChoice(null) } }, [openPayment, setTooltip]) const handleCreation = useCallback(() => { openPayment('creation') }, [openPayment]) return ( Que veux-tu faire en premier ? Tu pourras passer librement de la création à l’écoute après cette étape. Création Commence ton parcours avec les 10 crédits offerts à ton inscription. Écoute Retrouve les créations de la communauté dans l’espace Streaming. ) } const styles = StyleSheet.create({ pageContent: { flex: 1, alignItems: 'center', justifyContent: 'center', }, container: { width: '100%', }, content: { gap: 24, paddingHorizontal: 8, }, heading: { alignItems: 'center', gap: 8, marginBottom: 4, }, title: { color: Palette.white, fontFamily: FONT_FAMILY.InterSemiBold, fontSize: 24, textAlign: 'center', }, subtitle: { color: Palette.gray, fontFamily: FONT_FAMILY.InterRegular, fontSize: 14, lineHeight: 20, textAlign: 'center', }, choice: { gap: 16, }, choiceText: { gap: 6, }, choiceTitle: { color: Palette.white, fontFamily: FONT_FAMILY.InterSemiBold, fontSize: 19, }, choiceDescription: { color: Palette.gray, fontFamily: FONT_FAMILY.InterRegular, fontSize: 14, lineHeight: 20, }, button: { width: '100%', }, divider: { height: 1, backgroundColor: Palette.ultraLightWhite, }, }) export default RegistrationChoice