Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/CONST/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,7 @@ const CONST = {
FNS_TIMEZONE_FORMAT_STRING: "yyyy-MM-dd'T'HH:mm:ssXXX",
FNS_DB_FORMAT_STRING: 'yyyy-MM-dd HH:mm:ss.SSS',
LONG_DATE_FORMAT_WITH_WEEKDAY: 'eeee, MMMM d, yyyy',
LONG_DATE_FORMAT_WITH_WEEKDAY_WITHOUT_YEAR: 'eeee, MMMM d',
ORDINAL_DAY_OF_MONTH: 'do',
MONTH_DAY_YEAR_ORDINAL_FORMAT: 'MMMM do, yyyy',
SECONDS_PER_DAY: 24 * 60 * 60,
Expand Down
35 changes: 30 additions & 5 deletions src/components/Search/SearchRouter/useAskConcierge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,26 @@ import useSidePanelReportID from '@hooks/useSidePanelReportID';

import getNonEmptyStringOnyxID from '@libs/getNonEmptyStringOnyxID';

import {addComment} from '@userActions/Report';
import {addAttachmentWithComment, addComment} from '@userActions/Report';

import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type {FileObject} from '@src/types/utils/Attachment';

/**
* Returns a callback that opens the side panel (or Concierge chat on native)
* and sends the provided search query as a message.
* Also returns a flag indicating whether the Ask Concierge item is ready to be displayed.
*
* @param forceConcierge Always target the Concierge report, ignoring the report the side panel currently maps to.
* Entry points whose sole purpose is messaging Concierge (e.g. the Home prompt) must set this, otherwise the message
* can be posted to the workspace #admins room the side panel maps to during the onboarding RHP variants.
*/
function useAskConcierge() {
function useAskConcierge({forceConcierge = false}: {forceConcierge?: boolean} = {}) {
const sidePanelReportID = useSidePanelReportID();
const [conciergeReportID] = useOnyx(ONYXKEYS.CONCIERGE_REPORT_ID);
const {openConciergeAnywhere, isInSidePanel} = useOpenConciergeAnywhere();
const targetReportID = (isInSidePanel ? sidePanelReportID : undefined) ?? conciergeReportID;
const targetReportID = forceConcierge ? conciergeReportID : ((isInSidePanel ? sidePanelReportID : undefined) ?? conciergeReportID);
const [targetReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${getNonEmptyStringOnyxID(targetReportID)}`);
const {timezone, accountID: currentUserAccountID} = useCurrentUserPersonalDetails();
const delegateAccountID = useDelegateAccountID();
Expand All @@ -31,7 +36,7 @@ function useAskConcierge() {
if (!trimmedQuery || !shouldShowAskConcierge) {
return;
}
openConciergeAnywhere();
openConciergeAnywhere({forceConcierge});
addComment({
report: targetReport,
notifyReportID: targetReportID,
Expand All @@ -46,7 +51,27 @@ function useAskConcierge() {
});
};

return {askConcierge, shouldShowAskConcierge};
const askConciergeWithAttachment = (attachments: FileObject | FileObject[], searchQuery: string) => {
if (!shouldShowAskConcierge) {
return;
}
openConciergeAnywhere({forceConcierge});
addAttachmentWithComment({
report: targetReport,
notifyReportID: targetReportID,
ancestors: [],
attachments,
currentUserAccountID,
text: searchQuery.trim(),
timezone: timezone ?? CONST.DEFAULT_TIME_ZONE,
shouldPlaySound: true,
isInSidePanel,
delegateAccountID,
conciergeReportID,
});
};

return {askConcierge, askConciergeWithAttachment, shouldShowAskConcierge, conciergeTargetReportID: targetReportID};
}

export default useAskConcierge;
17 changes: 16 additions & 1 deletion src/hooks/useConciergeSidePanelReportActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,12 @@ function useConciergeSidePanelReportActions({
}
const filtered = actions.filter(isCurrentSessionAction);
if (filtered.length === 0) {
// Side panel: nothing matched the current session yet (e.g. just after reopen, before the new
// message propagates). Show the greeting instead of `actions` to avoid flashing stale history.
if (!isConciergeMainDM && conciergeGreetingAction) {
const createdAction = actions.find(isCreatedAction);
return createdAction ? [conciergeGreetingAction, createdAction] : [conciergeGreetingAction];
}
return actions;
}
if (conciergeGreetingAction) {
Expand All @@ -188,7 +194,16 @@ function useConciergeSidePanelReportActions({
}
return filtered;
},
[showConciergeSidePanelWelcome, conciergeGreetingAction, isConciergeHiddenHistory, showFullHistory, sessionStartTime, isCurrentSessionAction, hadUserMessageAtSessionStart],
[
showConciergeSidePanelWelcome,
conciergeGreetingAction,
isConciergeHiddenHistory,
showFullHistory,
sessionStartTime,
isCurrentSessionAction,
hadUserMessageAtSessionStart,
isConciergeMainDM,
],
);

const filteredVisibleActions = useMemo(() => filterActions(visibleReportActions), [filterActions, visibleReportActions]);
Expand Down
7 changes: 7 additions & 0 deletions src/languages/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1089,6 +1089,13 @@ const translations: TranslationDeepObject<typeof en> = {
emptyStateMessage: 'Erstellen Sie eine oder ziehen Sie eine Quittung hierher',
},
insightsSection: {chartUnavailable: 'Diagramm nicht verfügbar', notEnoughData: 'Wir haben noch nicht genügend Daten, um dieses Diagramm auszufüllen'},
conciergePrompt: {
goodMorning: ({name}: {name?: string}) => (name ? `Guten Morgen, ${name}.` : 'Guten Morgen.'),
goodAfternoon: ({name}: {name?: string}) => (name ? `Guten Tag, ${name}.` : 'Guten Tag.'),
goodEvening: ({name}: {name?: string}) => (name ? `Guten Abend, ${name}.` : 'Guten Abend.'),
inputPlaceholder: 'Bitten Sie Concierge, Ihre Ausgaben zu analysieren oder Unterstützung zu erhalten',
inputPlaceholderMobile: 'Stellen Sie Concierge eine Frage',
},
},
allSettingsScreen: {
subscription: 'Abonnement',
Expand Down
7 changes: 7 additions & 0 deletions src/languages/el.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1137,6 +1137,13 @@ const translations: TranslationDeepObject<typeof en> = {
chartUnavailable: 'Το γράφημα δεν είναι διαθέσιμο',
notEnoughData: 'Δεν έχουμε ακόμη αρκετά δεδομένα για να συμπληρώσουμε αυτό το γράφημα',
},
conciergePrompt: {
goodMorning: ({name}: {name?: string}) => (name ? `Καλημέρα, ${name}.` : 'Καλημέρα.'),
goodAfternoon: ({name}: {name?: string}) => (name ? `Καλησπέρα σας, ${name}.` : 'Καλό απόγευμα.'),
goodEvening: ({name}: {name?: string}) => (name ? `Καλησπέρα, ${name}.` : 'Καλησπέρα.'),
inputPlaceholder: 'Ζητήστε από το Concierge να αναλύσει τα έξοδά σας ή να λάβετε υποστήριξη',
inputPlaceholderMobile: 'Ρωτήστε το Concierge οτιδήποτε',
},
},
allSettingsScreen: {
subscription: 'Συνδρομή',
Expand Down
7 changes: 7 additions & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -969,6 +969,13 @@ const translations = {
},
homePage: {
forYou: 'For you',
conciergePrompt: {
goodMorning: ({name}: {name?: string}) => (name ? `Good morning, ${name}.` : 'Good morning.'),
goodAfternoon: ({name}: {name?: string}) => (name ? `Good afternoon, ${name}.` : 'Good afternoon.'),
goodEvening: ({name}: {name?: string}) => (name ? `Good evening, ${name}.` : 'Good evening.'),
inputPlaceholder: 'Ask Concierge to analyze your expenses or get support',
inputPlaceholderMobile: 'Ask Concierge anything',
},
timeSensitiveSection: {
title: 'Time sensitive',
ctaFix: 'Fix',
Expand Down
7 changes: 7 additions & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1084,6 +1084,13 @@ const translations: TranslationDeepObject<typeof en> = {
emptyStateMessage: 'Crea uno o arrastra un recibo aquí',
},
insightsSection: {chartUnavailable: 'Gráfico no disponible', notEnoughData: 'Todavía no tenemos suficientes datos para completar este gráfico'},
conciergePrompt: {
goodMorning: ({name}: {name?: string}) => (name ? `Buenos días, ${name}.` : 'Buenos días.'),
goodAfternoon: ({name}: {name?: string}) => (name ? `Buenas tardes, ${name}.` : 'Buenas tardes.'),
goodEvening: ({name}: {name?: string}) => (name ? `Buenas noches, ${name}.` : 'Buenas noches.'),
inputPlaceholder: 'Pídele a Concierge que analice tus gastos o que te ayude',
inputPlaceholderMobile: 'Pregunta a Concierge cualquier cosa',
},
},
allSettingsScreen: {
subscription: 'Suscripcion',
Expand Down
7 changes: 7 additions & 0 deletions src/languages/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1092,6 +1092,13 @@ const translations: TranslationDeepObject<typeof en> = {
emptyStateMessage: 'Créez-en un ou faites glisser un reçu ici',
},
insightsSection: {chartUnavailable: 'Graphique indisponible', notEnoughData: 'Nous n’avons pas encore suffisamment de données pour remplir ce graphique'},
conciergePrompt: {
goodMorning: ({name}: {name?: string}) => (name ? `Bonjour, ${name}.` : 'Bonjour.'),
goodAfternoon: ({name}: {name?: string}) => (name ? `Bonjour, ${name}.` : 'Bon après-midi.'),
goodEvening: ({name}: {name?: string}) => (name ? `Bonsoir, ${name}.` : 'Bonsoir.'),
inputPlaceholder: 'Demander à Concierge d’analyser vos dépenses ou d’obtenir de l’aide',
inputPlaceholderMobile: 'Demander n’importe quoi à Concierge',
},
},
allSettingsScreen: {
subscription: 'Abonnement',
Expand Down
7 changes: 7 additions & 0 deletions src/languages/it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1090,6 +1090,13 @@ const translations: TranslationDeepObject<typeof en> = {
emptyStateMessage: 'Creane una o trascina qui una ricevuta',
},
insightsSection: {chartUnavailable: 'Grafico non disponibile', notEnoughData: 'Non abbiamo ancora abbastanza dati per compilare questo grafico'},
conciergePrompt: {
goodMorning: ({name}: {name?: string}) => (name ? `Buongiorno, ${name}.` : 'Buongiorno.'),
goodAfternoon: ({name}: {name?: string}) => (name ? `Buon pomeriggio, ${name}.` : 'Buon pomeriggio.'),
goodEvening: ({name}: {name?: string}) => (name ? `Buonasera, ${name}.` : 'Buona sera.'),
inputPlaceholder: 'Chiedi a Concierge di analizzare le tue spese o chiedi supporto',
inputPlaceholderMobile: 'Chiedi qualsiasi cosa a Concierge',
},
},
allSettingsScreen: {
subscription: 'Abbonamento',
Expand Down
7 changes: 7 additions & 0 deletions src/languages/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1073,6 +1073,13 @@ const translations: TranslationDeepObject<typeof en> = {
emptyStateMessage: '新規作成するか、レシートをここにドラッグしてください',
},
insightsSection: {chartUnavailable: 'グラフを表示できません', notEnoughData: 'このチャートを表示するためのデータがまだ十分にありません'},
conciergePrompt: {
goodMorning: ({name}: {name?: string}) => (name ? `${name}さん、おはようございます。` : 'おはようございます。'),
goodAfternoon: ({name}: {name?: string}) => (name ? `${name}さん、こんにちは。` : 'こんにちは。'),
goodEvening: ({name}: {name?: string}) => (name ? `${name}さん、こんばんは。` : 'こんばんは。'),
inputPlaceholder: 'Concierge に経費の分析を依頼するか、サポートを受けます',
inputPlaceholderMobile: 'Concierge に何でも聞いてください',
},
},
allSettingsScreen: {
subscription: 'サブスクリプション',
Expand Down
7 changes: 7 additions & 0 deletions src/languages/nl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1088,6 +1088,13 @@ const translations: TranslationDeepObject<typeof en> = {
emptyStateMessage: 'Maak er een aan of sleep hier een bonnetje naartoe',
},
insightsSection: {chartUnavailable: 'Diagram niet beschikbaar', notEnoughData: 'We hebben nog niet genoeg gegevens om deze grafiek te vullen'},
conciergePrompt: {
goodMorning: ({name}: {name?: string}) => (name ? `Goedemorgen, ${name}.` : 'Goedemorgen.'),
goodAfternoon: ({name}: {name?: string}) => (name ? `Goedemiddag, ${name}.` : 'Goedemiddag.'),
goodEvening: ({name}: {name?: string}) => (name ? `Goedenavond, ${name}.` : 'Goedenavond.'),
inputPlaceholder: 'Vraag Concierge om je uitgaven te analyseren of om hulp te krijgen',
inputPlaceholderMobile: 'Stel Concierge alles gerust een vraag',
},
},
allSettingsScreen: {
subscription: 'Abonnement',
Expand Down
7 changes: 7 additions & 0 deletions src/languages/pl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1086,6 +1086,13 @@ const translations: TranslationDeepObject<typeof en> = {
emptyStateMessage: 'Utwórz jeden lub przeciągnij tu paragon',
},
insightsSection: {chartUnavailable: 'Wykres niedostępny', notEnoughData: 'Nie mamy jeszcze wystarczającej ilości danych, żeby wypełnić ten wykres'},
conciergePrompt: {
goodMorning: ({name}: {name?: string}) => (name ? `Dzień dobry, ${name}.` : 'Dzień dobry.'),
goodAfternoon: ({name}: {name?: string}) => (name ? `Dzień dobry, ${name}.` : 'Dzień dobry.'),
goodEvening: ({name}: {name?: string}) => (name ? `Dobry wieczór, ${name}.` : 'Dobry wieczór.'),
inputPlaceholder: 'Poproś Concierge o przeanalizowanie swoich wydatków lub uzyskaj pomoc',
inputPlaceholderMobile: 'Zapytaj Concierge o cokolwiek',
},
},
allSettingsScreen: {
subscription: 'Subskrypcja',
Expand Down
7 changes: 7 additions & 0 deletions src/languages/pt-BR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1088,6 +1088,13 @@ const translations: TranslationDeepObject<typeof en> = {
emptyStateMessage: 'Crie um ou arraste um recibo aqui',
},
insightsSection: {chartUnavailable: 'Gráfico indisponível', notEnoughData: 'Ainda não temos dados suficientes para preencher este gráfico'},
conciergePrompt: {
goodMorning: ({name}: {name?: string}) => (name ? `Bom dia, ${name}.` : 'Bom dia.'),
goodAfternoon: ({name}: {name?: string}) => (name ? `Boa tarde, ${name}.` : 'Boa tarde.'),
goodEvening: ({name}: {name?: string}) => (name ? `Boa noite, ${name}.` : 'Boa noite.'),
inputPlaceholder: 'Peça ao Concierge para analisar suas despesas ou obter suporte',
inputPlaceholderMobile: 'Pergunte qualquer coisa ao Concierge',
},
},
allSettingsScreen: {
subscription: 'Assinatura',
Expand Down
7 changes: 7 additions & 0 deletions src/languages/zh-hans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1044,6 +1044,13 @@ const translations: TranslationDeepObject<typeof en> = {
seeMore: ({count}: {count: number}) => `再查看 ${count} 个`,
recentlyAddedSection: {title: '最近添加', viewAll: '查看所有报销费用', emptyStateTitle: '最近没有报销记录', emptyStateMessage: '创建一个或将收据拖到这里'},
insightsSection: {chartUnavailable: '图表不可用', notEnoughData: '我们目前没有足够的数据来填充此图表'},
conciergePrompt: {
goodMorning: ({name}: {name?: string}) => (name ? `早上好,${name}。` : '早上好。'),
goodAfternoon: ({name}: {name?: string}) => (name ? `下午好,${name}。` : '下午好。'),
goodEvening: ({name}: {name?: string}) => (name ? `晚上好,${name}。` : '晚上好。'),
inputPlaceholder: '向 Concierge 请求分析你的报销或获取支持',
inputPlaceholderMobile: '向 Concierge 提问任何问题',
},
},
allSettingsScreen: {
subscription: '订阅',
Expand Down
26 changes: 26 additions & 0 deletions src/libs/DateUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,30 @@ function formatToLongDateWithWeekday(datetime: string | Date, dateFnsLocale: Dat
return format(new Date(datetime), CONST.DATE.LONG_DATE_FORMAT_WITH_WEEKDAY, {locale: dateFnsLocale});
}

/**
* Format date to a long date format with weekday but without the year
*
* @returns Sunday, July 9
*/
function formatToLongDateWithWeekdayWithoutYear(datetime: string | Date, dateFnsLocale: DateFnsLocale | undefined): string {
return format(new Date(datetime), CONST.DATE.LONG_DATE_FORMAT_WITH_WEEKDAY_WITHOUT_YEAR, {locale: dateFnsLocale});
}

/**
* Get the time-of-day greeting key based on the hour of the given (already timezone-adjusted) date.
* Ranges: morning 4am to 12pm, afternoon 12pm to 5pm, evening 5pm to 4am.
*/
function getTimeOfDayGreetingKey(date: Date): 'goodMorning' | 'goodAfternoon' | 'goodEvening' {
const hour = date.getHours();
if (hour >= 4 && hour < 12) {
return 'goodMorning';
}
if (hour >= 12 && hour < 17) {
return 'goodAfternoon';
}
return 'goodEvening';
}

/**
* Format date to a weekday format
*
Expand Down Expand Up @@ -1182,6 +1206,8 @@ const DateUtils = {
isDate,
formatToDayOfWeek,
formatToLongDateWithWeekday,
formatToLongDateWithWeekdayWithoutYear,
getTimeOfDayGreetingKey,
formatToLocalTime,
formatToReadableString,
getZoneAbbreviation,
Expand Down
Loading
Loading