2018-09-25 12:41:47 -07:00
|
|
|
|
import React from 'react';
|
|
|
|
|
import { connect } from 'react-redux';
|
|
|
|
|
import { Modal, Alert } from 'antd';
|
2018-12-28 15:05:34 -08:00
|
|
|
|
import { Proposal } from 'types';
|
2018-09-25 12:41:47 -07:00
|
|
|
|
import { AppState } from 'store/reducers';
|
|
|
|
|
|
|
|
|
|
interface OwnProps {
|
2018-12-28 15:05:34 -08:00
|
|
|
|
proposal: Proposal;
|
2018-09-25 12:41:47 -07:00
|
|
|
|
isVisible: boolean;
|
|
|
|
|
handleClose(): void;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface StateProps {
|
2018-12-14 11:36:22 -08:00
|
|
|
|
isRefundActionPending: boolean;
|
|
|
|
|
refundActionError: string;
|
2018-09-25 12:41:47 -07:00
|
|
|
|
}
|
|
|
|
|
|
2018-12-14 11:36:22 -08:00
|
|
|
|
type Props = StateProps & OwnProps;
|
2018-09-25 12:41:47 -07:00
|
|
|
|
|
|
|
|
|
class CancelModal extends React.Component<Props> {
|
|
|
|
|
componentDidUpdate() {
|
2018-12-28 15:05:34 -08:00
|
|
|
|
// TODO: Close on success of action
|
2018-09-25 12:41:47 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
render() {
|
2018-12-28 15:05:34 -08:00
|
|
|
|
const { isVisible, isRefundActionPending, refundActionError } = this.props;
|
|
|
|
|
const hasContributors = false; // TODO: Determine if it has contributors from proposal
|
2018-09-25 12:41:47 -07:00
|
|
|
|
const disabled = isRefundActionPending;
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Modal
|
|
|
|
|
title={<>Cancel proposal</>}
|
|
|
|
|
visible={isVisible}
|
|
|
|
|
okText="Confirm"
|
|
|
|
|
cancelText="Never mind"
|
|
|
|
|
onOk={this.cancelProposal}
|
|
|
|
|
onCancel={this.closeModal}
|
|
|
|
|
okButtonProps={{ type: 'danger', loading: disabled }}
|
|
|
|
|
cancelButtonProps={{ disabled }}
|
|
|
|
|
>
|
2018-12-28 15:05:34 -08:00
|
|
|
|
<p>
|
|
|
|
|
Are you sure you would like to cancel this proposal?{' '}
|
|
|
|
|
<strong>This cannot be undone</strong>.
|
|
|
|
|
</p>
|
2018-09-25 12:41:47 -07:00
|
|
|
|
<p>
|
|
|
|
|
Canceled proposals cannot be deleted and will still be viewable by contributors
|
|
|
|
|
or anyone with a direct link. However, they will be de-listed everywhere else on
|
2019-01-22 10:40:20 -08:00
|
|
|
|
ZF Grants.
|
2018-09-25 12:41:47 -07:00
|
|
|
|
</p>
|
|
|
|
|
{hasContributors && (
|
|
|
|
|
<p>
|
|
|
|
|
Should you choose to cancel, we highly recommend posting an update to let your
|
|
|
|
|
contributors know why you’ve decided to do so.
|
|
|
|
|
</p>
|
|
|
|
|
)}
|
|
|
|
|
{refundActionError && (
|
|
|
|
|
<Alert
|
|
|
|
|
type="error"
|
2018-12-28 15:05:34 -08:00
|
|
|
|
message="Failed to cancel proposal"
|
2018-09-25 12:41:47 -07:00
|
|
|
|
description={refundActionError}
|
|
|
|
|
showIcon
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
</Modal>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private closeModal = () => {
|
|
|
|
|
if (!this.props.isRefundActionPending) {
|
|
|
|
|
this.props.handleClose();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
private cancelProposal = () => {
|
2018-12-14 11:36:22 -08:00
|
|
|
|
console.warn('TODO - implement cancelProposal');
|
2018-09-25 12:41:47 -07:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2018-12-14 11:36:22 -08:00
|
|
|
|
export default connect<StateProps, {}, OwnProps, AppState>(state => {
|
|
|
|
|
console.warn('TODO - redux isRefundActionPending/refundActionError?', state);
|
|
|
|
|
return {
|
|
|
|
|
isRefundActionPending: false,
|
|
|
|
|
refundActionError: '',
|
|
|
|
|
};
|
|
|
|
|
})(CancelModal);
|