You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

52 lines
1.1 KiB

  1. import axios from 'axios'
  2. import { useState } from 'react'
  3. import { API_BASE_URL } from '@/config'
  4. export default () => {
  5. const [threadName, setThreadName] = useState ('')
  6. const [threadDescription, setThreadDescription] = useState ('')
  7. const submit = async () => {
  8. const formData = new FormData
  9. formData.append ('title', threadName)
  10. formData.append ('description', threadDescription)
  11. try
  12. {
  13. await axios.post (`${ API_BASE_URL }/threads`, formData)
  14. }
  15. catch
  16. {
  17. ;
  18. }
  19. }
  20. return (
  21. <form className="mb-2">
  22. {/* スレッド名 */}
  23. <div>
  24. <label>スレッド名:</label>
  25. <input type="text"
  26. className="border border-black"
  27. value={threadName}
  28. onChange={ev => setThreadName (ev.target.value)} />
  29. </div>
  30. {/* スレッド説明 */}
  31. <div>
  32. <label>スレッド説明:</label>
  33. <textarea className="border border-black"
  34. value={threadDescription}
  35. onChange={ev => setThreadDescription (ev.target.value)} />
  36. </div>
  37. {/* 作成 */}
  38. <button type="button"
  39. onClick={submit}>
  40. スレッド作成
  41. </button>
  42. </form>)
  43. }