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

fix(company data): extended error handling #958

Conversation

manojava-gk
Copy link
Contributor

@manojava-gk manojava-gk commented Jul 22, 2024

Description

  • Integrate /ready api to trigger once the new record is created
  • Show sharing state error details in the company overlay details page

Why

new request

Issue

#955 #941

Checklist

Please delete options that are not relevant.

  • I have followed the contributing guidelines
  • I have performed IP checks for added or updated 3rd party libraries
  • I have created and linked IP issues or requested their creation by a committer
  • I have performed a self-review of my own code
  • I have successfully tested my changes locally
  • I have added tests that prove my changes work
  • I have checked that new and existing tests pass locally with my changes
  • I have commented my code, particularly in hard-to-understand areas

@manojava-gk manojava-gk marked this pull request as ready for review July 24, 2024 15:10
Copy link
Contributor

@oyo oyo left a comment

Choose a reason for hiding this comment

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

simplify if-return-else-return... chains

return 'warning'
} else if (status === SharingStateStatusType.Pending) {
Copy link
Contributor

Choose a reason for hiding this comment

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

it has been in the code before but we don't need else in cases where the previous code will return 100% sure.

instead of

if (a) {
  return x
} else if (b) {
  return y
} else {
  return z
}

simply write

if (a)
  return x
if (b)
  return y
return z

} else if (status === SharingStateStatusType.Pending) {
return 'info'
} else if (status === SharingStateStatusType.Ready) {
return 'primary'
Copy link
Contributor

Choose a reason for hiding this comment

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

again else after return

@MaximilianHauer
Copy link

@manojava-gk could you please check the comment from @oyo

@manojava-gk manojava-gk requested a review from oyo August 12, 2024 05:47
@MaximilianHauer MaximilianHauer added the priority PR needs to prioritized at review label Aug 12, 2024
Copy link
Contributor

@oyo oyo left a comment

Choose a reason for hiding this comment

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

change mapping function to map like we did in other PRs

else if (status === SharingStateStatusType.Initial) return 'warning'
else if (status === SharingStateStatusType.Pending) return 'info'
else if (status === SharingStateStatusType.Ready) return 'primary'
return 'error'
Copy link
Contributor

Choose a reason for hiding this comment

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

In discussion with Lavanya we came up with a solution using a map instead of a function, which is more elegant imho. Can you please have a look and implement accordingly:
https://github.com/eclipse-tractusx/portal-frontend/pull/967/files#diff-ef36c5be86b0e58f10f5281ace1652ca5c2a443d542d2336fd3b0fd28f945de7R101

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 have already used this type of mapping just above this method.

const statusColor: Record<string, 'default' | 'primary' | 'secondary' | 'error' | 'info' | 'success' | 'warning'> = {
    Success: 'success',
    Pending: 'info',
    Ready: 'primary',
    Initial: 'warning',
    Error: 'error'
  }

Could you pls verify the above one?

Copy link
Contributor

Choose a reason for hiding this comment

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

I haven't seen that in your code - now I updated your PR with a shared map to get the colors from status types using proper types instead of strings

@evegufy evegufy added this to the Release 2.2.0 milestone Aug 12, 2024
Copy link

Copy link
Contributor

@oyo oyo left a comment

Choose a reason for hiding this comment

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

lgtm after PR update

@oyo oyo merged commit 2c923a1 into eclipse-tractusx:main Aug 12, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority PR needs to prioritized at review
Projects
Status: USER READY
Development

Successfully merging this pull request may close these issues.

4 participants