import { createEffect, createSignal, For, onMount, Show } from 'solid-js' import type { Author } from '../../graphql/types.gen' import { AuthorCard } from '../Author/Card' import { byFirstChar, sortBy } from '../../utils/sortby' import { groupByName } from '../../utils/groupby' import Icon from '../Nav/Icon' import { t } from '../../utils/intl' import { useAuthorsStore } from '../../stores/zine/authors' import { route, by, setBy, SortBy } from '../../stores/router' import { session } from '../../stores/auth' import { useStore } from '@nanostores/solid' import '../../styles/AllTopics.scss' export const AllAuthorsPage = (props: any) => { const { getSortedAuthors: authorslist } = useAuthorsStore(props.authors) const [sortedAuthors, setSortedAuthors] = createSignal([]) const [sortedKeys, setSortedKeys] = createSignal([]) const [abc, setAbc] = createSignal([]) const auth = useStore(session) const subscribed = (s) => Boolean(auth()?.info?.authors && auth()?.info?.authors?.includes(s || '')) createEffect(() => { if (!by() && abc().length === 0) { console.log('[authors] default grouping by abc') const grouped = { ...groupByName(authorslist()) } grouped['A-Z'] = sortBy(grouped['A-Z'], byFirstChar) setAbc(grouped) const keys = Object.keys(abc) keys.sort() setSortedKeys(keys as string[]) } else { console.log('[authors] sorting by ' + by()) setSortedAuthors(sortBy(authorslist(), by())) } }, [by()]) onMount(() => setBy('' as SortBy)) return (
(
{(author: Author) => ( )}
)} > {(letter: string) => (

{letter}

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