Commit 35e6c085 authored by David Björkheim's avatar David Björkheim
Browse files

DEICH-5591 Deichman.no: rename callback for LoginButton

parent 51ca7fbb
......@@ -7,11 +7,11 @@ import ModalPortal from "../ModalPortal/ModalPortal";
export default function LoginButton(props) {
const children = props.children;
const onClick = props.onClick || Function.prototype;
const onShowModal = props.onShowModal || Function.prototype;
const butttonsProps = { ...props };
delete butttonsProps.children;
delete butttonsProps.onClick;
delete butttonsProps.onShowModal;
const [showLoginModal, setShowLoginModal] = useState(false);
const [showDelayedModal, setShowDelayedModal] = useState(false);
......@@ -22,6 +22,10 @@ export default function LoginButton(props) {
},
[showLoginModal]
);
const clickHandler = () => {
setShowLoginModal(true);
onShowModal();
};
return (
<>
{showLoginModal && (
......@@ -53,13 +57,7 @@ export default function LoginButton(props) {
</FocusTrap>
</ModalPortal>
)}
<Button
{...butttonsProps}
onClick={() => {
setShowLoginModal(true);
onClick();
}}
>
<Button {...butttonsProps} onClick={clickHandler}>
{children}
</Button>
</>
......
......@@ -180,7 +180,7 @@ export default function ReservePublicationWidget({
<h3>{title}</h3>
{!isLoggedIn && (
<div>
<LoginButton onClick={trackLogin} primary>
<LoginButton onShowModal={trackLogin} primary>
Logg inn og bestill
</LoginButton>
</div>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment