Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | 15x 15x 15x 15x 15x 15x 15x 15x 15x 15x 15x 15x 15x 15x 15x 6x 6x 15x 6x 15x 30x 1x 30x 3x 30x | /*
* Copyright 2021 Harness Inc. All rights reserved.
* Use of this source code is governed by the PolyForm Shield 1.0.0 license
* that can be found in the licenses directory at the root of this repository, also available at
* https://polyformproject.org/wp-content/uploads/2020/06/PolyForm-Shield-1.0.0.txt.
*/
import React from 'react'
import { Container, Layout, Button } from '@wings-software/uicore'
import { useModalHook } from '@harness/use-modal'
import { Dialog, Classes } from '@blueprintjs/core'
import cx from 'classnames'
import { FeedBackForm, ExtendTrialForm } from './ExtendTrialOrFeedbackForm'
import cfExtendTrialImg from './images/cf-extend-trial.svg'
import ciExtendTrialImg from './images/ci-extend-trial.svg'
import cdExtendTrialImg from './images/cd-extend-trial.svg'
import ceExtendTrialImg from './images/ce-extend-trial.svg'
import css from './useExtendTrialOrFeedbackModal.module.scss'
export interface FeedbackFormValues {
experience?: string
suggestion?: string
}
export const enum FORM_TYPE {
EXTEND_TRIAL = 'EXTEND_TRIAL',
FEEDBACK = 'FEEDBACK'
}
interface UseExtendTrialOrFeedbackModalProps {
onCloseModal?: () => void
onSubmit: (values: FeedbackFormValues) => void
module: string
moduleDescription: string
bgImg?: string
expiryDateStr: string
formType: FORM_TYPE
loading: boolean
}
interface UseExtendTrialOrFeedbackModalReturn {
openExtendTrialOrFeedbackModal: () => void
closeExtendTrialOrFeedbackModal: () => void
}
const getBgImg = (module: string): string => {
switch (module.toUpperCase()) {
case 'CI':
return ciExtendTrialImg
case 'CF':
return cfExtendTrialImg
case 'CD':
return cdExtendTrialImg
case 'CE':
return ceExtendTrialImg
}
return ''
}
const ExtendTrialOrFeedbackDialog: React.FC<UseExtendTrialOrFeedbackModalProps> = ({
expiryDateStr,
onCloseModal,
onSubmit,
moduleDescription,
formType,
module,
loading
}) => {
return (
<Layout.Horizontal>
<Container
width="45%"
className={css.left}
style={{
background: `transparent url(${getBgImg(module)}) no-repeat`
}}
/>
<Container className={css.right} width="55%">
{formType === FORM_TYPE.EXTEND_TRIAL ? (
<ExtendTrialForm
expiryDateStr={expiryDateStr}
moduleDescription={moduleDescription}
onCloseModal={() => {
onCloseModal?.()
}}
onSubmit={onSubmit}
loading={loading}
/>
) : (
<FeedBackForm
moduleDescription={moduleDescription}
onCloseModal={() => {
onCloseModal?.()
}}
onSubmit={onSubmit}
loading={loading}
/>
)}
</Container>
</Layout.Horizontal>
)
}
export const useExtendTrialOrFeedbackModal = (
props: UseExtendTrialOrFeedbackModalProps
): UseExtendTrialOrFeedbackModalReturn => {
const onCloseModal = (): void => {
props.onCloseModal?.(), hideModal()
}
const [showModal, hideModal] = useModalHook(
() => (
<Dialog
enforceFocus={false}
isOpen={true}
onClose={onCloseModal}
className={cx(css.dialog, Classes.DIALOG, css.feedback)}
>
<ExtendTrialOrFeedbackDialog {...props} onCloseModal={onCloseModal} />
<Button
aria-label="close modal"
minimal
icon="cross"
iconProps={{ size: 18 }}
onClick={onCloseModal}
className={css.crossIcon}
/>
</Dialog>
),
[]
)
return {
openExtendTrialOrFeedbackModal: showModal,
closeExtendTrialOrFeedbackModal: hideModal
}
}
|