комбинация 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} />
) : (
<Grid>
{columns.map((cols, i) => {
{columns.flatMap((cols, i) => {
const columnPosition = 1 + i * 2
return cols.map((column, j) => (
<Fragment key={column.key}>
@ -46,6 +46,6 @@ export const View = memo(({ columns, item }) => !item || !columns?.length ? (
</GridItem>
</Fragment>
))
}).flat()}
})}
</Grid>
))

View File

@ -33,7 +33,7 @@ export const calcFlowData = (dataSaub, flowChart) => {
if (depth > maxDepth) maxDepth = depth
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 []
const out = []
let i = 0, j = 0
@ -50,7 +50,7 @@ export const calcFlowData = (dataSaub, flowChart) => {
})
}
return out
}).flat()
})
return out
}

View File

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