Add data
This commit is contained in:
parent
b27291a714
commit
7fabf42da4
|
@ -25,7 +25,6 @@ interface IZapSplitModal {
|
|||
const ZapSplitModal: React.FC<IZapSplitModal> = ({ account, status, onClose, zapAmount = 50 }) => {
|
||||
const dispatch = useAppDispatch();
|
||||
const intl = useIntl();
|
||||
const hasZapSplit = true;
|
||||
const [invoice, setInvoice] = useState<string | null>(null);
|
||||
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);
|
||||
setWidthModal('xl');
|
||||
setWidthModal('2xl');
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
|
@ -81,9 +80,7 @@ const ZapSplitModal: React.FC<IZapSplitModal> = ({ account, status, onClose, zap
|
|||
<a href={'lightning:' + invoice}>
|
||||
<Button type='submit' theme='primary' icon={require('@tabler/icons/outline/folder-open.svg')} text={intl.formatMessage(messages.zap_open_wallet)} />
|
||||
</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>
|
||||
</Stack>
|
||||
</div>}
|
||||
|
|
|
@ -12,6 +12,8 @@ import questionIcon from 'soapbox/assets/icons/questionIcon.svg';
|
|||
import Account from 'soapbox/components/account';
|
||||
import { Stack, HStack, Button, Input } from 'soapbox/components/ui';
|
||||
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';
|
||||
|
||||
|
@ -27,19 +29,29 @@ const messages = defineMessages({
|
|||
});
|
||||
|
||||
const ZapPayRequestForm = ({ account, status }: IZapPayRequestForm) => {
|
||||
// const api = useApi();
|
||||
const intl = useIntl();
|
||||
const dispatch = useAppDispatch();
|
||||
const [zapComment, setZapComment] = useState('');
|
||||
// amount in millisatoshi
|
||||
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>) => {
|
||||
e?.preventDefault();
|
||||
// const hasZapSplit = await fetchZapSplit(status!.id);
|
||||
// const teste = zapSplitSchema.parse(hasZapSplit.data);
|
||||
const invoice = await dispatch(zap(account, status, zapAmount * 1000, zapComment));
|
||||
|
||||
// If invoice is undefined it means the user has paid through his extension
|
||||
// In this case, we simply close the modal
|
||||
if (!invoice) {
|
||||
dispatch(closeModal('ZAP_PAY_REQUEST'));
|
||||
// Dispatch the adm account
|
||||
// hasZapSplit && dispatch(openModal('ZAP_SPLIT', { account }));
|
||||
return;
|
||||
}
|
||||
// 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 };
|
Loading…
Reference in New Issue