diff --git a/app/(app)/ActionMenu/AllDoctorScreen.tsx b/app/(app)/ActionMenu/AllDoctorScreen.tsx new file mode 100644 index 00000000..e1fd100a --- /dev/null +++ b/app/(app)/ActionMenu/AllDoctorScreen.tsx @@ -0,0 +1,376 @@ +import React,{ReactElement, useEffect, useState} from 'react'; +import { StyleSheet, Text, Image, View, TouchableHighlight, SafeAreaView, Button, Alert, Platform, Dimensions,TextInput, ScrollView, Pressable} from 'react-native' +import { Feather } from '@expo/vector-icons'; +import { AntDesign } from '@expo/vector-icons'; +import { Ionicons } from '@expo/vector-icons'; +import DoctorComponent from '@/components/DoctorComponent'; +import { FontAwesome } from '@expo/vector-icons'; + import { SvgXml } from "react-native-svg" +import { WhiteHeart } from '@/components/UI/icons/WhiteHeart'; +import { star } from '@/assets/icons/star'; +import { search } from '@/assets/icons/search'; +import { more } from '@/assets/icons/more'; +import { leftArrow } from '@/assets/icons/left'; +import data from "../../doctors.json" +import HeaderComponent from '@/components/HeaderComponent'; +import SearchComponent from '@/components/SearchComponent'; +import FoundDoctorCount from '@/components/FoundDoctorCount'; +import NofoundComponent from '@/components/NofoundComponent'; +import RemovefavoritePopup from '@/components/RemovefavoritePopup'; +import FilterPopup from '@/components/FilterSearchComponent'; +import { StatusBar } from 'expo-status-bar'; +import NotFoundScreen from '@/app/+not-found'; +import { ThemeContext } from '@/ctx/ThemeContext'; +import { useContext } from 'react'; +import { supabase } from '@/lib/supabase'; + + + +const tableName = 'doctors' + + + + +interface imageMapProp{ + [key:string]:ReturnType +} + +const imageMap:imageMapProp = { + 'doctor1.png': require("../../../assets/images/Doctors/doctor1.png"), + 'doctor2.png': require("../../../assets/images/Doctors/doctor2.png"), + 'doctor3.png': require("../../../assets/images/Doctors/doctor3.png"), + 'doctor4.png': require("../../../assets/images/Doctors/doctor4.png"), + 'doctor5.png':require("../../../assets/images/Doctors/doctor5.png") + +} +interface iconMappingProp{ + [key :string]:ReactElement +} + + +interface Doctor{ + id: number, + first_name: string, + last_name: string, + hospital: string, + rate: string, + review: string, + specialization: string, + about:string +} +interface categoryProp{ + name: string, + Doctors:Doctor[] +} + +export const iconMapping:iconMappingProp = { + heart: , + star: , +} + + + +function DoctorScreen() { + const [showSearch, setShowSearch] = useState(false) + const [searchTerm, setSearchTerm] = useState('') + const [selectedCategory, setSelectedCategory] = useState(data.categories[0]) + const [showpopUp, setShowPopup] = useState(false) + const [selectedDoctor, setSelectedDoctor] = useState() + const [showFilter, setShowfilter] = useState(false) + const [doctors,setDoctors]=useState([]) + const { theme, changeTheme } = useContext(ThemeContext) + const containerStyle = theme === "dark" ? styles.outerDark : styles.outerLight + const scrollbackColor = theme === "dark" ? styles.scrollDark : styles.scrollLight + + useEffect(() => { + async function fetchData() { + const { data, error } = await supabase.from(tableName).select('*'); + + if (error) { + console.error('Error fetching data:', error); + return; + } + setDoctors(data) + + console.log('Fetched data:', data); +} + +fetchData(); + },[]) + + const handleSearchPressed = () => { + setShowSearch(true) + } + const handleSearchSubmit = (text: string) => { + setSearchTerm(text.toLowerCase()) + } + + const handleFilter = () => { + setShowfilter(true) + } + const handleRemove = (doctor:any) => { + setSelectedDoctor(doctor) + + setShowPopup(true) + } + + const filteredDoctors=searchTerm.length>0 ? doctors.filter(doctor=>doctor.last_name.toLowerCase().includes(searchTerm)):doctors + return ( + + + + + + { + !showSearch ? ( + + ) : ( + + + ) + } + + + + + {data.categories.map((category, index) => + + + {category.name} + + + )} + + + + + {showSearch && ( + + )} + + + + {filteredDoctors.length > 0 ? ( + + filteredDoctors.map((doctor: any, index: any) => + + + } + professionalTitle={doctor.specialization} + hospital={doctor.hospital} + star={} + review={doctor.review} + rate={doctor.rate} + remove={()=>handleRemove(doctor)} + + /> + + + ) + + ) : ( + + )} + + + + + + + + + + setShowPopup(false)} + visible={showpopUp} + onClose={() => setShowPopup(false)} + doctor={selectedDoctor} + + + /> + setShowfilter(false)} + visible={showFilter} + onClose={() => setShowfilter(false)} + + + + /> + + + + + + ); +} + +export default DoctorScreen; + +const styles = StyleSheet.create({ + container: { + flex: 1, + zIndex:1 + }, + outerDark: { + backgroundColor:"#181A20" + + }, + outerLight: { + backgroundColor: "white", + + }, + upper: { + display: "flex", + flexDirection: 'row', + justifyContent: "center", + alignItems: "center", + width:"100%", + marginBottom: "7%", + marginTop: "18%", + }, + foundDoctorView: { + width: "100%", + display: "flex", + flexDirection: 'row', + justifyContent: "center", + alignItems: "center" + }, + searchComponent: { + + }, + upperInner: { + width: "95%", + display: "flex", + flexDirection: 'row', + justifyContent: "space-between", + alignItems: "center", + }, + upperLeft: { + display: "flex", + flexDirection: "row", + justifyContent: 'space-between', + width: "70%", + height:"100%", + }, + categoryScroll: { + + }, + categoryBtnView: { + display:"flex", + flexDirection: "row", + alignItems: 'center', + marginBottom: "5%", + backgroundColor: "white", + }, + categoryBtn: { + borderWidth: 2, + borderColor: "#246BFD", + height: 40, + paddingHorizontal: 20, + paddingVertical:7, + borderRadius: 20, + display: "flex", + flexDirection: "row", + justifyContent: "center", + alignItems: "center", + marginRight: 8, + marginLeft:10 + }, + firstCategoryBtn: { + backgroundColor: "#246BFD" + }, + firstCategoryBtnText: { + color:"white" + }, + categoryBtnText: { + color: "#246BFD", + fontSize:16 + }, + body: { + width: "98%", + backgroundColor:"#F7F7F7", + }, + scroll: { + width: "100%", + height: "100%", + zIndex: 1, + }, + scrollDark: { + backgroundColor:"#181A20" + + }, + scrollLight: { + backgroundColor: "#F7F7F7" + + }, + searchView: { + display: "flex", + flexDirection: 'row', + justifyContent: "center", + alignItems: "center", + }, + moreOuter: { + display: "flex", + flexDirection: 'row', + justifyContent: "center", + alignItems: "center", + }, + Headstyle: { + color: "#212121", + fontWeight: "bold", + fontSize:20 + }, + NotificationView: { + width:"80%" + }, + componentView: { + marginBottom: "5%", + width: "100%", + height:150, + display: "flex", + flexDirection: 'row', + justifyContent: "center", + alignItems: "center", + }, + rightView: { + display: "flex", + flexDirection: "row", + justifyContent: 'space-between', + width:"25%" + }, + + +}) \ No newline at end of file diff --git a/app/(app)/ActionMenu/FavoriteDoctorScreen.tsx b/app/(app)/ActionMenu/FavoriteDoctorScreen.tsx index e45b3c26..e08434b2 100644 --- a/app/(app)/ActionMenu/FavoriteDoctorScreen.tsx +++ b/app/(app)/ActionMenu/FavoriteDoctorScreen.tsx @@ -1,332 +1,374 @@ -import React, { ReactElement, useContext, useState } from "react"; -import { - StyleSheet, - Text, - Image, - View, - TouchableHighlight, - SafeAreaView, - Button, - Alert, - Platform, - Dimensions, - TextInput, - ScrollView, - Pressable, -} from "react-native"; -import { Feather } from "@expo/vector-icons"; -import { AntDesign } from "@expo/vector-icons"; -import { Ionicons } from "@expo/vector-icons"; -import DoctorComponent from "@/components/DoctorComponent"; -import { FontAwesome } from "@expo/vector-icons"; -import { SvgXml } from "react-native-svg"; -import { blueheart } from "@/assets/icons/blueHeart"; -import { star } from "@/assets/icons/star"; -import { search } from "@/assets/icons/search"; -import { more } from "@/assets/icons/more"; -import { leftArrow } from "@/assets/icons/left"; -import data from "../../doctors.json"; -import HeaderComponent from "@/components/HeaderComponent"; -import SearchComponent from "@/components/SearchComponent"; -import FoundDoctorCount from "@/components/FoundDoctorCount"; -import NofoundComponent from "@/components/NofoundComponent"; -import RemovefavoritePopup from "@/components/RemovefavoritePopup"; -import FilterPopup from "@/components/FilterSearchComponent"; -import { StatusBar } from "expo-status-bar"; -import NotFoundScreen from "@/app/+not-found"; -import Chips from "@/components/UI/ChipsComponent"; -import { ThemeContext } from "@/ctx/ThemeContext"; +import React,{ReactElement, useEffect, useState} from 'react'; +import { StyleSheet, Text, Image, View, TouchableHighlight, SafeAreaView, Button, Alert, Platform, Dimensions,TextInput, ScrollView, Pressable} from 'react-native' +import { Feather } from '@expo/vector-icons'; +import { AntDesign } from '@expo/vector-icons'; +import { Ionicons } from '@expo/vector-icons'; +import DoctorComponent from '@/components/DoctorComponent'; +import { FontAwesome } from '@expo/vector-icons'; + import { SvgXml } from "react-native-svg" +import { blueheart } from '@/assets/icons/blueHeart'; +import { star } from '@/assets/icons/star'; +import { search } from '@/assets/icons/search'; +import { more } from '@/assets/icons/more'; +import { leftArrow } from '@/assets/icons/left'; +import data from "../../doctors.json" +import HeaderComponent from '@/components/HeaderComponent'; +import SearchComponent from '@/components/SearchComponent'; +import FoundDoctorCount from '@/components/FoundDoctorCount'; +import NofoundComponent from '@/components/NofoundComponent'; +import RemovefavoritePopup from '@/components/RemovefavoritePopup'; +import FilterPopup from '@/components/FilterSearchComponent'; +import { StatusBar } from 'expo-status-bar'; +import NotFoundScreen from '@/app/+not-found'; +import { ThemeContext } from '@/ctx/ThemeContext'; +import { useContext } from 'react'; +import { supabase } from '@/lib/supabase'; -interface imageMapProp { - [key: string]: ReturnType; + +const tableName = 'doctors' + + + + +interface imageMapProp{ + [key:string]:ReturnType } -const imageMap: imageMapProp = { - "doctor1.png": require("../../../assets/images/Doctors/doctor1.png"), - "doctor2.png": require("../../../assets/images/Doctors/doctor2.png"), - "doctor3.png": require("../../../assets/images/Doctors/doctor3.png"), - "doctor4.png": require("../../../assets/images/Doctors/doctor4.png"), - "doctor5.png": require("../../../assets/images/Doctors/doctor5.png"), -}; -interface iconMappingProp { - [key: string]: ReactElement; +const imageMap:imageMapProp = { + 'doctor1.png': require("../../../assets/images/Doctors/doctor1.png"), + 'doctor2.png': require("../../../assets/images/Doctors/doctor2.png"), + 'doctor3.png': require("../../../assets/images/Doctors/doctor3.png"), + 'doctor4.png': require("../../../assets/images/Doctors/doctor4.png"), + 'doctor5.png':require("../../../assets/images/Doctors/doctor5.png") + } +interface iconMappingProp{ + [key :string]:ReactElement +} + -interface Doctor { - imageSource: string; - name: string; - iconComponent: ReactElement; - professionalTitle: string; - hospital: string; - star: number; - review: number; - rate: number; +interface Doctor{ + id: number, + first_name: string, + last_name: string, + hospital: string, + rate: string, + review: string, + specialization: string, + about:string } -interface categoryProp { - name: string; - Doctors: Doctor[]; +interface categoryProp{ + name: string, + Doctors:Doctor[] } -export const iconMapping: iconMappingProp = { - heart: , - star: , -}; +export const iconMapping:iconMappingProp = { + heart: , + star: , +} + + function DoctorScreen() { - const [showSearch, setShowSearch] = useState(false); - const [searchTerm, setSearchTerm] = useState(""); - const [selectedCategory, setSelectedCategory] = useState(data.categories[0]); - const [showpopUp, setShowPopup] = useState(false); - const [selectedDoctor, setSelectedDoctor] = useState(); - const [showFilter, setShowfilter] = useState(false); - const { theme, changeTheme } = useContext(ThemeContext); - const containerStyle = - theme === "dark" ? styles.outerDark : styles.outerLight; - const scrollbackColor = - theme === "dark" ? styles.scrollDark : styles.scrollLight; + const [showSearch, setShowSearch] = useState(false) + const [searchTerm, setSearchTerm] = useState('') + const [selectedCategory, setSelectedCategory] = useState(data.categories[0]) + const [showpopUp, setShowPopup] = useState(false) + const [selectedDoctor, setSelectedDoctor] = useState() + const [showFilter, setShowfilter] = useState(false) + const [doctors,setDoctors]=useState([]) + const { theme, changeTheme } = useContext(ThemeContext) + const containerStyle = theme === "dark" ? styles.outerDark : styles.outerLight + const scrollbackColor = theme === "dark" ? styles.scrollDark : styles.scrollLight + + useEffect(() => { + async function fetchData() { + const { data, error } = await supabase.from(tableName).select('*'); - const handleSearchPressed = () => { - setShowSearch(true); - }; - const handleSearchSubmit = (text: string) => { - setSearchTerm(text.toLowerCase()); - }; + if (error) { + console.error('Error fetching data:', error); + return; + } + setDoctors(data) + + console.log('Fetched data:', data); +} + +fetchData(); + },[]) + + const handleSearchPressed = () => { + setShowSearch(true) + } + const handleSearchSubmit = (text: string) => { + setSearchTerm(text.toLowerCase()) + } + + const handleFilter = () => { + setShowfilter(true) + } + const handleRemove = (doctor:any) => { + setSelectedDoctor(doctor) + + setShowPopup(true) + } - const handleCategoryChange = (category: any) => { - setSelectedCategory(category), setSearchTerm(""); - }; - const handleFilter = () => { - setShowfilter(true); - }; - const handleRemove = (doctor: any) => { - setSelectedDoctor(doctor); + const filteredDoctors=searchTerm.length>0 ? doctors.filter(doctor=>doctor.last_name.toLowerCase().includes(searchTerm)):doctors + return ( + + + + + + { + !showSearch ? ( + + ) : ( + + + ) + } + + + + + {data.categories.map((category, index) => + + + {category.name} + + + )} + + + + + {showSearch && ( + + )} + + + + {filteredDoctors.length > 0 ? ( + + filteredDoctors.map((doctor: any, index: any) => + + + 0 - ? selectedCategory.Doctors.filter((doctor) => - doctor.name.toLowerCase().includes(searchTerm) - ) - : selectedCategory.Doctors; - return ( - - - - - {!showSearch ? ( - } + professionalTitle={doctor.specialization} + hospital={doctor.hospital} + star={} + review={doctor.review} + rate={doctor.rate} + remove={()=>handleRemove(doctor)} + + /> + + + ) + + ) : ( + + )} + + + + + + + + + + setShowPopup(false)} + visible={showpopUp} + onClose={() => setShowPopup(false)} + doctor={selectedDoctor} + + /> - ) : ( - setShowfilter(false)} + visible={showFilter} + onClose={() => setShowfilter(false)} + + + /> - )} - - - - {data.categories.map((category, index) => ( - <> - handleCategoryChange(category)} - size="medium" - style={{ marginLeft: 10 }} - /> - - ))} - - - - {showSearch && } - - - - {filteredDoctors.length > 0 ? ( - filteredDoctors.map((doctor: any, index: any) => ( - - handleRemove(doctor)} - /> - - )) - ) : ( - - )} - - - - setShowPopup(false)} - visible={showpopUp} - onClose={() => setShowPopup(false)} - doctor={selectedDoctor} - /> - setShowfilter(false)} - visible={showFilter} - onClose={() => setShowfilter(false)} - /> - - ); + + + + + + ); } export default DoctorScreen; const styles = StyleSheet.create({ - container: { - flex: 1, - zIndex: 1, - }, - outerDark: { - backgroundColor: "#181A20", - }, - outerLight: { - backgroundColor: "white", - }, - upper: { - display: "flex", - flexDirection: "row", - justifyContent: "center", - alignItems: "center", - width: "100%", - marginBottom: "7%", - marginTop: "18%", - }, - foundDoctorView: { - width: "100%", - display: "flex", - flexDirection: "row", - justifyContent: "center", - alignItems: "center", - }, - searchComponent: {}, - upperInner: { - width: "95%", - display: "flex", - flexDirection: "row", - justifyContent: "space-between", - alignItems: "center", - }, - upperLeft: { - display: "flex", - flexDirection: "row", - justifyContent: "space-between", - width: "70%", - height: "100%", - }, - categoryScroll: {}, - categoryBtnView: { - display: "flex", - flexDirection: "row", - alignItems: "center", - marginBottom: "5%", - backgroundColor: "white", - }, - categoryBtn: { - borderWidth: 2, - borderColor: "#246BFD", - height: 40, - paddingHorizontal: 20, - paddingVertical: 7, - borderRadius: 20, - display: "flex", - flexDirection: "row", - justifyContent: "center", - alignItems: "center", - marginRight: 8, - marginLeft: 10, - }, - firstCategoryBtn: { - backgroundColor: "#246BFD", - }, - firstCategoryBtnText: { - color: "white", - }, - categoryBtnText: { - color: "#246BFD", - fontSize: 16, - }, - body: { - width: "98%", - backgroundColor: "#F7F7F7", - }, - scroll: { - width: "100%", - height: "100%", - zIndex: 1, - }, - scrollDark: { - backgroundColor: "#181A20", - }, - scrollLight: { - backgroundColor: "#F7F7F7", - }, - searchView: { - display: "flex", - flexDirection: "row", - justifyContent: "center", - alignItems: "center", - }, - moreOuter: { - display: "flex", - flexDirection: "row", - justifyContent: "center", - alignItems: "center", - }, - Headstyle: { - color: "#212121", - fontWeight: "bold", - fontSize: 20, - }, - NotificationView: { - width: "80%", - }, - componentView: { - marginBottom: "5%", - width: "100%", - height: 150, - display: "flex", - flexDirection: "row", - justifyContent: "center", - alignItems: "center", - }, - rightView: { - display: "flex", - flexDirection: "row", - justifyContent: "space-between", - width: "25%", - }, -}); + container: { + flex: 1, + zIndex:1 + }, + outerDark: { + backgroundColor:"#181A20" + + }, + outerLight: { + backgroundColor: "white", + + }, + upper: { + display: "flex", + flexDirection: 'row', + justifyContent: "center", + alignItems: "center", + width:"100%", + marginBottom: "7%", + marginTop: "18%", + }, + foundDoctorView: { + width: "100%", + display: "flex", + flexDirection: 'row', + justifyContent: "center", + alignItems: "center" + }, + searchComponent: { + + }, + upperInner: { + width: "95%", + display: "flex", + flexDirection: 'row', + justifyContent: "space-between", + alignItems: "center", + }, + upperLeft: { + display: "flex", + flexDirection: "row", + justifyContent: 'space-between', + width: "70%", + height:"100%", + }, + categoryScroll: { + + }, + categoryBtnView: { + display:"flex", + flexDirection: "row", + alignItems: 'center', + marginBottom: "5%", + backgroundColor: "white", + }, + categoryBtn: { + borderWidth: 2, + borderColor: "#246BFD", + height: 40, + paddingHorizontal: 20, + paddingVertical:7, + borderRadius: 20, + display: "flex", + flexDirection: "row", + justifyContent: "center", + alignItems: "center", + marginRight: 8, + marginLeft:10 + }, + firstCategoryBtn: { + backgroundColor: "#246BFD" + }, + firstCategoryBtnText: { + color:"white" + }, + categoryBtnText: { + color: "#246BFD", + fontSize:16 + }, + body: { + width: "98%", + backgroundColor:"#F7F7F7", + }, + scroll: { + width: "100%", + height: "100%", + zIndex: 1, + }, + scrollDark: { + backgroundColor:"#181A20" + + }, + scrollLight: { + backgroundColor: "#F7F7F7" + + }, + searchView: { + display: "flex", + flexDirection: 'row', + justifyContent: "center", + alignItems: "center", + }, + moreOuter: { + display: "flex", + flexDirection: 'row', + justifyContent: "center", + alignItems: "center", + }, + Headstyle: { + color: "#212121", + fontWeight: "bold", + fontSize:20 + }, + NotificationView: { + width:"80%" + }, + componentView: { + marginBottom: "5%", + width: "100%", + height:150, + display: "flex", + flexDirection: 'row', + justifyContent: "center", + alignItems: "center", + }, + rightView: { + display: "flex", + flexDirection: "row", + justifyContent: 'space-between', + width:"25%" + }, + + +}) \ No newline at end of file diff --git a/app/(app)/ActionMenu/_layout.tsx b/app/(app)/ActionMenu/_layout.tsx index 6576c213..a93e4d8b 100644 --- a/app/(app)/ActionMenu/_layout.tsx +++ b/app/(app)/ActionMenu/_layout.tsx @@ -15,6 +15,10 @@ export default function Layout() { name="FavoriteDoctorScreen" options={{ headerShown: false }} /> + ); } diff --git a/app/(app)/ActionMenu/index.tsx b/app/(app)/ActionMenu/index.tsx index 00acf7d3..494b9e9f 100644 --- a/app/(app)/ActionMenu/index.tsx +++ b/app/(app)/ActionMenu/index.tsx @@ -167,17 +167,8 @@ export default function Index() { - - Doctor Speciality - - + Doctor Speciality + router.push("/ActionMenu/FavoriteDoctorScreen")}> See All @@ -308,19 +299,8 @@ export default function Index() { - - Top Doctors - - router.push("/ActionMenu/FavoriteDoctorScreen")} - > + Top Doctors + router.push("/ActionMenu/AllDoctorScreen")}> See All diff --git a/assets/images/Doctors/African 1.png b/assets/images/Doctors/African 1.png new file mode 100644 index 00000000..1a4bc2d4 Binary files /dev/null and b/assets/images/Doctors/African 1.png differ diff --git a/assets/whiteHeart.ts b/assets/whiteHeart.ts new file mode 100644 index 00000000..6617cf05 --- /dev/null +++ b/assets/whiteHeart.ts @@ -0,0 +1,5 @@ +export const whiteHeart=` + + + +` \ No newline at end of file diff --git a/components/DoctorComponent.tsx b/components/DoctorComponent.tsx index 12fdf9fa..4d5544f6 100644 --- a/components/DoctorComponent.tsx +++ b/components/DoctorComponent.tsx @@ -5,7 +5,7 @@ import { SvgXml } from "react-native-svg" import { ThemeContext } from '@/ctx/ThemeContext'; import { useContext } from 'react'; interface DoctorComponentProps{ - imageSource: ImageURISource|number + imageSource: {uri:string} name: string, iconComponent: ReactElement, professionalTitle: string, @@ -21,13 +21,15 @@ function DoctorComponent({ imageSource, name, iconComponent, professionalTitle, const containerStyle = theme === "dark" ? styles.outerDark : styles.outerLight const nameColor = theme === "dark" ? styles.textDark : styles.textLight const descriptionColor = theme === "dark" ? styles.descriptionDark : styles.descriptionLight - const horizontalColor=theme==="dark"?styles.horizontalDark:styles.horizontalLight + const horizontalColor = theme === "dark" ? styles.horizontalDark : styles.horizontalLight + console.log("image url", imageSource.uri) + return ( - + @@ -234,6 +236,10 @@ const styles = StyleSheet.create({ color:"#424242" }, allReviewView: { - + + }, + image: { + width: 110, + height:110 } }) \ No newline at end of file