-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
closes #117 Co-Authored-By: steveoh <sgourley@utah.gov>
- Loading branch information
Showing
5 changed files
with
100 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,7 @@ | |
"SGID", | ||
"stringifier", | ||
"tailwindcss", | ||
"trimable", | ||
"UGRC", | ||
"vercel", | ||
"Wkid", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
const errors = { | ||
CSV_RECORD_INCONSISTENT_COLUMNS: | ||
'that a record did not contain the same amount of fields as the previous record. Somewhere in your file, a row is missing or has extra field delimiters.', | ||
CSV_INVALID_CLOSING_QUOTE: 'a quote in an unexpected location. Please check the quotes in your CSV file.', | ||
CSV_RECORD_INCONSISTENT_FIELDS_LENGTH: | ||
'that a record did not contain the same amount of fields as the previous record. Somewhere in your file, a row is missing or has extra field delimiters.', | ||
CSV_RECORD_DONT_MATCH_COLUMNS_LENGTH: | ||
'that a record did not contain the same amount of columns. Somewhere in your file, a row is missing or has extra field delimiters.', | ||
CSV_QUOTE_NOT_CLOSED: 'an open quote that was not closed. Please check the quotes in your CSV file.', | ||
}; | ||
|
||
export const CSV_PARSE_ERROR = 'CSV_PARSE_ERROR'; | ||
|
||
export default function InvalidCsv({ errorDetails }) { | ||
let message = 'something we have never seen before. Good luck and try again!'; | ||
|
||
const [code, stack] = errorDetails; | ||
|
||
if (Object.keys(errors).includes(code)) { | ||
message = errors[code]; | ||
|
||
window.ugrc.trackEvent({ | ||
category: 'invalid-file-type', | ||
label: code, | ||
}); | ||
} else { | ||
window.ugrc.trackEvent({ | ||
category: 'unhandled-invalid-file-type', | ||
label: code, | ||
}); | ||
} | ||
|
||
return ( | ||
<div className="w-full px-4 my-4 border rounded shadow border-amber-800 border-3 bg-amber-50"> | ||
<h2 className="text-center text-amber-500">Woops, that CSV is not valid</h2> | ||
<p>The file you selected has some problems that you will need to correct before we can continue.</p> | ||
<p>We found {message}</p> | ||
{stack && ( | ||
<> | ||
<label htmlFor="stack">Stack trace:</label> | ||
<pre id="stack" className="overflow-auto text-base text-gray-400"> | ||
{stack} | ||
</pre> | ||
</> | ||
)} | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters