import React from "react"; import { Link, useSearchParams } from "react-router"; import { Badge } from "src/components/ui/badge"; import { Card, CardContent, CardDescription, CardTitle, } from "src/components/ui/card"; import { cn } from "src/lib/utils"; import { AppStoreApp, appStoreApps, getAppStoreUrl, sortedAppStoreCategories, } from "./SuggestedAppData"; function AppCard(app: AppStoreApp) { return (
{`${app.title}
{app.title} {app.description} {app.legacyTitles?.length ? ` (Previously ${app.legacyTitles.join(", ")})` : ""}
); } export default function SuggestedApps() { const [searchParams] = useSearchParams(); const [selectedCategories, setSelectedCategories] = React.useState( () => { const category = searchParams.get("category"); return category ? [category] : []; } ); return ( <>
{sortedAppStoreCategories.map(([categoryId, category]) => ( setSelectedCategories((current) => [ ...current.filter((c) => c !== categoryId), ...(current.includes(categoryId) ? [] : [categoryId]), ]) } > {category.title} ))}
{sortedAppStoreCategories .filter( ([categoryId]) => !selectedCategories.length || selectedCategories.includes(categoryId) ) .map(([categoryId, category]) => { return (

{category.title}

{appStoreApps .filter((app) => (app.categories as string[]).includes(categoryId) ) .map((app) => ( ))}
); })}
); }