Create preview fix + extras (#382)
This commit is contained in:
parent
aff973182d
commit
94b8837bdc
|
@ -291,6 +291,7 @@ class CreateFlow extends React.Component<Props, State> {
|
||||||
|
|
||||||
private handlePop: History.LocationListener = (location, action) => {
|
private handlePop: History.LocationListener = (location, action) => {
|
||||||
if (action === 'POP') {
|
if (action === 'POP') {
|
||||||
|
this.setState({ isPreviewing: false });
|
||||||
const searchValues = qs.parse(location.search);
|
const searchValues = qs.parse(location.search);
|
||||||
const urlStep = searchValues.step && searchValues.step.toUpperCase();
|
const urlStep = searchValues.step && searchValues.step.toUpperCase();
|
||||||
if (urlStep && CREATE_STEP[urlStep]) {
|
if (urlStep && CREATE_STEP[urlStep]) {
|
||||||
|
|
|
@ -208,7 +208,9 @@ class ProposalMilestones extends React.Component<Props, State> {
|
||||||
|
|
||||||
const stepSize = milestoneCount > 5 ? 'small' : 'default';
|
const stepSize = milestoneCount > 5 ? 'small' : 'default';
|
||||||
const activeMilestone = proposal.milestones[this.state.step];
|
const activeMilestone = proposal.milestones[this.state.step];
|
||||||
const activeIsCurrent = activeMilestone.id === proposal.currentMilestone!.id;
|
const activeIsCurrent = proposal.currentMilestone
|
||||||
|
? activeMilestone.id === proposal.currentMilestone!.id
|
||||||
|
: false;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
|
|
@ -1,10 +1,4 @@
|
||||||
import {
|
import { ProposalDraft, STATUS, MILESTONE_STAGE, PROPOSAL_ARBITER_STATUS } from 'types';
|
||||||
ProposalDraft,
|
|
||||||
CreateMilestone,
|
|
||||||
STATUS,
|
|
||||||
MILESTONE_STAGE,
|
|
||||||
PROPOSAL_ARBITER_STATUS,
|
|
||||||
} from 'types';
|
|
||||||
import { User } from 'types';
|
import { User } from 'types';
|
||||||
import {
|
import {
|
||||||
getAmountError,
|
getAmountError,
|
||||||
|
@ -13,7 +7,6 @@ import {
|
||||||
isValidSproutAddress,
|
isValidSproutAddress,
|
||||||
} from 'utils/validators';
|
} from 'utils/validators';
|
||||||
import { Zat, toZat } from 'utils/units';
|
import { Zat, toZat } from 'utils/units';
|
||||||
import { ONE_DAY } from 'utils/time';
|
|
||||||
import { PROPOSAL_CATEGORY, PROPOSAL_STAGE } from 'api/constants';
|
import { PROPOSAL_CATEGORY, PROPOSAL_STAGE } from 'api/constants';
|
||||||
import {
|
import {
|
||||||
ProposalDetail,
|
ProposalDetail,
|
||||||
|
@ -183,28 +176,6 @@ export function getCreateWarnings(form: Partial<ProposalDraft>): string[] {
|
||||||
return warnings;
|
return warnings;
|
||||||
}
|
}
|
||||||
|
|
||||||
function milestoneToMilestoneAmount(milestone: CreateMilestone, raiseGoal: Zat) {
|
|
||||||
return raiseGoal.divn(100).mul(Zat(milestone.payoutPercent));
|
|
||||||
}
|
|
||||||
|
|
||||||
export function proposalToContractData(form: ProposalDraft): any {
|
|
||||||
const targetInZat = toZat(form.target);
|
|
||||||
const milestoneAmounts = form.milestones.map(m =>
|
|
||||||
milestoneToMilestoneAmount(m, targetInZat),
|
|
||||||
);
|
|
||||||
const immediateFirstMilestonePayout = form.milestones[0]!.immediatePayout;
|
|
||||||
|
|
||||||
return {
|
|
||||||
ethAmount: targetInZat,
|
|
||||||
payoutAddress: form.payoutAddress,
|
|
||||||
trusteesAddresses: [],
|
|
||||||
milestoneAmounts,
|
|
||||||
durationInMinutes: form.deadlineDuration || ONE_DAY * 60,
|
|
||||||
milestoneVotingPeriodInMinutes: ONE_DAY * 7,
|
|
||||||
immediateFirstMilestonePayout,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// This is kind of a disgusting function, sorry.
|
// This is kind of a disgusting function, sorry.
|
||||||
export function makeProposalPreviewFromDraft(draft: ProposalDraft): ProposalDetail {
|
export function makeProposalPreviewFromDraft(draft: ProposalDraft): ProposalDetail {
|
||||||
const { invites, ...rest } = draft;
|
const { invites, ...rest } = draft;
|
||||||
|
|
Loading…
Reference in New Issue