@@ -12,7 +12,7 @@ import { PageHeader } from '@/components/PageHeader';
1212import { useInstrument } from '@/hooks/useInstrument' ;
1313import { useUploadInstrumentRecordsMutation } from '@/hooks/useUploadInstrumentRecordsMutation' ;
1414import { useAppStore } from '@/store' ;
15- import { createUploadTemplateCSV , processInstrumentCSV , reformatInstrumentData , UploadError } from '@/utils/upload2 ' ;
15+ import { createUploadTemplateCSV , processInstrumentCSV , reformatInstrumentData , UploadError } from '@/utils/upload ' ;
1616
1717const RouteComponent = ( ) => {
1818 const [ file , setFile ] = useState < File | null > ( null ) ;
@@ -54,41 +54,35 @@ const RouteComponent = () => {
5454 try {
5555 setIsLoading ( true ) ;
5656 const processedDataResult = await processInstrumentCSV ( file ! , instrument ! ) ;
57- if ( processedDataResult . success ) {
58- const reformattedData = reformatInstrumentData ( {
59- currentGroup,
60- data : processedDataResult . value ,
61- instrument : instrument !
62- } ) ;
63- if ( reformattedData . records . length > 1000 ) {
64- addNotification ( {
65- message : t ( {
66- en : 'Lots of entries loading, please wait...' ,
67- fr : 'Beaucoup de données, veuillez patienter...'
68- } ) ,
69- type : 'info'
70- } ) ;
71- }
72- await uploadInstrumentRecordsMutation . mutateAsync ( reformattedData ) ;
73- } else {
57+ const reformattedData = reformatInstrumentData ( {
58+ currentGroup,
59+ data : processedDataResult ,
60+ instrument : instrument !
61+ } ) ;
62+ if ( reformattedData . records . length > 1000 ) {
7463 addNotification ( {
7564 message : t ( {
76- en : processedDataResult . message . en ,
77- fr : processedDataResult . message . fr
65+ en : 'Lots of entries loading, please wait...' ,
66+ fr : 'Beaucoup de données, veuillez patienter...'
7867 } ) ,
79- type : 'error '
68+ type : 'info '
8069 } ) ;
8170 }
71+ await uploadInstrumentRecordsMutation . mutateAsync ( reformattedData ) ;
8272 setFile ( null ) ;
8373 } catch ( error ) {
84- if ( error instanceof Error )
85- addNotification ( {
86- message : t ( {
87- en : `An error has happened within the request: '${ error . message } '` ,
88- fr : `Une erreur s'est produite lors du téléversement :'${ error . message } '.`
89- } ) ,
90- type : 'error'
91- } ) ;
74+ void navigate ( {
75+ search : {
76+ error : {
77+ description : error instanceof UploadError ? error . description : undefined ,
78+ title : {
79+ en : `An error has happened within the request` ,
80+ fr : `Une erreur s'est produite lors du téléversement`
81+ }
82+ }
83+ } ,
84+ to : '.'
85+ } ) ;
9286 } finally {
9387 setIsLoading ( false ) ;
9488 }
0 commit comments