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>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user