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
+4
View File
@@ -10,10 +10,12 @@ type ResponseObject = {
type LinkStore = {
links: LinkIncludingShortenedCollectionAndTags[];
selectedLinks: number[];
setLinks: (
data: LinkIncludingShortenedCollectionAndTags[],
isInitialCall: boolean
) => void;
setSelectedLinks: (linkIds: number[]) => void;
addLink: (
body: LinkIncludingShortenedCollectionAndTags
) => Promise<ResponseObject>;
@@ -27,6 +29,7 @@ type LinkStore = {
const useLinkStore = create<LinkStore>()((set) => ({
links: [],
selectedLinks: [],
setLinks: async (data, isInitialCall) => {
isInitialCall &&
set(() => ({
@@ -45,6 +48,7 @@ const useLinkStore = create<LinkStore>()((set) => ({
),
}));
},
setSelectedLinks: (linkIds) => set({ selectedLinks: linkIds }),
addLink: async (body) => {
const response = await fetch("/api/v1/links", {
body: JSON.stringify(body),
-1
View File
@@ -1,5 +1,4 @@
import { create } from "zustand";
import { ViewMode } from "@/types/global";
type LocalSettings = {
theme?: string;