Skip to content

Commit

Permalink
Merge pull request #114 from fc5y/qtuan1401/enhance/ContestActionButton
Browse files Browse the repository at this point in the history
Fix wrong Contest Action Button Dropdown material behaviour
  • Loading branch information
hnngo authored Jan 2, 2021
2 parents d32cf4d + 154d7aa commit 66a68c0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
12 changes: 10 additions & 2 deletions src/app/common-ui/DropdownButton/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@ import ClickWrapper from 'src/app/components/ClickWrapper';

import styles from './style.scss';

export function DropDownButton({ className, children, dropList = [], type, ...otherProps }) {
export function DropDownButton({
className,
onClickAllMaterials,
children,
dropList = [],
type,
...otherProps
}) {
const [showList, setShowList] = React.useState(false);
const isPrimary = type === 'primary';

Expand All @@ -18,7 +25,7 @@ export function DropDownButton({ className, children, dropList = [], type, ...ot
className={cx(styles.dropdownButton, isPrimary && styles.primaryDropdownButton)}
type="button"
{...otherProps}
onClick={() => setShowList((showList) => !showList)}
onClick={onClickAllMaterials}
>
{children}
</button>
Expand Down Expand Up @@ -62,6 +69,7 @@ DropDownButton.propTypes = {
type: PropTypes.string,
children: PropTypes.node,
dropList: PropTypes.any,
onClickAllMaterials: PropTypes.any,
};

export function PrimaryDropDownButton(props) {
Expand Down
14 changes: 12 additions & 2 deletions src/app/components/ContestActionButton/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,19 @@ function MaterialButton({ materials, type, buttonWidth }) {
return (
<ButtonWrapper buttonWidth={buttonWidth}>
{type === 'primary' ? (
<PrimaryDropDownButton dropList={dropList}>Xem tư liệu kỳ thi</PrimaryDropDownButton>
<PrimaryDropDownButton
dropList={dropList}
onClickAllMaterials={() => openLink(materials.all_materials_url)}
>
Xem tư liệu kỳ thi
</PrimaryDropDownButton>
) : (
<DropDownButton dropList={dropList}>Xem tư liệu kỳ thi</DropDownButton>
<DropDownButton
dropList={dropList}
onClickAllMaterials={() => openLink(materials.all_materials_url)}
>
Xem tư liệu kỳ thi
</DropDownButton>
)}
</ButtonWrapper>
);
Expand Down

0 comments on commit 66a68c0

Please sign in to comment.