* refactor: update Next.js and React.js * refactor: update Next.js images * refactor: update ESLint rules and fix warnings/errors * fix: remove old intl polyfill * fix: add proper size to next/image components * fix: adjust full-size for next/image components * fix: temporary allow all domains for image optimization * build: fixes an issue where dev env could lead to javascript heap out of memory * fix: resolve webpack cache issue with country-flag-icons * refactor: switch compiler from Babel to SWC * fix: resize logo in sidebar * fix: break word on long path to avoid text overflow * chore: added sharp for production image optimisation * fix: change extract script for i18n to a custom script * fix: resolve GitHub CodeQL alert * chore: temporarily remove builds for ARMv7 * fix: resize avatar images * refactor: update Node.js to v20 * fix: resolve various UI issues * build: migrate yarn to pnpm and restrict engine to node@^20.0.0 * ci: specify the pnpm version to use in workflow actions * ci: fix typo in pnpm action-setup for cypress workflow * test(cypress): use pnpm instead of yarn * style: ran prettier on pnpm-lock * ci(cypress): setup nodejs v20 in cypress workflow * ci: pnpm cache to reduce install time * ci: use sh shell to get pnpm store directory * build(dockerfile): migrate to pnpm from yarn in docker builds * build(dockerfile): copy the proper pnpm lockfile * build: install pnpm for all platforms * build(dockerfile): remove unnecessary `&&` on apk installation steps * build: migrate pnpm 8 to 9 * build(dockerfile): add node-gyp back in * build(dockerfile): install node-gyp through npm * build(dockerfile): ignore scripts to not run husky install when devdependencies are pruned * build: migrate to pnpm from yarn * chore: remove a section that is no longer relevant --------- Co-authored-by: fallenbagel <98979876+Fallenbagel@users.noreply.github.com>
133 lines
4.6 KiB
TypeScript
133 lines
4.6 KiB
TypeScript
import Button from '@app/components/Common/Button';
|
|
import globalMessages from '@app/i18n/globalMessages';
|
|
import defineMessages from '@app/utils/defineMessages';
|
|
import { CheckIcon, TrashIcon } from '@heroicons/react/24/solid';
|
|
import axios from 'axios';
|
|
import { useIntl } from 'react-intl';
|
|
import { mutate } from 'swr';
|
|
|
|
interface ErrorCardProps {
|
|
id: number;
|
|
tmdbId: number;
|
|
tvdbId?: number;
|
|
type: 'movie' | 'tv';
|
|
canExpand?: boolean;
|
|
}
|
|
|
|
const messages = defineMessages('components.TitleCard', {
|
|
mediaerror: '{mediaType} Not Found',
|
|
tmdbid: 'TMDB ID',
|
|
tvdbid: 'TheTVDB ID',
|
|
cleardata: 'Clear Data',
|
|
});
|
|
|
|
const Error = ({ id, tmdbId, tvdbId, type, canExpand }: ErrorCardProps) => {
|
|
const intl = useIntl();
|
|
|
|
const deleteMedia = async () => {
|
|
await axios.delete(`/api/v1/media/${id}`);
|
|
mutate('/api/v1/media?filter=allavailable&take=20&sort=mediaAdded');
|
|
mutate('/api/v1/request?filter=all&take=10&sort=modified&skip=0');
|
|
};
|
|
|
|
return (
|
|
<div
|
|
className={canExpand ? 'w-full' : 'w-36 sm:w-36 md:w-44'}
|
|
data-testid="title-card"
|
|
>
|
|
<div
|
|
className="relative transform-gpu cursor-default overflow-hidden rounded-xl bg-gray-800 bg-cover shadow outline-none ring-1 ring-gray-700 transition duration-300"
|
|
style={{
|
|
paddingBottom: '150%',
|
|
}}
|
|
>
|
|
<div className="absolute inset-0 h-full w-full overflow-hidden">
|
|
<div className="absolute left-0 right-0 flex items-center justify-between p-2">
|
|
<div
|
|
className={`pointer-events-none z-40 rounded-full shadow ${
|
|
type === 'movie' ? 'bg-blue-500' : 'bg-purple-600'
|
|
}`}
|
|
>
|
|
<div className="flex h-4 items-center px-2 py-2 text-center text-xs font-medium uppercase tracking-wider text-white sm:h-5">
|
|
{type === 'movie'
|
|
? intl.formatMessage(globalMessages.movie)
|
|
: intl.formatMessage(globalMessages.tvshow)}
|
|
</div>
|
|
</div>
|
|
<div className="pointer-events-none z-40">
|
|
<div className="flex h-4 w-4 items-center justify-center rounded-full bg-green-400 text-white shadow sm:h-5 sm:w-5">
|
|
<CheckIcon className="h-3 w-3 sm:h-4 sm:w-4" />
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div className="flex h-full w-full items-end">
|
|
<div className="px-2 pb-11 text-white">
|
|
<h1
|
|
className="whitespace-normal text-xl font-bold leading-tight"
|
|
style={{
|
|
WebkitLineClamp: 3,
|
|
display: '-webkit-box',
|
|
overflow: 'hidden',
|
|
WebkitBoxOrient: 'vertical',
|
|
wordBreak: 'break-word',
|
|
}}
|
|
data-testid="title-card-title"
|
|
>
|
|
{intl.formatMessage(messages.mediaerror, {
|
|
mediaType: intl.formatMessage(
|
|
type === 'movie'
|
|
? globalMessages.movie
|
|
: globalMessages.tvshow
|
|
),
|
|
})}
|
|
</h1>
|
|
<div
|
|
className="whitespace-normal text-xs"
|
|
style={{
|
|
WebkitLineClamp: 3,
|
|
display: '-webkit-box',
|
|
overflow: 'hidden',
|
|
WebkitBoxOrient: 'vertical',
|
|
wordBreak: 'break-word',
|
|
}}
|
|
>
|
|
<div className="flex items-center">
|
|
<span className="mr-2 font-bold text-gray-400">
|
|
{intl.formatMessage(messages.tmdbid)}
|
|
</span>
|
|
{tmdbId}
|
|
</div>
|
|
{!!tvdbId && (
|
|
<div className="mt-2 flex items-center sm:mt-1">
|
|
<span className="mr-2 font-bold text-gray-400">
|
|
{intl.formatMessage(messages.tvdbid)}
|
|
</span>
|
|
{tvdbId}
|
|
</div>
|
|
)}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div className="absolute bottom-0 left-0 right-0 flex justify-between px-2 py-2">
|
|
<Button
|
|
buttonType="danger"
|
|
buttonSize="sm"
|
|
onClick={(e) => {
|
|
e.preventDefault();
|
|
deleteMedia();
|
|
}}
|
|
className="h-7 w-full"
|
|
>
|
|
<TrashIcon />
|
|
<span>{intl.formatMessage(messages.cleardata)}</span>
|
|
</Button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
};
|
|
export default Error;
|