|
1 | | -import React, {FC, useContext} from 'react' |
| 1 | +import React, {FC, ChangeEvent, useContext, useState} from 'react' |
2 | 2 |
|
3 | 3 | // Components |
4 | | -import {Overlay} from '@influxdata/clockface' |
| 4 | +import { |
| 5 | + Button, |
| 6 | + ButtonType, |
| 7 | + ComponentColor, |
| 8 | + ComponentStatus, |
| 9 | + DropdownItemType, |
| 10 | + Form, |
| 11 | + Icon, |
| 12 | + IconFont, |
| 13 | + Method, |
| 14 | + Overlay, |
| 15 | + QuestionMarkTooltip, |
| 16 | + SelectDropdown, |
| 17 | + TextArea, |
| 18 | +} from '@influxdata/clockface' |
| 19 | +import {SafeBlankLink} from 'src/utils/SafeBlankLink' |
5 | 20 |
|
6 | 21 | // Contexts |
7 | 22 | import {OverlayContext} from 'src/overlays/components/OverlayController' |
8 | 23 |
|
9 | 24 | // Types |
10 | 25 | import ErrorBoundary from 'src/shared/components/ErrorBoundary' |
11 | 26 |
|
| 27 | +import './ContactSupport.scss' |
12 | 28 | interface OwnProps { |
13 | 29 | onClose: () => void |
14 | 30 | } |
15 | 31 |
|
16 | 32 | const PayGSupportOverlay: FC<OwnProps> = () => { |
| 33 | + const [severity, setSeverity] = useState('') |
| 34 | + const [textInput, setTextInput] = useState('') |
17 | 35 | const {onClose} = useContext(OverlayContext) |
18 | 36 |
|
| 37 | + const severityLevel = [ |
| 38 | + '1 - Critical', |
| 39 | + '2 - High', |
| 40 | + '3 - Standard', |
| 41 | + '4 - Request', |
| 42 | + ] |
| 43 | + |
| 44 | + const submitButtonStatus = |
| 45 | + textInput.length && severity.length |
| 46 | + ? ComponentStatus.Default |
| 47 | + : ComponentStatus.Disabled |
| 48 | + |
| 49 | + const handleInputChange = (e: ChangeEvent<HTMLTextAreaElement>) => { |
| 50 | + setTextInput(e.target.value) |
| 51 | + } |
| 52 | + const handleSubmit = (): void => { |
| 53 | + // submit support form |
| 54 | + } |
| 55 | + |
| 56 | + const handleChangeSeverity = (severity): void => { |
| 57 | + setSeverity(severity) |
| 58 | + } |
| 59 | + |
| 60 | + const handleValidation = (value: string): string | null => { |
| 61 | + if (value.trim() === '') { |
| 62 | + return 'This field cannot be empty' |
| 63 | + } |
| 64 | + |
| 65 | + if (value.length >= 2500) { |
| 66 | + return 'Must be 2500 characters or fewer' |
| 67 | + } |
| 68 | + return null |
| 69 | + } |
| 70 | + |
| 71 | + const severityTip = (): JSX.Element => { |
| 72 | + const tooltipContent = ( |
| 73 | + <div> |
| 74 | + Please refer to our severity levels in our |
| 75 | + <SafeBlankLink href="https://www.influxdata.com/legal/support-policy"> |
| 76 | + {' '} |
| 77 | + support policy{' '} |
| 78 | + </SafeBlankLink> |
| 79 | + website |
| 80 | + </div> |
| 81 | + ) |
| 82 | + return ( |
| 83 | + <QuestionMarkTooltip |
| 84 | + diameter={14} |
| 85 | + tooltipContents={tooltipContent} |
| 86 | + tooltipStyle={{fontSize: '13px'}} |
| 87 | + style={{marginLeft: '420px'}} |
| 88 | + /> |
| 89 | + ) |
| 90 | + } |
| 91 | + |
19 | 92 | return ( |
20 | | - <Overlay.Container maxWidth={500}> |
| 93 | + <Overlay.Container maxWidth={550}> |
21 | 94 | <Overlay.Header |
22 | 95 | testID="payg-support-overlay-header" |
23 | 96 | title="Contact Support" |
24 | 97 | onDismiss={onClose} |
25 | 98 | /> |
26 | | - |
| 99 | + <p className="status-page-text"> |
| 100 | + <span> |
| 101 | + {' '} |
| 102 | + <Icon glyph={IconFont.Info_New} />{' '} |
| 103 | + </span> |
| 104 | + Check our{' '} |
| 105 | + <SafeBlankLink href="https://status.influxdata.com"> |
| 106 | + status page |
| 107 | + </SafeBlankLink>{' '} |
| 108 | + to see if there is an outage impacting your region. |
| 109 | + </p> |
27 | 110 | <ErrorBoundary> |
28 | | - <Overlay.Body></Overlay.Body> |
| 111 | + <Form |
| 112 | + onSubmit={handleSubmit} |
| 113 | + action="https://influxdata--full.my.salesforce.com/servlet/servlet.WebToCase?encoding=UTF-8" |
| 114 | + method={Method.Post} |
| 115 | + > |
| 116 | + <Overlay.Body> |
| 117 | + <Form.Element |
| 118 | + label="Severity" |
| 119 | + required={true} |
| 120 | + labelAddOn={severityTip} |
| 121 | + > |
| 122 | + <SelectDropdown |
| 123 | + options={severityLevel} |
| 124 | + selectedOption={severity} |
| 125 | + onSelect={handleChangeSeverity} |
| 126 | + indicator={DropdownItemType.None} |
| 127 | + /> |
| 128 | + </Form.Element> |
| 129 | + <Form.ValidationElement |
| 130 | + label="Description" |
| 131 | + required={true} |
| 132 | + value={textInput} |
| 133 | + validationFunc={handleValidation} |
| 134 | + > |
| 135 | + {status => ( |
| 136 | + <TextArea |
| 137 | + status={status} |
| 138 | + rows={10} |
| 139 | + testID="support-description--textarea" |
| 140 | + name="description" |
| 141 | + value={textInput} |
| 142 | + onChange={handleInputChange} |
| 143 | + /> |
| 144 | + )} |
| 145 | + </Form.ValidationElement> |
| 146 | + </Overlay.Body> |
| 147 | + <Overlay.Footer> |
| 148 | + <Button |
| 149 | + text="Cancel" |
| 150 | + color={ComponentColor.Tertiary} |
| 151 | + onClick={onClose} |
| 152 | + type={ButtonType.Button} |
| 153 | + testID="payg-contact-support--cancel" |
| 154 | + /> |
| 155 | + <Button |
| 156 | + text="Submit" |
| 157 | + color={ComponentColor.Success} |
| 158 | + type={ButtonType.Submit} |
| 159 | + testID="payg-contact-support--submit" |
| 160 | + status={submitButtonStatus} |
| 161 | + /> |
| 162 | + </Overlay.Footer> |
| 163 | + </Form> |
29 | 164 | </ErrorBoundary> |
30 | 165 | </Overlay.Container> |
31 | 166 | ) |
|
0 commit comments