webapp/src/pages/allAuthors.page.tsx

42 lines
1.2 KiB
TypeScript
Raw Normal View History

2023-02-17 09:21:02 +00:00
import type { PageProps } from './types'
2024-05-05 16:13:48 +00:00
import { createSignal, onMount } from 'solid-js'
import { AllAuthors } from '../components/Views/AllAuthors/'
2024-02-29 21:11:59 +00:00
import { PAGE_SIZE } from '../components/Views/AllTopics/AllTopics'
2024-02-04 11:25:21 +00:00
import { PageLayout } from '../components/_shared/PageLayout'
2023-05-05 20:05:50 +00:00
import { useLocalize } from '../context/localize'
2024-02-29 21:11:59 +00:00
import { loadAllAuthors, loadAuthors } from '../stores/zine/authors'
2022-09-22 09:37:49 +00:00
export const AllAuthorsPage = (props: PageProps) => {
2024-02-29 21:11:59 +00:00
const [isLoaded, setIsLoaded] = createSignal<boolean>(
Boolean(props.allAuthors && props.topFollowedAuthors && props.topWritingAuthors),
)
2022-11-15 09:38:12 +00:00
2023-05-05 20:05:50 +00:00
const { t } = useLocalize()
2022-11-15 09:38:12 +00:00
onMount(async () => {
if (isLoaded()) {
return
}
2023-12-26 23:28:26 +00:00
await loadAllAuthors()
2024-02-29 21:11:59 +00:00
await loadAuthors({ by: { order: 'shouts' }, limit: PAGE_SIZE, offset: 0 })
await loadAuthors({ by: { order: 'followers' }, limit: PAGE_SIZE, offset: 0 })
2022-11-15 09:38:12 +00:00
setIsLoaded(true)
})
2022-09-22 09:37:49 +00:00
return (
<PageLayout title={t('Authors')}>
2024-02-29 21:11:59 +00:00
<AllAuthors
isLoaded={isLoaded()}
authors={props.allAuthors}
topWritingAuthors={props.topWritingAuthors}
topFollowedAuthors={props.topFollowedAuthors}
/>
2023-02-17 09:21:02 +00:00
</PageLayout>
2022-09-22 09:37:49 +00:00
)
}
2023-02-17 09:21:02 +00:00
export const Page = AllAuthorsPage