Skip to content

Commit 1b50ac5

Browse files
authored
Feature: History chats calls implementation (#154)
What does this PR do? Display Message chat history screen for appointments that happened between a patient and a doctor. It also shows completed appointments Description of Task to be completed? Fetch booked appointment details from the database Track appointment booked with the current time to mark it as booked if it is passed that time How should this be manually tested? Log in and go to history you can switch between messages where you will find what was discussed in chats you had with a doctor. Navigate to the appointment screens and click on completed appointment to see the appointments which are passed the current time as they are considered completed you can also leave a review when the appointment has been completed by clicking on the leave review button Any background context you want to provide? N/A
2 parents 480a2ad + a525f4e commit 1b50ac5

File tree

17 files changed

+269
-341
lines changed

17 files changed

+269
-341
lines changed

app/(tabs)/articles.tsx

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,7 @@ const Articles = () => {
66
return (
77
<>
88
<Article/>
9-
</>
10-
11-
12-
13-
14-
// <Article/>
15-
// <SeeAllArticles/>
16-
// <ArticlesDetails/>
17-
// <BookMarkedArticle/>
18-
19-
20-
9+
</>
2110
);
2211
};
2312

app/(tabs)/profile.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ const Profile = () => {
9090
nextTo: "notification",
9191
leftIcon: icons.notification,
9292
},
93-
{ text: t("profile.payment"), nextTo: "payment", leftIcon: icons.wallet },
93+
// { text: t("profile.payment"), nextTo: "payment", leftIcon: icons.wallet },
9494
{
9595
text: t("profile.security"),
9696
nextTo: "security",
@@ -101,12 +101,12 @@ const Profile = () => {
101101
nextTo: "language",
102102
leftIcon: icons.language,
103103
},
104-
{
105-
text: t("profile.dark_mode"),
106-
nextTo: "mode",
107-
leftIcon: icons.eye,
108-
mode: true,
109-
},
104+
// {
105+
// text: t("profile.dark_mode"),
106+
// nextTo: "mode",
107+
// leftIcon: icons.eye,
108+
// mode: true,
109+
// },
110110
{
111111
text: t("profile.help_center"),
112112
nextTo: "help",
@@ -192,9 +192,9 @@ const Profile = () => {
192192
{t("profile.title")}
193193
</Text>
194194
</View>
195-
<Touchable>
195+
{/* <Touchable>
196196
<SvgXml xml={moreOutlinedIcon} className="self-end" />
197-
</Touchable>
197+
</Touchable> */}
198198
</View>
199199
<ScrollView
200200
className="flex-1 p-6"

app/Appointments/voice-call/writeReview.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,4 +264,10 @@ const styles = StyleSheet.create({
264264
width: '100%',
265265
minHeight: 100,
266266
},
267+
doctorImage: {
268+
width: 120,
269+
height: 120,
270+
borderRadius: 60,
271+
marginBottom: 10,
272+
},
267273
});

app/Doctors/searchDoctor.tsx

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,44 +8,22 @@ import { View, Image, Animated,
88
Easing
99
} from "react-native";
1010
import { SearchInput } from "../../components/searchinput2";
11+
import { UIActivityIndicator } from "react-native-indicators";
1112

1213
export default function searchDoctor() {
1314

1415
const [selectedCategory, setSelectedCategory] = useState("all");
1516
const [searchQuery, setSearchQuery] = useState("");
1617
const [selectedRating, setSelectedRating] = useState(0);
17-
const rotateValue = new Animated.Value(0);
18-
const rotate = rotateValue.interpolate({
19-
inputRange: [0, 1],
20-
outputRange: ["0deg", "360deg"],
21-
});
18+
const [loading, setLoading]=useState(true);
2219

23-
const spin = () => {
24-
rotateValue.setValue(0);
25-
Animated.timing(rotateValue, {
26-
toValue: 1,
27-
duration: 2500,
28-
easing: Easing.linear,
29-
useNativeDriver: true,
30-
}).start(() => {
31-
setTimeout(() => {
32-
}, 2000);
33-
});
34-
};
35-
useEffect(() => {
36-
37-
spin();
38-
39-
}
40-
)
20+
4121

4222
return (
4323
<View className="flex-1 bg-white px-4 py-5">
4424
<View className="flex-1 justify-center items-center">
4525
<View>
46-
<Animated.View style={{ transform: [{ rotate }] }}>
47-
<Image source={require("../../assets/doctors/loading.png")} />
48-
</Animated.View>
26+
<UIActivityIndicator color={"#246BFD"} size={32} />
4927
</View>
5028
</View>
5129
</View>

app/articles/ArticlesDetails.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
Share,
1111
} from "react-native";
1212
import { supabase } from "../supabase";
13-
13+
import { UIActivityIndicator } from "react-native-indicators";
1414
interface Article {
1515
id: string;
1616
title: string;
@@ -209,11 +209,7 @@ export default function ArticlesDetails() {
209209
if (loading) {
210210
return (
211211
<View style={{ flex: 1, justifyContent: "center", alignItems: "center" }}>
212-
<Text
213-
style={{ fontSize: 20, fontFamily: "UrbanistBold", color: "#212121" }}
214-
>
215-
Loading...
216-
</Text>
212+
<UIActivityIndicator color={"#246BFD"} size={32} />
217213
</View>
218214
);
219215
}

app/articles/ArticlesPage.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { router, useLocalSearchParams, useNavigation } from "expo-router";
1212
import FieldComponent from "@/components/FieldComponent";
1313
import ArticleCard from "@/components/cards/ArticleCard";
1414
import { supabase } from "../supabase";
15-
15+
import { UIActivityIndicator } from "react-native-indicators";
1616
interface Article {
1717
id: number;
1818
title: string;
@@ -76,7 +76,7 @@ export default function Article() {
7676
if (loading) {
7777
return (
7878
<View style={styles.loadingContainer}>
79-
<Text style={styles.loadingText}>Loading...</Text>
79+
<UIActivityIndicator color={"#246BFD"} size={32} />
8080
</View>
8181
);
8282
}

app/articles/BookMarkedArticle.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
ScrollView,
1111
TouchableOpacity,
1212
} from "react-native";
13-
13+
import { UIActivityIndicator } from "react-native-indicators";
1414
interface Article {
1515
id: number;
1616
title: string;
@@ -133,7 +133,7 @@ export default function BookMarkedArticle() {
133133

134134
<ScrollView showsVerticalScrollIndicator={false}>
135135
{loading ? (
136-
<Text>Loading...</Text>
136+
<UIActivityIndicator color={"#246BFD"} size={32} />
137137
) : (
138138
bookmarkedArticles.map((article, index) => (
139139
<ArticleCard key={index} article={article} />

app/articles/SeeAllArticles.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { router, useNavigation } from "expo-router";
44
import FieldComponent from "@/components/FieldComponent";
55
import ArticleCard from "@/components/cards/ArticleCard";
66
import { supabase } from "../supabase";
7-
87
interface Article {
98
id: number;
109
title: string;

app/chat-history/VideoCall.tsx

Lines changed: 49 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,51 @@
1-
import React from "react";
2-
import { View, ScrollView } from "react-native";
3-
import DoctorVideo from "@/components/cards/DoctorVideo";
4-
import { useRouter } from "expo-router";
5-
import { DoctorCard } from "./types"; // Import the types
1+
// import React, {useState, useEffect} from "react";
2+
// import { View, ScrollView } from "react-native";
3+
// import DoctorVideo from "@/components/cards/DoctorVideo";
4+
// import { useRouter } from "expo-router";
5+
// import { DoctorCard } from "./types";
6+
// import { supabase } from "../supabase";
7+
// const VideoCall = () => {
8+
// const router = useRouter();
9+
// const [appointment, setAppointment]=useState<any[]>([]);
610

7-
const VideoCall = () => {
8-
const router = useRouter();
11+
// useEffect(()=>{
12+
// const fetchAppointments=async()=>{
13+
// const {data, error}=await supabase.auth.getUser();
14+
// if(error) throw error;
15+
// const userId=data?.user?.id;
16+
// const {data:AppointmentData, error:Error}=await supabase.from("appointment").select("*, doctor(name,image)").eq("patient_id", userId).eq("package","Video Call")
17+
// if(Error) throw Error
18+
// if(AppointmentData){
19+
// setAppointment(AppointmentData);
20+
// }
21+
// }
22+
// fetchAppointments();
23+
// },[])
24+
25+
// const handlePress = (appointmentId:any) => {
26+
// router.push({
27+
// pathname: "/chat-history/VideoRecord",
28+
// params: {appointmentId},
29+
// });
30+
// };
31+
// return (
32+
// <View style={{ backgroundColor: "white" }}>
33+
// <ScrollView style={{ backgroundColor: "#FAFAFA", paddingBottom: 6 }}>
34+
// {appointment.map((appointments, index) => (
35+
// <DoctorVideo
36+
// key={index}
37+
// onPress={() => handlePress(appointments.id)}
38+
// doctorName={appointments.doctor.name}
39+
// doctorImage={appointments.doctor.image}
40+
// callType={appointments.package}
41+
// callDay={appointments.appointment_date}
42+
// callTime={appointments.appointment_time.slice(0,5)}
43+
// isVideoCallScreen={false}
44+
// />
45+
// ))}
46+
// </ScrollView>
47+
// </View>
48+
// );
49+
// };
950

10-
const docCards: DoctorCard[] = [
11-
{
12-
name: "Dr. Randy Wigham",
13-
callDay: "Wednesday",
14-
callTime: "1:00 PM",
15-
images: require("../../assets/doctors/doc2.png"),
16-
},
17-
{
18-
name: "Dr. Jenny Watson",
19-
callDay: "Wednesday",
20-
callTime: "1:00 PM",
21-
images: require("../../assets/doctors/doc3.png"),
22-
},
23-
{
24-
name: "Dr. Raul Zirkind",
25-
callDay: "Wednesday",
26-
callTime: "1:00 PM",
27-
images: require("../../assets/doctors/doc1.png"),
28-
},
29-
{
30-
name: "Dr. Elijah Baranick",
31-
callDay: "Wednesday",
32-
callTime: "1:00 PM",
33-
images: require("../../assets/doctors/doc2.png"),
34-
},
35-
{
36-
name: "Dr. Stephen Shute",
37-
callDay: "Wednesday",
38-
callTime: "1:00 PM",
39-
images: require("../../assets/doctors/doc5.png"),
40-
},
41-
];
42-
43-
const handlePress = (doctor: DoctorCard) => {
44-
router.push({
45-
pathname: "/chat-history/VideoRecord",
46-
params: { doctor: JSON.stringify(doctor) },
47-
});
48-
};
49-
50-
return (
51-
<View style={{ backgroundColor: "white" }}>
52-
<ScrollView style={{ backgroundColor: "#FAFAFA", paddingBottom: 6 }}>
53-
{docCards.map((doctor, index) => (
54-
<DoctorVideo
55-
key={index}
56-
onPress={() => handlePress(doctor)}
57-
doctorName={doctor.name}
58-
doctorImage={doctor.images}
59-
callType="Video Call"
60-
callDay={doctor.callDay}
61-
callTime={doctor.callTime}
62-
isVideoCallScreen={false}
63-
/>
64-
))}
65-
</ScrollView>
66-
</View>
67-
);
68-
};
69-
70-
export default VideoCall;
51+
// export default VideoCall;

app/chat-history/VideoRecord.tsx

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,22 @@ import PlayButton from "@/components/cards/PlayButton";
1414
import { useRouter, useLocalSearchParams } from "expo-router";
1515
import { SvgXml } from "react-native-svg";
1616
import AsyncStorage from "@react-native-async-storage/async-storage";
17-
18-
import { DoctorCard } from "./types";
1917
import { moreTransparent } from "@/assets/icons/more";
2018
import { back } from "@/assets/icons/userprofile/icons";
19+
import { supabase } from "../supabase";
2120

2221
const VideoRecord: React.FC = () => {
2322
const router = useRouter();
24-
const { doctor: doctorString } = useLocalSearchParams();
25-
const doctor: DoctorCard = doctorString
26-
? JSON.parse(doctorString as string)
27-
: null;
28-
23+
24+
25+
const {appointmentId}=useLocalSearchParams();
2926
const [modalVisible, setModalVisible] = useState(false);
3027
const [videoDuration, setVideoDuration] = useState<number>(0);
28+
const[ name, setName]=useState("");
29+
const[date, setDate]=useState("");
30+
const[time, setTime]=useState("");
31+
const[packageType, setPackage]=useState("");
32+
const[image, setImage]=useState("");
3133

3234
useEffect(() => {
3335
const fetchDuration = async () => {
@@ -40,9 +42,7 @@ const VideoRecord: React.FC = () => {
4042
fetchDuration();
4143
}, []);
4244

43-
if (!doctor) {
44-
return null;
45-
}
45+
4646

4747
const handlePress = () => {
4848
router.push("/chat-history/PlayRecord");
@@ -64,7 +64,7 @@ const VideoRecord: React.FC = () => {
6464
setModalVisible(false);
6565
};
6666

67-
const { name, images, callDay, callTime } = doctor;
67+
6868

6969
const formatTime = (timeInSeconds: number) => {
7070
const hours = Math.floor(timeInSeconds / 3600);
@@ -79,6 +79,21 @@ const VideoRecord: React.FC = () => {
7979
return `${minutes}:${String(seconds).padStart(2, "0")} minutes`;
8080
}
8181
};
82+
useEffect(()=>{
83+
const fetchAppointments=async()=>{
84+
const {data:AppointmentData, error:Error}=await supabase.from("appointment").select("*, doctor(name,image)").eq("id",appointmentId).single();
85+
if(Error) throw Error
86+
if(AppointmentData){
87+
setName(AppointmentData.doctor.name);
88+
setPackage(AppointmentData.package);
89+
setImage(AppointmentData.doctor.image);
90+
setTime(AppointmentData.appointment_time);
91+
setDate(AppointmentData.appointment_date);
92+
93+
}
94+
}
95+
fetchAppointments();
96+
},[appointmentId])
8297

8398
return (
8499
<SafeAreaView style={areaView}>
@@ -89,12 +104,12 @@ const VideoRecord: React.FC = () => {
89104
<SvgXml xml={moreTransparent} onPress={handleMorePress} />
90105
</View>
91106
<View style={{ rowGap: 28, backgroundColor: "#FAFAFA" }}>
92-
<DoctorVideo
107+
<DoctorVideo
93108
doctorName={name}
94-
doctorImage={images}
95-
callType="Video Call"
96-
callDay={callDay}
97-
callTime={callTime}
109+
doctorImage={image}
110+
callType={packageType}
111+
callDay={date}
112+
callTime={time.slice(0, 5)}
98113
isVideoCallScreen={true}
99114
/>
100115
<View

0 commit comments

Comments
 (0)