Norbert de Langen ce2f7978f3
fix
2022-10-10 18:05:33 +02:00

28 lines
715 B
JavaScript

/* eslint-disable no-undef */
export const Form = ({ complete, value, setValue, onSubmit }) => {
const container = document.createElement('div');
container.innerHTML = `
<form id="interaction-test-form">
<label>
Enter Value
<input type="text" data-testid="value" required />
</label>
<button type="submit">Submit</button>
${complete ? '<p>Completed!!</p>' : ''}
</form>
`;
const form = container.querySelector('form');
form.onSubmit = (e) => {
e.preventDefault();
onSubmit(e);
};
const input = container.querySelector('[data-testid="value"]');
input.value = value;
input.onInput = (e) => setValue(e.target.value);
return container;
};