import { useLocale } from 'next-intl';
import { useRouter } from 'next/navigation';
import { useCallback } from 'react';

export function useMyNavigation() {
    const locale = useLocale();
    const router = useRouter();

    const push = useCallback(
        (url: string) => {
            router.push(`/${locale}${url}`);
        },
        [locale]
    );

    const replace = useCallback(
        (url: string) => {
            router.replace(`/${locale}${url}`);
        },
        [locale]
    );

    return {
        push,
        replace,
        back: router.back,
    };
}
