@@ -258,7 +258,7 @@ export interface SyncResult extends SyncStatus {
258258}
259259
260260interface ProcessSheetRowParams {
261- fieldTypes : CollectionFieldType [ ]
261+ fieldTypes : Record < string , CollectionFieldType >
262262 row : Row
263263 rowIndex : number
264264 uniqueHeaderRowNames : string [ ]
@@ -275,7 +275,7 @@ export interface SyncMutationOptions {
275275 fields : ManagedCollectionField [ ]
276276 slugColumn : string | null
277277 ignoredColumns : string [ ]
278- colFieldTypes : CollectionFieldType [ ]
278+ colFieldTypes : Record < string , CollectionFieldType >
279279 lastSyncedTime : string | null
280280}
281281
@@ -331,7 +331,11 @@ function getFieldValue(fieldType: CollectionFieldType, cellValue: CellValue) {
331331 case "formattedText" :
332332 case "color" :
333333 case "string" : {
334- return String ( cellValue )
334+ if ( typeof cellValue === "string" ) {
335+ return cellValue
336+ }
337+
338+ return ""
335339 }
336340 default :
337341 return null
@@ -355,18 +359,7 @@ function processSheetRow({
355359 for ( const [ colIndex , cell ] of row . entries ( ) ) {
356360 if ( ignoredFieldColumnIndexes . includes ( colIndex ) ) continue
357361
358- // +1 as zero-indexed, another +1 to account for header row
359- const location = columnToLetter ( colIndex + 1 ) + ( rowIndex + 2 )
360-
361- const fieldValue = getFieldValue ( fieldTypes [ colIndex ] , cell )
362-
363- if ( fieldValue === null ) {
364- status . warnings . push ( {
365- rowIndex,
366- message : `Invalid cell value at ${ location } .` ,
367- } )
368- continue
369- }
362+ const fieldValue = getFieldValue ( fieldTypes [ uniqueHeaderRowNames [ colIndex ] ] , cell )
370363
371364 if ( colIndex === slugFieldColumnIndex ) {
372365 if ( typeof fieldValue !== "string" ) {
@@ -394,7 +387,11 @@ function processSheetRow({
394387
395388 for ( const headerRowName of uniqueHeaderRowNames ) {
396389 if ( ! ( headerRowName in fieldData ) ) {
397- fieldData [ headerRowName ] = null
390+ if ( [ "string" , "formattedText" ] . includes ( fieldTypes [ headerRowName ] ) ) {
391+ fieldData [ headerRowName ] = ""
392+ } else {
393+ fieldData [ headerRowName ] = null
394+ }
398395 }
399396 }
400397
0 commit comments