Skip to content

Commit

Permalink
Merge pull request #48556 from software-mansion-labs/categories-impor…
Browse files Browse the repository at this point in the history
…t/empty-file-issue

[CP Staging] Handle empty file issue

(cherry picked from commit f30e696)

(CP triggered by mountiny)
  • Loading branch information
mountiny authored and OSBotify committed Sep 4, 2024
1 parent ebc0eb3 commit 2debc27
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/components/ImportSpreadsheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,13 @@ function ImportSpreedsheet({backTo, goTo}: ImportSpreedsheetProps) {
const workbook = XLSX.read(new Uint8Array(arrayBuffer), {type: 'buffer'});
const worksheet = workbook.Sheets[workbook.SheetNames[0]];
const data = XLSX.utils.sheet_to_json(worksheet, {header: 1, blankrows: false});
setSpreadsheetData(data as string[][]).then(() => {
Navigation.navigate(goTo);
});
setSpreadsheetData(data as string[][])
.then(() => {
Navigation.navigate(goTo);
})
.catch(() => {
setUploadFileError(true, 'spreadsheet.importFailedTitle', 'spreadsheet.invalidFileMessage');
});
})
.finally(() => {
setIsReadingFIle(false);
Expand Down
2 changes: 2 additions & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,8 @@ export default {
importCategoriesSuccessfullDescription: (categories: number) => (categories > 1 ? `${categories} categories have been added.` : '1 category has been added.'),
importFailedTitle: 'Import failed',
importFailedDescription: 'Please ensure all fields are filled out correctly and try again. If the problem persists, please reach out to Concierge.',
invalidFileMessage:
'The file you uploaded is either empty or contains invalid data. Please ensure that the file is correctly formatted and contains the necessary information before uploading it again.',
},
receipt: {
upload: 'Upload receipt',
Expand Down
2 changes: 2 additions & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,8 @@ export default {
importFailedDescription: 'Por favor, asegúrate de que todos los campos estén llenos correctamente e inténtalo de nuevo. Si el problema persiste, por favor contacta a Concierge.',
importCategoriesSuccessfullDescription: (categories: number) => (categories > 1 ? `Se han agregado ${categories} categorías.` : 'Se ha agregado 1 categoría.'),
importSuccessfullTitle: 'Importar categorías',
invalidFileMessage:
'El archivo que ha cargado está vacío o contiene datos no válidos. Asegúrese de que el archivo tiene el formato correcto y contiene la información necesaria antes de volver a cargarlo.',
},
receipt: {
upload: 'Subir recibo',
Expand Down

0 comments on commit 2debc27

Please sign in to comment.