Skip to content

Commit

Permalink
added opportunity to reload domains which depending of those roles
Browse files Browse the repository at this point in the history
  • Loading branch information
OlegPhenomenon committed Jul 5, 2021
1 parent dfb6ff9 commit 54269be
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 37 deletions.
26 changes: 14 additions & 12 deletions src/pages/HomePage/HomePage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,31 +27,33 @@ const HomePage = ({
const dispatch = useDispatch();

const [techParams, setTechParams] = useState(isTech);
const [previousTechParams, setPreviousTechParams] = useState(isTech);

const onSelectTech = (value) => {
setIsLoading(true);
setPreviousTechParams(isTech);
setTechParams(value);
dispatch(setSortByRoles(value));
};

useEffect(() => {
if (domains.length === 0) {
if (isTech === 'init') {
(async () => {
await fetchDomains(0, false, isTech);
setIsLoading(false);
})();
} else {
(async () => {
await fetchDomains(0, false, isTech);
setIsLoading(false);
})();
}
} else {
(async () => {
await fetchDomains(0, false, isTech);
setIsLoading(false);
})();}
else if (previousTechParams !== isTech) {
(async () => {
await fetchDomains(0, false, isTech);
setIsLoading(false);
})();}
else {
setIsLoading(false);
}
}, [fetchDomains, isTech]);

console.log(totalDomains);

if (isLoading) return <Loading />;

return (
Expand Down
25 changes: 0 additions & 25 deletions src/redux/reducers/domains.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,30 +143,6 @@ const failDomainUnlock = (payload) => ({
type: UNLOCK_DOMAIN_FAILURE,
});

// const fetchRawDomainList = async (isTech) => {
// let offset = 0;
// let domains = [];
// let count = 0;

// let res = await api.fetchDomains(null, offset, false, isTech);
// domains = domains.concat(res.data.domains);
// count = res.data.count;
// if (offset < count) {
// offset += 200;
// } else {
// return domains;
// }

// while (offset < count) {
// res = api.fetchDomains(null, offset, false);
// domains = domains.concat(res.data.domains);
// if (offset < count) {
// offset += 200;
// }
// }
// return domains;
// };

const fetchDomain = (uuid) => (dispatch) => {
dispatch(requestDomain());
return api
Expand Down Expand Up @@ -368,5 +344,4 @@ export {
lockDomain,
parseDomain,
unlockDomain,
// fetchRawDomainList,
};

0 comments on commit 54269be

Please sign in to comment.