mirror of
https://gitea.tendokyu.moe/ppc/amnet.git
synced 2026-09-29 10:17:58 +03:00
remove redundant subcomponent
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import {Server, Trash} from "lucide-react";
|
||||
import {useNavigate} from "react-router-dom";
|
||||
import {useLiveQuery} from "dexie-react-hooks";
|
||||
import {Plus, Server, Trash} from "lucide-react";
|
||||
|
||||
import {AimeCard, db} from "@/lib/database";
|
||||
|
||||
@@ -20,39 +20,24 @@ import {CardCreationDialog} from "@/components/card-creation-form";
|
||||
import {IncognitoStorageWarning} from "@/components/incognito-warning";
|
||||
import {NoCardsNotification} from "@/components/no-cards-notification";
|
||||
|
||||
function CardAddButton() {
|
||||
function CardList(props: { cards: AimeCard[] | undefined }) {
|
||||
return (<>
|
||||
<IncognitoStorageWarning/>
|
||||
<CardCreationDialog>
|
||||
<Button className="bg-blue-500">
|
||||
<Plus className="mr-2 h-4 w-4"/> Add Card
|
||||
</Button>
|
||||
</CardCreationDialog>
|
||||
</>);
|
||||
}
|
||||
<CardCreationDialog/>
|
||||
|
||||
function CardList(props: { cards: AimeCard[] | undefined }) {
|
||||
if (!props.cards?.length) {
|
||||
return (<>
|
||||
<CardAddButton/>
|
||||
<NoCardsNotification/>
|
||||
</>);
|
||||
}
|
||||
|
||||
return (<>
|
||||
<CardAddButton/>
|
||||
|
||||
{props.cards.map(s =>
|
||||
<ContextMenu key={s.id}>
|
||||
<ContextMenuTrigger>
|
||||
<AimeCardEntry card={s}/>
|
||||
</ContextMenuTrigger>
|
||||
<ContextMenuContent>
|
||||
<ContextMenuItem className="text-red-500" onClick={() => db.cards.delete(s.id)}>
|
||||
<Trash className="mr-2 h-4 w-4"/> Remove
|
||||
</ContextMenuItem>
|
||||
</ContextMenuContent>
|
||||
</ContextMenu>)}
|
||||
{!props.cards?.length
|
||||
? <NoCardsNotification/>
|
||||
: props.cards.map(s =>
|
||||
<ContextMenu key={s.id}>
|
||||
<ContextMenuTrigger>
|
||||
<AimeCardEntry card={s}/>
|
||||
</ContextMenuTrigger>
|
||||
<ContextMenuContent>
|
||||
<ContextMenuItem className="text-red-500" onClick={() => db.cards.delete(s.id)}>
|
||||
<Trash className="mr-2 h-4 w-4"/> Remove
|
||||
</ContextMenuItem>
|
||||
</ContextMenuContent>
|
||||
</ContextMenu>)}
|
||||
</>);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user