1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import { Head, useForm, router, Link } from '@inertiajs/react'
import Layout from '../../Layout'
import ImageUploadForm from '../../../components/ImageUploadForm'
export default function New({ auth, errors = {}, tags }) {
const { data, setData, processing } = useForm({
title: '',
file: null,
tag_ids: [],
status: 'approved',
})
const handleSubmit = (e) => {
e.preventDefault()
router.post('/admin/images', { image: data })
}
return (
<Layout user={auth}>
<Head title="添加新图片" />
<div className="bg-white shadow overflow-hidden sm:rounded-lg">
<div className="px-4 py-5 sm:px-6">
<div className="flex items-center mb-4">
<Link
href="/admin/images"
className="inline-flex items-center text-sm font-medium text-indigo-600 hover:text-indigo-500"
>
<svg xmlns="http://www.w3.org/2000/svg" className="h-5 w-5 mr-1" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M10 19l-7-7m0 0l7-7m-7 7h18" />
</svg>
返回图片列表
</Link>
</div>
<h1 className="text-2xl font-bold text-gray-900">添加新图片</h1>
<p className="mt-1 max-w-2xl text-sm text-gray-500">
添加新图片(自动审核通过)
</p>
</div>
<div className="border-t border-gray-200 px-4 py-5 sm:px-6">
<ImageUploadForm
data={data}
setData={setData}
processing={processing}
errors={errors}
onSubmit={handleSubmit}
submitButtonText="添加图片"
processingButtonText="添加中..."
showTagsField={true}
tags={tags}
/>
</div>
</div>
</Layout>
)
}