Skip to content

Commit

Permalink
fix(pages/expense): allow pay action to submit
Browse files Browse the repository at this point in the history
  • Loading branch information
HipsterBrown committed May 8, 2018
1 parent 4b0a431 commit 4551a9a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
15 changes: 12 additions & 3 deletions src/components/ExpenseWithData.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ class ExpenseWithData extends React.Component {
view: PropTypes.string, // "compact" for homepage (can't edit expense, don't show header), "list" for list view, "details" for details view
filter: PropTypes.object, // { category, recipient }
defaultAction: PropTypes.string, // "new" to open the new expense form by default
LoggedInUser: PropTypes.object
LoggedInUser: PropTypes.object,
allowPayAction: PropTypes.bool,
lockPayAction: PropTypes.func,
unlockPayAction: PropTypes.func,
}

constructor(props) {
Expand All @@ -28,7 +31,10 @@ class ExpenseWithData extends React.Component {
data,
LoggedInUser,
collective,
view
view,
allowPayAction,
lockPayAction,
unlockPayAction,
} = this.props;

if (data.error) {
Expand All @@ -52,7 +58,10 @@ class ExpenseWithData extends React.Component {
view={view}
editable={true}
LoggedInUser={LoggedInUser}
/>
allowPayAction={allowPayAction}
lockPayAction={lockPayAction}
unlockPayAction={unlockPayAction}
/>

{ view === 'details' &&
<CommentsWithData
Expand Down
9 changes: 7 additions & 2 deletions src/pages/expense.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ class ExpensePage extends React.Component {

constructor(props) {
super(props);
this.state = {};
this.state = {
isPayActionLocked: false,
};
}

async componentDidMount() {
Expand Down Expand Up @@ -110,7 +112,10 @@ class ExpensePage extends React.Component {
collective={collective}
view="details"
LoggedInUser={this.state.LoggedInUser}
/>
allowPayAction={!this.state.isPayActionLocked}
lockPayAction={() => this.setState({ isPayActionLocked: true })}
unlockPayAction={() => this.setState({ isPayActionLocked: false })}
/>

</div>

Expand Down

0 comments on commit 4551a9a

Please sign in to comment.