From d726aa8d33da60b25447c686f48ac89f21f2cfa0 Mon Sep 17 00:00:00 2001 From: ntr Date: Wed, 28 Aug 2019 18:57:23 +1000 Subject: [PATCH] stripe sub cancellations --- WORKLOG.md | 11 +-- client/assets/styles/account.less | 12 +++ client/assets/styles/styles.less | 4 + client/src/app.jsx | 2 +- client/src/components/account.management.jsx | 84 ++++++++++++++------ client/src/components/stripe.buttons.jsx | 2 +- client/src/events.jsx | 7 ++ client/src/socket.jsx | 11 +++ etc/mnml/{gs.SAMPLE.conf => gs.conf} | 2 + server/Cargo.toml | 3 +- server/src/main.rs | 4 +- server/src/payments.rs | 50 +++++++++++- server/src/rpc.rs | 20 ++++- 13 files changed, 173 insertions(+), 39 deletions(-) rename etc/mnml/{gs.SAMPLE.conf => gs.conf} (83%) diff --git a/WORKLOG.md b/WORKLOG.md index bb9934a4..7860dae3 100644 --- a/WORKLOG.md +++ b/WORKLOG.md @@ -3,8 +3,7 @@ *PRODUCTION* * ACP * essential - * error log - * account lookup w/ pw reset + * stripe verify * treats * constructs jiggle when clicked @@ -13,12 +12,9 @@ * bot game grind * serde serialize privatise -* stripe prod * mobile styles * change score to enum * pct based translates for combat animation -* account page -* graphs n shit * acp init * DO postgres * make our own toasts / msg pane @@ -28,6 +24,8 @@ * clear skill (if currently targetted) * increase power to speed up early rounds +* only login / logout / register http + ## SOON *SERVER* * modules @@ -38,12 +36,15 @@ * empower on ko * rework vecs into sets +* remove names so games/instances are copy *$$$* * chatwheel * eth adapter * illusions * vaporwave +* crop circles +* insects * sacred geometry * skulls / day of the dead * Aztec diff --git a/client/assets/styles/account.less b/client/assets/styles/account.less index a73faaae..cd4730ca 100644 --- a/client/assets/styles/account.less +++ b/client/assets/styles/account.less @@ -20,6 +20,18 @@ display: block; } + .unsub { + &:hover { + color: @red; + border-color: @red; + }; + + &:active, &.confirming { + background: @red; + color: black; + border: 1px solid black; + } + } .list { letter-spacing: 0.25em; diff --git a/client/assets/styles/styles.less b/client/assets/styles/styles.less index f234fcd0..30b6d8e1 100644 --- a/client/assets/styles/styles.less +++ b/client/assets/styles/styles.less @@ -78,6 +78,10 @@ p { margin-bottom: 1em; } +dl { + margin: 1em 0; +} + #mnml { display: grid; grid-template-columns: minmax(min-content, 1fr) 8fr 1fr; diff --git a/client/src/app.jsx b/client/src/app.jsx index 2e64724f..ddd7a1ea 100644 --- a/client/src/app.jsx +++ b/client/src/app.jsx @@ -30,7 +30,7 @@ document.fonts.load('16pt "Jura"').then(() => { const App = () => ( - + diff --git a/client/src/components/account.management.jsx b/client/src/components/account.management.jsx index 05a8b04b..d20c52a1 100644 --- a/client/src/components/account.management.jsx +++ b/client/src/components/account.management.jsx @@ -18,7 +18,7 @@ const addState = connect( } = state; - function setPassword(current, password) { + function sendSetPassword(current, password) { postData('/account/password', { current, password }) .then(res => res.json()) .then(data => { @@ -29,7 +29,7 @@ const addState = connect( .catch(error => errorToast(error)); } - function setEmail(email) { + function sendSetEmail(email) { postData('/account/email', { email }) .then(res => res.json()) .then(data => { @@ -49,14 +49,19 @@ const addState = connect( return ws.sendMtxConstructSpawn(name); } + function sendSubscriptionCancel() { + return ws.sendSubscriptionCancel(); + } + return { account, ping, email, logout, - setPassword, - setEmail, + sendSetPassword, + sendSetEmail, sendConstructSpawn, + sendSubscriptionCancel, }; }, ); @@ -67,42 +72,73 @@ class AccountStatus extends Component { super(props); this.state = { - setPassword: { current: '', password: '', confirm: ''}, - email: null, + passwordState: { current: '', password: '', confirm: ''}, + emailState: null, + unsubState: false, }; } - render(args) { + render(args, state) { const { account, ping, email, logout, - setPassword, - setEmail, + sendSetEmail, + sendSetPassword, sendConstructSpawn, + sendSubscriptionCancel, } = args; + const { + passwordState, + emailState, + unsubState, + } = state; + if (!account) return null; const passwordsEqual = () => - this.state.setPassword.password === this.state.setPassword.confirm; + passwordState.password === passwordState.confirm; const setPasswordDisabled = () => { - const { current, password, confirm } = this.state.setPassword; + const { current, password, confirm } = passwordState; return !(passwordsEqual() && password && current && confirm); } + const unsub = e => { + if (unsubState) { + return sendSubscriptionCancel(); + } + + e.stopPropagation(); + return this.setState({ unsubState: true }); + } + + const unsubBtn = () => { + if (!account.subscribed) return false; + + const classes = `unsub ${unsubState ? 'confirming' : ''}`; + const text = unsubState ? 'Confirm' : 'Unsubscribe' + return + } + + const tlClick = e => { + e.stopPropagation(); + return this.setState({ unsubState: false }); + } + return ( -
+