diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..14f60307e --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "editor.inlineSuggest.showToolbar": "onHover" +} \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 221da2336..9eab6f42a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -38,6 +38,7 @@ git checkout dev REACT_APP_MERAKI_URL = 'https://merd-api.merakilearn.org/' REACT_APP_CHANAKYA_BASE_URL = 'https://join.navgurukul.org/api/' REACT_APP_ADMISSIONS_URL = 'https://admissions.navgurukul.org/' + REACT_APP_SCRATCH_URL = 'https://dev.scratch.merakilearn.org/login/' REACT_APP_API_KEY = '' REACT_APP_authDomain = '' REACT_APP_projectId = '' diff --git a/src/components/Class/ClassForm.js b/src/components/Class/ClassForm.js index ba4d4842c..ab01c1a5e 100644 --- a/src/components/Class/ClassForm.js +++ b/src/components/Class/ClassForm.js @@ -787,6 +787,26 @@ function ClassForm({ .join(", ") .replace(/,([^,]*)$/, " and$1"); + const pathwayData = Newpathways.find((item) => { + return item.id === classFields.pathway_id; + }); + + useEffect(() => { + + if (pathwayData?.code === "ACB") { + const amazonCodingBootcamp = partnerData.find( + (partner) => partner.label?.toLowerCase() === "amazon coding bootcamp" + ); + if (amazonCodingBootcamp ) { + setSelectedPartners([amazonCodingBootcamp]); + setClassFields({ + ...classFields, + ["partner_id"]: [amazonCodingBootcamp.id], + }); + } + } + }, [pathwayData, partnerData]); + return ( <> {showSuccessModal ? ( diff --git a/src/components/Header/index.js b/src/components/Header/index.js index 757a1b754..b656a97aa 100644 --- a/src/components/Header/index.js +++ b/src/components/Header/index.js @@ -189,16 +189,7 @@ const PublicMenuOption = ({ leftDrawer, toggleDrawer }) => { > Donate @@ -209,31 +200,23 @@ const PublicMenuOption = ({ leftDrawer, toggleDrawer }) => { )} - {localStorage.getItem("studentAuth") ? - - - Scratch - - - - - : ( + {localStorage.getItem("studentAuth") ? ( + + + Scratch + + + + ) : ( <> {!leftDrawer && ( @@ -250,8 +233,6 @@ const PublicMenuOption = ({ leftDrawer, toggleDrawer }) => { )} )} - - ); }; diff --git a/src/components/Header/styles.js b/src/components/Header/styles.js index 564eb9d95..85aef2edf 100644 --- a/src/components/Header/styles.js +++ b/src/components/Header/styles.js @@ -40,6 +40,26 @@ const useStyles = makeStyles((theme) => ({ buttonLink: { textDecoration: "none", }, + scratchLink: { + height: "36px", + padding: "6px 16px", + display: "flex", + alignItems: "center", + "&:hover": { + backgroundColor: "#E9F5E9", + borderRadius: "8px", + }, + }, + donate: { + height: "36px", + padding: "6px 16px", + display: "flex", + alignItems: "center", + "&:hover": { + backgroundColor: "#E9F5E9", + borderRadius: "8px", + }, + } })); export default useStyles; diff --git a/src/components/PathwayExercise/index.js b/src/components/PathwayExercise/index.js index 2cd450fa0..f3b0a9eb9 100644 --- a/src/components/PathwayExercise/index.js +++ b/src/components/PathwayExercise/index.js @@ -175,7 +175,7 @@ function PathwayExercise() { if(localStorage.getItem("studentAuth")|| (user && user?.data?.token)){ return }else{ - history.push("/login"); + history.push(PATHS.LOGIN); } },[]) diff --git a/src/pages/Home/index.js b/src/pages/Home/index.js index 66f85d422..481b0a6be 100644 --- a/src/pages/Home/index.js +++ b/src/pages/Home/index.js @@ -40,7 +40,6 @@ function Home() { const roles = useSelector(selectRolesData); const history = useHistory(); - useEffect(() => { const urlParams = new URLSearchParams(window.location.search); const studentAuthParam = urlParams.get("studentAuth"); @@ -70,7 +69,6 @@ function Home() { } }, []); - useEffect(() => { dispatch(pathwayActions.getPathways()); }, [dispatch]); @@ -344,7 +342,6 @@ function Home() { {/* Section 5 */} - Hear from our Users diff --git a/src/pages/Login/index.js b/src/pages/Login/index.js index 5a37800c9..4214126f0 100644 --- a/src/pages/Login/index.js +++ b/src/pages/Login/index.js @@ -1,6 +1,6 @@ import React, { useState, useEffect } from "react"; import { useSelector, useDispatch } from "react-redux"; -import { Redirect } from "react-router-dom"; +import { Redirect, useHistory, useLocation } from "react-router-dom"; import GoogleLogin from "react-google-login"; import axios from "axios"; import { actions as userActions } from "../../components/User/redux/action"; @@ -14,12 +14,10 @@ import useMediaQuery from "@mui/material/useMediaQuery"; import GoogleIcon from "./assets/GoogleIcon"; import useStyles from "./styles"; import { breakpoints } from "../../theme/constant"; -import { useParams } from "react-router-dom"; function Login(props) { - // for amazon coding bootcamp redirect:- - const { utm_medium } = useParams(); - // console.log(utm_medium); + const history = useHistory(); + const location = useLocation(); const [queryString, setqueryString] = useState(null); const user = useSelector(({ User }) => User); const dispatch = useDispatch(); @@ -71,6 +69,20 @@ function Login(props) { pathway.data.pathways.find((pathway) => pathway.code === "PRGPYT"); const pythonPathwayId = pythonPathway && pythonPathway.id; + // PathwayId for Amazon Pathway:- + const amazonPathway = + pathway.data && + pathway.data.pathways.find((pathway) => pathway.code === "ACB"); + const [amazonPathwayId, setAmazonPathwayId] = useState(null); + + useEffect(() => { + if(amazonPathwayId == null){ + setAmazonPathwayId(amazonPathway && amazonPathway.id) + } + }, [user]); + + // --------------------------------------------- + const rolesLandingPages = { volunteer: PATHS.CLASS, admin: PATHS.PARTNERS, @@ -89,7 +101,18 @@ function Login(props) { }, data: { referrer: queryString }, }) - .then((res) => {}) + .then((res) => { + // For ACB Students joining using referrer link redirection below:- + const queryParams = new URLSearchParams(location.search); + const referrer = queryParams.get("referrer"); + if (referrer.includes("amazon")) { + history.push( + interpolatePath(PATHS.PATHWAY_COURSE, { + pathwayId: amazonPathwayId, + }) + ); + } + }) .catch((err) => {}); } if (props.location.state == "/volunteer-with-us") { @@ -102,6 +125,22 @@ function Login(props) { if (props.location.state) { return ; } + + // For already registered ACB Students redirection below:- + if ( + data?.user?.partner_id == 932 && + !data?.user?.rolesList.includes("partner") && + !data?.user?.rolesList.includes("admin") + ) { + return ( + + ); + } + return ( <> {pythonPathwayId && ( @@ -114,11 +153,7 @@ function Login(props) { } if (rolesList != false) { - if (!(rolesList.includes("partner") || rolesList.includes("admin"))) { - if (utm_medium.includes("amazon")) { - return ; - } return ; } } else if (rolesList.length == 0) {