kopia lustrzana https://gitlab.com/soapbox-pub/soapbox
Refactor code and rename translated texts
rodzic
4e07c616d6
commit
a6e18421d3
|
@ -1,5 +1,3 @@
|
|||
// import IconButton from 'soapbox/components/ui/icon-button.tsx';
|
||||
import arrowBackIcon from '@tabler/icons/outline/arrow-back-up.svg';
|
||||
import cancelIcon from '@tabler/icons/outline/cancel.svg';
|
||||
import withdrawIcon from '@tabler/icons/outline/cash.svg';
|
||||
import mIcon from '@tabler/icons/outline/circle-dotted-letter-m.svg';
|
||||
|
@ -19,7 +17,7 @@ import Input from 'soapbox/components/ui/input.tsx';
|
|||
import Stack from 'soapbox/components/ui/stack.tsx';
|
||||
import Text from 'soapbox/components/ui/text.tsx';
|
||||
import { SelectDropdown } from 'soapbox/features/forms/index.tsx';
|
||||
import { useWallet } from 'soapbox/features/zap/hooks/useHooks.ts';
|
||||
import { useTransactions, useWallet } from 'soapbox/features/zap/hooks/useHooks.ts';
|
||||
import { useApi } from 'soapbox/hooks/useApi.ts';
|
||||
import { useOwnAccount } from 'soapbox/hooks/useOwnAccount.ts';
|
||||
import { Quote, quoteSchema } from 'soapbox/schemas/wallet.ts';
|
||||
|
@ -28,10 +26,11 @@ import toast from 'soapbox/toast.tsx';
|
|||
|
||||
|
||||
const messages = defineMessages({
|
||||
amount: { id: 'wallet.balance.mint.amount', defaultMessage: 'Amount in sats' },
|
||||
cancel: { id: 'wallet.button.cancel', defaultMessage: 'Cancel' },
|
||||
balance: { id: 'wallet.sats', defaultMessage: '{amount} sats' },
|
||||
withdraw: { id: 'wallet.balance.withdraw_button', defaultMessage: 'Withdraw' },
|
||||
exchange: { id: 'wallet.balance.exchange_button', defaultMessage: 'Exchange' },
|
||||
mint: { id: 'wallet.balance.mint_button', defaultMessage: 'Mint' },
|
||||
withdraw: { id: 'wallet.button.withdraw', defaultMessage: 'Withdraw' },
|
||||
mint: { id: 'wallet.button.mint', defaultMessage: 'Mint' },
|
||||
payment: { id: 'wallet.balance.mint.payment', defaultMessage: 'Make the payment to complete:' },
|
||||
paidMessage: { id: 'wallet.balance.mint.paid_message', defaultMessage: 'Your mint was successful, and your sats are now in your balance. Enjoy!' },
|
||||
unpaidMessage: { id: 'wallet.balance.mint.unpaid_message', defaultMessage: 'Your mint is still unpaid. Complete the payment to receive your sats.' },
|
||||
|
@ -91,10 +90,12 @@ const NewMint = ({ onBack, list }: NewMintProps) => {
|
|||
const api = useApi();
|
||||
const intl = useIntl();
|
||||
const { getWallet } = useWallet();
|
||||
const { getTransactions } = useTransactions();
|
||||
|
||||
const now = Math.floor(Date.now() / 1000);
|
||||
|
||||
const handleClean = useCallback(() => {
|
||||
onBack();
|
||||
setQuote(undefined);
|
||||
setMintAmount('');
|
||||
setCurrentState('default');
|
||||
|
@ -111,8 +112,8 @@ const NewMint = ({ onBack, list }: NewMintProps) => {
|
|||
} else {
|
||||
toast.success(intl.formatMessage(messages.paidMessage));
|
||||
onBack();
|
||||
// onChange();
|
||||
getWallet(); // TODO: Remove
|
||||
getWallet();
|
||||
getTransactions();
|
||||
handleClean();
|
||||
setCurrentState('default');
|
||||
}
|
||||
|
@ -196,15 +197,13 @@ const NewMint = ({ onBack, list }: NewMintProps) => {
|
|||
<Form onSubmit={handleSubmit}>
|
||||
<Stack space={6}>
|
||||
{!quote ? <Stack space={2}>
|
||||
<FormGroup labelText='Mint'>
|
||||
<FormGroup labelText='Mint URL'>
|
||||
<SelectDropdown items={mintList} defaultValue={mintList[0]} onChange={handleSelectChange} />
|
||||
</FormGroup>
|
||||
<FormGroup labelText='Amount in sats'>
|
||||
<FormGroup labelText={intl.formatMessage(messages.amount)}>
|
||||
<Input
|
||||
// aria-label='Amount in sats'
|
||||
placeholder='Amount'
|
||||
type='number'
|
||||
// name='amount'
|
||||
value={mintAmount}
|
||||
onChange={(e) => /^[0-9]*$/.test(e.target.value) && setMintAmount(e.target.value)}
|
||||
autoCapitalize='off'
|
||||
|
@ -213,7 +212,6 @@ const NewMint = ({ onBack, list }: NewMintProps) => {
|
|||
</FormGroup>
|
||||
</Stack>
|
||||
: <Stack space={3} justifyContent='center' alignItems='center'>
|
||||
{/* eslint-disable-next-line formatjs/no-literal-string-in-jsx */}
|
||||
<Text>
|
||||
{intl.formatMessage(messages.payment)}
|
||||
</Text>
|
||||
|
@ -226,8 +224,7 @@ const NewMint = ({ onBack, list }: NewMintProps) => {
|
|||
}
|
||||
|
||||
<HStack grow space={2} justifyContent='center'>
|
||||
<Button icon={arrowBackIcon} theme='secondary' text='Back' onClick={onBack} />
|
||||
<Button icon={cancelIcon} theme='danger' text='Cancel' onClick={handleClean} />
|
||||
<Button icon={cancelIcon} theme='danger' text={intl.formatMessage(messages.cancel)} onClick={handleClean} />
|
||||
<Button icon={iconButton} type='submit' theme='primary' text={textButton} />
|
||||
</HStack>
|
||||
</Stack>
|
||||
|
@ -260,10 +257,9 @@ const Balance = () => {
|
|||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<Stack className='rounded-lg border p-6 black:border-gray-500 dark:border-gray-500' alignItems='center' space={4}>
|
||||
{items[current]}
|
||||
</Stack>
|
||||
return (<>
|
||||
{items[current]}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ import { useOwnAccount } from 'soapbox/hooks/useOwnAccount.ts';
|
|||
const messages = defineMessages({
|
||||
title: { id: 'wallet.create_wallet.title', defaultMessage: 'You don\'t have a wallet' },
|
||||
question: { id: 'wallet.create_wallet.question', defaultMessage: 'Do you want create one?' },
|
||||
button: { id: 'wallet.create_wallet.button', defaultMessage: 'Create wallet' },
|
||||
button: { id: 'wallet.button.create_wallet', defaultMessage: 'Create wallet' },
|
||||
mints: { id: 'wallet.mints', defaultMessage: 'Mints' },
|
||||
});
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ const MintField: StreamfieldComponent<string> = ({ value, onChange }) => {
|
|||
<HStack space={2} grow>
|
||||
<Input
|
||||
type='text'
|
||||
placeholder='https://mint.example.com'
|
||||
outerClassName='w-full grow'
|
||||
value={value}
|
||||
onChange={(e) => onChange(e.currentTarget.value)}
|
||||
|
@ -36,6 +37,7 @@ const RelayField: StreamfieldComponent<string> = ({ value, onChange }) => {
|
|||
<HStack space={2} grow>
|
||||
<Input
|
||||
type='text'
|
||||
placeholder='wss://example.com/relay'
|
||||
outerClassName='w-full grow'
|
||||
value={value}
|
||||
onChange={(e) => onChange(e.currentTarget.value)}
|
||||
|
|
|
@ -89,7 +89,7 @@ interface ITransactions {
|
|||
limit?: number;
|
||||
}
|
||||
|
||||
const Transactions = ({ limit = 6 }: ITransactions) => {
|
||||
const Transactions = ({ limit = 4 }: ITransactions) => {
|
||||
const { account } = useOwnAccount();
|
||||
const { transactions } = useTransactions();
|
||||
|
||||
|
@ -103,7 +103,7 @@ const Transactions = ({ limit = 6 }: ITransactions) => {
|
|||
|
||||
if (transactions.length === 0) {
|
||||
return (<Stack alignItems='center'>
|
||||
<FormattedMessage id='wallet.transactions.no_transactions' defaultMessage='No transactions available yet.' />
|
||||
<FormattedMessage id='wallet.transactions.no_transactions' defaultMessage={'You don\'t have transactions yet.'} />
|
||||
</Stack>);
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ const messages = defineMessages({
|
|||
payment: { id: 'wallet.payment', defaultMessage: 'Payment Method' },
|
||||
relays: { id: 'wallet.relays', defaultMessage: 'Wallet Relays' },
|
||||
transactions: { id: 'wallet.transactions', defaultMessage: 'Transactions' },
|
||||
wallet: { id: 'wallet', defaultMessage: 'Wallet' },
|
||||
wallet: { id: 'wallet.title', defaultMessage: 'Wallet' },
|
||||
management: { id: 'wallet.management', defaultMessage: 'Wallet Management' },
|
||||
mints: { id: 'wallet.mints', defaultMessage: 'Mints' },
|
||||
more: { id: 'wallet.transactions.more', defaultMessage: 'More' },
|
||||
|
@ -38,6 +38,7 @@ const Wallet = () => {
|
|||
const { wallet: walletData, isLoading } = useWallet();
|
||||
const { method, changeMethod } = usePaymentMethod();
|
||||
const { transactions } = useTransactions();
|
||||
const hasTransactions = transactions && transactions.length > 0;
|
||||
|
||||
if (!account) return null;
|
||||
|
||||
|
@ -58,7 +59,9 @@ const Wallet = () => {
|
|||
{walletData ? (
|
||||
<>
|
||||
<CardBody>
|
||||
<Balance />
|
||||
<Stack className='rounded-lg border p-6 black:border-gray-500 dark:border-gray-500' alignItems='center' space={4}>
|
||||
<Balance />
|
||||
</Stack>
|
||||
</CardBody>
|
||||
|
||||
<CardHeader>
|
||||
|
@ -67,7 +70,7 @@ const Wallet = () => {
|
|||
|
||||
<CardBody>
|
||||
<Transactions />
|
||||
{!transactions && <div className='flex w-full justify-center'>
|
||||
{hasTransactions && <div className='flex w-full justify-center'>
|
||||
<Button icon={moreIcon} theme='primary' to='/wallet/transactions'>
|
||||
{intl.formatMessage(messages.more)}
|
||||
</Button>
|
||||
|
|
|
@ -72,7 +72,7 @@ const PayRequestForm = ({ account, status, onClose }: IPayRequestForm) => {
|
|||
const splitData = { hasZapSplit, zapSplitAccounts, splitValues };
|
||||
|
||||
if (isCashu) {
|
||||
nutzapRequest(account, amount, zapComment, status);
|
||||
await nutzapRequest(account, amount, zapComment, status);
|
||||
dispatch(closeModal('PAY_REQUEST'));
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1712,15 +1712,15 @@
|
|||
"video.pause": "Pause",
|
||||
"video.play": "Play",
|
||||
"video.unmute": "Unmute sound",
|
||||
"wallet": "Wallet",
|
||||
"wallet.balance.exchange_button": "Exchange",
|
||||
"wallet.balance.expired": "Expired",
|
||||
"wallet.balance.mint.amount": "Amount in sats",
|
||||
"wallet.balance.mint.paid_message": "Your mint was successful, and your sats are now in your balance. Enjoy!",
|
||||
"wallet.balance.mint.payment": "Make the payment to complete:",
|
||||
"wallet.balance.mint.unpaid_message": "Your mint is still unpaid. Complete the payment to receive your sats.",
|
||||
"wallet.balance.mint_button": "Mint",
|
||||
"wallet.balance.withdraw_button": "Withdraw",
|
||||
"wallet.create_wallet.button": "Create wallet",
|
||||
"wallet.button.cancel": "Cancel",
|
||||
"wallet.button.create_wallet": "Create wallet",
|
||||
"wallet.button.mint": "Mint",
|
||||
"wallet.button.withdraw": "Withdraw",
|
||||
"wallet.create_wallet.question": "Do you want create one?",
|
||||
"wallet.create_wallet.title": "You don't have a wallet",
|
||||
"wallet.invalid_url": "All strings must be valid URLs.",
|
||||
|
@ -1736,9 +1736,10 @@
|
|||
"wallet.relays.error": "Failed to update mints.",
|
||||
"wallet.relays.sucess": "Relays updated with success!",
|
||||
"wallet.sats": "{amount} sats",
|
||||
"wallet.title": "Wallet",
|
||||
"wallet.transactions": "Transactions",
|
||||
"wallet.transactions.more": "More",
|
||||
"wallet.transactions.no_transactions": "No transactions available yet.",
|
||||
"wallet.transactions.no_transactions": "You don't have transactions yet.",
|
||||
"wallet.transactions.show_more": "Show More",
|
||||
"who_to_follow.title": "People To Follow",
|
||||
"zap.button.text.rounded": "{method} {amount}K sats",
|
||||
|
|
Ładowanie…
Reference in New Issue