nice fixing auth problems
This commit is contained in:
@@ -14,8 +14,7 @@ export default function ProtectedRoute({
|
|||||||
}) {
|
}) {
|
||||||
const [jwtToken, setJwtToken] = useRecoilState($jwtToken);
|
const [jwtToken, setJwtToken] = useRecoilState($jwtToken);
|
||||||
|
|
||||||
const { isLoading, isError, isFetching, isSuccess, refetch } =
|
const { isLoading, isError, isFetching, isSuccess, refetch } = useAuthCheck();
|
||||||
useAuthCheck(jwtToken);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// on load of this, if we already have jwt tokens in store,
|
// on load of this, if we already have jwt tokens in store,
|
||||||
|
|||||||
@@ -1,12 +1,16 @@
|
|||||||
import NirvanaApi, { ApiCalls } from "./nirvanaApi";
|
import NirvanaApi, { ApiCalls } from "./nirvanaApi";
|
||||||
import { useMutation, useQuery } from "react-query";
|
import { useMutation, useQuery } from "react-query";
|
||||||
|
|
||||||
|
import { $jwtToken } from "./recoil";
|
||||||
|
import { useRecoilValue } from "recoil";
|
||||||
|
|
||||||
// ====== QUERIES
|
// ====== QUERIES
|
||||||
export function useAuthCheck(jwtToken?: string) {
|
export function useAuthCheck() {
|
||||||
|
const jwtToken = useRecoilValue($jwtToken);
|
||||||
|
|
||||||
return useQuery("AUTH_CHECK", ApiCalls.authCheck, {
|
return useQuery("AUTH_CHECK", ApiCalls.authCheck, {
|
||||||
retry: false,
|
retry: false,
|
||||||
refetchOnWindowFocus: false,
|
refetchOnWindowFocus: false,
|
||||||
enabled: jwtToken ? true : false,
|
|
||||||
|
|
||||||
refetchInterval: 10000,
|
refetchInterval: 10000,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import { ILineDetails } from "../router";
|
|||||||
import IconButton from "../../components/Button/IconButton/index";
|
import IconButton from "../../components/Button/IconButton/index";
|
||||||
import LineRow from "../../components/lines/lineRow.tsx/index";
|
import LineRow from "../../components/lines/lineRow.tsx/index";
|
||||||
import NewLineModal from "./newLine";
|
import NewLineModal from "./newLine";
|
||||||
|
import { Tooltip } from "antd";
|
||||||
import { useSetRecoilState } from "recoil";
|
import { useSetRecoilState } from "recoil";
|
||||||
|
|
||||||
export default function NirvanaTerminal({
|
export default function NirvanaTerminal({
|
||||||
@@ -49,7 +50,7 @@ export default function NirvanaTerminal({
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
{/* tuned in lines block */}
|
{/* tuned in lines block */}
|
||||||
<div className="bg-gray-100 flex flex-col">
|
<div className="bg-gray-100 flex flex-col shadow-lg">
|
||||||
{/* tuned in header + general controls */}
|
{/* tuned in header + general controls */}
|
||||||
<div className="flex flex-row items-center p-3 pb-0">
|
<div className="flex flex-row items-center p-3 pb-0">
|
||||||
<span className="flex flex-row gap-2 items-center justify-start text-slate-800">
|
<span className="flex flex-row gap-2 items-center justify-start text-slate-800">
|
||||||
@@ -84,14 +85,16 @@ export default function NirvanaTerminal({
|
|||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
|
|
||||||
<div
|
<Tooltip title="new line">
|
||||||
onClick={() => setIsModalVisible(true)}
|
<div
|
||||||
className="ml-auto absolute bottom-2 right-2 shadow-xl"
|
onClick={() => setIsModalVisible(true)}
|
||||||
>
|
className="ml-auto absolute bottom-5 right-5 shadow-xl"
|
||||||
<IconButton>
|
>
|
||||||
<FaPlus />
|
<IconButton>
|
||||||
</IconButton>
|
<FaPlus />
|
||||||
</div>
|
</IconButton>
|
||||||
|
</div>
|
||||||
|
</Tooltip>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user