-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[Home Page] Add a simple onboarding slot to Home, focused on "manage my team" intent #86663
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
adamgrzybowski
wants to merge
13
commits into
Expensify:main
Choose a base branch
from
software-mansion-labs:@adamgrzybowski/onboarding-home
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
29e2993
Add tests
adamgrzybowski 86257b0
Add Getting Started onboarding checklist to Home page
adamgrzybowski 4a806bd
Simplify control flow in hasNonDefaultRules
adamgrzybowski 1875f8b
Remove unnecessary useCallback from GettingStartedRow
adamgrzybowski 3703841
Replace magic numbers with consts in GettingStartedRow
adamgrzybowski 7548620
Add explanatory comments to eslint-disable directives in useGettingSt…
adamgrzybowski 7622ea8
Fix isWithinGettingStartedPeriod to reject future trial dates
adamgrzybowski 547cc92
Fix create-workspace route assertions to use WORKSPACE_OVERVIEW
adamgrzybowski 6bab2b8
Add gettingStartedSection translations and format suggestionsAvailable
adamgrzybowski 9405144
Add Sentry label to GettingStartedRow pressable
adamgrzybowski dff7ec9
Remove default ID values from useOnyx collection keys
adamgrzybowski d75f4a7
Fix hasNonDefaultRules to detect customRules without rules object and…
adamgrzybowski b3869c4
Merge branch 'main' into @adamgrzybowski/onboarding-home
adamgrzybowski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
src/pages/home/GettingStartedSection/GettingStartedRow.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| import React from 'react'; | ||
| import {View} from 'react-native'; | ||
| import Checkbox from '@components/Checkbox'; | ||
| import Icon from '@components/Icon'; | ||
| import {PressableWithoutFeedback} from '@components/Pressable'; | ||
| import Text from '@components/Text'; | ||
| import {useMemoizedLazyExpensifyIcons} from '@hooks/useLazyAsset'; | ||
| import useResponsiveLayout from '@hooks/useResponsiveLayout'; | ||
| import useStyleUtils from '@hooks/useStyleUtils'; | ||
| import useTheme from '@hooks/useTheme'; | ||
| import useThemeStyles from '@hooks/useThemeStyles'; | ||
| import Navigation from '@libs/Navigation/Navigation'; | ||
| import variables from '@styles/variables'; | ||
| import CONST from '@src/CONST'; | ||
| import type {GettingStartedItem} from './hooks/useGettingStartedItems'; | ||
|
|
||
| type GettingStartedRowProps = { | ||
| item: GettingStartedItem; | ||
| }; | ||
|
|
||
| function GettingStartedRow({item}: GettingStartedRowProps) { | ||
| const styles = useThemeStyles(); | ||
| const theme = useTheme(); | ||
| const StyleUtils = useStyleUtils(); | ||
| const {shouldUseNarrowLayout} = useResponsiveLayout(); | ||
| const icons = useMemoizedLazyExpensifyIcons(['ArrowRight', 'Checkmark'] as const); | ||
|
|
||
| const navigateToItem = () => { | ||
| Navigation.navigate(item.route); | ||
| }; | ||
|
|
||
| return ( | ||
| <PressableWithoutFeedback | ||
| onPress={navigateToItem} | ||
| accessibilityLabel={item.label} | ||
| sentryLabel={CONST.SENTRY_LABEL.HOME_PAGE.GETTING_STARTED_ROW} | ||
| > | ||
| {({hovered}) => ( | ||
| <View style={[styles.flexRow, styles.alignItemsCenter, styles.gap3, shouldUseNarrowLayout ? styles.ph5 : styles.ph8, styles.pv3, hovered && styles.hoveredComponentBG]}> | ||
| {item.isComplete ? ( | ||
| <View | ||
| style={[ | ||
| StyleUtils.getCheckboxContainerStyle(variables.iconSizeNormal, variables.componentBorderRadiusSmall), | ||
| {backgroundColor: theme.icon, borderColor: theme.icon}, | ||
| ]} | ||
| > | ||
| <Icon | ||
adamgrzybowski marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| src={icons.Checkmark} | ||
| fill={theme.textLight} | ||
| height={variables.iconSizeSemiSmall} | ||
| width={variables.iconSizeSemiSmall} | ||
| /> | ||
| </View> | ||
| ) : ( | ||
| <Checkbox | ||
| isChecked={false} | ||
| onPress={navigateToItem} | ||
| accessibilityLabel={item.label} | ||
| /> | ||
| )} | ||
| <Text style={[styles.flex1, styles.textBold, item.isComplete && {color: theme.textSupporting}]}>{item.label}</Text> | ||
| {!item.isComplete && ( | ||
| <Icon | ||
| src={icons.ArrowRight} | ||
| width={variables.iconSizeNormal} | ||
| height={variables.iconSizeNormal} | ||
| fill={theme.icon} | ||
| /> | ||
| )} | ||
| </View> | ||
| )} | ||
| </PressableWithoutFeedback> | ||
| ); | ||
| } | ||
|
|
||
| export default GettingStartedRow; | ||
105 changes: 105 additions & 0 deletions
105
src/pages/home/GettingStartedSection/hooks/useGettingStartedItems.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| import useLocalize from '@hooks/useLocalize'; | ||
| import useOnyx from '@hooks/useOnyx'; | ||
| import {hasAccountingConnections, hasCustomCategories, hasNonDefaultRules} from '@libs/PolicyUtils'; | ||
| import isWithinGettingStartedPeriod from '@pages/home/GettingStartedSection/utils/isWithinGettingStartedPeriod'; | ||
| import CONST from '@src/CONST'; | ||
| import ONYXKEYS from '@src/ONYXKEYS'; | ||
| import ROUTES from '@src/ROUTES'; | ||
| import type {Route} from '@src/ROUTES'; | ||
|
|
||
| type GettingStartedItem = { | ||
| key: string; | ||
| label: string; | ||
| isComplete: boolean; | ||
| route: Route; | ||
| }; | ||
|
|
||
| type UseGettingStartedItemsResult = { | ||
| shouldShowSection: boolean; | ||
| items: GettingStartedItem[]; | ||
| }; | ||
|
|
||
| const DIRECT_CONNECT_INTEGRATIONS = new Set<string>([ | ||
| CONST.POLICY.CONNECTIONS.NAME.QBO, | ||
| CONST.POLICY.CONNECTIONS.NAME.QBD, | ||
| CONST.POLICY.CONNECTIONS.NAME.XERO, | ||
| CONST.POLICY.CONNECTIONS.NAME.NETSUITE, | ||
| CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT, | ||
| ]); | ||
|
|
||
| function useGettingStartedItems(): UseGettingStartedItemsResult { | ||
| const {translate} = useLocalize(); | ||
| const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED); | ||
| const [onboardingPurpose] = useOnyx(ONYXKEYS.ONBOARDING_PURPOSE_SELECTED); | ||
| const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID); | ||
| const [firstDayFreeTrial] = useOnyx(ONYXKEYS.NVP_FIRST_DAY_FREE_TRIAL); | ||
| const [reportedIntegration] = useOnyx(ONYXKEYS.ONBOARDING_USER_REPORTED_INTEGRATION); | ||
| const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${activePolicyID}`); | ||
| const [policyCategories] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${activePolicyID}`); | ||
|
|
||
| const emptyResult: UseGettingStartedItemsResult = {shouldShowSection: false, items: []}; | ||
|
|
||
| const intent = introSelected?.choice ?? onboardingPurpose; | ||
| if (intent !== CONST.ONBOARDING_CHOICES.MANAGE_TEAM) { | ||
| return emptyResult; | ||
| } | ||
|
|
||
| if (!activePolicyID || !policy) { | ||
| return emptyResult; | ||
| } | ||
|
|
||
| if (!isWithinGettingStartedPeriod(firstDayFreeTrial)) { | ||
| return emptyResult; | ||
| } | ||
|
|
||
| const items: GettingStartedItem[] = []; | ||
|
|
||
| items.push({ | ||
| key: 'createWorkspace', | ||
| label: translate('homePage.gettingStartedSection.createWorkspace'), | ||
| isComplete: true, | ||
| route: ROUTES.WORKSPACE_OVERVIEW.getRoute(activePolicyID), | ||
| }); | ||
|
|
||
| const isDirectConnect = !!reportedIntegration && DIRECT_CONNECT_INTEGRATIONS.has(reportedIntegration); | ||
|
|
||
| if (isDirectConnect) { | ||
| const integrationName = CONST.ONBOARDING_ACCOUNTING_MAPPING[reportedIntegration as keyof typeof CONST.ONBOARDING_ACCOUNTING_MAPPING] ?? String(reportedIntegration); | ||
| items.push({ | ||
| key: 'connectAccounting', | ||
| label: translate('homePage.gettingStartedSection.connectAccounting', {integrationName}), | ||
| isComplete: hasAccountingConnections(policy), | ||
| route: ROUTES.WORKSPACE_ACCOUNTING.getRoute(activePolicyID), | ||
| }); | ||
| } else { | ||
| items.push({ | ||
| key: 'customizeCategories', | ||
| label: translate('homePage.gettingStartedSection.customizeCategories'), | ||
| isComplete: hasCustomCategories(policyCategories), | ||
| route: ROUTES.WORKSPACE_CATEGORIES.getRoute(activePolicyID), | ||
| }); | ||
| } | ||
|
|
||
| if (policy.areCompanyCardsEnabled) { | ||
| items.push({ | ||
| key: 'linkCompanyCards', | ||
| label: translate('homePage.gettingStartedSection.linkCompanyCards'), | ||
| isComplete: false, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to update this logic? 😅
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, what do you mean exactly? |
||
| route: ROUTES.WORKSPACE_COMPANY_CARDS.getRoute(activePolicyID), | ||
| }); | ||
| } | ||
|
|
||
| if (policy.areRulesEnabled) { | ||
| items.push({ | ||
| key: 'setupRules', | ||
| label: translate('homePage.gettingStartedSection.setupRules'), | ||
| isComplete: hasNonDefaultRules(policy), | ||
| route: ROUTES.WORKSPACE_RULES.getRoute(activePolicyID), | ||
| }); | ||
| } | ||
|
|
||
| return {shouldShowSection: true, items}; | ||
| } | ||
|
|
||
| export default useGettingStartedItems; | ||
| export type {GettingStartedItem, UseGettingStartedItemsResult}; | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.