|
|
|
@@ -1,12 +1,10 @@ |
|
|
|
import axios from 'axios' |
|
|
|
import toCamel from 'camelcase-keys' |
|
|
|
import { useEffect, useState } from 'react' |
|
|
|
|
|
|
|
import PostFormTagsArea from '@/components/PostFormTagsArea' |
|
|
|
import PostOriginalCreatedTimeField from '@/components/PostOriginalCreatedTimeField' |
|
|
|
import Label from '@/components/common/Label' |
|
|
|
import { Button } from '@/components/ui/button' |
|
|
|
import { API_BASE_URL } from '@/config' |
|
|
|
import { apiPut } from '@/lib/api' |
|
|
|
|
|
|
|
import type { FC } from 'react' |
|
|
|
|
|
|
|
@@ -41,14 +39,11 @@ export default (({ post, onSave }: Props) => { |
|
|
|
const [tags, setTags] = useState<string> ('') |
|
|
|
|
|
|
|
const handleSubmit = async () => { |
|
|
|
const res = await axios.put ( |
|
|
|
`${ API_BASE_URL }/posts/${ post.id }`, |
|
|
|
{ title, tags, |
|
|
|
original_created_from: originalCreatedFrom, |
|
|
|
const data = await apiPut<Post> ( |
|
|
|
`/posts/${ post.id }`, |
|
|
|
{ title, tags, original_created_from: originalCreatedFrom, |
|
|
|
original_created_before: originalCreatedBefore }, |
|
|
|
{ headers: { 'Content-Type': 'multipart/form-data', |
|
|
|
'X-Transfer-Code': localStorage.getItem ('user_code') ?? '' } }) |
|
|
|
const data = toCamel (res.data as any, { deep: true }) as Post |
|
|
|
{ headers: { 'Content-Type': 'multipart/form-data' } }) |
|
|
|
onSave ({ ...post, |
|
|
|
title: data.title, |
|
|
|
tags: data.tags, |
|
|
|
|