Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add failure message when create a task error #26848

Merged
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
4 changes: 2 additions & 2 deletions src/components/ReportActionItem/TaskView.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ function TaskView(props) {
<View>
<OfflineWithFeedback
shouldShowErrorMessages
errors={lodashGet(props, 'report.errorFields.editTask')}
onClose={() => Task.clearEditTaskErrors(props.report.reportID)}
errors={lodashGet(props, 'report.errorFields.editTask') || lodashGet(props, 'report.errorFields.createTask')}
namhihi237 marked this conversation as resolved.
Show resolved Hide resolved
onClose={() => Task.clearTaskErrors(props.report.reportID)}
errorRowStyles={styles.ph5}
>
<Hoverable>
Expand Down
1 change: 1 addition & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1637,6 +1637,7 @@ export default {
markAsComplete: 'Mark as complete',
markAsIncomplete: 'Mark as incomplete',
assigneeError: 'There was an error assigning this task, please try another assignee.',
genericCreateTaskFailureMessage: 'Unexpected error create task, please try again later.',
},
statementPage: {
generatingPDF: "We're generating your PDF right now. Please come back later!",
Expand Down
1 change: 1 addition & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1660,6 +1660,7 @@ export default {
markAsComplete: 'Marcar como completada',
markAsIncomplete: 'Marcar como incompleta',
assigneeError: 'Hubo un error al asignar esta tarea, inténtalo con otro usuario.',
genericCreateTaskFailureMessage: 'Error inesperado al crear el tarea, por favor, inténtalo más tarde.',
},
statementPage: {
generatingPDF: 'Estamos generando tu PDF ahora mismo. ¡Por favor, vuelve más tarde!',
Expand Down
6 changes: 6 additions & 0 deletions src/libs/actions/ReportActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import * as ReportUtils from '@libs/ReportUtils';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ReportAction from '@src/types/onyx/ReportAction';
import * as Report from './Report';

function clearReportActionErrors(reportID: string, reportAction: ReportAction) {
const originalReportID = ReportUtils.getOriginalReportID(reportID, reportAction);
Expand All @@ -24,6 +25,11 @@ function clearReportActionErrors(reportID: string, reportAction: ReportAction) {
Onyx.set(`${ONYXKEYS.COLLECTION.TRANSACTION}${linkedTransactionID}`, null);
}

// Delete the failed task report too
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a generic function so I am trying to test it with other report actions. This might be applicable to money requests. But I am not sure how to get a failed money request error on action.

Any idea?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can flow steps:

  1. Click fab button
  2. Start chat with new user and send any message
  3. Click fab button
  4. Request money then select manual
  5. Input amount and next
  6. Input new account above and select
  7. Request

const taskReportID = reportAction.message?.[0]?.taskReportID;
if (taskReportID) {
Report.deleteReport(taskReportID);
}
return;
}

Expand Down
31 changes: 26 additions & 5 deletions src/libs/actions/Task.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import * as UserUtils from '@libs/UserUtils';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import * as Report from './Report';

let currentUserEmail;
let currentUserAccountID;
Expand Down Expand Up @@ -134,9 +135,13 @@ function createTaskAndNavigate(parentReportID, title, description, assigneeEmail
// FOR TASK REPORT
const failureData = [
{
onyxMethod: Onyx.METHOD.SET,
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT}${optimisticTaskReport.reportID}`,
value: null,
value: {
errorFields: {
createTask: ErrorUtils.getMicroSecondOnyxError('task.genericCreateTaskFailureMessage'),
namhihi237 marked this conversation as resolved.
Show resolved Hide resolved
},
},
},
{
onyxMethod: Onyx.METHOD.MERGE,
Expand Down Expand Up @@ -187,7 +192,11 @@ function createTaskAndNavigate(parentReportID, title, description, assigneeEmail
failureData.push({
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${parentReportID}`,
value: {[optimisticAddCommentReport.reportAction.reportActionID]: {pendingAction: null}},
value: {
[optimisticAddCommentReport.reportAction.reportActionID]: {
errors: ErrorUtils.getMicroSecondOnyxError('task.genericCreateTaskFailureMessage'),
},
},
});

clearOutTaskInfo();
Expand Down Expand Up @@ -875,7 +884,19 @@ function canModifyTask(taskReport, sessionAccountID) {
/**
* @param {String} reportID
*/
function clearEditTaskErrors(reportID) {
function clearTaskErrors(reportID) {
const report = ReportUtils.getReport(reportID);

// Delete the task preview in the parent report
if (lodashGet(report, 'pendingFields.createChat') === CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD) {
namhihi237 marked this conversation as resolved.
Show resolved Hide resolved
Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.parentReportID}`, {
[report.parentReportActionID]: null,
});

Report.navigateToConciergeChatAndDeleteReport(reportID);
return;
}

Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`, {
pendingFields: null,
errorFields: null,
Expand Down Expand Up @@ -930,7 +951,7 @@ export {
cancelTask,
dismissModalAndClearOutTaskInfo,
getTaskAssigneeAccountID,
clearEditTaskErrors,
clearTaskErrors,
canModifyTask,
getTaskReportActionMessage,
};
3 changes: 3 additions & 0 deletions src/types/onyx/ReportAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ type Message = {

moderationDecision?: Decision;
translationKey?: string;

/** ID of a task report */
taskReportID?: string;
};

type Person = {
Expand Down
Loading