minor-fix

This commit is contained in:
Untone 2024-02-03 00:19:58 +03:00
parent 829e523d36
commit 571e3cd8a4
3 changed files with 12 additions and 21 deletions

View File

@ -122,20 +122,11 @@ export const EditorProvider = (props: { children: JSX.Element }) => {
const updateShout = async (formToUpdate: ShoutForm, { publish }: { publish: boolean }) => {
return await apiClient.updateArticle({
shoutId: formToUpdate.shoutId,
shoutInput: {
body: formToUpdate.body,
shout_id: formToUpdate.shoutId,
shout_input: {
...formToUpdate,
topics: formToUpdate.selectedTopics.map((topic) => topic2topicInput(topic)), // NOTE: first is main
// authors?: InputMaybe<Array<InputMaybe<Scalars['String']>>>
// community?: InputMaybe<Scalars['Int']>
// mainTopic: topic2topicInput(formToUpdate.mainTopic),
slug: formToUpdate.slug,
subtitle: formToUpdate.subtitle,
title: formToUpdate.title,
lead: formToUpdate.lead,
description: formToUpdate.description,
cover: formToUpdate.coverImageUrl,
media: formToUpdate.media,
},
publish,
})
@ -204,10 +195,10 @@ export const EditorProvider = (props: { children: JSX.Element }) => {
}
}
const publishShoutById = async (shoutId: number) => {
const publishShoutById = async (shout_id: number) => {
try {
await apiClient.updateArticle({
shoutId,
shout_id,
publish: true,
})

View File

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

View File

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