ChangePassword.js 1.1 KB

1234567891011121314151617181920212223242526
  1. import {useEffect, useState} from "react";
  2. import {InputText} from "primereact/inputtext";
  3. import {Button} from "primereact/button";
  4. import authorizedFetch from "../Utils";
  5. import {SPRING_SERVER} from "../config";
  6. import {useTranslation} from "react-i18next";
  7. export default function (props) {
  8. const [newPassword, setNewPassword] = useState("")
  9. const [repeatPassword, setRepeatPassword] = useState("")
  10. const { t } = useTranslation(); // Initialize the hook
  11. function changePasswordClick() {
  12. if (newPassword === repeatPassword)
  13. authorizedFetch(SPRING_SERVER + "/api/setPassword/" + props.userData.login + "/" + newPassword)
  14. }
  15. return (
  16. <div className="shadow-4 flex flex-column p-2">
  17. <InputText className="" value={newPassword} placeholder={t("chgPass")} onChange={(e) => setNewPassword(e.target.value)}/>
  18. <InputText className="mt-2" value={repeatPassword} placeholder={t("repPass")} onChange={(e) => setRepeatPassword(e.target.value)}/>
  19. <Button onClick={changePasswordClick} className="mt-2">{t("chgPass")}</Button>
  20. </div>
  21. )
  22. }