fixing redirect stuff

This commit is contained in:
csawatzky 2025-04-28 16:05:12 -06:00
parent 424b75afb8
commit f8fb4b7c7d
4 changed files with 23 additions and 24 deletions

View file

@ -14,7 +14,7 @@ import { teamScope, User } from "models";
import { pond } from "protobuf-ts/pond";
import { useSnackbar, useUserAPI, useCNHiProxyAPI } from "providers";
import { useEffect, useState } from "react";
import { useLocation } from "react-router";
//import { useLocation } from "react-router";
import TeamSearch from "teams/TeamSearch";
export default function CNHiAccess() {
@ -29,8 +29,8 @@ export default function CNHiAccess() {
const cnhiAPI = useCNHiProxyAPI();
//const [dataOps, setDataOps] = useState<pond.DataOption[]>([]);
const { openSnack } = useSnackbar();
const search = useLocation().search;
const searchParams = new URLSearchParams(search);
//const search = useLocation().search;
//const searchParams = new URLSearchParams(search);
//const [{ as }] = useGlobalState();
const client_id = import.meta.env.VITE_CNHI_CLIENT_ID;
const auth_url = import.meta.env.VITE_CNHI_AUTHORIZE_URL;
@ -44,10 +44,6 @@ export default function CNHiAccess() {
cnhiAPI
.addAccount(teamKey, primaryUser, cnhiCode, cnhiUsername)
.then(resp => {
//the code was used so remove it from local storage
if (localStorage.getItem("code")) {
localStorage.removeItem("code");
}
openSnack("Added New Case New Holland Account Link");
})
.catch(err => {
@ -66,12 +62,12 @@ export default function CNHiAccess() {
}, [teamKey, userAPI]);
useEffect(() => {
let code = localStorage.getItem("code");
let code = new URLSearchParams(window.location.search).get("code");
if (code) {
setCNHiCode(code);
setOpenDialog(true);
}
}, [searchParams, cnhiCode]);
}, [window.location, cnhiCode]);
const validate = () => {
let invalid = false;