File size: 1,980 Bytes
f8b5d42 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | import { useRef } from "react";
import Admin from "@/models/admin";
import paths from "@/utils/paths";
import { LinkSimple, Trash } from "@phosphor-icons/react";
export default function WorkspaceRow({ workspace, users }) {
const rowRef = useRef(null);
const handleDelete = async () => {
if (
!window.confirm(
`Are you sure you want to delete ${workspace.name}?\nAfter you do this it will be unavailable in this instance of AnythingLLM.\n\nThis action is irreversible.`
)
)
return false;
rowRef?.current?.remove();
await Admin.deleteWorkspace(workspace.id);
};
return (
<>
<tr
ref={rowRef}
className="bg-transparent text-white text-opacity-80 text-xs font-medium border-b border-white/10 h-10"
>
<th scope="row" className="px-6 whitespace-nowrap">
{workspace.name}
</th>
<td className="px-6 flex items-center">
<a
href={paths.workspace.chat(workspace.slug)}
target="_blank"
rel="noreferrer"
className="text-white flex items-center hover:underline"
>
<LinkSimple className="mr-2 w-4 h-4" /> {workspace.slug}
</a>
</td>
<td className="px-6">
<a
href={paths.workspace.settings.members(workspace.slug)}
className="text-white flex items-center underline"
>
{workspace.userIds?.length}
</a>
</td>
<td className="px-6">{workspace.createdAt}</td>
<td className="px-6 flex items-center gap-x-6 h-full mt-1">
<button
onClick={handleDelete}
className="text-xs font-medium text-white/80 light:text-black/80 hover:light:text-red-500 hover:text-red-300 rounded-lg px-2 py-1 hover:bg-white hover:light:bg-red-50 hover:bg-opacity-10"
>
<Trash className="h-5 w-5" />
</button>
</td>
</tr>
</>
);
}
|