import { Trans } from "@lingui/react/macro" import { Button, Code, Group, Modal, Slider, Stack, Text } from "@mantine/core" import { setMarkAllAsReadConfirmationDialogOpen } from "app/entries/slice" import { markAllEntries } from "app/entries/thunks" import { useAppDispatch, useAppSelector } from "app/store" import { useState } from "react" export function MarkAllAsReadConfirmationDialog() { const [threshold, setThreshold] = useState(0) const open = useAppSelector(state => state.entries.markAllAsReadConfirmationDialogOpen) const source = useAppSelector(state => state.entries.source) const sourceLabel = useAppSelector(state => state.entries.sourceLabel) const entriesTimestamp = useAppSelector(state => state.entries.timestamp) ?? Date.now() const dispatch = useAppDispatch() const onConfirm = () => { dispatch( markAllEntries({ sourceType: source.type, req: { id: source.id, read: true, olderThan: Date.now() - threshold * 24 * 60 * 60 * 1000, insertedBefore: entriesTimestamp, }, }) ) dispatch(setMarkAllAsReadConfirmationDialogOpen(false)) } return ( dispatch(setMarkAllAsReadConfirmationDialogOpen(false))} title={Mark all entries as read} > {threshold === 0 && ( Are you sure you want to mark all entries of {sourceLabel} as read? )} {threshold > 0 && ( Are you sure you want to mark entries older than {threshold} days of {sourceLabel} as read? )} e.key === "Enter" && onConfirm()} /> ) }