2024-01-26 20:50:51 +01:00
|
|
|
/*
|
|
|
|
|
* Copyright (C) Contributors to the Suwayomi project
|
|
|
|
|
*
|
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import Card from '@mui/material/Card';
|
2024-04-14 15:50:12 +02:00
|
|
|
import Box from '@mui/material/Box';
|
|
|
|
|
import CardActionArea from '@mui/material/CardActionArea';
|
|
|
|
|
import Chip from '@mui/material/Chip';
|
2024-01-26 20:50:51 +01:00
|
|
|
import Typography from '@mui/material/Typography';
|
|
|
|
|
import { Link } from 'react-router-dom';
|
2026-01-10 19:45:02 +01:00
|
|
|
import { useLingui } from '@lingui/react/macro';
|
2024-10-06 01:27:51 +02:00
|
|
|
import { requestManager } from '@/lib/requests/RequestManager.ts';
|
2026-03-11 00:11:29 +01:00
|
|
|
import type { GetMigratableSourcesQuery } from '@/lib/graphql/generated/graphql.ts';
|
2025-08-15 22:02:58 +02:00
|
|
|
import { translateExtensionLanguage } from '@/features/extension/Extensions.utils.ts';
|
2025-08-16 02:48:46 +02:00
|
|
|
import { AppRoutes } from '@/base/AppRoute.constants.ts';
|
|
|
|
|
import { ListCardAvatar } from '@/base/components/lists/cards/ListCardAvatar.tsx';
|
|
|
|
|
import { ListCardContent } from '@/base/components/lists/cards/ListCardContent.tsx';
|
2024-01-26 20:50:51 +01:00
|
|
|
|
|
|
|
|
export type TMigratableSource = NonNullable<GetMigratableSourcesQuery['mangas']['nodes'][number]['source']> & {
|
|
|
|
|
mangaCount: number;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// TODO - cleanup source/extension components
|
2024-09-29 15:19:06 +02:00
|
|
|
export const MigrationCard = ({ id, name, lang, iconUrl, mangaCount }: TMigratableSource) => {
|
2026-01-10 19:45:02 +01:00
|
|
|
const { t } = useLingui();
|
2024-09-29 15:19:06 +02:00
|
|
|
|
|
|
|
|
const isLocalSource = Number(id) === 0;
|
2026-01-10 19:45:02 +01:00
|
|
|
const sourceName = isLocalSource ? t`Local source` : name;
|
2024-09-29 15:19:06 +02:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Card>
|
2024-12-11 20:10:59 +01:00
|
|
|
<CardActionArea component={Link} to={AppRoutes.migrate.path(id)}>
|
2025-04-25 01:05:43 +02:00
|
|
|
<ListCardContent sx={{ justifyContent: 'space-between' }}>
|
2025-04-25 00:50:51 +02:00
|
|
|
<Box sx={{ display: 'flex', gap: 1 }}>
|
2025-11-22 17:28:56 +01:00
|
|
|
<ListCardAvatar
|
|
|
|
|
iconUrl={requestManager.getValidImgUrlFor(iconUrl)}
|
|
|
|
|
alt={sourceName}
|
|
|
|
|
slots={{
|
|
|
|
|
spinnerImageProps: {
|
|
|
|
|
ignoreQueue: true,
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
/>
|
2024-09-29 15:19:06 +02:00
|
|
|
<Box sx={{ display: 'flex', flexDirection: 'column', justifyContent: 'center' }}>
|
|
|
|
|
<Typography variant="h6" component="h3">
|
|
|
|
|
{sourceName}
|
|
|
|
|
</Typography>
|
|
|
|
|
<Typography
|
|
|
|
|
variant="caption"
|
|
|
|
|
sx={{
|
|
|
|
|
display: 'block',
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{translateExtensionLanguage(lang)}
|
|
|
|
|
</Typography>
|
|
|
|
|
</Box>
|
2024-01-26 20:50:51 +01:00
|
|
|
</Box>
|
2024-09-29 15:19:06 +02:00
|
|
|
<Chip sx={{ borderRadius: 1 }} size="small" label={mangaCount} />
|
2025-04-25 01:05:43 +02:00
|
|
|
</ListCardContent>
|
2024-09-29 15:19:06 +02:00
|
|
|
</CardActionArea>
|
|
|
|
|
</Card>
|
|
|
|
|
);
|
|
|
|
|
};
|