@availity/feedback 0.0.0-t325224b2 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Feedback.js DELETED
@@ -1,48 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import { UncontrolledDropdown, DropdownToggle, DropdownMenu } from 'reactstrap';
4
- import FeedbackForm from './FeedbackForm';
5
-
6
- const Feedback = ({
7
- appName,
8
- formProps,
9
- children,
10
- className,
11
- color,
12
- outline,
13
- prompt,
14
- onFeedbackSent,
15
- ...props
16
- }) => (
17
- <UncontrolledDropdown className={`${className} hidden-print`} {...props}>
18
- <DropdownToggle color={color} outline={outline}>
19
- {children || 'Give Feedback'}
20
- </DropdownToggle>
21
- <DropdownMenu right className="p-3" style={{ width: '400px' }}>
22
- <FeedbackForm
23
- name={appName}
24
- onFeedbackSent={onFeedbackSent}
25
- prompt={prompt}
26
- {...formProps}
27
- />
28
- </DropdownMenu>
29
- </UncontrolledDropdown>
30
- );
31
-
32
- Feedback.propTypes = {
33
- appName: PropTypes.string.isRequired,
34
- className: PropTypes.string,
35
- prompt: PropTypes.string,
36
- color: PropTypes.string,
37
- outline: PropTypes.bool,
38
- formProps: PropTypes.object,
39
- children: PropTypes.node,
40
- onFeedbackSent: PropTypes.func,
41
- };
42
-
43
- Feedback.defaultProps = {
44
- className: '',
45
- color: 'light',
46
- };
47
-
48
- export default Feedback;
package/FeedbackButton.js DELETED
@@ -1,36 +0,0 @@
1
- import React, { Component } from 'react';
2
- import { PropTypes } from 'prop-types';
3
- import { Button } from 'reactstrap';
4
-
5
- const btnStyles = { fontSize: '1.4em', padding: '.2em .4em' };
6
-
7
- class FeedbackButton extends Component {
8
- static propTypes = {
9
- onClick: PropTypes.func,
10
- icon: PropTypes.string,
11
- active: PropTypes.string,
12
- children: PropTypes.node,
13
- };
14
-
15
- onClickHandler = () => {
16
- const { onClick, icon } = this.props;
17
-
18
- onClick(icon);
19
- };
20
-
21
- render() {
22
- const { icon, active, children } = this.props;
23
- return (
24
- <Button
25
- style={btnStyles}
26
- color={active === icon ? 'primary' : 'light'}
27
- onClick={this.onClickHandler}
28
- >
29
- <span className={`icon icon-${icon}`} />
30
- <span className="sr-only">{children}</span>
31
- </Button>
32
- );
33
- }
34
- }
35
-
36
- export default FeedbackButton;
package/FeedbackForm.d.ts DELETED
@@ -1,21 +0,0 @@
1
- type FaceOption = {
2
- icon?: string;
3
- description?: string;
4
- };
5
-
6
- type AboutOption = {
7
- icon?: string;
8
- label?: string;
9
- };
10
-
11
- export interface FeedBackFormProps {
12
- name: string;
13
- onFeedbackSent?: Function;
14
- faceOptions?: Array<FaceOption>;
15
- aboutOptions?: Array<AboutOption>;
16
- prompt?: string;
17
- }
18
-
19
- declare const FeedBackForm: React.ComponentType<FeedBackFormProps>;
20
-
21
- export default FeedBackForm;
package/FeedbackForm.js DELETED
@@ -1,137 +0,0 @@
1
- import React, { Component } from 'react';
2
- import PropTypes from 'prop-types';
3
- import { Button, ButtonGroup, Input, FormFeedback } from 'reactstrap';
4
- import { avLogMessagesApi, avRegionsApi } from '@availity/api-axios';
5
- import FeedbackButton from './FeedbackButton';
6
-
7
- class FeedbackForm extends Component {
8
- static propTypes = {
9
- name: PropTypes.string.isRequired,
10
- onFeedbackSent: PropTypes.func,
11
- faceOptions: PropTypes.arrayOf(
12
- PropTypes.shape({
13
- icon: PropTypes.string,
14
- description: PropTypes.string,
15
- })
16
- ),
17
- aboutOptions: PropTypes.arrayOf(
18
- PropTypes.shape({
19
- value: PropTypes.string,
20
- label: PropTypes.string,
21
- })
22
- ),
23
- prompt: PropTypes.string,
24
- };
25
-
26
- static defaultProps = {
27
- faceOptions: [
28
- {
29
- icon: 'smile',
30
- description: 'Smiley face',
31
- },
32
- {
33
- icon: 'meh',
34
- description: 'Meh face',
35
- },
36
- {
37
- icon: 'frown',
38
- description: 'Frowny face',
39
- },
40
- ],
41
- aboutOptions: [],
42
- };
43
-
44
- state = {};
45
-
46
- setActive = icon => {
47
- this.setState({ active: icon, invalid: null });
48
- };
49
-
50
- setTextFeedback = e => {
51
- this.setState({ textFeedback: e.target.value });
52
- };
53
-
54
- componentWillReceiveProps() {
55
- const { sent } = this.state;
56
-
57
- if (sent) {
58
- this.state = {};
59
- }
60
- }
61
-
62
- sendFeedback = async () => {
63
- const { active, textFeedback } = this.state;
64
- const { name, onFeedbackSent } = this.props;
65
- if (!active) {
66
- this.setState({ invalid: true });
67
- return;
68
- }
69
- const response = await avRegionsApi.getCurrentRegion();
70
- await avLogMessagesApi.info({
71
- surveyId: `${name.replace(/\s/g, '_')}_Smile_Survey`,
72
- smileLocation: `${name}`,
73
- smile: `icon-${active}`,
74
- feedback: textFeedback,
75
- url: window.location.href,
76
- region: response.data.regions[0] && response.data.regions[0].id,
77
- userAgent: window.navigator.userAgent,
78
- submitTime: new Date(),
79
- });
80
-
81
- if (onFeedbackSent) {
82
- onFeedbackSent(this.state);
83
- }
84
- this.setState({ sent: true, invalid: false });
85
- };
86
-
87
- render() {
88
- const { sent, active, invalid } = this.state;
89
- const { name, prompt, faceOptions, aboutOptions } = this.props;
90
-
91
- return sent ? (
92
- <div className="text-center">Thank you for your feedback.</div>
93
- ) : (
94
- <div className="text-center">
95
- <p>{prompt || `Tell us what you think about ${name}.`}</p>
96
- <ButtonGroup>
97
- {faceOptions.map(option => (
98
- <FeedbackButton
99
- key={option.icon}
100
- icon={option.icon}
101
- active={active}
102
- onClick={this.setActive}
103
- >
104
- {option.description}
105
- </FeedbackButton>
106
- ))}
107
- </ButtonGroup>
108
- <FormFeedback className={invalid ? 'd-block' : undefined}>
109
- Please select one of the faces above
110
- </FormFeedback>
111
- {aboutOptions.length > 0 && (
112
- <select className="custom-select" type="select">
113
- {aboutOptions.map(option => (
114
- <option key={option.value} value={option.value}>
115
- {option.label}
116
- </option>
117
- ))}
118
- </select>
119
- )}
120
- <Input
121
- className="mt-3"
122
- type="textarea"
123
- placeholder="Feedback? Requests? Defects? (optional)"
124
- onChange={this.setTextFeedback}
125
- aria-label="Please provide any feedback, requests, and/or defects."
126
- />
127
- <div className="mt-3 text-right">
128
- <Button onClick={this.sendFeedback} color="primary">
129
- Send
130
- </Button>
131
- </div>
132
- </div>
133
- );
134
- }
135
- }
136
-
137
- export default FeedbackForm;
package/LICENSE DELETED
@@ -1,20 +0,0 @@
1
- Copyright (c) 2017-present Availity, LLC
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,59 +0,0 @@
1
- import React from 'react';
2
- import { render } from 'react-testing-library';
3
- import Feedback from '..';
4
-
5
- describe('Feedback', () => {
6
- test('should render', () => {
7
- const { container } = render(<Feedback appName="Payer Space" />);
8
-
9
- expect(container).toMatchSnapshot();
10
- });
11
-
12
- test('should render custom button text', () => {
13
- const { container } = render(
14
- <Feedback appName="Payer Space">Provide Valuable Feedback</Feedback>
15
- );
16
-
17
- expect(container).toMatchSnapshot();
18
- });
19
-
20
- test('should render custom button color', () => {
21
- const { container } = render(
22
- <Feedback appName="Payer Space" color="success" />
23
- );
24
-
25
- expect(container).toMatchSnapshot();
26
- });
27
-
28
- test('should render custom prompt text', () => {
29
- const { container } = render(
30
- <Feedback appName="Payer Space" prompt="Provide same feedback" />
31
- );
32
-
33
- expect(container).toMatchSnapshot();
34
- });
35
-
36
- test('should render custom form props', () => {
37
- const { container } = render(
38
- <Feedback
39
- appName="Payer Space"
40
- formProps={{
41
- aboutOptions: [
42
- { value: 'payerSpace', label: 'Payer Space' },
43
- { value: 'wholeSite', label: 'Whole Site' },
44
- ],
45
- }}
46
- />
47
- );
48
-
49
- expect(container).toMatchSnapshot();
50
- });
51
-
52
- test('should render custom className', () => {
53
- const { container } = render(
54
- <Feedback appName="Payer Space" className="junk and-stuff" />
55
- );
56
-
57
- expect(container).toMatchSnapshot();
58
- });
59
- });
@@ -1,99 +0,0 @@
1
- import React from 'react';
2
- import { render, fireEvent } from 'react-testing-library';
3
- import { FeedbackForm } from '..';
4
-
5
- describe('Feedback', () => {
6
- test('should render', () => {
7
- const { container } = render(<FeedbackForm name="Payer Space" />);
8
-
9
- expect(container).toMatchSnapshot();
10
- });
11
-
12
- test('should indicate active smiley', () => {
13
- const { container, getByText } = render(
14
- <FeedbackForm name="Payer Space" />
15
- );
16
-
17
- // Get the Option with the smiley face
18
- const smileyFeedbackField = getByText('Smiley face');
19
-
20
- // Simulate the Click
21
- fireEvent.click(smileyFeedbackField);
22
-
23
- expect(container).toMatchSnapshot();
24
- });
25
-
26
- test('should set the feedback text value', () => {
27
- const { container, getByPlaceholderText } = render(
28
- <FeedbackForm name="Payer Space" />
29
- );
30
-
31
- // Get the Input Node for the Feedback
32
- const feedbackNode = getByPlaceholderText(
33
- 'Feedback? Requests? Defects? (optional)'
34
- );
35
-
36
- // Simulate a user typing the value below into the field
37
- fireEvent.change(feedbackNode, {
38
- target: { value: 'some good text here' },
39
- });
40
-
41
- // Check if the Input Got Updated
42
- expect(feedbackNode.value).toEqual('some good text here');
43
-
44
- expect(container).toMatchSnapshot();
45
- });
46
-
47
- test('should render custom face icons', () => {
48
- const faceOptions = [
49
- {
50
- icon: 'happy',
51
- description: 'Happy face',
52
- },
53
- {
54
- icon: 'okay',
55
- description: 'Okay face',
56
- },
57
- {
58
- icon: 'sad',
59
- description: 'Sad face',
60
- },
61
- {
62
- icon: 'confused',
63
- description: 'Confused face',
64
- },
65
- ];
66
-
67
- const { container } = render(
68
- <FeedbackForm name="Payer Space" faceOptions={faceOptions} />
69
- );
70
-
71
- expect(container).toMatchSnapshot();
72
- });
73
-
74
- test('should render custom button color', () => {
75
- const aboutOptions = [
76
- {
77
- value: 'this space',
78
- label: 'This Payer Space',
79
- },
80
- {
81
- value: 'that space',
82
- label: 'That Payer Space',
83
- },
84
- {
85
- value: 'portal',
86
- label: 'Portal as a whole',
87
- },
88
- {
89
- value: 'availity',
90
- label: 'Availity as a whole',
91
- },
92
- ];
93
- const { container } = render(
94
- <FeedbackForm name="Payer Space" aboutOptions={aboutOptions} />
95
- );
96
-
97
- expect(container).toMatchSnapshot();
98
- });
99
- });