-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Add bulk actions #223
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add bulk actions #223
Changes from all commits
2fe2f34
a19d8a4
1bda482
fcfbcbf
f9ae125
fa3dc5c
6760fb6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,116 @@ | ||||||||||||||||||||||||||||||
| import { usePostHog } from "posthog-js/react"; | ||||||||||||||||||||||||||||||
| import { | ||||||||||||||||||||||||||||||
| useBulkUnsubscribe, | ||||||||||||||||||||||||||||||
| useBulkApprove, | ||||||||||||||||||||||||||||||
| useBulkAutoArchive, | ||||||||||||||||||||||||||||||
| useBulkArchive, | ||||||||||||||||||||||||||||||
| useBulkDelete, | ||||||||||||||||||||||||||||||
| } from "@/app/(app)/bulk-unsubscribe/hooks"; | ||||||||||||||||||||||||||||||
| import { PremiumTooltip, usePremium } from "@/components/PremiumAlert"; | ||||||||||||||||||||||||||||||
| import { ButtonLoader } from "@/components/Loading"; | ||||||||||||||||||||||||||||||
| import { Button } from "@/components/ui/button"; | ||||||||||||||||||||||||||||||
| import { usePremiumModal } from "@/app/(app)/premium/PremiumModal"; | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| export function BulkActions({ | ||||||||||||||||||||||||||||||
| selected, | ||||||||||||||||||||||||||||||
| mutate, | ||||||||||||||||||||||||||||||
| }: { | ||||||||||||||||||||||||||||||
| selected: Map<string, boolean>; | ||||||||||||||||||||||||||||||
| mutate: () => Promise<any>; | ||||||||||||||||||||||||||||||
| }) { | ||||||||||||||||||||||||||||||
|
Comment on lines
+14
to
+20
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid using The use of Apply this diff to replace - mutate: () => Promise<any>;
+ mutate: () => Promise<void>;Committable suggestion
Suggested change
ToolsBiome
|
||||||||||||||||||||||||||||||
| const posthog = usePostHog(); | ||||||||||||||||||||||||||||||
| const { hasUnsubscribeAccess, mutate: refetchPremium } = usePremium(); | ||||||||||||||||||||||||||||||
| const { PremiumModal, openModal } = usePremiumModal(); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| const { bulkUnsubscribeLoading, onBulkUnsubscribe } = useBulkUnsubscribe({ | ||||||||||||||||||||||||||||||
| hasUnsubscribeAccess, | ||||||||||||||||||||||||||||||
| mutate, | ||||||||||||||||||||||||||||||
| posthog, | ||||||||||||||||||||||||||||||
| refetchPremium, | ||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| const { bulkApproveLoading, onBulkApprove } = useBulkApprove({ | ||||||||||||||||||||||||||||||
| mutate, | ||||||||||||||||||||||||||||||
| posthog, | ||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| const { bulkAutoArchiveLoading, onBulkAutoArchive } = useBulkAutoArchive({ | ||||||||||||||||||||||||||||||
| hasUnsubscribeAccess, | ||||||||||||||||||||||||||||||
| mutate, | ||||||||||||||||||||||||||||||
| posthog, | ||||||||||||||||||||||||||||||
| refetchPremium, | ||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| const { onBulkArchive } = useBulkArchive({ mutate, posthog }); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| const { onBulkDelete } = useBulkDelete({ mutate, posthog }); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| const getSelectedValues = () => | ||||||||||||||||||||||||||||||
| Array.from(selected.entries()) | ||||||||||||||||||||||||||||||
| .filter(([_, value]) => value) | ||||||||||||||||||||||||||||||
| .map(([name, value]) => ({ | ||||||||||||||||||||||||||||||
| name, | ||||||||||||||||||||||||||||||
| value, | ||||||||||||||||||||||||||||||
| })); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| return ( | ||||||||||||||||||||||||||||||
| <> | ||||||||||||||||||||||||||||||
| <PremiumTooltip showTooltip={!hasUnsubscribeAccess} openModal={openModal}> | ||||||||||||||||||||||||||||||
| <div className="flex items-center space-x-1.5"> | ||||||||||||||||||||||||||||||
| <div> | ||||||||||||||||||||||||||||||
| <Button | ||||||||||||||||||||||||||||||
| size="sm" | ||||||||||||||||||||||||||||||
| variant="outline" | ||||||||||||||||||||||||||||||
| onClick={() => onBulkUnsubscribe(getSelectedValues())} | ||||||||||||||||||||||||||||||
| disabled={bulkUnsubscribeLoading} | ||||||||||||||||||||||||||||||
| > | ||||||||||||||||||||||||||||||
| {bulkUnsubscribeLoading && <ButtonLoader />} | ||||||||||||||||||||||||||||||
| Unsubscribe | ||||||||||||||||||||||||||||||
| </Button> | ||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||
| <div> | ||||||||||||||||||||||||||||||
| <Button | ||||||||||||||||||||||||||||||
| size="sm" | ||||||||||||||||||||||||||||||
| variant="outline" | ||||||||||||||||||||||||||||||
| onClick={() => onBulkAutoArchive(getSelectedValues())} | ||||||||||||||||||||||||||||||
| disabled={bulkAutoArchiveLoading} | ||||||||||||||||||||||||||||||
| > | ||||||||||||||||||||||||||||||
| {bulkAutoArchiveLoading && <ButtonLoader />} | ||||||||||||||||||||||||||||||
| Auto Archive | ||||||||||||||||||||||||||||||
| </Button> | ||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||
| <div> | ||||||||||||||||||||||||||||||
| <Button | ||||||||||||||||||||||||||||||
| size="sm" | ||||||||||||||||||||||||||||||
| variant="outline" | ||||||||||||||||||||||||||||||
| onClick={() => onBulkApprove(getSelectedValues())} | ||||||||||||||||||||||||||||||
| disabled={bulkApproveLoading} | ||||||||||||||||||||||||||||||
| > | ||||||||||||||||||||||||||||||
| {bulkApproveLoading && <ButtonLoader />} | ||||||||||||||||||||||||||||||
| Approve | ||||||||||||||||||||||||||||||
| </Button> | ||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||
| <div> | ||||||||||||||||||||||||||||||
| <Button | ||||||||||||||||||||||||||||||
| size="sm" | ||||||||||||||||||||||||||||||
| variant="outline" | ||||||||||||||||||||||||||||||
| onClick={() => onBulkArchive(getSelectedValues())} | ||||||||||||||||||||||||||||||
| > | ||||||||||||||||||||||||||||||
| Archive All | ||||||||||||||||||||||||||||||
| </Button> | ||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||
| <div> | ||||||||||||||||||||||||||||||
| <Button | ||||||||||||||||||||||||||||||
| size="sm" | ||||||||||||||||||||||||||||||
| variant="outline" | ||||||||||||||||||||||||||||||
| onClick={() => onBulkDelete(getSelectedValues())} | ||||||||||||||||||||||||||||||
| > | ||||||||||||||||||||||||||||||
| Delete All | ||||||||||||||||||||||||||||||
| </Button> | ||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||
| </PremiumTooltip> | ||||||||||||||||||||||||||||||
| <PremiumModal /> | ||||||||||||||||||||||||||||||
| </> | ||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid using
anytype.The use of
anytype for themutatefunction should be avoided. Specify a more specific type to enable better type checking and maintainability.Apply this diff to replace
anywith a more specific type:Committable suggestion
Tools
Biome