Adds NPCs
This commit is contained in:
46
src/components/documents/npc/NpcRow.tsx
Normal file
46
src/components/documents/npc/NpcRow.tsx
Normal file
@@ -0,0 +1,46 @@
|
||||
import { AutoSaveTextarea } from "@/components/AutoSaveTextarea";
|
||||
import { pb } from "@/lib/pocketbase";
|
||||
import type { Npc } from "@/lib/types";
|
||||
|
||||
/**
|
||||
* Renders an editable npc row
|
||||
*/
|
||||
export const NpcRow = ({ npc }: { npc: Npc }) => {
|
||||
async function saveNpcName(name: string) {
|
||||
await pb.collection("documents").update(npc.id, {
|
||||
data: {
|
||||
...npc.data,
|
||||
npc: {
|
||||
...npc.data.npc,
|
||||
name,
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async function saveNpcDescription(description: string) {
|
||||
await pb.collection("documents").update(npc.id, {
|
||||
data: {
|
||||
...npc.data,
|
||||
npc: {
|
||||
...npc.data.npc,
|
||||
description,
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="">
|
||||
<AutoSaveTextarea
|
||||
multiline={false}
|
||||
value={npc.data.npc.name}
|
||||
onSave={saveNpcName}
|
||||
/>
|
||||
<AutoSaveTextarea
|
||||
value={npc.data.npc.description}
|
||||
onSave={saveNpcDescription}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user