Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/components/calls/__tests__/call-notes-modal-new.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ jest.mock('react-native-keyboard-controller', () => ({
const { View } = require('react-native');
return <View testID="keyboard-aware-scroll-view">{children}</View>;
},
KeyboardStickyView: ({ children }: any) => {
KeyboardAvoidingView: ({ children }: any) => {
const { View } = require('react-native');
return <View testID="keyboard-sticky-view">{children}</View>;
return <View testID="keyboard-avoiding-view">{children}</View>;
Comment on lines +69 to +71

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Type and forward the keyboard wrapper props.

Line 69 uses prohibited any, and the mock drops behavior and keyboardVerticalOffset, so tests cannot detect regressions in this PR’s keyboard-avoidance configuration. Define a props interface, forward the props to View, and assert behavior="padding" and keyboardVerticalOffset={0}.

As per coding guidelines, “Never use any type; use precise types and interfaces with TypeScript strict mode enabled,” and generate Jest tests that validate generated components.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/calls/__tests__/call-notes-modal-new.test.tsx` around lines 69
- 71, Update the KeyboardAvoidingView mock to use a precise props interface
instead of any, including children, behavior, and keyboardVerticalOffset, and
forward those props to the rendered View. Add or update the Jest assertions to
verify behavior="padding" and keyboardVerticalOffset={0} on the
keyboard-avoiding wrapper.

Source: Coding guidelines

},
}));

Expand Down
78 changes: 38 additions & 40 deletions src/components/calls/call-notes-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useColorScheme } from 'nativewind';
import React, { useCallback, useEffect, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { FlatList, Keyboard, Modal, SafeAreaView, StyleSheet, TouchableOpacity, View } from 'react-native';
import { KeyboardStickyView } from 'react-native-keyboard-controller';
import { KeyboardAvoidingView } from 'react-native-keyboard-controller';

import { useAnalytics } from '@/hooks/use-analytics';
import { useAuthStore } from '@/lib/auth';
Expand All @@ -26,6 +26,8 @@ interface CallNotesModalProps {
callId: string;
}

const keyExtractor = (item: { CallNoteId: string }) => item.CallNoteId;

const CallNotesModal = ({ isOpen, onClose, callId }: CallNotesModalProps) => {
const { t } = useTranslation();
const { trackEvent } = useAnalytics();
Expand Down Expand Up @@ -106,44 +108,37 @@ const CallNotesModal = ({ isOpen, onClose, callId }: CallNotesModalProps) => {
return (
<Modal visible={isOpen} animationType="slide" presentationStyle="pageSheet" onRequestClose={handleClose}>
<SafeAreaView style={[styles.container, isDark && styles.containerDark]}>
{/* Header */}
<View style={[styles.header, isDark && styles.headerDark]}>
<Heading size="lg">{t('callNotes.title')}</Heading>
<TouchableOpacity onPress={handleClose} style={styles.closeButton} testID="close-button">
<X size={24} color={isDark ? '#D1D5DB' : '#374151'} />
</TouchableOpacity>
</View>

{/* Search Bar */}
<View style={styles.searchContainer}>
<Input className="w-full rounded-lg bg-gray-100 dark:bg-gray-700">
<InputSlot>
<SearchIcon size={20} className="text-gray-500" />
</InputSlot>
<InputField placeholder={t('callNotes.searchPlaceholder')} value={searchQuery} onChangeText={setSearchQuery} />
</Input>
</View>

{/* Notes List */}
<View style={styles.listContainer}>
{isNotesLoading ? (
<Loading />
) : filteredNotes.length > 0 ? (
<FlatList
data={filteredNotes}
renderItem={renderNote}
keyExtractor={(item) => item.CallNoteId}
contentContainerStyle={styles.listContent}
showsVerticalScrollIndicator={true}
keyboardShouldPersistTaps="handled"
/>
) : (
<ZeroState heading={t('callNotes.noNotesFound')} />
)}
</View>

{/* Add Note Section - Sticks to keyboard */}
<KeyboardStickyView offset={{ opened: 0, closed: 0 }}>
<KeyboardAvoidingView style={styles.keyboardAvoiding} behavior="padding" keyboardVerticalOffset={0}>
{/* Header */}
<View style={[styles.header, isDark && styles.headerDark]}>
<Heading size="lg">{t('callNotes.title')}</Heading>
<TouchableOpacity onPress={handleClose} style={styles.closeButton} testID="close-button">
<X size={24} color={isDark ? '#D1D5DB' : '#374151'} />
</TouchableOpacity>
</View>

{/* Search Bar */}
<View style={styles.searchContainer}>
<Input className="w-full rounded-lg bg-gray-100 dark:bg-gray-700">
<InputSlot>
<SearchIcon size={20} className="text-gray-500" />
</InputSlot>
<InputField placeholder={t('callNotes.searchPlaceholder')} value={searchQuery} onChangeText={setSearchQuery} />
</Input>
</View>

{/* Notes List */}
<View style={styles.listContainer}>
{isNotesLoading ? (
<Loading />
) : filteredNotes.length > 0 ? (
<FlatList data={filteredNotes} renderItem={renderNote} keyExtractor={keyExtractor} contentContainerStyle={styles.listContent} showsVerticalScrollIndicator={true} keyboardShouldPersistTaps="handled" />
) : (
<ZeroState heading={t('callNotes.noNotesFound')} />
)}
</View>

{/* Add Note Section */}
<View style={[styles.footer, isDark && styles.footerDark]}>
<VStack space="sm" className="w-full">
<Text className="font-medium">{t('callNotes.addNoteLabel')}</Text>
Expand All @@ -161,7 +156,7 @@ const CallNotesModal = ({ isOpen, onClose, callId }: CallNotesModalProps) => {
</Button>
</HStack>
</View>
</KeyboardStickyView>
</KeyboardAvoidingView>
</SafeAreaView>
</Modal>
);
Expand All @@ -175,6 +170,9 @@ const styles = StyleSheet.create({
containerDark: {
backgroundColor: '#1F2937',
},
keyboardAvoiding: {
flex: 1,
},
header: {
flexDirection: 'row',
alignItems: 'center',
Expand Down
29 changes: 3 additions & 26 deletions src/components/notifications/NotificationDetail.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { useNotifications } from '@novu/react-native';
import { ArrowLeft, Calendar, ExternalLink, Trash2 } from 'lucide-react-native';
import { colorScheme } from 'nativewind';
import React, { useEffect } from 'react';
import React from 'react';
import { Animated, Dimensions, Platform, Pressable, SafeAreaView, StatusBar, StyleSheet, Text, View } from 'react-native';

// Define the interface directly in this file
Expand Down Expand Up @@ -29,30 +28,8 @@ const SIDEBAR_WIDTH = Math.min(width * 0.85, 400);
const STATUS_BAR_HEIGHT = Platform.OS === 'ios' ? 44 : StatusBar.currentHeight || 0;

export const NotificationDetail = ({ notification, onClose, onDelete, onNavigateToReference }: NotificationDetailProps) => {
const { refetch } = useNotifications();
const slideAnim = React.useRef(new Animated.Value(SIDEBAR_WIDTH)).current;
const fadeAnim = React.useRef(new Animated.Value(0)).current;

useEffect(() => {
// Mark as read when opened - we'll just refetch to sync with server
if (!notification.read && notification.id) {
refetch();
}

// Animate in
Animated.parallel([
Animated.timing(slideAnim, {
toValue: 0,
duration: 300,
useNativeDriver: true,
}),
Animated.timing(fadeAnim, {
toValue: 1,
duration: 300,
useNativeDriver: true,
}),
]).start();
}, [notification, refetch, slideAnim, fadeAnim]);
const slideAnim = React.useRef(new Animated.Value(0)).current;
const fadeAnim = React.useRef(new Animated.Value(1)).current;
Comment thread
coderabbitai[bot] marked this conversation as resolved.

const handleClose = () => {
// Animate out
Expand Down
Loading
Loading