Files
Open-Assistant/website/src/components/Messages/ReportPopup.tsx
T
356fd775e9 Add emoji reactions and reporting for messages (website) (#952)
* website: Move labelling to message ... menu and add reporting and emoji reactions

We can add more emoji easily in future, we just need to pick ones that we have consistent icons for.

Also added "open in new tab" option so that messages can be navigated to from tasks on mobile.

* website: Make new label and report strings translatable.

* website: Move report api call to oasst client

* small fixes

* pre-commit

---------

Co-authored-by: AbdBarho <ka70911@gmail.com>
2023-01-27 20:52:40 +01:00

57 lines
1.3 KiB
TypeScript

import {
Button,
Modal,
ModalBody,
ModalCloseButton,
ModalContent,
ModalFooter,
ModalHeader,
ModalOverlay,
Textarea,
} from "@chakra-ui/react";
import { useTranslation } from "next-i18next";
import { useState } from "react";
import { post } from "src/lib/api";
import useSWRMutation from "swr/mutation";
interface ReportPopupProps {
messageId: string;
show: boolean;
onClose: () => void;
}
export const ReportPopup = ({ messageId, show, onClose }: ReportPopupProps) => {
const { t } = useTranslation("message");
const [text, setText] = useState("");
const { trigger } = useSWRMutation("/api/report", post);
const submit = () => {
trigger({
message_id: messageId,
text,
});
setText("");
onClose();
};
return (
<Modal isOpen={show} onClose={onClose}>
<ModalOverlay />
<ModalContent>
<ModalHeader>{t("report_title")}</ModalHeader>
<ModalCloseButton />
<ModalBody>
<Textarea onChange={(e) => setText(e.target.value)} resize="none" placeholder={t("report_placeholder")} />
</ModalBody>
<ModalFooter>
<Button colorScheme="blue" mr={3} onClick={submit}>
{t("send_report")}
</Button>
</ModalFooter>
</ModalContent>
</Modal>
);
};