Skip to content

Commit

Permalink
Merge pull request #40303 from rezkiy37/feature/40013-invoice-rooms-i…
Browse files Browse the repository at this point in the history
…ndividual-receivers-2

Implement Invoice rooms with individual receivers
  • Loading branch information
cristipaval authored Apr 28, 2024
2 parents 3b213eb + 3844b32 commit 223672b
Show file tree
Hide file tree
Showing 15 changed files with 209 additions and 27 deletions.
7 changes: 7 additions & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const chatTypes = {
POLICY_ROOM: 'policyRoom',
POLICY_EXPENSE_CHAT: 'policyExpenseChat',
SELF_DM: 'selfDM',
INVOICE: 'invoice',
} as const;

// Explicit type annotation is required
Expand Down Expand Up @@ -805,6 +806,7 @@ const CONST = {
EXPENSE: 'expense',
IOU: 'iou',
TASK: 'task',
INVOICE: 'invoice',
},
CHAT_TYPE: chatTypes,
WORKSPACE_CHAT_ROOMS: {
Expand Down Expand Up @@ -854,6 +856,10 @@ const CONST = {
SHARE: 'share',
OWN: 'own',
},
INVOICE_RECEIVER_TYPE: {
INDIVIDUAL: 'individual',
BUSINESS: 'policy',
},
},
NEXT_STEP: {
FINISHED: 'Finished!',
Expand Down Expand Up @@ -1470,6 +1476,7 @@ const CONST = {
PAY: 'pay',
SPLIT: 'split',
REQUEST: 'request',
INVOICE: 'invoice',
SUBMIT: 'submit',
TRACK: 'track',
},
Expand Down
3 changes: 2 additions & 1 deletion src/components/AvatarWithDisplayName.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ function AvatarWithDisplayName({
const title = ReportUtils.getReportName(report);
const subtitle = ReportUtils.getChatRoomSubtitle(report);
const parentNavigationSubtitleData = ReportUtils.getParentNavigationSubtitle(report);
const isMoneyRequestOrReport = ReportUtils.isMoneyRequestReport(report) || ReportUtils.isMoneyRequest(report) || ReportUtils.isTrackExpenseReport(report);
const isMoneyRequestOrReport =
ReportUtils.isMoneyRequestReport(report) || ReportUtils.isMoneyRequest(report) || ReportUtils.isTrackExpenseReport(report) || ReportUtils.isInvoiceReport(report);
const icons = ReportUtils.getIcons(report, personalDetails, null, '', -1, policy);
const ownerPersonalDetails = OptionsListUtils.getPersonalDetailsForAccountIDs(report?.ownerAccountID ? [report.ownerAccountID] : [], personalDetails);
const displayNamesWithTooltips = ReportUtils.getDisplayNamesWithTooltips(Object.values(ownerPersonalDetails) as PersonalDetails[], false);
Expand Down
9 changes: 7 additions & 2 deletions src/components/ReportWelcomeText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ function ReportWelcomeText({report, policy, personalDetails}: ReportWelcomeTextP
const isPolicyExpenseChat = ReportUtils.isPolicyExpenseChat(report);
const isChatRoom = ReportUtils.isChatRoom(report);
const isSelfDM = ReportUtils.isSelfDM(report);
const isDefault = !(isChatRoom || isPolicyExpenseChat || isSelfDM);
const isInvoiceRoom = ReportUtils.isInvoiceRoom(report);
const isDefault = !(isChatRoom || isPolicyExpenseChat || isSelfDM || isInvoiceRoom);
const participantAccountIDs = report?.participantAccountIDs ?? [];
const isMultipleParticipant = participantAccountIDs.length > 1;
const displayNamesWithTooltips = ReportUtils.getDisplayNamesWithTooltips(OptionsListUtils.getPersonalDetailsForAccountIDs(participantAccountIDs, personalDetails), isMultipleParticipant);
Expand All @@ -58,6 +59,10 @@ function ReportWelcomeText({report, policy, personalDetails}: ReportWelcomeTextP
};

const welcomeHeroText = useMemo(() => {
if (isInvoiceRoom) {
return translate('reportActionsView.sayHello');
}

if (isChatRoom) {
return translate('reportActionsView.welcomeToRoom', {roomName: reportName});
}
Expand All @@ -67,7 +72,7 @@ function ReportWelcomeText({report, policy, personalDetails}: ReportWelcomeTextP
}

return translate('reportActionsView.sayHello');
}, [isChatRoom, isSelfDM, translate, reportName]);
}, [isChatRoom, isInvoiceRoom, isSelfDM, translate, reportName]);

return (
<>
Expand Down
2 changes: 2 additions & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,7 @@ export default {
beginningOfChatHistoryAnnounceRoomPartTwo: ({workspaceName}: BeginningOfChatHistoryAnnounceRoomPartTwo) => ` to chat about anything ${workspaceName} related.`,
beginningOfChatHistoryUserRoomPartOne: 'Collaboration starts here! 🎉\nUse this space to chat about anything ',
beginningOfChatHistoryUserRoomPartTwo: ' related.',
beginningOfChatHistoryInvoiceRoom: 'Collaboration starts here! 🎉 Use this room to view, discuss, and pay invoices.',
beginningOfChatHistory: 'This is the beginning of your chat with ',
beginningOfChatHistoryPolicyExpenseChatPartOne: 'Collaboration between ',
beginningOfChatHistoryPolicyExpenseChatPartTwo: ' and ',
Expand All @@ -519,6 +520,7 @@ export default {
split: 'split an expense',
submit: 'submit an expense',
track: 'track an expense',
invoice: 'invoice an expense',
},
},
reportAction: {
Expand Down
2 changes: 2 additions & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,7 @@ export default {
beginningOfChatHistoryAnnounceRoomPartTwo: ({workspaceName}: BeginningOfChatHistoryAnnounceRoomPartTwo) => ` para chatear sobre cualquier cosa relacionada con ${workspaceName}.`,
beginningOfChatHistoryUserRoomPartOne: '¡Este es el lugar para colaborar! 🎉\nUsa este espacio para chatear sobre cualquier cosa relacionada con ',
beginningOfChatHistoryUserRoomPartTwo: '.',
beginningOfChatHistoryInvoiceRoom: '¡Este es el lugar para colaborar! 🎉 Utilice esta sala para ver, discutir y pagar facturas.',
beginningOfChatHistory: 'Aquí comienzan tus conversaciones con ',
beginningOfChatHistoryPolicyExpenseChatPartOne: '¡La colaboración entre ',
beginningOfChatHistoryPolicyExpenseChatPartTwo: ' y ',
Expand All @@ -512,6 +513,7 @@ export default {
split: 'dividir un gasto',
submit: 'presentar un gasto',
track: 'rastrear un gasto',
invoice: 'facturar un gasto',
},
},
reportAction: {
Expand Down
4 changes: 2 additions & 2 deletions src/libs/ReportActionsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,9 @@ function isTransactionThread(parentReportAction: OnyxEntry<ReportAction> | Empty
* Returns the reportID for the transaction thread associated with a report by iterating over the reportActions and identifying the IOU report actions with a childReportID. Returns a reportID if there is exactly one transaction thread for the report, and null otherwise.
*/
function getOneTransactionThreadReportID(reportID: string, reportActions: OnyxEntry<ReportActions> | ReportAction[], isOffline: boolean | undefined = undefined): string | null {
// If the report is not an IOU or Expense report, it shouldn't be treated as one-transaction report.
// If the report is not an IOU, Expense report or an Invoice, it shouldn't be treated as one-transaction report.
const report = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`];
if (report?.type !== CONST.REPORT.TYPE.IOU && report?.type !== CONST.REPORT.TYPE.EXPENSE) {
if (report?.type !== CONST.REPORT.TYPE.IOU && report?.type !== CONST.REPORT.TYPE.EXPENSE && report?.type !== CONST.REPORT.TYPE.INVOICE) {
return null;
}

Expand Down
Loading

0 comments on commit 223672b

Please sign in to comment.