[VIP-Travel] Workspace address page and section in workspace profile#38381
Conversation
| const {translate} = useLocalize(); | ||
| const address = useMemo(() => policy?.address, [policy]); | ||
| const [currentCountry, setCurrentCountry] = useState(address?.country); | ||
| const [street1, street2] = (address?.addressStreet ?? '').split('\n'); | ||
| const [state, setState] = useState(address?.state); | ||
| const [city, setCity] = useState(address?.city); | ||
| const [zipcode, setZipcode] = useState(address?.zip); |
There was a problem hiding this comment.
AddressForm is already a FormProvider. Those useState hooks are needed for implementation of handleAddressChange. I agree we could simplify this as the performance is quite similar to what happens in AddressPage. But it requires some refactoring to AddressPage and AddressForm and I think it should be handled in a different PR. Especially since this PR's issue is critical.
| if (addressKey !== 'country' && addressKey !== 'state' && addressKey !== 'city' && addressKey !== 'zip') { | ||
| return; | ||
| } | ||
| if (addressKey === 'country') { | ||
| setCurrentCountry(countryValue); | ||
| setState(''); | ||
| setCity(''); | ||
| setZipcode(''); | ||
| return; | ||
| } | ||
| if (addressKey === 'state') { | ||
| setState(countryValue); | ||
| setCity(''); | ||
| setZipcode(''); | ||
| return; | ||
| } | ||
| if (addressKey === 'city') { | ||
| setCity(countryValue); | ||
| setZipcode(''); | ||
| return; | ||
| } | ||
| setZipcode(countryValue); | ||
| }, []); |
There was a problem hiding this comment.
this will get simplified afterwards I guess
| city={city} | ||
| country={currentCountry} | ||
| onAddressChanged={handleAddressChange} | ||
| state={state} | ||
| street1={street1} | ||
| street2={street2} | ||
| zip={zipcode} |
There was a problem hiding this comment.
afterwards, you can pass form data as a whole, or include it inside of AddressForm
| policyID, | ||
| // eslint-disable-next-line @typescript-eslint/naming-convention | ||
| 'data[addressStreet]': newAddress.addressStreet, | ||
| // eslint-disable-next-line @typescript-eslint/naming-convention | ||
| 'data[city]': newAddress.city, | ||
| // eslint-disable-next-line @typescript-eslint/naming-convention | ||
| 'data[country]': newAddress.country, | ||
| // eslint-disable-next-line @typescript-eslint/naming-convention | ||
| 'data[state]': newAddress.state, | ||
| // eslint-disable-next-line @typescript-eslint/naming-convention | ||
| 'data[zipCode]': newAddress.zip, | ||
| }; |
There was a problem hiding this comment.
this definitely needs to be discussed, it's weird we're passing it this way
There was a problem hiding this comment.
100% agreed. I think this is something what needs backend changes. I tried many different ways to make this API request and this is the only one which works.
There was a problem hiding this comment.
The thread about changing the endpoint on backend: https://swmansion.slack.com/archives/C05S5EV2JTX/p1713825690019579
In case of changes we need to modify this part.
|
@shubham1206agra Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
|
Just noting I created a polish issue above. Doesn't need to be included with this PR. |
Screen.Recording.2024-04-29.at.9.26.27.PM.mov@smelaa Please observe the logs when I click on the address from auto complete. It is trying to navigate too many times. |
Reviewer Checklist
Screenshots/VideosAndroid: NativeAndroid: mWeb ChromeScreen.Recording.2024-04-29.at.9.55.58.PM.moviOS: NativeScreen.Recording.2024-04-29.at.10.12.44.PM.moviOS: mWeb SafariScreen.Recording.2024-04-29.at.9.43.37.PM.movMacOS: Chrome / SafariScreen.Recording.2024-04-29.at.9.30.00.PM.movMacOS: DesktopScreen.Recording.2024-04-29.at.10.01.45.PM.mov |
|
We did not find an internal engineer to review this PR, trying to assign a random engineer to #37827 as well as to this PR... Please reach out for help on Slack if no one gets assigned! |
|
@twisterdotcom There seems to be some BE issue where addresses are not retaining for multiple workspaces. |
| @@ -0,0 +1,12 @@ | |||
| // TODO: Change API endpoint parameters format to make it possible to follow naming-convention | |||
There was a problem hiding this comment.
Has an issue been created for it?
There was a problem hiding this comment.
@deetergp is working on it here: https://github.com/Expensify/Web-Expensify/pull/41840
@shubham1206agra I've investigated this issue, and it also happens in |
|
Nice, @shubham1206agra could you report the bug in #expensify-bugs for that, and we'll get it cleaned up after? |
|
Anything stopping us from merging now? |
|
Nothing. |
|
Ahh, actually don't need you here @rushatgabhane. |
|
#41505 |
|
🚀 Deployed to production by https://github.com/marcaaron in version: 1.4.70-5 🚀
|
|
Agreed. @smelaa can you please take a look at that bug? |
|
Sure, the draft PR is almost done. |
Details
This PR adds workspace address page and address section in workspace profile. Currently it only saves the data in the state. Once backend is ready it should be adjusted to save the data using API.
Fixed Issues
$#37827
PROPOSAL:
Tests
Permissions.canUseSpotnanaTravelfunction returning always true.Offline tests
N/A
QA Steps
Same as tests.
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
MacOS: Desktop