Skip to content

Commit bbd80b7

Browse files
committed
fetch daily reminder
1 parent 7bdff6d commit bbd80b7

File tree

9 files changed

+64
-18
lines changed

9 files changed

+64
-18
lines changed

Utils/datafetching.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@ export const fetchTodaysEvents = async () => {
4545

4646

4747
//get ayah here
48+
export async function getDailyReminder(id:string) {
49+
const { data, error } = await supabase.from('daily_reminders').select('*').eq('id', id).single()
50+
if (error) {
51+
throw error
52+
}
53+
return data
54+
}
4855

4956

5057

Utils/formatDate.tsx

Whitespace-only changes.

Utils/utils.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
3+
// function to get id number of ayah/hadith based on date
4+
export default function getReminderId() {
5+
const today = new Date();
6+
const date = today.getDate();
7+
const month = today.getMonth();
8+
const year = today.getFullYear();
9+
const id = (date * month * year) % 98 ;
10+
return id.toString();
11+
}

app/(tabs)/Halalfood.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { View, Text } from 'react-native'
55
import { TextInput } from 'react-native'
66
import { Search } from 'lucide-react-native'
77
import { CircleX } from 'lucide-react-native'
8-
const HalalFood = () => {
8+
const halalFood = () => {
99
return (
1010
<ScrollView className='flex flex-col h-screen px-6 pt-4 bg-[#F8F5FF] '>
1111
<View className="items-center mx-4 ">
@@ -31,4 +31,4 @@ const HalalFood = () => {
3131
)
3232
}
3333

34-
export default HalalFood
34+
export default halalFood

app/components/AyahCard.tsx

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,40 @@
11
import { Text, View } from "react-native";
2+
import getReminderId from "@/Utils/utils";
3+
import { getDailyReminder } from "@/Utils/datafetching";
4+
import { useState, useEffect } from "react";
5+
type Reminder = {
6+
id: string
7+
english: string
8+
arabic: string
9+
reference: string
10+
11+
}
12+
const reminderId = getReminderId();
13+
214
const AyahCard = () => {
15+
const [ayah, setAyah] = useState<Reminder>()
16+
17+
useEffect(() => {
18+
getDailyReminder(reminderId).then((data) => {
19+
setAyah(data)
20+
})
21+
}, [])
22+
23+
24+
25+
326
return (
427
<View className="flex flex-col rounded-xl my-4 justify-start text-start bg-slate-50 shadow-md shadow-slate-200 p-6 w-full ">
528
<Text className="card-title text-[#2E046D] text-left pb-2">
629
Ayah of the Day
730
</Text>
831
<Text className="card-text text-gray-700 py-2 justify-end ">
9-
فَٱصْبِرْ عَلَىٰ مَا يَقُولُونَ وَسَبِّحْ بِحَمْدِ رَبِّكَ قَبْلَ طُلُوعِ ٱلشَّمْسِ وَقَبْلَ ٱلْغُرُوبِ
10-
32+
{ayah?.arabic}
1133
</Text>
1234
<Text className="card-text text-gray-700 py-2 justify-end ">
13-
So be patient ˹O Prophet˺ with what they say. And glorify the praises of your Lord before sunrise and before sunset.
14-
</Text>
35+
{ayah?.english} </Text>
1536
<Text className="card-text text-gray-400 pt-2">
16-
Surah Qaf, Ayah 39
37+
{ayah?.reference}
1738
</Text>
1839
</View>
1940
)

app/components/EventCard.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import {ChevronRight} from "lucide-react-native";
33
import { fetchTodaysEvents } from "@/Utils/datafetching";
44
import { useState, useEffect } from "react";
55
import { Link } from "expo-router";
6+
import { useRouter } from 'expo-router';
7+
68
type EventInfoProps = {
79
name: string
810
date: string
@@ -17,6 +19,7 @@ const EventCard= () => {
1719
setEvents(data)
1820
})
1921
}, [])
22+
const router = useRouter();
2023

2124

2225

@@ -29,7 +32,7 @@ const EventCard= () => {
2932
{events.length > 0 ? "Today's Events" : "No events today"}
3033
</Text>
3134
<Link href="/events">
32-
<Pressable>
35+
<Pressable onPress={() => router.navigate('/events')} >
3336
<View className="flex flex-row items-center justify-end p-2 rounded bg-violet-100">
3437
<Text className=" text-[#5636A7] ">All events </Text>
3538
<ChevronRight size={18} color="#5636A7" />

app/components/HalalfoodCard.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,13 @@ const HalalfoodCard:React.FC<Props> = ({name, description, location, link, image
4040
<View className='flex flex-row '>
4141
<Text className="text-lg font-semibold text-[#5636A7]"> {name} </Text>
4242
</View>
43-
<View className='flex flex-col justify-between w-full py-4 font-bold'>
44-
<Text className="text-md text-gray-600 py-2 ">{description} </Text>
45-
<Text className="text-md text-gray-500">Category: {category} </Text>
46-
<Text className="text-md text-gray-500">Method: {method} </Text>
47-
<Text className="text-md text-gray-500">Location: {location} </Text>
43+
<View className='flex flex-col justify-between w-full py-2 font-bold'>
44+
<Text className="text-md text-gray-600 ">{description} </Text>
45+
<View className='py-2'>
46+
<Text className="text-md text-gray-500">Category: {category} </Text>
47+
<Text className="text-md text-gray-500">Method: {method} </Text>
48+
<Text className="text-md text-gray-500">Location: {location} </Text>
49+
</View>
4850
<View className='flex flex-row justify-end'>
4951
{link && <Pressable className="bg-[#5636A7] w-36 p-2 rounded-xl text-center mt-2 flex flex-row items-center justify-center" onPress={() => Linking.openURL(link)}>
5052
<Text className="text-white text-center font-semibold ">Order now</Text>

app/components/Icon.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,11 @@ export const IconComponent:React.FC<ButtonProps> = ({icon, link, text}: ButtonPr
2727
<>
2828

2929
<View className="items-center text-center">
30-
<Link href={link as any}>
30+
<Link href={link as any} asChild>
3131
<Pressable
3232
onPressIn={onPress}
3333
onPressOut={onPress}
34+
3435
className={`items-center w-16 h-16 p-4 text-center shadow-md shadow-slate-200 bg-[#F9FAFB] justify-center rounded-xl ${isPressed ? "bg-[#ededed]" : "bg-[#F9FAFB]"}`}>
3536
{icon}
3637
</Pressable>

app/components/PrayerCard.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,19 @@ const PrayerCard = () => {
2626
<Text className="text-4xl font-bold text-white">6:00 AM</Text>
2727
</View>
2828

29-
<View className="" >
29+
<View className="flex flex-row justify-between" >
3030
<Text className="text-white ">
3131
in 1 hour 42 min
3232
</Text>
33-
</View>
34-
<Pressable>
33+
<Pressable>
3534
<Link href="/prayertimes">
36-
<View className="flex flex-row justify-end ">
35+
<View className=" ">
3736
<Text className="text-white underline">View all timings</Text>
3837
</View>
3938
</Link>
4039
</Pressable>
40+
</View>
41+
4142
</LinearGradient>
4243
</View>
4344
)

0 commit comments

Comments
 (0)