fixing redirect stuff
This commit is contained in:
parent
424b75afb8
commit
f8fb4b7c7d
4 changed files with 23 additions and 24 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import { teamScope, User } from "models";
|
|||
import { pond } from "protobuf-ts/pond";
|
||||
import { useSnackbar, useUserAPI, useJohnDeereProxyAPI } from "providers";
|
||||
import { useEffect, useState } from "react";
|
||||
import { useLocation } from "react-router";
|
||||
//import { useLocation } from "react-router";
|
||||
import TeamSearch from "teams/TeamSearch";
|
||||
|
||||
//const steps = [{label: "General"},{label: "Data Options"}]
|
||||
|
|
@ -31,13 +31,14 @@ export default function JDAccess() {
|
|||
const johnDeereAPI = useJohnDeereProxyAPI();
|
||||
//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 MAPBOX_TOKEN = import.meta.env.VITE_MAPBOX_ACCESS_TOKEN;
|
||||
const client_id = import.meta.env.VITE_JD_CLIENT_ID;
|
||||
const auth_url = import.meta.env.VITE_JD_AUTHORIZE_URL;
|
||||
const redirect_url = import.meta.env.VITE_JD_REDIRECT_URI;
|
||||
//const redirect_url = "http://localhost:5173/johndeere";//local redirect for testing
|
||||
const scopes = import.meta.env.VITE_JD_SCOPES;
|
||||
const state = import.meta.env.VITE_JD_STATE;
|
||||
|
||||
|
|
@ -48,10 +49,6 @@ export default function JDAccess() {
|
|||
johnDeereAPI
|
||||
.addAccount(teamKey, primaryUser, jdCode, jdUserName)
|
||||
.then(resp => {
|
||||
//the code was used so remove it from local storage
|
||||
if (sessionStorage.getItem("code")) {
|
||||
sessionStorage.removeItem("code");
|
||||
}
|
||||
openSnack("Added New John Deere Account Link");
|
||||
window.open(
|
||||
`https://connections.deere.com/connections/${client_id}/select-organizations`
|
||||
|
|
@ -73,12 +70,12 @@ export default function JDAccess() {
|
|||
}, [teamKey, userAPI]);
|
||||
|
||||
useEffect(() => {
|
||||
let code = sessionStorage.getItem("code");
|
||||
let code = new URLSearchParams(window.location.search).get("code");
|
||||
if (code) {
|
||||
setJDCode(code);
|
||||
setOpenDialog(true);
|
||||
}
|
||||
}, [searchParams, jdCode]);
|
||||
}, [window.location, jdCode]);
|
||||
|
||||
const validate = () => {
|
||||
let invalid = false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue