You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

PricesButton.js 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import React from "react";
  2. import PropTypes from "prop-types";
  3. import { useTranslation } from "react-i18next";
  4. import { ABOUT_PAGE } from "../../../../constants/pages";
  5. import { DollarIcon, GrayButton } from "../MyProfile.styled";
  6. import { PopoverButton } from "../../HeaderPopover/HeaderPopover.styled";
  7. import { useHistory } from "react-router-dom";
  8. import scrollConstants from "../../../../constants/scrollConstants";
  9. import { routeMatches } from "../../../../util/helpers/routeHelpers";
  10. const PricesButton = (props) => {
  11. const { t } = useTranslation();
  12. const history = useHistory();
  13. const seePrices = () => {
  14. if (!routeMatches(ABOUT_PAGE)) {
  15. history.push({
  16. pathname: ABOUT_PAGE,
  17. state: {
  18. navigation: scrollConstants.about.pricesPage,
  19. clicked: true,
  20. },
  21. });
  22. } else {
  23. history.replace({
  24. state: {
  25. clicked: true,
  26. navigation: scrollConstants.about.pricesPage,
  27. },
  28. });
  29. }
  30. props.closePopover();
  31. };
  32. return (
  33. <GrayButton>
  34. <PopoverButton
  35. sx={{
  36. mr: 2,
  37. mb: 2,
  38. }}
  39. variant="text"
  40. endIcon={<DollarIcon />}
  41. onClick={seePrices}
  42. >
  43. {t("header.prices")}
  44. </PopoverButton>
  45. </GrayButton>
  46. );
  47. };
  48. PricesButton.propTypes = {
  49. children: PropTypes.node,
  50. closePopover: PropTypes.func,
  51. };
  52. export default PricesButton;