fix: Fix routing issue with deeplink (#1721)

This commit is contained in:
Shailesh Parmar 2021-12-13 19:03:09 +05:30 committed by GitHub
parent f56e1e546a
commit 962584fbfe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -60,22 +60,6 @@ const TeamsPage = () => {
const [isAddingTeam, setIsAddingTeam] = useState<boolean>(false);
const [isAddingUsers, setIsAddingUsers] = useState<boolean>(false);
const [userList, setUserList] = useState<Array<User>>([]);
const fetchCurrentTeam = (name: string, update = false) => {
if (currentTeam?.name !== name || update) {
setIsLoading(true);
getTeamByName(name, ['users', 'owns'])
.then((res: AxiosResponse) => {
setCurrentTeam(res.data);
setIsLoading(false);
})
.catch((err: AxiosError) => {
if (err?.response?.data.code) {
setError(ERROR404);
}
setIsLoading(false);
});
}
};
const fetchTeams = () => {
setIsLoading(true);
@ -85,27 +69,46 @@ const TeamsPage = () => {
setCurrentTeam(res.data.data[0]);
}
setTeams(res.data.data);
setIsLoading(false);
})
.catch((err: AxiosError) => {
if (err?.response?.data.code) {
setError(ERROR404);
}
})
.finally(() => {
setIsLoading(false);
});
};
const fetchCurrentTeam = (name: string, update = false) => {
if (currentTeam?.name !== name || update) {
setIsLoading(true);
getTeamByName(name, ['users', 'owns'])
.then((res: AxiosResponse) => {
setCurrentTeam(res.data);
if (teams.length <= 0) {
fetchTeams();
}
})
.catch((err: AxiosError) => {
if (err?.response?.data.code) {
setError(ERROR404);
}
})
.finally(() => {
setIsLoading(false);
});
}
};
const createNewTeam = (data: Team) => {
createTeam(data)
.then((res: AxiosResponse) => {
if (res.data) {
fetchTeams();
setIsAddingTeam(false);
} else {
setIsAddingTeam(false);
}
})
.catch(() => {
.finally(() => {
setIsAddingTeam(false);
});
};