editor-wip
This commit is contained in:
parent
142c5bfb41
commit
a5bb138fc7
|
@ -13,21 +13,6 @@ import { LayoutType } from '~/types/common'
|
||||||
|
|
||||||
const EditView = lazy(() => import('~/components/Views/EditView/EditView'))
|
const EditView = lazy(() => import('~/components/Views/EditView/EditView'))
|
||||||
|
|
||||||
export const getContentTypeTitle = (layout: LayoutType) => {
|
|
||||||
switch (layout) {
|
|
||||||
case 'audio':
|
|
||||||
return 'Publish Album'
|
|
||||||
case 'image':
|
|
||||||
return 'Create gallery'
|
|
||||||
case 'video':
|
|
||||||
return 'Create video'
|
|
||||||
case 'literature':
|
|
||||||
return 'New literary work'
|
|
||||||
default:
|
|
||||||
return 'Write an article'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default (props: RouteSectionProps) => {
|
export default (props: RouteSectionProps) => {
|
||||||
const { t } = useLocalize()
|
const { t } = useLocalize()
|
||||||
const { session } = useSession()
|
const { session } = useSession()
|
||||||
|
@ -44,7 +29,8 @@ export default (props: RouteSectionProps) => {
|
||||||
createEffect(on(session, (s) => s?.access_token && loadDraft(), { defer: true }))
|
createEffect(on(session, (s) => s?.access_token && loadDraft(), { defer: true }))
|
||||||
|
|
||||||
const loadDraft = async () => {
|
const loadDraft = async () => {
|
||||||
const result = await client()?.query(getShoutDraft, { shout_id: props.params.id }).toPromise()
|
const shout_id = Number.parseInt(props.params.id)
|
||||||
|
const result = await client()?.query(getShoutDraft, { shout_id }).toPromise()
|
||||||
if (result) {
|
if (result) {
|
||||||
const { shout: loadedShout, error } = result.data.get_my_shout
|
const { shout: loadedShout, error } = result.data.get_my_shout
|
||||||
if (error) {
|
if (error) {
|
||||||
|
@ -56,14 +42,21 @@ export default (props: RouteSectionProps) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const title = createMemo(() => {
|
const title = createMemo(() => {
|
||||||
if (!shout()) {
|
const layout = (shout()?.layout as LayoutType) || 'article'
|
||||||
return t('Create post')
|
if (!shout()) return 'Create post'
|
||||||
}
|
return (
|
||||||
return t(getContentTypeTitle(shout()?.layout as LayoutType))
|
{
|
||||||
|
article: 'Write an article',
|
||||||
|
audio: 'Publish Album',
|
||||||
|
image: 'Create gallery',
|
||||||
|
video: 'Create video',
|
||||||
|
literature: 'New literary work'
|
||||||
|
}[layout] || 'Write an article'
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PageLayout title={`${t('Discours')} :: ${title()}`}>
|
<PageLayout title={`${t('Discours')} :: ${t(title())}`}>
|
||||||
<AuthGuard>
|
<AuthGuard>
|
||||||
<EditView shout={shout() as Shout} />
|
<EditView shout={shout() as Shout} />
|
||||||
</AuthGuard>
|
</AuthGuard>
|
||||||
|
|
|
@ -17,7 +17,8 @@ export default (props: RouteSectionProps) => {
|
||||||
createEffect(on(session, (s) => s?.access_token && loadDraft(), { defer: true }))
|
createEffect(on(session, (s) => s?.access_token && loadDraft(), { defer: true }))
|
||||||
const [shout, setShout] = createSignal<Shout>()
|
const [shout, setShout] = createSignal<Shout>()
|
||||||
const loadDraft = async () => {
|
const loadDraft = async () => {
|
||||||
const result = await client()?.query(getShoutDraft, { shout_id: props.params.id }).toPromise()
|
const shout_id = Number.parseInt(props.params.id)
|
||||||
|
const result = await client()?.query(getShoutDraft, { shout_id }).toPromise()
|
||||||
if (result) {
|
if (result) {
|
||||||
const { shout: loadedShout, error } = result.data.get_my_shout
|
const { shout: loadedShout, error } = result.data.get_my_shout
|
||||||
if (error) throw new Error(error)
|
if (error) throw new Error(error)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user