Skip to content

Commit

Permalink
Suisin/Updated Sign up Modal Message (#6126)
Browse files Browse the repository at this point in the history
* Updated Sign up Modal Message

* Updated Localize Value

* Remove selectedCountry

* resolved characters issue

* Make Choose Country empty

* Fixed Highlight Issue

* Update highlight selection functions

* Update function
  • Loading branch information
suisin-deriv committed Aug 29, 2022
1 parent 529dd2e commit 1147568
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
15 changes: 12 additions & 3 deletions packages/components/src/components/autocomplete/autocomplete.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const Autocomplete = React.memo(props => {
autoComplete,
className,
dropdown_offset,
historyValue,
error,
has_updating_list = true,
input_id,
Expand Down Expand Up @@ -65,10 +66,18 @@ const Autocomplete = React.memo(props => {
React.useEffect(() => {
if (has_updating_list) {
setFilteredItems(list_items);
setActiveIndex(null);
setInputValue('');
if (historyValue) {
const index = filtered_items.findIndex(object => {
return object.text === historyValue;
});
setInputValue(historyValue);
setActiveIndex(index);
} else {
setInputValue('');
setActiveIndex(null);
}
}
}, [list_items, has_updating_list]);
}, [list_items, has_updating_list, historyValue]);

React.useEffect(() => {
if (should_show_list && list_item_ref.current) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const AccountSignup = ({ enableApp, isModalVisible, clients_country, onSignup, r
const [api_error, setApiError] = React.useState(false);
const [is_loading, setIsLoading] = React.useState(true);
const [country, setCountry] = React.useState('');
const history_value = React.useRef();
const [pw_input, setPWInput] = React.useState('');
const [selected_residence, setSelectedResidence] = React.useState('');
const [selected_citizenship, setSelectedCitizenship] = React.useState('');
Expand Down Expand Up @@ -110,6 +111,7 @@ const AccountSignup = ({ enableApp, isModalVisible, clients_country, onSignup, r
setFieldValue={setFieldValue}
residence_list={residence_list}
default_value={country}
history_value={history_value.current}
>
<Button
className={classNames('account-signup__btn', {
Expand All @@ -119,6 +121,7 @@ const AccountSignup = ({ enableApp, isModalVisible, clients_country, onSignup, r
is_disabled={!values.residence || !!errors.residence}
onClick={() => {
onResidenceSelection(values.residence);
history_value.current = values.residence;
}}
primary
large
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const SameCitizenshipModal = ({
}) => (
<div>
<Text as='p' className='account-signup__text'>
{localize('Are you a citizen of the same country where you live?')}
{localize('Are you a citizen of {{- residence}}?', { residence })}
</Text>
<div className='account-signup__same-citizenship'>
<Button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const SetResidenceForm = ({
class_prefix = 'set-residence',
children,
default_value,
history_value,
header_text,
errors,
touched,
Expand Down Expand Up @@ -42,6 +43,7 @@ const SetResidenceForm = ({
className={`${class_prefix}__residence-field`}
type='text'
label={localize('Choose country')}
historyValue={history_value}
error={touched.residence && errors.residence}
required
list_items={residence_list}
Expand Down Expand Up @@ -77,6 +79,7 @@ SetResidenceForm.propTypes = {
children: PropTypes.node,
class_prefix: PropTypes.string,
default_value: PropTypes.string,
history_value: PropTypes.string,
errors: PropTypes.object,
header_text: PropTypes.string,
residence_list: PropTypes.arrayOf(PropTypes.object),
Expand Down

0 comments on commit 1147568

Please sign in to comment.