-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
Copy pathpage.tsx
92 lines (86 loc) · 2.93 KB
/
page.tsx
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import {Fragment, Suspense} from 'react';
import Link from 'next/link';
import {editChangelog} from 'sentry-docs/actions/changelog';
import {FileUpload} from 'sentry-docs/components/changelog/fileUpload';
import {ForwardRefEditor} from 'sentry-docs/components/changelog/forwardRefEditor';
import {TitleSlug} from 'sentry-docs/components/changelog/titleSlug';
import {Button} from 'sentry-docs/components/changelog/ui/Button';
import {Select} from 'sentry-docs/components/changelog/ui/Select';
import {prisma} from 'sentry-docs/prisma';
export default async function ChangelogCreatePage({params}) {
const categories = await prisma.category.findMany();
const changelog = await prisma.changelog.findUnique({
where: {id: params.id},
include: {
author: true,
categories: true,
},
});
if (!changelog) {
return (
<Fragment>
<header>
<h2>Changelog not found</h2>
</header>
<footer>
<Link href="/changelogs">Return to Changelogs list</Link>
</footer>
</Fragment>
);
}
return (
<section className="overflow-x-auto col-start-3 col-span-8">
<form action={editChangelog} className="px-2 w-full">
<input type="hidden" name="id" value={changelog.id} />
<TitleSlug defaultSlug={changelog.slug} defaultTitle={changelog.title} />
<FileUpload defaultFile={changelog.image || ''} />
<div className="my-6">
<label htmlFor="summary" className="block text-xs font-medium text-gray-700">
Summary
<Fragment>
<span className="font-bold text-secondary">*</span>
</Fragment>
</label>
<textarea name="summary" className="w-full" required>
{changelog.summary}
</textarea>
<span className="text-xs text-gray-500 italic">
This will be shown in the list
</span>
</div>
<div>
<Select
name="categories"
className="mt-1 mb-6"
label="Category"
placeholder="Select Category"
defaultValue={changelog.categories.map(category => ({
label: category.name,
value: category.name,
}))}
options={categories.map(category => ({
label: category.name,
value: category.name,
}))}
isMulti
/>
</div>
<Suspense fallback={null}>
<ForwardRefEditor
name="content"
defaultValue={changelog.content || ''}
className="w-full"
/>
</Suspense>
<footer className="flex items-center justify-between mt-2 mb-8">
<Link href="/changelog/_admin" className="underline text-gray-500">
Return to Changelogs list
</Link>
<div>
<Button type="submit">Update</Button>
</div>
</footer>
</form>
</section>
);
}