From faefe66c11212e85fa0c0eae8d54fa8229905eeb Mon Sep 17 00:00:00 2001 From: Owen-Morgan825 Date: Tue, 3 Dec 2024 18:24:17 -0500 Subject: [PATCH 1/3] Testing configurable newline character. --- config/2024/config.json | 3 ++- config/schema.json | 23 +++++++++++++++++++---- src/components/QR/QRModal.tsx | 2 +- src/components/inputs/BaseInputProps.ts | 1 + 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/config/2024/config.json b/config/2024/config.json index 53b36cf..cdb064e 100644 --- a/config/2024/config.json +++ b/config/2024/config.json @@ -2,6 +2,7 @@ "$schema": "../schema.json", "title": "QRScout", "page_title": "Crescendo", + "newline_character": "\t", "sections": [ { "name": "Prematch", @@ -245,4 +246,4 @@ ] } ] -} +} \ No newline at end of file diff --git a/config/schema.json b/config/schema.json index 9f85202..808d324 100644 --- a/config/schema.json +++ b/config/schema.json @@ -14,6 +14,9 @@ "page_title": { "type": "string" }, + "newline_character": { + "type": "string" + }, "sections": { "type": "array", "items": { @@ -21,7 +24,11 @@ } } }, - "required": ["title", "page_title", "sections"], + "required": [ + "title", + "page_title", + "sections" + ], "additionalProperties": false }, "Section": { @@ -41,7 +48,10 @@ } } }, - "required": ["name", "fields"], + "required": [ + "name", + "fields" + ], "additionalProperties": false }, "InputProps": { @@ -87,7 +97,12 @@ "type": "boolean" } }, - "required": ["title", "type", "required", "code"], + "required": [ + "title", + "type", + "required", + "code" + ], "additionalProperties": false }, "InputTypes": { @@ -104,4 +119,4 @@ ] } } -} +} \ No newline at end of file diff --git a/src/components/QR/QRModal.tsx b/src/components/QR/QRModal.tsx index 4e831ee..4ac1058 100644 --- a/src/components/QR/QRModal.tsx +++ b/src/components/QR/QRModal.tsx @@ -15,7 +15,7 @@ export function getQRCodeData(formData: Config): string { .map(s => s.fields) .flat() .map(v => `${v.value}`.replace(/\n/g, ' ')) - .join('\t'); + .join(formData.newline_character); } export function QRModal(props: QRModalProps) { diff --git a/src/components/inputs/BaseInputProps.ts b/src/components/inputs/BaseInputProps.ts index 3a7f3f4..1bb864b 100644 --- a/src/components/inputs/BaseInputProps.ts +++ b/src/components/inputs/BaseInputProps.ts @@ -5,6 +5,7 @@ export default interface BaseInputProps extends InputProps { export interface Config { title: string; page_title: string; + newline_character: string; sections: SectionProps[]; } From 7ff2ac00269af95a09edce3bec7ae0b066bb7dcb Mon Sep 17 00:00:00 2001 From: Owen-Morgan825 Date: Tue, 3 Dec 2024 18:41:02 -0500 Subject: [PATCH 2/3] Line seperator character feild added to config.json and fixed the way it's viewed in the preview. --- config/2024/config.json | 3 ++- src/components/QR/PreviewText.tsx | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/config/2024/config.json b/config/2024/config.json index cdb064e..9d52245 100644 --- a/config/2024/config.json +++ b/config/2024/config.json @@ -112,7 +112,8 @@ "6": "Midline 3 (Middle)", "7": "Midline 2", "8": "Midline 1 (Amp Edge)" - } + }, + "required": false }, { "code": "auf", diff --git a/src/components/QR/PreviewText.tsx b/src/components/QR/PreviewText.tsx index 86d3be3..0dbd8b5 100644 --- a/src/components/QR/PreviewText.tsx +++ b/src/components/QR/PreviewText.tsx @@ -1,10 +1,12 @@ +import { useQRScoutState } from '../../store/store'; import { CopyButton } from './CopyButton'; export type PreviewTextProps = { data: string; }; export function PreviewText(props: PreviewTextProps) { - const chunks = props.data.split('\t'); + const formData = useQRScoutState(state => state.formData); + const chunks = props.data.split(formData.newline_character); return (
From dddc5cd4ed54d81c2b5836a0aeafb8278bac5265 Mon Sep 17 00:00:00 2001 From: Owen-Morgan825 Date: Tue, 3 Dec 2024 18:43:34 -0500 Subject: [PATCH 3/3] change name of line seperator from "newline_character" to "delimiter" --- config/2024/config.json | 2 +- config/schema.json | 2 +- src/components/QR/PreviewText.tsx | 2 +- src/components/QR/QRModal.tsx | 2 +- src/components/inputs/BaseInputProps.ts | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/config/2024/config.json b/config/2024/config.json index 9d52245..5648312 100644 --- a/config/2024/config.json +++ b/config/2024/config.json @@ -2,7 +2,7 @@ "$schema": "../schema.json", "title": "QRScout", "page_title": "Crescendo", - "newline_character": "\t", + "delimiter": "\t", "sections": [ { "name": "Prematch", diff --git a/config/schema.json b/config/schema.json index 808d324..ff8c99f 100644 --- a/config/schema.json +++ b/config/schema.json @@ -14,7 +14,7 @@ "page_title": { "type": "string" }, - "newline_character": { + "delimiter": { "type": "string" }, "sections": { diff --git a/src/components/QR/PreviewText.tsx b/src/components/QR/PreviewText.tsx index 0dbd8b5..a86ece9 100644 --- a/src/components/QR/PreviewText.tsx +++ b/src/components/QR/PreviewText.tsx @@ -6,7 +6,7 @@ export type PreviewTextProps = { }; export function PreviewText(props: PreviewTextProps) { const formData = useQRScoutState(state => state.formData); - const chunks = props.data.split(formData.newline_character); + const chunks = props.data.split(formData.delimiter); return (
diff --git a/src/components/QR/QRModal.tsx b/src/components/QR/QRModal.tsx index 4ac1058..e7bc381 100644 --- a/src/components/QR/QRModal.tsx +++ b/src/components/QR/QRModal.tsx @@ -15,7 +15,7 @@ export function getQRCodeData(formData: Config): string { .map(s => s.fields) .flat() .map(v => `${v.value}`.replace(/\n/g, ' ')) - .join(formData.newline_character); + .join(formData.delimiter); } export function QRModal(props: QRModalProps) { diff --git a/src/components/inputs/BaseInputProps.ts b/src/components/inputs/BaseInputProps.ts index 1bb864b..a5655ca 100644 --- a/src/components/inputs/BaseInputProps.ts +++ b/src/components/inputs/BaseInputProps.ts @@ -5,7 +5,7 @@ export default interface BaseInputProps extends InputProps { export interface Config { title: string; page_title: string; - newline_character: string; + delimiter: string; sections: SectionProps[]; }