Skip to content

Commit

Permalink
Merge pull request Expensify#52803 from nkdengineer/fix/51487
Browse files Browse the repository at this point in the history
Add Chat with setup specialist to the accounting page.
  • Loading branch information
techievivek authored Dec 11, 2024
2 parents f8f12c2 + bbb44e6 commit dac90e1
Show file tree
Hide file tree
Showing 9 changed files with 87 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3815,6 +3815,10 @@ const translations = {
xero: 'Xero',
netsuite: 'NetSuite',
intacct: 'Sage Intacct',
talkYourOnboardingSpecialist: 'Chat with your setup specialist.',
talkYourAccountManager: 'Chat with your account manager.',
talkToConcierge: 'Chat with Concierge.',
needAnotherAccounting: 'Need another accounting software? ',
connectionName: ({connectionName}: ConnectionNameParams) => {
switch (connectionName) {
case CONST.POLICY.CONNECTIONS.NAME.QBO:
Expand Down
4 changes: 4 additions & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3823,6 +3823,10 @@ const translations = {
xero: 'Xero',
netsuite: 'NetSuite',
intacct: 'Sage Intacct',
talkYourOnboardingSpecialist: 'Chatea con tu especialista asignado.',
talkYourAccountManager: 'Chatea con tu gestor de cuenta.',
talkToConcierge: 'Chatear con Concierge.',
needAnotherAccounting: '¿Necesitas otro software de contabilidad? ',
connectionName: ({connectionName}: ConnectionNameParams) => {
switch (connectionName) {
case CONST.POLICY.CONNECTIONS.NAME.QBO:
Expand Down
5 changes: 5 additions & 0 deletions src/libs/API/parameters/GetAssignedSupportDataParams.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type GetAssignedSupportDataParams = {
policyID: string;
};

export default GetAssignedSupportDataParams;
1 change: 1 addition & 0 deletions src/libs/API/parameters/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ export type {default as ExportReportCSVParams} from './ExportReportCSVParams';
export type {default as UpdateExpensifyCardLimitParams} from './UpdateExpensifyCardLimitParams';
export type {CreateWorkspaceApprovalParams, UpdateWorkspaceApprovalParams, RemoveWorkspaceApprovalParams} from './WorkspaceApprovalParams';
export type {default as StartIssueNewCardFlowParams} from './StartIssueNewCardFlowParams';
export type {default as GetAssignedSupportDataParams} from './GetAssignedSupportDataParams';
export type {default as ConnectAsDelegateParams} from './ConnectAsDelegateParams';
export type {default as SetPolicyRulesEnabledParams} from './SetPolicyRulesEnabledParams';
export type {default as SetPolicyDefaultReportTitleParams} from './SetPolicyDefaultReportTitle';
Expand Down
2 changes: 2 additions & 0 deletions src/libs/API/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -951,6 +951,7 @@ const READ_COMMANDS = {
OPEN_DRAFT_DISTANCE_EXPENSE: 'OpenDraftDistanceExpense',
START_ISSUE_NEW_CARD_FLOW: 'StartIssueNewCardFlow',
OPEN_CARD_DETAILS_PAGE: 'OpenCardDetailsPage',
GET_ASSIGNED_SUPPORT_DATA: 'GetAssignedSupportData',
} as const;

type ReadCommand = ValueOf<typeof READ_COMMANDS>;
Expand Down Expand Up @@ -1013,6 +1014,7 @@ type ReadCommandParameters = {
[READ_COMMANDS.OPEN_DRAFT_DISTANCE_EXPENSE]: null;
[READ_COMMANDS.START_ISSUE_NEW_CARD_FLOW]: Parameters.StartIssueNewCardFlowParams;
[READ_COMMANDS.OPEN_CARD_DETAILS_PAGE]: Parameters.OpenCardDetailsPageParams;
[READ_COMMANDS.GET_ASSIGNED_SUPPORT_DATA]: Parameters.GetAssignedSupportDataParams;
};

const SIDE_EFFECT_REQUEST_COMMANDS = {
Expand Down
9 changes: 9 additions & 0 deletions src/libs/actions/Policy/Policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import type {
EnablePolicyReportFieldsParams,
EnablePolicyTaxesParams,
EnablePolicyWorkflowsParams,
GetAssignedSupportDataParams,
LeavePolicyParams,
OpenDraftWorkspaceRequestParams,
OpenPolicyEditCardLimitTypePageParams,
Expand Down Expand Up @@ -4602,6 +4603,13 @@ function updateInvoiceCompanyWebsite(policyID: string, companyWebsite: string) {
API.write(WRITE_COMMANDS.UPDATE_INVOICE_COMPANY_WEBSITE, parameters, {optimisticData, successData, failureData});
}

function getAssignedSupportData(policyID: string) {
const parameters: GetAssignedSupportDataParams = {
policyID,
};
API.read(READ_COMMANDS.GET_ASSIGNED_SUPPORT_DATA, parameters);
}

export {
leaveWorkspace,
addBillingCardAndRequestPolicyOwnerChange,
Expand Down Expand Up @@ -4697,6 +4705,7 @@ export {
verifySetupIntentAndRequestPolicyOwnerChange,
updateInvoiceCompanyName,
updateInvoiceCompanyWebsite,
getAssignedSupportData,
};

export type {NewCustomUnit};
4 changes: 4 additions & 0 deletions src/libs/actions/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4445,6 +4445,9 @@ function exportReportToCSV({reportID, transactionIDList}: ExportReportCSVParams,

fileDownload(ApiUtils.getCommandURL({command: WRITE_COMMANDS.EXPORT_REPORT_TO_CSV}), 'Expensify.csv', '', false, formData, CONST.NETWORK.METHOD.POST, onDownloadFailed);
}
function getConciergeReportID() {
return conciergeChatReportID;
}

function setDeleteTransactionNavigateBackUrl(url: string) {
Onyx.set(ONYXKEYS.NVP_DELETE_TRANSACTION_NAVIGATE_BACK_URL, url);
Expand Down Expand Up @@ -4543,6 +4546,7 @@ export {
updateReportName,
updateRoomVisibility,
updateWriteCapability,
getConciergeReportID,
setDeleteTransactionNavigateBackUrl,
clearDeleteTransactionNavigateBackUrl,
};
42 changes: 41 additions & 1 deletion src/pages/workspace/accounting/PolicyAccountingPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import CollapsibleSection from '@components/CollapsibleSection';
import ConfirmModal from '@components/ConfirmModal';
import FormHelpMessage from '@components/FormHelpMessage';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
import Icon from '@components/Icon';
import * as Expensicons from '@components/Icon/Expensicons';
import * as Illustrations from '@components/Icon/Illustrations';
import MenuItem from '@components/MenuItem';
Expand All @@ -28,6 +29,8 @@ import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import useWindowDimensions from '@hooks/useWindowDimensions';
import {isAuthenticationError, isConnectionInProgress, isConnectionUnverified, removePolicyConnection, syncConnection} from '@libs/actions/connections';
import {getAssignedSupportData} from '@libs/actions/Policy/Policy';
import {getConciergeReportID} from '@libs/actions/Report';
import * as PolicyUtils from '@libs/PolicyUtils';
import {
areSettingsInErrorFields,
Expand Down Expand Up @@ -75,7 +78,8 @@ function PolicyAccountingPage({policy}: PolicyAccountingPageProps) {
const [datetimeToRelative, setDateTimeToRelative] = useState('');
const threeDotsMenuContainerRef = useRef<View>(null);
const {startIntegrationFlow, popoverAnchorRefs} = useAccountingContext();

const [account] = useOnyx(ONYXKEYS.ACCOUNT);
const {isLargeScreenWidth} = useResponsiveLayout();
const route = useRoute();
const params = route.params as RouteParams | undefined;
const newConnectionName = params?.newConnectionName;
Expand Down Expand Up @@ -172,6 +176,13 @@ function PolicyAccountingPage({policy}: PolicyAccountingPageProps) {
setDateTimeToRelative('');
}, [getDatetimeToRelative, successfulDate]);

useEffect(() => {
if (!policyID) {
return;
}
getAssignedSupportData(policyID);
}, [policyID]);

const integrationSpecificMenuItems = useMemo(() => {
const sageIntacctEntityList = policy?.connections?.intacct?.data?.entities ?? [];
const netSuiteSubsidiaryList = policy?.connections?.netsuite?.options?.data?.subsidiaryList ?? [];
Expand Down Expand Up @@ -459,6 +470,20 @@ function PolicyAccountingPage({policy}: PolicyAccountingPageProps) {
popoverAnchorRefs,
]);

const [chatTextLink, chatReportID] = useMemo(() => {
// If they have an onboarding specialist assigned display the following and link to the #admins room with the setup specialist.
if (account?.adminsRoomReportID) {
return [translate('workspace.accounting.talkYourOnboardingSpecialist'), account?.adminsRoomReportID];
}

// If not, if they have an account manager assigned display the following and link to the DM with their account manager.
if (account?.accountManagerAccountID) {
return [translate('workspace.accounting.talkYourAccountManager'), account?.accountManagerReportID];
}
// Else, display the following and link to their Concierge DM.
return [translate('workspace.accounting.talkToConcierge'), getConciergeReportID()];
}, [account, translate]);

return (
<AccessOrNotFoundWrapper
accessVariants={[CONST.POLICY.ACCESS_VARIANTS.ADMIN, CONST.POLICY.ACCESS_VARIANTS.PAID]}
Expand Down Expand Up @@ -546,6 +571,21 @@ function PolicyAccountingPage({policy}: PolicyAccountingPageProps) {
/>
</CollapsibleSection>
)}
{!!account?.guideDetails?.email && (
<View style={[styles.flexRow, styles.alignItemsCenter, styles.mt7]}>
<Icon
src={Expensicons.QuestionMark}
width={20}
height={20}
fill={theme.icon}
additionalStyles={styles.mr3}
/>
<View style={[!isLargeScreenWidth ? styles.flexColumn : styles.flexRow]}>
<Text style={styles.textSupporting}>{translate('workspace.accounting.needAnotherAccounting')}</Text>
<TextLink onPress={() => Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(chatReportID ?? ''))}>{chatTextLink}</TextLink>
</View>
</View>
)}
</Section>
</View>
</ScrollView>
Expand Down
17 changes: 17 additions & 0 deletions src/types/onyx/Account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,15 @@ type Account = {
/** The primaryLogin associated with the account */
primaryLogin?: string;

/** The Report ID of the admins room */
adminsRoomReportID?: string;

/** The Account ID of the account manager */
accountManagerAccountID?: string;

/** The Report ID of the account manager */
accountManagerReportID?: string;

/** The message to be displayed when code requested */
message?: string;

Expand Down Expand Up @@ -157,6 +166,14 @@ type Account = {

/** Indicates SMS delivery failure status and associated information */
smsDeliveryFailureStatus?: SMSDeliveryFailureStatus;

/** The guide details of the account */
guideDetails?: {
/** The email of the guide details */
email: string;
/** The calendar link of the guide details */
calendarLink: string;
};
};

export default Account;
Expand Down

0 comments on commit dac90e1

Please sign in to comment.