Skip to content

Commit 2251767

Browse files
committed
feat: Implement HIPAA agreement acceptance functionality with loading state; enhance user experience with improved button states and error handling.
1 parent 962bf98 commit 2251767

File tree

2 files changed

+71
-34
lines changed

2 files changed

+71
-34
lines changed

frontend/src/components/Dashboard/EMRTraining/Emrtraining.jsx

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ const EmrTrainingComponent = () => {
6565
};
6666

6767
const getLevelColor = (level) => {
68-
switch(level) {
68+
switch (level) {
6969
case 'Beginner': return 'bg-green-100 text-green-800';
7070
case 'Intermediate': return 'bg-yellow-100 text-yellow-800';
7171
case 'Advanced': return 'bg-red-100 text-red-800';
@@ -83,7 +83,7 @@ const EmrTrainingComponent = () => {
8383
</span>
8484
</div>
8585
</div>
86-
86+
8787
<div className="space-y-3 mb-6 flex-grow">
8888
<div className="flex items-center gap-2 text-sm text-gray-600">
8989
<Clock className="h-4 w-4 text-[#169AB4]" />
@@ -94,7 +94,7 @@ const EmrTrainingComponent = () => {
9494
<span>{recording.instructor}{recording.views} views</span>
9595
</div>
9696
</div>
97-
97+
9898
<div className="flex justify-end items-center mt-auto">
9999
<button className="flex items-center gap-2 px-6 py-2 bg-[#169AB4] text-white rounded-lg hover:bg-[#147a8f] transition-colors font-medium">
100100
<Play className="h-4 w-4" />
@@ -119,11 +119,11 @@ const EmrTrainingComponent = () => {
119119
</div>
120120
</div>
121121
</div>
122-
122+
123123
<p className="text-gray-600 text-sm mb-4 leading-relaxed flex-grow">
124124
{registration.description}
125125
</p>
126-
126+
127127
<div className="space-y-3 mb-6">
128128
<div className="flex items-center gap-2 text-sm text-gray-600">
129129
<Calendar className="h-4 w-4 text-[#169AB4]" />
@@ -134,7 +134,7 @@ const EmrTrainingComponent = () => {
134134
<span>Registered on {registration.registeredDate}</span>
135135
</div>
136136
</div>
137-
137+
138138
<div className="flex justify-end items-center mt-auto">
139139
<button
140140
onClick={() => handleCancelRegistration(registration.id)}
@@ -176,36 +176,33 @@ const EmrTrainingComponent = () => {
176176
</div>
177177
</div>
178178
)}
179-
179+
180180
<div className="flex border-b border-gray-200 mb-8">
181181
<button
182182
onClick={handleShowBookingTab}
183-
className={`px-6 py-3 font-medium border-b-2 transition-colors ${
184-
activeTab === 'book'
185-
? 'border-[#169AB4] text-[#169AB4]'
183+
className={`px-6 py-3 font-medium border-b-2 transition-colors ${activeTab === 'book'
184+
? 'border-[#169AB4] text-[#169AB4]'
186185
: 'border-transparent text-gray-500 hover:text-gray-700'
187-
}`}
186+
}`}
188187
>
189188
Book Training
190189
{!hasAgreedToTerms && <span className="ml-2 text-xs text-red-500">*</span>}
191190
</button>
192191
<button
193192
onClick={() => setActiveTab('recordings')}
194-
className={`px-6 py-3 font-medium border-b-2 transition-colors ${
195-
activeTab === 'recordings'
196-
? 'border-[#169AB4] text-[#169AB4]'
193+
className={`px-6 py-3 font-medium border-b-2 transition-colors ${activeTab === 'recordings'
194+
? 'border-[#169AB4] text-[#169AB4]'
197195
: 'border-transparent text-gray-500 hover:text-gray-700'
198-
}`}
196+
}`}
199197
>
200198
Virtual Training
201199
</button>
202200
<button
203201
onClick={() => setActiveTab('registrations')}
204-
className={`px-6 py-3 font-medium border-b-2 transition-colors ${
205-
activeTab === 'registrations'
206-
? 'border-[#169AB4] text-[#169AB4]'
202+
className={`px-6 py-3 font-medium border-b-2 transition-colors ${activeTab === 'registrations'
203+
? 'border-[#169AB4] text-[#169AB4]'
207204
: 'border-transparent text-gray-500 hover:text-gray-700'
208-
}`}
205+
}`}
209206
>
210207
Your Registrations ({registrations.length})
211208
</button>
@@ -221,11 +218,10 @@ const EmrTrainingComponent = () => {
221218
<button
222219
key={month}
223220
onClick={() => setSelectedMonth(month)}
224-
className={`px-4 py-2 rounded-lg font-medium transition-colors ${
225-
selectedMonth === month
226-
? 'bg-[#169AB4] text-white'
221+
className={`px-4 py-2 rounded-lg font-medium transition-colors ${selectedMonth === month
222+
? 'bg-[#169AB4] text-white'
227223
: 'bg-gray-100 text-gray-700 hover:bg-gray-200'
228-
}`}
224+
}`}
229225
>
230226
{month}
231227
</button>
@@ -259,15 +255,21 @@ const EmrTrainingComponent = () => {
259255

260256
{activeTab === 'recordings' && (
261257
<div>
262-
<h2 className="text-xl font-semibold text-[#04445E] mb-6">Available Recordings</h2>
263-
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
264-
{recordings.map((recording) => (
265-
<RecordingCard key={recording.id} recording={recording} />
266-
))}
267-
</div>
258+
<h2 className="text-xl font-semibold text-[#04445E] mb-6">
259+
Available Recordings
260+
</h2>
261+
<a
262+
href="https://app.nextstepscareer.com/"
263+
target="_blank"
264+
rel="noopener noreferrer"
265+
className="bg-[#04445E] text-white px-4 py-2 rounded-lg shadow hover:bg-[#06617f] transition"
266+
>
267+
Click here to access NextSteps App
268+
</a>
268269
</div>
269270
)}
270271

272+
271273
{activeTab === 'registrations' && (
272274
<div>
273275
<h2 className="text-xl font-semibold text-[[#04445E] mb-6">Your Registrations</h2>

frontend/src/components/Dashboard/EMRTraining/HipaaAgreeement.jsx

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,28 @@
1-
import React from 'react';
1+
// HipaaAgreementComponent.jsx
2+
import React, { useState } from 'react';
3+
import api from '../../../utils/api.js';
24

35
const HipaaAgreementComponent = ({ onAccept, onDecline, onClose }) => {
6+
const [isSubmitting, setIsSubmitting] = useState(false);
7+
8+
const handleAccept = async () => {
9+
setIsSubmitting(true);
10+
try {
11+
const response = await api.post('/hipaa/accept');
12+
13+
if (response.data.success) {
14+
onAccept();
15+
} else {
16+
alert('Failed to save agreement. Please try again.');
17+
}
18+
} catch (error) {
19+
console.error('Error accepting HIPAA agreement:', error);
20+
alert(error.response?.data?.message || 'Failed to save agreement. Please try again.');
21+
} finally {
22+
setIsSubmitting(false);
23+
}
24+
};
25+
426
return (
527
<div className="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4">
628
<div className="bg-white rounded-lg max-w-4xl w-full max-h-[90vh] overflow-y-auto">
@@ -13,6 +35,7 @@ const HipaaAgreementComponent = ({ onAccept, onDecline, onClose }) => {
1335
<button
1436
onClick={onClose}
1537
className="text-gray-400 hover:text-gray-600 transition-colors"
38+
disabled={isSubmitting}
1639
>
1740
<svg className="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
1841
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M6 18L18 6M6 6l12 12" />
@@ -86,15 +109,27 @@ const HipaaAgreementComponent = ({ onAccept, onDecline, onClose }) => {
86109
<div className="flex gap-4">
87110
<button
88111
onClick={onDecline}
89-
className="px-8 py-3 border-2 border-red-300 rounded-lg text-red-700 hover:bg-red-50 transition-colors font-medium"
112+
disabled={isSubmitting}
113+
className="px-8 py-3 border-2 border-red-300 rounded-lg text-red-700 hover:bg-red-50 transition-colors font-medium disabled:opacity-50 disabled:cursor-not-allowed"
90114
>
91115
Decline
92116
</button>
93117
<button
94-
onClick={onAccept}
95-
className="px-8 py-3 bg-[#169AB4] text-white rounded-lg hover:bg-[#147a8f] transition-colors font-medium shadow-lg"
118+
onClick={handleAccept}
119+
disabled={isSubmitting}
120+
className="px-8 py-3 bg-[#169AB4] text-white rounded-lg hover:bg-[#147a8f] transition-colors font-medium shadow-lg disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2"
96121
>
97-
I Agree & Accept
122+
{isSubmitting ? (
123+
<>
124+
<svg className="animate-spin h-5 w-5" viewBox="0 0 24 24">
125+
<circle className="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" strokeWidth="4" fill="none" />
126+
<path className="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" />
127+
</svg>
128+
Processing...
129+
</>
130+
) : (
131+
'I Agree & Accept'
132+
)}
98133
</button>
99134
</div>
100135
</div>

0 commit comments

Comments
 (0)