Skip to content
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

fix: Multiple fileInputs in a repeatingSet #4188

Merged
merged 7 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ export const processFormData = async (
const splitKey = _key.split("-");
if (splitKey.length > 1) {
const currentValue = fields[splitKey[0]] as Record<string, unknown>[];
if (!currentValue[Number(splitKey[1])]) {
currentValue[Number(splitKey[1])] = {};
}
currentValue[Number(splitKey[1])][splitKey[2]] = key;
} else {
fields[_key] = key;
Expand All @@ -72,6 +75,9 @@ export const processFormData = async (
const splitKey = _key.split("-");
if (splitKey.length > 1) {
const currentValue = fields[splitKey[0]] as Record<string, unknown>[];
if (!currentValue[Number(splitKey[1])]) {
currentValue[Number(splitKey[1])] = {};
}
currentValue[Number(splitKey[1])][`${splitKey[2]}-${index}`] = key;
} else {
fields[`${_key}-${index}`] = key;
Expand Down
2 changes: 1 addition & 1 deletion i18n/translations/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"phone": "Enter a valid telephone number.",
"regex": "Enter the correct format.",
"file-size-too-large": "Select a smaller file.",
"file-size-too-large-all-files": "Files exceed the 6 MB maximum. Upload smaller files.",
"file-size-too-large-all-files": "Files exceed the 3.5 MB maximum. Upload smaller files.",
dsamojlenko marked this conversation as resolved.
Show resolved Hide resolved
"file-type-invalid": "Select a different file type.",
"too-many-characters": "Shorten the response.",
"all-checkboxes-required": "Read and check all boxes to confirm the items in this section.",
Expand Down
2 changes: 1 addition & 1 deletion i18n/translations/fr/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"phone": "Entrer un numéro de téléphone valide.",
"regex": "Veuillez utiliser le bon format.",
"file-size-too-large": "Sélectionner un fichier plus petit.",
"file-size-too-large-all-files": "Les fichiers dépassent le maximum de 6 Mo. Téléversez des fichiers plus petits.",
"file-size-too-large-all-files": "Les fichiers dépassent le maximum de 3.5 Mo. Téléversez des fichiers plus petits.",
dsamojlenko marked this conversation as resolved.
Show resolved Hide resolved
"file-type-invalid": "Sélectionner un autre type de fichier.",
"too-many-characters": "Raccourcir la réponse.",
"all-checkboxes-required": "Lisez et cochez toutes les cases pour confirmer les éléments de cette section.",
Expand Down
2 changes: 1 addition & 1 deletion lib/tests/validation/fileValidationClientSide.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe("File extension validator", () => {
describe("File size validator", () => {
it.each([
[1000, true],
[8000000, true],
[5000000, true],
[8389121, false],
[10000000, false],
])(`Should return true if file size is valid (testing "%s")`, async (fileSize, isValid) => {
Expand Down
2 changes: 1 addition & 1 deletion lib/validation/fileValidationClientSide.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const ALLOWED_FILE_TYPES = [
{ mime: "application/xml", extensions: ["xml"] },
];

const MAXIMUM_FILE_SIZE_IN_BYTES = 8 * 1024 * 1024 + 512; // 8.5MB
const MAXIMUM_FILE_SIZE_IN_BYTES = 5 * 1024 * 1024; // 5MB

// See https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/accept
export const htmlInputAccept = ALLOWED_FILE_TYPES.map((t) =>
Expand Down
2 changes: 1 addition & 1 deletion next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ const nextConfig = {
// ppr: true,
serverComponentsExternalPackages: ["@aws-sdk/lib-dynamodb", "pino"],
serverActions: {
bodySizeLimit: "8.5mb",
bodySizeLimit: "5mb",
},
turbo: {
rules: {
Expand Down
Loading