This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
import axios from 'axios'
|
||||
import React, { useEffect, useState } from 'react'
|
||||
import { useState } from 'react'
|
||||
|
||||
import TextArea from '@/components/common/TextArea'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { API_BASE_URL } from '@/config'
|
||||
|
||||
import type { Post, Tag } from '@/types'
|
||||
import type { Post } from '@/types'
|
||||
|
||||
type Props = { post: Post
|
||||
onSave: (newPost: Post) => void }
|
||||
@@ -19,9 +19,10 @@ export default ({ post, onSave }: Props) => {
|
||||
.join (' '))
|
||||
|
||||
const handleSubmit = async () => {
|
||||
const { data } = await axios.put (`${ API_BASE_URL }/posts/${ post.id }`, { title, tags },
|
||||
const res = await axios.put (`${ API_BASE_URL }/posts/${ post.id }`, { title, tags },
|
||||
{ headers: { 'Content-Type': 'multipart/form-data',
|
||||
'X-Transfer-Code': localStorage.getItem ('user_code') || '' } } )
|
||||
const data = res.data as Post
|
||||
onSave ({ ...post,
|
||||
title: data.title,
|
||||
tags: data.tags } as Post)
|
||||
|
||||
Reference in New Issue
Block a user