Skip to content

Commit

Permalink
Prefill country calling code in onboarding survey
Browse files Browse the repository at this point in the history
ref DEV-1647
  • Loading branch information
louischan-oursky committed Aug 20, 2024
2 parents e332a5f + 2d798be commit a3a6de1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions portal/src/OnboardingSurveyScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,9 @@ function Step2(_props: StepProps) {
}

function Step3Team(_props: StepProps) {
const { viewer } = useViewerQuery();
const { geoIPCountryCode } = viewer ?? {};

const prefix = "step3team";
const companyNameFromLocalStorage = getFromLocalStorage("company_name");
const [companyName, setCompanyName] = useState(
Expand Down Expand Up @@ -603,6 +606,7 @@ function Step3Team(_props: StepProps) {
"OnboardingSurveyScreen.step3-team.phone.label"
)}
inputValue={companyPhone.rawInputValue}
initialCountry={geoIPCountryCode ?? undefined}
onChange={(v) => setCompanyPhone(v)}
/>
</FormProvider>
Expand Down
4 changes: 3 additions & 1 deletion portal/src/PhoneTextField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ export default class PhoneTextField extends React.Component<PhoneTextFieldProps>
formatOnDisplay: false,
};
if (this.props.initialCountry != null) {
options.initialCountry = this.props.initialCountry;
// seems IntlTelInputInitOptions.initialCountry must be lowercase
// https://github.com/jackocnr/intl-tel-input/blob/c53a32b4f39996d50cde4ffa0df37726e8435ec2/src/spec/tests/options/initialCountry.js#L15
options.initialCountry = this.props.initialCountry.toLowerCase();
}
if (this.props.allowlist != null) {
options.onlyCountries = [...this.props.allowlist];
Expand Down

0 comments on commit a3a6de1

Please sign in to comment.