This commit is contained in:
bniwredyc 2023-04-21 17:10:23 +02:00
parent 11f0a25a96
commit a23d476da4
4 changed files with 41 additions and 1 deletions

View File

@ -1,7 +1,7 @@
import { capitalize, formatDate } from '../../utils'
import { Icon } from '../_shared/Icon'
import { AuthorCard } from '../Author/Card'
import { createMemo, createSignal, For, Match, onMount, Show, Switch } from 'solid-js'
import { createEffect, createMemo, createSignal, For, Match, onMount, Show, Switch } from 'solid-js'
import type { Author, Shout } from '../../graphql/types.gen'
import MD from './MD'
import { SharePopup } from './SharePopup'

View File

@ -0,0 +1,4 @@
import { ROUTES } from '../stores/router'
import { getServerRoute } from '../utils/getServerRoute'
export default getServerRoute(ROUTES.drafts)

35
src/pages/drafts.page.tsx Normal file
View File

@ -0,0 +1,35 @@
import { createMemo, createSignal, For, lazy, onMount, Show, Suspense } from 'solid-js'
import { PageLayout } from '../components/_shared/PageLayout'
import { useSession } from '../context/session'
import { Shout } from '../graphql/types.gen'
import { useRouter } from '../stores/router'
import { apiClient } from '../utils/apiClient'
export const DraftsPage = () => {
const { isAuthenticated, isSessionLoaded, user } = useSession()
const [drafts, setDrafts] = createSignal<Shout[]>([])
onMount(async () => {
const loadedDrafts = await apiClient.getShouts({
filters: {
author: user().slug,
visibility: 'owner'
},
limit: 9999
})
setDrafts(loadedDrafts)
})
return (
<PageLayout>
<Show when={isSessionLoaded()}>
<Show when={isAuthenticated()} fallback="Давайте авторизуемся">
<For each={drafts()}>{(draft) => <div>{draft.title}</div>}</For>
</Show>
</Show>
</PageLayout>
)
}
export const Page = DraftsPage

View File

@ -11,6 +11,7 @@ export const ROUTES = {
create: '/create',
edit: '/edit/:shoutSlug',
editSettings: '/edit/:shoutSlug/settings',
drafts: '/drafts',
topics: '/topics',
topic: '/topic/:slug',
authors: '/authors',