Files
suwayomi-material-you-webui/src/components/tracker/TrackerCard.tsx

50 lines
1.3 KiB
TypeScript
Raw Normal View History

2024-03-10 17:36:22 +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 { TBaseTracker, TTrackRecord } from '@/lib/data/Trackers.ts';
import { TrackerUntrackedCard } from '@/components/tracker/TrackerUntrackedCard.tsx';
import { TrackerSearch } from '@/components/tracker/TrackerSearch.tsx';
import { TManga } from '@/typings.ts';
export enum TrackerMode {
UNTRACKED,
SEARCH,
INFO,
}
export const TrackerCard = ({
tracker,
mangaId,
trackRecord,
mode,
setSearchMode,
}: {
tracker: TBaseTracker;
mangaId: number;
trackRecord?: TTrackRecord;
mode: TrackerMode;
setSearchMode: (id?: number) => void;
}) => {
if (mode === TrackerMode.UNTRACKED) {
return <TrackerUntrackedCard tracker={tracker} onClick={() => setSearchMode(tracker.id)} />;
}
if (mode === TrackerMode.SEARCH) {
return (
<TrackerSearch
mangaId={mangaId}
tracker={tracker}
trackedId={trackRecord?.remoteId}
closeSearchMode={() => setSearchMode(undefined)}
/>
);
}
return 'tracked';
};