File size: 837 Bytes
b59aa07
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import React from "react";
import { useTranslation } from "react-i18next";
import { I18nKey } from "#/i18n/declaration";
import { getRandomTip } from "#/utils/tips";

export function RandomTip() {
  const { t } = useTranslation();
  const [randomTip, setRandomTip] = React.useState(getRandomTip());

  // Update the random tip when the component mounts
  React.useEffect(() => {
    setRandomTip(getRandomTip());
  }, []);

  return (
    <p>
      <h4 className="font-bold">{t(I18nKey.TIPS$PROTIP)}:</h4>
      {t(randomTip.key)}
      {randomTip.link && (
        <>
          {" "}
          <a
            href={randomTip.link}
            target="_blank"
            rel="noopener noreferrer"
            className="underline"
          >
            {t(I18nKey.TIPS$LEARN_MORE)}
          </a>
        </>
      )}
    </p>
  );
}