Skip to content

Commit 8e7f5be

Browse files
committed
ft: create user and chat rooms with a specific doctor
1 parent 57ba818 commit 8e7f5be

File tree

16 files changed

+6730
-3278
lines changed

16 files changed

+6730
-3278
lines changed

app.json

+5
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@
6565
{
6666
"photosPermission": "The app accesses your photos to let you share them with your friends."
6767
}
68+
], [
69+
"expo-av",
70+
{
71+
"microphonePermission": "$(PRODUCT_NAME) would like to use your microphone for voice recording."
72+
}
6873
]
6974
],
7075
"experiments": {

app/(app)/ActionMenu/Booking/EnterYourPin.tsx

+9-2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ export default function EnterYourPin() {
3535
}
3636
}
3737
console.log("this is from lastpage",doctor_id,hour,packageTitle,packagePrice,problem)
38+
39+
function successBooking() {
40+
router.push("(app)/Appointments/index");
41+
modal.hide();
42+
}
3843
async function handlePIN() {
3944

4045
await bookAppointment()
@@ -95,13 +100,15 @@ export default function EnterYourPin() {
95100
<Button
96101
title="View Appointment"
97102
onPress={() => {
98-
router.push("Appointments");
103+
router.push("(app)/Appointments");
104+
modal.hide();
105+
99106
}}
100107
/>
101108
<TouchableOpacity
102109
onPress={() => {
103-
modal.hide();
104110
router.push("ActionMenu");
111+
modal.hide();
105112
}}
106113
style={{
107114
backgroundColor:

app/(app)/ActionMenu/index.tsx

+9-17
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import {
1212
import React, { useContext, useEffect, useState } from "react";
1313
import { useFonts as useFontsExpo } from "expo-font";
1414
import { useNavigation } from "@react-navigation/native";
15-
import Line from "@/components/Line";
1615
import { router } from "expo-router";
1716
import { SvgXml } from "react-native-svg";
1817
import {
@@ -21,11 +20,6 @@ import {
2120
} from "@/assets/icons/Profile/Icons";
2221
import { ThemeContext } from "@/ctx/ThemeContext";
2322
import { blackHeart } from "@/components/UI/icons/blackHeart";
24-
import Chips from "@/components/UI/ChipsComponent";
25-
import {
26-
fullSmallBlueStar,
27-
fullSmallWhiteStar,
28-
} from "@/components/UI/icons/star";
2923
import { Session } from "@supabase/supabase-js";
3024
import { supabase } from "@/lib/supabase";
3125
import {
@@ -34,17 +28,15 @@ import {
3428
getPatientData,
3529
} from "@/utils/LoggedInUser";
3630
import { Doctor } from "@/constants/Types";
37-
import DoctorDetails from "./Booking/Doctor_details";
3831
import DoctorComponent from "@/components/DoctorComponent";
3932
import { star } from "@/assets/icons/star";
4033
import { whiteHeart } from "@/assets/icons/whiteHeart";
4134
import { blueheart } from '@/assets/icons/blueHeart';
4235
import NofoundComponent from "@/components/NofoundComponent";
43-
import { useAuth } from "@/ctx/AuthContext";
36+
import { AuthContext, useAuth } from "@/ctx/AuthContext";
4437
import RemovefavoritePopup from "@/components/RemovefavoriteIndexPopup";
4538

4639
export default function Index() {
47-
const [session, setSession] = useState<Session | null>(null);
4840
const [searchTerm, setSearchTerm] = useState<string>("");
4941
const [userData, setUserData] = useState<[]>([]);
5042
const [patientData, setPatientData] = useState(null);
@@ -54,7 +46,6 @@ export default function Index() {
5446
const { theme, changeTheme } = useContext(ThemeContext);
5547
const navigation = useNavigation();
5648
const [text, setText] = useState("");
57-
const [isLoading, setIsLoading] = useState(false);
5849
const [doctors, setDoctors] = useState<Doctor[]>([]);
5950
const [greeting, setGreeting] = useState("");
6051
const { authType, imageUrl: otherAuthImageUrl } = useAuth();
@@ -66,6 +57,7 @@ export default function Index() {
6657
const [favoriteDoctors, setFavoriteDoctors] = useState<number[]>([])
6758
const [loggeduser, setLoggedUser] = useState<string>()
6859
const [profile, setProfile] = useState<any>(null)
60+
const { userId } = useContext(AuthContext);
6961

7062
const [fontsLoaded] = useFontsExpo({
7163
"Urbanist-regular": require("@/assets/fonts/Urbanist-Regular.ttf"),
@@ -86,11 +78,11 @@ export default function Index() {
8678
}, []);
8779

8880
useEffect(() => {
89-
if (userData?.id) {
90-
fetchPatientData(userData?.id, setPatientData);
91-
getUserImageUrl("patients", userData, setImageUrl);
81+
if (userId ) {
82+
fetchPatientData(userId , setPatientData);
83+
getUserImageUrl("patients", userId , setImageUrl);
9284
}
93-
}, [userData]);
85+
}, [userId]);
9486

9587
useEffect(() => {
9688
if (imageUrl.length > 0) {
@@ -271,8 +263,8 @@ export default function Index() {
271263
source={{
272264
uri:authType && authType !== "apple"
273265
? otherAuthImageUrl
274-
: `${CDNURL + userData?.id + "/" + profilePhoto}`,
275-
}}
266+
: `${CDNURL + userId + "/" + profilePhoto}`,
267+
}}
276268
/>
277269
</View>
278270
<View
@@ -832,4 +824,4 @@ const styles = StyleSheet.create({
832824
color: "#246BFD",
833825
fontSize: 16,
834826
},
835-
});
827+
});

app/(app)/Appointments/MessagingAppointment/Camera.tsx

-105
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import React, { useContext, useEffect, useState } from 'react'
2+
import { fetchPatientData } from '@/utils/LoggedInUser';
3+
import { AuthContext } from '@/ctx/AuthContext';
4+
import {
5+
ChannelList
6+
} from 'stream-chat-expo'
7+
import { useAppContext } from '@/ctx/ChatContext';
8+
import { PatientTypes } from '@/constants/Types';
9+
import { router, Stack, useRouter } from 'expo-router';
10+
11+
const ChannelLists = (props: any) => {
12+
const { channel, setChannel } = useAppContext();
13+
const [patientData, setPatientData] = useState<PatientTypes[] | null>(null);
14+
const { userId, email, isLoggedIn } = useContext(AuthContext);
15+
const router = useRouter();
16+
17+
useEffect(() => {
18+
if (userId) {
19+
fetchPatientData(userId, setPatientData);
20+
}
21+
}, [userId]);
22+
let filters = {}
23+
if (patientData && patientData[0]) {
24+
filters = {
25+
members: {
26+
'$in': [`${patientData[0]?.id}`],
27+
},
28+
};
29+
}
30+
31+
const sort = {last_message_at: -1,};
32+
33+
const handleNavigateToChannel = (channel: any) => {
34+
setChannel(channel);
35+
router.push({
36+
pathname: "(app)/Appointments/MessagingAppointment/ChannelScreen",
37+
params: { id: channel?.id },
38+
});
39+
};
40+
41+
return (
42+
<ChannelList
43+
onSelect={(channel) => handleNavigateToChannel(channel)}
44+
filters={filters}
45+
sort={sort}
46+
/>
47+
)
48+
}
49+
50+
51+
export default ChannelLists
52+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import { View, Text, Image } from 'react-native'
2+
import React from 'react'
3+
import {
4+
Channel,
5+
MessageList,
6+
MessageInput,
7+
useMessageContext,
8+
} from 'stream-chat-expo'
9+
import { useAppContext, } from '@/ctx/ChatContext';
10+
import {Colors} from '@/constants/Colors';
11+
12+
const MessageStyle = () => {
13+
const { message, isMyMessage } = useMessageContext();
14+
15+
return (
16+
<View style={{
17+
alignSelf: isMyMessage ? 'flex-end' : 'flex-start',
18+
borderRadius: 10,
19+
maxWidth: '100%',
20+
maxHeight: 200,
21+
22+
}}>
23+
<Text style={{
24+
alignSelf: isMyMessage ? 'flex-end' : 'flex-start',
25+
backgroundColor: isMyMessage ? Colors.main.primary._500 : '#ededed',
26+
color:isMyMessage ? Colors.others.white : 'black',
27+
padding: 10,
28+
marginVertical : 10,
29+
marginHorizontal: 0,
30+
borderRadius: 10,
31+
width: '100%',
32+
}}>{message.text}</Text>
33+
</View>
34+
)
35+
}
36+
37+
38+
const ChannelScreen = () => {
39+
40+
const { channel } = useAppContext();
41+
return (
42+
<Channel channel={channel}
43+
// MessageText={MessageStyle}
44+
audioRecordingEnabled={true}
45+
enforceUniqueReaction={true}
46+
giphyEnabled={true}
47+
>
48+
<MessageList />
49+
<MessageInput />
50+
</Channel>
51+
52+
);
53+
};
54+
55+
export default ChannelScreen

0 commit comments

Comments
 (0)