Browse Source

fix(nc-gui): reduce of empty array with no initial value

pull/4384/head
Wing-Kam Wong 2 years ago
parent
commit
0779a69cae
  1. 6
      packages/nc-gui/utils/parsers/CSVTemplateAdapter.ts

6
packages/nc-gui/utils/parsers/CSVTemplateAdapter.ts

@ -179,8 +179,10 @@ export default class CSVTemplateAdapter {
) {
this.tables[tableIdx].columns[columnIdx].uidt = UITypes.Date
// take the date format with the max occurrence
this.tables[tableIdx].columns[columnIdx].meta.date_format =
Object.keys(dateFormat).reduce((x, y) => (dateFormat[x] > dateFormat[y] ? x : y)) || 'YYYY/MM/DD'
const objKeys = Object.keys(dateFormat)
this.tables[tableIdx].columns[columnIdx].meta.date_format = objKeys.length
? objKeys.reduce((x, y) => (dateFormat[x] > dateFormat[y] ? x : y))
: 'YYYY/MM/DD'
} else {
// Datetime
this.tables[tableIdx].columns[columnIdx].uidt = uidt

Loading…
Cancel
Save