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';
|
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';
|
2025-08-15 22:02:58 +02:00
|
|
|
import { translateExtensionLanguage } from '@/features/extension/Extensions.utils.ts';
|
2026-03-13 22:41:28 +01:00
|
|
|
import { MigrationManager } from '@/features/migration/MigrationManager.ts';
|
2025-08-16 02:48:46 +02:00
|
|
|
import { ListCardAvatar } from '@/base/components/lists/cards/ListCardAvatar.tsx';
|
|
|
|
|
import { ListCardContent } from '@/base/components/lists/cards/ListCardContent.tsx';
|
2026-04-23 15:18:35 +02:00
|
|
|
import { Sources } from '@/features/source/services/Sources';
|
|
|
|
|
import type { TMigratableSource } from '@/features/migration/Migration.types.ts';
|
|
|
|
|
import { ReactRouter } from '@/lib/react-router/ReactRouter.ts';
|
|
|
|
|
import { AppRoutes } from '@/base/AppRoute.constants.ts';
|
2024-01-26 20:50:51 +01:00
|
|
|
|
2026-04-23 15:18:35 +02:00
|
|
|
export const MigrationCard = (source: TMigratableSource) => {
|
|
|
|
|
const { id, name, lang, iconUrl, mangaCount } = source;
|
2026-01-10 19:45:02 +01:00
|
|
|
const { t } = useLingui();
|
2024-09-29 15:19:06 +02:00
|
|
|
|
2026-04-23 15:18:35 +02:00
|
|
|
const sourceName = Sources.isLocalSource(source) ? t`Local source` : name;
|
2024-09-29 15:19:06 +02:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Card>
|
2026-04-23 15:18:35 +02:00
|
|
|
<CardActionArea
|
|
|
|
|
onClick={() => {
|
|
|
|
|
MigrationManager.selectSources([id]);
|
|
|
|
|
ReactRouter.navigate(AppRoutes.migrate.path);
|
|
|
|
|
}}
|
|
|
|
|
>
|
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>
|
|
|
|
|
);
|
|
|
|
|
};
|