Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 43 additions & 14 deletions src/pages/Main.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,56 @@
import { useNavigate } from "react-router-dom";
// import { useNavigate } from "react-router-dom";
import {
LoadingSpinner,
useInitialisedDeskproAppClient,
// useDeskproLatestAppContext,
// useInitialisedDeskproAppClient,
} from "@deskpro/app-sdk";
import { useStore } from "../context/StoreProvider/hooks";
import { checkIsAuthService } from "../services/github";
// import { useStore } from "../context/StoreProvider/hooks";
// import { checkIsAuthService } from "../services/github";
import { Container } from "../components/common";
import { Button } from "@deskpro/deskpro-ui";
import { useEffect, useState } from "react";

export const Main = () => {
const navigate = useNavigate();
const [, dispatch] = useStore();
// const { context } = useDeskproLatestAppContext()
// console.log("Context Data: ", context?.data)
const [errorState, setErrorState] = useState<string | null>(null)
// const navigate = useNavigate();
// const [, dispatch] = useStore();

useInitialisedDeskproAppClient((client) => {
checkIsAuthService(client)
.then((isAuth) => {
dispatch({ type: "setAuth", isAuth })
navigate(isAuth ? "/home" : "/log_in")
})
});
useEffect(() => {
if (errorState === "left") {
throw new Error("hello")
}

if (errorState === "right") {
throw "HI"
}



}, [errorState])

// throw "String"

// useInitialisedDeskproAppClient((client) => {
// checkIsAuthService(client)
// .then((isAuth) => {
// dispatch({ type: "setAuth", isAuth })
// navigate(isAuth ? "/home" : "/log_in")
// })
// });

return (
<Container>
<LoadingSpinner/>
<Button
text="Left Error"
onClick={() => { setErrorState("left") }}
/>
<Button
text="Right Error"
onClick={() => { setErrorState("right") }}
/>
<LoadingSpinner />
</Container>
);
};
Loading