Refactor type and string handling in ThankYou component

Changed the `DynamicFormData` type to accept any data type, enhancing flexibility. Updated string handling to be more explicit with type checks, ensuring newline handling works correctly for strings only.
This commit is contained in:
Teriuihi 2024-08-11 19:09:31 +02:00
parent 25c6a15413
commit 30720d0738

View File

@ -6,7 +6,7 @@ import './ThankYou.css';
const ThankYou: FC = () => {
const location = useLocation();
type DynamicFormData = {
[key: string]: string;
[key: string]: any;
};
if (location.state === null || location.state.formData === undefined) {
@ -30,7 +30,7 @@ const ThankYou: FC = () => {
<div>
<p><strong>{key}</strong></p>
{
value.includes("\n") ?
typeof value === "string" && value.includes("\n") ?
value
.split("\n")
.filter(str => str.trim() !== "")
@ -38,9 +38,9 @@ const ThankYou: FC = () => {
: <p style={{ wordWrap: 'break-word' }}>{value}</p>
}
</div>
))}
</div>
</div>
))}
</div>
</div>
)
;
}