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';
|
|
|
|
|
import CardContent from '@mui/material/CardContent';
|
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 Avatar from '@mui/material/Avatar';
|
|
|
|
|
import Typography from '@mui/material/Typography';
|
|
|
|
|
import { Link } from 'react-router-dom';
|
2024-09-29 15:19:06 +02:00
|
|
|
import { useTranslation } from 'react-i18next';
|
2024-10-05 16:09:34 +02:00
|
|
|
import { requestManager } from '@/lib/requests/requests/RequestManager.ts';
|
2024-01-26 20:50:51 +01:00
|
|
|
import { GetMigratableSourcesQuery } from '@/lib/graphql/generated/graphql.ts';
|
2024-10-05 21:29:50 +02:00
|
|
|
import { translateExtensionLanguage } from '@/modules/extension/services/Extensions.ts';
|
2024-10-05 16:09:34 +02:00
|
|
|
import { SpinnerImage } from '@/modules/core/components/SpinnerImage.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) => {
|
|
|
|
|
const { t } = useTranslation();
|
|
|
|
|
|
|
|
|
|
const isLocalSource = Number(id) === 0;
|
|
|
|
|
const sourceName = isLocalSource ? t('source.local_source.title') : name;
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Card>
|
|
|
|
|
<CardActionArea component={Link} to={`/migrate/source/${id}/`}>
|
|
|
|
|
<CardContent
|
|
|
|
|
sx={{
|
|
|
|
|
display: 'flex',
|
|
|
|
|
justifyContent: 'space-between',
|
|
|
|
|
alignItems: 'center',
|
|
|
|
|
p: 1.5,
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Box sx={{ display: 'flex' }}>
|
|
|
|
|
<Avatar
|
|
|
|
|
variant="rounded"
|
2024-09-03 17:15:47 +02:00
|
|
|
sx={{
|
2024-09-29 15:19:06 +02:00
|
|
|
width: 56,
|
|
|
|
|
height: 56,
|
|
|
|
|
flex: '0 0 auto',
|
|
|
|
|
mr: 1,
|
|
|
|
|
background: 'transparent',
|
2024-09-03 17:15:47 +02:00
|
|
|
}}
|
|
|
|
|
>
|
2024-09-29 15:19:06 +02:00
|
|
|
<SpinnerImage
|
|
|
|
|
spinnerStyle={{ small: true }}
|
|
|
|
|
imgStyle={{ objectFit: 'cover', width: '100%', height: '100%' }}
|
|
|
|
|
alt={sourceName}
|
|
|
|
|
src={requestManager.getValidImgUrlFor(iconUrl)}
|
|
|
|
|
/>
|
|
|
|
|
</Avatar>
|
|
|
|
|
<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} />
|
|
|
|
|
</CardContent>
|
|
|
|
|
</CardActionArea>
|
|
|
|
|
</Card>
|
|
|
|
|
);
|
|
|
|
|
};
|