| { | { | ||||
| "name": "web", | "name": "web", | ||||
| "version": "0.1.0", | |||||
| "version": "2.0.4", | |||||
| "lockfileVersion": 1, | "lockfileVersion": 1, | ||||
| "requires": true, | "requires": true, | ||||
| "dependencies": { | "dependencies": { |
| ButtonsContainer, | ButtonsContainer, | ||||
| ErrorMessage, | ErrorMessage, | ||||
| ProfileImagePicker, | ProfileImagePicker, | ||||
| InputFieldLabelLocation, | |||||
| } from "./EditProfile.styled"; | } from "./EditProfile.styled"; | ||||
| import selectedTheme from "../../../themes"; | import selectedTheme from "../../../themes"; | ||||
| import { useFormik } from "formik"; | import { useFormik } from "formik"; | ||||
| import { selectUserId } from "../../../store/selectors/loginSelectors"; | import { selectUserId } from "../../../store/selectors/loginSelectors"; | ||||
| import editProfileValidation from "../../../validations/editProfileValidation"; | import editProfileValidation from "../../../validations/editProfileValidation"; | ||||
| import useIsMobile from "../../../hooks/useIsMobile"; | import useIsMobile from "../../../hooks/useIsMobile"; | ||||
| import AutoSuggestTextField from "../../TextFields/AutoSuggestTextField/AutoSuggestTextField"; | |||||
| import { selectLocations } from "../../../store/selectors/locationsSelectors"; | |||||
| const EditProfile = (props) => { | const EditProfile = (props) => { | ||||
| const [profileImage, setProfileImage] = useState(props.profile.image); | const [profileImage, setProfileImage] = useState(props.profile.image); | ||||
| const dispatch = useDispatch(); | const dispatch = useDispatch(); | ||||
| const { isMobile } = useIsMobile(); | const { isMobile } = useIsMobile(); | ||||
| const userId = useSelector(selectUserId); | const userId = useSelector(selectUserId); | ||||
| const locations = useSelector(selectLocations); | |||||
| useEffect(() => { | useEffect(() => { | ||||
| if (isMobile) { | if (isMobile) { | ||||
| fullWidth | fullWidth | ||||
| disabled | disabled | ||||
| /> | /> | ||||
| <InputFieldLabel | |||||
| <InputFieldLabelLocation | |||||
| leftText={t("common.labelLocation").toUpperCase()} | leftText={t("common.labelLocation").toUpperCase()} | ||||
| /> | /> | ||||
| <InputField | |||||
| <AutoSuggestTextField | |||||
| editLocation | |||||
| data={locations.map((item) => ({ name: item.city }))} | |||||
| value={formik.values.firmLocation} | |||||
| onChange={(event, { newValue }) => | |||||
| formik.setFieldValue("firmLocation", newValue) | |||||
| } | |||||
| /> | |||||
| {/* <InputField | |||||
| name="firmLocation" | name="firmLocation" | ||||
| value={formik.values.firmLocation} | value={formik.values.firmLocation} | ||||
| onChange={formik.handleChange} | onChange={formik.handleChange} | ||||
| error={formik.touched.firmLocation && formik.errors.firmLocation} | error={formik.touched.firmLocation && formik.errors.firmLocation} | ||||
| margin="normal" | margin="normal" | ||||
| fullWidth | fullWidth | ||||
| /> | |||||
| /> */} | |||||
| </BasicInfo> | </BasicInfo> | ||||
| )} | )} | ||||
| {showDetails && ( | {showDetails && ( | ||||
| <DetailsInfo> | <DetailsInfo> | ||||
| <InputFieldLabel | <InputFieldLabel | ||||
| leftText={t("editProfile.website").toUpperCase()} | leftText={t("editProfile.website").toUpperCase()} | ||||
| labelWebsite | |||||
| /> | /> | ||||
| <InputField | <InputField | ||||
| name="firmWebsite" | name="firmWebsite" |
| export const InputFieldLabel = styled(Label)` | export const InputFieldLabel = styled(Label)` | ||||
| position: relative; | position: relative; | ||||
| bottom: -14px; | bottom: -14px; | ||||
| & label { | & label { | ||||
| font-size: 12px; | font-size: 12px; | ||||
| font-weight: 600; | font-weight: 600; | ||||
| color: #808080; | color: #808080; | ||||
| cursor: auto; | cursor: auto; | ||||
| letter-spacing: 0.2px; | letter-spacing: 0.2px; | ||||
| ${(props) => props.labelWebsite && `margin-top: 8px`} | |||||
| } | } | ||||
| @media screen and (max-width: 600px) { | @media screen and (max-width: 600px) { | ||||
| & label { | & label { | ||||
| font-size: 9px; | font-size: 9px; | ||||
| margin-top: -3px; | |||||
| margin-top: 0; | |||||
| } | } | ||||
| } | } | ||||
| `; | `; | ||||
| } | } | ||||
| `; | `; | ||||
| export const InputFieldLabelLocation = styled(Label)` | |||||
| position: relative; | |||||
| bottom: -8px; | |||||
| margin: 10px 0; | |||||
| & label { | |||||
| font-size: 12px; | |||||
| font-weight: 600; | |||||
| line-height: 20px; | |||||
| color: #808080; | |||||
| cursor: auto; | |||||
| letter-spacing: 0.2px; | |||||
| } | |||||
| @media screen and (max-width: 600px) { | |||||
| bottom: -12px; | |||||
| margin: 5px 0 17px 0; | |||||
| & label { | |||||
| font-size: 9px; | |||||
| margin-top: 0; | |||||
| } | |||||
| } | |||||
| `; | |||||
| export const SaveButton = styled(PrimaryButton)` | export const SaveButton = styled(PrimaryButton)` | ||||
| font-size: 12px; | font-size: 12px; | ||||
| letter-spacing: 1.5px; | letter-spacing: 1.5px; |
| const getSuggestions = (value) => { | const getSuggestions = (value) => { | ||||
| const escapedValue = escapeRegexCharacters(value.trim()); | const escapedValue = escapeRegexCharacters(value.trim()); | ||||
| if (escapedValue === "") { | if (escapedValue === "") { | ||||
| return []; | return []; | ||||
| } | } | ||||
| const regex = new RegExp("^" + escapedValue, "i"); | const regex = new RegExp("^" + escapedValue, "i"); | ||||
| const suggestions = data.filter((dataItem) => regex.test(dataItem.name)); | const suggestions = data.filter((dataItem) => regex.test(dataItem.name)); | ||||
| if (suggestions.length === 0) { | if (suggestions.length === 0) { | ||||
| return [{ isAddNew: true }]; | return [{ isAddNew: true }]; | ||||
| } | } | ||||
| return suggestions; | return suggestions; | ||||
| }; | }; | ||||
| }; | }; | ||||
| return ( | return ( | ||||
| <AutoSuggestTextFieldContainer> | |||||
| <AutoSuggestTextFieldContainer editLocation={props.editLocation}> | |||||
| <Autosuggest | <Autosuggest | ||||
| suggestions={suggestions} | suggestions={suggestions} | ||||
| onSuggestionsFetchRequested={onSuggestionsFetchRequested} | onSuggestionsFetchRequested={onSuggestionsFetchRequested} | ||||
| value: PropTypes.string, | value: PropTypes.string, | ||||
| onChange: PropTypes.func, | onChange: PropTypes.func, | ||||
| data: PropTypes.array, | data: PropTypes.array, | ||||
| editLocation: PropTypes.bool, | |||||
| }; | }; | ||||
| export default AutoSuggestTextField; | export default AutoSuggestTextField; |
| export const AutoSuggestTextFieldContainer = styled(Box)` | export const AutoSuggestTextFieldContainer = styled(Box)` | ||||
| & .react-autosuggest__container { | & .react-autosuggest__container { | ||||
| width: 100%; | width: 100%; | ||||
| height: 48px; | |||||
| height: ${(props) => (props.editLocation ? "43px" : "48px")}; | |||||
| position: relative; | position: relative; | ||||
| z-index: 20; | z-index: 20; | ||||
| & input { | & input { | ||||
| width: 100%; | width: 100%; | ||||
| height: 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 rgba(0, 0, 0, 0.23); | ||||
| border: 2px solid ${selectedTheme.primaryPurple}; | border: 2px solid ${selectedTheme.primaryPurple}; | ||||
| } | } | ||||
| & input::placeholder { | & input::placeholder { | ||||
| color: rgba(0,0,0, 0.38); | |||||
| color: rgba(0, 0, 0, 0.38); | |||||
| } | } | ||||
| & div { | & div { | ||||
| color: ${selectedTheme.primaryBackgroundColor}; | color: ${selectedTheme.primaryBackgroundColor}; | ||||
| } | } | ||||
| } | } | ||||
| @media (max-width: 600px) { | |||||
| & .react-autosuggest__container { | |||||
| & input { | |||||
| font-size: 13px; | |||||
| } | |||||
| } | |||||
| } | |||||
| `; | `; |
| .required(i18n.t("editProfile.labelPIBRequired")) | .required(i18n.t("editProfile.labelPIBRequired")) | ||||
| .min(9, i18n.t("register.PIBnoOfCharacters")) | .min(9, i18n.t("register.PIBnoOfCharacters")) | ||||
| .max(9, i18n.t("register.PIBnoOfCharacters")), | .max(9, i18n.t("register.PIBnoOfCharacters")), | ||||
| firmLocation: Yup.string().required( | |||||
| i18n.t("editProfile.labelLocationRequired") | |||||
| ), | |||||
| firmLocation: Yup.string(), | |||||
| firmWebsite: Yup.string(), | firmWebsite: Yup.string(), | ||||
| firmApplink: Yup.string(), | firmApplink: Yup.string(), | ||||
| firmPhone: Yup.string() | firmPhone: Yup.string() | ||||
| .required(i18n.t("editProfile.labelPhoneRequired")) | |||||
| .min(6, i18n.t("editProfile.labelPhoneValid")) | .min(6, i18n.t("editProfile.labelPhoneValid")) | ||||
| .max(14, i18n.t("editProfile.labelPhoneValid")), | .max(14, i18n.t("editProfile.labelPhoneValid")), | ||||
| }); | }); |