Skip to content

Commit 8bcd148

Browse files
Tim Emioladfordivam
authored andcommitted
Show popup when approving a Proposal matching a Delegation
Signed-off-by: Tim Emiola <adetokunbo@emio.la>
1 parent 8990113 commit 8bcd148

File tree

5 files changed

+25
-25
lines changed

5 files changed

+25
-25
lines changed

apps/wallet/frontend/src/__tests__/mocks/delegation-constants.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ export const delegationExpiresAt = '2050-01-01T00:00:00.000000Z';
1313
// Formatted version as displayed by DateDisplay component
1414
export const delegationExpiresAtFormatted = '2050-01-01 00:00';
1515

16-
// Onboarded status for each delegation (bob is onboarded, charlie is not, eve is onboarded)
17-
export const mockDelegationOnboardedStatus = [true, false, true];
16+
// Hosted status for each delegation (bob is hosted, charlie is not, eve is hosted)
17+
export const mockDelegationHostedStatus = [true, false, true];
1818

19-
// Onboarded status for each proposal (charlie is onboarded, dave is not, eve is onboarded)
20-
export const mockProposalOnboardedStatus = [true, false, true];
19+
// Hosted status for each proposal (charlie is hosted, dave is not, eve is hosted)
20+
export const mockProposalHostedStatus = [true, false, true];
2121

2222
// Three different expiration dates for testing sort order
2323
export const expiresAtCurrent = '2050-01-01T00:00:00.000000Z';
@@ -69,8 +69,8 @@ export const mockMintingDelegationsSorted: MintingDelegation[] = [
6969
mockMintingDelegations[1], // charlie - 6 months
7070
];
7171

72-
// Onboarded status in sorted order (eve: true, bob: true, charlie: false)
73-
export const mockDelegationOnboardedStatusSorted = [true, true, false];
72+
// Hosted status in sorted order (eve: true, bob: true, charlie: false)
73+
export const mockDelegationHostedStatusSorted = [true, true, false];
7474

7575
// Mock data is intentionally NOT sorted by expiration date.
7676
// Order: 3 months, 6 months, current - to verify UI sorts them correctly.
@@ -111,5 +111,5 @@ export const mockMintingDelegationProposalsSorted: MintingDelegationProposal[] =
111111
mockMintingDelegationProposals[1], // dave - 6 months
112112
];
113113

114-
// Onboarded status in sorted order (eve: true, charlie: true, dave: false)
115-
export const mockProposalOnboardedStatusSorted = [true, true, false];
114+
// Hosted status in sorted order (eve: true, charlie: true, dave: false)
115+
export const mockProposalHostedStatusSorted = [true, true, false];

apps/wallet/frontend/src/__tests__/mocks/handlers/wallet-api.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ import {
3232
import {
3333
mockMintingDelegations,
3434
mockMintingDelegationProposals,
35-
mockDelegationOnboardedStatus,
36-
mockProposalOnboardedStatus,
35+
mockDelegationHostedStatus,
36+
mockProposalHostedStatus,
3737
} from '../delegation-constants';
3838
import { mkContract } from '../contract';
3939

@@ -239,7 +239,7 @@ export const buildWalletMock = (walletUrl: string): RestHandler[] => [
239239
ctx.json<ListMintingDelegationsResponse>({
240240
delegations: mockMintingDelegations.map((delegation, index) => ({
241241
contract: mkContract(MintingDelegation, delegation),
242-
beneficiary_onboarded: mockDelegationOnboardedStatus[index],
242+
beneficiary_hosted: mockDelegationHostedStatus[index],
243243
})),
244244
})
245245
);
@@ -250,7 +250,7 @@ export const buildWalletMock = (walletUrl: string): RestHandler[] => [
250250
ctx.json<ListMintingDelegationProposalsResponse>({
251251
proposals: mockMintingDelegationProposals.map((proposal, index) => ({
252252
contract: mkContract(MintingDelegationProposal, proposal),
253-
beneficiary_onboarded: mockProposalOnboardedStatus[index],
253+
beneficiary_hosted: mockProposalHostedStatus[index],
254254
})),
255255
})
256256
);

apps/wallet/frontend/src/__tests__/wallet.test.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ import {
2121
mockMintingDelegations,
2222
mockMintingDelegationsSorted,
2323
mockMintingDelegationProposals,
24-
mockDelegationOnboardedStatusSorted,
25-
mockProposalOnboardedStatusSorted,
24+
mockDelegationHostedStatusSorted,
25+
mockProposalHostedStatusSorted,
2626
mockMintingDelegationProposalsSorted,
2727
} from './mocks/delegation-constants';
2828
import { requestMocks } from './mocks/handlers/transfers-api';
@@ -539,7 +539,7 @@ describe('Wallet user can', () => {
539539

540540
// Verify warning icons are shown for proposals where beneficiary is not hosted
541541
const proposalWarnings = document.querySelectorAll('.proposal-not-hosted-warning');
542-
const expectedProposalWarnings = mockProposalOnboardedStatusSorted.filter(s => !s).length;
542+
const expectedProposalWarnings = mockProposalHostedStatusSorted.filter(s => !s).length;
543543
expect(proposalWarnings.length).toBe(expectedProposalWarnings);
544544

545545
// Verify proposal max amulets values are in sorted order
@@ -558,12 +558,12 @@ describe('Wallet user can', () => {
558558
});
559559

560560
// Verify Accept buttons are present for each proposal
561-
// Accept button should be disabled when beneficiary is not onboarded (in sorted order)
561+
// Accept button should be disabled when beneficiary is not hosted (in sorted order)
562562
const acceptButtons = document.querySelectorAll('.proposal-accept');
563563
expect(acceptButtons.length).toBe(mockMintingDelegationProposals.length);
564-
mockProposalOnboardedStatusSorted.forEach((isOnboarded, index) => {
564+
mockProposalHostedStatusSorted.forEach((isHosted, index) => {
565565
expect(acceptButtons[index].textContent).toBe('Accept');
566-
if (isOnboarded) {
566+
if (isHosted) {
567567
expect(acceptButtons[index]).not.toBeDisabled();
568568
} else {
569569
expect(acceptButtons[index]).toBeDisabled();
@@ -588,7 +588,7 @@ describe('Wallet user can', () => {
588588

589589
// Verify warning icons are shown for delegations where beneficiary is not hosted
590590
const delegationWarnings = document.querySelectorAll('.delegation-not-hosted-warning');
591-
const expectedDelegationWarnings = mockDelegationOnboardedStatusSorted.filter(s => !s).length;
591+
const expectedDelegationWarnings = mockDelegationHostedStatusSorted.filter(s => !s).length;
592592
expect(delegationWarnings.length).toBe(expectedDelegationWarnings);
593593

594594
// Verify max amulets values are in sorted order

apps/wallet/frontend/src/contexts/WalletServiceContext.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ import {
4242

4343
export interface MintingDelegationWithStatus {
4444
contract: Contract<MintingDelegation>;
45-
beneficiaryOnboarded: boolean;
45+
beneficiaryHosted: boolean;
4646
}
4747

4848
export interface MintingDelegationProposalWithStatus {
4949
contract: Contract<MintingDelegationProposal>;
50-
beneficiaryOnboarded: boolean;
50+
beneficiaryHosted: boolean;
5151
}
5252

5353
import {
@@ -360,14 +360,14 @@ export const WalletClientProvider: React.FC<React.PropsWithChildren<WalletProps>
360360
const res = await walletClient.listMintingDelegations();
361361
return res.delegations.map(d => ({
362362
contract: Contract.decodeOpenAPI(d.contract, MintingDelegation),
363-
beneficiaryOnboarded: d.beneficiary_onboarded,
363+
beneficiaryHosted: d.beneficiary_hosted,
364364
}));
365365
},
366366
listMintingDelegationProposals: async () => {
367367
const res = await walletClient.listMintingDelegationProposals();
368368
return res.proposals.map(p => ({
369369
contract: Contract.decodeOpenAPI(p.contract, MintingDelegationProposal),
370-
beneficiaryOnboarded: p.beneficiary_onboarded,
370+
beneficiaryHosted: p.beneficiary_hosted,
371371
}));
372372
},
373373
acceptMintingDelegationProposal: async proposalContractId => {

apps/wallet/frontend/src/routes/delegations.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ interface DelegationRowProps {
155155

156156
const DelegationRow: React.FC<DelegationRowProps> = ({ delegation }) => {
157157
const { withdrawMintingDelegation } = useWalletClient();
158-
const { contract, beneficiaryOnboarded: beneficiaryHosted } = delegation;
158+
const { contract, beneficiaryHosted } = delegation;
159159
const [confirmDialogOpen, setConfirmDialogOpen] = useState(false);
160160

161161
const withdrawMutation = useMutation({
@@ -250,7 +250,7 @@ interface ProposalRowProps {
250250

251251
const ProposalRow: React.FC<ProposalRowProps> = ({ proposal, existingDelegation }) => {
252252
const { acceptMintingDelegationProposal, rejectMintingDelegationProposal } = useWalletClient();
253-
const { contract, beneficiaryOnboarded: beneficiaryHosted } = proposal;
253+
const { contract, beneficiaryHosted } = proposal;
254254
const [acceptDialogOpen, setAcceptDialogOpen] = useState(false);
255255
const [rejectDialogOpen, setRejectDialogOpen] = useState(false);
256256

0 commit comments

Comments
 (0)