|
1 | | -/* eslint-disable prettier/prettier */ |
2 | 1 | import { Component } from 'react'; |
3 | 2 | import PropTypes from 'prop-types'; |
4 | 3 | import { |
@@ -623,10 +622,14 @@ export class WeeklySummary extends Component { |
623 | 622 |
|
624 | 623 | // Updates user profile and weekly summaries |
625 | 624 | updateUserData = async userId => { |
626 | | - // eslint-disable-next-line no-shadow |
627 | 625 | const { getUserProfile, getWeeklySummaries } = this.props; |
628 | | - await getUserProfile(userId); |
629 | | - await getWeeklySummaries(userId); |
| 626 | + if (typeof getUserProfile === 'function') { |
| 627 | + await getUserProfile(userId); |
| 628 | + } |
| 629 | + // always refresh summaries if that exists |
| 630 | + if (typeof getWeeklySummaries === 'function') { |
| 631 | + await getWeeklySummaries(userId); |
| 632 | + } |
630 | 633 | }; |
631 | 634 |
|
632 | 635 | // Handler for success scenario after save |
@@ -654,15 +657,15 @@ export class WeeklySummary extends Component { |
654 | 657 | const toastIdOnSave = 'toast-on-save'; |
655 | 658 | const errors = this.validate(); |
656 | 659 |
|
657 | | - this.setState({ errors: errors || {} }); |
| 660 | + this.setState({ errors: errors }); |
658 | 661 | if (Object.keys(errors).length > 0) { |
659 | 662 | this.setState({ moveConfirm: false }); |
660 | 663 | return; |
661 | 664 | } |
662 | 665 |
|
663 | 666 | const result = await this.handleChangeInSummary(); |
664 | 667 |
|
665 | | - if (result === 200) { |
| 668 | + if (result === 200 || result?.status === 200) { |
666 | 669 | await this.handleSaveSuccess(toastIdOnSave); |
667 | 670 | if (closeAfterSave) { |
668 | 671 | this.handleClose(); |
@@ -712,10 +715,10 @@ export class WeeklySummary extends Component { |
712 | 715 | } |
713 | 716 | this.mainSaveHandler(true); |
714 | 717 | }; |
715 | | - |
716 | 718 | handleClose = () => { |
717 | | - // eslint-disable-next-line react/destructuring-assignment |
718 | | - this.props.setPopup(false); |
| 719 | + if (typeof this.props.setPopup === 'function') { |
| 720 | + this.props.setPopup(false); |
| 721 | + } |
719 | 722 | }; |
720 | 723 |
|
721 | 724 | render() { |
|
0 commit comments