Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | 2x 3x 3x 3x 3x 1x 1x 1x 3x | import { useCallback } from 'react';
import { SCREENS } from '@repo/constants/screens';
import { useEnableOldUI } from '@repo/hooks/flags';
import { useAuth } from '@/contexts/AuthContext';
import { AppStackScreenProps } from '@/types/navigation';
interface UseRequestNavigationProps {
navigation: AppStackScreenProps<typeof SCREENS.REQUEST_DETAIL>['navigation'];
fromDeepLink?: boolean;
}
export const useRequestNavigation = ({ navigation, fromDeepLink }: UseRequestNavigationProps) => {
const { user } = useAuth();
const { value: enableOldUI } = useEnableOldUI(user?.email);
const handlePressBack = useCallback(() => {
switch (true) {
case !fromDeepLink:
return navigation.goBack();
case enableOldUI:
return navigation.navigate(SCREENS.BOTTOM_TAB, { screen: SCREENS.HOME });
default:
return navigation.navigate(SCREENS.HOME_V2);
}
}, [navigation, fromDeepLink, enableOldUI]);
return { handlePressBack };
};
|