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.

ThirdPartOfRegistration.js 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. import React from "react";
  2. import PropTypes from "prop-types";
  3. import {
  4. FormContainer,
  5. RegisterDescription,
  6. } from "./ThirdPartOfRegistration.styled";
  7. import { useFormik } from "formik";
  8. import * as Yup from "yup";
  9. import { useTranslation } from "react-i18next";
  10. import { TextField } from "../../../../components/TextFields/TextField/TextField";
  11. import { PrimaryButton } from "../../../../components/Buttons/PrimaryButton/PrimaryButton";
  12. import selectedTheme from "../../../../themes";
  13. const ThirdPartOfRegistration = (props) => {
  14. const { t } = useTranslation();
  15. const formik = useFormik({
  16. initialValues: {
  17. phoneNumber: "",
  18. location: "",
  19. website: "",
  20. },
  21. validationSchema: Yup.object().shape({
  22. phoneNumber: Yup.number().required(t("login.usernameRequired")),
  23. location: Yup.string().required(t("login.passwordRequired")),
  24. website: Yup.string().matches(
  25. /^((ftp|http|https):\/\/)?(www.)?(?!.*(ftp|http|https|www.))[a-zA-Z0-9_-]+(\.[a-zA-Z]+)+((\/)[\w#]+)*(\/\w+\?[a-zA-Z0-9_]+=\w+(&[a-zA-Z0-9_]+=\w+)*)?$/gm
  26. ),
  27. }),
  28. onSubmit: props.handleSubmit,
  29. validateOnBlur: true,
  30. enableReinitialize: true,
  31. });
  32. return (
  33. <FormContainer component="form" onSubmit={formik.handleSubmit}>
  34. <RegisterDescription component="p" variant="p">
  35. {t("register.descriptionThird")}
  36. </RegisterDescription>
  37. <TextField
  38. name="phoneNumber"
  39. placeholder={t("common.labelPhone")}
  40. margin="normal"
  41. type="number"
  42. value={formik.values.phoneNumber}
  43. onChange={formik.handleChange}
  44. error={formik.touched.phoneNumber && Boolean(formik.errors.phoneNumber)}
  45. helperText={formik.touched.phoneNumber && formik.errors.phoneNumber}
  46. autoFocus
  47. fullWidth
  48. />
  49. <TextField
  50. name="location"
  51. placeholder={t("common.labelLocation")}
  52. margin="normal"
  53. type="text"
  54. value={formik.values.location}
  55. onChange={formik.handleChange}
  56. error={formik.touched.location && Boolean(formik.errors.location)}
  57. helperText={formik.touched.location && formik.errors.location}
  58. fullWidth={true}
  59. />
  60. <TextField
  61. name="website"
  62. placeholder={t("common.labelWebsite")}
  63. margin="normal"
  64. type="text"
  65. value={formik.values.website}
  66. onChange={formik.handleChange}
  67. error={formik.touched.website && Boolean(formik.errors.website)}
  68. helperText={formik.touched.website && formik.errors.website}
  69. fullWidth={true}
  70. />
  71. <PrimaryButton
  72. type="submit"
  73. variant="contained"
  74. height="48px"
  75. fullWidth={true}
  76. buttoncolor={selectedTheme.primaryPurple}
  77. textcolor="white"
  78. disabled={
  79. formik.values.location.length === 0 &&
  80. formik.values.phoneNumber.length === 0 &&
  81. formik.values.website.length === 0
  82. }
  83. >
  84. {t("common.continue")}
  85. </PrimaryButton>
  86. </FormContainer>
  87. );
  88. };
  89. ThirdPartOfRegistration.propTypes = {
  90. children: PropTypes.node,
  91. handleSubmit: PropTypes.func,
  92. };
  93. export default ThirdPartOfRegistration;