import differenceInDays from "date-fns/differenceInDays"; import { TrashIcon, ArchiveIcon, ShapesIcon, InputIcon } from "outline-icons"; import * as React from "react"; import { Trans, useTranslation } from "react-i18next"; import styled from "styled-components"; import Document from "~/models/Document"; import ErrorBoundary from "~/components/ErrorBoundary"; import Notice from "~/components/Notice"; import Time from "~/components/Time"; type Props = { document: Document; readOnly: boolean; }; function Days(props: { dateTime: string }) { const { t } = useTranslation(); const days = differenceInDays(new Date(props.dateTime), new Date()); return ( <> {t(`{{ count }} days`, { count: days, })} ); } export default function Notices({ document, readOnly }: Props) { const { t } = useTranslation(); function permanentlyDeletedDescription() { if (!document.permanentlyDeletedAt) { return; } return document.template ? ( This template will be permanently deleted in{" "} unless restored. ) : ( This document will be permanently deleted in{" "} unless restored. ); } return ( {document.isTemplate && !readOnly && ( } description={ Highlight some text and use the control to add placeholders that can be filled out when creating new documents } > {t("You’re editing a template")} )} {document.archivedAt && !document.deletedAt && ( }> {t("Archived by {{userName}}", { userName: document.updatedBy?.name ?? t("Unknown"), })}   )} {document.deletedAt && ( } description={permanentlyDeletedDescription()} > {t("Deleted by {{userName}}", { userName: document.updatedBy?.name ?? t("Unknown"), })}   )} ); } const PlaceholderIcon = styled(InputIcon)` position: relative; top: 6px; margin-top: -6px; `;