комбинация map и flat заменена на flatMap

This commit is contained in:
Александр Сироткин 2022-11-28 05:18:16 +05:00
parent 5eb66e5fbc
commit 0aeef42811
3 changed files with 6 additions and 6 deletions

View File

@ -10,7 +10,7 @@ export const View = memo(({ columns, item }) => !item || !columns?.length ? (
<Empty key={'empty'} image={Empty.PRESENTED_IMAGE_SIMPLE} /> <Empty key={'empty'} image={Empty.PRESENTED_IMAGE_SIMPLE} />
) : ( ) : (
<Grid> <Grid>
{columns.map((cols, i) => { {columns.flatMap((cols, i) => {
const columnPosition = 1 + i * 2 const columnPosition = 1 + i * 2
return cols.map((column, j) => ( return cols.map((column, j) => (
<Fragment key={column.key}> <Fragment key={column.key}>
@ -46,6 +46,6 @@ export const View = memo(({ columns, item }) => !item || !columns?.length ? (
</GridItem> </GridItem>
</Fragment> </Fragment>
)) ))
}).flat()} })}
</Grid> </Grid>
)) ))

View File

@ -33,7 +33,7 @@ export const calcFlowData = (dataSaub, flowChart) => {
if (depth > maxDepth) maxDepth = depth if (depth > maxDepth) maxDepth = depth
return { date: new Date(row.date), depth: row.wellDepth } return { date: new Date(row.date), depth: row.wellDepth }
}) })
const out = flowChart.map((flow) => { const out = flowChart.flatMap((flow) => {
if (flow.depthStart > maxDepth || flow.depthEnd < minDepth) return [] if (flow.depthStart > maxDepth || flow.depthEnd < minDepth) return []
const out = [] const out = []
let i = 0, j = 0 let i = 0, j = 0
@ -50,7 +50,7 @@ export const calcFlowData = (dataSaub, flowChart) => {
}) })
} }
return out return out
}).flat() })
return out return out
} }

View File

@ -81,7 +81,7 @@ export const TLChart = memo(({
invokeWebApiWrapperAsync( invokeWebApiWrapperAsync(
async () => { async () => {
const { operations } = await DetectedOperationService.get(well.id) const { operations } = await DetectedOperationService.get(well.id)
setData(operations.map((raw) => { setData(operations.flatMap((raw) => {
const startTime = moment(raw.dateStart) const startTime = moment(raw.dateStart)
const endTime = moment(raw.dateEnd) const endTime = moment(raw.dateEnd)
return splitByDate(startTime, endTime).map((dt) => ({ return splitByDate(startTime, endTime).map((dt) => ({
@ -89,7 +89,7 @@ export const TLChart = memo(({
startTime: dt.startTime, startTime: dt.startTime,
endTime: dt.endTime, endTime: dt.endTime,
})) }))
}).flat()) }))
}, },
setIsLoading, setIsLoading,
`Не удалось загрузить список операций`, `Не удалось загрузить список операций`,