Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: nwc connection page ui #151

Merged
merged 12 commits into from
Nov 1, 2023
4 changes: 2 additions & 2 deletions echo_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,6 @@ func (svc *Service) AppsNewHandler(c echo.Context) error {

requestMethods = strings.Join(keys, " ")
}
budgetEnabled := maxAmount != "" || budgetRenewal != ""
csrf, _ := c.Get(middleware.DefaultCSRFConfig.ContextKey).(string)

user, err := svc.GetUser(c)
Expand All @@ -280,13 +279,15 @@ func (svc *Service) AppsNewHandler(c echo.Context) error {
//and indicate which ones are checked by default in the front-end
type RequestMethodHelper struct {
Description string
Icon string
Checked bool
}

requestMethodHelper := map[string]*RequestMethodHelper{}
for k, v := range nip47MethodDescriptions {
requestMethodHelper[k] = &RequestMethodHelper{
Description: v,
Icon: nip47MethodIcons[k],
}
}

Expand All @@ -304,7 +305,6 @@ func (svc *Service) AppsNewHandler(c echo.Context) error {
"MaxAmount": maxAmount,
"BudgetRenewal": budgetRenewal,
"ExpiresAt": expiresAt,
"BudgetEnabled": budgetEnabled,
"RequestMethods": requestMethods,
"RequestMethodHelper": requestMethodHelper,
"Disabled": disabled,
Expand Down
21 changes: 14 additions & 7 deletions models.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,17 @@ const (
)

var nip47MethodDescriptions = map[string]string{
NIP_47_GET_BALANCE_METHOD: "Read your balance.",
NIP_47_PAY_INVOICE_METHOD: "Send payments from your wallet.",
NIP_47_MAKE_INVOICE_METHOD: "Create invoices on your behalf.",
NIP_47_LOOKUP_INVOICE_METHOD: "Lookup status of created invoices.",
NIP_47_GET_BALANCE_METHOD: "Read your balance",
NIP_47_PAY_INVOICE_METHOD: "Send payments",
NIP_47_MAKE_INVOICE_METHOD: "Create invoices",
NIP_47_LOOKUP_INVOICE_METHOD: "Lookup status of invoices",
}

var nip47MethodIcons = map[string]string{
NIP_47_GET_BALANCE_METHOD: "wallet",
NIP_47_PAY_INVOICE_METHOD: "lightning",
NIP_47_MAKE_INVOICE_METHOD: "invoice",
NIP_47_LOOKUP_INVOICE_METHOD: "search",
}

type AlbyMe struct {
Expand Down Expand Up @@ -197,6 +204,6 @@ type Nip47LookupInvoiceParams struct {
}

type Nip47LookupInvoiceResponse struct {
Invoice string `json:"invoice"`
Paid bool `json:"paid"`
}
Invoice string `json:"invoice"`
Paid bool `json:"paid"`
}
Loading
Loading