Skip to content

Commit

Permalink
Merge pull request #48185 from narefyev91/feed-settings
Browse files Browse the repository at this point in the history
[NO QA]: Feed Settings
  • Loading branch information
robertjchen authored Aug 30, 2024
2 parents 694fd06 + c34a080 commit 76f16bc
Show file tree
Hide file tree
Showing 22 changed files with 490 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2341,6 +2341,12 @@ const CONST = {
PAYPERUSE: 'monthly2018',
},
},
COMPANY_CARDS: {
DELETE_TRANSACTIONS: {
RESTRICT: 'corporate',
ALLOW: 'personal',
},
},
REGEX: {
SPECIAL_CHARS_WITHOUT_NEWLINE: /((?!\n)[()-\s\t])/g,
DIGITS_AND_PLUS: /^\+?[0-9]*$/,
Expand Down
3 changes: 3 additions & 0 deletions src/ONYXKEYS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,8 @@ const ONYXKEYS = {
WORKSPACE_RATE_AND_UNIT_FORM_DRAFT: 'workspaceRateAndUnitFormDraft',
WORKSPACE_TAX_CUSTOM_NAME: 'workspaceTaxCustomName',
WORKSPACE_TAX_CUSTOM_NAME_DRAFT: 'workspaceTaxCustomNameDraft',
WORKSPACE_COMPANY_CARD_FEED_NAME: 'workspaceCompanyCardFeedName',
WORKSPACE_COMPANY_CARD_FEED_NAME_DRAFT: 'workspaceCompanyCardFeedNameDraft',
WORKSPACE_REPORT_FIELDS_FORM: 'workspaceReportFieldForm',
WORKSPACE_REPORT_FIELDS_FORM_DRAFT: 'workspaceReportFieldFormDraft',
POLICY_CREATE_DISTANCE_RATE_FORM: 'policyCreateDistanceRateForm',
Expand Down Expand Up @@ -647,6 +649,7 @@ type OnyxFormValuesMapping = {
[ONYXKEYS.FORMS.WORKSPACE_TAG_FORM]: FormTypes.WorkspaceTagForm;
[ONYXKEYS.FORMS.WORKSPACE_RATE_AND_UNIT_FORM]: FormTypes.WorkspaceRateAndUnitForm;
[ONYXKEYS.FORMS.WORKSPACE_TAX_CUSTOM_NAME]: FormTypes.WorkspaceTaxCustomName;
[ONYXKEYS.FORMS.WORKSPACE_COMPANY_CARD_FEED_NAME]: FormTypes.WorkspaceCompanyCardFeedName;
[ONYXKEYS.FORMS.WORKSPACE_REPORT_FIELDS_FORM]: FormTypes.WorkspaceReportFieldForm;
[ONYXKEYS.FORMS.CLOSE_ACCOUNT_FORM]: FormTypes.CloseAccountForm;
[ONYXKEYS.FORMS.PROFILE_SETTINGS_FORM]: FormTypes.ProfileSettingsForm;
Expand Down
8 changes: 8 additions & 0 deletions src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -936,6 +936,14 @@ const ROUTES = {
route: 'settings/workspaces/:policyID/expensify-card/settings/frequency',
getRoute: (policyID: string) => `settings/workspaces/${policyID}/expensify-card/settings/frequency` as const,
},
WORKSPACE_COMPANY_CARDS_SETTINGS: {
route: 'settings/workspaces/:policyID/company-cards/settings',
getRoute: (policyID: string) => `settings/workspaces/${policyID}/company-cards/settings` as const,
},
WORKSPACE_COMPANY_CARDS_SETTINGS_FEED_NAME: {
route: 'settings/workspaces/:policyID/company-cards/settings/feed-name',
getRoute: (policyID: string) => `settings/workspaces/${policyID}/company-cards/settings/feed-name` as const,
},
WORKSPACE_RULES: {
route: 'settings/workspaces/:policyID/rules',
getRoute: (policyID: string) => `settings/workspaces/${policyID}/rules` as const,
Expand Down
2 changes: 2 additions & 0 deletions src/SCREENS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,8 @@ const SCREENS = {
RATE_AND_UNIT_UNIT: 'Workspace_RateAndUnit_Unit',
COMPANY_CARDS: 'Workspace_CompanyCards',
COMPANY_CARDS_SELECT_FEED: 'Workspace_CompanyCards_Select_Feed',
COMPANY_CARDS_SETTINGS: 'Workspace_CompanyCards_Settings',
COMPANY_CARDS_SETTINGS_FEED_NAME: 'Workspace_CompanyCards_Settings_Feed_Name',
EXPENSIFY_CARD: 'Workspace_ExpensifyCard',
EXPENSIFY_CARD_DETAILS: 'Workspace_ExpensifyCard_Details',
EXPENSIFY_CARD_LIMIT: 'Workspace_ExpensifyCard_Limit',
Expand Down
18 changes: 18 additions & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import type {
ChangePolicyParams,
ChangeTypeParams,
CharacterLimitParams,
CompanyCardFeedNameParams,
ConfirmHoldExpenseParams,
ConfirmThatParams,
DateShouldBeAfterParams,
Expand Down Expand Up @@ -2901,6 +2902,23 @@ export default {
disableCardTitle: 'Disable Company Cards',
disableCardPrompt: 'You can’t disable company cards because this feature is in use. Reach out to the Concierge for next steps.',
disableCardButton: 'Chat with Concierge',
assignCard: 'Assign card',
cardFeedName: 'Card feed name',
cardFeedNameDescription: 'Give the card feed a unique name so you can tell it apart from the others.',
cardFeedTransaction: 'Delete transactions',
cardFeedTransactionDescription: 'Choose whether cardholders can delete card transactions. New transactions will follow these rules.',
cardFeedRestrictDeletingTransaction: 'Restrict deleting transactions',
cardFeedAllowDeletingTransaction: 'Allow deleting transactions',
removeCardFeed: 'Remove card feed',
removeCardFeedTitle: ({feedName}: CompanyCardFeedNameParams) => `Remove ${feedName} feed`,
removeCardFeedDescription: 'Are you sure you want to remove this card feed? This will unassign all cards.',
error: {
feedNameRequired: 'Card feed name is required.',
},
corporate: 'Restrict deleting transactions',
personal: 'Allow deleting transactions',
setFeedNameDescription: 'Give the card feed a unique name so you can tell it apart from the others.',
setTransactionLiabilityDescription: 'When enabled, cardholders can delete card transactions. New transactions will follow this rule.',
emptyAddedFeedTitle: 'Assign company cards',
emptyAddedFeedDescription: 'Get started by assigning your first card to a member.',
},
Expand Down
19 changes: 19 additions & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import type {
ChangePolicyParams,
ChangeTypeParams,
CharacterLimitParams,
CompanyCardFeedNameParams,
ConfirmHoldExpenseParams,
ConfirmThatParams,
DateShouldBeAfterParams,
Expand Down Expand Up @@ -2945,6 +2946,24 @@ export default {
disableCardTitle: 'Deshabilitar tarjetas de empresa',
disableCardPrompt: 'No puedes deshabilitar las tarjetas de empresa porque esta función está en uso. Por favor, contacta a Concierge para los próximos pasos.',
disableCardButton: 'Chatear con Concierge',
assignCard: 'Asignar tarjeta',
cardFeedName: 'Nombre del feed de tarjeta',
cardFeedNameDescription: 'Dale al feed de tarjeta un nombre único para que puedas distinguirlo de los demás.',
cardFeedTransaction: 'Eliminar transacciones',
cardFeedTransactionDescription: 'Elige si los titulares de tarjetas pueden eliminar transacciones de tarjetas. Las nuevas transacciones seguirán estas reglas.',
cardFeedRestrictDeletingTransaction: 'Restringir eliminación de transacciones',
cardFeedAllowDeletingTransaction: 'Permitir eliminación de transacciones',
removeCardFeed: 'Quitar la alimentación de tarjetas',
removeCardFeedTitle: ({feedName}: CompanyCardFeedNameParams) => `Eliminar el feed de ${feedName}`,
removeCardFeedDescription: '¿Estás seguro de que deseas eliminar esta fuente de tarjetas? Esto anulará la asignación de todas las tarjetas.',
error: {
feedNameRequired: 'Se requiere el nombre de la fuente de la tarjeta.',
},
corporate: 'Restringir eliminación de transacciones',
personal: 'Permitir eliminación de transacciones',
setFeedNameDescription: 'Dale al feed de tarjeta un nombre único para que puedas distinguirlo de los demás.',
setTransactionLiabilityDescription:
'Cuando está habilitada, los titulares de tarjetas pueden eliminar transacciones con tarjeta. Las transacciones nuevas seguirán esta regla.',
emptyAddedFeedTitle: 'Asignar tarjetas de empresa',
emptyAddedFeedDescription: 'Comienza asignando tu primera tarjeta a un miembro.',
},
Expand Down
3 changes: 3 additions & 0 deletions src/languages/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ type PayerOwesAmountParams = {payer: string; amount: number | string; comment?:

type PayerOwesParams = {payer: string};

type CompanyCardFeedNameParams = {feedName: string};

type PayerPaidAmountParams = {payer?: string; amount: number | string};

type ApprovedAmountParams = {amount: number | string};
Expand Down Expand Up @@ -371,6 +373,7 @@ export type {
CharacterLimitParams,
ConfirmHoldExpenseParams,
ConfirmThatParams,
CompanyCardFeedNameParams,
DateShouldBeAfterParams,
DateShouldBeBeforeParams,
DeleteActionParams,
Expand Down
7 changes: 7 additions & 0 deletions src/libs/API/parameters/DeleteCompanyCardFeed.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
type DeleteCompanyCardFeed = {
authToken?: string | null;
policyID: string;
bankName: string;
};

export default DeleteCompanyCardFeed;
8 changes: 8 additions & 0 deletions src/libs/API/parameters/SetCompanyCardFeedName.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
type SetCompanyCardFeedName = {
authToken?: string | null;
policyID: string;
bankName: string;
userDefinedName: string;
};

export default SetCompanyCardFeedName;
7 changes: 7 additions & 0 deletions src/libs/API/parameters/SetCompanyCardTransactionLiability.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
type SetCompanyCardTransactionLiability = {
authToken?: string | null;
bankName: string;
liabilityType: string;
};

export default SetCompanyCardTransactionLiability;
3 changes: 3 additions & 0 deletions src/libs/API/parameters/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,3 +290,6 @@ export type {default as UpdateExpensifyCardLimitTypeParams} from './UpdateExpens
export type {default as UpdateXeroGenericTypeParams} from './UpdateXeroGenericTypeParams';
export type {default as UpdateCardSettlementFrequencyParams} from './UpdateCardSettlementFrequencyParams';
export type {default as UpdateCardSettlementAccountParams} from './UpdateCardSettlementAccountParams';
export type {default as SetCompanyCardFeedName} from './SetCompanyCardFeedName';
export type {default as DeleteCompanyCardFeed} from './DeleteCompanyCardFeed';
export type {default as SetCompanyCardTransactionLiability} from './SetCompanyCardTransactionLiability';
6 changes: 6 additions & 0 deletions src/libs/API/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,9 @@ const WRITE_COMMANDS = {
UPDATE_XERO_IMPORT_TAX_RATES: 'UpdateXeroImportTaxRates',
UPDATE_XERO_TENANT_ID: 'UpdateXeroTenantID',
UPDATE_XERO_MAPPING: 'UpdateXeroMappings',
SET_COMPANY_CARD_FEED_NAME: 'SetFeedName',
DELETE_COMPANY_CARD_FEED: 'RemoveFeed',
SET_COMPANY_CARD_TRANSACTION_LIABILITY: 'SetFeedTransactionLiability',
} as const;

type WriteCommand = ValueOf<typeof WRITE_COMMANDS>;
Expand Down Expand Up @@ -405,6 +408,9 @@ type WriteCommandParameters = {
[WRITE_COMMANDS.UPDATE_STATUS]: Parameters.UpdateStatusParams;
[WRITE_COMMANDS.CLEAR_STATUS]: null;
[WRITE_COMMANDS.UPDATE_PERSONAL_DETAILS_FOR_WALLET]: Parameters.UpdatePersonalDetailsForWalletParams;
[WRITE_COMMANDS.SET_COMPANY_CARD_FEED_NAME]: Parameters.SetCompanyCardFeedName;
[WRITE_COMMANDS.DELETE_COMPANY_CARD_FEED]: Parameters.DeleteCompanyCardFeed;
[WRITE_COMMANDS.SET_COMPANY_CARD_TRANSACTION_LIABILITY]: Parameters.SetCompanyCardTransactionLiability;
[WRITE_COMMANDS.VERIFY_IDENTITY]: Parameters.VerifyIdentityParams;
[WRITE_COMMANDS.ACCEPT_WALLET_TERMS]: Parameters.AcceptWalletTermsParams;
[WRITE_COMMANDS.ANSWER_QUESTIONS_FOR_WALLET]: Parameters.AnswerQuestionsForWalletParams;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,8 @@ const SettingsModalStackNavigator = createModalStackNavigator<SettingsNavigatorP
[SCREENS.WORKSPACE.EXPENSIFY_CARD_NAME]: () => require<ReactComponentModule>('../../../../pages/workspace/expensifyCard/WorkspaceEditCardNamePage').default,
[SCREENS.WORKSPACE.EXPENSIFY_CARD_LIMIT]: () => require<ReactComponentModule>('../../../../pages/workspace/expensifyCard/WorkspaceEditCardLimitPage').default,
[SCREENS.WORKSPACE.EXPENSIFY_CARD_LIMIT_TYPE]: () => require<ReactComponentModule>('../../../../pages/workspace/expensifyCard/WorkspaceEditCardLimitTypePage').default,
[SCREENS.WORKSPACE.COMPANY_CARDS_SETTINGS]: () => require<ReactComponentModule>('../../../../pages/workspace/companyCards/WorkspaceCompanyCardsSettingsPage').default,
[SCREENS.WORKSPACE.COMPANY_CARDS_SETTINGS_FEED_NAME]: () => require<ReactComponentModule>('../../../../pages/workspace/companyCards/WorkspaceCompanyCardsSettingsFeedNamePage').default,
[SCREENS.SETTINGS.SAVE_THE_WORLD]: () => require<ReactComponentModule>('../../../../pages/TeachersUnite/SaveTheWorldPage').default,
[SCREENS.SETTINGS.SUBSCRIPTION.CHANGE_PAYMENT_CURRENCY]: () => require<ReactComponentModule>('../../../../pages/settings/PaymentCard/ChangeCurrency').default,
[SCREENS.SETTINGS.SUBSCRIPTION.CHANGE_BILLING_CURRENCY]: () => require<ReactComponentModule>('../../../../pages/settings/Subscription/PaymentCard/ChangeBillingCurrency').default,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ const FULL_SCREEN_TO_RHP_MAPPING: Partial<Record<FullScreenName, string[]>> = {
SCREENS.WORKSPACE.REPORT_FIELDS_EDIT_INITIAL_VALUE,
],
[SCREENS.WORKSPACE.INVOICES]: [SCREENS.WORKSPACE.INVOICES_COMPANY_NAME, SCREENS.WORKSPACE.INVOICES_COMPANY_WEBSITE],
[SCREENS.WORKSPACE.COMPANY_CARDS]: [SCREENS.WORKSPACE.COMPANY_CARDS_SELECT_FEED],
[SCREENS.WORKSPACE.COMPANY_CARDS]: [SCREENS.WORKSPACE.COMPANY_CARDS_SELECT_FEED, SCREENS.WORKSPACE.COMPANY_CARDS_SETTINGS, SCREENS.WORKSPACE.COMPANY_CARDS_SETTINGS_FEED_NAME],
[SCREENS.WORKSPACE.EXPENSIFY_CARD]: [
SCREENS.WORKSPACE.EXPENSIFY_CARD_ISSUE_NEW,
SCREENS.WORKSPACE.EXPENSIFY_CARD_BANK_ACCOUNT,
Expand Down
6 changes: 6 additions & 0 deletions src/libs/Navigation/linkingConfig/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,12 @@ const config: LinkingOptions<RootStackParamList>['config'] = {
[SCREENS.WORKSPACE.EXPENSIFY_CARD_SETTINGS_ACCOUNT]: {
path: ROUTES.WORKSPACE_EXPENSIFY_CARD_SETTINGS_ACCOUNT.route,
},
[SCREENS.WORKSPACE.COMPANY_CARDS_SETTINGS]: {
path: ROUTES.WORKSPACE_COMPANY_CARDS_SETTINGS.route,
},
[SCREENS.WORKSPACE.COMPANY_CARDS_SETTINGS_FEED_NAME]: {
path: ROUTES.WORKSPACE_COMPANY_CARDS_SETTINGS_FEED_NAME.route,
},
[SCREENS.WORKSPACE.EXPENSIFY_CARD_DETAILS]: {
path: ROUTES.WORKSPACE_EXPENSIFY_CARD_DETAILS.route,
},
Expand Down
6 changes: 6 additions & 0 deletions src/libs/Navigation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,12 @@ type SettingsNavigatorParamList = {
[SCREENS.WORKSPACE.EXPENSIFY_CARD_SETTINGS_FREQUENCY]: {
policyID: string;
};
[SCREENS.WORKSPACE.COMPANY_CARDS_SETTINGS]: {
policyID: string;
};
[SCREENS.WORKSPACE.COMPANY_CARDS_SETTINGS_FEED_NAME]: {
policyID: string;
};
[SCREENS.WORKSPACE.EXPENSIFY_CARD_DETAILS]: {
policyID: string;
cardID: string;
Expand Down
82 changes: 82 additions & 0 deletions src/libs/actions/Policy/Policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3740,6 +3740,85 @@ function getAdminPoliciesConnectedToNetSuite(): Policy[] {
return Object.values(allPolicies ?? {}).filter<Policy>((policy): policy is Policy => !!policy && policy.role === CONST.POLICY.ROLE.ADMIN && !!policy?.connections?.netsuite);
}

function setWorkspaceCompanyCardFeedName(policyID: string, workspaceAccountID: number, bankName: string, userDefinedName: string) {
const authToken = NetworkStore.getAuthToken();
const onyxData: OnyxData = {
optimisticData: [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${workspaceAccountID}`,
value: {
companyCardNicknames: {
[bankName]: userDefinedName,
},
},
},
],
};

const parameters = {
authToken,
policyID,
bankName,
userDefinedName,
};

API.write(WRITE_COMMANDS.SET_COMPANY_CARD_FEED_NAME, parameters, onyxData);
}

function setWorkspaceCompanyCardTransactionLiability(workspaceAccountID: number, bankName: string, liabilityType: string) {
const authToken = NetworkStore.getAuthToken();
const onyxData: OnyxData = {
optimisticData: [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${workspaceAccountID}`,
value: {
companyCards: {
[bankName]: {liabilityType},
},
},
},
],
};

const parameters = {
authToken,
bankName,
liabilityType,
};

API.write(WRITE_COMMANDS.SET_COMPANY_CARD_TRANSACTION_LIABILITY, parameters, onyxData);
}
function deleteWorkspaceCompanyCardFeed(policyID: string, workspaceAccountID: number, bankName: string) {
const authToken = NetworkStore.getAuthToken();

const onyxData: OnyxData = {
optimisticData: [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${workspaceAccountID}`,
value: {
companyCards: {
[bankName]: null,
},
companyCardNicknames: {
[bankName]: null,
},
},
},
],
};

const parameters = {
authToken,
policyID,
bankName,
};

API.write(WRITE_COMMANDS.DELETE_COMPANY_CARD_FEED, parameters, onyxData);
}

function clearAllPolicies() {
if (!allPolicies) {
return;
Expand Down Expand Up @@ -3831,6 +3910,9 @@ export {
setPolicyMaxExpenseAge,
setPolicyBillableMode,
setWorkspaceEReceiptsEnabled,
setWorkspaceCompanyCardFeedName,
deleteWorkspaceCompanyCardFeed,
setWorkspaceCompanyCardTransactionLiability,
};

export type {NewCustomUnit};
Loading

0 comments on commit 76f16bc

Please sign in to comment.