This commit is contained in:
Isaac Wise
2024-02-11 01:29:11 -06:00
parent e2c6993a6d
commit 0a77ee90a7
15 changed files with 186 additions and 129 deletions
+11 -7
View File
@@ -9,14 +9,18 @@ type Props = {
onChange: any;
showDefaultValue?: boolean;
defaultValue?:
| {
label: string;
value?: number;
}
| undefined;
| {
label: string;
value?: number;
}
| undefined;
};
export default function CollectionSelection({ onChange, defaultValue, showDefaultValue = true }: Props) {
export default function CollectionSelection({
onChange,
defaultValue,
showDefaultValue = true,
}: Props) {
const { collections } = useCollectionStore();
const router = useRouter();
@@ -52,7 +56,7 @@ export default function CollectionSelection({ onChange, defaultValue, showDefaul
options={options}
styles={styles}
defaultValue={showDefaultValue ? defaultValue : null}
// menuPosition="fixed"
// menuPosition="fixed"
/>
);
}
+1 -1
View File
@@ -4,7 +4,7 @@ import { LinkIncludingShortenedCollectionAndTags } from "@/types/global";
export default function CardView({
links,
showCheckbox = true,
editMode
editMode,
}: {
links: LinkIncludingShortenedCollectionAndTags[];
showCheckbox?: boolean;
+1 -2
View File
@@ -4,7 +4,7 @@ import { LinkIncludingShortenedCollectionAndTags } from "@/types/global";
export default function ListView({
links,
showCheckbox = true,
editMode
editMode,
}: {
links: LinkIncludingShortenedCollectionAndTags[];
showCheckbox?: boolean;
@@ -21,7 +21,6 @@ export default function ListView({
showCheckbox={showCheckbox}
flipDropdown={i === links.length - 1}
editMode={editMode}
/>
);
})}
+3 -2
View File
@@ -32,7 +32,7 @@ export default function LinkCard({
link,
flipDropdown,
showCheckbox = true,
editMode
editMode,
}: Props) {
const { collections } = useCollectionStore();
const { account } = useAccountStore();
@@ -103,7 +103,8 @@ export default function LinkCard({
ref={ref}
className="border border-solid border-neutral-content bg-base-200 shadow-md hover:shadow-none duration-100 rounded-2xl relative"
>
{showCheckbox && editMode &&
{showCheckbox &&
editMode &&
(permissions === true ||
permissions?.canCreate ||
permissions?.canDelete) && (
+16 -8
View File
@@ -35,8 +35,12 @@ export default function LinkCardCompact({
const { account } = useAccountStore();
const { links, setSelectedLinks, selectedLinks } = useLinkStore();
const handleCheckboxClick = (link: LinkIncludingShortenedCollectionAndTags) => {
const linkIndex = selectedLinks.findIndex(selectedLink => selectedLink.id === link.id);
const handleCheckboxClick = (
link: LinkIncludingShortenedCollectionAndTags
) => {
const linkIndex = selectedLinks.findIndex(
(selectedLink) => selectedLink.id === link.id
);
if (linkIndex !== -1) {
const updatedLinks = [...selectedLinks];
@@ -77,17 +81,21 @@ export default function LinkCardCompact({
return (
<>
<div
className={`border-neutral-content relative items-center flex ${!showInfo && !isPWA() ? "hover:bg-base-300 p-3" : "py-3"
} duration-200 rounded-lg`}
className={`border-neutral-content relative items-center flex ${
!showInfo && !isPWA() ? "hover:bg-base-300 p-3" : "py-3"
} duration-200 rounded-lg`}
>
{showCheckbox && editMode &&
{showCheckbox &&
editMode &&
(permissions === true ||
permissions?.canCreate ||
permissions?.canDelete) && (
<input
type="checkbox"
className="checkbox checkbox-primary my-auto mr-2"
checked={selectedLinks.some(selectedLink => selectedLink.id === link.id)}
checked={selectedLinks.some(
(selectedLink) => selectedLink.id === link.id
)}
onChange={() => handleCheckboxClick(link)}
/>
)}
@@ -131,8 +139,8 @@ export default function LinkCardCompact({
collection={collection}
position="top-3 right-3"
flipDropdown={flipDropdown}
// toggleShowInfo={() => setShowInfo(!showInfo)}
// linkInfo={showInfo}
// toggleShowInfo={() => setShowInfo(!showInfo)}
// linkInfo={showInfo}
/>
{showInfo ? (
<div>
@@ -34,7 +34,11 @@ export default function BulkEditLinksModal({ onClose }: Props) {
const load = toast.loading("Updating...");
const response = await updateLinks(selectedLinks, removePreviousTags, updatedValues);
const response = await updateLinks(
selectedLinks,
removePreviousTags,
updatedValues
);
toast.dismiss(load);
@@ -58,7 +62,10 @@ export default function BulkEditLinksModal({ onClose }: Props) {
<div className="grid sm:grid-cols-2 gap-3">
<div>
<p className="mb-2">Collection</p>
<CollectionSelection showDefaultValue={false} onChange={setCollection} />
<CollectionSelection
showDefaultValue={false}
onChange={setCollection}
/>
</div>
<div>
@@ -71,7 +78,6 @@ export default function BulkEditLinksModal({ onClose }: Props) {
<input
type="checkbox"
className="checkbox checkbox-primary"
checked={removePreviousTags}
onChange={(e) => setRemovePreviousTags(e.target.checked)}
/>
+10 -8
View File
@@ -26,20 +26,22 @@ export default function ViewDropdown({ viewMode, setViewMode }: Props) {
<div className="p-1 flex flex-row gap-1 border border-neutral-content rounded-[0.625rem]">
<button
onClick={(e) => onChangeViewMode(e, ViewMode.Card)}
className={`btn btn-square btn-sm btn-ghost ${viewMode == ViewMode.Card
? "bg-primary/20 hover:bg-primary/20"
: "hover:bg-neutral/20"
}`}
className={`btn btn-square btn-sm btn-ghost ${
viewMode == ViewMode.Card
? "bg-primary/20 hover:bg-primary/20"
: "hover:bg-neutral/20"
}`}
>
<i className="bi-grid w-4 h-4 text-neutral"></i>
</button>
<button
onClick={(e) => onChangeViewMode(e, ViewMode.List)}
className={`btn btn-square btn-sm btn-ghost ${viewMode == ViewMode.List
? "bg-primary/20 hover:bg-primary/20"
: "hover:bg-neutral/20"
}`}
className={`btn btn-square btn-sm btn-ghost ${
viewMode == ViewMode.List
? "bg-primary/20 hover:bg-primary/20"
: "hover:bg-neutral/20"
}`}
>
<i className="bi bi-view-stacked w-4 h-4 text-neutral"></i>
</button>