import { Link, useNavigate } from 'react-router-dom'; import { useTranslation } from 'react-i18next'; import { useDefaultSubplebbitsState, useDefaultSubplebbits, MultisubSubplebbit } from '../../../hooks/use-default-subplebbits'; import { getBoardPath } from '../../../lib/utils/route-utils'; import useDisclaimerModalStore from '../../../stores/use-disclaimer-modal-store'; import useDirectoryModalStore from '../../../stores/use-directory-modal-store'; import useBoardsFilterStore from '../../../stores/use-boards-filter-store'; import BoardsFilterModal from './boards-filter-modal'; import styles from '../home.module.css'; // Helper function to find board address by matching title pattern const findBoardAddress = (multisub: MultisubSubplebbit[], titlePattern: string): string | null => { const entry = multisub.find((ms) => ms.title === titlePattern); return entry?.address || null; }; const NSFWBadge = () => { return ( <>  

(NSFW)

); }; const BoardsList = ({ multisub }: { multisub: MultisubSubplebbit[] }) => { const { t } = useTranslation(); const navigate = useNavigate(); const { error } = useDefaultSubplebbitsState(); const { showDisclaimerModal } = useDisclaimerModalStore(); const { openDirectoryModal } = useDirectoryModalStore(); const { useCatalogLinks, boardFilter } = useBoardsFilterStore(); const defaultSubplebbits = useDefaultSubplebbits(); const handleLinkClick = (e: React.MouseEvent, address: string) => { e.preventDefault(); const boardPath = getBoardPath(address, defaultSubplebbits); showDisclaimerModal(address, navigate, boardPath); }; // Helper to generate link URL with optional catalog suffix const getBoardLink = (address: string | null): string => { if (!address) return '#'; const boardPath = getBoardPath(address, defaultSubplebbits); return `/${boardPath}${useCatalogLinks ? '/catalog' : ''}`; }; // Handler for placeholder board links const handlePlaceholderClick = (e: React.MouseEvent) => { e.preventDefault(); openDirectoryModal(); }; // Find active boards const bizAddress = findBoardAddress(multisub, '/biz/ - Business & Finance'); const polAddress = findBoardAddress(multisub, '/pol/ - Politically Incorrect'); const errorMessage = error?.message; // Filtering logic: determine which categories to show const showAll = boardFilter === 'all'; const showNsfwOnly = boardFilter === 'nsfw'; const showWorksafeOnly = boardFilter === 'worksafe'; // Category visibility based on filter const showJapaneseCulture = showAll || showWorksafeOnly || showNsfwOnly; const showVideoGames = showAll || showWorksafeOnly; const showInterests = showAll || showWorksafeOnly; const showCreative = showAll || showWorksafeOnly || showNsfwOnly; const showOther = showAll || showWorksafeOnly; const showMisc = showAll || showNsfwOnly; const showAdult = showAll || showNsfwOnly; const showMultiboards = showAll || showNsfwOnly; return (

{t('boards')}

{errorMessage &&
{errorMessage}
} {/* Column 1: Japanese Culture + Video Games */} {(showJapaneseCulture || showVideoGames) && (
{/* Japanese Culture */} {showJapaneseCulture && ( <>

Japanese Culture

    {(showAll || showWorksafeOnly) && ( <>
  • Anime & Manga
  • Anime/Cute
  • Anime/Wallpapers
  • Mecha
  • Cosplay & EGL
  • Cute/Male
  • )} {(showAll || showNsfwOnly) && (
  • Flash
  • )} {(showAll || showWorksafeOnly) && ( <>
  • Transportation
  • Otaku Culture
  • Virtual YouTubers
  • )}
)} {/* Video Games */} {showVideoGames && ( <>

Video Games

  • Video Games
  • Video Game Generals
  • Video Games/Multiplayer
  • Video Games/Mobile
  • Pokémon
  • Retro Games
  • Video Games/RPG
  • Video Games/Strategy
)}
)} {/* Column 2: Interests */} {showInterests && (

Interests

  • Comics & Cartoons
  • Technology
  • Television & Film
  • Weapons
  • Auto
  • Animals & Nature
  • Traditional Games
  • Sports
  • Extreme Sports
  • Professional Wrestling
  • Science & Math
  • History & Humanities
  • International
  • Outdoors
  • Toys
)} {/* Column 3: Creative */} {showCreative && (

Creative

    {(showAll || showNsfwOnly) && (
  • Oekaki
  • )} {(showAll || showWorksafeOnly) && ( <>
  • Papercraft & Origami
  • Photography
  • Food & Cooking
  • )} {(showAll || showNsfwOnly) && (
  • Artwork/Critique
  • )} {(showAll || showNsfwOnly) && (
  • Wallpapers/General
  • )} {(showAll || showWorksafeOnly) && ( <>
  • Literature
  • Music
  • Fashion
  • 3DCG
  • Graphic Design
  • Do-It-Yourself
  • Worksafe GIF
  • Quests
  • )}
)} {/* Column 4: Other + Misc. */} {(showOther || showMisc) && (
{/* Other */} {showOther && ( <>

Other

    {bizAddress ? (
  • handleLinkClick(e, bizAddress)}> Business & Finance
  • ) : (
  • Business & Finance
  • )}
  • Travel
  • Fitness
  • Paranormal
  • Advice
  • LGBT
  • Pony
  • Current News
  • Worksafe Requests
  • Very Important Posts
)} {/* Misc. (NSFW) */} {showMisc && ( <>

Misc.

  • Random
  • ROBOT9001
  • {polAddress ? (
  • handleLinkClick(e, polAddress)}> Politically Incorrect
  • ) : (
  • Politically Incorrect
  • )}
  • International/Random
  • Cams & Meetups
  • Shit 4chan Says
)}
)} {/* Column 5: Adult (NSFW) */} {showAdult && (

Adult

  • Sexy Beautiful Women
  • Hardcore
  • Handsome Men
  • Hentai
  • Ecchi
  • Yuri
  • Hentai/Alternative
  • Yaoi
  • Torrents
  • High Resolution
  • Adult GIF
  • Adult Cartoons
  • Adult Requests
)} {/* Column 6: Meta */} {showMultiboards && (

Multiboards

  • All 5chan Directories
  • Subscriptions
)}
); }; export default BoardsList;