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

feat: uses username on highlight instead of full name #162

Merged
merged 2 commits into from Jun 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 5 additions & 7 deletions src/pages/home.tsx
Expand Up @@ -23,6 +23,7 @@
title: string;
name: string;
url: string;
login: string;
}


Expand All @@ -31,7 +32,7 @@
const { currentTabIsOpensaucedUser, checkedUser } = useOpensaucedUserCheck();
const [highlights, setHighlights] = useState<Highlight[]>([]);
const [currentPage, setCurrentPage] = useState(0);
const [currentName, setCurrentName] = useState<string>("");

Check warning on line 35 in src/pages/home.tsx

View workflow job for this annotation

GitHub Actions / test / Code standards

'currentName' is assigned a value but never used


useEffect(() => {
Expand All @@ -57,16 +58,13 @@
setCurrentPage(prevPage => prevPage + 1);
};

const formatNameForLink = (name: string): string => name.replace(/\s/g, "");

useEffect(() => {
// Update the current name when the highlight changes
if (highlights[currentPage]?.name) {
setCurrentName(formatNameForLink(highlights[currentPage].name));
if (highlights[currentPage]?.login) {
setCurrentName(highlights[currentPage].login);
}
}, [highlights, currentPage]);


return (
<div className="p-4 bg-slate-800">
<div className="grid grid-cols-1 divide-y divide-white/40 divider-y-center-2 min-w-[320px] text-white">
Expand Down Expand Up @@ -119,13 +117,13 @@

<a
className="text-blue-500 hover:text-blue-700 underline cursor-pointer"
href={`https://insights.opensauced.pizza/user/${formatNameForLink(highlights[currentPage]?.name)}`}
href={`https://insights.opensauced.pizza/user/${highlights[currentPage]?.login}`}
rel="noopener noreferrer"
target="_blank"


>
{highlights[currentPage]?.name}
{highlights[currentPage]?.login}
</a>
</div>

Expand Down