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:
@@ -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() !== "")
|
||||
@@ -40,7 +40,7 @@ const ThankYou: FC = () => {
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user