Skip to content

Commit

Permalink
feat:history chats implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
Latiah committed Jul 10, 2024
1 parent 128acff commit e6c110f
Show file tree
Hide file tree
Showing 9 changed files with 271 additions and 323 deletions.
170 changes: 56 additions & 114 deletions app/Appointments/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ function Screen() {
const [notupcome, setNotupcome] = useState(false);
const [isModalVisible, setIsModalVisible] = useState(false);
const[appointmentData, setAppointmentData]=useState<any[]>([]);
const[completedAppointment, setCompletedAppointment]=useState<any[]>([]);
const { doctorId } = useLocalSearchParams<{ doctorId: string }>();

const handleUpcoming = () => {
Expand Down Expand Up @@ -54,7 +55,7 @@ function Screen() {
}
};

const fetchAppointment=async()=>{
const fetchAppointment=async()=>{
try{
const { data: userData, error: userError } = await supabase.auth.getUser();
if (userError) throw userError;
Expand All @@ -71,16 +72,13 @@ const{data, error}=await supabase
hospital
)
`)
.eq("patient_id", userId);
.eq("patient_id", userId).eq("status", "Booked").order("appointment_date", { ascending: false })
.order("appointment_time", { ascending: false })

if(error){
console.log("Error occured while fetching appointments", error)
}else{
setAppointmentData(data);
console.log("fetched data:");
setTimeout(()=>{
router.push("/(tabs)/appointment")
},0)
}}
catch(error){
console.log(error);
Expand All @@ -91,6 +89,43 @@ useEffect(()=>{
fetchAppointment();
},[])

const fetchCompletedAppointment=async()=>{
try{
const { data: userData, error: userError } = await supabase.auth.getUser();
if (userError) throw userError;
const userId = userData?.user?.id;
const{data, error}=await supabase
.from("appointment")
.select(`
*,
doctor(
id,
name,
role,
image,
hospital
)
`)
.eq("patient_id", userId)
.eq("status", "Completed").order("appointment_date", { ascending: false })
.order("appointment_time", { ascending: false })

if(error){
console.log("Error occured while fetching appointments", error)
}else{
setCompletedAppointment(data);

}}
catch(error){
console.log(error);
}
}
useEffect(()=>{

fetchCompletedAppointment();
},[])


const getPackageIcon = (typecall:any) => {
switch (typecall) {
case 'Voice Call':
Expand Down Expand Up @@ -219,60 +254,6 @@ const getPackageIcon = (typecall:any) => {
contentContainerStyle={styles.scrollViewContent}
showsVerticalScrollIndicator={false}
>
{/* {cancels && (
<View style={styles.content}>
<Cardcomponent
name="Dr.Mutoni Dach"
imager={require("../../assets/doctors/doc1.png")}
typecall="Voice call"
action="Cancelled"
date="Dec 12,2022"
time="16:00 PM"
imagerr={require("../../assets/appointmentIcon/voice.png")}
styles={styles.cancelStyles}
/>
<Cardcomponent
name="Dr.Keegan Dach"
imager={require("../../assets/doctors/doc2.png")}
typecall="Messaging"
action="Cancelled"
date="Dec 12,2022"
time="16:00 PM"
imagerr={require("../../assets/appointmentIcon/message.png")}
styles={styles.cancelStyles}
/>
<Cardcomponent
name="Dr.Drake Beison"
imager={require("../../assets/doctors/doc4.png")}
typecall="Video call"
action="Cancelled"
date="Dec 12,2022"
time="16:00 PM"
imagerr={require("../../assets/appointmentIcon/video.png")}
styles={styles.cancelStyles}
/>
<Cardcomponent
name="Dr.Tomas Slatter"
imager={require("../../assets/doctors/doc5.png")}
typecall="Voice call"
action="Cancelled"
date="Dec 12,2022"
time="16:00 PM"
imagerr={require("../../assets/appointmentIcon/voice.png")}
styles={styles.cancelStyles}
/>
<Cardcomponent
name="Dr.Quinn Muhawe"
imager={require("../../assets/doctors/doc3.png")}
typecall="Voice call"
action="Cancelled"
date="Dec 12,2022"
time="16:00 PM"
imagerr={require("../../assets/appointmentIcon/voice.png")}
styles={styles.cancelStyles}
/>
</View>
)} */}
{upcoming && (
<View style={styles.content}>
{appointmentData.map((appointment:any, index:any) => (
Expand All @@ -289,74 +270,35 @@ const getPackageIcon = (typecall:any) => {
backcad="bg-white rounded-xl flex-row p-4 w-400 items-center gap-7"
chance="Cancel Appointment"
cantchance="Reschedule"
// fact={() => router.push("/Appointments/reschedul")}
// cancle={() => setIsModalVisible(true)}
fact={() => router.push("/Appointments/reschedul")}
cancle={() => setIsModalVisible(true)}
/>
))}
</View>
)}

{/* {complete && (
{complete && (
<View style={styles.content}>
{completedAppointment.map((appointment:any, index:any) => (
<Cardscomponent
name="Dr.Raul Kamanzi"
imager={require("../../assets/doctors/doc1.png")}
typecall="Voice call"
key={index}
name={appointment.doctor.name}
imager={appointment.doctor.image}
typecall={appointment.package}
action="Complete"
date="Dec 12,2022"
time="16:00 PM"
imagerr={require("../../assets/appointmentIcon/voice.png")}
date={appointment.appointment_date}
time={appointment.appointment_time.slice(0,5)}
imagerr={getPackageIcon(appointment.package)}
styles={styles.completeStyles}
chance="Book Again"
cantchance="Leave a Review"
backcad="bg-white rounded-xl flex-row p-4 w-400 items-center gap-7"
fact={() => router.push("/Appointments/voice-call/writeReview")}
/>
<Cardscomponent
name="Dr.Mutoni Dach"
imager={require("../../assets/doctors/doc2.png")}
typecall="Messaging"
action="Complete"
date="Dec 12,2022"
time="16:00 PM"
imagerr={require("../../assets/appointmentIcon/message.png")}
styles={styles.completeStyles}
chance="Book Again"
cantchance="Leave a Review"
backcad="bg-white rounded-xl flex-row p-4 w-400 items-center gap-7"
fact={() => router.push("/Appointments/voice-call/writeReview")}
/>
<Cardscomponent
name="Dr.Drake Beison"
imager={require("../../assets/doctors/doc5.png")}
typecall="Video call"
action="Complete"
date="Dec 12,2022"
time="16:00 PM"
imagerr={require("../../assets/appointmentIcon/video.png")}
styles={styles.completeStyles}
chance="Book Again"
cantchance="Leave a Review"
backcad="bg-white rounded-xl flex-row p-4 w-400 items-center gap-7"
fact={() => router.push("/Appointments/voice-call/writeReview")}
/>
<Cardscomponent
name="Dr.Quinn Slatter"
imager={require("../../assets/doctors/doc3.png")}
typecall="Voice call"
action="Complete"
date="Dec 12,2022"
time="16:00 PM"
imagerr={require("../../assets/appointmentIcon/voice.png")}
styles={styles.completeStyles}
chance="Book Again"
cantchance="Leave a Review"
backcad="bg-white rounded-xl flex-row p-4 w-400 items-center gap-7"
fact={() => router.push("/Appointments/voice-call/writeReview")}
fact={() => router.push({pathname:"/Appointments/voice-call/writeReview",
params:{appointmentId:appointment.doctor.id}})}
/>
))}
</View>
)} */}
)}
</ScrollView>

{notupcome && (
Expand Down
38 changes: 25 additions & 13 deletions app/Appointments/voice-call/writeReview.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React, { useState, useEffect } from "react";
import { View, Text, TouchableOpacity, Image, TextInput, StyleSheet, Modal, ScrollView, SafeAreaView, Pressable } from "react-native";
import { router } from "expo-router";
import { router, useLocalSearchParams } from "expo-router";
import { useFonts } from 'expo-font';
import FiveStarRating from "../doctorcard/star";
import { supabase } from "@/app/supabase";

interface CustomCheckBoxProps {
selected: boolean;
Expand All @@ -21,25 +22,30 @@ export default function Writereview() {
const [isModalVisible, setIsModalVisible] = useState(false);
const [isoption, setIsoption] = useState("");
const [text, setText] = useState('');
const [fontLoaded] = useFonts({
'UrbanistBold': require('../../../assets/fonts/Urbanist-Bold.ttf'),
'UrbanistRegular': require("../../../assets/fonts/Urbanist-Regular.ttf"),
'Urbanist-SemiBold': require("../../../assets/fonts/Urbanist-SemiBold.ttf"),
'UrbanistMedium': require("../../../assets/fonts/Urbanist-Medium.ttf")
});
const [name, setName]=useState("");
const [image, setImage]=useState("");
const {appointmentId}=useLocalSearchParams();

const handleChangeText = (value: string) => {
setText(value);
};

const isSubmitEnabled = text.trim().length > 0 && isoption.length > 0;

if (!fontLoaded) {
return null;
}


const Options = ["Yes", "No"];

useEffect(()=>{
const fetchDoctor=async()=>{
const {data, error}=await supabase.from("doctor").select("*").eq("id",appointmentId).single();
if(data){
setName(data.name);
console.log(data.name);
setImage(data.image)
}
if (error) throw error}
fetchDoctor()},[])
return (
<>
<Modal
Expand Down Expand Up @@ -71,10 +77,10 @@ export default function Writereview() {
<Text className="text-[#212121] font-UrbanistBold text-[24px] pl-5">Write a Review</Text>
</View>
<View className="w-[370px] flex justify-center items-center gap-5 mb-2">
<Image source={require("../../../assets/doctors/Ellipse.png")} />
<Image source={{uri:image}} style={styles.doctorImage}/>
<View>
<Text className="text-[#212121] font-UrbanistBold text-[20px] text-center">How was your experience </Text>
<Text className="text-[#212121] font-UrbanistBold text-[20px] text-center">with Dr. Drake Boeson?</Text>
<Text className="text-[#212121] font-UrbanistBold text-[20px] text-center">with {name}?</Text>
</View>
<View className=" w-[350px] flex flex-row justify-center pb-3">
<SafeAreaView>
Expand All @@ -92,7 +98,7 @@ export default function Writereview() {
placeholder="Your review here..."
style={styles.textInput}
/>
<Text className="text-[#212121] font-UrbanistBold text-[20px] pb-5 pt-3">Would you recommend Dr. Drake Boeson to your friends?</Text>
<Text className="text-[#212121] font-UrbanistBold text-[20px] pb-5 pt-3">Would you recommend {name} to your friends?</Text>
<View className="flex flex-row items-center pl-2 justify-between w-[130px]">
{Options.map((option, index) => (
<View key={index} className="flex flex-row items-center justify-center gap-2">
Expand Down Expand Up @@ -184,4 +190,10 @@ const styles = StyleSheet.create({
width: '100%',
minHeight: 100,
},
doctorImage: {
width: 120,
height: 120,
borderRadius: 60,
marginBottom: 10,
},
});
Loading

0 comments on commit e6c110f

Please sign in to comment.