BulkActionCheckbox.tsx
2 years ago
BulkActionSelect.module.scss
3 years ago
BulkActionSelect.tsx
2 years ago
BulkActionSelect.tsx
40 lines
| 1 | import pageStyles from '@givewp/components/ListTable/ListTablePage/ListTablePage.module.scss'; |
| 2 | import styles from './BulkActionSelect.module.scss'; |
| 3 | import {__} from '@wordpress/i18n'; |
| 4 | import Select from '@givewp/components/ListTable/Select'; |
| 5 | |
| 6 | export const BulkActionSelect = ({bulkActions = null, selectedState, showModal, data, parameters}) => { |
| 7 | const [selectedAction, setSelectedAction] = selectedState; |
| 8 | |
| 9 | if (window.GiveDonations && window.GiveDonations.addonsBulkActions) { |
| 10 | bulkActions = [...bulkActions, ...window.GiveDonations.addonsBulkActions]; |
| 11 | } |
| 12 | |
| 13 | if (!bulkActions) { |
| 14 | return null; |
| 15 | } |
| 16 | |
| 17 | const changeSelected = (event) => { |
| 18 | setSelectedAction(event.target.value); |
| 19 | }; |
| 20 | |
| 21 | return ( |
| 22 | <form id={styles.bulkActionsForm} onSubmit={showModal}> |
| 23 | <Select value={selectedAction} onChange={changeSelected}> |
| 24 | <option value="">{__('Bulk Actions', 'give')}</option> |
| 25 | {bulkActions.map((action) => { |
| 26 | if (typeof action?.isVisible == 'function' && !action.isVisible(data, parameters)) { |
| 27 | return null; |
| 28 | } |
| 29 | return ( |
| 30 | <option key={action.value} value={action.value}> |
| 31 | {action.label} |
| 32 | </option> |
| 33 | ); |
| 34 | })} |
| 35 | </Select> |
| 36 | <button className={pageStyles.addFormButton}>{__('Apply', 'give')}</button> |
| 37 | </form> |
| 38 | ); |
| 39 | }; |
| 40 |