diff --git a/frontend/src/components/Permissions.tsx b/frontend/src/components/Permissions.tsx index 007af467..ef3d9446 100644 --- a/frontend/src/components/Permissions.tsx +++ b/frontend/src/components/Permissions.tsx @@ -15,8 +15,6 @@ import { cn } from "src/lib/utils"; import { AppPermissions, BudgetRenewalType, - Nip47NotificationType, - Nip47RequestMethod, Scope, budgetOptions, expiryOptions, @@ -57,51 +55,20 @@ const Permissions: React.FC = ({ onPermissionsChange(updatedPermissions); }; - const toScopes = ( - _requestMethods: Set, - _notificationTypes: Set - ): Set => { - throw new Error("TODO - map should come from backend"); - }; - const handleScopeChange = (scope: Scope) => { if (!canEditPermissions) { return; } - const scopeToRequestMethods = (_scope: Scope): Nip47RequestMethod[] => { - throw new Error("TODO - map should come from backend"); - }; - const scopeToNotificationTypes = ( - _scope: Scope - ): Nip47NotificationType[] => { - throw new Error("TODO - map should come from backend"); - }; - - const scopeRequestMethods = scopeToRequestMethods(scope); - const scopeNotificationTypes = scopeToNotificationTypes(scope); - - const newRequestMethods = new Set(permissions.requestMethods); - for (const method of scopeRequestMethods) { - if (newRequestMethods.has(method)) { - newRequestMethods.delete(method); - } else { - newRequestMethods.add(method); - } - } - - const newNotificationTypes = new Set(permissions.notificationTypes); - for (const notificationType of scopeNotificationTypes) { - if (newNotificationTypes.has(notificationType)) { - newNotificationTypes.delete(notificationType); - } else { - newNotificationTypes.add(notificationType); - } + const newScopes = new Set(permissions.scopes); + if (newScopes.has(scope)) { + newScopes.delete(scope); + } else { + newScopes.add(scope); } handlePermissionsChange({ - requestMethods: newRequestMethods, - notificationTypes: newNotificationTypes, + scopes: newScopes, }); }; @@ -146,9 +113,9 @@ const Permissions: React.FC = ({ className={cn( "w-full", scope == "pay_invoice" ? "order-last" : "", - /*!canEditPermissions && !permissions.requestMethods.has(rm) + !canEditPermissions && !permissions.scopes.has(scope) ? "hidden" - : */ "" + : "" )} >
@@ -164,10 +131,7 @@ const Permissions: React.FC = ({ id={scope} className={cn("mr-2", !canEditPermissions ? "hidden" : "")} onCheckedChange={() => handleScopeChange(scope)} - checked={toScopes( - permissions.requestMethods, - permissions.notificationTypes - ).has(scope)} + checked={permissions.scopes.has(scope)} />