kopia lustrzana https://gitlab.com/soapbox-pub/soapbox
Add data
rodzic
b27291a714
commit
7fabf42da4
|
@ -25,7 +25,6 @@ interface IZapSplitModal {
|
||||||
const ZapSplitModal: React.FC<IZapSplitModal> = ({ account, status, onClose, zapAmount = 50 }) => {
|
const ZapSplitModal: React.FC<IZapSplitModal> = ({ account, status, onClose, zapAmount = 50 }) => {
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const hasZapSplit = true;
|
|
||||||
const [invoice, setInvoice] = useState<string | null>(null);
|
const [invoice, setInvoice] = useState<string | null>(null);
|
||||||
const [widthModal, setWidthModal] = useState<'xl' | 'xs' | 'sm' | 'md' | 'lg' | '2xl' | '3xl' | '4xl' | undefined>('sm');
|
const [widthModal, setWidthModal] = useState<'xl' | 'xs' | 'sm' | 'md' | 'lg' | '2xl' | '3xl' | '4xl' | undefined>('sm');
|
||||||
|
|
||||||
|
@ -51,7 +50,7 @@ const ZapSplitModal: React.FC<IZapSplitModal> = ({ account, status, onClose, zap
|
||||||
}
|
}
|
||||||
|
|
||||||
setInvoice(invoice);
|
setInvoice(invoice);
|
||||||
setWidthModal('xl');
|
setWidthModal('2xl');
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -81,9 +80,7 @@ const ZapSplitModal: React.FC<IZapSplitModal> = ({ account, status, onClose, zap
|
||||||
<a href={'lightning:' + invoice}>
|
<a href={'lightning:' + invoice}>
|
||||||
<Button type='submit' theme='primary' icon={require('@tabler/icons/outline/folder-open.svg')} text={intl.formatMessage(messages.zap_open_wallet)} />
|
<Button type='submit' theme='primary' icon={require('@tabler/icons/outline/folder-open.svg')} text={intl.formatMessage(messages.zap_open_wallet)} />
|
||||||
</a>
|
</a>
|
||||||
{hasZapSplit &&
|
<Button type='button' theme='muted' className='!font-bold' text={intl.formatMessage(messages.zap_next)} />
|
||||||
<Button type='button' theme='muted' className='!font-bold' text={intl.formatMessage(messages.zap_next)} />
|
|
||||||
}
|
|
||||||
</HStack>
|
</HStack>
|
||||||
</Stack>
|
</Stack>
|
||||||
</div>}
|
</div>}
|
||||||
|
|
|
@ -12,6 +12,8 @@ import questionIcon from 'soapbox/assets/icons/questionIcon.svg';
|
||||||
import Account from 'soapbox/components/account';
|
import Account from 'soapbox/components/account';
|
||||||
import { Stack, HStack, Button, Input } from 'soapbox/components/ui';
|
import { Stack, HStack, Button, Input } from 'soapbox/components/ui';
|
||||||
import { useAppDispatch } from 'soapbox/hooks';
|
import { useAppDispatch } from 'soapbox/hooks';
|
||||||
|
// import { useApi, useAppDispatch } from 'soapbox/hooks';
|
||||||
|
// import { zapSplitSchema } from 'soapbox/schemas/zap-split';
|
||||||
|
|
||||||
import type { Account as AccountEntity, Status as StatusEntity } from 'soapbox/types/entities';
|
import type { Account as AccountEntity, Status as StatusEntity } from 'soapbox/types/entities';
|
||||||
|
|
||||||
|
@ -27,19 +29,29 @@ const messages = defineMessages({
|
||||||
});
|
});
|
||||||
|
|
||||||
const ZapPayRequestForm = ({ account, status }: IZapPayRequestForm) => {
|
const ZapPayRequestForm = ({ account, status }: IZapPayRequestForm) => {
|
||||||
|
// const api = useApi();
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
const [zapComment, setZapComment] = useState('');
|
const [zapComment, setZapComment] = useState('');
|
||||||
// amount in millisatoshi
|
// amount in millisatoshi
|
||||||
const [zapAmount, setZapAmount] = useState(50);
|
const [zapAmount, setZapAmount] = useState(50);
|
||||||
|
|
||||||
|
// const fetchZapSplit = async (id: string) => {
|
||||||
|
// return await api.get(`/api/v1/ditto/${id}/zap_splits`);
|
||||||
|
// };
|
||||||
|
|
||||||
const handleSubmit = async (e?: React.FormEvent<Element>) => {
|
const handleSubmit = async (e?: React.FormEvent<Element>) => {
|
||||||
e?.preventDefault();
|
e?.preventDefault();
|
||||||
|
// const hasZapSplit = await fetchZapSplit(status!.id);
|
||||||
|
// const teste = zapSplitSchema.parse(hasZapSplit.data);
|
||||||
const invoice = await dispatch(zap(account, status, zapAmount * 1000, zapComment));
|
const invoice = await dispatch(zap(account, status, zapAmount * 1000, zapComment));
|
||||||
|
|
||||||
// If invoice is undefined it means the user has paid through his extension
|
// If invoice is undefined it means the user has paid through his extension
|
||||||
// In this case, we simply close the modal
|
// In this case, we simply close the modal
|
||||||
if (!invoice) {
|
if (!invoice) {
|
||||||
dispatch(closeModal('ZAP_PAY_REQUEST'));
|
dispatch(closeModal('ZAP_PAY_REQUEST'));
|
||||||
|
// Dispatch the adm account
|
||||||
|
// hasZapSplit && dispatch(openModal('ZAP_SPLIT', { account }));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// open QR code modal
|
// open QR code modal
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
import { z } from 'zod';
|
||||||
|
|
||||||
|
import { accountSchema } from './account';
|
||||||
|
|
||||||
|
const zapSplitSchema = z.object({
|
||||||
|
account: accountSchema,
|
||||||
|
message: z.string().catch(''),
|
||||||
|
weight: z.number().catch(0),
|
||||||
|
});
|
||||||
|
|
||||||
|
type ZapSplitData = z.infer<typeof zapSplitSchema>;
|
||||||
|
|
||||||
|
export { zapSplitSchema, type ZapSplitData };
|
Ładowanie…
Reference in New Issue