Commit 707b88d2 authored by chechunchi's avatar chechunchi

add AnnounceModal

parent a65896ee
Pipeline #21829 passed with stages
in 14 minutes and 33 seconds
......@@ -2,6 +2,7 @@ import React from "react";
import {
Alert,
AnnounceModal,
CardListModal,
CardModal,
CheckCounterModal,
......@@ -28,6 +29,7 @@ const NeosDuel = () => {
<OptionModal />
<CheckCounterModal />
<SortCardModal />
<AnnounceModal />
</>
);
};
......
import { CheckCard } from "@ant-design/pro-components";
import { Button } from "antd";
import React, { useState } from "react";
import { useSnapshot } from "valtio";
import { sendSelectOptionResponse } from "@/api";
import { messageStore } from "@/stores";
import { DragModal } from "./DragModal";
const { announceModal } = messageStore;
export const AnnounceModal = () => {
const snap = useSnapshot(announceModal);
const isOpen = snap.isOpen;
const title = snap.title;
const min = snap.min;
const options = snap.options;
const [selected, setSelected] = useState<number[]>([]);
return (
<DragModal
title={title}
open={isOpen}
closable={false}
footer={
<Button
disabled={selected.length != min}
onClick={() => {
let response = selected.reduce((res, current) => res | current, 0); // 多个选择求或
sendSelectOptionResponse(response);
announceModal.isOpen = false;
announceModal.title = undefined;
announceModal.options = [];
}}
>
submit
</Button>
}
>
<CheckCard.Group
bordered
size="small"
onChange={(value: any) => {
setSelected(value);
}}
>
{options.map((option, idx) => (
<CheckCard key={idx} title={option.info} value={option.response} />
))}
</CheckCard.Group>
</DragModal>
);
};
export * from "./Alert";
export * from "./AnnounceModal";
export * from "./CardListModal";
export * from "./CardModal";
export * from "./CheckCounterModal";
......
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