From 6c0a09d6ddfc80cbd1a370a70b90192d01c1c42c Mon Sep 17 00:00:00 2001 From: Lvyshnevska Date: Sun, 3 Dec 2023 13:40:59 +0100 Subject: [PATCH 1/9] allow company and startup --- .../ProfilePage/FormComponents/GeneralInfo.js | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/FrontEnd/src/components/ProfilePage/FormComponents/GeneralInfo.js b/FrontEnd/src/components/ProfilePage/FormComponents/GeneralInfo.js index 62f1ab6c9..cca296283 100644 --- a/FrontEnd/src/components/ProfilePage/FormComponents/GeneralInfo.js +++ b/FrontEnd/src/components/ProfilePage/FormComponents/GeneralInfo.js @@ -49,6 +49,7 @@ const GeneralInfo = (props) => { const [profile, setProfile] = useState(props.profile); const [formStateErr, setFormStateErr] = useState(ERRORS); const [edrpouError, setEdrpouError] = useState(null); + const [companyTypeError, setCompanyTypeError] = useState(null); const { data: fetchedRegions, isLoading: isRegionLoading } = useSWR(`${process.env.REACT_APP_BASE_API_URL}/api/regions/`, fetcher); const { data: fetchedActivities, isLoading: isActivitiesLoading } = useSWR(`${process.env.REACT_APP_BASE_API_URL}/api/activities/`, fetcher); @@ -79,6 +80,9 @@ const GeneralInfo = (props) => { if (profile.edrpou && profile.edrpou.toString().length !== 8) { isValid = false; } + if (!profile.is_registered && !profile.is_startup) { + isValid = false; + } return isValid; }; @@ -109,16 +113,19 @@ const GeneralInfo = (props) => { } }; - const onChangeCheckbox = e => { - if (e.target.name === 'is_startup') { - setProfile((prevState) => { - return { ...prevState, [e.target.name]: true, 'is_registered': false }; - }); - } else if (e.target.name === 'is_registered') { - setProfile((prevState) => { - return { ...prevState, [e.target.name]: true, 'is_startup': false }; - }); - } + const onChangeCheckbox = (e) => { + const isAnyChecked = + (profile.is_registered && e.target.name === 'is_startup') || + (profile.is_startup && e.target.name === 'is_registered') || + e.target.checked; + if (!isAnyChecked) { + setCompanyTypeError('Оберіть тип компанії, яку Ви представляєте'); + } else { + setCompanyTypeError(null); + } + setProfile((prevState) => { + return { ...prevState, [e.target.name]: e.target.checked }; + }); }; const onUpdateTextAreaField = e => { @@ -294,6 +301,7 @@ const GeneralInfo = (props) => { nameStartup="is_startup" valueStartup={profile.is_startup} updateHandler={onChangeCheckbox} + error={companyTypeError} requredField={true} /> From 21ada0a76eb26db0daa00b0fe540a4fffb3c4200 Mon Sep 17 00:00:00 2001 From: Lvyshnevska Date: Sun, 3 Dec 2023 13:43:47 +0100 Subject: [PATCH 2/9] added error msg to checkbox field --- .../FormFields/CheckBoxField.js | 5 +++++ .../FormFields/CheckBoxField.module.css | 20 +++++++++++++++++-- .../FormFields/HalfFormField.module.css | 8 ++++---- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/FrontEnd/src/components/ProfilePage/FormComponents/FormFields/CheckBoxField.js b/FrontEnd/src/components/ProfilePage/FormComponents/FormFields/CheckBoxField.js index 7e5c05284..f5ed64c41 100644 --- a/FrontEnd/src/components/ProfilePage/FormComponents/FormFields/CheckBoxField.js +++ b/FrontEnd/src/components/ProfilePage/FormComponents/FormFields/CheckBoxField.js @@ -38,6 +38,11 @@ const CheckBoxField = (props) => { + {(props.requredField || props.error) && +
+ {props.error} +
+ } ); }; diff --git a/FrontEnd/src/components/ProfilePage/FormComponents/FormFields/CheckBoxField.module.css b/FrontEnd/src/components/ProfilePage/FormComponents/FormFields/CheckBoxField.module.css index 289ed3889..88a59b6d6 100644 --- a/FrontEnd/src/components/ProfilePage/FormComponents/FormFields/CheckBoxField.module.css +++ b/FrontEnd/src/components/ProfilePage/FormComponents/FormFields/CheckBoxField.module.css @@ -1,5 +1,6 @@ .representative { display: flex; + min-height: 102px; flex-direction: column; align-items: flex-start; gap: 8px; @@ -67,7 +68,22 @@ letter-spacing: -0.14px; } - .checkbox__input { +.checkbox__input { justify-content: start; accent-color: #1F9A7C; - } +} + +.error-message { + display: flex; + padding: 1px 0px; + align-items: flex-start; + gap: 10px; + align-self: stretch; + flex: 1 0 0; + color: var(--red-red-100, #F34444); + font-family: Roboto; + font-size: 14px; + font-style: normal; + font-weight: 400; + line-height: 22px; +} \ No newline at end of file diff --git a/FrontEnd/src/components/ProfilePage/FormComponents/FormFields/HalfFormField.module.css b/FrontEnd/src/components/ProfilePage/FormComponents/FormFields/HalfFormField.module.css index 3a23b7435..cebe5d462 100644 --- a/FrontEnd/src/components/ProfilePage/FormComponents/FormFields/HalfFormField.module.css +++ b/FrontEnd/src/components/ProfilePage/FormComponents/FormFields/HalfFormField.module.css @@ -70,7 +70,7 @@ font-weight: 400; line-height: 22px; letter-spacing: -0.01em; - text-align: left; + text-align: left; color: #00000040; } @@ -79,7 +79,7 @@ border: 1px solid #1f9a7c; background: #fff; outline: none; - } +} .error-message { display: flex; @@ -105,5 +105,5 @@ text-align: left; color: #00000040; background: linear-gradient(0deg, #F5F5F5, #F5F5F5), - linear-gradient(0deg, #D9D9D9, #D9D9D9); -} + linear-gradient(0deg, #D9D9D9, #D9D9D9); +} \ No newline at end of file From d6eda7543d3edbc47696034fd389b71d26c9fd27 Mon Sep 17 00:00:00 2001 From: Lvyshnevska Date: Sun, 3 Dec 2023 13:44:49 +0100 Subject: [PATCH 3/9] clicked button style --- .../UI/ProfileFormButton/ProfileFormButton.module.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/FrontEnd/src/components/ProfilePage/UI/ProfileFormButton/ProfileFormButton.module.css b/FrontEnd/src/components/ProfilePage/UI/ProfileFormButton/ProfileFormButton.module.css index 470bbf070..23a756e28 100644 --- a/FrontEnd/src/components/ProfilePage/UI/ProfileFormButton/ProfileFormButton.module.css +++ b/FrontEnd/src/components/ProfilePage/UI/ProfileFormButton/ProfileFormButton.module.css @@ -32,4 +32,8 @@ text-align: center; cursor: pointer; margin-left: 430px; +} + +.sign-up__button:active { + transform: translateY(2px); } \ No newline at end of file From af83a601c6ad6fe73736c153db573652fc095dce Mon Sep 17 00:00:00 2001 From: Lvyshnevska Date: Sun, 3 Dec 2023 13:48:02 +0100 Subject: [PATCH 4/9] disabled menu items and tooltips --- .../ProfilePageComponents/ProfileContent.js | 40 +++++++++++++++++-- .../ProfileContent.module.css | 17 ++++++-- 2 files changed, 51 insertions(+), 6 deletions(-) diff --git a/FrontEnd/src/components/ProfilePage/ProfilePageComponents/ProfileContent.js b/FrontEnd/src/components/ProfilePage/ProfilePageComponents/ProfileContent.js index 6af3a8eac..f8eb86e5d 100644 --- a/FrontEnd/src/components/ProfilePage/ProfilePageComponents/ProfileContent.js +++ b/FrontEnd/src/components/ProfilePage/ProfilePageComponents/ProfileContent.js @@ -1,3 +1,4 @@ +import { Tooltip } from 'antd'; import css from './ProfileContent.module.css'; import { Link, NavLink, Route, Routes } from 'react-router-dom'; import AdditionalInfo from '../FormComponents/AdditionalInfo'; @@ -26,14 +27,17 @@ const INFOLINKS = [ { title: 'Інформація про товари/ послуги', link: '/products-service-info', + tooltipText: 'Цей розділ доступний, коли обрано опцію "Зареєстрована компанія" у розділі Загальна інформація' }, { title: 'Додаткова інформація', link: '/additional-info', + tooltipText: 'Цей розділ доступний, коли обрано опцію "Зареєстрована компанія" у розділі Загальна інформація' }, { title: 'Стартап', link: '/startup', + tooltipText: 'Цей розділ доступний, коли обрано опцію "Стартап проект" у розділі Загальна інформація' }, ]; @@ -52,13 +56,43 @@ const ProfileContent = (props) => {
- {INFOLINKS.map((element) => ( + {INFOLINKS.map((element) => { + const isLinkEnabled = + (props.profile.is_registered && props.profile.is_startup) || + (props.profile.is_registered && element.title !== 'Стартап') || + (props.profile.is_startup && element.title !== 'Інформація про товари/ послуги' && element.title !== 'Додаткова інформація'); + return isLinkEnabled ? ( (`${css['infolink']} ${isActive && css['infolink__active']}`)} to={`/profile${element.link}`} key={element.title} - >{element.title} - ))} + > + {element.title} + + ) : ( + + + {element.title} + + + ); + })}
Date: Mon, 4 Dec 2023 11:32:06 +0100 Subject: [PATCH 5/9] prop types, key to list added --- .../ProfilePage/FormComponents/GeneralInfo.js | 29 ++++++++++++- .../ProfilePageComponents/ProfileContent.js | 42 ++++++++++++++++++- 2 files changed, 69 insertions(+), 2 deletions(-) diff --git a/FrontEnd/src/components/ProfilePage/FormComponents/GeneralInfo.js b/FrontEnd/src/components/ProfilePage/FormComponents/GeneralInfo.js index cca296283..d8ef65043 100644 --- a/FrontEnd/src/components/ProfilePage/FormComponents/GeneralInfo.js +++ b/FrontEnd/src/components/ProfilePage/FormComponents/GeneralInfo.js @@ -1,7 +1,8 @@ -import css from './FormComponents.module.css'; +import { PropTypes } from 'prop-types'; import { useState, useEffect } from 'react'; import useSWR from 'swr'; import { useUser, useProfile } from '../../../hooks/'; +import css from './FormComponents.module.css'; import CheckBoxField from './FormFields/CheckBoxField'; import FullField from './FormFields/FullField'; @@ -312,3 +313,29 @@ const GeneralInfo = (props) => { }; export default GeneralInfo; + +GeneralInfo.propTypes = { + profile: PropTypes.shape({ + name: PropTypes.string.isRequired, + official_name: PropTypes.string, + edrpou: PropTypes.number, + region: PropTypes.string, + common_info: PropTypes.string, + is_registered: PropTypes.bool, + is_startup: PropTypes.bool, + categories: PropTypes.arrayOf( + PropTypes.shape({ + id: PropTypes.number, + name: PropTypes.string, + }) + ), + activities: PropTypes.arrayOf( + PropTypes.shape({ + id: PropTypes.number, + name: PropTypes.string, + }) + ), + }).isRequired, + currentFormNameHandler: PropTypes.func, + curForm: PropTypes.string, + }; diff --git a/FrontEnd/src/components/ProfilePage/ProfilePageComponents/ProfileContent.js b/FrontEnd/src/components/ProfilePage/ProfilePageComponents/ProfileContent.js index f8eb86e5d..deaedcc9f 100644 --- a/FrontEnd/src/components/ProfilePage/ProfilePageComponents/ProfileContent.js +++ b/FrontEnd/src/components/ProfilePage/ProfilePageComponents/ProfileContent.js @@ -1,5 +1,5 @@ import { Tooltip } from 'antd'; -import css from './ProfileContent.module.css'; +import { PropTypes } from 'prop-types'; import { Link, NavLink, Route, Routes } from 'react-router-dom'; import AdditionalInfo from '../FormComponents/AdditionalInfo'; import ContactsInfo from '../FormComponents/ContactsInfo'; @@ -9,6 +9,7 @@ import ProductServiceInfo from '../FormComponents/ProductServiceInfo'; import StartupInfo from '../FormComponents/StartupInfo'; import UserInfo from '../FormComponents/UserInfo'; import ProfileFormButton from '../UI/ProfileFormButton/ProfileFormButton'; +import css from './ProfileContent.module.css'; const INFOLINKS = [ @@ -71,6 +72,7 @@ const ProfileContent = (props) => { ) : ( { }; export default ProfileContent; + +ProfileContent.propTypes = { + user: PropTypes.shape({ + name: PropTypes.string.isRequired, + surname: PropTypes.string.isRequired, + profile_id: PropTypes.number.isRequired, + }).isRequired, + profile: PropTypes.shape({ + name: PropTypes.string.isRequired, + official_name: PropTypes.string, + edrpou: PropTypes.number, + region: PropTypes.string, + common_info: PropTypes.string, + phone: PropTypes.string, + address: PropTypes.string, + phounded: PropTypes.number, + person_position: PropTypes.string, + startup_idea: PropTypes.string, + product_info: PropTypes.string, + service_info: PropTypes.string, + is_registered: PropTypes.bool, + is_startup: PropTypes.bool, + categories: PropTypes.arrayOf( + PropTypes.shape({ + id: PropTypes.number, + name: PropTypes.string, + }) + ), + activities: PropTypes.arrayOf( + PropTypes.shape({ + id: PropTypes.number, + name: PropTypes.string, + }) + ), + }).isRequired, + currentFormNameHandler: PropTypes.func, + formName: PropTypes.string, + }; \ No newline at end of file From c8df461c7348663717217a80d87ffcd2d89cd231 Mon Sep 17 00:00:00 2001 From: Lvyshnevska Date: Mon, 4 Dec 2023 12:23:09 +0100 Subject: [PATCH 6/9] prop types in checkbox component --- .../FormComponents/FormFields/CheckBoxField.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/FrontEnd/src/components/ProfilePage/FormComponents/FormFields/CheckBoxField.js b/FrontEnd/src/components/ProfilePage/FormComponents/FormFields/CheckBoxField.js index f5ed64c41..c9f41ca9d 100644 --- a/FrontEnd/src/components/ProfilePage/FormComponents/FormFields/CheckBoxField.js +++ b/FrontEnd/src/components/ProfilePage/FormComponents/FormFields/CheckBoxField.js @@ -1,3 +1,4 @@ +import { PropTypes } from 'prop-types'; import css from './CheckBoxField.module.css'; const CheckBoxField = (props) => { @@ -47,3 +48,13 @@ const CheckBoxField = (props) => { }; export default CheckBoxField; + +CheckBoxField.propTypes = { + requredField: PropTypes.bool.isRequired, + nameRegister: PropTypes.string.isRequired, + valueRegister: PropTypes.bool.isRequired, + nameStartup: PropTypes.string.isRequired, + valueStartup: PropTypes.bool.isRequired, + updateHandler: PropTypes.func.isRequired, + error:PropTypes.string, + }; \ No newline at end of file From 3add10ececc2088494e1bed7bda7c8aef6d58340 Mon Sep 17 00:00:00 2001 From: Lvyshnevska Date: Mon, 4 Dec 2023 12:24:37 +0100 Subject: [PATCH 7/9] correct prop types --- .../ProfilePage/FormComponents/GeneralInfo.js | 14 ++------------ .../ProfilePageComponents/ProfileContent.js | 14 ++------------ 2 files changed, 4 insertions(+), 24 deletions(-) diff --git a/FrontEnd/src/components/ProfilePage/FormComponents/GeneralInfo.js b/FrontEnd/src/components/ProfilePage/FormComponents/GeneralInfo.js index d8ef65043..0dc19188d 100644 --- a/FrontEnd/src/components/ProfilePage/FormComponents/GeneralInfo.js +++ b/FrontEnd/src/components/ProfilePage/FormComponents/GeneralInfo.js @@ -323,18 +323,8 @@ GeneralInfo.propTypes = { common_info: PropTypes.string, is_registered: PropTypes.bool, is_startup: PropTypes.bool, - categories: PropTypes.arrayOf( - PropTypes.shape({ - id: PropTypes.number, - name: PropTypes.string, - }) - ), - activities: PropTypes.arrayOf( - PropTypes.shape({ - id: PropTypes.number, - name: PropTypes.string, - }) - ), + categories: PropTypes.array, + activities: PropTypes.array, }).isRequired, currentFormNameHandler: PropTypes.func, curForm: PropTypes.string, diff --git a/FrontEnd/src/components/ProfilePage/ProfilePageComponents/ProfileContent.js b/FrontEnd/src/components/ProfilePage/ProfilePageComponents/ProfileContent.js index deaedcc9f..e7bd65a40 100644 --- a/FrontEnd/src/components/ProfilePage/ProfilePageComponents/ProfileContent.js +++ b/FrontEnd/src/components/ProfilePage/ProfilePageComponents/ProfileContent.js @@ -175,18 +175,8 @@ ProfileContent.propTypes = { service_info: PropTypes.string, is_registered: PropTypes.bool, is_startup: PropTypes.bool, - categories: PropTypes.arrayOf( - PropTypes.shape({ - id: PropTypes.number, - name: PropTypes.string, - }) - ), - activities: PropTypes.arrayOf( - PropTypes.shape({ - id: PropTypes.number, - name: PropTypes.string, - }) - ), + categories: PropTypes.array, + activities: PropTypes.array, }).isRequired, currentFormNameHandler: PropTypes.func, formName: PropTypes.string, From 6359c77a479f8a50431bf5cf3a5221d0c855a32f Mon Sep 17 00:00:00 2001 From: Lvyshnevska Date: Thu, 7 Dec 2023 22:38:57 +0100 Subject: [PATCH 8/9] span element for error message --- .../ProfilePage/FormComponents/FormFields/CheckBoxField.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/FrontEnd/src/components/ProfilePage/FormComponents/FormFields/CheckBoxField.js b/FrontEnd/src/components/ProfilePage/FormComponents/FormFields/CheckBoxField.js index c9f41ca9d..1ae7b884b 100644 --- a/FrontEnd/src/components/ProfilePage/FormComponents/FormFields/CheckBoxField.js +++ b/FrontEnd/src/components/ProfilePage/FormComponents/FormFields/CheckBoxField.js @@ -40,9 +40,9 @@ const CheckBoxField = (props) => {
{(props.requredField || props.error) && -
+ {props.error} -
+ }
); }; From 47b38e1bb616826efde6a4c5af326441cc3091b3 Mon Sep 17 00:00:00 2001 From: Lvyshnevska Date: Fri, 8 Dec 2023 10:17:34 +0100 Subject: [PATCH 9/9] tooltip custom styles adjusted --- .../ProfilePageComponents/ProfileContent.js | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/FrontEnd/src/components/ProfilePage/ProfilePageComponents/ProfileContent.js b/FrontEnd/src/components/ProfilePage/ProfilePageComponents/ProfileContent.js index e7bd65a40..c57d4d13d 100644 --- a/FrontEnd/src/components/ProfilePage/ProfilePageComponents/ProfileContent.js +++ b/FrontEnd/src/components/ProfilePage/ProfilePageComponents/ProfileContent.js @@ -53,6 +53,17 @@ const FORM_NAMES = [ ]; const ProfileContent = (props) => { + + const tooltipInnerContentStyles = { + display: 'flex', + borderRadius: '2px', + background: 'var(--main-grey-90, #25292C)', + color: 'var(--main-white, #FFF)', + fontFeatureSettings: 'calt', + fontFamily: 'Inter', + letterSpacing: '-0.14px', + }; + return (
@@ -75,15 +86,7 @@ const ProfileContent = (props) => { key={element.title} placement="bottomLeft" title={element.tooltipText} - overlayInnerStyle={{ - display: 'flex', - borderRadius: '2px', - background: 'var(--main-grey-90, #25292C)', - color: 'var(--main-white, #FFF)', - fontFeatureSettings: 'calt', - fontFamily: 'Inter', - letterSpacing: '-0.14px', - }} + overlayInnerStyle={tooltipInnerContentStyles} >