diff --git a/apps/expo/src/app/workout/createNew/index.tsx b/apps/expo/src/app/workout/createNew/index.tsx
index 784506c9..0101d683 100644
--- a/apps/expo/src/app/workout/createNew/index.tsx
+++ b/apps/expo/src/app/workout/createNew/index.tsx
@@ -2,6 +2,7 @@ import React from 'react'
import {StyleSheet, View, Text, TouchableOpacity, TextInput, ScrollView } from 'react-native'
import { router } from 'expo-router'
import { SafeAreaView } from 'react-native-safe-area-context'
+import ExerciseList from '~/components/workout/exerciseList'
const styles = StyleSheet.create({
container: {
@@ -47,9 +48,8 @@ export default function createNew() {
-
-
-
+
+
@@ -58,6 +58,7 @@ export default function createNew() {
+
)
}
\ No newline at end of file
diff --git a/apps/expo/src/app/workout/startExisting/index.tsx b/apps/expo/src/app/workout/startExisting/index.tsx
index 508e11b5..f29c23fd 100644
--- a/apps/expo/src/app/workout/startExisting/index.tsx
+++ b/apps/expo/src/app/workout/startExisting/index.tsx
@@ -2,6 +2,7 @@ import React from 'react'
import {StyleSheet, View, Text, TouchableOpacity, TextInput, ScrollView } from 'react-native'
import { router } from 'expo-router'
import { SafeAreaView } from 'react-native-safe-area-context'
+import WorkoutList from '~/components/workout/workoutList'
const styles = StyleSheet.create({
container: {
@@ -14,7 +15,7 @@ export default function createNew() {
return (
-
+
router.back()}>
Back
@@ -27,17 +28,10 @@ export default function createNew() {
-
-
+
+
+
-
-
-
-
-
)
}
\ No newline at end of file
diff --git a/apps/expo/src/components/ui/search-bar/SearchBar.tsx b/apps/expo/src/components/ui/search-bar/SearchBar.tsx
index 1199939b..494c0b66 100644
--- a/apps/expo/src/components/ui/search-bar/SearchBar.tsx
+++ b/apps/expo/src/components/ui/search-bar/SearchBar.tsx
@@ -29,8 +29,8 @@ import { View } from 'react-native'
import { TextInput } from 'react-native-gesture-handler'
interface SearchBarProps {
- list: any[]
- setFilteredList: React.Dispatch>
+ list: any[] | undefined
+ setFilteredList: React.Dispatch>
filterBy: string
placeholder: string
}
@@ -38,15 +38,16 @@ interface SearchBarProps {
export default function SearchBar({ list, setFilteredList, filterBy, placeholder }: SearchBarProps) {
const [searchTerm, setSearchTerm] = useState('')
- useEffect(() => {
- setFilteredList(list.filter((item) => item[filterBy].toLowerCase().includes(searchTerm.toLowerCase())))
- }, [searchTerm])
+ if (list) {
+ useEffect(() => {
+ setFilteredList(list.filter((item) => item[filterBy].toLowerCase().includes(searchTerm.toLowerCase())))
+ }, [searchTerm])
+ }
return (
diff --git a/apps/expo/src/components/workout/exerciseList.tsx b/apps/expo/src/components/workout/exerciseList.tsx
new file mode 100644
index 00000000..8bc57529
--- /dev/null
+++ b/apps/expo/src/components/workout/exerciseList.tsx
@@ -0,0 +1,39 @@
+import { TouchableOpacity } from '@gorhom/bottom-sheet'
+import React, {useState} from 'react'
+import { Text, View } from 'react-native'
+import { ScrollView } from 'react-native-gesture-handler'
+
+import RotatingBarbellIcon from '~/components/notif/RotatingBarbellIcon'
+import { api } from '~/utils/api'
+
+export default function ExerciseList() {
+ const { data, isFetched, isFetching } = api.exercise.getAllExercises.useQuery()
+
+ const [selectExercise, setSelect] = useState<{[eid: number]: boolean }>({});
+
+ const selectToggle = (eid: number) => {
+ setSelect((prevState) => ({
+ prevState,
+ [eid]: !prevState[eid],
+ }));
+ };
+
+ const exercises =
+
+ {data?.map((exercise) =>
+ selectToggle(exercise.id)}>
+
+ {exercise.name}
+
+ )}
+
+
+ return (
+
+ {isFetching && }
+ {isFetched && exercises}
+
+ )
+}
diff --git a/apps/expo/src/components/workout/workoutList.tsx b/apps/expo/src/components/workout/workoutList.tsx
new file mode 100644
index 00000000..f38846a7
--- /dev/null
+++ b/apps/expo/src/components/workout/workoutList.tsx
@@ -0,0 +1,63 @@
+import React, { useState } from 'react'
+import { Text, TextInput, View } from 'react-native'
+import { ScrollView } from 'react-native-gesture-handler'
+
+import { TouchableOpacity } from '@gorhom/bottom-sheet'
+
+import RotatingBarbellIcon from '~/components/notif/RotatingBarbellIcon'
+import SearchBar from '~/components/ui/search-bar/SearchBar'
+import { api } from '~/utils/api'
+
+export default function WorkoutList() {
+ // Query data
+ const { data, isFetched, isFetching } = api.workout.getAllWorkouts.useQuery()
+
+ // Select an exercise
+ const [selectExercise, setSelect] = useState<{ [wid: number]: boolean }>({})
+ const selectToggle = (wid: number) => {
+ setSelect((prevState) => ({
+ [wid]: !prevState[wid],
+ }))
+ }
+
+ const [filteredList, setFilteredList] = useState(data)
+
+ const workouts = (
+
+
+
+
+
+ {filteredList?.map((workout) => (
+
+
+ selectToggle(workout.id)}
+ >
+ {workout.name}
+
+ {workout.description}
+
+
+
+
+ ))}
+
+
+ )
+
+ return (
+
+ {isFetched && workouts}
+ {isFetching && }
+
+ )
+}