Changed types and resetted tab id when on Admin Page

This commit is contained in:
Lucas Oliveira 2023-08-31 15:08:09 -03:00
commit 28580095dd
6 changed files with 12 additions and 9 deletions

View file

@ -504,7 +504,7 @@ export const USER_PROJECTS_HEADER = "My Collection";
* @constant
*
*/
export const ADMIN_HEADER_TITLE = "Welcome back!";
export const ADMIN_HEADER_TITLE = "Admin Page";
/**
* Header description for admin page

View file

@ -238,7 +238,6 @@ export function TabsProvider({ children }: { children: ReactNode }) {
function hardReset() {
newNodeId.current = uid();
setTabId("");
setFlows([]);
setIsLoading(true);
setId(uid());

View file

@ -400,7 +400,7 @@ export async function renewAccessToken(token: string) {
}
}
export async function getLoggedUser(): Promise<Array<Users>> {
export async function getLoggedUser(): Promise<Users | null> {
try {
const res = await api.get(`${BASE_URL_API}user`);
@ -411,7 +411,7 @@ export async function getLoggedUser(): Promise<Array<Users>> {
console.log("Error:", error);
throw error;
}
return [];
return null;
}
export async function addUser(user: UserInputType): Promise<Array<Users>> {

View file

@ -48,7 +48,7 @@ export default function LoginAdminPage() {
}
function getUser() {
if (getAuthentication) {
if (getAuthentication()) {
setTimeout(() => {
getLoggedUser()
.then((user) => {

View file

@ -22,6 +22,7 @@ import {
} from "../../constants/constants";
import { alertContext } from "../../contexts/alertContext";
import { AuthContext } from "../../contexts/authContext";
import { TabsContext } from "../../contexts/tabsContext";
import {
addUser,
deleteUser,
@ -43,6 +44,13 @@ export default function AdminPage() {
const { userData } = useContext(AuthContext);
const [totalRowsCount, setTotalRowsCount] = useState(0);
const { setTabId } = useContext(TabsContext);
// set null id
useEffect(() => {
setTabId("");
}, []);
const userList = useRef([]);
useEffect(() => {

View file

@ -35,10 +35,6 @@ export default function HomePage(): JSX.Element {
}, []);
const navigate = useNavigate();
useEffect(() => {
console.log(isLoading);
}, [isLoading]);
// Personal flows display
return (
<>