Skip to content

Commit

Permalink
fix: maxAmount, returnTo
Browse files Browse the repository at this point in the history
  • Loading branch information
rolznz committed Jan 12, 2024
1 parent d7e512f commit ebea066
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
3 changes: 1 addition & 2 deletions echo_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"fmt"
"net/http"
"net/url"
"strconv"
"strings"
"time"

Expand Down Expand Up @@ -268,7 +267,7 @@ func (svc *Service) AppsCreateHandler(c echo.Context) error {
}
}
app := App{Name: name, NostrPubkey: pairingPublicKey}
maxAmount, _ := strconv.Atoi(requestData.MaxAmount)
maxAmount := requestData.MaxAmount
budgetRenewal := requestData.BudgetRenewal

expiresAt := time.Time{}
Expand Down
1 change: 1 addition & 0 deletions frontend/src/screens/apps/AppCreated.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export default function AppCreated() {
}
}, []);

// TODO: use a modal library instead of doing this manually
useEffect(() => {
const handleClickOutside = (event: MouseEvent) => {
if (
Expand Down
26 changes: 14 additions & 12 deletions frontend/src/screens/apps/NewApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ const NewApp = () => {
? budgetRenewalParam
: "monthly";

// returns RequestMethod Set
const parseRequestMethods = (reqParam: string): Set<RequestMethodType> => {
const methods = reqParam
? reqParam.split(" ")
Expand Down Expand Up @@ -123,17 +122,22 @@ const NewApp = () => {
},
body: JSON.stringify({
name: appName,
pubkey: pubkey,
maxAmount: maxAmount.toString(),
budgetRenewal: budgetRenewal,
expiresAt: expiresAt,
pubkey,
maxAmount,
budgetRenewal,
expiresAt,
requestMethods: [...requestMethods].join(" "),
returnTo: returnTo,
}),
});
await validateFetchResponse(response);

const createAppResponse: CreateAppResponse = await response.json();
if (createAppResponse.returnTo) {
// open connection URI directly in an app
window.location.href = createAppResponse.returnTo;
return;
}
navigate("/apps/created", {
state: createAppResponse,
});
Expand Down Expand Up @@ -211,18 +215,16 @@ const NewApp = () => {

<div className="mb-6">
<ul className="flex flex-col w-full">
{Object.keys(nip47MethodDescriptions).map((rm, index) => {
const RequestMethodIcon = iconMap[rm as RequestMethodType];
{(
Object.keys(nip47MethodDescriptions) as RequestMethodType[]
).map((rm, index) => {
const RequestMethodIcon = iconMap[rm];
return (
<li
key={index}
className={`w-full ${
rm == "pay_invoice" ? "order-last" : ""
} ${
!edit && !requestMethods.has(rm as RequestMethodType)
? "hidden"
: ""
}`}
} ${!edit && !requestMethods.has(rm) ? "hidden" : ""}`}
>
<div className="flex items-center mb-2">
{RequestMethodIcon && (
Expand Down
2 changes: 1 addition & 1 deletion models/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type ListAppsResponse struct {
type CreateAppRequest struct {
Name string `json:"name"`
Pubkey string `json:"pubkey"`
MaxAmount string `json:"maxAmount"`
MaxAmount int `json:"maxAmount"`
BudgetRenewal string `json:"budgetRenewal"`
ExpiresAt string `json:"expiresAt"`
RequestMethods string `json:"requestMethods"`
Expand Down

0 comments on commit ebea066

Please sign in to comment.