From bd04a26a4aad8f915f8ed6361d421c43057f79a8 Mon Sep 17 00:00:00 2001
From: 0x1eef <0x1eef@protonmail.com>
Date: Thu, 17 Oct 2024 23:00:05 -0300
Subject: [PATCH] Add routes for 'SurahStream'
---
src/js/components/Head.tsx | 2 +-
src/js/components/SurahIndex/index.tsx | 2 +-
src/js/components/SurahStream/index.tsx | 5 ++++-
src/js/index.tsx | 4 +++-
4 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/src/js/components/Head.tsx b/src/js/components/Head.tsx
index c8d2948..dca9d3a 100644
--- a/src/js/components/Head.tsx
+++ b/src/js/components/Head.tsx
@@ -17,7 +17,7 @@ export function Head({ title, locale, children }: Props) {
{title}
diff --git a/src/js/components/SurahIndex/index.tsx b/src/js/components/SurahIndex/index.tsx
index 32e992f..61737dd 100644
--- a/src/js/components/SurahIndex/index.tsx
+++ b/src/js/components/SurahIndex/index.tsx
@@ -70,7 +70,7 @@ export function SurahIndex({ locale, surahs, t }: Props) {
>
{formatNumber(locale, surah.id)}
diff --git a/src/js/components/SurahStream/index.tsx b/src/js/components/SurahStream/index.tsx
index abb261b..216ab17 100644
--- a/src/js/components/SurahStream/index.tsx
+++ b/src/js/components/SurahStream/index.tsx
@@ -23,7 +23,7 @@ type Props = {
t: TFunction;
};
-export function SurahStream({ surah, locale, t }: Props) {
+export function SurahStream({ surahId, localeId, t }: Props) {
const [stream, setStream] = useState([]);
const [isPaused, setIsPaused] = useState(false);
const [audioEnabled, setAudioEnabled] = useState(false);
@@ -32,6 +32,9 @@ export function SurahStream({ surah, locale, t }: Props) {
const [showLangDropdown, setShowLangDropdown] = useState(false);
const [showThemeDropdown, setShowThemeDropdown] = useState(false);
const [theme, setTheme] = useTheme();
+
+ const locale = Quran.locales[localeId];
+ const surah = Quran.surahs[localeId][parseInt(surahId) - 1]
const rootRef = useRef(null);
const audio = useMemo(() => new Audio(), []);
const readyToRender = stream.length > 0;
diff --git a/src/js/index.tsx b/src/js/index.tsx
index 8af5b08..427357c 100644
--- a/src/js/index.tsx
+++ b/src/js/index.tsx
@@ -1,6 +1,7 @@
import { Quran } from "Quran";
import { T } from "~/lib/t";
import { SurahIndex } from "~/components/SurahIndex";
+import { SurahStream } from "~/components/SurahStream";
import { render } from "preact";
import { useState, useEffect, useMemo, useRef } from "preact/hooks";
import * as React from "preact/compat";
@@ -9,6 +10,7 @@ import { Router } from "preact-router";
import "core-js";
const exports = {
+ Quran,
React,
render,
useState,
@@ -20,7 +22,6 @@ const exports = {
Object.assign(window, exports);
document.addEventListener("DOMContentLoaded", () => {
- console.log(Quran.surahs["en"][0].ayat)
const Main = (function () {
const t = T(require("@json/t.json"));
return () => {
@@ -29,6 +30,7 @@ document.addEventListener("DOMContentLoaded", () => {
+
);
};