Skip to content

Commit

Permalink
fix: add the types to bulk selection hook
Browse files Browse the repository at this point in the history
  • Loading branch information
eshankvaish committed Feb 7, 2024
1 parent e490c30 commit adba8e2
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@devtron-labs/devtron-fe-common-lib",
"version": "0.0.61-beta-3",
"version": "0.0.61-beta-4",
"description": "Supporting common component library",
"main": "dist/index.js",
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions src/Shared/Components/BulkSelection/BulkSelection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import { ReactComponent as ICCheckAll } from '../../../Assets/Icon/ic-check-all.
import { ReactComponent as ICClose } from '../../../Assets/Icon/ic-close.svg'

const BulkSelection = <T,>({ showPagination }: BulkSelectionProps) => {
const { handleBulkSelection, selectedIdentifiers, isChecked, checkboxValue } = useBulkSelection<T>()
const areOptionsSelected = Object.keys(selectedIdentifiers).length > 0
const { handleBulkSelection, isChecked, checkboxValue, getSelectedIdentifiersCount } = useBulkSelection<T>()
const areOptionsSelected = getSelectedIdentifiersCount() > 0
const BulkSelectionItems: BulkSelectionDropdownItemsType[] = [
{
locator: BulkSelectionEvents.SELECT_ALL_ON_PAGE,
Expand Down
2 changes: 2 additions & 0 deletions src/Shared/Components/BulkSelection/BulkSelectionProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ const BulkSelectionContext = createContext<UseBulkSelectionReturnType<any>>({
handleBulkSelection: noop,
isChecked: false,
checkboxValue: CHECKBOX_VALUE.CHECKED,
isBulkSelectionApplied: false,
getSelectedIdentifiersCount: noop,
})

export const useBulkSelection = <T,>() => {
Expand Down
2 changes: 2 additions & 0 deletions src/Shared/Components/BulkSelection/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ export interface GetBulkSelectionCheckboxValuesType {
export interface UseBulkSelectionReturnType<T> extends GetBulkSelectionCheckboxValuesType {
selectedIdentifiers: T
handleBulkSelection: ({ action, data }: HandleBulkSelectionType<T>) => void
isBulkSelectionApplied: boolean
getSelectedIdentifiersCount: () => number
}

export interface BulkSelectionProps {
Expand Down

0 comments on commit adba8e2

Please sign in to comment.