import { useQuery } from '@apollo/client' import Link from 'next/link' import { getGetServerSideProps } from '../api/ssrApollo' 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 { Fragment } from 'react' import ItemJob from '../components/item-job' import PageLoading from '../components/page-loading' export const getServerSideProps = getGetServerSideProps(WALLET_HISTORY) 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.item) { return (
{fact.description || 'no invoice description'}
) } if (fact.item.title) { if (fact.item.isJob) { return } return } return } function Fact ({ fact }) { return ( <>
0 ? '' : 'text-muted'}`}>{fact.type}
0 ? '' : 'text-muted'}`}>{fact.sats}
) } 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 (

satistics

filterRoutePush('invoice', c)} /> filterRoutePush('withdrawal', c)} /> filterRoutePush('stacked', c)} /> filterRoutePush('spent', c)} />
type
detail
sats
{facts.map(f => )}
) }