1
0
Fork 0
mirror of synced 2024-08-08 06:37:55 +12:00

Don't cast on the fe

This commit is contained in:
Adria Navarro 2023-10-10 10:47:56 +02:00
parent 979c2aeb00
commit 62c6631bc8

View file

@ -96,35 +96,11 @@
let validateHash = ""
let errors = {}
let selectedColumnTypes = {}
let rawRows = []
$: displayColumnOptions = Object.keys(schema || {}).filter(column => {
return validation[column]
})
$: {
rows = []
for (const row of rawRows) {
const castedRow = { ...row }
for (const fieldSchema of Object.values(schema || {})) {
if (fieldSchema.type === FieldType.BB_REFERENCE) {
try {
castedRow[fieldSchema.name] = JSON.parse(
row[fieldSchema.name].replace(/'/g, '"')
)
} catch {
console.warn("Not a valid json", {
field: fieldSchema.name,
data: row[fieldSchema.name],
})
}
}
}
rows.push(castedRow)
}
}
$: {
// binding in consumer is causing double renders here
const newValidateHash = JSON.stringify(rows) + JSON.stringify(schema)
@ -142,7 +118,7 @@
try {
const response = await parseFile(e)
rawRows = response.rows
rows = response.rows
schema = response.schema
fileName = response.fileName
selectedColumnTypes = Object.entries(response.schema).reduce(