Skip to content

Commit

Permalink
feat(pn-10953): Mandate api migration (#1209)
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreaCimini90 authored May 20, 2024
1 parent aa6fda2 commit c85c72f
Show file tree
Hide file tree
Showing 97 changed files with 5,586 additions and 1,615 deletions.
6 changes: 3 additions & 3 deletions packages/pn-commons/src/utility/redux.utility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ export function parseError(e: any) {
* D'altro canto, la funzione che si passa verso performThunkAction può avere parametri, e può realizzare azione più complesse
* che chiamare un'API senza parametri, o con i parametri che vengono passati. Un esempio
export const acceptDelegation = createAsyncThunk<
export const acceptMandate = createAsyncThunk<
AcceptDelegationResponse,
{ id: string; code: string }
>('acceptDelegation',
>('acceptMandate',
performThunkAction(async ({id, code}: { id: string; code: string }) => {
const data = {
verificationCode: code,
};
return await DelegationsApi.acceptDelegation(id, data);
return await DelegationsApi.acceptMandate(id, data);
})
);
Expand Down
11 changes: 11 additions & 0 deletions packages/pn-personafisica-webapp/openapitools.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,17 @@
"modelPackage": "models",
"cleanupOutput": true
}
},
"bff-mandate": {
"generatorName": "typescript-axios",
"inputSpec": "https://raw.githubusercontent.com/pagopa/pn-bff/develop/docs/openapi/api-external-pn-bff-recipient-mandate.yaml",
"output": "./src/generated-client/mandate",
"additionalProperties": {
"supportsES6": true,
"apiPackage": "apis",
"modelPackage": "models",
"cleanupOutput": true
}
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions packages/pn-personafisica-webapp/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import Router from './navigation/routes';
import * as routes from './navigation/routes.const';
import { getCurrentAppStatus } from './redux/appStatus/actions';
import { logout } from './redux/auth/actions';
import { Delegation } from './redux/delegation/types';
import { useAppDispatch, useAppSelector } from './redux/hooks';
import { getDomicileInfo, getSidemenuInformation } from './redux/sidemenu/actions';
import { RootState } from './redux/store';
Expand Down Expand Up @@ -149,7 +148,7 @@ const App = () => {
label: t('title', { ns: 'notifiche' }),
route: routes.NOTIFICHE,
};
const mappedDelegators = delegators.map((delegator: Delegation) => ({
const mappedDelegators = delegators.map((delegator) => ({
label:
'delegator' in delegator && delegator.delegator
? `${delegator.delegator.displayName}`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { RecipientType } from '@pagopa-pn/pn-commons';

import { CreateDelegationResponse, NewDelegationFormProps } from '../redux/delegation/types';
import { NewDelegationFormProps } from '../redux/delegation/types';

export const createDelegationPayload: NewDelegationFormProps = {
selectPersonaFisicaOrPersonaGiuridica: RecipientType.PF,
Expand All @@ -20,24 +20,6 @@ export const createDelegationSelectedPayload: NewDelegationFormProps = {
enti: [{ name: 'test', id: 'test' }],
};

export const createDelegationResponse: CreateDelegationResponse = {
datefrom: '2022-01-01',
dateto: '2022-01-02',
delegate: {
firstName: 'nome',
lastName: 'cognome',
displayName: 'nome cognome',
fiscalCode: 'fiscalCode',
companyName: 'companyName',
person: true,
},
delegator: null,
mandateId: '1',
status: 'pending',
verificationCode: '00000',
visibilityIds: [],
};

export const createDelegationGenericErrorResponse = {
status: 401,
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { CreateDelegationProps, Delegate, Delegator } from '../redux/delegation/types';
import { Delegate, Delegator, NewMandateRequest } from '../redux/delegation/types';

export const mockCreateDelegation: CreateDelegationProps = {
export const mockCreateDelegation: NewMandateRequest = {
delegate: {
firstName: 'Davide',
lastName: 'Legato',
Expand All @@ -19,7 +19,7 @@ export const mockCreateDelegation: CreateDelegationProps = {
dateto: '2022-04-16',
};

export const arrayOfDelegates: Array<Delegate> = [
export const mandatesByDelegator: Array<Delegate> = [
{
mandateId: '1',
delegate: {
Expand Down Expand Up @@ -64,7 +64,7 @@ export const arrayOfDelegates: Array<Delegate> = [
},
];

export const arrayOfDelegators: Array<Delegator> = [
export const mandatesByDelegate: Array<Delegator> = [
{
mandateId: '3',
delegator: {
Expand Down
17 changes: 8 additions & 9 deletions packages/pn-personafisica-webapp/src/__test__/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ import { currentStatusDTO } from '../__mocks__/AppStatus.mock';
import { userResponse } from '../__mocks__/Auth.mock';
import { tosPrivacyConsentMock } from '../__mocks__/Consents.mock';
import { digitalAddresses } from '../__mocks__/Contacts.mock';
import { arrayOfDelegators } from '../__mocks__/Delegations.mock';
import { mandatesByDelegate } from '../__mocks__/Delegations.mock';
import { apiClient } from '../api/apiClients';
import { DELEGATIONS_BY_DELEGATE } from '../api/delegations/delegations.routes';
import {
RenderResult,
act,
Expand Down Expand Up @@ -109,7 +108,7 @@ describe('App', async () => {
mock.onGet('/bff/v1/tos-privacy').reply(200, tosPrivacyConsentMock(true, true));
mock.onGet('downtime/v1/status').reply(200, currentStatusDTO);
mock.onGet('/bff/v1/addresses').reply(200, digitalAddresses);
mock.onGet(DELEGATIONS_BY_DELEGATE()).reply(200, arrayOfDelegators);
mock.onGet('/bff/v1/mandate/delegate').reply(200, mandatesByDelegate);
await act(async () => {
result = render(<Component />, { preloadedState: reduxInitialState });
});
Expand All @@ -127,7 +126,7 @@ describe('App', async () => {
mock.onGet('/bff/v1/tos-privacy').reply(200, tosPrivacyConsentMock(true, true));
mock.onGet('downtime/v1/status').reply(200, currentStatusDTO);
mock.onGet('/bff/v1/addresses').reply(200, digitalAddresses);
mock.onGet(DELEGATIONS_BY_DELEGATE()).reply(200, arrayOfDelegators);
mock.onGet('/bff/v1/mandate/delegate').reply(200, mandatesByDelegate);
await act(async () => {
result = render(<Component />, { preloadedState: reduxInitialState });
});
Expand Down Expand Up @@ -161,7 +160,7 @@ describe('App', async () => {
mock.onGet('/bff/v1/tos-privacy').reply(500);
mock.onGet('downtime/v1/status').reply(200, currentStatusDTO);
mock.onGet('/bff/v1/addresses').reply(200, digitalAddresses);
mock.onGet(DELEGATIONS_BY_DELEGATE()).reply(200, arrayOfDelegators);
mock.onGet('/bff/v1/mandate/delegate').reply(200, mandatesByDelegate);
await act(async () => {
result = render(<Component />, { preloadedState: reduxInitialState });
});
Expand All @@ -175,7 +174,7 @@ describe('App', async () => {
mock.onGet('/bff/v1/tos-privacy').reply(200, tosPrivacyConsentMock(false, false));
mock.onGet('downtime/v1/status').reply(200, currentStatusDTO);
mock.onGet('/bff/v1/addresses').reply(200, digitalAddresses);
mock.onGet(DELEGATIONS_BY_DELEGATE()).reply(200, arrayOfDelegators);
mock.onGet('/bff/v1/mandate/delegate').reply(200, mandatesByDelegate);
await act(async () => {
result = render(<Component />, { preloadedState: reduxInitialState });
});
Expand All @@ -191,7 +190,7 @@ describe('App', async () => {
mock.onGet('/bff/v1/tos-privacy').reply(200, tosPrivacyConsentMock(false, false));
mock.onGet('downtime/v1/status').reply(200, currentStatusDTO);
mock.onGet('/bff/v1/addresses').reply(200, digitalAddresses);
mock.onGet(DELEGATIONS_BY_DELEGATE()).reply(200, arrayOfDelegators);
mock.onGet('/bff/v1/mandate/delegate').reply(200, mandatesByDelegate);
await act(async () => {
render(<Component />, { preloadedState: reduxInitialState });
});
Expand All @@ -208,7 +207,7 @@ describe('App', async () => {
mock.onGet('/bff/v1/tos-privacy').reply(200, tosPrivacyConsentMock(true, true));
mock.onGet('downtime/v1/status').reply(200, currentStatusDTO);
mock.onGet('/bff/v1/addresses').reply(200, digitalAddresses);
mock.onGet(DELEGATIONS_BY_DELEGATE()).reply(200, arrayOfDelegators);
mock.onGet('/bff/v1/mandate/delegate').reply(200, mandatesByDelegate);
await act(async () => {
result = render(<Component />, { preloadedState: reduxInitialState });
});
Expand All @@ -223,7 +222,7 @@ describe('App', async () => {
mock.onGet('/bff/v1/tos-privacy').reply(200, tosPrivacyConsentMock(true, true));
mock.onGet('downtime/v1/status').reply(200, currentStatusDTO);
mock.onGet('/bff/v1/addresses').reply(200, digitalAddresses);
mock.onGet(DELEGATIONS_BY_DELEGATE()).reply(200, []);
mock.onGet('/bff/v1/mandate/delegate').reply(200, []);
await act(async () => {
result = render(<Component />, { preloadedState: reduxInitialState });
});
Expand Down

This file was deleted.

Loading

0 comments on commit c85c72f

Please sign in to comment.