Skip to content

Fetch recipients from Forms API #1336

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .nais/fyllut/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ spec:
value: {{pdl-token-scope-cluster}}
- name: AMPLITUDE_API_ENDPOINT
value: "https://amplitude.nav.no/collect-auto"
- name: FORMS_API_URL
value: {{forms-api-url}}{{^forms-api-url}}http://forms-api.fyllut-sendinn{{/forms-api-url}}
{{#each environmentVars}}
- name: {{this.name}}
value: {{this.value}}
Expand Down
2 changes: 2 additions & 0 deletions .nais/fyllut/dev-delingslenke.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ skjemabygging-proxy-client-id: 95170319-b4d7-4190-8271-118ed19bafbf
skjemabygging-proxy-url: https://skjemabygging-proxy.dev-fss-pub.nais.io
send-inn-token-x-client-id: dev-gcp:team-soknad:innsending-api
send-inn-host: http://innsending-api.team-soknad
forms-api-url: https://forms-api.nav.no
kodeverk:
url: https://kodeverk-api.nav.no
scope: dev-gcp.team-rocket.kodeverk-api
Expand Down Expand Up @@ -49,3 +50,4 @@ accessPolicy:
- host: skjemabygging-proxy.dev-fss-pub.nais.io
- host: formio-api.intern.dev.nav.no
- host: kodeverk-api.nav.no
- host: forms-api.nav.no
3 changes: 3 additions & 0 deletions .nais/fyllut/dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ accessPolicy:
- application: nav-dekoratoren
namespace: personbruker
cluster: dev-gcp
- application: forms-api
namespace: fyllut-sendinn
cluster: dev-gcp
external:
- host: skjemabygging-proxy.dev-fss-pub.nais.io
- host: formio-api.intern.dev.nav.no
Expand Down
3 changes: 3 additions & 0 deletions .nais/fyllut/preprod-alt.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ accessPolicy:
- application: nav-dekoratoren
namespace: personbruker
cluster: dev-gcp
- application: forms-api
namespace: fyllut-sendinn
cluster: dev-gcp
external:
- host: skjemabygging-proxy.dev-fss-pub.nais.io
- host: formio-api.intern.dev.nav.no
Expand Down
3 changes: 3 additions & 0 deletions .nais/fyllut/preprod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ accessPolicy:
- application: nav-dekoratoren
namespace: personbruker
cluster: dev-gcp
- application: forms-api
namespace: fyllut-sendinn
cluster: dev-gcp
external:
- host: skjemabygging-proxy.dev-fss-pub.nais.io
- host: formio-api.intern.dev.nav.no
Expand Down
3 changes: 3 additions & 0 deletions .nais/fyllut/prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ accessPolicy:
- application: kodeverk-api
namespace: team-rocket
cluster: prod-gcp
- application: forms-api
namespace: fyllut-sendinn
cluster: prod-gcp
external:
- host: skjemabygging-proxy.prod-fss-pub.nais.io
- host: formio-api.intern.nav.no
4 changes: 2 additions & 2 deletions packages/bygger/cypress/e2e/diff.spec.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ describe('Diff', () => {
cy.intercept('GET', '/api/published-forms/dif123456', { fixture: 'form123456-published.json' }).as(
'getPublishedForm',
);
cy.intercept('GET', '/mottaksadresse/submission', { fixture: 'mottakadresse.json' }).as('getMottakAdresse');
cy.intercept('GET', '/api/recipients', { fixture: 'recipients.json' }).as('getRecipients');
cy.intercept('GET', /language\/submission?.*/, { fixture: 'globalTranslations.json' }).as('getTranslations');
cy.intercept('GET', '/api/temakoder', { fixture: 'temakoder.json' }).as('getTemaKoder');
});
Expand All @@ -16,7 +16,7 @@ describe('Diff', () => {
cy.wait('@getConfig');
cy.wait('@getForm');
cy.wait('@getPublishedForm');
cy.wait('@getMottakAdresse');
cy.wait('@getRecipients');
cy.wait('@getTemaKoder');
cy.wait('@getTranslations');
});
Expand Down
1 change: 0 additions & 1 deletion packages/bygger/cypress/e2e/form-builder.spec.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ describe('Form Builder', () => {
beforeEach(() => {
cy.intercept('GET', '/api/config', { fixture: 'config.json' }).as('getConfig');
cy.intercept('GET', /language\/submission?.*/, { fixture: 'globalTranslations.json' }).as('getTranslations');
cy.intercept('GET', '/mottaksadresse/submission', { fixture: 'mottakadresse.json' }).as('getMottakAdresse');
cy.intercept('GET', '/api/temakoder', { fixture: 'temakoder.json' }).as('getTemaKoder');
});

Expand Down
2 changes: 1 addition & 1 deletion packages/bygger/cypress/e2e/settings.spec.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('FormSettingsPage', () => {
fixture: 'getForm.json',
}).as('getForm');
cy.intercept('GET', '/api/published-forms/*', { statusCode: 404 }).as('getPublishedForm');
cy.intercept('GET', '/mottaksadresse/submission', { fixture: 'mottakadresse.json' }).as('getMottakAdresse');
cy.intercept('GET', '/api/recipients', { fixture: 'recipients.json' }).as('getRecipients');
cy.intercept('GET', /language\/submission?.*/, { fixture: 'globalTranslations.json' }).as('getTranslations');
cy.intercept('GET', '/api/temakoder', { fixture: 'temakoder.json' }).as('getTemaKoder');
cy.visit('forms/cypresssettings/settings');
Expand Down
123 changes: 123 additions & 0 deletions packages/bygger/cypress/fixtures/recipients.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
[
{
"recipientId": "6173f82ea9a3430003fac933",
"name": "NAV Skanning sykmelding del A ",
"poBoxAddress": "Postboks 1411 Sentrum ",
"postalCode": "0109",
"postalName": "Oslo",
"createdAt": "2021-10-23T13:55:26.568+02:00",
"createdBy": "IMPORT",
"changedAt": "2021-10-25T19:14:21.371+02:00",
"changedBy": "IMPORT"
},
{
"recipientId": "6177bea68e0d00000370f2ef",
"name": "NAV Pensjon",
"poBoxAddress": "Postboks 6600 Etterstad",
"postalCode": "0607",
"postalName": "Oslo",
"createdAt": "2021-10-26T10:39:02.454+02:00",
"createdBy": "IMPORT",
"changedAt": "2021-10-26T10:39:02.455+02:00",
"changedBy": "IMPORT"
},
{
"recipientId": "61af4b3a1127300003cb8d31",
"name": "NAV Familie- og pensjonsytelser Oslo 2",
"poBoxAddress": "Postboks 6600 Etterstad",
"postalCode": "0607",
"postalName": "Oslo",
"createdAt": "2021-12-07T12:53:30.409+01:00",
"createdBy": "IMPORT",
"changedAt": "2021-12-07T12:53:30.41+01:00",
"changedBy": "IMPORT"
},
{
"recipientId": "61c09f91ec962a0003c65014",
"name": "NAV Skanning bidrag",
"poBoxAddress": "PB 6215 Etterstad",
"postalCode": "0603",
"postalName": "Oslo",
"createdAt": "2021-12-20T16:21:53.673+01:00",
"createdBy": "IMPORT",
"changedAt": "2021-12-20T16:21:53.685+01:00",
"changedBy": "IMPORT"
},
{
"recipientId": "6246de1afd03d2caeeda2825",
"name": "NAV Arbeid og ytelser lønnsgaranti",
"poBoxAddress": "Postboks 6683 St. Olavs Plass",
"postalCode": "0129",
"postalName": "Oslo",
"createdAt": "2022-04-01T13:12:26.434+02:00",
"createdBy": "IMPORT",
"changedAt": "2022-04-01T13:12:26.438+02:00",
"changedBy": "IMPORT"
},
{
"recipientId": "62bc3f3f4a6e0d0bbc83bf30",
"name": "NAV Økonomi pensjon",
"poBoxAddress": "Postboks 6600 Etterstad",
"postalCode": "0607",
"postalName": "Oslo",
"createdAt": "2022-06-29T14:02:07.432+02:00",
"createdBy": "IMPORT",
"changedAt": "2022-06-29T14:02:07.433+02:00",
"changedBy": "IMPORT"
},
{
"recipientId": "6536331ef0f518e1e5cf0a30",
"name": "NAV skanning",
"poBoxAddress": "Postboks 1402",
"postalCode": "0109",
"postalName": "Oslo",
"createdAt": "2023-10-23T10:47:26.101+02:00",
"createdBy": "IMPORT",
"changedAt": "2023-10-23T10:47:26.103+02:00",
"changedBy": "IMPORT"
},
{
"recipientId": "65aa418f3ad9b63ae4a0d5a9",
"name": "NAV Registerforvaltning - Tipsmottaket",
"poBoxAddress": "Postboks 4330",
"postalCode": "2308",
"postalName": "Hamar",
"createdAt": "2024-01-19T10:31:59.353+01:00",
"createdBy": "IMPORT",
"changedAt": "2024-01-19T10:31:59.355+01:00",
"changedBy": "IMPORT"
},
{
"recipientId": "6173f7e7a9a3430003fac931",
"name": "NAV Økonomi Stønad",
"poBoxAddress": "Postboks 354",
"postalCode": "8601",
"postalName": "MO I RANA",
"createdAt": "2021-10-23T13:54:15.537+02:00",
"createdBy": "IMPORT",
"changedAt": "2024-10-16T12:18:09.155434+02:00",
"changedBy": "Lars Olav Torvik"
},
{
"recipientId": "90ead851-04e1-4f64-83e7-2e45a93a649d",
"name": "NAV Test 3",
"poBoxAddress": "Postboks 3",
"postalCode": "0591",
"postalName": "Oslo",
"createdAt": "2024-10-10T21:10:51.218632+02:00",
"createdBy": "Ann Katrin Gagnat",
"changedAt": "2024-10-16T13:51:04.336741+02:00",
"changedBy": "Ann Katrin Gagnat"
},
{
"recipientId": "6177c7998e0d00000370f2f1",
"name": "NAV Registerforvaltning 2",
"poBoxAddress": "Tipsmottaket",
"postalCode": "2308",
"postalName": "Hamar",
"createdAt": "2021-10-26T11:17:13.075+02:00",
"createdBy": "IMPORT",
"changedAt": "2024-10-18T10:29:09.889821+02:00",
"changedBy": "Ann Katrin Gagnat"
}
]
2 changes: 0 additions & 2 deletions packages/bygger/src/AuthenticatedApp.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { FormsRouter } from './Forms';
import ImportFormsPage from './import/ImportFormsPage';
import BulkPublishPage from './migration/BulkPublishPage';
import MigrationRouter from './migration/MigrationRouter';
import MottaksadresserPage from './mottaksadresser/MottaksadresserPage';
import RecipientsPage from './recipients/RecipientsPage';
import ReportsPage from './reports/ReportsPage';
import TranslationsRouter from './translations/TranslationsRouter';
Expand All @@ -16,7 +15,6 @@ function AuthenticatedApp({ serverURL, formio }) {
<Route path="/forms/*" element={<FormsRouter formio={formio} serverURL={serverURL} />} />
<Route path="/translations/*" element={<TranslationsRouter formio={formio} serverURL={serverURL} />} />
<Route path="/import/skjema" element={<ImportFormsPage />} />
<Route path="/mottaksadresser" element={<MottaksadresserPage />} />
<Route path="/mottakere" element={<RecipientsPage />} />
<Route path="/migrering/*" element={<MigrationRouter />} />
<Route path="/bulk-publisering" element={<BulkPublishPage />} />
Expand Down
5 changes: 4 additions & 1 deletion packages/bygger/src/Forms/settings/FormSettingsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import RowLayout from '../../components/layout/RowLayout';
import Title from '../../components/layout/Title';
import TitleRowLayout from '../../components/layout/TitleRowLayout';
import { useForm } from '../../context/form/FormContext';
import RecipientsProvider from '../../context/recipients/RecipientsContext';
import PublishModalComponents from '../publish/PublishModalComponents';
import FormSettingsSidebar from './FormSettingsSidebar';

Expand Down Expand Up @@ -67,7 +68,9 @@ export function FormSettingsPage({ form }: FormSettingsPageProps) {
/>
}
>
<FormMetadataEditor form={form} onChange={changeForm} errors={errors} />
<RecipientsProvider>
<FormMetadataEditor form={form} onChange={changeForm} errors={errors} />
</RecipientsProvider>
</RowLayout>
<PublishModalComponents
form={form}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,17 @@ import React from 'react';
import { v4 as uuidv4 } from 'uuid';
import form from '../../../example_data/Form.json';
import featureToggles from '../../../test/featureToggles';
import mockMottaksadresser from '../../fakeBackend/mock-mottaksadresser';
import mockRecipients from '../../fakeBackend/mock-recipients';
import { CreationFormMetadataEditor, FormMetadataEditor } from './FormMetadataEditor';
import { UpdateFormFunction } from './utils/utils';

const testform = form as unknown as NavFormType;

vi.mock('../../hooks/useMottaksadresser', () => {
vi.mock('../../context/recipients/RecipientsContext', () => {
return {
default: () => ({
ready: true,
mottaksadresser: mockMottaksadresser,
errorMessage: undefined,
useRecipients: () => ({
isReady: true,
recipients: mockRecipients,
}),
};
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Alert, Link, Select } from '@navikt/ds-react';
import { MottaksadresseData, NavFormSettingsDiff, NavFormType } from '@navikt/skjemadigitalisering-shared-domain';
import { Link, Select } from '@navikt/ds-react';
import { NavFormSettingsDiff, NavFormType, Recipient } from '@navikt/skjemadigitalisering-shared-domain';
import { Link as ReactRouterLink } from 'react-router-dom';
import useMottaksadresser from '../../../hooks/useMottaksadresser';
import { useRecipients } from '../../../context/recipients/RecipientsContext';
import LabelWithDiff from '../LabelWithDiff';
import { UpdateFormFunction } from '../utils/utils';

Expand All @@ -15,17 +15,10 @@ const AddressFields = ({ onChange, diff, form }: AddressFieldsProps) => {
const innsending = form.properties.innsending || 'PAPIR_OG_DIGITAL';
const mottaksadresseId = form.properties.mottaksadresseId;
const isLockedForm = form.properties.isLockedForm;
const { mottaksadresser, ready: isMottaksAdresserReady, errorMessage: mottaksadresseError } = useMottaksadresser();
const { isReady: isMottaksAdresserReady, recipients } = useRecipients();

const toAddressString = (address: MottaksadresseData) => {
const linjer = [address.adresselinje1];
if (address.adresselinje2) {
linjer.push(address.adresselinje2);
}
if (address.adresselinje3) {
linjer.push(address.adresselinje3);
}
return `${linjer.join(', ')}, ${address.postnummer} ${address.poststed}`;
const toAddressString = (recipient: Recipient) => {
return `${recipient.name}, ${recipient.poBoxAddress}, ${recipient.postalCode} ${recipient.postalName}`;
};

return (
Expand Down Expand Up @@ -53,21 +46,16 @@ const AddressFields = ({ onChange, diff, form }: AddressFieldsProps) => {
<option value="">
{mottaksadresseId && !isMottaksAdresserReady ? `Mottaksadresse-id: ${mottaksadresseId}` : 'Standard'}
</option>
{mottaksadresser.map((adresse) => (
<option value={adresse._id} key={adresse._id}>
{toAddressString(adresse.data)}
{recipients.map((recipient) => (
<option value={recipient.recipientId} key={recipient.recipientId}>
{toAddressString(recipient)}
</option>
))}
</Select>
{mottaksadresseError && (
<Alert variant="error" size="small">
{mottaksadresseError}
</Alert>
)}
</div>
)}
<div className="mb">
<Link as={ReactRouterLink} to="/mottaksadresser">
<Link as={ReactRouterLink} to="/mottakere">
Rediger mottaksadresser
</Link>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { System } from '@navikt/ds-icons';
import { Dropdown, InternalHeader, Tag } from '@navikt/ds-react';
import { Dropdown, InternalHeader } from '@navikt/ds-react';
import useUnsavedChangesModal from '../../../hooks/useUnsavedChangesModal';
import { AdminMenuLink } from './AdminMenuLink';

Expand Down Expand Up @@ -32,18 +32,10 @@ const AdminMenu = ({ showImport = false }) => {
Bulkpublisering
</AdminMenuLink>
</Dropdown.Menu.GroupedList.Item>
<Dropdown.Menu.GroupedList.Item>
<AdminMenuLink showUnsavedChangesModal={showUnsavedChangesModal} to="/mottaksadresser">
Rediger mottaksadresser
</AdminMenuLink>
</Dropdown.Menu.GroupedList.Item>
<Dropdown.Menu.GroupedList.Item>
<AdminMenuLink showUnsavedChangesModal={showUnsavedChangesModal} to="/mottakere">
Mottakere
</AdminMenuLink>
<Tag size={'small'} variant={'warning'}>
Beta
</Tag>
</Dropdown.Menu.GroupedList.Item>

<Dropdown.Menu.GroupedList.Item>
Expand Down
20 changes: 20 additions & 0 deletions packages/bygger/src/fakeBackend/mock-recipients.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Recipient } from '@navikt/skjemadigitalisering-shared-domain';

const recipients: Recipient[] = [
{
recipientId: '1',
name: 'NAV alternativ skanning',
poBoxAddress: 'Postboks 3',
postalCode: '0591',
postalName: 'Oslo',
},
{
recipientId: '2',
name: 'NAV skanning Molde',
poBoxAddress: 'Storgata 1',
postalCode: '6400',
postalName: 'Molde',
},
];

export default recipients;
Loading