Merge branch 'dev' into hotfix/posting

This commit is contained in:
Untone 2024-02-03 00:22:11 +03:00
commit 5f47bf161c
3 changed files with 11 additions and 12 deletions

View File

@ -122,11 +122,10 @@ export const EditorProvider = (props: { children: JSX.Element }) => {
const updateShout = async (formToUpdate: ShoutForm, { publish }: { publish: boolean }) => { const updateShout = async (formToUpdate: ShoutForm, { publish }: { publish: boolean }) => {
return await apiClient.updateArticle({ return await apiClient.updateArticle({
shoutId: formToUpdate.shoutId, shout_id: formToUpdate.shoutId,
shoutInput: { shout_input: {
...formToUpdate, ...formToUpdate,
topics: formToUpdate.selectedTopics.map((topic) => topic2topicInput(topic)), // NOTE: first is main topics: formToUpdate.selectedTopics.map((topic) => topic2topicInput(topic)), // NOTE: first is main
media: formToUpdate.media,
cover: formToUpdate.coverImageUrl, cover: formToUpdate.coverImageUrl,
}, },
publish, publish,
@ -196,10 +195,10 @@ export const EditorProvider = (props: { children: JSX.Element }) => {
} }
} }
const publishShoutById = async (shoutId: number) => { const publishShoutById = async (shout_id: number) => {
try { try {
await apiClient.updateArticle({ await apiClient.updateArticle({
shoutId, shout_id,
publish: true, publish: true,
}) })

View File

@ -150,16 +150,16 @@ export const apiClient = {
return response.data.create_shout.shout return response.data.create_shout.shout
}, },
updateArticle: async ({ updateArticle: async ({
shoutId, shout_id,
shoutInput, shout_input,
publish, publish,
}: { }: {
shoutId: number shout_id: number
shoutInput?: ShoutInput shout_input?: ShoutInput
publish: boolean publish: boolean
}): Promise<Shout> => { }): Promise<Shout> => {
const response = await apiClient.private const response = await apiClient.private
.mutation(updateArticle, { shoutId, shoutInput, publish }) .mutation(updateArticle, { shout_id, shout_input, publish })
.toPromise() .toPromise()
console.debug('[graphql.client.core] updateArticle:', response.data) console.debug('[graphql.client.core] updateArticle:', response.data)
return response.data.update_shout.shout return response.data.update_shout.shout

View File

@ -1,8 +1,8 @@
import { gql } from '@urql/core' import { gql } from '@urql/core'
export default gql` export default gql`
mutation UpdateShoutMutation($shoutId: Int!, $shoutInput: ShoutInput, $publish: Boolean) { mutation UpdateShoutMutation($shout_id: Int!, $shout_input: ShoutInput, $publish: Boolean) {
update_shout(shout_id: $shoutId, shout_input: $shoutInput, publish: $publish) { update_shout(shout_id: $shout_id, shout_input: $shout_input, publish: $publish) {
error error
shout { shout {
id id