File size: 2,347 Bytes
b136cbe
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import { useState } from "react";

function ConsentForm({ onConsentApproved, onRejected }) {
  const [form, setForm] = useState({
    over18: false,
    readConsent: false,
    hasAudio: false,
    speaksEnglish: false,
  });

  const handleChange = (e) => {
    const { name, checked } = e.target;
    setForm((prev) => ({ ...prev, [name]: checked }));
  };

  const handleSubmit = (e) => {
    e.preventDefault();
    const allChecked = Object.values(form).every(Boolean);
    if (allChecked) {
      onConsentApproved();
    } else {
      onRejected();
    }
  };

  return (
<form
  onSubmit={handleSubmit}
  style={{
    minHeight: '100vh',
    display: 'flex',
    flexDirection: 'column',
    gap: '1.5rem',
    padding: '1rem 2rem', // top/bottom 1rem, left/right 2rem
  }}
>
  <h2 style={{ margin: 0 }}>Consent Form</h2>

  <div style={{ height: '66.67vh' }}>
    <object
      data="/images/consent_form.pdf"
      type="application/pdf"
      width="100%"
      height="100%"
    >
      <p>
        Your browser doesn't support embedded PDFs.
        <a href="/consent.pdf" target="_blank" rel="noopener noreferrer">
          View the consent form
        </a>
      </p>
    </object>
  </div>

  <div style={{ display: 'flex', flexDirection: 'column', gap: '0.5rem' }}>
    <label>
      <input
        type="checkbox"
        name="over18"
        checked={form.over18}
        onChange={handleChange}
      />
      {' '}I am 18 years of age or older
    </label>
    <label>
      <input
        type="checkbox"
        name="readConsent"
        checked={form.readConsent}
        onChange={handleChange}
      />
      {' '}I have read and agree to the consent form
    </label>
    <label>
      <input
        type="checkbox"
        name="hasAudio"
        checked={form.hasAudio}
        onChange={handleChange}
      />
      {' '}I have access to a device that can play audio
    </label>
    <label>
      <input
        type="checkbox"
        name="speaksEnglish"
        checked={form.speaksEnglish}
        onChange={handleChange}
      />
      {' '}I can understand and speak English
    </label>
  </div>

  <button
    type="submit"
    style={{
      marginTop: '1rem',
      padding: '0.5rem 1rem',
      alignSelf: 'flex-start',
    }}
  >
    Continue
  </button>
</form>
  );
}

export default ConsentForm;