From 918cd4aef344bb06bce239cfb5ed16277b1ed41d Mon Sep 17 00:00:00 2001 From: elforjani13 <39470382+elforjani13@users.noreply.github.com> Date: Thu, 11 Nov 2021 15:39:42 +0200 Subject: [PATCH] feat: add display name defaultText --- src/components/DisplayNameList.js | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/src/components/DisplayNameList.js b/src/components/DisplayNameList.js index cb09cb4ac..3deba980f 100644 --- a/src/components/DisplayNameList.js +++ b/src/components/DisplayNameList.js @@ -1,5 +1,6 @@ import React from 'react'; -import ListSelect from "./ListSelect"; +import intl from 'react-intl-universal'; +import ListSelect from './ListSelect'; export default function DisplayNameList({ salutation, @@ -9,25 +10,32 @@ export default function DisplayNameList({ ...restProps }) { const formats = [ - { format: '{1} {2} {3}', values: [salutation, firstName, lastName], required: [1] }, + { + format: '{1} {2} {3}', + values: [salutation, firstName, lastName], + required: [1], + }, { format: '{1} {2}', values: [firstName, lastName], required: [] }, { format: '{1}, {2}', values: [firstName, lastName], required: [1, 2] }, - { format: '{1}', values: [company], required: [1] } + { format: '{1}', values: [company], required: [1] }, ]; const formatOptions = formats - .filter((format) => !format.values.some((value, index) => { - return !value && format.required.indexOf(index + 1) !== -1; - })) + .filter( + (format) => + !format.values.some((value, index) => { + return !value && format.required.indexOf(index + 1) !== -1; + }), + ) .map((formatOption) => { const { format, values } = formatOption; let label = format; values.forEach((value, index) => { - const replaceWith = (value || ''); + const replaceWith = value || ''; label = label.replace(`{${index + 1}}`, replaceWith).trim(); }); - return { label: label.replace(/\s+/g, " ") }; + return { label: label.replace(/\s+/g, ' ') }; }); return ( @@ -35,9 +43,9 @@ export default function DisplayNameList({ items={formatOptions} selectedItemProp={'label'} textProp={'label'} - defaultText={'Select display name as'} + defaultText={intl.get('select_display_name_as')} filterable={false} - { ...restProps } + {...restProps} /> ); -} \ No newline at end of file +}