@ -26,9 +26,13 @@ const SLIDER_ANSWERS_STORAGE_KEY = "marriage-slider-answers";
export type SliderPageProps = {
export type SliderPageProps = {
onClose ? : ( ) = > void ;
onClose ? : ( ) = > void ;
onComplete ? : ( targetPath : string ) = > void ;
} ;
} ;
export default function SliderPage ( { onClose } : SliderPageProps = { } ) {
export default function SliderPage ( {
onClose ,
onComplete ,
} : SliderPageProps = { } ) {
const router = useRouter ( ) ;
const router = useRouter ( ) ;
const { locale } = useI18n ( ) ;
const { locale } = useI18n ( ) ;
const [ activeSlide , setActiveSlide ] = useState ( 0 ) ;
const [ activeSlide , setActiveSlide ] = useState ( 0 ) ;
@ -114,7 +118,15 @@ export default function SliderPage({ onClose }: SliderPageProps = {}) {
window . localStorage . removeItem ( SLIDER_ANSWERS_STORAGE_KEY ) ;
window . localStorage . removeItem ( SLIDER_ANSWERS_STORAGE_KEY ) ;
}
}
router . replace ( localizePath ( getSubmitPath ( freshProfile ) , locale ) ) ;
const targetPath = getSubmitPath ( freshProfile ) ;
const localizedTarget = localizePath ( targetPath , locale ) ;
router . prefetch ( localizedTarget ) ;
if ( onComplete ) {
onComplete ( targetPath ) ;
} else {
router . replace ( localizedTarget ) ;
}
} catch ( error ) {
} catch ( error ) {
console . error ( "Failed to complete onboarding:" , error ) ;
console . error ( "Failed to complete onboarding:" , error ) ;
setSubmitError ( t [ "Failed to update profile basic details. Please try again." ] || "Failed to update profile basic details. Please try again." ) ;
setSubmitError ( t [ "Failed to update profile basic details. Please try again." ] || "Failed to update profile basic details. Please try again." ) ;
@ -279,13 +291,14 @@ type SliderStepActionsProps = {
} ;
} ;
function SliderStepActions ( { onBack , onNext } : SliderStepActionsProps ) {
function SliderStepActions ( { onBack , onNext } : SliderStepActionsProps ) {
const { dictionary : t } = useI18n ( ) ;
return (
return (
< div className = "flex items-center gap-3 [&>button]:flex-1" >
< div className = "flex items-center gap-3 [&>button]:flex-1" >
< Button variant = "outlined" arrowDirection = "left" onClick = { onBack } >
< Button variant = "outlined" arrowDirection = "left" onClick = { onBack } >
Back
{ t [ " Back" ] || t [ "back" ] || "Back" }
< / Button >
< / Button >
< Button arrowDirection = "right" onClick = { onNext } >
< Button arrowDirection = "right" onClick = { onNext } >
Next
{ t [ " Next" ] || t [ "next" ] || "Next" }
< / Button >
< / Button >
< / div >
< / div >
) ;
) ;
@ -302,6 +315,7 @@ function SliderFinalActions({
onBack ,
onBack ,
onFinish ,
onFinish ,
} : SliderFinalActionsProps ) {
} : SliderFinalActionsProps ) {
const { dictionary : t } = useI18n ( ) ;
return (
return (
< div className = "flex items-center gap-3 [&>button]:flex-1" >
< div className = "flex items-center gap-3 [&>button]:flex-1" >
< Button
< Button
@ -310,10 +324,10 @@ function SliderFinalActions({
disabled = { isFinishing }
disabled = { isFinishing }
onClick = { onBack }
onClick = { onBack }
>
>
Back
{ t [ " Back" ] || t [ "back" ] || "Back" }
< / Button >
< / Button >
< Button disabled = { isFinishing } isLoading = { isFinishing } onClick = { onFinish } >
< Button disabled = { isFinishing } isLoading = { isFinishing } onClick = { onFinish } >
Finish
{ t [ " Finish" ] || t [ "finish" ] || "Finish" }
< / Button >
< / Button >
< / div >
< / div >
) ;
) ;