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

100% Statements 13/13
100% Branches 0/0
100% Functions 7/7
100% Lines 12/12

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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143                                            2x 3x 3x   3x                                                                                   3x 3x     3x       1x                       18x     18x 3x                     3x                                                                              
import { Text, TouchableOpacity, View } from 'react-native';
 
import { FlashList } from '@shopify/flash-list';
 
import { ScreenLayout } from '@repo/ui/components/ScreenLayout';
import { BrandIcon } from '@repo/ui/icons/Brand';
import { BuildingIcon } from '@repo/ui/icons/Building';
import { CalendarIcon } from '@repo/ui/icons/Calendar';
import { ChevronLeftIcon } from '@repo/ui/icons/ChevronLeft';
import { ExchangeIcon } from '@repo/ui/icons/Exchange';
import { FoodPlateIcon } from '@repo/ui/icons/FoodPlate';
import { GearIcon } from '@repo/ui/icons/Gear';
import { HomeIcon } from '@repo/ui/icons/Home';
import { makeStyles } from '@repo/ui/themes/makeStyles';
import { useTheme } from '@repo/ui/themes/ThemeContext';
 
import { SCREENS } from '@repo/constants/screens';
 
import type { AppStackParamList, AppStackScreenProps } from '@/types/navigation';
 
type NewRequestScreenProps = AppStackScreenProps<typeof SCREENS.NEW_REQUEST>;
 
export const NewRequestScreen = ({ navigation }: NewRequestScreenProps) => {
  const { theme } = useTheme();
  const styles = useStyles();
 
  const MENU_ITEMS = [
    {
      title: 'Time Off',
      icon: <CalendarIcon color={theme.colors.icon.active} />,
      path: SCREENS.TIME_OFF,
    },
    {
      title: 'Book a Room',
      icon: <BuildingIcon color={theme.colors.icon.active} />,
      path: SCREENS.BOOK_ROOM,
    },
    {
      title: 'Reallocation',
 
      icon: <ExchangeIcon color={theme.colors.icon.active} />,
      path: SCREENS.REALLOCATION,
    },
    {
      title: 'Maintenace',
 
      icon: <GearIcon color={theme.colors.icon.active} />,
      path: SCREENS.MAINTENANCE,
    },
    {
      title: 'Meal Reservation',
 
      icon: <FoodPlateIcon color={theme.colors.icon.active} />,
      path: SCREENS.MEAL_RESERVATION,
    },
    {
      title: 'Home Screen V2',
      icon: (
        <HomeIcon
          color={theme.colors.icon.active}
          width={theme.metrics.iconSize[32]}
          height={theme.metrics.iconSize[32]}
        />
      ),
      path: SCREENS.HOME_V2,
    },
  ];
 
  const handlePress = (screen: Exclude<keyof AppStackParamList, typeof SCREENS.REQUEST_DETAIL>) => {
    navigation.navigate(screen);
  };
 
  return (
    <ScreenLayout style={styles.container}>
      <View style={styles.header}>
        <TouchableOpacity
          onPress={() => navigation.goBack()}
          accessibilityRole="button"
          accessibilityLabel="Go back"
        >
          <ChevronLeftIcon />
        </TouchableOpacity>
        <BrandIcon />
        <View style={styles.spacer} />
      </View>
 
      <FlashList
        data={MENU_ITEMS}
        keyExtractor={item => item.title}
        contentContainerStyle={styles.list}
        renderItem={({ item }) => {
          return (
            <TouchableOpacity style={[styles.item]} onPress={() => handlePress(item.path)}>
              {item.icon}
              <Text style={styles.itemTitle}>{item.title}</Text>
            </TouchableOpacity>
          );
        }}
      />
    </ScreenLayout>
  );
};
 
const useStyles = makeStyles(theme => ({
  container: {
    padding: theme.metrics.spacing[4],
    gap: theme.metrics.spacing[12.5],
  },
  header: {
    flexDirection: 'row',
    alignItems: 'center',
    justifyContent: 'space-between',
  },
  item: {
    flexDirection: 'row',
    alignItems: 'center',
    padding: theme.metrics.spacing[5],
    borderWidth: theme.metrics.borderWidth.default,
    borderColor: theme.colors.border.default,
    borderRadius: theme.metrics.borderRadius[3],
    backgroundColor: theme.colors.background.default,
    gap: theme.metrics.spacing[3],
    marginBottom: theme.metrics.spacing[1],
  },
  list: {
    flex: 1,
    paddingBottom: theme.metrics.spacing[4],
  },
  itemTitle: {
    fontSize: theme.metrics.textSize[16],
    fontWeight: theme.metrics.fontWeight.semiBold,
    color: theme.colors.text.primary,
  },
  itemDescription: {
    color: theme.colors.text.secondary,
  },
  spacer: {
    width: theme.metrics.iconSize[24],
  },
}));
 
export default NewRequestScreen;