Skip to content

Commit

Permalink
Add solutions column (#72)
Browse files Browse the repository at this point in the history
* Remove duplicate Google entry from Word Search II company list

* Add solutions column with hyperlinks to Leetcode Discuss solutions

The "Name" column has been renamed to "Questions" where each question is
now a hyperlink to the respective Leetcode URL.
  • Loading branch information
Sean Prashad committed Dec 26, 2020
1 parent 818b430 commit 32abbbc
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
35 changes: 24 additions & 11 deletions src/components/Table/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
import Toggle from 'react-toggle';
import ReactTooltip from 'react-tooltip';
import { useTable, useFilters, useSortBy } from 'react-table';
import { FaQuestionCircle, FaLock } from 'react-icons/fa';
import { FaLock, FaExternalLinkAlt, FaQuestionCircle } from 'react-icons/fa';
import {
DefaultColumnFilter,
SelectDifficultyColumnFilter,
Expand Down Expand Up @@ -105,13 +105,15 @@ const Table = () => {
totalDifficultyCount.Hard}
</span>
</Badge>
<br />
<Badge className="easy" pill>
<span
data-tip={`You've completed ${difficultyCount.Easy}/${totalDifficultyCount.Easy} easy questions`}
>
Easy: {difficultyCount.Easy}/{totalDifficultyCount.Easy}
</span>
</Badge>
<br />
<Badge className="medium" pill>
<span
data-tip={`You've completed ${difficultyCount.Medium}/${totalDifficultyCount.Medium} medium questions`}
Expand All @@ -120,6 +122,7 @@ const Table = () => {
{totalDifficultyCount.Medium}
</span>
</Badge>
<br />
<Badge className="hard" pill>
<span
data-tip={`You've completed ${difficultyCount.Hard}/${totalDifficultyCount.Hard} hard questions`}
Expand Down Expand Up @@ -154,11 +157,21 @@ const Table = () => {
},
},
{
Header: 'Name',
accessor: 'name',
Header: 'Questions',
accessor: 'questions',
Cell: cellInfo => {
return (
<span>
<NavLink
target="_blank"
href={cellInfo.row.original.url}
onClick={() => {
Event(
'Table',
'Clicked question url',
`${cellInfo.row.original.name} question url`,
);
}}
>
{cellInfo.row.original.premium ? (
<span data-tip="Requires leetcode premium to view">
<FaLock />{' '}
Expand All @@ -167,26 +180,26 @@ const Table = () => {
''
)}
{cellInfo.row.original.name}
</span>
</NavLink>
);
},
},
{
Header: 'URL',
accessor: 'url',
Header: 'Solutions',
accessor: 'solutions',
Cell: cellInfo => (
<NavLink
target="_blank"
href={cellInfo.row.original.url}
href={`${cellInfo.row.original.url}discuss`}
onClick={() => {
Event(
'Table',
'Clicked url',
`${cellInfo.row.original.name} url`,
'Clicked solution',
`${cellInfo.row.original.name} solution`,
);
}}
>
{cellInfo.row.original.url}
<FaExternalLinkAlt />
</NavLink>
),
disableFilters: true,
Expand Down
1 change: 0 additions & 1 deletion src/data/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1804,7 +1804,6 @@ const questions = [
'Uber',
'Snapchat',
'Google',
'Google',
'Oracle',
],
},
Expand Down

0 comments on commit 32abbbc

Please sign in to comment.