Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
featI(integration): integrate callpro erxes/erxes-integrations#8
- Loading branch information
1 parent
54fb470
commit 5cb1719
Showing
15 changed files
with
184 additions
and
3 deletions.
There are no files selected for viewing
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
81 changes: 81 additions & 0 deletions
81
src/modules/settings/integrations/components/callpro/Form.tsx
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,81 @@ | ||
import FormControl from 'modules/common/components/form/Control'; | ||
import Form from 'modules/common/components/form/Form'; | ||
import FormGroup from 'modules/common/components/form/Group'; | ||
import ControlLabel from 'modules/common/components/form/Label'; | ||
import Spinner from 'modules/common/components/Spinner'; | ||
import { ModalFooter } from 'modules/common/styles/main'; | ||
import { IButtonMutateProps, IFormProps } from 'modules/common/types'; | ||
import React from 'react'; | ||
import SelectBrand from '../../containers/SelectBrand'; | ||
|
||
type Props = { | ||
renderButton: (props: IButtonMutateProps) => JSX.Element; | ||
closeModal: () => void; | ||
}; | ||
|
||
class CallPro extends React.Component<Props, { loading: boolean }> { | ||
constructor(props: Props) { | ||
super(props); | ||
|
||
this.state = { | ||
loading: false | ||
}; | ||
} | ||
|
||
generateDoc = (values: { | ||
name: string; | ||
phoneNumber: string; | ||
brandId: string; | ||
}) => { | ||
return { | ||
name: `${values.name} - ${values.phoneNumber}`, | ||
brandId: values.brandId, | ||
kind: 'callpro', | ||
data: { | ||
phoneNumber: values.phoneNumber | ||
} | ||
}; | ||
}; | ||
|
||
renderContent = (formProps: IFormProps) => { | ||
const { renderButton } = this.props; | ||
const { values, isSubmitted } = formProps; | ||
|
||
return ( | ||
<> | ||
{this.state.loading && <Spinner />} | ||
<FormGroup> | ||
<ControlLabel required={true}>Name</ControlLabel> | ||
<FormControl {...formProps} name="name" required={true} /> | ||
</FormGroup> | ||
|
||
<FormGroup> | ||
<ControlLabel required={true}>Phone number</ControlLabel> | ||
<FormControl | ||
{...formProps} | ||
type="number" | ||
name="phoneNumber" | ||
required={true} | ||
/> | ||
</FormGroup> | ||
|
||
<SelectBrand isRequired={true} formProps={formProps} /> | ||
|
||
<ModalFooter> | ||
{renderButton({ | ||
name: 'integration', | ||
values: this.generateDoc(values), | ||
isSubmitted, | ||
callback: this.props.closeModal | ||
})} | ||
</ModalFooter> | ||
</> | ||
); | ||
}; | ||
|
||
render() { | ||
return <Form renderContent={this.renderContent} />; | ||
} | ||
} | ||
|
||
export default CallPro; |
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
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
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
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 |
---|---|---|
|
@@ -18,6 +18,7 @@ type Props = { | |
form: number; | ||
facebook: number; | ||
gmail: number; | ||
callpro: number; | ||
}; | ||
}; | ||
|
||
|
46 changes: 46 additions & 0 deletions
46
src/modules/settings/integrations/containers/callpro/Form.tsx
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,46 @@ | ||
import ButtonMutate from 'modules/common/components/ButtonMutate'; | ||
import { IButtonMutateProps, IRouterProps } from 'modules/common/types'; | ||
import CallPro from 'modules/settings/integrations/components/callpro/Form'; | ||
import { mutations } from 'modules/settings/integrations/graphql'; | ||
import React from 'react'; | ||
import { withRouter } from 'react-router'; | ||
|
||
type Props = { | ||
type?: string; | ||
closeModal: () => void; | ||
}; | ||
|
||
type FinalProps = {} & IRouterProps & Props; | ||
|
||
class CallProContainer extends React.Component<FinalProps> { | ||
renderButton = ({ | ||
name, | ||
values, | ||
isSubmitted, | ||
callback | ||
}: IButtonMutateProps) => { | ||
return ( | ||
<ButtonMutate | ||
mutation={mutations.integrationsCreateExternalIntegration} | ||
variables={values} | ||
callback={callback} | ||
isSubmitted={isSubmitted} | ||
type="submit" | ||
successMessage={`You successfully added a ${name}`} | ||
/> | ||
); | ||
}; | ||
|
||
render() { | ||
const { closeModal } = this.props; | ||
|
||
const updatedProps = { | ||
closeModal, | ||
renderButton: this.renderButton | ||
}; | ||
|
||
return <CallPro {...updatedProps} />; | ||
} | ||
} | ||
|
||
export default withRouter<FinalProps>(CallProContainer); |
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