import { useQuery } from '@apollo/client' import Link from 'next/link' import { Table } from 'react-bootstrap' import { getGetServerSideProps } from '../api/ssrApollo' import Layout from '../components/layout' import { useMe } from '../components/me' import MoreFooter from '../components/more-footer' import UserHeader from '../components/user-header' import { WALLET_HISTORY } from '../fragments/wallet' import styles from '../styles/satistics.module.css' import Moon from '../svgs/moon-fill.svg' import Check from '../svgs/check-double-line.svg' import ThumbDown from '../svgs/thumb-down-fill.svg' import { Checkbox, Form } from '../components/form' import { useRouter } from 'next/router' import Item from '../components/item' import Comment from '../components/comment' export const getServerSideProps = getGetServerSideProps(WALLET_HISTORY) function satusClass (status) { if (!status) { return '' } switch (status) { case 'CONFIRMED': return '' case 'PENDING': return 'text-muted' default: return styles.failed } } function Satus ({ status }) { if (!status) { return null } const desc = () => { switch (status) { case 'CONFIRMED': return 'confirmed' case 'EXPIRED': return 'expired' case 'INSUFFICIENT_BALANCE': return "you didn't have enough sats" case 'INVALID_PAYMENT': return 'invalid payment' case 'PATHFINDING_TIMEOUT': case 'ROUTE_NOT_FOUND': return 'no route found' case 'PENDING': return 'pending' default: return 'unknown failure' } } const color = () => { switch (status) { case 'CONFIRMED': return 'success' case 'PENDING': return 'muted' default: return 'danger' } } const Icon = () => { switch (status) { case 'CONFIRMED': return case 'PENDING': return default: return } } return (
{' ' + desc()}
) } function Detail ({ fact }) { if (fact.type === 'earn') { return ( <>
SN gives the sats it earns back to its best users daily. These sats come from jobs, boost, and posting fees.
) } if (!fact.item) { return ( <>
{fact.description || 'no description'}
) } if (fact.item.title) { return
} return
} export default function Satistics ({ data: { walletHistory: { facts, cursor } } }) { const me = useMe() const router = useRouter() const { data, fetchMore } = useQuery(WALLET_HISTORY, { variables: { inc: router.query.inc } }) function filterRoutePush (filter, add) { const inc = new Set(router.query.inc?.split(',')) inc.delete('') // depending on addrem, add or remove filter if (add) { inc.add(filter) } else { inc.delete(filter) } const incstr = [...inc].join(',') router.push(`/satistics?inc=${incstr}`) } function included (filter) { const inc = new Set(router.query.inc?.split(',')) return inc.has(filter) } function href (fact) { switch (fact.type) { case 'withdrawal': case 'invoice': return `/${fact.type}s/${fact.factId}` default: return `/items/${fact.factId}` } } if (data) { ({ walletHistory: { facts, cursor } } = data) } const SatisticsSkeleton = () => (
) return (
filterRoutePush('invoice', c)} /> filterRoutePush('withdrawal', c)} /> filterRoutePush('stacked', c)} /> filterRoutePush('spent', c)} />
{facts.map((f, i) => ( ))}
type detail sats
{f.type} {f.msats / 1000}
) }