Skip to content

Commit

Permalink
chore: code cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
turban committed Dec 22, 2023
1 parent a059ced commit 44c77e5
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 676 deletions.
67 changes: 2 additions & 65 deletions src/components/edit/earthEngine/EarthEngineDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ const EarthEngineDialog = (props) => {
description,
notice,
periodType,
periodRange,
periodReducer,
bands,
filters,
unit,
Expand All @@ -60,46 +58,6 @@ const EarthEngineDialog = (props) => {
precision,
} = props // dataset

// const period = getPeriodFromFilter(filter)

// const getFilterFromPeriod = (period) => {}

/*
const setFilterFromPeriod = useCallback(
(period) => {
let periodFilter = null
if (period) {
const { id, startDate, endDate } = period
if (startDate && endDate) {
periodFilter = translateFilters(
filters,
startDate,
incrementDate(endDate)
)
} else {
periodFilter = translateFilters(
filters,
// periodType === 'yearly' ? String(period.year) : period.id
period.id
)
}
// TODO: Make more flexible
periodFilter[0].id = period.id
periodFilter[0].name = period.name
periodFilter[0].year = period.year
}
console.log('periodFilter', periodFilter)
setFilter(periodFilter)
},
[filters, setFilter]
)
*/

const noBandSelected = Array.isArray(bands) && (!band || !band.length)

const hasAggregations = !!(aggregations || defaultAggregations)
Expand Down Expand Up @@ -129,20 +87,9 @@ const EarthEngineDialog = (props) => {
}
}, [hasOrgUnitField, areaRadius, setBufferRadius])

/*
useEffect(() => {
if (!periodType && filters) {
setFilter(filters)
}
}, [periodType, filters, setFilter])
*/

useEffect(() => {
if (validateLayer) {
// const isValid = !noBandSelected && (!periodType || period)
const isValid =
!noBandSelected &&
(!periodType || periodType === 'range' || period)
const isValid = !noBandSelected && (!periodType || period)

if (!isValid) {
if (noBandSelected) {
Expand Down Expand Up @@ -239,8 +186,6 @@ const EarthEngineDialog = (props) => {
datasetId={datasetId}
periodType={periodType}
period={period}
periodRange={periodRange}
periodReducer={periodReducer}
filters={filters}
onChange={setEarthEnginePeriod}
onError={setError}
Expand Down Expand Up @@ -268,8 +213,6 @@ const EarthEngineDialog = (props) => {
EarthEngineDialog.propTypes = {
datasetId: PropTypes.string.isRequired,
setBufferRadius: PropTypes.func.isRequired,
// layerId: PropTypes.string.isRequired,
// setFilter: PropTypes.func.isRequired,
setEarthEnginePeriod: PropTypes.func.isRequired,
setOrgUnits: PropTypes.func.isRequired,
validateLayer: PropTypes.bool.isRequired,
Expand All @@ -280,19 +223,13 @@ EarthEngineDialog.propTypes = {
bands: PropTypes.array,
defaultAggregations: PropTypes.array,
description: PropTypes.string,
// filter: PropTypes.array,
filters: PropTypes.array,
legend: PropTypes.object,
maskOperator: PropTypes.string,
notice: PropTypes.string,
orgUnitField: PropTypes.string,
orgUnits: PropTypes.object,
period: PropTypes.object,
periodRange: PropTypes.shape({
firstDate: PropTypes.string.isRequired,
lastDate: PropTypes.number.isRequired, // relative to today
}),
periodReducer: PropTypes.string,
periodType: PropTypes.string,
precision: PropTypes.number,
rows: PropTypes.array,
Expand All @@ -311,7 +248,7 @@ EarthEngineDialog.propTypes = {

export default connect(
null,
{ setOrgUnits, setEarthEnginePeriod, /* setFilter, */ setBufferRadius },
{ setOrgUnits, setEarthEnginePeriod, setBufferRadius },
null,
{
forwardRef: true,
Expand Down
Loading

0 comments on commit 44c77e5

Please sign in to comment.