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 13 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 @@ -56,8 +56,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.createChat')}
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 @@ -1636,6 +1636,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
4 changes: 4 additions & 0 deletions src/libs/actions/ReportActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ 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

if (ReportUtils.isThreadParent(reportAction)) {
namhihi237 marked this conversation as resolved.
Show resolved Hide resolved
Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${reportAction.childReportID}`, null);
namhihi237 marked this conversation as resolved.
Show resolved Hide resolved
}
return;
}

Expand Down
32 changes: 27 additions & 5 deletions src/libs/actions/Task.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,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: {
createChat: ErrorUtils.getMicroSecondOnyxError('task.genericCreateTaskFailureMessage'),
Copy link
Member

Choose a reason for hiding this comment

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

So I checked the backend returns error with CreateTask but I am not sure which flag should we use here. @thienlnam Can you help us with this? Should this be createChat or createTask?

Copy link
Member

Choose a reason for hiding this comment

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

Also, Can you please tell me how do we determine which key should be used here? It will help me understand this concept better.

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's just use a new createTask key.

Can you please tell me how do we determine which key should be used here

We mostly just use the action that failed and key it as such. So in this scenario since there was an error creating the task we add the error key on createTask

Copy link
Member

Choose a reason for hiding this comment

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

@namhihi237 let's get that done please. This is the last change.

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 updated

},
},
},
{
onyxMethod: Onyx.METHOD.MERGE,
Expand Down Expand Up @@ -186,7 +190,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 @@ -905,7 +913,21 @@ 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,
});

Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`, null);

Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(report.parentReportID));
namhihi237 marked this conversation as resolved.
Show resolved Hide resolved
return;
}

Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`, {
pendingFields: null,
errorFields: null,
Expand Down Expand Up @@ -960,7 +982,7 @@ export {
cancelTask,
dismissModalAndClearOutTaskInfo,
getTaskAssigneeAccountID,
clearEditTaskErrors,
clearTaskErrors,
canModifyTask,
getTaskReportActionMessage,
};
Loading