Implement binding manga to tracker
This commit is contained in:
49
src/components/tracker/TrackerCard.tsx
Normal file
49
src/components/tracker/TrackerCard.tsx
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* 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';
|
||||
};
|
||||
Reference in New Issue
Block a user