import { useQuery } from '@apollo/client' import Link from 'next/link' import { getGetServerSideProps } from '@/api/ssrApollo' import Nav from 'react-bootstrap/Nav' import Layout from '@/components/layout' import MoreFooter from '@/components/more-footer' 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 { CommentFlat } from '@/components/comment' import ItemJob from '@/components/item-job' import PageLoading from '@/components/page-loading' import PayerData from '@/components/payer-data' import { Badge } from 'react-bootstrap' import navStyles from '../settings/settings.module.css' export const getServerSideProps = getGetServerSideProps({ query: WALLET_HISTORY, authRequired: true }) function satusClass (status) { if (!status) { return '' } switch (status) { case 'CONFIRMED': return 'text-reset' case 'PENDING': return 'text-muted' default: return `${styles.failed} text-muted` } } function Satus ({ status }) { if (!status) { return null } let color = 'danger'; let desc switch (status) { case 'CONFIRMED': desc = 'confirmed' color = 'success' break case 'EXPIRED': desc = 'expired' color = 'muted' break case 'PENDING': desc = 'pending' color = 'muted' break case 'INSUFFICIENT_BALANCE': desc = "you didn't have enough sats" break case 'INVALID_PAYMENT': desc = 'invalid payment' break case 'PATHFINDING_TIMEOUT': case 'ROUTE_NOT_FOUND': desc = 'no route found' break default: return 'unknown failure' } const Icon = () => { switch (status) { case 'CONFIRMED': return case 'PENDING': return default: return } } return ( {desc} ) } function Detail ({ fact }) { if (fact.type === 'earn') { return ( SN distributes the sats it earns back to its best stackers daily. These sats come from jobs, boosts, posting fees, and donations. ) } if (fact.type === 'donation') { return (
You made a donation to daily rewards!
) } if (fact.type === 'referral') { return (
You stacked sats from a referral!
) } if (fact.type === 'billing') { return (
billing for ~{fact.subName}
) } if (fact.type === 'revenue') { return (
revenue for ~{fact.subName}
) } if (!fact.item) { let zap try { zap = JSON.parse(fact.description) } catch { } return (
{(!fact.bolt11 && invoice deleted) || (zap && nostr zap{zap.content && `: ${zap.content}`}) || (fact.description && {fact.description})} {fact.invoiceComment && sender says: {fact.invoiceComment}} {fact.autoWithdraw && autowithdraw}
) } if (fact.item.title) { if (fact.item.isJob) { return } return } return } function Fact ({ fact }) { const factDate = new Date(fact.createdAt) return ( <>
0 ? '' : 'text-muted'}`}>{fact.type}
{`${factDate.toLocaleDateString()} ${factDate.toLocaleTimeString()}`}
0 ? '' : 'text-muted'}`}>{fact.sats}
) } export function SatisticsHeader () { const router = useRouter() const pathParts = router.asPath.split('?')[0].split('/').filter(segment => !!segment) const activeKey = pathParts[1] ?? 'history' return ( <>

satistics

) } export default function Satistics ({ ssrData }) { const router = useRouter() const { data, fetchMore } = useQuery(WALLET_HISTORY, { variables: { inc: router.query.inc } }) if (!data && !ssrData) return 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) } const { walletHistory: { facts, cursor } } = data || ssrData return (
filterRoutePush('invoice', c)} /> filterRoutePush('withdrawal', c)} /> filterRoutePush('stacked', c)} /> filterRoutePush('spent', c)} />
type
detail
sats
{facts.map(f => )}
) }