|
|
@ -62,6 +62,7 @@ const DuaComponent: React.FC<DuaComponentProps> = ({ |
|
|
|
const [recitingPart, setRecitingPart] = useState<Dua | null>(null); |
|
|
|
const [loading, setLoading] = useState(false); |
|
|
|
const [nextURL, setNextURL] = useState(""); |
|
|
|
const [data, setData] = useState({}); |
|
|
|
|
|
|
|
// Add event listeners for wheel and touch
|
|
|
|
useEffect(() => { |
|
|
@ -96,6 +97,7 @@ const DuaComponent: React.FC<DuaComponentProps> = ({ |
|
|
|
setLoading(true); |
|
|
|
const duaResponse = await http.get<DuaPartsResponse>(URL); |
|
|
|
setDuaParts((prev) => [...prev, ...duaResponse.data.results]); |
|
|
|
setData(duaResponse.data); |
|
|
|
setNextURL(duaResponse.data.next); |
|
|
|
getAudio(id); |
|
|
|
} catch (error) { |
|
|
@ -116,6 +118,7 @@ const DuaComponent: React.FC<DuaComponentProps> = ({ |
|
|
|
} |
|
|
|
fetchData(); |
|
|
|
}, [slug]); |
|
|
|
console.log(data); |
|
|
|
|
|
|
|
const playAudio = useCallback( |
|
|
|
(part: Dua) => { |
|
|
@ -172,17 +175,17 @@ const DuaComponent: React.FC<DuaComponentProps> = ({ |
|
|
|
setRecitingPart(currentRecitingPart); |
|
|
|
}, [audio, duaParts]); |
|
|
|
|
|
|
|
function processSlug(slug: string): string { |
|
|
|
if (!slug) return ""; |
|
|
|
const parts = slug.split("-"); |
|
|
|
if (parts.length === 0) return ""; |
|
|
|
parts.pop(); |
|
|
|
return parts |
|
|
|
.map( |
|
|
|
(word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase() |
|
|
|
) |
|
|
|
.join(" "); |
|
|
|
} |
|
|
|
// function processSlug(slug: string): string {
|
|
|
|
// if (!slug) return "";
|
|
|
|
// const parts = slug.split("-");
|
|
|
|
// if (parts.length === 0) return "";
|
|
|
|
// parts.pop();
|
|
|
|
// return parts
|
|
|
|
// .map(
|
|
|
|
// (word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()
|
|
|
|
// )
|
|
|
|
// .join(" ");
|
|
|
|
// }
|
|
|
|
|
|
|
|
const handleBack = () => { |
|
|
|
if (SelectedDua) { |
|
|
@ -241,8 +244,8 @@ const DuaComponent: React.FC<DuaComponentProps> = ({ |
|
|
|
[fetching, setAutoScroll] |
|
|
|
); |
|
|
|
|
|
|
|
const title = duaParts[0]?.seo_field?.title; |
|
|
|
const description = duaParts[0]?.seo_field?.description; |
|
|
|
const title = data?.seo_field?.title; |
|
|
|
const description = data?.seo_field?.description; |
|
|
|
const keywords = "dua, islam, prayer, supplication, dua parts"; |
|
|
|
|
|
|
|
return ( |
|
|
@ -262,7 +265,7 @@ const DuaComponent: React.FC<DuaComponentProps> = ({ |
|
|
|
> |
|
|
|
<FaArrowLeft size={18} /> |
|
|
|
</button> |
|
|
|
<p className="text-sm font-semibold">{processSlug(slug)}</p> |
|
|
|
<p className="text-sm font-semibold">{data?.title}</p> |
|
|
|
<div className="relative"> |
|
|
|
<button |
|
|
|
className="p-2 bg-white/20 rounded-2xl" |
|
|
|