| }; | }; | ||||
| return ( | return ( | ||||
| <AutoSuggestTextFieldContainer editLocation={props.editLocation}> | |||||
| <AutoSuggestTextFieldContainer | |||||
| editLocation={props.editLocation} | |||||
| error={props.error} | |||||
| > | |||||
| <Autosuggest | <Autosuggest | ||||
| suggestions={suggestions} | suggestions={suggestions} | ||||
| onSuggestionsFetchRequested={onSuggestionsFetchRequested} | onSuggestionsFetchRequested={onSuggestionsFetchRequested} | ||||
| onChange: PropTypes.func, | onChange: PropTypes.func, | ||||
| data: PropTypes.array, | data: PropTypes.array, | ||||
| editLocation: PropTypes.bool, | editLocation: PropTypes.bool, | ||||
| error: PropTypes.bool, | |||||
| }; | }; | ||||
| AutoSuggestTextField.defaultProps = { | |||||
| error: false, | |||||
| editLocation: false, | |||||
| } | |||||
| export default AutoSuggestTextField; | export default AutoSuggestTextField; |
| height: ${(props) => (props.editLocation ? "43px" : "48px")}; | height: ${(props) => (props.editLocation ? "43px" : "48px")}; | ||||
| padding: 4px 14px; | padding: 4px 14px; | ||||
| border-radius: 4px; | border-radius: 4px; | ||||
| border: 1px solid rgba(0, 0, 0, 0.23); | |||||
| border: 1px solid | |||||
| ${(props) => | |||||
| props.error | |||||
| ? selectedTheme.colors.errorColor | |||||
| : "rgba(0, 0, 0, 0.23)"}; | |||||
| outline-width: 0; | outline-width: 0; | ||||
| background-color: initial; | background-color: initial; | ||||
| font-family: ${selectedTheme.fonts.textFont}; | font-family: ${selectedTheme.fonts.textFont}; | ||||
| border: 1px solid rgba(0, 0, 0, 0.87); | border: 1px solid rgba(0, 0, 0, 0.87); | ||||
| } */ | } */ | ||||
| & input:focus-visible { | & input:focus-visible { | ||||
| border: 2px solid ${selectedTheme.colors.primaryPurple}; | |||||
| border: 2px solid | |||||
| ${(props) => | |||||
| props.error | |||||
| ? selectedTheme.colors.errorColor | |||||
| : selectedTheme.colors.primaryPurple}; | |||||
| } | } | ||||
| & input::placeholder { | & input::placeholder { | ||||
| color: rgba(0, 0, 0, 0.38); | color: rgba(0, 0, 0, 0.38); |
| labelPassword: "Lozinka", | labelPassword: "Lozinka", | ||||
| labelFirm: "Ime Firme", | labelFirm: "Ime Firme", | ||||
| labelPIB: "PIB", | labelPIB: "PIB", | ||||
| labelPhone: "Telefon (opciono)", | |||||
| labelPhone: "Telefon", | |||||
| labelPhoneNumber: "Broj telefona", | labelPhoneNumber: "Broj telefona", | ||||
| labelLocation: "Lokacija (opciono)", | |||||
| labelWebsite: "Adresa Websajta (opciono)", | |||||
| labelLocation: "Lokacija", | |||||
| labelWebsite: "Adresa Websajta", | |||||
| logout: "Odjavi se", | logout: "Odjavi se", | ||||
| next: "Sledeće", | next: "Sledeće", | ||||
| nextPage: "Sledeća strana", | nextPage: "Sledeća strana", | ||||
| imageError: "Slika je obavezna!", | imageError: "Slika je obavezna!", | ||||
| serverError: "Greška sa serverom!", | serverError: "Greška sa serverom!", | ||||
| labelLocationValid: "Unesite ispravnu lokaciju!", | labelLocationValid: "Unesite ispravnu lokaciju!", | ||||
| labelLocationRequired: "Lokacija je obavezna!", | |||||
| phoneNumberNoOfCharacters: | phoneNumberNoOfCharacters: | ||||
| "Broj telefona mora imati izmedju 6 i 15 karaktera!", | "Broj telefona mora imati izmedju 6 i 15 karaktera!", | ||||
| phoneNumberRequired: "Broj telefona je obavezan!", | |||||
| locationError: "Odaberite ispravnu lokaciju!", | locationError: "Odaberite ispravnu lokaciju!", | ||||
| websiteError: "Unesite ispravnu adresu svog website!", | websiteError: "Unesite ispravnu adresu svog website!", | ||||
| websiteRequired: "Website je obavezan!" | |||||
| }, | }, | ||||
| forgotPassword: { | forgotPassword: { | ||||
| title: "Povrati lozinku", | title: "Povrati lozinku", |
| import { | import { | ||||
| ErrorMessage, | ErrorMessage, | ||||
| FormContainer, | FormContainer, | ||||
| RegisterDescription, | |||||
| // RegisterDescription, | |||||
| } from "./SecondPartOfRegistration.styled"; | } from "./SecondPartOfRegistration.styled"; | ||||
| import { useFormik } from "formik"; | import { useFormik } from "formik"; | ||||
| import * as Yup from "yup"; | import * as Yup from "yup"; | ||||
| }); | }); | ||||
| return ( | return ( | ||||
| <FormContainer component="form" onSubmit={formik.handleSubmit}> | <FormContainer component="form" onSubmit={formik.handleSubmit}> | ||||
| <RegisterDescription component="p" variant="p"> | |||||
| {/* <RegisterDescription component="p" variant="p"> | |||||
| {t("register.descriptionSecond")} | {t("register.descriptionSecond")} | ||||
| </RegisterDescription> | |||||
| </RegisterDescription> */} | |||||
| <TextField | <TextField | ||||
| name="nameOfFirm" | name="nameOfFirm" |
| const formik = props.formik; | const formik = props.formik; | ||||
| return ( | return ( | ||||
| <> | <> | ||||
| {formik.errors?.location && formik.touched?.location ? ( | |||||
| <ErrorMessageContainer>{formik.errors.location}</ErrorMessageContainer> | |||||
| ) : formik.errors?.phoneNumber && formik.touched?.phoneNumber ? ( | |||||
| {formik.errors?.phoneNumber && formik.touched?.phoneNumber ? ( | |||||
| <ErrorMessageContainer> | <ErrorMessageContainer> | ||||
| {formik.errors.phoneNumber} | {formik.errors.phoneNumber} | ||||
| </ErrorMessageContainer> | </ErrorMessageContainer> | ||||
| ) : formik.errors?.location && formik.touched?.location ? ( | |||||
| <ErrorMessageContainer>{formik.errors.location}</ErrorMessageContainer> | |||||
| ) : formik.errors?.website && formik.touched?.website ? ( | ) : formik.errors?.website && formik.touched?.website ? ( | ||||
| <ErrorMessageContainer>{formik.errors.website}</ErrorMessageContainer> | <ErrorMessageContainer>{formik.errors.website}</ErrorMessageContainer> | ||||
| ) : ( | ) : ( |
| import PropTypes from "prop-types"; | import PropTypes from "prop-types"; | ||||
| import { | import { | ||||
| FormContainer, | FormContainer, | ||||
| RegisterDescription, | |||||
| // RegisterDescription, | |||||
| } from "./ThirdPartOfRegistration.styled"; | } from "./ThirdPartOfRegistration.styled"; | ||||
| import { useFormik } from "formik"; | import { useFormik } from "formik"; | ||||
| import { useTranslation } from "react-i18next"; | import { useTranslation } from "react-i18next"; | ||||
| return ( | return ( | ||||
| <FormContainer component="form" onSubmit={formik.handleSubmit}> | <FormContainer component="form" onSubmit={formik.handleSubmit}> | ||||
| <RegisterDescription component="p" variant="p"> | |||||
| {/* <RegisterDescription component="p" variant="p"> | |||||
| {t("register.descriptionThird")} | {t("register.descriptionThird")} | ||||
| </RegisterDescription> | |||||
| </RegisterDescription> */} | |||||
| <TextField | <TextField | ||||
| name="phoneNumber" | name="phoneNumber" | ||||
| placeholder={t("common.labelLocation")} | placeholder={t("common.labelLocation")} | ||||
| data={locations.map((item) => ({ name: item.city }))} | data={locations.map((item) => ({ name: item.city }))} | ||||
| value={formik.values.location} | value={formik.values.location} | ||||
| error={formik.touched.location && Boolean(formik.errors.location)} | |||||
| onChange={(event, { newValue }) => | onChange={(event, { newValue }) => | ||||
| formik.setFieldValue("location", newValue) | formik.setFieldValue("location", newValue) | ||||
| } | } |
| staticBackgroundColor: "#F3EFF8", | staticBackgroundColor: "#F3EFF8", | ||||
| stepProgressAltColor: "#F4F4F4", | stepProgressAltColor: "#F4F4F4", | ||||
| blockedColor: "#EE3A3A", | blockedColor: "#EE3A3A", | ||||
| errorColor: "#d32f2f" | |||||
| }; | }; |
| import i18next from "i18next"; | |||||
| import * as Yup from "yup"; | import * as Yup from "yup"; | ||||
| import i18n from "../../i18n"; | import i18n from "../../i18n"; | ||||
| Yup.object().shape({ | Yup.object().shape({ | ||||
| phoneNumber: Yup.string() | phoneNumber: Yup.string() | ||||
| .min(6, i18n.t("register.phoneNumberNoOfCharacters")) | .min(6, i18n.t("register.phoneNumberNoOfCharacters")) | ||||
| .max(14, i18n.t("register.phoneNumberNoOfCharacters")), | |||||
| location: Yup.string().oneOf( | |||||
| locations.map((l) => l.city), | |||||
| i18next.t("register.labelLocationValid") | |||||
| ), | |||||
| website: Yup.string().matches( | |||||
| /^((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, | |||||
| i18n.t("register.websiteError") | |||||
| ), | |||||
| .max(14, i18n.t("register.phoneNumberNoOfCharacters")) | |||||
| .required(i18n.t("register.phoneNumberRequired")), | |||||
| location: Yup.string() | |||||
| .oneOf( | |||||
| locations.map((l) => l.city), | |||||
| i18n.t("register.labelLocationValid") | |||||
| ) | |||||
| .required(i18n.t("register.labelLocationRequired")), | |||||
| website: Yup.string() | |||||
| .matches( | |||||
| /^((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, | |||||
| i18n.t("register.websiteError") | |||||
| ) | |||||
| .required(i18n.t("register.websiteRequired")), | |||||
| }); | }); |