mirror of
https://github.com/apricote/Listory.git
synced 2026-01-13 13:11:02 +00:00
feat(frontend): show page when login fails
This commit is contained in:
parent
cffddedc81
commit
32dcd84964
6 changed files with 35 additions and 5 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import React from "react";
|
||||
import { Route, Switch } from "react-router-dom";
|
||||
import { LoginFailure } from "./components/LoginFailure";
|
||||
import { NavBar } from "./components/NavBar";
|
||||
import { useAuth } from "./hooks/use-auth";
|
||||
import "./tailwind/generated.css";
|
||||
|
|
@ -7,8 +8,6 @@ import "./tailwind/generated.css";
|
|||
export function App() {
|
||||
const { isLoaded } = useAuth();
|
||||
|
||||
console.log("App", { isLoaded });
|
||||
|
||||
if (!isLoaded) {
|
||||
return <div>Loading...</div>;
|
||||
}
|
||||
|
|
@ -20,6 +19,7 @@ export function App() {
|
|||
</header>
|
||||
<Switch>
|
||||
<Route path="/" exact />
|
||||
<Route path="/login/failure" exact component={LoginFailure} />
|
||||
</Switch>
|
||||
</div>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ const getDefaultHeaders = (): Headers => {
|
|||
};
|
||||
|
||||
export const getUsersMe = async (): Promise<User> => {
|
||||
const res = await fetch(`api/v1/users/me`, { headers: getDefaultHeaders() });
|
||||
const res = await fetch(`/api/v1/users/me`, { headers: getDefaultHeaders() });
|
||||
|
||||
switch (res.status) {
|
||||
case 200: {
|
||||
|
|
|
|||
25
frontend/src/components/LoginFailure.tsx
Normal file
25
frontend/src/components/LoginFailure.tsx
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import React from "react";
|
||||
import { useQuery } from "../hooks/use-query";
|
||||
|
||||
export const LoginFailure: React.FC = () => {
|
||||
const query = useQuery();
|
||||
|
||||
const source = query.get("source");
|
||||
const reason = query.get("reason");
|
||||
|
||||
return (
|
||||
<div
|
||||
className="bg-orange-100 border-l-4 border-orange-500 text-orange-700 p-4 m-8"
|
||||
role="alert"
|
||||
>
|
||||
<p className="font-bold">Login Failure</p>
|
||||
<p>Something not ideal might be happening.</p>
|
||||
<p className="m-5 bg-gray-100 p-5">
|
||||
<ul className="text-xs text-gray-700 font-mono">
|
||||
<li>Source: {source}</li>
|
||||
<li>Reason: {reason}</li>
|
||||
</ul>
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
5
frontend/src/hooks/use-query.tsx
Normal file
5
frontend/src/hooks/use-query.tsx
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
import { useLocation } from "react-router-dom";
|
||||
|
||||
export function useQuery(): URLSearchParams {
|
||||
return new URLSearchParams(useLocation().search);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue