From 37540a879f439ad514d92c569f525ad37baf5b31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Demazi=C3=A8re?= Date: Thu, 24 Mar 2022 10:29:06 +0100 Subject: [PATCH] prevent city name loss --- package.json | 2 +- src/components/panel-body/UEpage/forms/addressForm.js | 7 +++---- src/utils/functions/surveyUnitFunctions.js | 3 ++- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 326a4a187..4b9676ed2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pearl", - "version": "0.5.2", + "version": "0.5.3", "private": true, "dependencies": { "@date-io/date-fns": "1.x", diff --git a/src/components/panel-body/UEpage/forms/addressForm.js b/src/components/panel-body/UEpage/forms/addressForm.js index d81d49dd6..19cb36636 100644 --- a/src/components/panel-body/UEpage/forms/addressForm.js +++ b/src/components/panel-body/UEpage/forms/addressForm.js @@ -1,7 +1,8 @@ -import { Button, DialogActions, DialogTitle, makeStyles, TextField } from '@material-ui/core'; +import { Button, DialogActions, DialogTitle, TextField, makeStyles } from '@material-ui/core'; +import React, { useContext, useState } from 'react'; + import D from 'i18n'; import PropTypes from 'prop-types'; -import React, { useContext, useState } from 'react'; import SurveyUnitContext from '../UEContext'; const useStyles = makeStyles(() => ({ @@ -14,8 +15,6 @@ const useStyles = makeStyles(() => ({ const Form = ({ closeModal, save, previousValue }) => { const { surveyUnit } = useContext(SurveyUnitContext); - /** previousValue =[ { label: D.anyOne , value: realValue }, {}, ... ] */ - /** previousData = { D.anyOne: realValue , D.anotherOne: anotherRealValue } */ const previousData = previousValue.reduce( (obj, { label, value }) => ({ ...obj, [label]: value }), {} diff --git a/src/utils/functions/surveyUnitFunctions.js b/src/utils/functions/surveyUnitFunctions.js index afcc050b0..b77db8e68 100644 --- a/src/utils/functions/surveyUnitFunctions.js +++ b/src/utils/functions/surveyUnitFunctions.js @@ -295,7 +295,8 @@ export const isSelectable = su => { }; export const getAddressData = su => { - const [postCode, cityName] = su.address.l6.split(' '); + const [postCode, ...rest] = su.address.l6.split(' '); + const cityName = rest.join(' '); return [ { label: D.addressDeliveryPoint, value: su.address.l2 || '' },