Created
April 22, 2021 03:23
-
-
Save renderlife/ecd6d626b37d3e8758fd2d8bbd727f8c to your computer and use it in GitHub Desktop.
Res2271
This file contains hidden or 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
import React, { Component } from 'react' | |
import Modal from 'react-modal' | |
import styles from './stylesReport.module.sass' | |
import { providers } from 'Constants/constants' | |
import { | |
PARAMS_PLATFORM_ID | |
} from '../Geoservices' | |
Modal.setAppElement('#pointer') | |
function getInitialState(generateDataForSearchDone) { | |
return { | |
searchQuery: '', | |
} | |
} | |
export default class ResultsModal extends Component { | |
constructor(props) { | |
super(props) | |
this.state = getInitialState() | |
} | |
componentDidMount() { | |
} | |
getSearchParams(props) { | |
return new URLSearchParams(props.location.search) | |
} | |
getPlatformIdByAlias = alias => { | |
const platform = providers.find(item => item.alias === alias) | |
return platform ? platform.id : null | |
} | |
getActiveModalParams = (props = this.props) => { | |
const searchParams = this.getSearchParams(props) | |
const platformId = searchParams.has(PARAMS_PLATFORM_ID) | |
? this.getPlatformIdByAlias(searchParams.get(PARAMS_PLATFORM_ID)) | |
: null | |
return { platformId } | |
} | |
handleModalShow = data => { | |
this.setState({ ...data }) | |
} | |
handleModalClose = () => { | |
this.clearQueryParams() | |
this.setState(getInitialState(true)) | |
} | |
renderDetailModal = () => { | |
const queryParams = this.getActiveModalParams() | |
const showDetailsModal = Boolean( | |
queryParams && (queryParams.platformId || (queryParams.keyField && queryParams.keyCount)) | |
) | |
return ( | |
<Modal | |
key="modal" | |
className={styles.detailModal} | |
isOpen={showDetailsModal} | |
onRequestClose={this.handleModalClose} | |
> | |
test | |
</Modal> | |
) | |
} | |
render() { | |
return this.renderDetailModal() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment