import uniq from "lodash/uniq"; import { observer } from "mobx-react"; import * as React from "react"; import { Trans, useTranslation } from "react-i18next"; import { usePopoverState, PopoverDisclosure } from "reakit/Popover"; import { toast } from "sonner"; import styled from "styled-components"; import { s } from "@shared/styles"; import { IntegrationType } from "@shared/types"; import Collection from "~/models/Collection"; import Integration from "~/models/Integration"; import Button from "~/components/Button"; import ButtonLink from "~/components/ButtonLink"; import Flex from "~/components/Flex"; import CollectionIcon from "~/components/Icons/CollectionIcon"; import ListItem from "~/components/List/Item"; import Popover from "~/components/Popover"; import Switch from "~/components/Switch"; import Text from "~/components/Text"; type Props = { integration: Integration; collection: Collection; }; function SlackListItem({ integration, collection }: Props) { const { t } = useTranslation(); const handleChange = async (ev: React.ChangeEvent) => { if (ev.target.checked) { integration.events = uniq([...integration.events, ev.target.name]); } else { integration.events = integration.events.filter( (n) => n !== ev.target.name ); } await integration.save(); toast.success(t("Settings saved")); }; const mapping = { "documents.publish": t("document published"), "documents.update": t("document updated"), }; const popover = usePopoverState({ gutter: 0, placement: "bottom-start", }); return ( {collection.name} } subtitle={ <> {{ channelName }} channel on`} values={{ channelName: integration.settings.channel, events: integration.events.map((ev) => mapping[ev]).join(", "), }} components={{ em: , }} />{" "} {(props) => ( {integration.events.map((ev) => mapping[ev]).join(", ")} )}

{t("Notifications")}

{t("These events should be posted to Slack")}
} actions={ } /> ); } const Events = styled.div` color: ${s("text")}; margin-top: -12px; `; export default observer(SlackListItem);