import classNames from "classnames";
import { useRef, useState } from "react";
import { Trans, useTranslation } from "react-i18next";
import { useNavigate } from "react-router-dom";
import { SearchBarInput } from "@/components/form/SearchBar";
import { ThinContainer } from "@/components/layout/ThinContainer";
import { MwLink } from "@/components/text/Link";
import { Ol } from "@/components/utils/Ol";
import { Heading1, Heading2, Paragraph } from "@/components/utils/Text";
import { PageTitle } from "@/pages/parts/util/PageTitle";
import { SubPageLayout } from "./layouts/SubPageLayout";
function Question(props: { title: string; children: React.ReactNode }) {
return (
<>
{props.title}
{props.children}
>
);
}
export function Button(props: {
className: string;
onClick?: () => void;
children: React.ReactNode;
disabled?: boolean;
}) {
return (
);
}
function SectionHeading(props: { title: string }) {
return (
{props.title}
);
}
type SectionKey =
| "general"
| "search"
| "playback"
| "connections"
| "language";
interface Sections {
general: JSX.Element[];
search: JSX.Element[];
playback: JSX.Element[];
connections: JSX.Element[];
language: JSX.Element[];
}
export function AboutPage() {
const { t } = useTranslation();
const navigate = useNavigate();
const [searchQuery, setSearchQuery] = useState("");
const searchRef = useRef(null);
const questionKeys = Object.keys(t("about", { returnObjects: true }))
.filter((key) => key.startsWith("q"))
.sort((a, b) => parseInt(a.slice(1), 10) - parseInt(b.slice(1), 10));
const sections: Sections = {
general: [],
search: [],
playback: [],
connections: [],
language: [],
};
questionKeys.forEach((key) => {
const section = t(`about.${key}.section`) as SectionKey;
if (section && sections[section]) {
sections[section].push(
{t(`about.${key}.body`)}
,
);
}
});
const allFaqItems = [
...sections.general,
...sections.search,
...sections.playback,
...sections.connections,
...sections.language,
];
const filteredItems = allFaqItems.filter((item: JSX.Element) => {
try {
const title = item?.props?.title?.toLowerCase() || "";
const body = item?.props?.children?.toLowerCase() || "";
const query = searchQuery.toLowerCase();
return title.includes(query) || body.includes(query);
} catch (e) {
return false;
}
});
const showFilteredItems = searchQuery.length > 0;
return (
{t("about.title")}
{t("about.description")}
setSearchQuery(value)}
onUnFocus={() => {}}
placeholder={t("about.searchPlaceholder")}
hideTooltip
/>
{t("about.faqTitle")}
{showFilteredItems ? (
) : (
<>
{/* General Section */}
{sections.general.length > 0 && (
<>
>
)}
{/* Search Section */}
{sections.search.length > 0 && (
<>
>
)}
{/* Playback Section */}
{sections.playback.length > 0 && (
<>
>
)}
{/* FED API Section */}
{sections.connections.length > 0 && (
<>
>
)}
{/* Language Section */}
{sections.language.length > 0 && (
<>
>
)}
>
)}
);
}