Skip to content

Commit

Permalink
chore: further changes
Browse files Browse the repository at this point in the history
  • Loading branch information
im-adithya committed Jul 11, 2024
1 parent 8191a62 commit 0aebbac
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
16 changes: 13 additions & 3 deletions frontend/src/components/Permissions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,24 @@ const Permissions: React.FC<PermissionsProps> = ({
const [permissions, setPermissions] = React.useState(initialPermissions);

const [canEditBudgetAmount, setCanEditBudgetAmount] = React.useState(
isNewConnection ? Number.isNaN(permissions.maxAmount) : canEditPermissions
isNewConnection
? Number.isNaN(initialPermissions.maxAmount)
: canEditPermissions
);
const [canEditExpiry, setCanEditExpiry] = React.useState(
isNewConnection ? !permissions.expiresAt : canEditPermissions
isNewConnection ? !initialPermissions.expiresAt : canEditPermissions
);

// this is triggered when edit mode is cancelled in show app
// this is triggered when changes are saved in show app
React.useEffect(() => {
setPermissions(initialPermissions);
}, [initialPermissions]);

// this is triggered when edit mode is called
React.useEffect(() => {
if (isNewConnection) {
return;
}
setCanEditBudgetAmount(
isNewConnection
? Number.isNaN(initialPermissions.maxAmount)
Expand Down Expand Up @@ -163,6 +172,7 @@ const Permissions: React.FC<PermissionsProps> = ({
variant="secondary"
onClick={() => {
setShowBudgetOptions(true);
handleBudgetRenewalChange("monthly");
handleBudgetMaxAmountChange(100000);
}}
className="mb-4 mr-4"
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/screens/apps/NewApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ const NewAppInternal = ({ capabilities }: NewAppInternalProps) => {
maxAmount: parseInt(budgetMaxAmountParam),
budgetRenewal: validBudgetRenewals.includes(budgetRenewalParam)
? budgetRenewalParam
: "monthly",
: "never",
expiresAt: parseExpiresParam(expiresAtParam),
});

Expand Down

0 comments on commit 0aebbac

Please sign in to comment.