@@ -12,15 +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 } from '@/utils/upload2' ;
16-
17- const $UploadError = z . object ( {
18- message : z . string ( ) . nullable ( ) ,
19- title : z . object ( {
20- en : z . string ( ) ,
21- fr : z . string ( )
22- } )
23- } ) ;
15+ import { createUploadTemplateCSV , processInstrumentCSV , reformatInstrumentData , UploadError } from '@/utils/upload2' ;
2416
2517const RouteComponent = ( ) => {
2618 const [ file , setFile ] = useState < File | null > ( null ) ;
@@ -46,7 +38,7 @@ const RouteComponent = () => {
4638 void navigate ( {
4739 search : {
4840 error : {
49- message : error instanceof Error ? error . message : t ( 'core.unknownError' ) ,
41+ description : error instanceof UploadError ? error . description : undefined ,
5042 title : {
5143 en : `Error Occurred Downloading Sample Template` ,
5244 fr : `Une erreur s'est produite lors du téléchargement du CSV`
@@ -106,7 +98,9 @@ const RouteComponent = () => {
10698 return (
10799 < div className = "flex min-h-screen flex-col items-center justify-center gap-1 p-3 text-center" >
108100 < h3 className = "text-2xl font-extrabold tracking-tight sm:text-3xl" > { t ( error . title ) } </ h3 >
109- < p className = "text-muted-foreground mt-2 max-w-prose text-sm sm:text-base" > { error . message } </ p >
101+ { error . description && (
102+ < p className = "text-muted-foreground mt-2 max-w-prose text-sm sm:text-base" > { t ( error . description ) } </ p >
103+ ) }
110104 < div className = "mt-6 flex gap-2" >
111105 < Button
112106 type = "button"
@@ -210,6 +204,20 @@ const RouteComponent = () => {
210204export const Route = createFileRoute ( '/_app/upload/$instrumentId' ) ( {
211205 component : RouteComponent ,
212206 validateSearch : z . object ( {
213- error : $UploadError . optional ( )
207+ error : z
208+ . object ( {
209+ description : z
210+ . object ( {
211+ en : z . string ( ) ,
212+ fr : z . string ( )
213+ } )
214+ . partial ( )
215+ . optional ( ) ,
216+ title : z . object ( {
217+ en : z . string ( ) ,
218+ fr : z . string ( )
219+ } )
220+ } )
221+ . optional ( )
214222 } )
215223} ) ;
0 commit comments