2023-06-26 10:07:12 +00:00
|
|
|
"use client";
|
|
|
|
|
|
2023-02-13 13:46:56 +00:00
|
|
|
import { FC, useState } from "react";
|
2023-06-28 09:09:45 +00:00
|
|
|
import { useRouter, usePathname } from "next/navigation";
|
2023-02-13 13:46:56 +00:00
|
|
|
import { Button } from "@mui/material";
|
|
|
|
|
import { QuestionMark as QuestionMarkIcon } from "@mui/icons-material";
|
2024-06-05 08:52:41 +02:00
|
|
|
import { useLeafcutterContext } from "@link-stack/leafcutter-ui/components/LeafcutterProvider";
|
2023-02-13 13:46:56 +00:00
|
|
|
|
|
|
|
|
export const HelpButton: FC = () => {
|
|
|
|
|
const router = useRouter();
|
2023-07-23 11:21:39 +02:00
|
|
|
const pathname = usePathname() ?? "";
|
2023-02-13 13:46:56 +00:00
|
|
|
const [helpActive, setHelpActive] = useState(false);
|
|
|
|
|
const {
|
|
|
|
|
colors: { leafcutterElectricBlue },
|
2024-03-20 17:51:21 +01:00
|
|
|
} = useLeafcutterContext();
|
2023-02-13 13:46:56 +00:00
|
|
|
const onClick = () => {
|
|
|
|
|
if (helpActive) {
|
2023-06-28 09:09:45 +00:00
|
|
|
router.push(pathname);
|
2023-02-13 13:46:56 +00:00
|
|
|
} else {
|
|
|
|
|
router.push("/?tooltip=welcome");
|
|
|
|
|
}
|
|
|
|
|
setHelpActive(!helpActive);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Button
|
|
|
|
|
color="primary"
|
|
|
|
|
onClick={onClick}
|
|
|
|
|
sx={{
|
|
|
|
|
backgroundColor: leafcutterElectricBlue,
|
|
|
|
|
width: "40px",
|
|
|
|
|
height: "40px",
|
|
|
|
|
minWidth: "40px",
|
|
|
|
|
p: 0,
|
|
|
|
|
borderRadius: "500px",
|
|
|
|
|
":hover": {
|
|
|
|
|
backgroundColor: leafcutterElectricBlue,
|
|
|
|
|
opacity: 0.8,
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<QuestionMarkIcon width="30px" height="30px" htmlColor="white" />
|
|
|
|
|
</Button>
|
|
|
|
|
);
|
|
|
|
|
};
|