Skip to content

Commit

Permalink
Merge pull request #623 from open-formulieren/feature/address-compone…
Browse files Browse the repository at this point in the history
…nt-2

Add address component
  • Loading branch information
sergei-maertens authored Jan 8, 2024
2 parents a70dd8a + 68064d3 commit b014d03
Show file tree
Hide file tree
Showing 16 changed files with 790 additions and 9 deletions.
11 changes: 11 additions & 0 deletions src/components/FormStepSummary/ComponentValueDisplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,16 @@ const CoSignDisplay = ({component, value}) => {
return <CoSignOld interactive={false} />;
};

const AddressNLDisplay = ({component, value}) => {
if (!value || Object.values(value).every(v => v === '')) {
return <EmptyDisplay />;
}

return `${value.postcode} ${value.houseNumber}${value.houseLetter || ''} ${
value.houseNumberAddition || ''
}`;
};

const ComponentValueDisplay = ({value, component}) => {
const {multiple = false, type} = component;

Expand Down Expand Up @@ -259,6 +269,7 @@ const TYPE_TO_COMPONENT = {
map: MapDisplay,
password: PasswordDisplay,
coSign: CoSignDisplay,
addressNL: AddressNLDisplay,
};

export default ComponentValueDisplay;
89 changes: 89 additions & 0 deletions src/components/Summary/Summary.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,3 +281,92 @@ export const Loading = {
isLoading: true,
},
};

export const AddressNLSummary = {
render,
args: {
summaryData: [
{
slug: 'address-nl',
name: 'Address NL',
data: [
{
name: 'Address NL',
value: {postcode: '1234 AB', houseNumber: '1'},
component: {
key: 'addressNL',
type: 'addressNL',
label: 'Address NL',
hidden: false,
},
},
],
},
],
},
play: async ({canvasElement}) => {
const canvas = within(canvasElement);
await expect(canvas.getByRole('definition')).toHaveTextContent('1234 AB 1');
},
};

export const AddressNLSummaryFull = {
render,
args: {
summaryData: [
{
slug: 'address-nl',
name: 'Address NL',
data: [
{
name: 'Address NL',
value: {
postcode: '1234 AB',
houseNumber: '1',
houseLetter: 'A',
houseNumberAddition: 'Add',
},
component: {
key: 'addressNL',
type: 'addressNL',
label: 'Address NL',
hidden: false,
},
},
],
},
],
},
play: async ({canvasElement}) => {
const canvas = within(canvasElement);
await expect(canvas.getByRole('definition')).toHaveTextContent('1234 AB 1A Add');
},
};

export const AddressNLSummaryEmpty = {
render,
args: {
summaryData: [
{
slug: 'address-nl',
name: 'Address NL',
data: [
{
name: 'Address NL',
value: {},
component: {
key: 'addressNL',
type: 'addressNL',
label: 'Address NL',
hidden: false,
},
},
],
},
],
},
play: async ({canvasElement}) => {
const canvas = within(canvasElement);
await expect(canvas.getByRole('definition')).toHaveTextContent('');
},
};
Loading

0 comments on commit b014d03

Please sign in to comment.