From 294ca0147f3bb548bd95ae879d46b3c2ec2d3c66 Mon Sep 17 00:00:00 2001 From: TingSyuanWang Date: Fri, 4 Aug 2023 14:14:10 -0400 Subject: [PATCH 1/2] refactor: handle multi-select input box from package Signed-off-by: TingSyuanWang --- app/routes/profile-generator.jsx | 24 +++++------------------- package-lock.json | 14 +++++++------- package.json | 2 +- 3 files changed, 13 insertions(+), 27 deletions(-) diff --git a/app/routes/profile-generator.jsx b/app/routes/profile-generator.jsx index 9ff6bb4..111090c 100644 --- a/app/routes/profile-generator.jsx +++ b/app/routes/profile-generator.jsx @@ -29,27 +29,13 @@ import HandleError from '~/components/HandleError' export async function action({ request }) { let formData = await request.formData() - let rawData = {} + let data = {} for (let key of formData.keys()) { - const values = formData.getAll(key) - - // Deal with multiple values submitted as an array - if (key.endsWith('[]')) { - const keyWithoutBrackets = key.slice(0, -2) - - if (values.length === 1) { - rawData[keyWithoutBrackets] = [] - rawData[keyWithoutBrackets].push(...values) - } else { - rawData[keyWithoutBrackets] = values - } - - delete rawData[key] - } else { - rawData[key] = values.length > 1 ? values : values[0] + if (key !== '_action') { + data[key] = formData.getAll(key) } } - let { _action, ...data } = rawData + const _action = formData.get('_action') let schema, profileId, profileTitle, @@ -61,7 +47,7 @@ export async function action({ request }) { profileIpfsHash switch (_action) { case 'submit': - schema = await parseRef(data.linked_schemas) + schema = await parseRef(data.linked_schemas[0]) profile = await generateInstance(schema, data) response = await fetchJsonPost( process.env.PUBLIC_INDEX_URL + '/v2/validate', diff --git a/package-lock.json b/package-lock.json index 9d4568d..75fd47c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "1.0.0", "license": "GPLv3", "dependencies": { - "@murmurations/jsig": "^1.0.0", + "@murmurations/jsig": "^1.0.1-pre.1", "@murmurations/jsrfg": "^1.0.0", "@remix-run/react": "^1.18.1", "@vercel/node": "^2.15.3", @@ -2636,9 +2636,9 @@ "dev": true }, "node_modules/@murmurations/jsig": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@murmurations/jsig/-/jsig-1.0.0.tgz", - "integrity": "sha512-MzZjtUih9lJ6HELEe0RcRqhEe+mWX+mxpRAICb/s6Yxv/5W/V3bIIKGxIsK5+qlVkGmgOgqGb5PSx47lxW5uTg==", + "version": "1.0.1-pre.1", + "resolved": "https://registry.npmjs.org/@murmurations/jsig/-/jsig-1.0.1-pre.1.tgz", + "integrity": "sha512-SWuo6FsR7QQUto5tTrJaPtA6Is5XA/kGMDBAhzwpdTM/iWms/LkX47xJoTX3/Y9q41Qpbcy5kvr6Wp0cL+ZA9Q==", "dependencies": { "@apidevtools/json-schema-ref-parser": "^10.1.0" } @@ -16947,9 +16947,9 @@ "dev": true }, "@murmurations/jsig": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@murmurations/jsig/-/jsig-1.0.0.tgz", - "integrity": "sha512-MzZjtUih9lJ6HELEe0RcRqhEe+mWX+mxpRAICb/s6Yxv/5W/V3bIIKGxIsK5+qlVkGmgOgqGb5PSx47lxW5uTg==", + "version": "1.0.1-pre.1", + "resolved": "https://registry.npmjs.org/@murmurations/jsig/-/jsig-1.0.1-pre.1.tgz", + "integrity": "sha512-SWuo6FsR7QQUto5tTrJaPtA6Is5XA/kGMDBAhzwpdTM/iWms/LkX47xJoTX3/Y9q41Qpbcy5kvr6Wp0cL+ZA9Q==", "requires": { "@apidevtools/json-schema-ref-parser": "^10.1.0" } diff --git a/package.json b/package.json index 52d6813..1de9bb9 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ ] }, "dependencies": { - "@murmurations/jsig": "^1.0.0", + "@murmurations/jsig": "^1.0.1-pre.1", "@murmurations/jsrfg": "^1.0.0", "@remix-run/react": "^1.18.1", "@vercel/node": "^2.15.3", From 81b602b3a5fae284d17ce61cfc32cfe12348126c Mon Sep 17 00:00:00 2001 From: TingSyuanWang Date: Sat, 5 Aug 2023 03:18:41 -0400 Subject: [PATCH 2/2] chore: update jsig to v1.0.1 Signed-off-by: TingSyuanWang --- package-lock.json | 14 +++++++------- package.json | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 75fd47c..9eb6e99 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "1.0.0", "license": "GPLv3", "dependencies": { - "@murmurations/jsig": "^1.0.1-pre.1", + "@murmurations/jsig": "^1.0.1", "@murmurations/jsrfg": "^1.0.0", "@remix-run/react": "^1.18.1", "@vercel/node": "^2.15.3", @@ -2636,9 +2636,9 @@ "dev": true }, "node_modules/@murmurations/jsig": { - "version": "1.0.1-pre.1", - "resolved": "https://registry.npmjs.org/@murmurations/jsig/-/jsig-1.0.1-pre.1.tgz", - "integrity": "sha512-SWuo6FsR7QQUto5tTrJaPtA6Is5XA/kGMDBAhzwpdTM/iWms/LkX47xJoTX3/Y9q41Qpbcy5kvr6Wp0cL+ZA9Q==", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@murmurations/jsig/-/jsig-1.0.1.tgz", + "integrity": "sha512-1s68/jLrfVG/G0OmNLJ+lX5PwiE/YdESUyJoz5YwsrgjywaX07hIx+4oLIjHG/AyKMhK8OA6Lc6RyzYm/U5zlg==", "dependencies": { "@apidevtools/json-schema-ref-parser": "^10.1.0" } @@ -16947,9 +16947,9 @@ "dev": true }, "@murmurations/jsig": { - "version": "1.0.1-pre.1", - "resolved": "https://registry.npmjs.org/@murmurations/jsig/-/jsig-1.0.1-pre.1.tgz", - "integrity": "sha512-SWuo6FsR7QQUto5tTrJaPtA6Is5XA/kGMDBAhzwpdTM/iWms/LkX47xJoTX3/Y9q41Qpbcy5kvr6Wp0cL+ZA9Q==", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@murmurations/jsig/-/jsig-1.0.1.tgz", + "integrity": "sha512-1s68/jLrfVG/G0OmNLJ+lX5PwiE/YdESUyJoz5YwsrgjywaX07hIx+4oLIjHG/AyKMhK8OA6Lc6RyzYm/U5zlg==", "requires": { "@apidevtools/json-schema-ref-parser": "^10.1.0" } diff --git a/package.json b/package.json index 1de9bb9..ee66ca1 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ ] }, "dependencies": { - "@murmurations/jsig": "^1.0.1-pre.1", + "@murmurations/jsig": "^1.0.1", "@murmurations/jsrfg": "^1.0.0", "@remix-run/react": "^1.18.1", "@vercel/node": "^2.15.3",