Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/libs/Navigation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,10 @@ type SettingsNavigatorParamList = {
[SCREENS.SETTINGS.PROFILE.STATUS_CLEAR_AFTER_DATE]: undefined;
[SCREENS.SETTINGS.PROFILE.STATUS_CLEAR_AFTER_TIME]: undefined;
[SCREENS.WORKSPACE.CURRENCY]: undefined;
[SCREENS.WORKSPACE.ADDRESS]: undefined;
[SCREENS.WORKSPACE.ADDRESS]: {
policyID: string;
country?: Country | '';
};
[SCREENS.WORKSPACE.NAME]: undefined;
[SCREENS.WORKSPACE.DESCRIPTION]: undefined;
[SCREENS.WORKSPACE.SHARE]: undefined;
Expand Down
13 changes: 12 additions & 1 deletion src/pages/workspace/WorkspaceProfileAddressPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Navigation from '@libs/Navigation/Navigation';
import type {SettingsNavigatorParamList} from '@libs/Navigation/types';
import {updateAddress} from '@userActions/Policy';
import type {Country} from '@src/CONST';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type SCREENS from '@src/SCREENS';
import type {CompanyAddress} from '@src/types/onyx/Policy';
Expand All @@ -19,7 +20,7 @@ type WorkspaceProfileAddressPagePolicyProps = WithPolicyProps;

type WorkspaceProfileAddressPageProps = StackScreenProps<SettingsNavigatorParamList, typeof SCREENS.WORKSPACE.ADDRESS> & WorkspaceProfileAddressPagePolicyProps;

function WorkspaceProfileAddressPage({policy}: WorkspaceProfileAddressPageProps) {
function WorkspaceProfileAddressPage({policy, route}: WorkspaceProfileAddressPageProps) {
const {translate} = useLocalize();
const address = useMemo(() => policy?.address, [policy]);
const [currentCountry, setCurrentCountry] = useState(address?.country);
Expand All @@ -28,6 +29,9 @@ function WorkspaceProfileAddressPage({policy}: WorkspaceProfileAddressPageProps)
const [city, setCity] = useState(address?.city);
const [zipcode, setZipcode] = useState(address?.zipCode);

const countryFromUrlTemp = route?.params?.country;
const countryFromUrl = CONST.ALL_COUNTRIES[countryFromUrlTemp as keyof typeof CONST.ALL_COUNTRIES] ? countryFromUrlTemp : '';

const updatePolicyAddress = (values: FormOnyxValues<typeof ONYXKEYS.FORMS.HOME_ADDRESS_FORM>) => {
if (!policy) {
return;
Expand Down Expand Up @@ -81,6 +85,13 @@ function WorkspaceProfileAddressPage({policy}: WorkspaceProfileAddressPageProps)
setZipcode(address.zipCode);
}, [address]);

useEffect(() => {
if (!countryFromUrl) {
return;
}
handleAddressChange(countryFromUrl, 'country');
}, [countryFromUrl, handleAddressChange]);

return (
<ScreenWrapper
includeSafeAreaPaddingBottom={false}
Expand Down
1 change: 1 addition & 0 deletions src/pages/workspace/withPolicy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ type PolicyRoute = RouteProp<
| typeof SCREENS.WORKSPACE.CARD
| typeof SCREENS.WORKSPACE.OWNER_CHANGE_CHECK
| typeof SCREENS.WORKSPACE.TAX_EDIT
| typeof SCREENS.WORKSPACE.ADDRESS
>;

function getPolicyIDFromRoute(route: PolicyRoute): string {
Expand Down