Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

website content update feedback #2440

Merged
merged 7 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 65 additions & 50 deletions website2/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion website2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
"date-fns": "^4.1.0",
"dompurify": "^3.2.4",
"framer-motion": "^11.11.1",
"glob": "^9.3.5",
"lucide-react": "^0.447.0",
"next": "14.2.14",
"next": "^14.2.23",
"quill-delta-to-html": "^0.12.1",
"react": "^18",
"react-dom": "^18",
Expand Down
89 changes: 71 additions & 18 deletions website2/src/app/clean-air-forum/glossary/page.tsx
Original file line number Diff line number Diff line change
@@ -1,36 +1,89 @@
'use client';
import DOMPurify from 'dompurify';
import Link from 'next/link';
import { useRouter } from 'next/navigation';
import React from 'react';

import { Divider } from '@/components/ui';
import { useForumData } from '@/context/ForumDataContext';
import { useDispatch, useSelector } from '@/hooks/reduxHooks';
import { selectEvent } from '@/store/slices/forumSlice';
import { renderContent } from '@/utils/quillUtils';

const Page = () => {
const data = useForumData();
const Page: React.FC = () => {
const router = useRouter();
const dispatch = useDispatch();
// Retrieve forum events and selected event index from Redux.
const { events, selectedEventIndex } = useSelector((state) => state.forum);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add type definitions for Redux state.

Define proper types for the Redux state to improve type safety.

+interface ForumEvent {
+  id: string;
+  title: string;
+  glossary_details: string;
+}
+
+interface ForumState {
+  events: ForumEvent[];
+  selectedEventIndex: number;
+}

-  const { events, selectedEventIndex } = useSelector((state) => state.forum);
+  const { events, selectedEventIndex } = useSelector((state: { forum: ForumState }) => state.forum);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const { events, selectedEventIndex } = useSelector((state) => state.forum);
+interface ForumEvent {
+ id: string;
+ title: string;
+ glossary_details: string;
+}
+
+interface ForumState {
+ events: ForumEvent[];
+ selectedEventIndex: number;
+}
- const { events, selectedEventIndex } = useSelector((state) => state.forum);
+ const { events, selectedEventIndex } = useSelector((state: { forum: ForumState }) => state.forum);


if (!data) {
if (events.length === 0) {
return null;
}

const selectedEvent = events[selectedEventIndex];

// Utility function to create a slug from event title.
const createSlug = (title: string) => {
return title.split(',')[0].trim().toLowerCase().replace(/\s+/g, '-');
};

return (
<div className="px-4 lg:px-0 flex flex-col gap-6">
<Divider className="bg-black p-0 m-0 h-[1px] w-full" />

{/* Split Section - Vaccination */}
<div>
<div className="flex flex-col md:flex-row md:space-x-8">
<div className="md:w-1/3 mb-4 md:mb-0">
<h2 className="text-2xl font-bold text-gray-900">
Clear Air Glossary
</h2>
</div>
<div
className="md:w-2/3 space-y-4"
dangerouslySetInnerHTML={{
__html: renderContent(data.glossary_details),
}}
></div>
{/* Clean Air Forum Events Section */}
<div className="flex flex-col md:flex-row md:space-x-8">
{/* Left column: Heading */}
<div className="md:w-1/3 mb-4 md:mb-0">
<h3 className="text-xl font-semibold">Clean Air Forum Events</h3>
</div>
{/* Right column: List of events */}
<div className="md:w-2/3">
<ul className="space-y-2">
{events.map((event, index) => {
const slug = createSlug(event.title);
const href = `/clean-air-forum?slug=${encodeURIComponent(slug)}`;
return (
<li key={event.id}>
<Link
href={href}
onClick={(e) => {
e.preventDefault();
dispatch(selectEvent(index));
router.push('/clean-air-forum');
window.scrollTo({ top: 0, behavior: 'smooth' });
}}
className={`text-blue-600 hover:underline ${
selectedEventIndex === index ? 'font-bold' : ''
}`}
>
{event.title}
</Link>
</li>
);
})}
</ul>
</div>
</div>

<Divider className="bg-black p-0 m-0 h-[1px] w-full" />

{/* Clear Air Glossary Section */}
<div className="flex flex-col md:flex-row md:space-x-8">
{/* Left column: Heading */}
<div className="md:w-1/3 mb-4 md:mb-0">
<h2 className="text-2xl font-bold text-gray-900">
Clear Air Glossary
</h2>
</div>
{/* Right column: Glossary content */}
<div
className="md:w-2/3 space-y-4"
dangerouslySetInnerHTML={{
__html: DOMPurify.sanitize(
renderContent(selectedEvent.glossary_details),
),
}}
></div>
</div>
</div>
);
Expand Down
Loading
Loading