Cleans up the new-doc forms.
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
import { useState } from "react";
|
||||
import type { CampaignId, Treasure } from "@/lib/types";
|
||||
import { pb } from "@/lib/pocketbase";
|
||||
import { BaseForm } from "@/components/form/BaseForm";
|
||||
import { SingleLineInput } from "@/components/form/SingleLineInput";
|
||||
|
||||
/**
|
||||
* Renders a form to add a new treasure. Calls onCreate with the new treasure document.
|
||||
@@ -42,29 +44,18 @@ export const NewTreasureForm = ({
|
||||
}
|
||||
|
||||
return (
|
||||
<form
|
||||
className="flex flex-col items-center gap-2 mt-4 w-full"
|
||||
<BaseForm
|
||||
title="Create new treasure"
|
||||
isLoading={adding || !newTreasure.trim()}
|
||||
onSubmit={handleSubmit}
|
||||
>
|
||||
<div>
|
||||
<input
|
||||
type="text"
|
||||
className="flex-1 px-3 py-2 rounded bg-slate-800 text-slate-100 border border-slate-700 focus:outline-none focus:ring-2 focus:ring-violet-500"
|
||||
placeholder="Add a new treasure..."
|
||||
error={error}
|
||||
content={
|
||||
<SingleLineInput
|
||||
value={newTreasure}
|
||||
onChange={(e) => setNewTreasure(e.target.value)}
|
||||
disabled={adding}
|
||||
aria-label="Add new treasure"
|
||||
onChange={setNewTreasure}
|
||||
placeholder="Treasure description"
|
||||
/>
|
||||
</div>
|
||||
{error && <div className="text-red-400 mt-2 text-sm">{error}</div>}
|
||||
<button
|
||||
type="submit"
|
||||
className="px-4 py-2 rounded bg-emerald-600 hover:bg-emerald-700 text-white font-semibold transition-colors disabled:opacity-60"
|
||||
disabled={adding || !newTreasure.trim()}
|
||||
>
|
||||
{adding ? "Adding..." : "Add Treasure"}
|
||||
</button>
|
||||
</form>
|
||||
}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user