Added selectedLinks to store & checkbox on list view

This commit is contained in:
Isaac Wise
2024-02-09 23:24:22 -06:00
parent c78aa2da0d
commit 0a070deebd
4 changed files with 17 additions and 4 deletions
+12 -2
View File
@@ -26,7 +26,11 @@ export default function LinkCardCompact({
flipDropdown,
}: Props) {
const { collections } = useCollectionStore();
const { links } = useLinkStore();
const { links, setSelectedLinks, selectedLinks } = useLinkStore();
const handleCheckboxClick = (checkboxId: number) => {
setSelectedLinks((selectedLinks.includes(checkboxId) ? selectedLinks.filter((id) => id !== checkboxId) : [...selectedLinks, checkboxId]));
};
let shortendURL;
@@ -56,9 +60,15 @@ export default function LinkCardCompact({
return (
<>
<div
className={`border-neutral-content relative ${!showInfo && !isPWA() ? "hover:bg-base-300 p-3" : "py-3"
className={`border-neutral-content relative items-center flex ${!showInfo && !isPWA() ? "hover:bg-base-300 p-3" : "py-3"
} duration-200 rounded-lg`}
>
<input
type="checkbox"
className="checkbox checkbox-primary my-auto mr-2"
checked={selectedLinks.includes(link.id)}
onChange={() => handleCheckboxClick(link.id)}
/>
<Link
href={generateLinkHref(link)}
target="_blank"