2023-11-14 15:10:00 +00:00
|
|
|
import { redirectPage } from '@nanostores/router'
|
2023-12-13 10:39:31 +00:00
|
|
|
import { Meta } from '@solidjs/meta'
|
2023-11-14 15:10:00 +00:00
|
|
|
import { clsx } from 'clsx'
|
|
|
|
|
2023-05-31 12:23:18 +00:00
|
|
|
import { Button } from '../components/_shared/Button'
|
|
|
|
import { Icon } from '../components/_shared/Icon'
|
2023-11-14 15:10:00 +00:00
|
|
|
import { PageLayout } from '../components/_shared/PageLayout'
|
|
|
|
import { AuthGuard } from '../components/AuthGuard'
|
|
|
|
import { useLocalize } from '../context/localize'
|
2023-11-28 13:18:25 +00:00
|
|
|
import { apiClient } from '../graphql/client/core'
|
2023-05-31 12:23:18 +00:00
|
|
|
import { router } from '../stores/router'
|
2023-12-13 10:39:31 +00:00
|
|
|
import { getImageUrl } from '../utils/getImageUrl'
|
2023-11-14 15:10:00 +00:00
|
|
|
|
2023-07-02 05:08:42 +00:00
|
|
|
import { LayoutType } from './types'
|
2023-11-14 15:10:00 +00:00
|
|
|
|
|
|
|
import styles from '../styles/Create.module.scss'
|
2023-02-17 09:21:02 +00:00
|
|
|
|
2023-07-02 05:08:42 +00:00
|
|
|
const handleCreate = async (layout: LayoutType) => {
|
2023-06-10 14:10:05 +00:00
|
|
|
const shout = await apiClient.createArticle({ article: { layout: layout } })
|
|
|
|
redirectPage(router, 'edit', {
|
2023-11-14 15:10:00 +00:00
|
|
|
shoutId: shout.id.toString(),
|
2023-06-10 14:10:05 +00:00
|
|
|
})
|
2023-05-31 12:23:18 +00:00
|
|
|
}
|
2023-03-29 08:51:27 +00:00
|
|
|
|
2023-05-31 12:23:18 +00:00
|
|
|
export const CreatePage = () => {
|
|
|
|
const { t } = useLocalize()
|
2023-12-13 10:39:31 +00:00
|
|
|
const ogImage = getImageUrl('production/image/logo_image.png')
|
|
|
|
const ogTitle = t('Choose a post type')
|
|
|
|
const description = t('Participate in the Discours: share information, join the editorial team')
|
2023-11-14 10:45:44 +00:00
|
|
|
|
2023-02-17 09:21:02 +00:00
|
|
|
return (
|
2023-12-13 10:39:31 +00:00
|
|
|
<PageLayout title={ogTitle}>
|
|
|
|
<Meta name="descprition" content={description} />
|
|
|
|
<Meta name="keywords" content={t('keywords')} />
|
|
|
|
<Meta name="og:type" content="article" />
|
|
|
|
<Meta name="og:title" content={ogTitle} />
|
|
|
|
<Meta name="og:image" content={ogImage} />
|
|
|
|
<Meta name="twitter:image" content={ogImage} />
|
|
|
|
<Meta name="og:description" content={description} />
|
|
|
|
<Meta name="twitter:card" content="summary_large_image" />
|
|
|
|
<Meta name="twitter:title" content={ogTitle} />
|
|
|
|
<Meta name="twitter:description" content={description} />
|
2023-09-21 11:38:22 +00:00
|
|
|
<AuthGuard>
|
|
|
|
<article class={clsx('wide-container', 'container--static-page', styles.Create)}>
|
|
|
|
<h1>{t('Choose a post type')}</h1>
|
|
|
|
<ul class={clsx('nodash', styles.list)}>
|
|
|
|
<li>
|
|
|
|
<div class={styles.link} onClick={() => handleCreate('article')}>
|
|
|
|
<Icon name="create-article" class={styles.icon} />
|
|
|
|
<div>{t('article')}</div>
|
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<div class={styles.link} onClick={() => handleCreate('literature')}>
|
|
|
|
<Icon name="create-books" class={styles.icon} />
|
|
|
|
<div>{t('literature')}</div>
|
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<div class={styles.link} onClick={() => handleCreate('image')}>
|
|
|
|
<Icon name="create-images" class={styles.icon} />
|
|
|
|
<div>{t('images')}</div>
|
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
<li>
|
2023-11-28 13:18:25 +00:00
|
|
|
<div class={styles.link} onClick={() => handleCreate('audio')}>
|
2023-09-21 11:38:22 +00:00
|
|
|
<Icon name="create-music" class={styles.icon} />
|
|
|
|
<div>{t('music')}</div>
|
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<div class={styles.link} onClick={() => handleCreate('video')}>
|
|
|
|
<Icon name="create-video" class={styles.icon} />
|
|
|
|
<div>{t('video')}</div>
|
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
<Button value={t('Back')} onClick={() => window.history.back()} />
|
|
|
|
</article>
|
|
|
|
</AuthGuard>
|
2023-02-17 09:21:02 +00:00
|
|
|
</PageLayout>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export const Page = CreatePage
|