Skip to content

Commit ba1ec75

Browse files
committed
Fix admin asset creation dropdown
1 parent 662608a commit ba1ec75

4 files changed

Lines changed: 16 additions & 32 deletions

File tree

Site/src/global.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,7 @@ select,
480480
background: var(--darker);
481481
filter: drop-shadow(0 10px 8px rgba(255, 255, 255, 0.04))
482482
drop-shadow(0 0px 3px rgba(255, 255, 255, 0.1));
483+
max-height: min(50vh, 20rem);
483484

484485
@starting-style {
485486
opacity: 0;

Site/src/lib/assetTypes.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export default Object.freeze({
1+
const types = Object.freeze({
22
1: "Image",
33
2: "T-Shirt",
44
3: "Audio",
@@ -26,4 +26,9 @@ export default Object.freeze({
2626
37: "Code",
2727
38: "Plugin",
2828
42: "Face Accessory",
29-
} as { [_: string]: string })
29+
} as { [_: number]: string })
30+
31+
export default types
32+
export const typeToNumber: { [_: string]: number } = Object.fromEntries(
33+
Object.entries(types).map(([key, value]) => [value, +key])
34+
)

Site/src/routes/(main)/admin/create/+page.server.ts

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,42 +3,20 @@ import { redirect } from "@sveltejs/kit"
33
import { type } from "arktype"
44
import { arktype } from "sveltekit-superforms/adapters"
55
import { superValidate } from "sveltekit-superforms/server"
6+
import types, { typeToNumber } from "$lib/assetTypes"
67
import { authorise } from "$lib/server/auth"
78
import formError from "$lib/server/formError"
89
import { db, Record } from "$lib/server/surreal"
910
import createQuery from "./create.surql"
1011

1112
const schema = type({
1213
type: type
13-
.enumerated(
14-
1,
15-
2,
16-
3,
17-
4,
18-
5,
19-
8,
20-
10,
21-
11,
22-
12,
23-
13,
24-
16,
25-
17,
26-
18,
27-
19,
28-
24,
29-
25,
30-
26,
31-
27,
32-
28,
33-
29,
34-
30,
35-
31,
36-
32,
37-
35,
38-
37,
39-
38,
40-
42
41-
)
14+
.enumerated(...Object.values(types))
15+
.pipe(t => {
16+
const num = typeToNumber[t]
17+
if (!num) throw new Error("Invalid asset type")
18+
return num
19+
})
4220
.configure({
4321
problem: "must be a valid asset type",
4422
}),

Site/src/routes/(main)/admin/create/+page.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
submit="Create">
3939
<Select
4040
formData={formDataManual}
41-
options={Object.entries(types)}
41+
options={Object.values(types)}
4242
name="type"
4343
label="Asset type" />
4444
<Input

0 commit comments

Comments
 (0)