refactor: cleanup login routes
This commit is contained in:
2 files changed
+21
-37
No files matched your search
@@ -1,21 +1,18 @@
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import React, { useLayoutEffect } from "react";
|
||||
import React, { useEffect } from "react";
|
||||
|
||||
import { Chip, IconButton, Typography } from "@mui/material";
|
||||
import Button from "@mui/material/Button";
|
||||
import { Chip, Typography } from "@mui/material";
|
||||
|
||||
import { AppBarBackOnly } from "@/components/appBar/backOnly.jsx";
|
||||
|
||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
||||
|
||||
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice.jsx";
|
||||
import "./login.scss";
|
||||
|
||||
import QuickConnectButton from "@/components/buttons/quickConnectButton";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import { useBackdropStore } from "@/utils/store/backdrop.js";
|
||||
import type { UserDto } from "@jellyfin/sdk/lib/generated-client";
|
||||
import { Link, createFileRoute, useNavigate } from "@tanstack/react-router";
|
||||
import { Link, createFileRoute } from "@tanstack/react-router";
|
||||
|
||||
import avatar from "../../../assets/icons/avatar.png";
|
||||
|
||||
@@ -36,7 +33,7 @@ const UserCard = ({ user }: { user: UserDto }) => {
|
||||
<img
|
||||
className="user-card-image"
|
||||
alt={"user"}
|
||||
src={`${api.basePath}/Users/${user.Id}/Images/Primary?quality=80&tag=${user.PrimaryImageTag}`}
|
||||
src={`${api?.basePath}/Users/${user.Id}/Images/Primary?quality=80&tag=${user.PrimaryImageTag}`}
|
||||
/>
|
||||
) : (
|
||||
<img className="user-card-image" alt="user" src={avatar} />
|
||||
@@ -50,13 +47,8 @@ const UserCard = ({ user }: { user: UserDto }) => {
|
||||
}
|
||||
|
||||
function LoginPublicUsersList() {
|
||||
const navigate = useNavigate();
|
||||
|
||||
const api = useApiInContext((s) => s.api);
|
||||
|
||||
const handleChangeServer = () => {
|
||||
navigate({ to: "/setup/server/list" });
|
||||
};
|
||||
const users = useQuery({
|
||||
queryKey: ["login", "public-users"],
|
||||
queryFn: async () => {
|
||||
@@ -67,11 +59,11 @@ function LoginPublicUsersList() {
|
||||
enabled: Boolean(api),
|
||||
});
|
||||
|
||||
const setBackdrop = useBackdropStore((state) => state.setBackdrop);
|
||||
|
||||
useLayoutEffect(() => {
|
||||
const setBackdrop = useBackdropStore((state) => state.setBackdrop);
|
||||
useEffect(() => {
|
||||
setBackdrop("", "");
|
||||
}, []);
|
||||
|
||||
if (users.isSuccess) {
|
||||
return (
|
||||
<div className="login-container scrollY">
|
||||
@@ -85,17 +77,6 @@ function LoginPublicUsersList() {
|
||||
})}
|
||||
</div>
|
||||
|
||||
{/* <div className="buttons">
|
||||
<Button
|
||||
color="secondary"
|
||||
variant="contained"
|
||||
className="userEventButton"
|
||||
onClick={handleChangeServer}
|
||||
>
|
||||
Change Server
|
||||
</Button>
|
||||
<QuickConnectButton />
|
||||
</div> */}
|
||||
<Chip
|
||||
style={{ marginLeft: "50%", transform: "translateX(-50%)" }}
|
||||
label={
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { skipToken, useMutation, useQuery } from "@tanstack/react-query";
|
||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||
import React, {
|
||||
type ChangeEvent,
|
||||
type FormEvent,
|
||||
@@ -24,7 +24,6 @@ import { useApiInContext } from "@/utils/store/api.js";
|
||||
import { getBrandingApi } from "@jellyfin/sdk/lib/utils/api/branding-api";
|
||||
import "./login.scss";
|
||||
|
||||
import QuickConnectButton from "@/components/buttons/quickConnectButton";
|
||||
import { useBackdropStore } from "@/utils/store/backdrop.js";
|
||||
import { blue } from "@mui/material/colors";
|
||||
import {
|
||||
@@ -32,10 +31,12 @@ import {
|
||||
useNavigate,
|
||||
useRouter,
|
||||
} from "@tanstack/react-router";
|
||||
import axios from "axios";
|
||||
|
||||
export const Route = createFileRoute("/_api/login/manual")({
|
||||
component: UserLoginManual,
|
||||
validateSearch: (search): { redirect: string } => {
|
||||
return { redirect: String(search.redirect) };
|
||||
},
|
||||
});
|
||||
|
||||
function UserLoginManual() {
|
||||
@@ -49,7 +50,7 @@ function UserLoginManual() {
|
||||
const server = useQuery({
|
||||
queryKey: ["login", "manual", "serverInfo"],
|
||||
queryFn: async () =>
|
||||
api ? (await getBrandingApi(api).getBrandingOptions()).data : skipToken,
|
||||
api ? (await getBrandingApi(api).getBrandingOptions()).data : null,
|
||||
});
|
||||
|
||||
const navigate = useNavigate();
|
||||
@@ -64,12 +65,14 @@ function UserLoginManual() {
|
||||
password: "",
|
||||
});
|
||||
|
||||
const handlePassword = (prop: "password" | "showpass") => (event) => {
|
||||
setPassword({
|
||||
...password,
|
||||
[prop]: event.target.value,
|
||||
});
|
||||
};
|
||||
const handlePassword =
|
||||
(prop: "password" | "showpass") =>
|
||||
(event: ChangeEvent<HTMLInputElement>) => {
|
||||
setPassword({
|
||||
...password,
|
||||
[prop]: event.target.value,
|
||||
});
|
||||
};
|
||||
|
||||
const handleShowPassword = () => {
|
||||
setPassword({
|
||||
@@ -199,7 +202,7 @@ function UserLoginManual() {
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
{server.isSuccess && server.data.LoginDisclaimer && (
|
||||
{server.isSuccess && server.data?.LoginDisclaimer && (
|
||||
<Paper
|
||||
elevation={5}
|
||||
style={{
|
||||
|
||||
Reference in new issue
Block a user