2023-05-01 18:32:32 +00:00
|
|
|
import { createSignal, For, onMount, Show } from 'solid-js'
|
2023-04-21 15:10:23 +00:00
|
|
|
import { PageLayout } from '../components/_shared/PageLayout'
|
|
|
|
import { useSession } from '../context/session'
|
|
|
|
import { Shout } from '../graphql/types.gen'
|
|
|
|
import { apiClient } from '../utils/apiClient'
|
2023-05-05 20:05:50 +00:00
|
|
|
import { getPagePath } from '@nanostores/router'
|
|
|
|
import { router } from '../stores/router'
|
2023-04-21 15:10:23 +00:00
|
|
|
|
|
|
|
export const DraftsPage = () => {
|
|
|
|
const { isAuthenticated, isSessionLoaded, user } = useSession()
|
|
|
|
|
|
|
|
const [drafts, setDrafts] = createSignal<Shout[]>([])
|
|
|
|
|
|
|
|
onMount(async () => {
|
2023-05-05 20:05:50 +00:00
|
|
|
const loadedDrafts = await apiClient.getDrafts()
|
2023-04-21 15:10:23 +00:00
|
|
|
setDrafts(loadedDrafts)
|
|
|
|
})
|
|
|
|
|
|
|
|
return (
|
|
|
|
<PageLayout>
|
|
|
|
<Show when={isSessionLoaded()}>
|
2023-05-05 20:05:50 +00:00
|
|
|
<div class="wide-container">
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-md-19 col-lg-18 col-xl-16 offset-md-5">
|
|
|
|
<Show when={isAuthenticated()} fallback="Давайте авторизуемся">
|
|
|
|
<For each={drafts()}>
|
|
|
|
{(draft) => (
|
|
|
|
<div>
|
|
|
|
<a href={getPagePath(router, 'edit', { shoutSlug: draft.slug })}>{draft.id}</a>
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
</For>
|
|
|
|
</Show>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2023-04-21 15:10:23 +00:00
|
|
|
</Show>
|
|
|
|
</PageLayout>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export const Page = DraftsPage
|