Skip to content

Commit 7888f8f

Browse files
authored
Merge pull request #5168 from cpinitiative/monthlies-internal
Manually Add "Internal Sol" Dropdown Item to Monthlies Table
2 parents b851991 + d9a5a81 commit 7888f8f

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

src/components/markdown/ProblemsList/ProblemsListItemDropdown.tsx

+24-9
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import React from 'react';
33
import { Instance } from 'tippy.js';
44
import { useDarkMode } from '../../../context/DarkModeContext';
55
import useUserSolutionsForProblem from '../../../hooks/useUserSolutionsForProblem';
6-
import { isUsaco, ProblemInfo } from '../../../models/problem';
6+
import { getProblemURL, isUsaco, ProblemInfo } from '../../../models/problem';
77
import TextTooltip from '../../Tooltip/TextTooltip';
88
import { DivisionProblemInfo } from './DivisionList/DivisionProblemInfo';
99
import ProblemListItemSolution from './ProblemListItemSolution';
@@ -61,15 +61,30 @@ export default function ProblemsListItemDropdown(
6161

6262
const { problem, isDivisionTable, isFocusProblem } = props;
6363
const darkMode = useDarkMode();
64-
const solutionContent =
65-
isFocusProblem || isDivisionTable == true ? (
66-
<></>
64+
65+
const solutionContent = isFocusProblem ? (
66+
<></>
67+
) : isDivisionTable ? (
68+
props?.problem?.solution?.kind == 'internal' ? (
69+
<a
70+
className={`flex items-center group px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800`}
71+
href={`${getProblemURL(problem)}/solution`}
72+
target="_blank"
73+
rel="noreferrer"
74+
>
75+
<div className="text-left">
76+
{props.problem.solution.hasHints && 'Hints + '}Internal Sol
77+
</div>
78+
</a>
6779
) : (
68-
<ProblemListItemSolution
69-
problem={props.problem}
70-
onShowSolutionSketch={props.onShowSolutionSketch}
71-
/>
72-
);
80+
<></>
81+
)
82+
) : (
83+
<ProblemListItemSolution
84+
problem={props.problem}
85+
onShowSolutionSketch={props.onShowSolutionSketch}
86+
/>
87+
);
7388

7489
const tippyRef = React.useRef<Instance>();
7590
const [isDropdownShown, setIsDropdownShown] = React.useState(false);

0 commit comments

Comments
 (0)