diff --git a/backend/api/models/PartnerGroupMessage.py b/backend/api/models/PartnerGroupMessage.py new file mode 100644 index 00000000..4ee8c7fc --- /dev/null +++ b/backend/api/models/PartnerGroupMessage.py @@ -0,0 +1,16 @@ +from api.core import Mixin +from .base import db +from flask_mongoengine import Document +from mongoengine import * +from api.models import Availability + + +class PartnerGroupMessage(Document, Mixin): + body = StringField(required=True) + message_read = BooleanField(required=True) + sender_id = ObjectIdField(required=True) + created_at = DateTimeField(required=True) + parent_message_id = StringField(required=False) + + def __repr__(self): + return f"" diff --git a/backend/api/models/__init__.py b/backend/api/models/__init__.py index fb775cce..68721530 100644 --- a/backend/api/models/__init__.py +++ b/backend/api/models/__init__.py @@ -18,6 +18,7 @@ from .Message import Message from .DirectMessage import DirectMessage from .GroupMessage import GroupMessage +from .PartnerGroupMessage import PartnerGroupMessage from .Admin import Admin from .Training import Training from .Event import Event @@ -64,6 +65,8 @@ "Support", "SignOrigin", "SignedDocs", + "GroupMessage", + "PartnerGroupMessage", ] # You must import all of the new Models you create to this page diff --git a/backend/api/utils/constants.py b/backend/api/utils/constants.py index d30bcba2..04bfbd63 100644 --- a/backend/api/utils/constants.py +++ b/backend/api/utils/constants.py @@ -180,3 +180,6 @@ def __eq__(self, other): } TRANSLATION_COST_PER_PAGE = 0.08 + +N50_ID_DEV = "675985b41684c4310ac00e4c" +N50_ID_PROD = "" diff --git a/backend/api/views/apply.py b/backend/api/views/apply.py index 327aa9d9..0fde3685 100644 --- a/backend/api/views/apply.py +++ b/backend/api/views/apply.py @@ -26,6 +26,8 @@ PROFILE_COMPLETED, TRANSLATIONS, ALERT_TO_ADMINS, + N50_ID_DEV, + N50_ID_PROD, ) from api.utils.request_utils import ( send_email, @@ -280,10 +282,17 @@ def change_state_to_build_profile(email, role): application["application_state"] = NEW_APPLICATION_STATUS["BUILDPROFILE"] application.save() target_url = "" + n50_url = "" + if ( + application["partner"] == N50_ID_DEV + or application["partner"] == N50_ID_PROD + ): + n50_url = "n50/" if "front_url" in request.args: front_url = request.args["front_url"] target_url = ( front_url + + n50_url + "build-profile?role=" + str(role) + "&email=" @@ -419,8 +428,12 @@ def edit_application(id, role): logger.info(msg) if application.application_state == NEW_APPLICATION_STATUS["APPROVED"]: front_url = data.get("front_url", "") + n50_url = "" + if application.partner == N50_ID_DEV or application.partner == N50_ID_PROD: + n50_url = "n50/" target_url = ( front_url + + n50_url + "application-training?role=" + str(role) + "&email=" diff --git a/backend/api/views/main.py b/backend/api/views/main.py index 1ce2679e..eba9fd31 100644 --- a/backend/api/views/main.py +++ b/backend/api/views/main.py @@ -660,7 +660,9 @@ def edit_mentor(id): def uploadImage(id): image = request.files["image"] try: - account_type = int(request.form["account_type"]) + account_type = request.form["account_type"] + if isinstance(account_type, str): + account_type = int(account_type) except: msg = "Level param doesn't exist or isn't an int" return create_response(status=422, message=msg) @@ -672,6 +674,10 @@ def uploadImage(id): if token is None: if account_type == Account.PARTNER: account = PartnerProfile.objects.get(id=id) + elif account_type == Account.MENTEE: + account = MenteeProfile.objects.get(id=id) + elif account_type == Account.MENTOR: + account = MentorProfile.objects.get(id=id) else: msg = "Level param doesn't match existing account types" return create_response(status=422, message=msg) @@ -687,7 +693,6 @@ def uploadImage(id): and int(login_user_role) != Account.HUB ): return response - if account_type == Account.MENTEE: account = MenteeProfile.objects.get(id=id) elif account_type == Account.MENTOR: @@ -699,6 +704,7 @@ def uploadImage(id): elif account_type == Account.ADMIN: account = Admin.objects.get(id=id) + else: msg = "Level param doesn't match existing account types" return create_response(status=422, message=msg) diff --git a/backend/api/views/messages.py b/backend/api/views/messages.py index c5487721..4dd6b775 100644 --- a/backend/api/views/messages.py +++ b/backend/api/views/messages.py @@ -5,6 +5,7 @@ Message, DirectMessage, GroupMessage, + PartnerGroupMessage, PartnerProfile, Availability, Specializations, @@ -379,7 +380,13 @@ def get_sidebar_mentors(pageNumber): @all_users def get_group_messages(): try: - messages = GroupMessage.objects(Q(hub_user_id=request.args.get("hub_user_id"))) + hub_user_id = request.args.get("hub_user_id", None) + if hub_user_id is not None and hub_user_id != "": + messages = GroupMessage.objects( + Q(hub_user_id=request.args.get("hub_user_id")) + ) + else: + messages = PartnerGroupMessage.objects() except: msg = "Invalid parameters provided" logger.info(msg) @@ -413,22 +420,37 @@ def get_direct_messages(): @socketio.on("sendGroup") def chatGroup(msg, methods=["POST"]): try: - message = GroupMessage( - body=msg["body"], - message_read=msg["message_read"], - sender_id=msg["sender_id"], - hub_user_id=msg["hub_user_id"], - parent_message_id=msg["parent_message_id"], - created_at=msg["time"], - ) - logger.info(msg["hub_user_id"]) - socketio.emit(msg["hub_user_id"], json.loads(message.to_json())) + if "hub_user_id" in msg and msg["hub_user_id"] is not None: + message = GroupMessage( + body=msg["body"], + message_read=msg["message_read"], + sender_id=msg["sender_id"], + hub_user_id=msg["hub_user_id"], + parent_message_id=msg["parent_message_id"], + created_at=msg["time"], + ) + logger.info(msg["hub_user_id"]) + + else: + message = PartnerGroupMessage( + body=msg["body"], + message_read=msg["message_read"], + sender_id=msg["sender_id"], + parent_message_id=msg["parent_message_id"], + created_at=msg["time"], + ) + logger.info(msg["sender_id"]) + except Exception as e: logger.info(e) return create_response(status=500, message="Failed to send message") try: message.save() + if "hub_user_id" in msg and msg["hub_user_id"] is not None: + socketio.emit(msg["hub_user_id"], json.loads(message.to_json())) + else: + socketio.emit("group-partner", json.loads(message.to_json())) msg = "successfully sent message" except: msg = "Error in meessage" diff --git a/frontend/src/app/App.js b/frontend/src/app/App.js index 9b3352b7..981e87bf 100644 --- a/frontend/src/app/App.js +++ b/frontend/src/app/App.js @@ -63,7 +63,7 @@ function App() { const path = window.location.href; const [role, setRole] = useState(getRole()); const [allHubData, setAllHubData] = useState({}); - + const [n50Flag, setN50flag] = useState(false); // TODO: Remove this when we have a proper solution for this // some kind of cached method of updating on login status change // useEffect(() => { @@ -91,12 +91,26 @@ function App() { useEffect(() => { setStartPathTime(new Date().getTime()); + setTimeout(() => { + let n50_flag = localStorage.getItem("n50_user"); + if (n50_flag) { + setN50flag(true); + } else { + setN50flag(false); + } + }, 500); if (path.indexOf("/event") > 0) { if (!role) { let direct_path = "event" + path.split("/event")[1]; localStorage.setItem("direct_path", direct_path); } } + if (path.indexOf("/new_training") > 0) { + if (!role) { + let direct_path = "new_training" + path.split("/new_training")[1]; + localStorage.setItem("direct_path", direct_path); + } + } }, [path]); useEffect(() => { @@ -128,18 +142,33 @@ function App() { + + + + + + + + + + + + + + + @@ -152,15 +181,27 @@ function App() { + + + + + + + + + + + + {Object.keys(allHubData).map((hub_url) => { return ( <> @@ -598,6 +639,9 @@ function App() { + + + @@ -608,6 +652,7 @@ function App() { {role == ACCOUNT_TYPE.HUB && } + {n50Flag && } diff --git a/frontend/src/components/LoginForm.js b/frontend/src/components/LoginForm.js index 4ff6ac23..856fe968 100644 --- a/frontend/src/components/LoginForm.js +++ b/frontend/src/components/LoginForm.js @@ -11,7 +11,7 @@ import { ACCOUNT_TYPE, ACCOUNT_TYPE_LABELS, REDIRECTS } from "utils/consts"; import fireauth from "utils/fireauth"; import { fetchUser } from "features/userSlice"; -function LoginForm({ role, defaultEmail, location }) { +function LoginForm({ role, defaultEmail, n50_flag, location }) { if (!defaultEmail) { if (location && location.state && location.state.email) { defaultEmail = location.state.email; @@ -124,6 +124,9 @@ function LoginForm({ role, defaultEmail, location }) { }) ); let direct_path = localStorage.getItem("direct_path"); + if (n50_flag) { + localStorage.setItem("n50_user", true); + } if (direct_path) { setTimeout(() => { history.push(direct_path); diff --git a/frontend/src/components/NavigationHeader.js b/frontend/src/components/NavigationHeader.js index 57f3b9c2..863dc3dd 100644 --- a/frontend/src/components/NavigationHeader.js +++ b/frontend/src/components/NavigationHeader.js @@ -39,9 +39,14 @@ function NavigationHeader() { const logoutUser = () => { var login_path = getLoginPath(); + var n50_flag = localStorage.getItem("n50_user"); + if (n50_flag) { + login_path = "/n50"; + } logout().then(() => { resetRoleState(); dispatch(resetUser()); + localStorage.removeItem("n50_user"); if (login_path && login_path != "") { // window.location.href = login_path; history.push(login_path); diff --git a/frontend/src/components/NavigationSider.js b/frontend/src/components/NavigationSider.js index 176081af..0ce16499 100644 --- a/frontend/src/components/NavigationSider.js +++ b/frontend/src/components/NavigationSider.js @@ -8,6 +8,7 @@ import useSidebars from "utils/hooks/useSidebars"; import { collapse } from "features/userSlice"; // import { ReactComponent as Logo } from "resources/mentee.svg"; import BigLogoImage from "resources/Mentee_logo_letter.png"; +import N50SmallLogoImage from "resources/N50 Logo_small.png"; // import { ReactComponent as SmallLogo } from "resources/menteeSmall.svg"; import SmallLogoImage from "resources/Mentee_logo_small.png"; import "components/css/Navigation.scss"; @@ -27,6 +28,7 @@ function NavigationSider() { const sidebarItems = useSidebars(role, user, t); const isMobile = useMediaQuery({ query: `(max-width: 761px)` }); const currentPage = [history.location.pathname.split("/")[1]]; + const n50_flag = localStorage.getItem("n50_user"); const onClick = ({ key }) => { isMobile && dispatch(collapse()); @@ -83,7 +85,7 @@ function NavigationSider() { // alt="MENTEE" // /> {""} {""} { const [successfulSubmit, setSuccessfulSubmit] = useState(undefined); const role = location.state?.role; const email = location.state?.email; + var n50_flag = false; + if (location && location.pathname.includes("n50")) { + n50_flag = true; + } const onSubmitSuccess = () => { setSuccessfulSubmit(true); @@ -57,6 +61,7 @@ const ApplicationForm = ({ location, history }) => { case ACCOUNT_TYPE.MENTOR: return ( { return ( { async function getUserData() { @@ -117,10 +121,10 @@ function BuildProfile({ location, history, hub_user }) { messageApi.info(t("commonProfile.accountCreated")); let path = ""; if (role === ACCOUNT_TYPE.MENTOR) { - path = "/mentor"; + path = n50_flag ? "/n50/mentor" : "/mentor"; } if (role === ACCOUNT_TYPE.MENTEE) { - path = "/mentee"; + path = n50_flag ? "/n50/mentee" : "/mentee"; } if (role === ACCOUNT_TYPE.PARTNER) { path = "/partner"; @@ -160,6 +164,7 @@ function BuildProfile({ location, history, hub_user }) { onSubmit={onSubmit} applicationData={applicationData} loading={loading} + n50_flag={n50_flag} /> ); case ACCOUNT_TYPE.MENTEE: @@ -170,6 +175,7 @@ function BuildProfile({ location, history, hub_user }) { onSubmit={onSubmit} applicationData={applicationData} loading={loading} + n50_flag={n50_flag} /> ); case ACCOUNT_TYPE.PARTNER: diff --git a/frontend/src/components/pages/GroupMessages.js b/frontend/src/components/pages/GroupMessages.js index 3f5347ed..9dff7159 100644 --- a/frontend/src/components/pages/GroupMessages.js +++ b/frontend/src/components/pages/GroupMessages.js @@ -38,59 +38,95 @@ function GroupMessages(props) { } const messageListener = (data) => { - if ( - data?.hub_user_id?.$oid === activeMessageId && - data?.sender_id?.$oid !== profileId - ) { - setMessages((prevMessages) => [...prevMessages, data]); - dispatch( - updateNotificationsCount({ - recipient: profileId, - sender: data.sender_id.$oid, - }) - ); + if (hub_user_id) { + if ( + data?.hub_user_id?.$oid === activeMessageId && + data?.sender_id?.$oid !== profileId + ) { + setMessages((prevMessages) => [...prevMessages, data]); + dispatch( + updateNotificationsCount({ + recipient: profileId, + sender: data.sender_id.$oid, + }) + ); + } + } else { + if (data?.sender_id?.$oid !== profileId) { + setMessages((prevMessages) => [...prevMessages, data]); + dispatch( + updateNotificationsCount({ + recipient: profileId, + sender: data.sender_id.$oid, + }) + ); + } } }; useEffect(() => { async function getParticiants(hub_user_id) { var temp = []; - const Partner_data = await fetchPartners(undefined, hub_user_id); + let Partner_data = []; + if (hub_user_id) { + Partner_data = await fetchPartners(undefined, hub_user_id); + } else { + Partner_data = await fetchPartners(); + } + if (Partner_data) { temp = Partner_data; } - const hub_user = await fetchAccountById(hub_user_id, ACCOUNT_TYPE.HUB); - if (hub_user) { - temp.push(hub_user); + if (hub_user_id) { + const hub_user = await fetchAccountById(hub_user_id, ACCOUNT_TYPE.HUB); + if (hub_user) { + temp.push(hub_user); + } } setParticiants(temp); } - - if (hub_user_id) { - getParticiants(hub_user_id); - } + getParticiants(hub_user_id); }, [hub_user_id]); useEffect(() => { - if (socket && hub_user_id) { - socket.on(hub_user_id, messageListener); - return () => { - socket.off(hub_user_id, messageListener); - }; + if (socket) { + if (hub_user_id) { + socket.on(hub_user_id, messageListener); + return () => { + socket.off(hub_user_id, messageListener); + }; + } else { + socket.on("group-partner", messageListener); + return () => { + socket.off("group-partner", messageListener); + }; + } } - }, [socket, hub_user_id, activeMessageId]); + }, [socket, hub_user_id, profileId, activeMessageId]); useEffect(() => { dispatch( - setActiveMessageId(props.match ? props.match.params.hub_user_id : null) + setActiveMessageId( + props.match + ? props.match.params.hub_user_id + ? props.match.params.hub_user_id + : props.match.params.receiverId + : null + ) ); }); useEffect(() => { async function getData(hub_user_id) { dispatch( - setActiveMessageId(props.match ? props.match.params.hub_user_id : null) + setActiveMessageId( + props.match + ? props.match.params.hub_user_id + ? props.match.params.hub_user_id + : props.match.params.receiverId + : null + ) ); if (profileId) { setLoading(true); diff --git a/frontend/src/components/pages/Home.js b/frontend/src/components/pages/Home.js index 54cad299..0a116146 100644 --- a/frontend/src/components/pages/Home.js +++ b/frontend/src/components/pages/Home.js @@ -17,7 +17,7 @@ const SelectCardsStyle = css` } `; -function Home() { +function Home({ location }) { const { t } = useTranslation(); const history = useHistory(); @@ -29,18 +29,28 @@ function Home() { title={t("homepage.existingAccountTitle")} description={t("homepage.existingAccountDesc")} onClick={() => { - history.push("/login"); + if (location && location.pathname.includes("n50")) { + history.push("/n50/login"); + } else { + history.push("/login"); + } }} /> } title={t("homepage.newAccountTitle")} description={t("homepage.newAccountDesc")} - onClick={() => - history.push({ - pathname: "/apply", - }) - } + onClick={() => { + if (location && location.pathname.includes("n50")) { + history.push({ + pathname: "/n50/apply", + }); + } else { + history.push({ + pathname: "/apply", + }); + } + }} /> diff --git a/frontend/src/components/pages/HomeLayout.js b/frontend/src/components/pages/HomeLayout.js index 57a3a666..4032e630 100644 --- a/frontend/src/components/pages/HomeLayout.js +++ b/frontend/src/components/pages/HomeLayout.js @@ -5,6 +5,7 @@ import { css } from "@emotion/css"; import LanguageDropdown from "components/LanguageDropdown"; // import { ReactComponent as Logo } from "resources/mentee.svg"; import BigLogoImage from "resources/Mentee_logo_letter.png"; +import N50Logo from "resources/N50_logo.png"; // import { ReactComponent as SmallLogo } from "resources/menteeSmall.svg"; import SmallLogoImage from "resources/Mentee_logo_small.png"; import { useMediaQuery } from "react-responsive"; @@ -37,6 +38,21 @@ function HomeLayout({ children, ignoreHomeLayout, allHubData, location }) { "/application-training", "/build-profile", "/digital-sign", + "/n50/application-form", + "/n50/application-training", + "/n50/build-profile", + ]; + + const N50Path = [ + "/n50", + "/n50/login", + "/n50/mentor/login", + "/n50/mentee/login", + "/n50/partner/login", + "/n50/apply", + "/n50/application-form", + "/n50/application-training", + "/n50/build-profile", ]; const homeLayoutPaths = [ @@ -112,18 +128,31 @@ function HomeLayout({ children, ignoreHomeLayout, allHubData, location }) { `} onClick={() => history.push("/")} /> */} - {""} history.push("/")} - /> + {(isTablet && N50Path.includes(location.pathname)) ? ( + {""} + ) : ( + {""} history.push("/")} + /> + )} )} + {N50Path.includes(location.pathname) && ( + <> +
+ {""} +
+
+
+
+ {t("common.powered_by")} +
+
+ {/* history.push("/")} + /> */} + {""} history.push("/")} + /> +
+
+
+ + )} )} diff --git a/frontend/src/components/pages/Login.js b/frontend/src/components/pages/Login.js index 070d3534..d6fb6d5c 100644 --- a/frontend/src/components/pages/Login.js +++ b/frontend/src/components/pages/Login.js @@ -25,20 +25,36 @@ function Login({ location }) { const query = useQuery(); let cur_role = location?.state?.role ?? query.get("role"); let cur_current = cur_role ? StepNumeration.login : StepNumeration.role; + var n50_flag = false; + if (location && location.pathname.includes("n50")) { + n50_flag = true; + } if (location && location.pathname) { switch (location.pathname) { case "/mentor/login": cur_role = ACCOUNT_TYPE.MENTOR; cur_current = StepNumeration.login; break; + case "/n50/mentor/login": + cur_role = ACCOUNT_TYPE.MENTOR; + cur_current = StepNumeration.login; + break; case "/mentee/login": cur_role = ACCOUNT_TYPE.MENTEE; cur_current = StepNumeration.login; break; + case "/n50/mentee/login": + cur_role = ACCOUNT_TYPE.MENTEE; + cur_current = StepNumeration.login; + break; case "/partner/login": cur_role = ACCOUNT_TYPE.PARTNER; cur_current = StepNumeration.login; break; + case "/n50/partner/login": + cur_role = ACCOUNT_TYPE.PARTNER; + cur_current = StepNumeration.login; + break; case "/readonly/login": cur_role = ACCOUNT_TYPE.GUEST; cur_current = StepNumeration.login; @@ -68,13 +84,25 @@ function Login({ location }) { // setCurrent(StepNumeration.login); switch (role) { case ACCOUNT_TYPE.MENTOR: - history.push("/mentor/login"); + if (n50_flag) { + history.push("/n50/mentor/login"); + } else { + history.push("/mentor/login"); + } break; case ACCOUNT_TYPE.MENTEE: - history.push("/mentee/login"); + if (n50_flag) { + history.push("/n50/mentee/login"); + } else { + history.push("/mentee/login"); + } break; case ACCOUNT_TYPE.PARTNER: - history.push("/partner/login"); + if (n50_flag) { + history.push("/n50/partner/login"); + } else { + history.push("/partner/login"); + } break; case ACCOUNT_TYPE.GUEST: history.push("/readonly/login"); @@ -96,7 +124,11 @@ function Login({ location }) { } else if (newStep !== StepNumeration.login) { setCurrent(newStep); setRole(null); - history.push("/login"); + if (n50_flag) { + history.push("/n50/login"); + } else { + history.push("/login"); + } } }; @@ -132,7 +164,9 @@ function Login({ location }) { { title: "Login", key: "login", - content: , + content: ( + + ), }, ]; diff --git a/frontend/src/components/pages/MenteeApplication.js b/frontend/src/components/pages/MenteeApplication.js index 8bf6a43a..7f1dfdf4 100644 --- a/frontend/src/components/pages/MenteeApplication.js +++ b/frontend/src/components/pages/MenteeApplication.js @@ -4,9 +4,16 @@ import { Form, Input, Radio, Typography, Select, Button } from "antd"; import { useTranslation } from "react-i18next"; import { createApplication, fetchPartners, getAllcountries } from "utils/api"; import "components/css/MentorApplicationPage.scss"; +import { N50_ID } from "utils/consts"; const { Paragraph } = Typography; -function MenteeApplication({ email, role, onSubmitSuccess, onSubmitFailure }) { +function MenteeApplication({ + email, + role, + n50_flag, + onSubmitSuccess, + onSubmitFailure, +}) { const { t } = useTranslation(); const options = useSelector((state) => state.options); const [loading, setLoading] = useState(); @@ -17,16 +24,27 @@ function MenteeApplication({ email, role, onSubmitSuccess, onSubmitFailure }) { const partenr_data = await fetchPartners(undefined, null); var temp_partner_options = []; partenr_data.map((item) => { - temp_partner_options.push({ - value: item._id.$oid, - label: item.organization, - }); + if (n50_flag) { + if (item._id.$oid === N50_ID) { + temp_partner_options.push({ + value: item._id.$oid, + label: item.organization, + }); + } + } else { + temp_partner_options.push({ + value: item._id.$oid, + label: item.organization, + }); + } return true; }); - temp_partner_options.push({ - value: null, - label: t("commonApplication.no-affiliation"), - }); + if (!n50_flag) { + temp_partner_options.push({ + value: null, + label: t("commonApplication.no-affiliation"), + }); + } setPartnerOptions(temp_partner_options); setLoading(false); } @@ -129,6 +147,9 @@ function MenteeApplication({ email, role, onSubmitSuccess, onSubmitFailure }) { ]; const onFinish = async (values) => { + if (n50_flag) { + values.partner = N50_ID; + } setLoading(true); let immigrantStatus = values.immigrantStatus; let topics = values.topics; @@ -183,7 +204,6 @@ function MenteeApplication({ email, role, onSubmitSuccess, onSubmitFailure }) { const res = await createApplication(data); setLoading(false); - console.log("res", res); if (res && res.status === 200) { onSubmitSuccess(); } else { @@ -519,6 +539,8 @@ function MenteeApplication({ email, role, onSubmitSuccess, onSubmitFailure }) { filterOption={(input, option) => (option?.label.toLowerCase() ?? "").includes(input.toLowerCase()) } + defaultValue={n50_flag ? N50_ID : null} + disabled={n50_flag} options={[...partnerOptions]} /> diff --git a/frontend/src/components/pages/MenteeProfileForm.js b/frontend/src/components/pages/MenteeProfileForm.js index b2be9148..5b40b90d 100644 --- a/frontend/src/components/pages/MenteeProfileForm.js +++ b/frontend/src/components/pages/MenteeProfileForm.js @@ -51,6 +51,7 @@ function MenteeProfileForm({ profileData, resetFields, applicationData, + n50_flag, }) { const { t, i18n } = useTranslation(); const options = useSelector((state) => state.options); @@ -63,6 +64,7 @@ function MenteeProfileForm({ const [flag, setFlag] = useState(false); const [finishFlag, setFinishFlag] = useState(false); const [refresh, setRefresh] = useState(false); + var n50_user = localStorage.getItem("n50_user"); const immigrantOptions = [ { @@ -488,7 +490,10 @@ function MenteeProfileForm({ ]} className={styles.formGroupItem} > - state.options); @@ -20,16 +26,27 @@ function MentorApplication({ email, role, onSubmitFailure, onSubmitSuccess }) { const partenr_data = await fetchPartners(undefined, null); var temp_partner_options = []; partenr_data.map((item) => { - temp_partner_options.push({ - value: item._id.$oid, - label: item.organization, - }); + if (n50_flag) { + if (item._id.$oid === N50_ID) { + temp_partner_options.push({ + value: item._id.$oid, + label: item.organization, + }); + } + } else { + temp_partner_options.push({ + value: item._id.$oid, + label: item.organization, + }); + } return true; }); - temp_partner_options.push({ - value: null, - label: t("commonApplication.no-affiliation"), - }); + if (!n50_flag) { + temp_partner_options.push({ + value: null, + label: t("commonApplication.no-affiliation"), + }); + } setPartnerOptions(temp_partner_options); setloading(false); } @@ -37,6 +54,9 @@ function MentorApplication({ email, role, onSubmitFailure, onSubmitSuccess }) { }, []); const onFinish = async (values) => { + if (n50_flag) { + values.partner = N50_ID; + } setloading(true); const data = { email, @@ -414,6 +434,8 @@ function MentorApplication({ email, role, onSubmitFailure, onSubmitSuccess }) { filterOption={(input, option) => (option?.label.toLowerCase() ?? "").includes(input.toLowerCase()) } + defaultValue={n50_flag ? N50_ID : null} + disabled={n50_flag} options={[...partnerOptions]} /> diff --git a/frontend/src/components/pages/MentorProfileForm.js b/frontend/src/components/pages/MentorProfileForm.js index 78afc244..98437366 100644 --- a/frontend/src/components/pages/MentorProfileForm.js +++ b/frontend/src/components/pages/MentorProfileForm.js @@ -51,6 +51,7 @@ function MentorProfileForm({ profileData, resetFields, applicationData, + n50_flag, }) { const { t, i18n } = useTranslation(); const options = useSelector((state) => state.options); @@ -61,6 +62,7 @@ function MentorProfileForm({ const [partnerOptions, setPartnerOptions] = useState([]); const [flag, setFlag] = useState(false); const [finishFlag, setFinishFlag] = useState(false); + var n50_user = localStorage.getItem("n50_user"); useEffect(() => { async function getPartners() { @@ -479,7 +481,7 @@ function MentorProfileForm({ ]} className={styles.formGroupItem} > - { - const requestExtension = `/messages/group/?hub_user_id=${hub_user_id}`; + const requestExtension = `/messages/group/?hub_user_id=${ + hub_user_id ? hub_user_id : "" + }`; return authGet(requestExtension).then( (response) => response.data.result.Messages, (err) => { diff --git a/frontend/src/utils/consts.js b/frontend/src/utils/consts.js index f33ea3c1..36e8ef0d 100644 --- a/frontend/src/utils/consts.js +++ b/frontend/src/utils/consts.js @@ -11,6 +11,12 @@ export const FRONT_BASE_URL = IS_PRODUCTION ? BASE_URL : `http://localhost:3000/`; +export const N50_ID = IS_PRODUCTION + ? IS_DEVELOPMENT + ? "675985b41684c4310ac00e4c" + : "673629a96d37195fa12e2a51" + : "675985b41684c4310ac00e4c"; + export const API_URL = BASE_URL + "api/"; export const AUTH_URL = BASE_URL + "auth/"; diff --git a/frontend/src/utils/hooks/useSidebars.js b/frontend/src/utils/hooks/useSidebars.js index 8d63ef38..c42b6428 100644 --- a/frontend/src/utils/hooks/useSidebars.js +++ b/frontend/src/utils/hooks/useSidebars.js @@ -141,6 +141,11 @@ export default function useSidebars(userType, user, t) { key: `messages/${ACCOUNT_TYPE.PARTNER}`, icon: , }, + { + label: t("common.group_message"), + key: `partner_group_messages/${user ? user._id.$oid : ""}`, + icon: , + }, { label: t("sidebars.meeting"), key: `createmeetinglink/${ACCOUNT_TYPE.PARTNER}`,