mirror of
https://github.com/C9Glax/tranga-website.git
synced 2025-09-10 11:58:20 +02:00
Manga Remove button
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
import Sheet from '@mui/joy/Sheet';
|
import Sheet from '@mui/joy/Sheet';
|
||||||
import Header from './Header.tsx';
|
import Header from './Header.tsx';
|
||||||
import Settings from './Components/Settings/Settings.tsx';
|
import Settings from './Components/Settings/Settings.tsx';
|
||||||
import ApiProvider from './contexts/ApiContext.tsx';
|
import ApiProvider, { ApiContext } from './contexts/ApiContext.tsx';
|
||||||
import { useEffect, useState } from 'react';
|
import { useContext, useEffect, useState } from 'react';
|
||||||
import { ApiConfig } from './api/http-client.ts';
|
import { ApiConfig } from './api/http-client.ts';
|
||||||
import MangaProvider from './contexts/MangaContext.tsx';
|
import MangaProvider from './contexts/MangaContext.tsx';
|
||||||
import MangaList from './Components/Mangas/MangaList.tsx';
|
import MangaList from './Components/Mangas/MangaList.tsx';
|
||||||
@@ -10,8 +10,9 @@ import { Search } from './Search.tsx';
|
|||||||
import MangaConnectorProvider from './contexts/MangaConnectorContext.tsx';
|
import MangaConnectorProvider from './contexts/MangaConnectorContext.tsx';
|
||||||
import LibraryProvider from './contexts/FileLibraryContext.tsx';
|
import LibraryProvider from './contexts/FileLibraryContext.tsx';
|
||||||
import MangaDetail from './Components/Mangas/Detail/MangaDetail.tsx';
|
import MangaDetail from './Components/Mangas/Detail/MangaDetail.tsx';
|
||||||
|
import TButton from './Components/Inputs/TButton.tsx';
|
||||||
|
|
||||||
export default function App() {
|
export function App() {
|
||||||
const [apiUri, setApiUri] = useState<string>(
|
const [apiUri, setApiUri] = useState<string>(
|
||||||
localStorage.getItem('apiUri') ??
|
localStorage.getItem('apiUri') ??
|
||||||
window.location.href.substring(0, window.location.href.lastIndexOf('/')) + '/api'
|
window.location.href.substring(0, window.location.href.lastIndexOf('/')) + '/api'
|
||||||
@@ -21,16 +22,30 @@ export default function App() {
|
|||||||
setApiConfig({ baseUrl: apiUri });
|
setApiConfig({ baseUrl: apiUri });
|
||||||
}, [apiUri]);
|
}, [apiUri]);
|
||||||
|
|
||||||
|
const Api = useContext(ApiContext);
|
||||||
|
|
||||||
const [searchOpen, setSearchOpen] = useState<boolean>(false);
|
const [searchOpen, setSearchOpen] = useState<boolean>(false);
|
||||||
const [downloadDrawerOpen, setDownloadDrawerOpen] = useState(false);
|
const [downloadDrawerOpen, setDownloadDrawerOpen] = useState(false);
|
||||||
const [selectedMangaKey, setSelectedMangaKey] = useState<string>();
|
const [selectedMangaKey, setSelectedMangaKey] = useState<string>();
|
||||||
const [downloadSectionOpen, setDownloadSectionOpen] = useState(false);
|
const [downloadSectionOpen, setDownloadSectionOpen] = useState(false);
|
||||||
|
|
||||||
function openMangaDownloadDrawer(mangaKey: string, downloadSectionOpen?: boolean) {
|
function openMangaDownloadDrawer(mangaKey: string, downloadSectionOpen?: boolean) {
|
||||||
setDownloadDrawerOpen(true);
|
setDownloadDrawerOpen(true);
|
||||||
setSelectedMangaKey(mangaKey);
|
setSelectedMangaKey(mangaKey);
|
||||||
setDownloadSectionOpen(downloadSectionOpen ?? false);
|
setDownloadSectionOpen(downloadSectionOpen ?? false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const removeManga = async (mangaKey?: string): Promise<void> => {
|
||||||
|
if (!mangaKey) return Promise.reject();
|
||||||
|
try {
|
||||||
|
let r = await Api.mangaDelete(mangaKey);
|
||||||
|
if (r.ok) return Promise.resolve();
|
||||||
|
else return Promise.reject();
|
||||||
|
} catch (reason) {
|
||||||
|
return await Promise.reject(reason);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ApiProvider apiConfig={apiConfig}>
|
<ApiProvider apiConfig={apiConfig}>
|
||||||
<MangaConnectorProvider>
|
<MangaConnectorProvider>
|
||||||
@@ -54,8 +69,11 @@ export default function App() {
|
|||||||
open={downloadDrawerOpen}
|
open={downloadDrawerOpen}
|
||||||
setOpen={setDownloadDrawerOpen}
|
setOpen={setDownloadDrawerOpen}
|
||||||
mangaKey={selectedMangaKey}
|
mangaKey={selectedMangaKey}
|
||||||
downloadOpen={downloadSectionOpen}
|
downloadOpen={downloadSectionOpen}>
|
||||||
/>
|
<TButton completionAction={() => removeManga(selectedMangaKey)}>
|
||||||
|
Remove
|
||||||
|
</TButton>
|
||||||
|
</MangaDetail>
|
||||||
</Sheet>
|
</Sheet>
|
||||||
</Sheet>
|
</Sheet>
|
||||||
</MangaProvider>
|
</MangaProvider>
|
||||||
|
@@ -5,18 +5,19 @@ import {
|
|||||||
Box,
|
Box,
|
||||||
Checkbox,
|
Checkbox,
|
||||||
List,
|
List,
|
||||||
ListItem, Option,
|
ListItem,
|
||||||
|
Option,
|
||||||
Select,
|
Select,
|
||||||
Stack,
|
Stack,
|
||||||
Typography
|
Typography,
|
||||||
} from "@mui/joy";
|
} from '@mui/joy';
|
||||||
import {ReactNode, useContext} from "react";
|
import { ReactNode, useContext } from 'react';
|
||||||
import TButton from "../../Inputs/TButton.tsx";
|
import TButton from '../../Inputs/TButton.tsx';
|
||||||
import MangaConnectorIcon from "../MangaConnectorIcon.tsx";
|
import MangaConnectorIcon from '../MangaConnectorIcon.tsx';
|
||||||
import {FileLibrary, Manga, MangaConnectorId} from "../../../api/data-contracts.ts";
|
import { FileLibrary, Manga, MangaConnectorId } from '../../../api/data-contracts.ts';
|
||||||
import {FileLibraryContext} from "../../../contexts/FileLibraryContext.tsx";
|
import { FileLibraryContext } from '../../../contexts/FileLibraryContext.tsx';
|
||||||
|
|
||||||
export default function DownloadSection (props: DownloadSectionProps) : ReactNode {
|
export default function DownloadSection(props: DownloadSectionProps): ReactNode {
|
||||||
const Libraries = useContext(FileLibraryContext);
|
const Libraries = useContext(FileLibraryContext);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -64,13 +65,9 @@ export default function DownloadSection (props: DownloadSectionProps) : ReactNod
|
|||||||
gap: 5,
|
gap: 5,
|
||||||
}}>
|
}}>
|
||||||
<MangaConnectorIcon
|
<MangaConnectorIcon
|
||||||
mangaConnectorName={
|
mangaConnectorName={id.mangaConnectorName}
|
||||||
id.mangaConnectorName
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
<Typography>
|
<Typography>{id.mangaConnectorName}</Typography>
|
||||||
{id.mangaConnectorName}
|
|
||||||
</Typography>
|
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
@@ -1,21 +1,12 @@
|
|||||||
import { Dispatch, ReactNode, useContext, useEffect, useState } from 'react';
|
import { Dispatch, ReactNode, useContext, useEffect, useState } from 'react';
|
||||||
import {
|
import { Card, CardCover, Chip, Modal, ModalDialog, Stack, Typography, useTheme } from '@mui/joy';
|
||||||
Card,
|
|
||||||
CardCover,
|
|
||||||
Chip,
|
|
||||||
Modal,
|
|
||||||
ModalDialog,
|
|
||||||
Stack,
|
|
||||||
Typography,
|
|
||||||
useTheme,
|
|
||||||
} from '@mui/joy';
|
|
||||||
import ModalClose from '@mui/joy/ModalClose';
|
import ModalClose from '@mui/joy/ModalClose';
|
||||||
import { FileLibrary, Manga, MangaConnectorId } from '../../../api/data-contracts.ts';
|
import { FileLibrary, Manga, MangaConnectorId } from '../../../api/data-contracts.ts';
|
||||||
import { ApiContext } from '../../../contexts/ApiContext.tsx';
|
import { ApiContext } from '../../../contexts/ApiContext.tsx';
|
||||||
import { MangaContext } from '../../../contexts/MangaContext.tsx';
|
import { MangaContext } from '../../../contexts/MangaContext.tsx';
|
||||||
import { FileLibraryContext } from '../../../contexts/FileLibraryContext.tsx';
|
import { FileLibraryContext } from '../../../contexts/FileLibraryContext.tsx';
|
||||||
import MarkdownPreview from '@uiw/react-markdown-preview';
|
import MarkdownPreview from '@uiw/react-markdown-preview';
|
||||||
import DownloadSection from "./DownloadSection.tsx";
|
import DownloadSection from './DownloadSection.tsx';
|
||||||
|
|
||||||
export default function MangaDetail(props: MangaDetailProps): ReactNode {
|
export default function MangaDetail(props: MangaDetailProps): ReactNode {
|
||||||
const Api = useContext(ApiContext);
|
const Api = useContext(ApiContext);
|
||||||
@@ -139,9 +130,20 @@ export default function MangaDetail(props: MangaDetailProps): ReactNode {
|
|||||||
overflowY: 'auto',
|
overflowY: 'auto',
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
<Stack
|
||||||
|
direction={'row-reverse'}
|
||||||
|
gap={1}>
|
||||||
|
{props.children}
|
||||||
</Stack>
|
</Stack>
|
||||||
</Stack>
|
</Stack>
|
||||||
<DownloadSection downloadOpen={props.downloadOpen??false} library={library} onLibraryChange={onLibraryChange} downloadFromMap={downloadFromMap} setDownload={setDownload} />
|
</Stack>
|
||||||
|
<DownloadSection
|
||||||
|
downloadOpen={props.downloadOpen ?? false}
|
||||||
|
library={library}
|
||||||
|
onLibraryChange={onLibraryChange}
|
||||||
|
downloadFromMap={downloadFromMap}
|
||||||
|
setDownload={setDownload}
|
||||||
|
/>
|
||||||
</ModalDialog>
|
</ModalDialog>
|
||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
@@ -153,4 +155,5 @@ export interface MangaDetailProps {
|
|||||||
open: boolean;
|
open: boolean;
|
||||||
setOpen: Dispatch<boolean>;
|
setOpen: Dispatch<boolean>;
|
||||||
downloadOpen?: boolean;
|
downloadOpen?: boolean;
|
||||||
|
children?: ReactNode;
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
import { createRoot } from 'react-dom/client';
|
import { createRoot } from 'react-dom/client';
|
||||||
import './index.css';
|
import './index.css';
|
||||||
import App from './App.tsx';
|
import { App } from './App.tsx';
|
||||||
// @ts-expect-error font
|
// @ts-expect-error font
|
||||||
import '@fontsource/inter';
|
import '@fontsource/inter';
|
||||||
import { CssVarsProvider } from '@mui/joy/styles';
|
import { CssVarsProvider } from '@mui/joy/styles';
|
||||||
|
Reference in New Issue
Block a user