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 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 6x 6x 6x 6x 6x 1x 8x 3x 1x 8x | /* * 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 { Text, Button, Formik, FormikForm as Form, Layout, FormInput, SelectOption } from '@wings-software/uicore' import { Color } from '@harness/design-system' import { useModalHook } from '@harness/use-modal' import { Dialog, Classes } from '@blueprintjs/core' import * as Yup from 'yup' import cx from 'classnames' import { NameSchema, EmailSchema } from '@common/utils/Validation' import { useStrings } from 'framework/strings' import css from './useContactSalesModal.module.scss' interface UseContactSalesModalProps { onSubmit: (values: ContactSalesFormProps) => void onCloseModal?: () => void } export interface ContactSalesFormProps { fullName: string email: string countryName: string phone: { countryCode: string number: string } role: string orgName: string companySize: string } interface UseContactSalesModalReturn { openContactSalesModal: () => void closeContactSalesModal: () => void } //TO-DO: call backend api to get country codes and names const countryCodeItems: SelectOption[] = [] const countryNameItems: SelectOption[] = [] const ContactSalesForm = ({ onSubmit }: { onSubmit: (values: ContactSalesFormProps) => void }): React.ReactElement => { const { getString } = useStrings() const roleItems: SelectOption[] = [ { label: getString('common.banners.trial.contactSalesForm.roleItems.it'), value: 'IT' }, { label: getString('common.banners.trial.contactSalesForm.roleItems.devOps'), value: 'DevOps' }, { label: getString('common.banners.trial.contactSalesForm.roleItems.devSecOps'), value: 'DevSecOps' }, { label: getString('common.banners.trial.contactSalesForm.roleItems.softwareDeveloper'), value: 'Software Developer' }, { label: getString('common.banners.trial.contactSalesForm.roleItems.softwareArchitect'), value: 'Software Architect' }, { label: getString('common.banners.trial.contactSalesForm.roleItems.engineeringManager'), value: 'Engineering Manager' }, { label: getString('common.banners.trial.contactSalesForm.roleItems.engineeringDirector'), value: 'Engineering Director' }, { label: getString('common.banners.trial.contactSalesForm.roleItems.vp'), value: 'VP / Executive' }, { label: getString('common.banners.trial.contactSalesForm.roleItems.others'), value: 'Others' } ] const companySizeItems: SelectOption[] = [ { label: getString('common.banners.trial.contactSalesForm.companySizeItems.below100'), value: '1-100 employees' }, { label: getString('common.banners.trial.contactSalesForm.companySizeItems.below500'), value: '101-500 employees' }, { label: getString('common.banners.trial.contactSalesForm.companySizeItems.below2000'), value: '501-2,000 employees' }, { label: getString('common.banners.trial.contactSalesForm.companySizeItems.below5000'), value: '2,001-5,000 employees' }, { label: getString('common.banners.trial.contactSalesForm.companySizeItems.above5000'), value: '> 5,000 employees' } ] const validationSchema = Yup.object().shape({ fullName: NameSchema(), email: EmailSchema(), countryName: Yup.string().trim().required(getString('common.banners.trial.contactSalesForm.countryValidation')), countryCode: Yup.string() .trim() .required(getString('common.banners.trial.contactSalesForm.phoneValidation.required')), number: Yup.number() .required(getString('common.banners.trial.contactSalesForm.phoneValidation.required')) .typeError(getString('common.banners.trial.contactSalesForm.phoneValidation.number')), role: Yup.string().trim().required(getString('common.banners.trial.contactSalesForm.roleValidation')), orgName: Yup.string().trim().required(getString('common.banners.trial.contactSalesForm.orgNameValidation')), companySize: Yup.string().trim().required(getString('common.banners.trial.contactSalesForm.companySizeValidation')) }) return ( <Formik formName="contactSalesModalForm" initialValues={{ fullName: '', email: '', countryName: '', phone: { countryCode: '', number: '' }, role: '', orgName: '', companySize: '' }} validationSchema={validationSchema} enableReinitialize={true} onSubmit={onSubmit} > <Form> <Layout.Vertical padding={{ bottom: 'xxlarge' }} spacing="small"> <Text font={{ size: 'large', weight: 'bold' }} color={Color.BLACK}> {getString('common.banners.trial.contactSales')} </Text> <Text>{getString('common.banners.trial.contactSalesForm.description')}</Text> </Layout.Vertical> <FormInput.Text name={'fullName'} label={getString('common.banners.trial.contactSalesForm.fullName')} /> <FormInput.Text name={'email'} label={getString('common.banners.trial.contactSalesForm.email')} /> <FormInput.Select label={getString('common.banners.trial.contactSalesForm.country')} name={'countryName'} items={countryNameItems} /> <Layout.Vertical spacing="xsmall" padding={{ bottom: 'xsmall' }}> <Text> {getString('common.banners.trial.contactSalesForm.phone')}</Text> <Layout.Horizontal padding={{ top: 'xsmall' }}> <FormInput.Select className={css.phone} style={{ paddingBottom: 'xsmall' }} name={'countryCode'} items={countryCodeItems} /> <FormInput.Text className={css.contactNumber} name={'number'} placeholder={getString('common.banners.trial.contactSalesForm.phonePlaceHolder')} /> </Layout.Horizontal> </Layout.Vertical> <FormInput.Select label={getString('common.banners.trial.contactSalesForm.role')} name={'role'} items={roleItems} /> <FormInput.Text name={'orgName'} label={getString('common.banners.trial.contactSalesForm.orgName')} /> <FormInput.Select label={getString('common.banners.trial.contactSalesForm.companySize')} name={'companySize'} items={companySizeItems} /> <Button margin={{ top: 'xlarge' }} intent="primary" text={getString('submit')} type="submit" /> </Form> </Formik> ) } export const useContactSalesModal = ({ onCloseModal, onSubmit }: UseContactSalesModalProps): UseContactSalesModalReturn => { const [showModal, hideModal] = useModalHook( () => ( <Dialog isOpen={true} enforceFocus={false} onClose={() => { hideModal(), onCloseModal?.() }} className={cx(css.dialog, Classes.DIALOG, css.contactSales)} > <ContactSalesForm onSubmit={onSubmit} /> <Button aria-label="close modal" minimal icon="cross" iconProps={{ size: 18 }} onClick={() => { hideModal(), onCloseModal?.() }} className={css.crossIcon} /> </Dialog> ), [] ) return { openContactSalesModal: showModal, closeContactSalesModal: hideModal } } |