import { createEffect, createSignal, For, 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 { handleClientRouteLinkClick, useRouter } from '../../stores/router' import { session } from '../../stores/auth' import { useStore } from '@nanostores/solid' import '../../styles/AllTopics.scss' type AllAuthorsPageSearchParams = { by: '' | 'name' | 'shouts' | 'rating' } type Props = { authors: Author[] } export const AllAuthorsView = (props: Props) => { const { sortedAuthors: authorList } = useAuthorsStore({ authors: 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 || '')) const { getSearchParams } = useRouter() createEffect(() => { if ((!getSearchParams().by || getSearchParams().by === 'name') && abc().length === 0) { console.log('[authors] default grouping by abc') const grouped = { ...groupByName(authorList()) } 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 ' + getSearchParams().by) setSortedAuthors(sortBy(authorList(), getSearchParams().by)) } }, [authorList(), getSearchParams().by]) return (
0}>
(
{(author: Author) => ( )}
)} > {(letter: string) => (

{letter}

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