Skip to content
This repository has been archived by the owner on Sep 2, 2024. It is now read-only.

Commit

Permalink
fix: default scopes and budget renewal
Browse files Browse the repository at this point in the history
  • Loading branch information
rolznz committed Jul 1, 2024
1 parent 084f61a commit e3d05f7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
16 changes: 10 additions & 6 deletions frontend/src/components/Permissions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,21 @@ const Permissions: React.FC<PermissionsProps> = ({
return;
}

let budgetRenewal = permissions.budgetRenewal;

const newScopes = new Set(permissions.scopes);
if (newScopes.has(scope)) {
newScopes.delete(scope);
} else {
newScopes.add(scope);
if (scope === "pay_invoice") {
budgetRenewal = "monthly";
}
}

handlePermissionsChange({
scopes: newScopes,
budgetRenewal,
});
};

Expand Down Expand Up @@ -171,13 +177,11 @@ const Permissions: React.FC<PermissionsProps> = ({
<SelectContent>
{validBudgetRenewals.map((renewalOption) => (
<SelectItem
key={renewalOption || "never"}
value={renewalOption || "never"}
key={renewalOption}
value={renewalOption}
>
{renewalOption
? renewalOption.charAt(0).toUpperCase() +
renewalOption.slice(1)
: "Never"}
{renewalOption.charAt(0).toUpperCase() +
renewalOption.slice(1)}
</SelectItem>
))}
</SelectContent>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ export type UpdateAppRequest = {
maxAmount: number;
budgetRenewal: string;
expiresAt: string | undefined;
scopes: string[];
scopes: Scope[];
};

export type Channel = {
Expand Down
2 changes: 1 addition & 1 deletion nip47/permissions/permissions.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func scopeToRequestMethods(scope string) []string {
func RequestMethodsToScopes(requestMethods []string) ([]string, error) {
scopes := []string{}

for _, requestMethod := range scopes {
for _, requestMethod := range requestMethods {
scope, err := RequestMethodToScope(requestMethod)
if err != nil {
return nil, err
Expand Down

0 comments on commit e3d05f7

Please sign in to comment.