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