Skip to content

Commit

Permalink
Merge pull request #1084 from navgurukul/acb-new-changes-main
Browse files Browse the repository at this point in the history
Acb new changes main
  • Loading branch information
komalahire authored Dec 8, 2023
2 parents c9e0eb7 + f2df70e commit 0427656
Show file tree
Hide file tree
Showing 8 changed files with 108 additions and 51 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"editor.inlineSuggest.showToolbar": "onHover"
}
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ''
Expand Down
20 changes: 20 additions & 0 deletions src/components/Class/ClassForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ? (
Expand Down
55 changes: 18 additions & 37 deletions src/components/Header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,16 +189,7 @@ const PublicMenuOption = ({ leftDrawer, toggleDrawer }) => {
>
<Typography
variant="subtitle1"
sx={{
height: "36px",
padding: "6px 16px",
display: "flex",
alignItems: "center",
"&:hover": {
backgroundColor: "#E9F5E9",
borderRadius: "8px",
},
}}
className={classes.donate}
>
Donate
<LaunchOutlinedIcon sx={{ pl: "5px" }} />
Expand All @@ -209,31 +200,23 @@ const PublicMenuOption = ({ leftDrawer, toggleDrawer }) => {
)}
</Box>

{localStorage.getItem("studentAuth") ?
<a
href={`https://dev.scratch.merakilearn.org/login/?studentAuth=${localStorage.getItem("studentAuthToken")}`}
target="_blank"
style={{ textDecoration: "none", color:"black" }}
>
<Typography
variant="subtitle1"
sx={{
height: "36px",
padding: "6px 16px",
display: "flex",
alignItems: "center",
"&:hover": {
backgroundColor: "#E9F5E9",
borderRadius: "8px",
},
}}
>
Scratch
<OpenInNewIcon style={{ color: "Black", paddingLeft: "9px" }} />

</Typography>
</a>
: (
{localStorage.getItem("studentAuth") ? (
<a
href={`${
process.env.REACT_APP_SCRATCH_URL
}?studentAuth=${localStorage.getItem("studentAuthToken")}`}
target="_blank"
style={{ textDecoration: "none", color: "black" }}
>
<Typography
variant="subtitle1"
className={classes.scratchLink}
>
Scratch
<OpenInNewIcon style={{ color: "Black", paddingLeft: "9px" }} />
</Typography>
</a>
) : (
<>
{!leftDrawer && (
<Box sx={{ flexGrow: 0, display: { xs: "none", md: "flex" } }}>
Expand All @@ -250,8 +233,6 @@ const PublicMenuOption = ({ leftDrawer, toggleDrawer }) => {
)}
</>
)}


</>
);
};
Expand Down
20 changes: 20 additions & 0 deletions src/components/Header/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
2 changes: 1 addition & 1 deletion src/components/PathwayExercise/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ function PathwayExercise() {
if(localStorage.getItem("studentAuth")|| (user && user?.data?.token)){
return
}else{
history.push("/login");
history.push(PATHS.LOGIN);
}

},[])
Expand Down
3 changes: 0 additions & 3 deletions src/pages/Home/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -70,7 +69,6 @@ function Home() {
}
}, []);


useEffect(() => {
dispatch(pathwayActions.getPathways());
}, [dispatch]);
Expand Down Expand Up @@ -344,7 +342,6 @@ function Home() {
</Container>

{/* Section 5 */}

<Container maxWidth="lg" sx={{ marginTop: "64px" }}>
<Typography variant="h5" textAlign="center" marginBottom="32px">
Hear from our Users
Expand Down
55 changes: 45 additions & 10 deletions src/pages/Login/index.js
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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();
Expand Down Expand Up @@ -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,
Expand All @@ -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") {
Expand All @@ -102,6 +125,22 @@ function Login(props) {
if (props.location.state) {
return <Redirect to={props.location.state.from.pathname} />;
}

// For already registered ACB Students redirection below:-
if (
data?.user?.partner_id == 932 &&
!data?.user?.rolesList.includes("partner") &&
!data?.user?.rolesList.includes("admin")
) {
return (
<Redirect
to={interpolatePath(PATHS.PATHWAY_COURSE, {
pathwayId: amazonPathwayId,
})}
/>
);
}

return (
<>
{pythonPathwayId && (
Expand All @@ -114,11 +153,7 @@ function Login(props) {
}

if (rolesList != false) {

if (!(rolesList.includes("partner") || rolesList.includes("admin"))) {
if (utm_medium.includes("amazon")) {
return <Redirect to={"/pathway/:7"} />;
}
return <Redirect to={PATHS.COURSE} />;
}
} else if (rolesList.length == 0) {
Expand Down

0 comments on commit 0427656

Please sign in to comment.