Small improvement to persona table

This commit is contained in:
Weves 2024-01-08 18:35:40 -08:00 committed by Chris Weaver
parent 733626f277
commit 77b0d76f53

View File

@ -138,130 +138,6 @@ export function PersonasTable({ personas }: { personas: Persona[] }) {
})}
setRows={updatePersonaOrder}
/>
<Divider />
{/* <TableBody>
{sortedPersonas.map((persona) => {
return (
<DraggableRow key={persona.id}>
<TableCell className="whitespace-normal break-none">
<p className="text font-medium">{persona.name}</p>
</TableCell>
<TableCell className="whitespace-normal break-all max-w-2xl">
{persona.description}
</TableCell>
<TableCell>{persona.default_persona ? "Yes" : "No"}</TableCell>
<TableCell>
{" "}
<div
onClick={async () => {
const response = await fetch(
`/api/admin/persona/${persona.id}/visible`,
{
method: "PATCH",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
is_visible: !persona.is_visible,
}),
}
);
if (response.ok) {
router.refresh();
} else {
setPopup({
type: "error",
message: `Failed to update persona - ${await response.text()}`,
});
}
}}
className="px-1 py-0.5 hover:bg-hover-light rounded flex cursor-pointer select-none w-fit"
>
<div className="my-auto w-12">
{!persona.is_visible ? (
<div className="text-error">Hidden</div>
) : (
"Visible"
)}
</div>
<div className="ml-1 my-auto">
<CustomCheckbox checked={persona.is_visible} />
</div>
</div>
</TableCell>
<TableCell>
{persona.is_visible ? (
<EditableValue
emptyDisplay="-"
initialValue={
persona.display_priority !== null
? persona.display_priority.toString()
: ""
}
onSubmit={async (value) => {
if (
value === (persona.display_priority || "").toString()
) {
return true;
}
const numericDisplayPriority = Number(value);
if (isNaN(numericDisplayPriority)) {
setPopup({
message: "Display priority must be a number",
type: "error",
});
return false;
}
const response = await fetch(
`/api/admin/persona/${persona.id}/display-priority`,
{
method: "PATCH",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
display_priority: numericDisplayPriority,
}),
}
);
if (!response.ok) {
setPopup({
message: `Failed to update display priority - ${await response.text()}`,
type: "error",
});
}
router.refresh();
return true;
}}
/>
) : (
"-"
)}
</TableCell>
<TableCell>
<div className="flex">
<div className="mx-auto">
{!persona.default_persona ? (
<EditButton
onClick={() =>
router.push(`/admin/personas/${persona.id}`)
}
/>
) : (
"-"
)}
</div>
</div>
</TableCell>
</DraggableRow>
);
})}
</TableBody> */}
</div>
);
}