Skip to content

Commit

Permalink
deny dont ban
Browse files Browse the repository at this point in the history
  • Loading branch information
boufni95 committed Sep 20, 2024
1 parent 140d8e7 commit 0daac38
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/Components/BackgroundJobs/DebitRequestHandler.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { useCallback, useEffect, useState } from "react";
import { useCallback, useEffect, useMemo, useState } from "react";
import { DebitAuthorization, LiveDebitRequest, LiveDebitRequest_debit_type } from "../../Api/pub/autogenerated/ts/types";
import { SourceDebitRequest } from "../../globalTypes";
import { getNostrClient, parseNprofile } from "../../Api/nostr";
import { selectNostrSpends, useSelector } from "../../State/store";
import { Modal } from "../Modals/Modal";

export const DebitRequestHandler = () => {
const nostrSpends = useSelector(selectNostrSpends);
Expand Down Expand Up @@ -39,11 +40,9 @@ export const DebitRequestHandler = () => {
}
setRequestData(null)
}, [])
if (!requestData) {
return null
}
return (
<>
const modalContent = useMemo(() => {
if (!requestData) { return <></> }
return <>
<div className='Sources_modal_header'>Incoming Request</div>
<div className='Sources_modal_discription'>{requestData.request.npub}</div>
<div className='Sources_modal_discription'>
Expand All @@ -58,9 +57,14 @@ export const DebitRequestHandler = () => {
<div className='Sources_modal_discription'>Wants to spend</div>
<div className='Sources_modal_discription'>{requestData.request.amount}</div>
<div className="Sources_modal_add_btn">
<button onClick={() => banRequest(requestData)}>Deny</button>
<button onClick={() => setRequestData(null)}>Deny</button>
<button onClick={() => authroizeRequest(requestData)}>{requestData.request.debit.type === LiveDebitRequest_debit_type.FREQUENCY ? "Allow" : "Pay"}</button>
</div>
</>
)
}, [requestData])
if (!requestData) {
return null
}

return <Modal isShown={!!requestData} hide={() => setRequestData(null)} modalContent={modalContent} headerText={''} />
}

0 comments on commit 0daac38

Please sign in to comment.