-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UIU-2969: change user type confirmation modal
- Loading branch information
1 parent
3454583
commit bec610e
Showing
7 changed files
with
109 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
...omponents/EditSections/EditUserInfo/components/ChangeUserTypeModal/ChangeUserTypeModal.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import PropTypes from 'prop-types'; | ||
import { FormattedMessage } from 'react-intl'; | ||
|
||
import { | ||
Button, | ||
Modal, | ||
ModalFooter, | ||
} from '@folio/stripes/components'; | ||
|
||
import { USER_TYPES } from '../../../../../constants'; | ||
|
||
const ChangeUserTypeModal = ({ onChange, initialUserType, open }) => { | ||
const userTypeModalFooter = ( | ||
<ModalFooter> | ||
<Button | ||
id="userType-modal-btn" | ||
onClick={() => onChange(USER_TYPES.PATRON)} | ||
> | ||
<FormattedMessage id="ui-users.information.change.userType.modal.button" /> | ||
</Button> | ||
<Button | ||
id="userType-modal-cancel-btn" | ||
onClick={() => onChange(initialUserType)} | ||
> | ||
<FormattedMessage id="ui-users.cancel" /> | ||
</Button> | ||
</ModalFooter> | ||
); | ||
|
||
return ( | ||
<Modal | ||
footer={userTypeModalFooter} | ||
id="userType_confirmation_modal" | ||
label={<FormattedMessage id="ui-users.information.change.userType.modal.label" />} | ||
open={open} | ||
> | ||
<div> | ||
<FormattedMessage | ||
id="ui-users.information.change.userType.modal.text" | ||
/> | ||
</div> | ||
</Modal> | ||
); | ||
}; | ||
|
||
ChangeUserTypeModal.propTypes = { | ||
onChange: PropTypes.func.isRequired, | ||
initialUserType: PropTypes.string.isRequired, | ||
open: PropTypes.bool, | ||
}; | ||
|
||
ChangeUserTypeModal.defaultProps = { | ||
open: false, | ||
}; | ||
|
||
export default ChangeUserTypeModal; |
17 changes: 17 additions & 0 deletions
17
...ents/EditSections/EditUserInfo/components/ChangeUserTypeModal/ChangeUserTypeModal.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { render, screen } from '@folio/jest-config-stripes/testing-library/react'; | ||
|
||
import { USER_TYPES } from '../../../../../constants'; | ||
import ChangeUserTypeModal from './ChangeUserTypeModal'; | ||
|
||
describe('ChangeUserTypeModal', () => { | ||
it('should render component', () => { | ||
const onChange = jest.fn(); | ||
render(<ChangeUserTypeModal | ||
open | ||
onChange={onChange} | ||
initialUserType={USER_TYPES.STAFF} | ||
/>); | ||
|
||
expect(screen.getByTestId('ui-users.information.change.userType.modal.label')).toBeInTheDocument(); | ||
}); | ||
}); |
1 change: 1 addition & 0 deletions
1
src/components/EditSections/EditUserInfo/components/ChangeUserTypeModal/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from './ChangeUserTypeModal'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
/* eslint-disable import/prefer-default-export */ | ||
export { default as ProfilePicture } from './ProfilePicture'; | ||
export { default as ChangeUserTypeModal } from './ChangeUserTypeModal'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters