Convert all SecurityClient API calls to hooks except auth

This commit is contained in:
Tuan Dang
2023-08-10 17:19:23 +07:00
parent 78802409bd
commit 2dba7847b6
45 changed files with 179 additions and 1377 deletions
+6 -6
View File
@@ -1,10 +1,11 @@
import { useEffect } from "react";
import { useRouter } from "next/router";
import getOrganizations from "./api/organization/getOrgs";
import { useGetOrganizations } from "@app/hooks/api";
export default function DashboardRedirect() {
const router = useRouter();
const { data: userOrgs } = useGetOrganizations();
/**
* Here we forward to the default workspace if a user opens this url
@@ -16,11 +17,10 @@ export default function DashboardRedirect() {
try {
if (localStorage.getItem("orgData.id")) {
router.push(`/org/${localStorage.getItem("orgData.id")}/overview`);
} else {
const userOrgs = await getOrganizations();
userOrg = userOrgs[0]._id;
router.push(`/org/${userOrg}/overview`);
}
} else if (userOrgs) {
userOrg = userOrgs[0]._id;
router.push(`/org/${userOrg}/overview`);
}
} catch (error) {
console.log("Error - Not logged in yet");
}