Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit 0d8961e

Browse files
committed
Remove unneccesary imports.
Redirect user from results page if no added roles before first paint.
1 parent ae8738d commit 0d8961e

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

src/routes/CreateNewTeam/components/SearchContainer/index.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import React, { useCallback, useState } from "react";
99
import PT from "prop-types";
1010
import _ from "lodash";
11-
import { useDispatch, useSelector } from "react-redux";
11+
import { useDispatch } from "react-redux";
1212
import AddedRolesAccordion from "../AddedRolesAccordion";
1313
import Completeness from "../Completeness";
1414
import SearchCard from "../SearchCard";

src/routes/CreateNewTeam/components/SubmitContainer/index.jsx

+16-5
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,14 @@
44
* Requires authentication to complete submission process
55
* and contains a series of popups to lead user through the flow.
66
*/
7-
import React, { useCallback, useEffect, useState } from "react";
7+
import React, {
8+
useCallback,
9+
useEffect,
10+
useLayoutEffect,
11+
useState,
12+
} from "react";
813
import PT from "prop-types";
9-
import { useDispatch, useSelector } from "react-redux";
14+
import { useDispatch } from "react-redux";
1015
import _ from "lodash";
1116
import { toastr } from "react-redux-toastr";
1217
import { navigate } from "@reach/router";
@@ -39,14 +44,20 @@ function SubmitContainer({
3944

4045
const dispatch = useDispatch();
4146

42-
// Set correct state for Completeness tab, and redirect
43-
// to main page if path loaded without any selected roles.
4447
useEffect(() => {
4548
setCurrentStage(2, stages, setStages);
4649
if (!addedRoles || addedRoles.length === 0) {
4750
navigate("/taas/myteams/createnewteam");
4851
}
49-
// only needed on initial load, avoids too many re-renders
52+
// eslint-disable-next-line react-hooks/exhaustive-deps
53+
}, []);
54+
55+
// redirects user if they enter the page URL directly
56+
// without adding any roles.
57+
useLayoutEffect(() => {
58+
if (!addedRoles || addedRoles.length === 0) {
59+
navigate("/taas/myteams/createnewteam");
60+
}
5061
// eslint-disable-next-line react-hooks/exhaustive-deps
5162
}, []);
5263

0 commit comments

Comments
 (0)