Skip to content

Commit

Permalink
resolved 3rd conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
JAYATEJA04 committed Jul 29, 2023
1 parent 8c1adfc commit 0efc902
Show file tree
Hide file tree
Showing 12 changed files with 126 additions and 85 deletions.
4 changes: 2 additions & 2 deletions __tests__/Goals/GoalsScreen-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import GoalScreen from '../../src/screens/GoalScreen/GoalScreen';

test('renders GoalScreen correctly', () => {
const { getByTestId } = render(<GoalScreen />);

// Verify that the TodoComponent is rendered
const todoComponent = getByTestId('todo-component');
expect(todoComponent).toBeTruthy();

// TODO: Add assertions for ShortGoalsComponent and LongGoalsComponent once they are implemented.
});
27 changes: 24 additions & 3 deletions __tests__/Goals/components/Card-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,14 @@ describe('Card', () => {

test('renders task correctly', () => {
const { getByText } = render(
<Card item={item} posStyle="relative" changecard={() => {}} removeCard={() => {}} disabled={false} setDisabled={() => {}} />
<Card
item={item}
posStyle="relative"
changecard={() => {}}
removeCard={() => {}}
disabled={false}
setDisabled={() => {}}
/>,
);
const taskElement = getByText('Sample Task');
expect(taskElement).toBeTruthy();
Expand All @@ -20,7 +27,14 @@ describe('Card', () => {
test('calls changecard function when pan gesture ends with translateY > 100', () => {
const changecardMock = jest.fn();
const { getByTestId } = render(
<Card item={item} posStyle="relative" changecard={changecardMock} removeCard={() => {}} disabled={false} setDisabled={() => {}} />
<Card
item={item}
posStyle="relative"
changecard={changecardMock}
removeCard={() => {}}
disabled={false}
setDisabled={() => {}}
/>,
);
const animatedView = getByTestId('animated-view');
fireEvent.panEnd(animatedView, { translationY: 150 });
Expand All @@ -29,7 +43,14 @@ describe('Card', () => {

test('marks the card as done and shows a toast message when "Mark Done" button is pressed', () => {
const { getByTestId, getByText } = render(
<Card item={item} posStyle="relative" changecard={() => {}} removeCard={() => {}} disabled={false} setDisabled={() => {}} />
<Card
item={item}
posStyle="relative"
changecard={() => {}}
removeCard={() => {}}
disabled={false}
setDisabled={() => {}}
/>,
);
const markDoneButton = getByTestId('doneBtn');
fireEvent.press(markDoneButton);
Expand Down
17 changes: 13 additions & 4 deletions __tests__/Goals/components/Create-Goals-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ describe('MainScreen', () => {
test('renders title and input fields correctly', () => {
const { getByText, getByPlaceholderText } = render(<MembersPage />);
const titleText = getByText('Add New Goal');
const titleInput = getByPlaceholderText('Enter title max of 50 characters.');
const titleInput = getByPlaceholderText(
'Enter title max of 50 characters.',
);
const descriptionInput = getByPlaceholderText('Enter max 200 characters.');
expect(titleText).toBeTruthy();
expect(titleInput).toBeTruthy();
Expand All @@ -15,15 +17,22 @@ describe('MainScreen', () => {

test('navigates to MemberScreen when "Assigned To" is pressed', () => {
const navigateMock = jest.fn();
const { getByText } = render(<MembersPage navigation={{ navigate: navigateMock }} />);
const { getByText } = render(
<MembersPage navigation={{ navigate: navigateMock }} />,
);
const assignedToText = getByText("Enter member's name");
fireEvent.press(assignedToText);
expect(navigateMock).toHaveBeenCalledWith("Member's page", expect.any(Object));
expect(navigateMock).toHaveBeenCalledWith(
"Member's page",
expect.any(Object),
);
});

test('navigates to FormScreen when "Create" button is pressed', () => {
const navigateMock = jest.fn();
const { getByText } = render(<MembersPage navigation={{ push: navigateMock }} />);
const { getByText } = render(
<MembersPage navigation={{ push: navigateMock }} />,
);
const createButton = getByText('Create');
fireEvent.press(createButton);
expect(navigateMock).toHaveBeenCalledWith('Form screen');
Expand Down
12 changes: 9 additions & 3 deletions __tests__/Goals/components/TodoComponent-text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,27 @@ import TodoComponent from '../../../src/components/ToDoComponent/TodoComponent';
describe('TodoComponent', () => {
test('renders title correctly', () => {
const navigationProp = { navigate: jest.fn() };
const { getByText } = render(<TodoComponent navigationProp={navigationProp} />);
const { getByText } = render(
<TodoComponent navigationProp={navigationProp} />,
);
const titleElement = getByText("To Do's");
expect(titleElement).toBeTruthy();
});

test('renders "Add" button correctly', () => {
const navigationProp = { navigate: jest.fn() };
const { getByText } = render(<TodoComponent navigationProp={navigationProp} />);
const { getByText } = render(
<TodoComponent navigationProp={navigationProp} />,
);
const addButton = getByText('Add');
expect(addButton).toBeTruthy();
});

test('calls navigationProp.navigate when "Add" button is pressed', () => {
const navigationProp = { navigate: jest.fn() };
const { getByText } = render(<TodoComponent navigationProp={navigationProp} />);
const { getByText } = render(
<TodoComponent navigationProp={navigationProp} />,
);
const addButton = getByText('Add');
fireEvent.press(addButton);
expect(navigationProp.navigate).toHaveBeenCalledWith('CreatingGoals');
Expand Down
41 changes: 24 additions & 17 deletions src/components/SearchBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,42 @@ type SearchBarProps = {
setMembersData: ([]) => void;
};

type DisplayNameTypeProps ={
github_display_name?:string;
first_name?:string | undefined;
last_name?:string | undefined;
username?:string;
github_id?:string;
}

type DisplayNameTypeProps = {
github_display_name?: string;
first_name?: string | undefined;
last_name?: string | undefined;
username?: string;
github_id?: string;
};

const SearchBar = ({
setSearchValue,
searchValue,
membersData,
setMembersData,
}: SearchBarProps) => {
const searchFunction = (text: string) => {
const searchFunction = (text: string) => {
setSearchValue(text);
console.log('1',text)

const updatedData = text
? membersData?.filter((member) =>{
const { github_display_name,first_name,last_name,username, github_id } = member;
const assignedTo = username ?? github_display_name ?? github_id ?? first_name + last_name;
return assignedTo
?.toLowerCase()
.includes(text.toLowerCase())}
)
? membersData?.filter((member) => {
const {
github_display_name,
first_name,
last_name,
username,
github_id,
} = member;
const assignedTo =
username ??
github_display_name ??
github_id ??
first_name + last_name;
assignedTo?.toLowerCase().includes(text.toLowerCase());
})
: membersData;
setMembersData(updatedData)
setMembersData(updatedData);
};

return (
Expand Down
35 changes: 20 additions & 15 deletions src/components/ToDoComponent/RenderMemberItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,25 @@ import React from 'react';
import { useNavigation } from '@react-navigation/native';

type RenderMemberItemProps = {
item:DisplayNameType;
setSelectedMember:()=>void;
}
type DisplayNameType ={
github_display_name?:string;
first_name?:string;
last_name?:string
username?:string;
github_id?:string
}
const RenderMemberItem = ({ item, setSelectedMember }:RenderMemberItemProps) => {
item: DisplayNameType;
setSelectedMember: () => void;
};
type DisplayNameType = {
github_display_name?: string;
first_name?: string;
last_name?: string;
username?: string;
github_id?: string;
};
const RenderMemberItem = ({
item,
setSelectedMember,
}: RenderMemberItemProps) => {
const navigation = useNavigation();
const { github_display_name,first_name,last_name,username, github_id } = item;
const assignedTo = username ?? github_display_name ?? github_id ?? first_name + last_name
const { github_display_name, first_name, last_name, username, github_id } =
item;
const assignedTo =
username ?? github_display_name ?? github_id ?? first_name + last_name;

const handleSelectMember = (name: string) => {
setSelectedMember(name);
Expand All @@ -38,14 +43,14 @@ const styles = StyleSheet.create({
itemContainer: {
backgroundColor: '#FFFFFF',
padding: 12,
marginTop:10,
marginTop: 10,
marginBottom: 8,
borderRadius: 8,
},
itemText: {
fontSize: 16,
fontWeight: 'bold',
color: '#333333',
padding:4
padding: 4,
},
});
4 changes: 1 addition & 3 deletions src/components/ToDoComponent/SettingGoals/POST_API.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ const postData = async () => {
});
request = await request.json();
if (request.ok) {
Alert.alert(`Successfully created the goal.`);
} else {
Alert.alert(`${request.status}`);
Alert.alert('Successfully created the goal.');
}
};

Expand Down
10 changes: 5 additions & 5 deletions src/components/ToDoComponent/Styles/TodoStyles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ export const TodoStyles = StyleSheet.create({
position: 'relative',
top: 10,
},
flex:{
flexDirection:'row',
justifyContent:'space-between',
alignItems:'center'
}
flex: {
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
},
});
8 changes: 8 additions & 0 deletions src/components/ToDoComponent/TodoComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,15 @@ const TodoComponent = () => {
>
<Text style={{ color: 'black', elevation: 10 }}> Add</Text>
</TouchableOpacity>
<Text style={TodoStyles.title}>To Do's</Text>
<TouchableOpacity
style={styles.CreateGoalButton}
onPress={() => navigation.navigate('CreatingGoals')}
>
<Text style={{ color: 'black', elevation: 10 }}> Add</Text>
</TouchableOpacity>
</View>

<View style={{ paddingVertical: 35 }}>
{tasks?.length === 0 ? (
<Text style={TodoStyles.taskNotFound}>No tasks found</Text>
Expand Down
6 changes: 1 addition & 5 deletions src/constants/apiConstant/GoalsApi.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
const GoalsApi = {
MEMBERS_API : 'https://api.realdevsquad.com/members',
GET_TODO_S: 'https://backend-goals-production.up.railway.app/goal/',

MembersApi : 'https://api.realdevsquad.com/members',
}

export default GoalsApi
5 changes: 2 additions & 3 deletions src/screens/GoalScreen/GoalScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import CreatingGoals from '../../components/ToDoComponent/SettingGoals/CreateGoa
import MembersPage from '../MemberScreen/MembersPage';

const Stack = createNativeStackNavigator();
const GoalScreen = () => {
const GoalsScreen = () => {
return (
<ScrollView>
<TodoComponent data-testid="todo-component" />
Expand All @@ -27,10 +27,9 @@ function GoalsScreenStack() {
headerShown: false,
}}
>
<Stack.Screen name="GoalsScreen" component={GoalScreen} />
<Stack.Screen name="GoalsScreen" component={GoalsScreen} />
<Stack.Screen name="CreatingGoals" component={CreatingGoals} />
<Stack.Screen name="Member's page" component={MembersPage} />

</Stack.Navigator>
);
}
Expand Down
42 changes: 17 additions & 25 deletions src/screens/MemberScreen/MembersPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,31 +66,23 @@ const MembersPage = () => {
};

return (
errorState ??
renderError ??
loading ??
renderLoader ?? (
<View style={styles.container}>
<Text style={styles.title}>Real Dev Squad Member's</Text>
<SearchBar
setSearchValue={setSearchValue}
searchValue={searchValue}
membersData={filterMemberData}
setMembersData={setMembersData}
/>
<FlatList
data={membersData}
renderItem={({ item }) => (
<RenderMemberItem
item={item}
setSelectedMember={setSelectedMember}
/>
)}
keyExtractor={(item) => item.id}
ListFooterComponent={renderLoader}
/>
</View>
)
<View style={styles.container}>
<Text style={styles.title}>Real Dev Squad Member's</Text>
<SearchBar
setSearchValue={setSearchValue}
searchValue={searchValue}
membersData={filterMemberData}
setMembersData={setMembersData}
/>
<FlatList
data={membersData}
renderItem={({ item }) => (
<RenderMemberItem item={item} setSelectedMember={setSelectedMember} />
)}
keyExtractor={(item) => item.id}
ListFooterComponent={renderLoader}
/>
</View>
);
};

Expand Down

0 comments on commit 0efc902

Please sign in to comment.