Skip to content

Commit 20337da

Browse files
committed
Bug fix and updates
1 parent bec3fd7 commit 20337da

File tree

4 files changed

+75
-13
lines changed

4 files changed

+75
-13
lines changed

mobile/__tests__/App.test.js

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,18 @@ test('Renders Search Result Page Correctly', () => {
5353
expect(tree).toMatchSnapshot();
5454
});
5555

56-
test('Searches Correctly', async () => { /* TODO: Change the endpoints */
56+
test('Searches Correctly', async () => {
5757
const mockTitle = jest.fn();
5858
const mockImage = jest.fn();
59-
const mockCreator = jest.fn();
60-
const mockType = jest.fn();
61-
62-
const response = await apiInstance().post("search", { mockTitle, mockImage, mockCreator, mockType });
59+
const mockExercies = jest.fn();
60+
const mockName = jest.fn();
61+
const mockEquipment = jest.fn();
62+
const mockBodyPart = jest.fn();
63+
const mockInstruction = jest.fn();
64+
const mockTargetMuscle = jest.fn();
65+
const mockSecondaryMuscles = jest.fn();
66+
67+
const response = await apiInstance().post("search", { mockTitle, mockImage, mockExercies, mockName, mockEquipment, mockBodyPart, mockInstruction, mockTargetMuscle, mockSecondaryMuscles });
6368
expect(response).toBe( /* TODO: The Object That Returns */ );
6469
});
6570

@@ -72,11 +77,16 @@ test('Renders Create Post Page Correctly', () => {
7277

7378
test('Create Post Correctly', async () => {
7479
const mockTitle = jest.fn();
80+
const mockPost = jest.fn();
7581
const mockDescription = jest.fn();
82+
const mockImage = jest.fn();
7683
const mockLabels = jest.fn();
7784
const mockLabelTest = jest.fn();
85+
const mockProfile = jest.fn();
86+
const mockPassword = jest.fn();
87+
const mockSessionToken = jest.fn();
7888

79-
const response = await apiInstance().post("createPost", { mockTitle, mockDescription, mockLabels, mockLabelTest });
89+
const response = await apiInstance().post("createPost", { mockTitle, mockPost, mockDescription, mockImage, mockLabels, mockLabelTest, mockProfile, mockPassword, mockSessionToken });
8090
expect(response).toBe( /* TODO: The Object That Returns */ );
8191
});
8292

mobile/components/ProfilePage.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,14 @@ useEffect(() => {
175175
const programs = [
176176
{ id: 1, title: "Full Body Workout",
177177
description: "This is a comprehensive program targeting all major muscle groups.",
178-
trainerUsername: "fitness_guru_123",
178+
trainerUsername: "sametalan",
179+
participants:[
180+
"sametalan2",
181+
"Hanaaa",
182+
"deno",
183+
"fit_deniz"
184+
],
185+
createdAt:'2024-11-25T13:52:56.512941',
179186
exercises: [
180187
{ exercise:{
181188
name: "Push-Up",
@@ -204,7 +211,14 @@ useEffect(() => {
204211
]},
205212
{ id: 2, title: "Full Body Workout",
206213
description: "This is a comprehensive program targeting all major muscle groups.",
207-
trainerUsername: "fitness_guru_123",
214+
trainerUsername: "fit_deniz",
215+
participants:[
216+
"sametalan2",
217+
"Hanaaa",
218+
"deno",
219+
"fit_deniz"
220+
],
221+
createdAt:'2024-11-25T13:52:56.512941',
208222
exercises: [
209223
{ exercise:{
210224
name: "Push-Up",
@@ -353,7 +367,7 @@ useEffect(() => {
353367
{/* Profile Header */}
354368
<View style={styles.header}>
355369
<Image
356-
source={{ uri: 'https://via.placeholder.com/150' }} // Mock profile image
370+
source={{ uri: 'https://example.com/push-up.gif' }} // Mock profile image
357371
style={styles.profileImage}
358372
/>
359373
<Text style={styles.profileName}>{username}</Text>

mobile/components/ProgramCard.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const ProgramCard = ({ trainerUsername, title, description, exercises, date, par
55
return (
66
<TouchableOpacity
77
style={styles.card}
8-
onPress={() => navigation.navigate('ProgramDetail', { trainerUsername, title, description, exercises, navigation })}
8+
onPress={() => navigation.navigate('ProgramDetail', { trainerUsername, title, description, exercises, participants, date, navigation })}
99
>
1010
<TouchableOpacity onPress={() => navigation.navigate('UserProfile', { username: trainerUsername })}>
1111
<Text style={styles.owner}>{trainerUsername}</Text>

mobile/components/ProgramDetail.js

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
} from 'react-native';
1212

1313
const ProgramDetail = ({ route }) => {
14-
const { title, description, trainerUsername, exercises } = route.params;
14+
const { trainerUsername, title, description, exercises, date, participants, navigation } = route.params;
1515
/*const {title, description, trainerUsername, exercises} = {
1616
title: "Full Body Workout",
1717
description: "This is a comprehensive program targeting all major muscle groups.",
@@ -43,11 +43,19 @@ const ProgramDetail = ({ route }) => {
4343
}
4444
],
4545
}*/
46+
console.log(participants);
4647
const [expandedExercise, setExpandedExercise] = useState(null);
4748

4849
const toggleExerciseDetails = (index) => {
4950
setExpandedExercise(expandedExercise === index ? null : index);
5051
};
52+
const renderParticipant = ({ item, index }) => {
53+
return(
54+
<TouchableOpacity onPress={() => navigation.navigate('UserProfile', { username: item })}>
55+
<Text style={styles.owner}>{item}</Text>
56+
</TouchableOpacity>
57+
);
58+
}
5159

5260
const renderExercise = ({ item, index }) => {
5361
const isExpanded = expandedExercise === index;
@@ -100,11 +108,21 @@ const ProgramDetail = ({ route }) => {
100108
return (
101109
<ScrollView contentContainerStyle={styles.container}>
102110
<View style={styles.postContainer}>
103-
{/* Program Info */}
111+
{/* Participant Info */}
104112
<Text style={styles.title}>{title}</Text>
105113
<Text style={styles.owner}>{trainerUsername}</Text>
106114
<Text style={styles.description}>{description}</Text>
107115
</View>
116+
<View style={styles.participantsContainer}>
117+
<Text style={styles.participantListTitle}>Participants:</Text>
118+
<FlatList
119+
data={participants}
120+
keyExtractor={(item, index) => index.toString()}
121+
renderItem={renderParticipant}
122+
contentContainerStyle={styles.participantsList}
123+
/>
124+
</View>
125+
108126
{/* Exercises List */}
109127
<View style={styles.exercisesContainer}>
110128
<Text style={styles.exerciseListTitle}>Exercises:</Text>
@@ -185,7 +203,26 @@ container: {
185203
shadowColor: '#000',
186204
shadowOpacity: 0.1,
187205
shadowRadius: 5,
188-
marginBottom: 20},
206+
marginBottom: 20
207+
},
208+
participantListTitle: {
209+
fontSize: 18,
210+
fontWeight: 'bold',
211+
color: '#333',
212+
marginBottom: 10,
213+
},
214+
participantsList: {
215+
paddingBottom: 20,
216+
},
217+
participantsContainer:{
218+
backgroundColor: '#FFFFFF',
219+
borderRadius: 12,
220+
padding: 15,
221+
shadowColor: '#000',
222+
shadowOpacity: 0.1,
223+
shadowRadius: 5,
224+
marginBottom: 20
225+
},
189226
exerciseContainer: {
190227
backgroundColor: '#f9f9f9',
191228
borderRadius: 10,
@@ -196,6 +233,7 @@ container: {
196233
shadowRadius: 5,
197234
elevation: 2,
198235
},
236+
199237
exerciseHeader: {
200238
flexDirection: 'row',
201239
justifyContent: 'space-between',

0 commit comments

Comments
 (0)