fixed an vault edit error.
This commit is contained in:
@@ -83,9 +83,9 @@ const CALIBERS_BY_PLATFORM: Record<
|
||||
type CaliberOption = string | "";
|
||||
|
||||
// -----------------------------
|
||||
// Other controlled fields (optional scaffolding)
|
||||
// Build Class (controlled list)
|
||||
// -----------------------------
|
||||
const PURPOSE_OPTIONS = [
|
||||
const BUILD_CLASS_OPTIONS = [
|
||||
"Home Defense",
|
||||
"Duty / Patrol",
|
||||
"Training",
|
||||
@@ -94,7 +94,7 @@ const PURPOSE_OPTIONS = [
|
||||
"Range / Fun",
|
||||
] as const;
|
||||
|
||||
type PurposeOption = (typeof PURPOSE_OPTIONS)[number] | "";
|
||||
type BuildClassOption = (typeof BUILD_CLASS_OPTIONS)[number] | "";
|
||||
|
||||
function fmt(d?: string | null) {
|
||||
if (!d) return "—";
|
||||
@@ -133,7 +133,7 @@ export default function EditBuildPage() {
|
||||
|
||||
platform: PlatformOption;
|
||||
caliber: CaliberOption;
|
||||
purpose: PurposeOption;
|
||||
buildClass: BuildClassOption;
|
||||
|
||||
tagsText: string; // comma-separated for MVP
|
||||
coverImageUrl: string;
|
||||
@@ -201,9 +201,11 @@ export default function EditBuildPage() {
|
||||
platform: normalizedPlatform,
|
||||
caliber: normalizedCaliber,
|
||||
|
||||
purpose: (PURPOSE_OPTIONS.includes((dto.buildClass ?? "") as any)
|
||||
buildClass: (BUILD_CLASS_OPTIONS.includes(
|
||||
(dto.buildClass ?? "") as any
|
||||
)
|
||||
? (dto.buildClass as any)
|
||||
: "") as PurposeOption,
|
||||
: "") as BuildClassOption,
|
||||
|
||||
tagsText: Array.isArray(dto.tags) ? dto.tags.join(", ") : "",
|
||||
coverImageUrl: dto.coverImageUrl ?? "",
|
||||
@@ -265,7 +267,7 @@ export default function EditBuildPage() {
|
||||
isPublic: !!profile.isPublic,
|
||||
|
||||
// Backend expects buildClass (not purpose)
|
||||
buildClass: profile.purpose || null,
|
||||
buildClass: profile.buildClass || null,
|
||||
|
||||
caliber: profile.caliber || null,
|
||||
coverImageUrl: profile.coverImageUrl?.trim() || null,
|
||||
@@ -454,24 +456,29 @@ export default function EditBuildPage() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Purpose */}
|
||||
{/* Build Class */}
|
||||
<div>
|
||||
<label className="block text-xs font-medium text-white/70">
|
||||
Purpose
|
||||
Build Class
|
||||
</label>
|
||||
<select
|
||||
value={profile.purpose}
|
||||
value={profile.buildClass}
|
||||
onChange={(e) =>
|
||||
setProfile((p) =>
|
||||
p ? { ...p, purpose: e.target.value as PurposeOption } : p
|
||||
p
|
||||
? {
|
||||
...p,
|
||||
buildClass: e.target.value as BuildClassOption,
|
||||
}
|
||||
: p
|
||||
)
|
||||
}
|
||||
className="mt-1 w-full rounded-md border border-white/10 bg-black/30 px-3 py-2 text-sm text-white outline-none focus:ring-1 focus:ring-amber-400/60"
|
||||
>
|
||||
<option value="">Select…</option>
|
||||
{PURPOSE_OPTIONS.map((p) => (
|
||||
<option key={p} value={p}>
|
||||
{p}
|
||||
{BUILD_CLASS_OPTIONS.map((c) => (
|
||||
<option key={c} value={c}>
|
||||
{c}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
@@ -602,7 +609,7 @@ export default function EditBuildPage() {
|
||||
{profile.caliber || "—"}
|
||||
</span>
|
||||
<span className="rounded-full border border-white/10 bg-white/5 px-2 py-1">
|
||||
{profile.purpose || "—"}
|
||||
{profile.buildClass || "—"}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
||||
Generated
+9
@@ -1012,6 +1012,7 @@
|
||||
"integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"bin": {
|
||||
"acorn": "bin/acorn"
|
||||
},
|
||||
@@ -1452,6 +1453,7 @@
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"baseline-browser-mapping": "^2.8.25",
|
||||
"caniuse-lite": "^1.0.30001754",
|
||||
@@ -2134,6 +2136,7 @@
|
||||
"deprecated": "This version is no longer supported. Please see https://eslint.org/version-support for other options.",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@eslint-community/eslint-utils": "^4.2.0",
|
||||
"@eslint-community/regexpp": "^4.6.1",
|
||||
@@ -2302,6 +2305,7 @@
|
||||
"integrity": "sha512-whOE1HFo/qJDyX4SnXzP4N6zOWn79WhnCUY/iDR0mPfQZO8wcYE4JClzI2oZrhBnnMUCBCHZhO6VQyoBU95mZA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@rtsao/scc": "^1.1.0",
|
||||
"array-includes": "^3.1.9",
|
||||
@@ -4531,6 +4535,7 @@
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"nanoid": "^3.3.7",
|
||||
"picocolors": "^1.0.0",
|
||||
@@ -4780,6 +4785,7 @@
|
||||
"resolved": "https://registry.npmjs.org/react/-/react-18.3.1.tgz",
|
||||
"integrity": "sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ==",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"loose-envify": "^1.1.0"
|
||||
},
|
||||
@@ -4792,6 +4798,7 @@
|
||||
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.3.1.tgz",
|
||||
"integrity": "sha512-5m4nQKp+rZRb09LNH59GM4BxTh9251/ylbKIbpe7TpGxfJ+9kv6BLkLBXIjjspbgbnIBNqlI23tRnTWT0snUIw==",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"loose-envify": "^1.1.0",
|
||||
"scheduler": "^0.23.2"
|
||||
@@ -5796,6 +5803,7 @@
|
||||
"integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
@@ -5965,6 +5973,7 @@
|
||||
"integrity": "sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"peer": true,
|
||||
"bin": {
|
||||
"tsc": "bin/tsc",
|
||||
"tsserver": "bin/tsserver"
|
||||
|
||||
Reference in New Issue
Block a user