|
|
@ -16,45 +16,39 @@ import { Category, Dua, ListProps } from "../utils/types"; |
|
|
|
|
|
|
|
const List: React.FC<ListProps> = ({ tab, path, setPath, data, setData }) => { |
|
|
|
const [loading, setLoading] = useState<boolean>(false); |
|
|
|
const [currentDhikr, setCurrentDhikr] = useState<string>(""); |
|
|
|
const [currentTranslation, setCurrentTranslation] = useState<string>(""); |
|
|
|
const router = useRouter(); |
|
|
|
const today = new Date(); |
|
|
|
const dayOfWeek = new Intl.DateTimeFormat("en-US", { |
|
|
|
weekday: "long", |
|
|
|
}).format(today); |
|
|
|
|
|
|
|
let locale : string ; |
|
|
|
// Mapping of days of the week to their respective Dhikr phrases with vowels and English translations
|
|
|
|
const dhikrMap: { [key: string]: { dhikr: string; english: string } } = { |
|
|
|
Saturday: { |
|
|
|
dhikr: "یَا رَبِّ الْعالَمِین", |
|
|
|
english: "O Lord of the Worlds", |
|
|
|
}, |
|
|
|
Sunday: { |
|
|
|
dhikr: "یَا ذَا الْجَلاَلِ وَ الْاِکْرَامِ", |
|
|
|
english: "O Lord of Glory and Honor", |
|
|
|
}, |
|
|
|
Monday: { |
|
|
|
dhikr: "یَا قَاضِیَ الْحَاجَاتِ", |
|
|
|
english: "O the Judge of needs", |
|
|
|
}, |
|
|
|
Tuesday: { |
|
|
|
dhikr: "یَا أَرْحَمَ الرَّاحِمِین", |
|
|
|
english: "O Most Merciful of all givers", |
|
|
|
}, |
|
|
|
Wednesday: { |
|
|
|
dhikr: "یَا حَیُّ یَا قَیُّومُ", |
|
|
|
english: "O Ever-Living, O Sustainer", |
|
|
|
}, |
|
|
|
Thursday: { |
|
|
|
dhikr: "لَا إِلٰهَ إِلَّا اللَّهُ الْمَلِکُ الْحَقُّ الْمُبِینُ", |
|
|
|
english: |
|
|
|
"There is no god but Allah, the Sovereign, the True, the Manifest", |
|
|
|
}, |
|
|
|
Friday: { |
|
|
|
dhikr: "اللّهُمّ صَلِّ عَلَى مُحَمَّدٍ وَ آلِ مُحَمَّدٍ", |
|
|
|
english: |
|
|
|
"O Allah, send blessings upon Muhammad and the family of Muhammad", |
|
|
|
}, |
|
|
|
}; |
|
|
|
useEffect(() => { |
|
|
|
locale = localStorage.getItem("locale") || "en"; |
|
|
|
if (tab === "Today") { |
|
|
|
setLoading(true); |
|
|
|
http |
|
|
|
.get("web/mafatih-duas/dhikrs/?today=true") |
|
|
|
.then((res) => { |
|
|
|
const dhikrForToday = res.data.find( |
|
|
|
(item: any) => item.day === dayOfWeek |
|
|
|
); |
|
|
|
if (dhikrForToday) { |
|
|
|
setCurrentDhikr(dhikrForToday.text); |
|
|
|
setCurrentTranslation( |
|
|
|
dhikrForToday.translation[locale] || dhikrForToday.translation.en |
|
|
|
); |
|
|
|
} |
|
|
|
setLoading(false); |
|
|
|
}) |
|
|
|
.catch((error) => { |
|
|
|
console.error("Error fetching Dhikr data:", error); |
|
|
|
setLoading(false); |
|
|
|
}); |
|
|
|
} |
|
|
|
}, [tab, dayOfWeek, locale]); |
|
|
|
|
|
|
|
const openCategory = (category: Category) => { |
|
|
|
setData({ type: "children", data: category.children }); |
|
|
@ -138,15 +132,13 @@ const List: React.FC<ListProps> = ({ tab, path, setPath, data, setData }) => { |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
|
|
}, [path]); |
|
|
|
|
|
|
|
if (loading) { |
|
|
|
return <p>Loading ...</p>; |
|
|
|
} |
|
|
|
|
|
|
|
const currentDhikr = dhikrMap[dayOfWeek]?.dhikr || ""; |
|
|
|
const currentEnglish = dhikrMap[dayOfWeek]?.english || ""; |
|
|
|
console.log(data); |
|
|
|
|
|
|
|
return ( |
|
|
@ -174,7 +166,7 @@ const List: React.FC<ListProps> = ({ tab, path, setPath, data, setData }) => { |
|
|
|
{colorizeVowels(currentDhikr)} |
|
|
|
</div> |
|
|
|
|
|
|
|
<p className="text-sm text-[#8B8B8B]">{currentEnglish}</p> |
|
|
|
<p className="text-sm text-[#8B8B8B]">{currentTranslation}</p> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
@ -238,7 +230,7 @@ const List: React.FC<ListProps> = ({ tab, path, setPath, data, setData }) => { |
|
|
|
)} |
|
|
|
</div> |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
) : ( |
|
|
|
<div className="flex my-[40%] items-center justify-center"> |
|
|
|