Skip to content

Commit 6b90dfe

Browse files
authored
Merge pull request #1162 from joshunrau/disable-upload-zod-v4
fix: disable upload for Zod v4 instruments
2 parents a43f0b3 + c1c123c commit 6b90dfe

File tree

2 files changed

+50
-37
lines changed
  • apps/web/src/features/upload/pages
  • packages/instrument-library/src/forms/DNP_HAPPINESS_QUESTIONNAIRE

2 files changed

+50
-37
lines changed

apps/web/src/features/upload/pages/UploadPage.tsx

Lines changed: 49 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import React, { useState } from 'react';
22

3+
import { isZodType } from '@douglasneuroinformatics/libjs';
34
import { Button, FileDropzone, Heading, Spinner } from '@douglasneuroinformatics/libui/components';
45
import { useDownload, useNotificationsStore, useTranslation } from '@douglasneuroinformatics/libui/hooks';
56
import type { AnyUnilingualFormInstrument } from '@opendatacapture/runtime-core';
6-
import { BadgeHelpIcon, DownloadIcon } from 'lucide-react';
7+
import { BadgeHelpIcon, CircleAlertIcon, DownloadIcon } from 'lucide-react';
78
import { useParams } from 'react-router-dom';
89

910
import { PageHeader } from '@/components/PageHeader';
@@ -107,44 +108,56 @@ export const UploadPage = () => {
107108
</Heading>
108109
</PageHeader>
109110
{!isLoading ? (
110-
<div className="mx-auto flex w-full max-w-3xl grow flex-col justify-center">
111-
<FileDropzone
112-
acceptedFileTypes={{
113-
'text/csv': ['.csv']
114-
}}
115-
className="flex h-80 w-full flex-col"
116-
file={file}
117-
setFile={setFile}
118-
/>
119-
<div className="mt-4 flex justify-between space-x-2">
120-
<Button disabled={!(file && instrument)} variant={'primary'} onClick={() => void handleInstrumentCSV()}>
121-
{t('core.submit')}
122-
</Button>
123-
<div className="flex justify-between space-x-1">
124-
<Button className="gap-1" disabled={!instrument} variant={'primary'} onClick={handleTemplateDownload}>
125-
<DownloadIcon />
126-
{t({
127-
en: 'Download Template',
128-
fr: 'Télécharger le modèle'
129-
})}
130-
</Button>
131-
<Button
132-
className="gap-1"
133-
disabled={!instrument}
134-
variant={'primary'}
135-
onClick={() => {
136-
window.open('https://opendatacapture.org/en/docs/guides/how-to-upload-data/');
137-
}}
138-
>
139-
<BadgeHelpIcon />
140-
{t({
141-
en: 'Help',
142-
fr: 'Aide'
143-
})}
111+
isZodType(instrument.validationSchema, { version: 4 }) ? (
112+
<div className="mb-2 flex items-center gap-2 rounded-md bg-red-300 p-4 dark:bg-red-800">
113+
<CircleAlertIcon style={{ height: '20px', strokeWidth: '2px', width: '20px' }} />
114+
<h5 className="font-medium tracking-tight">
115+
{t({
116+
en: 'Upload is Not Supported for Zod v4 Instruments',
117+
fr: "Le téléchargement n'est pas pris en charge pour les instruments utilisant Zod v4"
118+
})}
119+
</h5>
120+
</div>
121+
) : (
122+
<div className="mx-auto flex w-full max-w-3xl grow flex-col justify-center">
123+
<FileDropzone
124+
acceptedFileTypes={{
125+
'text/csv': ['.csv']
126+
}}
127+
className="flex h-80 w-full flex-col"
128+
file={file}
129+
setFile={setFile}
130+
/>
131+
<div className="mt-4 flex justify-between space-x-2">
132+
<Button disabled={!(file && instrument)} variant={'primary'} onClick={() => void handleInstrumentCSV()}>
133+
{t('core.submit')}
144134
</Button>
135+
<div className="flex justify-between space-x-1">
136+
<Button className="gap-1" disabled={!instrument} variant={'primary'} onClick={handleTemplateDownload}>
137+
<DownloadIcon />
138+
{t({
139+
en: 'Download Template',
140+
fr: 'Télécharger le modèle'
141+
})}
142+
</Button>
143+
<Button
144+
className="gap-1"
145+
disabled={!instrument}
146+
variant={'primary'}
147+
onClick={() => {
148+
window.open('https://opendatacapture.org/en/docs/guides/how-to-upload-data/');
149+
}}
150+
>
151+
<BadgeHelpIcon />
152+
{t({
153+
en: 'Help',
154+
fr: 'Aide'
155+
})}
156+
</Button>
157+
</div>
145158
</div>
146159
</div>
147-
</div>
160+
)
148161
) : (
149162
<>
150163
<div className="mx-auto flex w-full max-w-3xl grow flex-col justify-center">

packages/instrument-library/src/forms/DNP_HAPPINESS_QUESTIONNAIRE/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { defineInstrument } from '/runtime/v1/@opendatacapture/runtime-core';
22
import { pick, sum } from '/runtime/v1/[email protected]';
3-
import { z } from '/runtime/v1/[email protected]';
3+
import { z } from '/runtime/v1/[email protected]/v4';
44

55
export default defineInstrument({
66
kind: 'FORM',

0 commit comments

Comments
 (0)