-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upload Non-CR3 file #1641
base: john/20316-nested-object-support
Are you sure you want to change the base?
Upload Non-CR3 file #1641
Conversation
|
||
const onSelectFile = useCallback( | ||
(file: File) => { | ||
Papa.parse<NonCr3Upload>(file, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the old version of this feature used react-csv-reader, which is just a wrapper around papaparse
.
</AlignedLabel> | ||
</Alert> | ||
)} | ||
{validationErrors && ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the old version of this feature used a fancy table component that enabled the user to edit the CSV and re-submit it through the UI.
I opted to keep things simpler. AFAIK Xavier uses this feature four times per year.
/** | ||
* This is a 4x4 decimal degree bounding box centered on the tx state | ||
* capitol building | ||
* */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
copied from the old VZE
@@ -0,0 +1,86 @@ | |||
import { z } from "zod"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Zod is back! and it's making quick work of a bunch of validation code we used in the old editor.
*/ | ||
export const NonCr3UploadDedupedSchema = z | ||
.array(NonCr3UploadSchema) | ||
.refine(noDuplicateCaseIds, "Duplicate case IDs (case_id) detected"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know how common this problem is, but it was in the old VZE so i went ahead and added the test here. Without this check, Hasura is going to bomb with a very unhelpful error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested this new iteration, and I think it covers all the bases. 🙌 🚀 I requested changes because the template file is missing from the diff so it is a small fix. I also had one question about the validation behavior.
type="file" | ||
name="file" | ||
accept=".csv" | ||
onChange={(e: React.ChangeEvent<HTMLInputElement>) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i tested the invalid template, and, when I removed the problem rows from my file and tried again without refreshing the page, I'm not seeing this onChange function fire again to clear the errors. I might need someone else to test as well or confirmation that this is expected.
The errors do clear when I refresh or navigate away and back to retry the same file.
</Col> | ||
<Col className="my-auto"> | ||
<Link | ||
href="/files/non_cr3_template.csv" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@johnclary this file is missing from the public folder but I was able to test with the template from staging. 🥼
edit: I just realized that .csvs are gitignored at the root project level so that makes sense why it snuck out of this diff. I was so confused when I wasn't seeing a git change locally when i added the file to my local project. 😵💫
Associated issues
This PR adds the ability to upload a CSV of non-CR3 crashes.
Testing
URL to test: Local
./upload-non-cr3
I think that's it!
Ship list
main
branch