Skip to content

Commit

Permalink
Merge pull request #37717 from MrMuzyk/feat/policy-distance-rates-page
Browse files Browse the repository at this point in the history
feat: policy distance rate page
  • Loading branch information
luacmartins authored Mar 8, 2024
2 parents 1435b3e + 546e706 commit 838e3fd
Show file tree
Hide file tree
Showing 24 changed files with 449 additions and 7 deletions.
6 changes: 6 additions & 0 deletions assets/images/document-slash.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1417,6 +1417,11 @@ const CONST = {
MAKE_MEMBER: 'makeMember',
MAKE_ADMIN: 'makeAdmin',
},
DISTANCE_RATES_BULK_ACTION_TYPES: {
DELETE: 'delete',
DISABLE: 'disable',
ENABLE: 'enable',
},
},

CUSTOM_UNITS: {
Expand Down
4 changes: 4 additions & 0 deletions src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,10 @@ const ROUTES = {
route: 'workspace/:policyID/members/:accountID/role-selection',
getRoute: (policyID: string, accountID: number, backTo?: string) => getUrlWithBackToParam(`workspace/${policyID}/members/${accountID}/role-selection`, backTo),
},
WORKSPACE_DISTANCE_RATES: {
route: 'workspace/:policyID/distance-rates',
getRoute: (policyID: string) => `workspace/${policyID}/distance-rates` as const,
},

// Referral program promotion
REFERRAL_DETAILS_MODAL: {
Expand Down
1 change: 1 addition & 0 deletions src/SCREENS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ const SCREENS = {
CATEGORIES_SETTINGS: 'Categories_Settings',
MEMBER_DETAILS: 'Workspace_Member_Details',
MEMBER_DETAILS_ROLE_SELECTION: 'Workspace_Member_Details_Role_Selection',
DISTANCE_RATES: 'Distance_Rates',
},

EDIT_REQUEST: {
Expand Down
3 changes: 2 additions & 1 deletion src/components/ButtonWithDropdownMenu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ function ButtonWithDropdownMenu<IValueType>({
options,
onOptionSelected,
enterKeyEventListenerPriority = 0,
wrapperStyle,
}: ButtonWithDropdownMenuProps<IValueType>) {
const theme = useTheme();
const styles = useThemeStyles();
Expand Down Expand Up @@ -66,7 +67,7 @@ function ButtonWithDropdownMenu<IValueType>({
}, [windowWidth, windowHeight, isMenuVisible, anchorAlignment.vertical]);

return (
<View>
<View style={wrapperStyle}>
{shouldAlwaysShowDropdownMenu || options.length > 1 ? (
<View style={[styles.flexRow, styles.justifyContentBetween, styles.alignItemsCenter, style]}>
<Button
Expand Down
7 changes: 6 additions & 1 deletion src/components/ButtonWithDropdownMenu/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ type PaymentType = DeepValueOf<typeof CONST.IOU.PAYMENT_TYPE | typeof CONST.IOU.

type WorkspaceMemberBulkActionType = DeepValueOf<typeof CONST.POLICY.MEMBERS_BULK_ACTION_TYPES>;

type WorkspaceDistanceRatesBulkActionType = DeepValueOf<typeof CONST.POLICY.DISTANCE_RATES_BULK_ACTION_TYPES>;

type DropdownOption<TValueType> = {
value: TValueType;
text: string;
Expand Down Expand Up @@ -66,6 +68,9 @@ type ButtonWithDropdownMenuProps<TValueType> = {

/** Whether the dropdown menu should be shown even if it has only one option */
shouldAlwaysShowDropdownMenu?: boolean;

/** Additional style to add to the wrapper */
wrapperStyle?: StyleProp<ViewStyle>;
};

export type {PaymentType, WorkspaceMemberBulkActionType, DropdownOption, ButtonWithDropdownMenuProps};
export type {PaymentType, WorkspaceMemberBulkActionType, WorkspaceDistanceRatesBulkActionType, DropdownOption, ButtonWithDropdownMenuProps};
2 changes: 2 additions & 0 deletions src/components/Icon/Expensicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import Concierge from '@assets/images/concierge.svg';
import Connect from '@assets/images/connect.svg';
import Copy from '@assets/images/copy.svg';
import CreditCard from '@assets/images/creditcard.svg';
import DocumentSlash from '@assets/images/document-slash.svg';
import Document from '@assets/images/document.svg';
import DotIndicatorUnfilled from '@assets/images/dot-indicator-unfilled.svg';
import DotIndicator from '@assets/images/dot-indicator.svg';
Expand Down Expand Up @@ -194,6 +195,7 @@ export {
CreditCard,
DeletedRoomAvatar,
Document,
DocumentSlash,
DomainRoomAvatar,
DotIndicator,
DotIndicatorUnfilled,
Expand Down
2 changes: 2 additions & 0 deletions src/components/Icon/Illustrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import Approval from '@assets/images/simple-illustrations/simple-illustration__a
import BankArrow from '@assets/images/simple-illustrations/simple-illustration__bank-arrow.svg';
import BigRocket from '@assets/images/simple-illustrations/simple-illustration__bigrocket.svg';
import PinkBill from '@assets/images/simple-illustrations/simple-illustration__bill.svg';
import CarIce from '@assets/images/simple-illustrations/simple-illustration__car-ice.svg';
import ChatBubbles from '@assets/images/simple-illustrations/simple-illustration__chatbubbles.svg';
import CoffeeMug from '@assets/images/simple-illustrations/simple-illustration__coffeemug.svg';
import CommentBubbles from '@assets/images/simple-illustrations/simple-illustration__commentbubbles.svg';
Expand Down Expand Up @@ -148,4 +149,5 @@ export {
ThreeLeggedLaptopWoman,
House,
Tag,
CarIce,
};
20 changes: 19 additions & 1 deletion src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1755,6 +1755,8 @@ export default {
workspaceAvatar: 'Workspace avatar',
mustBeOnlineToViewMembers: 'You must be online in order to view members of this workspace.',
requested: 'Requested',
distanceRates: 'Distance rates',
selected: ({selectedNumber}) => `${selectedNumber} selected`,
},
type: {
free: 'Free',
Expand Down Expand Up @@ -1816,7 +1818,6 @@ export default {
makeMember: 'Make member',
makeAdmin: 'Make admin',
selectAll: 'Select all',
selected: ({selectedNumber}) => `${selectedNumber} selected`,
error: {
genericAdd: 'There was a problem adding this workspace member.',
cannotRemove: 'You cannot remove yourself or the workspace owner.',
Expand Down Expand Up @@ -1909,6 +1910,23 @@ export default {
welcomeNote: ({workspaceName}: WelcomeNoteParams) =>
`You have been invited to ${workspaceName || 'a workspace'}! Download the Expensify mobile app at use.expensify.com/download to start tracking your expenses.`,
},
distanceRates: {
oopsNotSoFast: 'Oops! Not so fast...',
workspaceNeeds: 'A workspace needs at least one enabled distance rate.',
distance: 'Distance',
centrallyManage: 'Centrally manage rates, choose to track in miles or kilometers, and set a default category.',
rate: 'Rate',
addRate: 'Add rate',
deleteRate: 'Delete rate',
deleteRates: 'Delete rates',
enableRate: 'Enable rate',
disableRate: 'Disable rate',
disableRates: 'Disable rates',
enableRates: 'Enable rates',
status: 'Status',
enabled: 'Enabled',
disabled: 'Disabled',
},
editor: {
descriptionInputLabel: 'Description',
nameInputLabel: 'Name',
Expand Down
20 changes: 19 additions & 1 deletion src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1779,6 +1779,8 @@ export default {
workspaceAvatar: 'Espacio de trabajo avatar',
mustBeOnlineToViewMembers: 'Debes estar en línea para poder ver los miembros de este espacio de trabajo.',
requested: 'Solicitado',
distanceRates: 'Tasas de distancia',
selected: ({selectedNumber}) => `${selectedNumber} seleccionados`,
},
type: {
free: 'Gratis',
Expand Down Expand Up @@ -1840,7 +1842,6 @@ export default {
makeMember: 'Hacer miembro',
makeAdmin: 'Hacer administrador',
selectAll: 'Seleccionar todo',
selected: ({selectedNumber}) => `${selectedNumber} seleccionados`,
error: {
genericAdd: 'Ha ocurrido un problema al añadir el miembro al espacio de trabajo.',
cannotRemove: 'No puedes eliminarte ni a ti mismo ni al dueño del espacio de trabajo.',
Expand Down Expand Up @@ -1934,6 +1935,23 @@ export default {
welcomeNote: ({workspaceName}: WelcomeNoteParams) =>
`¡Has sido invitado a ${workspaceName}! Descargue la aplicación móvil Expensify en use.expensify.com/download para comenzar a rastrear sus gastos.`,
},
distanceRates: {
oopsNotSoFast: 'Ups! No tan rápido...',
workspaceNeeds: 'Un espacio de trabajo necesita al menos una tasa de distancia activa.',
distance: 'Distancia',
centrallyManage: 'Gestiona centralizadamente las tasas, elige si contabilizar en millas o kilómetros, y define una categoría por defecto',
rate: 'Tasa',
addRate: 'Agregar tasa',
deleteRate: 'Eliminar tasa',
deleteRates: 'Eliminar tasas',
enableRate: 'Activar tasa',
disableRate: 'Desactivar tasa',
disableRates: 'Desactivar tasas',
enableRates: 'Activar tasas',
status: 'Estado',
enabled: 'Activada',
disabled: 'Desactivada',
},
editor: {
nameInputLabel: 'Nombre',
descriptionInputLabel: 'Descripción',
Expand Down
5 changes: 5 additions & 0 deletions src/libs/API/parameters/OpenPolicyDistanceRatesPageParams.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type OpenPolicyDistanceRatesPageParams = {
policyID: string;
};

export default OpenPolicyDistanceRatesPageParams;
1 change: 1 addition & 0 deletions src/libs/API/parameters/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,4 @@ export type {default as SwitchToOldDotParams} from './SwitchToOldDotParams';
export type {default as AcceptJoinRequestParams} from './AcceptJoinRequest';
export type {default as DeclineJoinRequestParams} from './DeclineJoinRequest';
export type {default as JoinPolicyInviteLinkParams} from './JoinPolicyInviteLink';
export type {default as OpenPolicyDistanceRatesPageParams} from './OpenPolicyDistanceRatesPageParams';
2 changes: 2 additions & 0 deletions src/libs/API/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ const READ_COMMANDS = {
OPEN_POLICY_CATEGORIES_PAGE: 'OpenPolicyCategoriesPage',
OPEN_WORKSPACE_INVITE_PAGE: 'OpenWorkspaceInvitePage',
OPEN_DRAFT_WORKSPACE_REQUEST: 'OpenDraftWorkspaceRequest',
OPEN_POLICY_DISTANCE_RATES_PAGE: 'OpenPolicyDistanceRatesPage',
} as const;

type ReadCommand = ValueOf<typeof READ_COMMANDS>;
Expand Down Expand Up @@ -386,6 +387,7 @@ type ReadCommandParameters = {
[READ_COMMANDS.OPEN_POLICY_CATEGORIES_PAGE]: Parameters.OpenPolicyCategoriesPageParams;
[READ_COMMANDS.OPEN_WORKSPACE_INVITE_PAGE]: Parameters.OpenWorkspaceInvitePageParams;
[READ_COMMANDS.OPEN_DRAFT_WORKSPACE_REQUEST]: Parameters.OpenDraftWorkspaceRequestParams;
[READ_COMMANDS.OPEN_POLICY_DISTANCE_RATES_PAGE]: Parameters.OpenPolicyDistanceRatesPageParams;
};

const SIDE_EFFECT_REQUEST_COMMANDS = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const workspaceSettingsScreens = {
[SCREENS.WORKSPACE.MEMBERS]: () => require('../../../../../pages/workspace/WorkspaceMembersPage').default as React.ComponentType,
[SCREENS.WORKSPACE.CATEGORIES]: () => require('../../../../../pages/workspace/categories/WorkspaceCategoriesPage').default as React.ComponentType,
[SCREENS.WORKSPACE.TAGS]: () => require('../../../../../pages/workspace/tags/WorkspaceTagsPage').default as React.ComponentType,
[SCREENS.WORKSPACE.DISTANCE_RATES]: () => require('../../../../../pages/workspace/distanceRates/PolicyDistanceRatesPage').default as React.ComponentType,
} satisfies Screens;

function BaseCentralPaneNavigator() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const TAB_TO_CENTRAL_PANE_MAPPING: Record<BottomTabName, CentralPaneName[]> = {
SCREENS.WORKSPACE.TRAVEL,
SCREENS.WORKSPACE.MEMBERS,
SCREENS.WORKSPACE.CATEGORIES,
SCREENS.WORKSPACE.DISTANCE_RATES,
],
};

Expand Down
3 changes: 3 additions & 0 deletions src/libs/Navigation/linkingConfig/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ const config: LinkingOptions<RootStackParamList>['config'] = {
[SCREENS.WORKSPACE.TAGS]: {
path: ROUTES.WORKSPACE_TAGS.route,
},
[SCREENS.WORKSPACE.DISTANCE_RATES]: {
path: ROUTES.WORKSPACE_DISTANCE_RATES.route,
},
},
},
[SCREENS.NOT_FOUND]: '*',
Expand Down
3 changes: 3 additions & 0 deletions src/libs/Navigation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ type CentralPaneNavigatorParamList = {
policyID: string;
categoryName: string;
};
[SCREENS.WORKSPACE.DISTANCE_RATES]: {
policyID: string;
};
};

type WorkspaceSwitcherNavigatorParamList = {
Expand Down
12 changes: 12 additions & 0 deletions src/libs/actions/Policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import type {
DeleteWorkspaceParams,
OpenDraftWorkspaceRequestParams,
OpenPolicyCategoriesPageParams,
OpenPolicyDistanceRatesPageParams,
OpenWorkspaceInvitePageParams,
OpenWorkspaceMembersPageParams,
OpenWorkspaceParams,
Expand Down Expand Up @@ -2758,6 +2759,16 @@ function declineJoinRequest(reportID: string, reportAction: OnyxEntry<ReportActi
API.write(WRITE_COMMANDS.DECLINE_JOIN_REQUEST, parameters, {optimisticData, failureData, successData});
}

function openPolicyDistanceRatesPage(policyID?: string) {
if (!policyID) {
return;
}

const params: OpenPolicyDistanceRatesPageParams = {policyID};

API.read(READ_COMMANDS.OPEN_POLICY_DISTANCE_RATES_PAGE, params);
}

export {
removeMembers,
updateWorkspaceMembersRole,
Expand Down Expand Up @@ -2812,4 +2823,5 @@ export {
declineJoinRequest,
createPolicyCategory,
clearCategoryErrors,
openPolicyDistanceRatesPage,
};
6 changes: 6 additions & 0 deletions src/pages/workspace/WorkspaceInitialPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,12 @@ function WorkspaceInitialPage({policyDraft, policy: policyProp, policyMembers, r
action: singleExecution(waitForNavigate(() => Navigation.navigate(ROUTES.WORKSPACE_TAGS.getRoute(policyID)))),
routeName: SCREENS.WORKSPACE.TAGS,
},
{
translationKey: 'workspace.common.distanceRates',
icon: Expensicons.Car,
action: singleExecution(waitForNavigate(() => Navigation.navigate(ROUTES.WORKSPACE_DISTANCE_RATES.getRoute(policyID)))),
routeName: SCREENS.WORKSPACE.DISTANCE_RATES,
},
];

const menuItems: WorkspaceMenuItem[] = [
Expand Down
2 changes: 1 addition & 1 deletion src/pages/workspace/WorkspaceMembersPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ function WorkspaceMembersPage({policyMembers, personalDetails, route, policy, se
<ButtonWithDropdownMenu<WorkspaceMemberBulkActionType>
shouldAlwaysShowDropdownMenu
pressOnEnter
customText={translate('workspace.people.selected', {selectedNumber: selectedEmployees.length})}
customText={translate('workspace.common.selected', {selectedNumber: selectedEmployees.length})}
buttonSize={CONST.DROPDOWN_BUTTON_SIZE.MEDIUM}
onPress={() => null}
options={getBulkActionsButtonOptions()}
Expand Down
3 changes: 2 additions & 1 deletion src/pages/workspace/categories/WorkspaceCategoriesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ function WorkspaceCategoriesPage({policy, policyCategories, route}: WorkspaceCat
medium
onPress={navigateToCategoriesSettings}
icon={Expensicons.Gear}
iconStyles={[styles.mr2]}
text={translate('common.settings')}
style={[isSmallScreenWidth && styles.w50]}
/>
Expand All @@ -166,7 +167,7 @@ function WorkspaceCategoriesPage({policy, policyCategories, route}: WorkspaceCat
{!isSmallScreenWidth && headerButtons}
</HeaderWithBackButton>
{isSmallScreenWidth && <View style={[styles.pl5, styles.pr5]}>{headerButtons}</View>}
<View style={[styles.ph5, styles.pb5]}>
<View style={[styles.ph5, styles.pb5, styles.pt3]}>
<Text style={[styles.textNormal, styles.colorMuted]}>{translate('workspace.categories.subtitle')}</Text>
</View>
{isLoading && (
Expand Down
Loading

0 comments on commit 838e3fd

Please sign in to comment.