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

5242 add delete response requisitions #5269

Merged
merged 22 commits into from
Nov 10, 2024

Conversation

fergie-nz
Copy link
Contributor

@fergie-nz fergie-nz commented Oct 30, 2024

Fixes #5242

πŸ‘©πŸ»β€πŸ’» What does this PR do?

Adds delete for response requisitions

Matches pattern of request requisition with slightly different validation.

Note the front end error handling for both response and request requisitions isn't quite right and will return all is OK when structured errors are returned.

I've made a separate issue for structured error handling as changes are required for both request and response error handling. (#5270)

πŸ’Œ Any notes for the reviewer?

I think also missing is a check for linked shipments before being able to select and delete.

I wonder should requisitions be disabled once a shipment has been created? Currently this doesn't include checks for this.

πŸ§ͺ Testing

  • Go to response requisitions
  • Create a requisition
  • Select via drop down and delete

πŸ“ƒ Documentation

  • Part of an epic: documentation will be completed for the feature as a whole

@github-actions github-actions bot added enhancement New feature or request Team Ruru πŸ¦‰ Roxy, Ferg, Noel labels Oct 30, 2024
Comment on lines 19 to 44

// response requisition errors

pub struct FinalisedRequisition;
#[Object]
impl FinalisedRequisition {
pub async fn description(&self) -> &str {
"Response requisition has already been finalised"
}
}

pub struct TransferRequisition;
#[Object]
impl TransferRequisition {
pub async fn description(&self) -> &str {
"Cannot delete a response requisition transferred from a request requisition"
}
}

pub struct RequisitionWithShipment;
#[Object]
impl RequisitionWithShipment {
pub async fn description(&self) -> &str {
"Cannot delete a response requisition once a shipment has been generated"
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These errors won't propagate to UI currently. We need error handling for both response and request requisitions

Copy link

github-actions bot commented Oct 30, 2024

Bundle size difference

Comparing this PR to main

Old size New size Diff
4.96 MB 4.97 MB 3.54 KB (0.07%)

@roxy-dao roxy-dao self-assigned this Nov 4, 2024
Copy link
Contributor

@roxy-dao roxy-dao left a comment

Choose a reason for hiding this comment

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

Thanks Ferg! Looks great~

Have just a few changes down below (: and would be great if we can get errors showing correctly. Very confusing to the user to see a "1 requisition has been deleted" success toast when they've not deleted any requisitions...

@fergie-nz fergie-nz requested a review from roxy-dao November 4, 2024 23:09
Comment on lines 33 to 41
result.forEach(line => {
if (line.response.__typename == 'DeleteResponseRequisitionError') {
info(line.response.error.description)();
errorMessages.push(line.response.error.description);
}
});
if (errorMessages.length > 0) {
throw new Error();
}
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've added a check here for errors on delete action to throw errors for each failed delete with structure rather than one error with the generic hook.

However it does leave an extra snack when error handling. But figure that is OK rather than more extended refactoring

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm getting double toast on error
Screenshot 2024-11-06 at 9 09 06β€―AM

Copy link
Contributor

@roxy-dao roxy-dao left a comment

Choose a reason for hiding this comment

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

Thanks for the changes Ferg. I seem to be getting double snack because of the error being throw in the length check

Comment on lines 33 to 41
result.forEach(line => {
if (line.response.__typename == 'DeleteResponseRequisitionError') {
info(line.response.error.description)();
errorMessages.push(line.response.error.description);
}
});
if (errorMessages.length > 0) {
throw new Error();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm getting double toast on error
Screenshot 2024-11-06 at 9 09 06β€―AM

@fergie-nz fergie-nz requested a review from roxy-dao November 6, 2024 03:05
@fergie-nz
Copy link
Contributor Author

Thanks for the changes Ferg. I seem to be getting double snack because of the error being throw in the length check

Nice yeah I had added that. I thought that might have been better than only showing one toast when there were multiple errors.

But have removed.

I think it might be helpful in future to allow useDeleteConfirmation hook to accept an array of errors to propagate them all, rather than the first one which is caught so that the user has to iterate through a trial and error process if there are more than one error across multiple lines

Comment on lines 32 to 40
switch (line.response.error.__typename) {
case 'FinalisedRequisition':
throw Error(t('messages.cannot-delete-finalised-requisition'));
case 'RecordNotFound':
throw Error(t('messages.record-not-found'));
case 'RequisitionWithShipment':
throw Error(t('messages.cannot-delete-requisition-with-shipment'));
case 'TransferRequisition':
throw Error(t('messages.cannot-delete-transfer-requisition'));
Copy link
Contributor

@roxy-dao roxy-dao Nov 6, 2024

Choose a reason for hiding this comment

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

these don't actually get propped...

@fergie-nz fergie-nz requested a review from roxy-dao November 7, 2024 22:05
Copy link
Contributor

@roxy-dao roxy-dao left a comment

Choose a reason for hiding this comment

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

Thanks Ferg just two more changes please (:

pub enum DeleteErrorInterface {
RecordNotFound(RecordNotFound),
FinalisedRequisition(FinalisedRequisition),
TransferRequisition(TransferRequisition),
Copy link
Contributor

Choose a reason for hiding this comment

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

TransferredRequisition

Some(service_provider(test_service, &connection_manager))
);

// line delete error ?
Copy link
Contributor

Choose a reason for hiding this comment

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

???

@roxy-dao roxy-dao merged commit 43d97ee into develop Nov 10, 2024
6 checks passed
@roxy-dao roxy-dao deleted the 5242-add-delete-response-requisitions branch November 10, 2024 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Team Ruru πŸ¦‰ Roxy, Ferg, Noel
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Delete response requisitions
2 participants