import { createEffect, createMemo, For, Show } from 'solid-js' import type { Author } from '../../graphql/types.gen' import { AuthorCard } from '../Author/Card' import { Icon } from '../Nav/Icon' import { t } from '../../utils/intl' import { useAuthorsStore, setAuthorsSort } from '../../stores/zine/authors' import { handleClientRouteLinkClick, useRouter } from '../../stores/router' import { useAuthStore } from '../../stores/auth' import styles from '../../styles/AllTopics.module.scss' import { clsx } from 'clsx' type AllAuthorsPageSearchParams = { by: '' | 'name' | 'shouts' | 'rating' } type Props = { authors: Author[] } export const AllAuthorsView = (props: Props) => { const { sortedAuthors } = useAuthorsStore({ authors: props.authors }) const { session } = useAuthStore() createEffect(() => { setAuthorsSort(searchParams().by || 'shouts') }) const subscribed = (s) => Boolean(session()?.news?.authors && session()?.news?.authors?.includes(s || '')) const { searchParams } = useRouter() const byLetter = createMemo<{ [letter: string]: Author[] }>(() => { return sortedAuthors().reduce((acc, author) => { if (!author.name) { // name === null for new users return acc } const letter = author.name[0].toUpperCase() if (!acc[letter]) { acc[letter] = [] } acc[letter].push(author) return acc }, {} as { [letter: string]: Author[] }) }) const sortedKeys = createMemo(() => { const keys = Object.keys(byLetter()) keys.sort() return keys }) // log.debug(getSearchParams()) return (
0}>

{t('Authors')}

{t('Subscribe who you like to tune your personal feed')}

(
{(author) => ( )}
)} > {(letter) => (

{letter}

{(author: Author) => ( )}
)}
) }