Skip to content

Commit 13b1564

Browse files
committed
fix: structure
1 parent a470514 commit 13b1564

File tree

9 files changed

+29
-15
lines changed

9 files changed

+29
-15
lines changed

features/overview/components/balance/balance.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { OverviewItem, OverviewSection } from 'features/overview/shared';
2-
import { SectionPayload, useVaultOverview } from 'features/overview/contexts';
2+
import { SectionData, useVaultOverview } from 'features/overview/contexts';
33
import { appPaths } from 'consts/routing';
44

5-
const sectionPayloadList: SectionPayload[] = [
5+
const sectionPayloadList: SectionData[] = [
66
{
77
key: 'withdrawableEth',
88
actionRole: 'withdrawer',

features/overview/components/capacity/capacity.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { OverviewItem, OverviewSection } from 'features/overview/shared';
2-
import { SectionPayload, useVaultOverview } from 'features/overview/contexts';
2+
import { SectionData, useVaultOverview } from 'features/overview/contexts';
33
import { getUtilizationRatioColor } from 'utils';
44

5-
const sectionPayloadList: SectionPayload[] = [
5+
const sectionPayloadList: SectionData[] = [
66
{
77
key: 'utilizationRatio',
88
},

features/overview/components/health/heath.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { OverviewItem, OverviewSection } from 'features/overview/shared';
2-
import { SectionPayload, useVaultOverview } from 'features/overview/contexts';
2+
import { SectionData, useVaultOverview } from 'features/overview/contexts';
33
import { formatPercent, getHealthFactorColor } from 'utils';
44

5-
const sectionPayloadList: SectionPayload[] = [
5+
const sectionPayloadList: SectionData[] = [
66
{
77
key: 'healthFactorNumber',
88
},

features/overview/components/node-operator/node-operator.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { OverviewItem, OverviewSection } from 'features/overview/shared';
2-
import { SectionPayload, useVaultOverview } from 'features/overview/contexts';
2+
import { SectionData, useVaultOverview } from 'features/overview/contexts';
33
import { appPaths } from 'consts/routing';
44

5-
const sectionPayloadList: SectionPayload[] = [
5+
const sectionPayloadList: SectionData[] = [
66
{
77
key: 'nodeOperatorFee',
88
},

features/overview/contexts/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ export {
33
useVaultOverview,
44
type VaultOverviewContextType,
55
type VaultOverviewContextKeys,
6-
type SectionData as SectionPayload,
6+
type SectionData,
7+
type SectionPayload,
78
} from './vault-overview';

features/overview/shared/overview-item/overview-item.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import { useVaultInfo, useVaultPermission } from 'modules/vaults';
88
import { OverviewItemValue } from './overview-item-value';
99
import { ItemWrapper, Title } from './styles';
1010

11-
import type { SectionPayload } from 'features/overview/contexts/vault-overview';
1211
import { Hint } from 'shared/components';
12+
import type { SectionPayload } from 'features/overview/contexts';
1313

1414
export type ItemProps = {
1515
payload: string | Address | number;

features/settings/main/hooks/use-edit-main-settings.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ export const useEditMainSettings = () => {
147147
}),
148148
);
149149

150+
// refetch anyway because some transactions may be successful
150151
await refetchVaultInfo();
151152

152153
return result;

modules/vaults/components/permissioned-submit-button.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const PermissionedSubmitButton = forwardRef<
3535
<ConnectWalletButton>
3636
<Button disabled={shouldDisable} ref={ref} {...rest}>
3737
{shouldShowPermissionError
38-
? `You don't have ${roleTitle} role`
38+
? vaultTexts.common.errors.noRoles([roleTitle])
3939
: children}
4040
</Button>
4141
</ConnectWalletButton>
@@ -60,15 +60,14 @@ export const MultiplePermissionedSubmitButton = forwardRef<
6060
const shouldShowPermissionError =
6161
!isLoading && data && !data.hasPermissions && isAccountActive;
6262

63-
const missingRoles = data?.missingRoles
64-
.map((role) => vaultTexts.roles[role].title)
65-
.join(', ');
63+
const missingRoles =
64+
data?.missingRoles.map((role) => vaultTexts.roles[role].title) ?? [];
6665

6766
return (
6867
<ConnectWalletButton>
6968
<Button disabled={shouldDisable} ref={ref} {...rest}>
7069
{shouldShowPermissionError
71-
? `You don't have ${missingRoles} role${data && data.missingRoles.length > 1 ? 's' : ''}`
70+
? vaultTexts.common.errors.noRoles(missingRoles)
7271
: children}
7372
</Button>
7473
</ConnectWalletButton>

modules/vaults/consts/texts.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ type Token = 'stETH' | 'wstETH';
22

33
type ConfirmAction = 'Setting' | 'Proposing';
44

5+
// This structure contains texts related to vault functionality
6+
// such texts for actions, metrics, roles and etc
57
export const vaultTexts = {
8+
// configuration for transactions and forms
69
actions: {
710
approve: {
811
loading: (token: Token) => `Approving ${token}` as const,
@@ -112,6 +115,8 @@ export const vaultTexts = {
112115
},
113116
},
114117
},
118+
// configuration for vault metrics as seen in overview page
119+
// but can be used in other places as well where vault status is displayed
115120
metrics: {
116121
totalValue: {
117122
title: 'Total value',
@@ -175,6 +180,7 @@ export const vaultTexts = {
175180
action: 'Claim',
176181
},
177182
},
183+
// configuration for vault roles
178184
roles: {
179185
defaultAdmin: {
180186
title: 'Vault Owner',
@@ -283,4 +289,11 @@ export const vaultTexts = {
283289
hint: 'Allows to increase locked ETH amount on stVault to allow stETH minting',
284290
},
285291
},
292+
// common texts like errors, warnings, etc.
293+
common: {
294+
errors: {
295+
noRoles: (roleNames: string[]) =>
296+
`You don't have ${roleNames.join(',')} role${roleNames.length > 1 ? 's' : ''}` as const,
297+
},
298+
},
286299
} as const;

0 commit comments

Comments
 (0)