Commit 2849c472 authored by Chunchi Che's avatar Chunchi Che

handle create new deck

parent 82fcc0a7
Pipeline #23054 passed with stages
in 12 minutes and 53 seconds
......@@ -5,7 +5,15 @@ import {
PlusOutlined,
UploadOutlined,
} from "@ant-design/icons";
import { App, Button, Dropdown, MenuProps, Upload, UploadProps } from "antd";
import {
App,
Button,
Dropdown,
Input,
MenuProps,
Upload,
UploadProps,
} from "antd";
import React, { useRef, useState } from "react";
import YGOProDeck from "ygopro-deck-encode";
......@@ -22,13 +30,38 @@ export const DeckSelect: React.FC<{
onAdd: () => void;
}> = ({ decks, selected, onSelect, onDelete, onDownload, onAdd }) => {
const newDeck = useRef<IDeck | null>(null);
const newDeckName = useRef<string | null>(null);
const { modal } = App.useApp();
const modalProps = { width: 500, centered: true, icon: null };
const showCreateModal = () => {
const { destroy } = modal.info({
...modalProps,
title: "请输入新卡组名称",
content: (
<Input
onChange={(e) => {
newDeckName.current = e.target.value;
}}
/>
),
okText: "新建",
onCancel: () => destroy(),
onOk: async () => {
if (newDeckName.current && newDeckName.current !== "") {
await deckStore.add({
deckName: newDeckName.current,
main: [],
extra: [],
side: [],
});
}
},
});
};
const showUploadModal = () => {
const { destroy } = modal.info({
width: 500,
centered: true,
...modalProps,
title: "请上传YDK文件",
icon: null,
content: (
<DeckUploader
onLoaded={(deck) => {
......@@ -51,7 +84,7 @@ export const DeckSelect: React.FC<{
key: "1",
label: "新建卡组",
icon: <PlusOutlined />,
onClick: () => {},
onClick: showCreateModal,
},
{
key: "2",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment