Skip to content

Commit

Permalink
feat: add feedback when canceling
Browse files Browse the repository at this point in the history
  • Loading branch information
castrolem committed Oct 15, 2019
1 parent 7326544 commit 8c17bc2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
13 changes: 10 additions & 3 deletions app/javascript/bundles/User/components/SubscriptionCancel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const SUBSCRIPTION_CANCEL_URL = userID => `/users/${userID}/subscription`

function SubscriptionCancelView ({ user, subscription }) {
const [open, setOpen] = useState(false)
const [active, toggleActive] = useState(subscription.active)

const handleClickOpen = () => {
setOpen(true)
Expand All @@ -20,9 +21,14 @@ function SubscriptionCancelView ({ user, subscription }) {
}

const handleSubscriptionCancellation = async () => {
await fetch(SUBSCRIPTION_CANCEL_URL(user.id), {
method: 'delete'
})
const isSubscriptionCancelled = await fetch(
SUBSCRIPTION_CANCEL_URL(user.id),
{
method: 'delete'
}
)

toggleActive(!subscription.active)

handleClose()
}
Expand All @@ -36,6 +42,7 @@ function SubscriptionCancelView ({ user, subscription }) {
<Button color='secondary' onClick={handleClickOpen}>
Cancel Subscription
</Button>
{!active && 'No active subscription'}
<Dialog
open={open}
onClose={handleClose}
Expand Down
2 changes: 1 addition & 1 deletion spec/features/user/users_profile_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
click_button 'Cancel Subscription'
end

sleep 2
expect(page).to have_content('No active subscription')
subscription.reload
expect(subscription.active).to eq(false)
end
Expand Down

0 comments on commit 8c17bc2

Please sign in to comment.