Skip to content

Commit

Permalink
Change topic card links to interview landing page (#64)
Browse files Browse the repository at this point in the history
* Changes topic card links to landing page URLs

Closes #51

* Uses HTML links instead of Javascript click handlers for interview liniks
  • Loading branch information
samglover authored Sep 10, 2024
1 parent 3344296 commit 2869eaa
Showing 1 changed file with 47 additions and 51 deletions.
98 changes: 47 additions & 51 deletions src/app/components/TopicCard.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use client';
import Link from 'next/link';
import { useState } from 'react';
import { toUrlFriendlyString } from '../utils/helpers';

interface TopicCardProps {
topic: {
Expand Down Expand Up @@ -52,65 +53,60 @@ const TopicCard = ({
setIsExpanded(!isExpanded);
};

const handleNavigation = (url) => {
window.location.href = url;
};

return (
<div
className={`col-lg-4 ${cardClassName} ${visibilityClass}`}
key={topic.codes[0]}
>
<Link
href={`/${path}/${topic.name.toLowerCase()}`}
className="text-decoration-none text-dark"
>
<div className="card topic-card m-1 h-100">
<div className="card-header d-flex align-items-center">
<div
style={{ minWidth: '40px', minHeight: '40px' }}
className="icon-container d-inline-flex justify-content-center align-items-center rounded"
>
<FontAwesomeIcon iconName={topic.icon} className="fa-icon" />
</div>
<h5 className="card-title ms-3">{topic.long_name}</h5>
<div className="card topic-card m-1 h-100">
<Link
href={`/${path}/${topic.name.toLowerCase()}`}
className="card-header d-flex align-items-center text-decoration-none text-dark"
>
<div
style={{ minWidth: '40px', minHeight: '40px' }}
className="icon-container d-inline-flex justify-content-center align-items-center rounded"
>
<FontAwesomeIcon iconName={topic.icon} className="fa-icon" />
</div>
<div className="card-body">
<div
className="tag-container"
style={{ maxHeight: isExpanded ? '800px' : '200px' }}
>
{displayInterviews.map((interview, index) => {
if (interview.metadata && interview.metadata.title) {
return (
<span
key={index}
className="form-tag text-decoration-none"
onClick={(e) => {
e.preventDefault();
handleNavigation(interview.serverUrl + interview.link);
}}
>
{interview.metadata.title}
</span>
);
}
return null;
})}
</div>
{interviews.length > 3 && (
<div className="show-container">
<div className="show-more" onClick={toggleExpand}>
{isExpanded ? 'Show Less' : 'Show More'}
<i
className={`fas fa-chevron-${isExpanded ? 'up' : 'down'}`}
></i>
</div>
</div>
)}
<h5 className="card-title ms-3">{topic.long_name}</h5>
</Link>
<div className="card-body">
<div
className="tag-container"
style={{ maxHeight: isExpanded ? '800px' : '200px' }}
>
{displayInterviews.map((interview, index) => {
if (interview.metadata && interview.metadata.title) {
return (
<Link
key={
toUrlFriendlyString(interview.metadata.title) +
'-' +
index
}
className="form-tag text-decoration-none"
href={`/forms/${toUrlFriendlyString(interview.metadata.title)}`}
>
{interview.metadata.title}
</Link>
);
}
return null;
})}
</div>
{interviews.length > 3 && (
<div className="show-container">
<div className="show-more" onClick={toggleExpand}>
{isExpanded ? 'Show Less' : 'Show More'}
<i
className={`fas fa-chevron-${isExpanded ? 'up' : 'down'}`}
></i>
</div>
</div>
)}
</div>
</Link>
</div>
</div>
);
};
Expand Down

0 comments on commit 2869eaa

Please sign in to comment.