Skip to content

Commit 52d4da9

Browse files
CK-7vncarddev81
authored andcommitted
fix: remove duplicate useEffect, console statements
1 parent 7c74532 commit 52d4da9

File tree

4 files changed

+92
-99
lines changed

4 files changed

+92
-99
lines changed

frontend/src/Components/forms/LoginForm.tsx

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -77,21 +77,6 @@ export default function LoginForm() {
7777
return () => clearInterval(timer);
7878
}, [lockedOutSeconds]);
7979

80-
useEffect(() => {
81-
if (lockedOutSeconds === null) {
82-
return;
83-
}
84-
const minutes = Math.floor(lockedOutSeconds / 60);
85-
const seconds = lockedOutSeconds % 60;
86-
setCountdownDisplay(
87-
minutes > 0
88-
? `${minutes} minute${minutes > 1 ? 's' : ''} and ${seconds} second${
89-
seconds !== 1 ? 's' : ''
90-
}`
91-
: `${seconds} second${seconds !== 1 ? 's' : ''}`
92-
);
93-
}, [lockedOutSeconds]);
94-
9580
const onSubmit: SubmitHandler<Inputs> = async (data) => {
9681
if (user) {
9782
data.identifier = user;

frontend/src/Components/modals/BulkUploadModal.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ export const BulkUploadModal = forwardRef<
8686
);
8787
}
8888
} catch (error) {
89-
console.error('Upload error:', error);
9089
toaster(
9190
`${error instanceof Error ? error.message : 'An error occurred while uploading the file.'}`,
9291
ToastState.error
@@ -115,8 +114,7 @@ export const BulkUploadModal = forwardRef<
115114
ToastState.error
116115
);
117116
}
118-
} catch (error) {
119-
console.error('Create accounts error:', error);
117+
} catch {
120118
toaster(
121119
'Failed to create accounts. Please try again.',
122120
ToastState.error
@@ -167,8 +165,7 @@ export const BulkUploadModal = forwardRef<
167165
link.click();
168166
document.body.removeChild(link);
169167
window.URL.revokeObjectURL(url);
170-
} catch (error) {
171-
console.error('Download error report error:', error);
168+
} catch {
172169
toaster('Failed to download error report.', ToastState.error);
173170
}
174171
};

frontend/src/Pages/FAQs.tsx

Lines changed: 88 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import API from "@/api/api";
2-
import { ChevronRightIcon } from "@heroicons/react/24/solid";
3-
import { useState } from "react";
1+
import API from '@/api/api';
2+
import { ChevronRightIcon } from '@heroicons/react/24/solid';
3+
import { useState } from 'react';
44

55
export default function FAQs() {
66
const [openQuestion, setOpenQuestion] = useState<string | null>(null);
77
const FAQ_CATEGORIES = {
8-
"Overview": [
8+
Overview: [
99
{
1010
question: "What is UnlockEd's Knowledge Center?",
1111
answer: "UnlockEd's Knowledge Center is a digital library filled with videos, articles, and other learning resources. It includes a wide variety of topics, from academic subjects to life skills, job preparation, and personal interests. You can browse freely or search for something specific to support your learning goals."
@@ -15,159 +15,173 @@ export default function FAQs() {
1515
answer: "UnlockEd gives you access to a wide variety of learning materials, including videos and articles. You'll find everything from coding tutorials to high school math study guides, resume building tips, science videos, and philosophy forums. Explore and enjoy!"
1616
},
1717
{
18-
question: "Who can use the Knowledge Center?",
18+
question: 'Who can use the Knowledge Center?',
1919
answer: "Right now, access is limited as we test and improve UnlockEd. If you know someone who might benefit from using it, let the staff know—we're hoping to expand soon!"
2020
}
2121
],
22-
"Finding and Using Content": [
22+
'Finding and Using Content': [
2323
{
24-
question: "What can I use UnlockEd for?",
25-
answer: "You can use UnlockEd to:",
24+
question: 'What can I use UnlockEd for?',
25+
answer: 'You can use UnlockEd to:',
2626
list: [
2727
"Learn about topics you're interested in",
28-
"Study for exams, including the GED",
29-
"Explore new hobbies or skills",
30-
"Prepare for job applications and reentry",
31-
"Get guidance on finances, health, and more",
28+
'Study for exams, including the GED',
29+
'Explore new hobbies or skills',
30+
'Prepare for job applications and reentry',
31+
'Get guidance on finances, health, and more'
3232
],
3333
extra: "With UnlockEd, there's no specific path or program you have to follow. You can just explore."
3434
},
3535
{
36-
question: "Can UnlockEd help me study for my GED?",
36+
question: 'Can UnlockEd help me study for my GED?',
3737
answer: "You can search for study materials on the topics you're learning. UnlockEd isn't a full GED prep program, but it gives you access to a large collection of educational resources that may help."
3838
},
3939
{
40-
question: "Can UnlockEd help with a certification I'm going for?",
40+
question:
41+
"Can UnlockEd help with a certification I'm going for?",
4142
answer: "Try searching for materials related to your program! If you don't find what you need, please let the staff know—we may be able to add more relevant content."
4243
},
4344
{
44-
question: "Can I find information on hobbies or personal interests?",
45+
question:
46+
'Can I find information on hobbies or personal interests?',
4547
answer: "Maybe! The library covers a wide range of topics, and we add more based on what people find useful. Try searching for what interests you, and if you don’t see what you're looking for, let the staff know."
4648
},
4749
{
48-
question: "Where does the content in these libraries come from?",
49-
answer: "UnlockEd offers access to free educational materials available online. These resources are created by various organizations and individuals. Descriptions of the content from many libraries can be found within UnlockEd."
50+
question:
51+
'Where does the content in these libraries come from?',
52+
answer: 'UnlockEd offers access to free educational materials available online. These resources are created by various organizations and individuals. Descriptions of the content from many libraries can be found within UnlockEd.'
5053
},
5154
{
52-
question: "Where do the videos come from?",
55+
question: 'Where do the videos come from?',
5356
answer: "Videos come from platforms like YouTube and other free educational sources. They're made by different organizations and individuals. Check the video descriptions or the beginning of the video for more details."
5457
},
5558
{
56-
question: "How is content organized in UnlockEd?",
57-
answer: "UnlockEd organizes content into categories, making it easier to find related materials. You can also search by keywords or browse featured and popular content."
59+
question: 'How is content organized in UnlockEd?',
60+
answer: 'UnlockEd organizes content into categories, making it easier to find related materials. You can also search by keywords or browse featured and popular content.'
5861
},
5962
{
60-
question: "What's the difference between featured content, popular content, and your top content?",
61-
answer: "Featured content includes resources that staff have picked as useful. Popular content is what other residents are using the most. Your top content is what you use most."
63+
question:
64+
"What's the difference between featured content, popular content, and your top content?",
65+
answer: 'Featured content includes resources that staff have picked as useful. Popular content is what other residents are using the most. Your top content is what you use most.'
6266
},
6367
{
64-
question: "I can't find what I am searching for. What should I do?",
68+
question:
69+
"I can't find what I am searching for. What should I do?",
6570
answer: "Try using different keywords or checking related topics. Try searching within a particular library that you think might be related. If you still can't find what you're looking for, ask the staff—they may be able to help you find something or request new content if it's not there."
6671
},
6772
{
68-
question: "Can I save content to watch or use later?",
69-
answer: "Yep! Click on the favorites icon (shaped like a star) to keep track of content you like."
73+
question: 'Can I save content to watch or use later?',
74+
answer: 'Yep! Click on the favorites icon (shaped like a star) to keep track of content you like.'
7075
},
7176
{
72-
question: "How can I request new content for UnlockEd?",
77+
question: 'How can I request new content for UnlockEd?',
7378
answer: "Let the staff know! We can't promise everything, but we're always looking for useful additions."
7479
}
7580
],
76-
"Managing My Account": [
81+
'Managing My Account': [
7782
{
78-
question: "Can I change my name or username?",
79-
answer: "Talk to the staff and they can help you."
83+
question: 'Can I change my name or username?',
84+
answer: 'Talk to the staff and they can help you.'
8085
},
8186
{
82-
question: "How do I reset my password?",
83-
answer: "Talk to the staff and they can help you."
87+
question: 'How do I reset my password?',
88+
answer: 'Talk to the staff and they can help you.'
8489
},
8590
{
86-
question: "Does UnlockEd have a way to track my progress?",
91+
question: 'Does UnlockEd have a way to track my progress?',
8792
answer: "Right now, UnlockEd is a library of resources you can explore freely. Some of these resources may have more of a learning path built into them, but the tool doesn't guide you along or track your progress like some other courses do. We're considering ways to help users track their learning in the future. We're always eager to hear what you'd find useful, so please let us know!"
8893
},
8994
{
90-
question: "Is my activity on UnlockEd private?",
91-
answer: "The UnlockEd team and authorized facility staff can see this information."
95+
question: 'Is my activity on UnlockEd private?',
96+
answer: 'The UnlockEd team and authorized facility staff can see this information.'
9297
}
9398
],
94-
"Getting Help and Troubleshooting": [
99+
'Getting Help and Troubleshooting': [
95100
{
96-
question: "Can I use UnlockEd more often?",
101+
question: 'Can I use UnlockEd more often?',
97102
answer: "We're excited you'd want to use it even more! Please share this request and positive feedback with the staff. They're collecting all of it as input for the future plans."
98103
},
99104
{
100-
question: "If I need more help, what do I do?",
105+
question: 'If I need more help, what do I do?',
101106
answer: "Ask the staff. If they can't help, they'll reach out to the UnlockEd team."
102107
},
103108
{
104-
question: "What should I do if something isn’t working?",
109+
question: 'What should I do if something isn’t working?',
105110
answer: "Let the staff know, and they'll report the issue!"
106111
},
107112
{
108-
question: "How can I share ideas to improve UnlockEd?",
109-
answer: "We want to hear from you! If you have ideas, suggestions, or things you’d like to change, please share them with the staff, and they’ll get passed along to the UnlockEd team."
113+
question: 'How can I share ideas to improve UnlockEd?',
114+
answer: 'We want to hear from you! If you have ideas, suggestions, or things you’d like to change, please share them with the staff, and they’ll get passed along to the UnlockEd team.'
110115
},
111116
{
112117
question: "What's next for UnlockEd?",
113118
answer: "We're always improving what we offer based on what people find helpful. For the Knowledge Center, we will continue to add valuable content and make it easy to find and use those resources. We're also exploring other offerings that would help residents access courses and track the programs they've completed. We would love to know what's valuable to you!"
114119
}
115-
]
116-
};
120+
]
121+
};
117122
const logQuestionClick = async (question: string) => {
118-
const requestBody = {
119-
question: question
120-
};
121123
try {
122-
const response = await API.post("analytics/faq-click",
123-
requestBody
124-
)
125-
if (!response.success){
126-
console.log("Unable to log that the question was clicked. Message is: ", response.message);
127-
}
128-
} catch (error) {
129-
console.error("Error occurred while trying to make POST request to endpoint 'users/faq-click'. Error is: ", error);
124+
await API.post('analytics/faq-click', { question });
125+
} catch {
126+
// Analytics failures are intentionally ignored
130127
}
131128
};
132129
const toggleQuestion = (id: string, question: string) => {
133130
setOpenQuestion(openQuestion === id ? null : id);
134131
void logQuestionClick(question);
135132
};
136133
return (
137-
<>
138-
<h2>Frequently Asked Questions</h2>
139-
<div className="space-y-3">
140-
{Object.entries(FAQ_CATEGORIES).map(([category, questions]) => (
141-
<div key={category}>
142-
<h3 className="text-sm">{category}</h3>
143-
{questions.map((faq, index) => (
144-
<div key={category + '-' + index} className="border-b">
134+
<>
135+
<h2>Frequently Asked Questions</h2>
136+
<div className="space-y-3">
137+
{Object.entries(FAQ_CATEGORIES).map(([category, questions]) => (
138+
<div key={category}>
139+
<h3 className="text-sm">{category}</h3>
140+
{questions.map((faq, index) => (
141+
<div
142+
key={category + '-' + index}
143+
className="border-b"
144+
>
145145
<button
146-
onClick={() => toggleQuestion(category + '-' + index, faq.question)}
146+
onClick={() =>
147+
toggleQuestion(
148+
category + '-' + index,
149+
faq.question
150+
)
151+
}
147152
className="flex items-center w-full px-4 py-3 text-left hover:text-teal-4"
148153
>
149154
<ChevronRightIcon
150155
className={`w-4 mr-3 transform transition-transform ${
151-
openQuestion === (category + '-' + index) ? "rotate-90" : ""
156+
openQuestion ===
157+
category + '-' + index
158+
? 'rotate-90'
159+
: ''
152160
}`}
153161
/>
154-
<span className="flex-1 body">{faq.question}</span>
162+
<span className="flex-1 body">
163+
{faq.question}
164+
</span>
155165
</button>
156166
<div
157167
className={`transition-[max-height] duration-400 ${
158-
openQuestion === (category + '-' + index) ? "overflow-visible max-h-[800px]" : "max-h-0 overflow-hidden"
168+
openQuestion === category + '-' + index
169+
? 'overflow-visible max-h-[800px]'
170+
: 'max-h-0 overflow-hidden'
159171
}`}
160172
>
161173
<div className="body px-4 pb-3 border-l-4 border-teal-3">
162174
<p>{faq.answer}</p>
163-
{("list" in faq) && faq.list && (
164-
<ul className="list-disc list-outside pl-6 mt-2">
165-
{faq.list.map((item, i) => (
166-
<li key={i}>{item}</li>
167-
))}
168-
</ul>
169-
)}
170-
{("extra" in faq) && faq.extra && <p className="mt-2">{faq.extra}</p>}
175+
{'list' in faq && faq.list && (
176+
<ul className="list-disc list-outside pl-6 mt-2">
177+
{faq.list.map((item, i) => (
178+
<li key={i}>{item}</li>
179+
))}
180+
</ul>
181+
)}
182+
{'extra' in faq && faq.extra && (
183+
<p className="mt-2">{faq.extra}</p>
184+
)}
171185
</div>
172186
</div>
173187
</div>
@@ -177,4 +191,4 @@ export default function FAQs() {
177191
</div>
178192
</>
179193
);
180-
}
194+
}

frontend/src/Pages/LibraryViewer.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,6 @@ export default function LibraryViewer() {
192192
} else if (!src.startsWith('/')) {
193193
relativeUrl = '/' + src;
194194
}
195-
console.log('Unbookmarking with relative URL:', relativeUrl);
196195
const response = await API.put(
197196
`open-content/${libraryId}/bookmark`,
198197
{
@@ -206,9 +205,8 @@ export default function LibraryViewer() {
206205
} else {
207206
toaster(response.message, ToastState.error);
208207
}
209-
} catch (error: unknown) {
208+
} catch {
210209
toaster('Error updating bookmark status', ToastState.error);
211-
console.error('Unbookmark error:', error);
212210
}
213211
};
214212

@@ -243,9 +241,8 @@ export default function LibraryViewer() {
243241
} else {
244242
toaster(response.message, ToastState.error);
245243
}
246-
} catch (error) {
244+
} catch {
247245
toaster('Error updating favorite status', ToastState.error);
248-
console.error(error);
249246
} finally {
250247
favoriteModalRef.current?.close();
251248
}

0 commit comments

Comments
 (0)