Skip to content

Commit bb405b5

Browse files
committed
feat: select all in potential library
Signed-off-by: Varun Raj <mailme@varunraj.in>
1 parent b752bd2 commit bb405b5

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

src/components/albums/potential-albums/PotentialAlbumsAssets.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export default function PotentialAlbumsAssets() {
3737
isSelected: selectedIds.includes(p.id),
3838
}));
3939
}, [assets, selectedIds]);
40+
console.log(images)
4041

4142
const slides = useMemo(
4243
() =>
@@ -96,6 +97,7 @@ export default function PotentialAlbumsAssets() {
9697
onClick={handleClick}
9798
enableImageSelection={true}
9899
onSelect={handleSelect}
100+
99101
/>
100102
</div>
101103
</>

src/pages/albums/potential-albums.tsx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import PotentialAlbumsDates from "@/components/albums/potential-albums/Potential
44
import PageLayout from "@/components/layouts/PageLayout";
55
import Header from "@/components/shared/Header";
66
import { Badge } from "@/components/ui/badge";
7+
import { Button } from "@/components/ui/button";
78
import { useToast } from "@/components/ui/use-toast";
89
import PotentialAlbumContext, {
910
IPotentialAlbumConfig,
@@ -30,6 +31,7 @@ export default function PotentialAlbums() {
3031
assets: config.assets.filter(
3132
(asset) => !config.selectedIds.includes(asset.id)
3233
),
34+
selectedIds: [],
3335
});
3436
})
3537
.then(() => {
@@ -56,6 +58,31 @@ export default function PotentialAlbums() {
5658
<Badge variant={"outline"}>
5759
{config.selectedIds.length} Selected
5860
</Badge>
61+
{config.selectedIds.length === config.assets.length ? (
62+
<Button
63+
variant={"outline"}
64+
onClick={() =>
65+
setConfig({
66+
...config,
67+
selectedIds: [],
68+
})
69+
}
70+
>
71+
Unselect all
72+
</Button>
73+
) : (
74+
<Button
75+
variant={"outline"}
76+
onClick={() =>
77+
setConfig({
78+
...config,
79+
selectedIds: config.assets.map((a) => a.id),
80+
})
81+
}
82+
>
83+
Select all
84+
</Button>
85+
)}
5986
<AlbumSelectorDialog onSelected={handleSelect} />
6087
</>
6188
}

0 commit comments

Comments
 (0)