Skip to content

Commit

Permalink
Merge pull request #320 from shocknet/create-rule
Browse files Browse the repository at this point in the history
create rule
  • Loading branch information
shocknet-justin authored Oct 2, 2024
2 parents f6a44eb + 797272a commit 65e61bc
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/Components/Modals/DebitRequestModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,16 @@ export const DebitRequestModal = () => {
frequency_rule: { ...frequencyRule, amount: +requestAmount }
}
})
} else if (isCreateRule) {
rules.push({
rule: {
type: Types.DebitRule_rule_type.FREQUENCY_RULE,
frequency_rule: { amount: +requestAmount, number_of_intervals: 120_000, interval: Types.IntervalType.MONTH }
}
})
}

if (currentRequest.request.debit.type === Types.LiveDebitRequest_debit_type.INVOICE && !isRecurringPayment) {
if (currentRequest.request.debit.type === Types.LiveDebitRequest_debit_type.INVOICE && !isRecurringPayment && !isCreateRule) {
const invoice = currentRequest.request.debit.invoice
const parsed = await parseBitcoinInput(invoice)
history.push({
Expand All @@ -129,7 +136,7 @@ export const DebitRequestModal = () => {
dispatch(removeDebitRequest({ requestorNpub: currentRequest.request.npub, sourceId: currentRequest.source.id }))
dispatch(refetchDebits())
toast.success("Linked app added successfuly")
}, [history, isRecurringPayment, frequencyRule, dispatch, currentRequest, requestAmount]);
}, [history, isRecurringPayment, frequencyRule, dispatch, currentRequest, requestAmount, isCreateRule]);



Expand Down Expand Up @@ -401,7 +408,7 @@ export const EditDebitModal = () => {
toast.error(<Toast title="Update linked app error" message={res.reason} />)
return
}
console.log({rules})
console.log({ rules })
dispatch(refetchDebits())
dispatch(setDebitToEdit(null));
toast.success("Linked app updated successfuly")
Expand Down

0 comments on commit 65e61bc

Please sign in to comment.