-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement backend for local hub items + placeholder endpoints to fetc…
…h hub app data
- Loading branch information
1 parent
795c87d
commit de7866c
Showing
9 changed files
with
486 additions
and
169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
frontend/src/pages/GeneralSettings/CommunityHub/HubItemRow/index.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { Trash } from "@phosphor-icons/react"; | ||
import { useState } from "react"; | ||
import showToast from "@/utils/toast"; | ||
import Hub from "@/models/hub"; | ||
|
||
export default function HubItemRow({ item, onDelete }) { | ||
const [deleting, setDeleting] = useState(false); | ||
|
||
const handleDelete = async () => { | ||
if (deleting) return; | ||
setDeleting(true); | ||
const success = await Hub.deleteItem(item.id); | ||
if (!success) { | ||
showToast("Failed to delete item", "error"); | ||
setDeleting(false); | ||
return; | ||
} | ||
showToast("Item deleted successfully", "success"); | ||
onDelete(item.id); | ||
}; | ||
|
||
return ( | ||
<tr className="bg-transparent text-white text-opacity-80 text-sm font-medium"> | ||
<td className="px-6 py-4">{item.name}</td> | ||
<td className="px-6 py-4 capitalize">{item.type}</td> | ||
<td className="px-6 py-4"> | ||
{new Date(item.createdAt).toLocaleDateString()} | ||
</td> | ||
<td className="px-6 py-4 cursor-pointer"> | ||
<button | ||
onClick={handleDelete} | ||
disabled={deleting} | ||
className="transition-all duration-300 p-2 rounded-lg text-white/60 hover:text-white hover:bg-white/10" | ||
> | ||
<Trash className="h-5 w-5" /> | ||
</button> | ||
</td> | ||
</tr> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.