mirror of
https://github.com/wassname/Open-Assistant.git
synced 2026-07-04 17:20:19 +08:00
f277e2da0f
Note: skipping is only half implemented for labelling and summarisation tasks as those probably need to be changed to use the new Task component.
64 lines
1.4 KiB
TypeScript
64 lines
1.4 KiB
TypeScript
import {
|
|
Button,
|
|
ButtonProps,
|
|
Menu,
|
|
MenuButton,
|
|
MenuItem,
|
|
MenuList,
|
|
Modal,
|
|
ModalBody,
|
|
ModalCloseButton,
|
|
ModalContent,
|
|
ModalFooter,
|
|
ModalHeader,
|
|
ModalOverlay,
|
|
Textarea,
|
|
useDisclosure,
|
|
} from "@chakra-ui/react";
|
|
import { useState } from "react";
|
|
import { FaChevronDown } from "react-icons/fa";
|
|
|
|
interface SkipButtonProps extends ButtonProps {
|
|
onSkip: (reason: string) => void;
|
|
}
|
|
|
|
export const SkipButton = ({ onSkip, ...props }: SkipButtonProps) => {
|
|
const { isOpen, onOpen: showModal, onClose: closeModal } = useDisclosure();
|
|
const [value, setValue] = useState("");
|
|
|
|
const onSubmit = () => {
|
|
onSkip(value);
|
|
setValue("");
|
|
closeModal();
|
|
};
|
|
|
|
return (
|
|
<>
|
|
<Button size="lg" variant="outline" onClick={showModal} {...props}>
|
|
Skip
|
|
</Button>
|
|
<Modal isOpen={isOpen} onClose={closeModal}>
|
|
<ModalOverlay />
|
|
<ModalContent>
|
|
<ModalHeader>Skip</ModalHeader>
|
|
<ModalCloseButton />
|
|
<ModalBody>
|
|
<Textarea
|
|
value={value}
|
|
onChange={(e) => setValue(e.target.value)}
|
|
resize="none"
|
|
placeholder="Any feedback on this task?"
|
|
/>
|
|
</ModalBody>
|
|
|
|
<ModalFooter>
|
|
<Button colorScheme="blue" mr={3} onClick={onSubmit}>
|
|
Send
|
|
</Button>
|
|
</ModalFooter>
|
|
</ModalContent>
|
|
</Modal>
|
|
</>
|
|
);
|
|
};
|