2025-02-13 16:52:36 +00:00
|
|
|
import { defineMessages, useIntl } from 'react-intl';
|
|
|
|
|
|
|
|
import List, { ListItem } from 'soapbox/components/list.tsx';
|
|
|
|
import { Card, CardBody, CardHeader, CardTitle } from 'soapbox/components/ui/card.tsx';
|
|
|
|
import { Column } from 'soapbox/components/ui/column.tsx';
|
2025-02-20 23:55:01 +00:00
|
|
|
import Spinner from 'soapbox/components/ui/spinner.tsx';
|
|
|
|
import Stack from 'soapbox/components/ui/stack.tsx';
|
2025-03-15 18:12:31 +00:00
|
|
|
import { SelectDropdown } from 'soapbox/features/forms/index.tsx';
|
2025-03-18 14:19:30 +00:00
|
|
|
import Balance from 'soapbox/features/wallet/components/balance.tsx';
|
|
|
|
import CreateWallet from 'soapbox/features/wallet/components/create-wallet.tsx';
|
|
|
|
import Transactions from 'soapbox/features/wallet/components/transactions.tsx';
|
2025-03-21 19:51:17 +00:00
|
|
|
import { useWallet } from 'soapbox/features/zap/hooks/useHooks.ts';
|
2025-03-15 18:12:31 +00:00
|
|
|
import { usePaymentMethod } from 'soapbox/features/zap/usePaymentMethod.ts';
|
2025-02-13 16:52:36 +00:00
|
|
|
import { useOwnAccount } from 'soapbox/hooks/useOwnAccount.ts';
|
|
|
|
|
|
|
|
|
|
|
|
const messages = defineMessages({
|
2025-03-18 14:19:30 +00:00
|
|
|
payment: { id: 'wallet.payment', defaultMessage: 'Payment Method' },
|
2025-03-21 19:51:17 +00:00
|
|
|
relays: { id: 'wallet.relays', defaultMessage: 'Wallet Relays' },
|
2025-03-18 14:19:30 +00:00
|
|
|
transactions: { id: 'wallet.transactions', defaultMessage: 'Transactions' },
|
|
|
|
wallet: { id: 'wallet', defaultMessage: 'Wallet' },
|
|
|
|
management: { id: 'wallet.management', defaultMessage: 'Wallet Management' },
|
|
|
|
mints: { id: 'wallet.mints', defaultMessage: 'Mints' },
|
2025-02-13 16:52:36 +00:00
|
|
|
});
|
|
|
|
|
2025-03-15 18:12:31 +00:00
|
|
|
const paymentMethods = {
|
|
|
|
zap: 'zap',
|
|
|
|
cashu: 'cashu',
|
|
|
|
};
|
|
|
|
|
2025-02-18 02:03:20 +00:00
|
|
|
/** User Wallet page. */
|
2025-03-18 14:19:30 +00:00
|
|
|
const Wallet = () => {
|
2025-02-13 16:52:36 +00:00
|
|
|
const intl = useIntl();
|
|
|
|
|
|
|
|
const { account } = useOwnAccount();
|
2025-03-21 19:51:17 +00:00
|
|
|
const { wallet: walletData, isLoading } = useWallet();
|
2025-03-15 18:12:31 +00:00
|
|
|
const { method, changeMethod } = usePaymentMethod();
|
2025-02-18 02:03:20 +00:00
|
|
|
|
2025-02-13 16:52:36 +00:00
|
|
|
if (!account) return null;
|
|
|
|
|
|
|
|
return (
|
2025-02-20 23:55:01 +00:00
|
|
|
<>
|
|
|
|
{isLoading ?
|
|
|
|
<Stack className='h-screen justify-center'>
|
|
|
|
<Spinner size={40} withText={false} />
|
|
|
|
</Stack>
|
|
|
|
:
|
|
|
|
(
|
2025-03-18 14:19:30 +00:00
|
|
|
<Column label={intl.formatMessage(messages.wallet)} transparent withHeader={false} slim>
|
2025-02-20 23:55:01 +00:00
|
|
|
<Card className='space-y-4'>
|
|
|
|
<CardHeader>
|
2025-03-18 14:19:30 +00:00
|
|
|
<CardTitle title={intl.formatMessage(messages.wallet)} />
|
2025-02-20 23:55:01 +00:00
|
|
|
</CardHeader>
|
|
|
|
|
|
|
|
{walletData ? (
|
|
|
|
<>
|
|
|
|
<CardBody>
|
2025-03-12 18:31:48 +00:00
|
|
|
<Balance />
|
2025-02-20 23:55:01 +00:00
|
|
|
</CardBody>
|
|
|
|
|
|
|
|
<CardHeader>
|
|
|
|
<CardTitle title={intl.formatMessage(messages.transactions)} />
|
|
|
|
</CardHeader>
|
|
|
|
|
|
|
|
<CardBody>
|
|
|
|
<Transactions />
|
|
|
|
</CardBody>
|
|
|
|
|
|
|
|
<CardHeader>
|
|
|
|
<CardTitle title={intl.formatMessage(messages.management)} />
|
|
|
|
</CardHeader>
|
|
|
|
|
|
|
|
<CardBody>
|
|
|
|
<List>
|
2025-03-19 00:41:57 +00:00
|
|
|
<ListItem label={intl.formatMessage(messages.mints)} to='/wallet-mints' />
|
|
|
|
<ListItem label={intl.formatMessage(messages.relays)} to='/wallet-relays' />
|
2025-03-15 18:12:31 +00:00
|
|
|
<ListItem label={intl.formatMessage(messages.payment)} >
|
|
|
|
<SelectDropdown
|
|
|
|
className='max-w-[200px]'
|
|
|
|
items={paymentMethods}
|
|
|
|
defaultValue={method}
|
|
|
|
onChange={(event: React.ChangeEvent<HTMLSelectElement>) => {
|
|
|
|
changeMethod((event.target.value as 'cashu' | 'zap'));
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</ListItem>
|
2025-02-20 23:55:01 +00:00
|
|
|
</List>
|
|
|
|
</CardBody>
|
|
|
|
|
|
|
|
</>
|
|
|
|
)
|
|
|
|
:
|
|
|
|
<>
|
|
|
|
<CardBody>
|
2025-03-20 19:58:52 +00:00
|
|
|
<CreateWallet />
|
2025-02-20 23:55:01 +00:00
|
|
|
</CardBody>
|
|
|
|
|
|
|
|
</>
|
|
|
|
}
|
|
|
|
</Card>
|
|
|
|
</Column>
|
2025-02-13 16:52:36 +00:00
|
|
|
)
|
2025-02-20 23:55:01 +00:00
|
|
|
}
|
|
|
|
</>
|
2025-02-13 16:52:36 +00:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2025-03-18 14:19:30 +00:00
|
|
|
export default Wallet;
|