shout create
This commit is contained in:
parent
5b791d7a26
commit
5a3560fc12
|
@ -47,8 +47,21 @@ export const CreateView = () => {
|
||||||
setTopics(allTopics)
|
setTopics(allTopics)
|
||||||
})
|
})
|
||||||
|
|
||||||
const handleFormSubmit = (e) => {
|
const handleFormSubmit = async (e) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
|
|
||||||
|
const newShout = await apiClient.createArticle({
|
||||||
|
article: {
|
||||||
|
slug: form.slug,
|
||||||
|
title: form.title,
|
||||||
|
subtitle: form.subtitle,
|
||||||
|
body: form.body,
|
||||||
|
topics: form.selectedTopics.map((topic) => topic.slug),
|
||||||
|
mainTopic: form.selectedTopics[0].slug
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
router.open(getPagePath(router, 'article', { slug: newShout.slug }))
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleTitleInputChange = (e) => {
|
const handleTitleInputChange = (e) => {
|
||||||
|
|
|
@ -5,13 +5,13 @@ export default gql`
|
||||||
createShout(inp: $shout) {
|
createShout(inp: $shout) {
|
||||||
error
|
error
|
||||||
shout {
|
shout {
|
||||||
_id: slug
|
id
|
||||||
slug
|
slug
|
||||||
title
|
title
|
||||||
subtitle
|
subtitle
|
||||||
body
|
body
|
||||||
topics {
|
topics {
|
||||||
# id
|
id
|
||||||
title
|
title
|
||||||
slug
|
slug
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,7 @@ const handleClientRouteLinkClick = (event) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const anchor = document.querySelector(selector)
|
const anchor = document.querySelector(selector)
|
||||||
const headerOffset = 80 // 100px for header
|
const headerOffset = 80 // 80px for header
|
||||||
const elementPosition = anchor ? anchor.getBoundingClientRect().top : 0
|
const elementPosition = anchor ? anchor.getBoundingClientRect().top : 0
|
||||||
const newScrollTop = elementPosition + window.scrollY - headerOffset
|
const newScrollTop = elementPosition + window.scrollY - headerOffset
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,8 @@ import type {
|
||||||
ProfileInput,
|
ProfileInput,
|
||||||
ReactionInput,
|
ReactionInput,
|
||||||
Chat,
|
Chat,
|
||||||
ReactionBy
|
ReactionBy,
|
||||||
|
Shout
|
||||||
} from '../graphql/types.gen'
|
} from '../graphql/types.gen'
|
||||||
import { publicGraphQLClient } from '../graphql/publicGraphQLClient'
|
import { publicGraphQLClient } from '../graphql/publicGraphQLClient'
|
||||||
import { getToken, privateGraphQLClient } from '../graphql/privateGraphQLClient'
|
import { getToken, privateGraphQLClient } from '../graphql/privateGraphQLClient'
|
||||||
|
@ -234,10 +235,10 @@ export const apiClient = {
|
||||||
const response = await publicGraphQLClient.query(topicBySlug, { slug }).toPromise()
|
const response = await publicGraphQLClient.query(topicBySlug, { slug }).toPromise()
|
||||||
return response.data.getTopic
|
return response.data.getTopic
|
||||||
},
|
},
|
||||||
createArticle: async ({ article }: { article: ShoutInput }) => {
|
createArticle: async ({ article }: { article: ShoutInput }): Promise<Shout> => {
|
||||||
const response = await privateGraphQLClient.mutation(createArticle, { shout: article }).toPromise()
|
const response = await privateGraphQLClient.mutation(createArticle, { shout: article }).toPromise()
|
||||||
console.debug('[createArticle]:', response.data)
|
console.debug('[createArticle]:', response.data)
|
||||||
return response.data.createShout
|
return response.data.createShout.shout
|
||||||
},
|
},
|
||||||
createReaction: async (input: ReactionInput) => {
|
createReaction: async (input: ReactionInput) => {
|
||||||
const response = await privateGraphQLClient.mutation(reactionCreate, { reaction: input }).toPromise()
|
const response = await privateGraphQLClient.mutation(reactionCreate, { reaction: input }).toPromise()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user