All files / apps/host/src/screens/CreateRequestSuccess index.tsx

100% Statements 13/13
83.33% Branches 5/6
100% Functions 3/3
100% Lines 13/13

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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57                                              2x 5x 5x 5x   5x 5x   5x 1x     5x   5x 1x         5x             2x            
import { useCallback } from 'react';
import { StyleSheet, View } from 'react-native';
 
import { useFocusEffect, useRoute } from '@react-navigation/native';
 
import { useTheme } from '@repo/ui/themes/ThemeContext';
 
import { SCREENS } from '@repo/constants/screens';
 
import { RequestResolvedCard } from '@/components';
 
import { useChat } from '@/contexts';
 
import { useBlockBackNavigationWhileSubmitting } from '@/hooks';
 
import type { AppStackScreenProps } from '@/types/navigation';
 
type CreateRequestSuccessProps = AppStackScreenProps<typeof SCREENS.CREATE_REQUEST_SUCCESS>;
 
interface SuccessParams {
  message?: string;
}
 
export const CreateRequestSuccessScreen = ({ navigation }: CreateRequestSuccessProps) => {
  const { theme } = useTheme();
  const { setFabOffset, fabOffset } = useChat();
  useBlockBackNavigationWhileSubmitting(navigation, true);
 
  const route = useRoute();
  const { message } = (route.params as SuccessParams) || {};
 
  const handlePress = () => {
    navigation.navigate(SCREENS.HOME_V2);
  };
 
  useFocusEffect(
    useCallback(() => {
      if (fabOffset !== 0) {
        setFabOffset(0);
      }
    }, [fabOffset, setFabOffset]),
  );
 
  return (
    <View style={[styles.container, { backgroundColor: theme.colors.background.page }]}>
      <RequestResolvedCard text={message || 'YOUR REQUEST HAS BEEN SENT'} onPress={handlePress} />
    </View>
  );
};
 
const styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: 'center',
  },
});