/* This file is part of GNU Taler (C) 2022 Taler Systems S.A. GNU Taler is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Taler; see the file COPYING. If not, see */ import { AbsoluteTime, AttentionInfo, AttentionType, } from "@gnu-taler/taler-util"; import { Fragment, h, VNode } from "preact"; import { Column, DateSeparator, HistoryRow, LargeText, SmallLightText, } from "../../components/styled/index.js"; import { Time } from "../../components/Time.js"; import { useTranslationContext } from "../../context/translation.js"; import { Avatar } from "../../mui/Avatar.js"; import { Button } from "../../mui/Button.js"; import { Grid } from "../../mui/Grid.js"; import { Pages } from "../../NavigationBar.js"; import { assertUnreachable } from "../../utils/index.js"; import { State } from "./index.js"; const term = 1000 * 60 * 60 * 24; function normalizeToDay(x: number): number { return Math.round(x / term) * term; } export function ReadyView({ list }: State.Ready): VNode { const { i18n } = useTranslationContext(); if (list.length < 1) { return (
No notification left
); } const byDate = list.reduce((rv, x) => { const theDate = x.when.t_ms === "never" ? 0 : normalizeToDay(x.when.t_ms); if (theDate) { (rv[theDate] = rv[theDate] || []).push(x); } return rv; }, {} as { [x: string]: typeof list }); const datesWithNotifications = Object.keys(byDate); return (
{datesWithNotifications.map((d, i) => { return ( {byDate[d].map((n, i) => ( ))} ); })}
); } function NotificationItem({ info, isRead, timestamp, }: { info: AttentionInfo; timestamp: AbsoluteTime; isRead: boolean; }): VNode { switch (info.type) { case AttentionType.KycWithdrawal: return ( ); case AttentionType.MerchantRefund: return ( ); case AttentionType.BackupUnpaid: return ( ); case AttentionType.AuditorDenominationsExpires: return
not implemented
; case AttentionType.AuditorKeyExpires: return
not implemented
; case AttentionType.AuditorTosChanged: return
not implemented
; case AttentionType.ExchangeDenominationsExpired: return
not implemented
; // case AttentionType.ExchangeDenominationsExpiresSoon: // return
not implemented
; case AttentionType.ExchangeKeyExpired: return
not implemented
; // case AttentionType.ExchangeKeyExpiresSoon: // return
not implemented
; case AttentionType.ExchangeTosChanged: return
not implemented
; case AttentionType.BackupExpiresSoon: return
not implemented
; case AttentionType.PushPaymentReceived: return
not implemented
; case AttentionType.PullPaymentPaid: return
not implemented
; default: assertUnreachable(info); } } function NotificationLayout(props: { title: string; href: string; subtitle?: string; timestamp: AbsoluteTime; iconPath: string; isRead: boolean; }): VNode { const { i18n } = useTranslationContext(); return ( {props.iconPath}
{props.title}
{props.subtitle && (
{props.subtitle}
)}
); }