Browse Source

Prompt user before unsubscribing

master
Immanuel Onyeka 4 months ago
parent
commit
bb7b9fdbe0
3 changed files with 35 additions and 5 deletions
  1. +5
    -4
      components/settings.vue
  2. +29
    -0
      components/unsubscribe.vue
  3. +1
    -1
      main.css

+ 5
- 4
components/settings.vue View File

@@ -54,7 +54,7 @@
<section class="form inputs special"> <section class="form inputs special">
<h3>Subscriptions</h3> <h3>Subscriptions</h3>
<label for="">Standard Plan ($49/month)</label> <label for="">Standard Plan ($49/month)</label>
<button @click="unsubscribe">Unsubscribe</button>
<button @click="() => unsubing = true">Unsubscribe</button>
<label for="">Newsletter</label> <label for="">Newsletter</label>
<button @click="changeNewsSub"> <button @click="changeNewsSub">
{{props.user.newsletter ? "Unsubscribe" : "Subscribe"}} {{props.user.newsletter ? "Unsubscribe" : "Subscribe"}}
@@ -81,6 +81,8 @@
<button>Confirm</button> <button>Confirm</button>
</Dialog> </Dialog>


<UnsubPrompt v-if="unsubing" :token="token" @close="() => unsubing = false"/>

</div> </div>
</template> </template>


@@ -88,10 +90,12 @@
import { ref, watch, onMounted } from "vue" import { ref, watch, onMounted } from "vue"
import Dialog from "./dialog.vue" import Dialog from "./dialog.vue"
import Dropdown from "./dropdown.vue" import Dropdown from "./dropdown.vue"
import UnsubPrompt from "./unsubscribe.vue"


let avatar = ref(null) // the canvas element let avatar = ref(null) // the canvas element
let letterhead = ref(null) // the canvas element let letterhead = ref(null) // the canvas element
let ready = ref(false) let ready = ref(false)
let unsubing = ref(false)
let avatarChanged = ref(false) let avatarChanged = ref(false)
let avatarError = ref('') let avatarError = ref('')
let letterheadError = ref('') let letterheadError = ref('')
@@ -278,9 +282,6 @@ function getLocations(e) {
}) })
} }


function unsubscribe() {
}

function changeNewsSub() { function changeNewsSub() {
fetch(`/api/user/newsletter`, fetch(`/api/user/newsletter`,
{method: 'GET', {method: 'GET',


+ 29
- 0
components/unsubscribe.vue View File

@@ -0,0 +1,29 @@
<template>

<Dialog @close="() => $emit('close')">
<h3>Are you sure you want to unsubscribe?</h3>
<button @click="() => $emit('close')">Cancel</button>
<button @click="unsubscribe">Confirm</button>
</Dialog>

</template>

<script setup>
import Dialog from "./dialog.vue"

const emit = defineEmits(['close'])
const props = defineProps(['token'])

function unsubscribe() {
console.log(props.user)
fetch(`/api/user/unsubscribe`,
{method: 'GET',
headers: {
"Accept": "application/json",
"Authorization": `Bearer ${props.token}`,
},
}).then(resp => {
if (resp.ok) emit('updateUser')
})
}
</script>

+ 1
- 1
main.css View File

@@ -359,7 +359,7 @@ div.modal-prompt .form {
margin: auto auto; margin: auto auto;
margin-top: 10%; margin-top: 10%;
width: 100%; width: 100%;
max-width: 90%;
max-width: 400px;
padding: 20px 10px; padding: 20px 10px;
background: white; background: white;
box-shadow: rgba(100, 100, 111, 0.2) 0px 7px 29px 0px; box-shadow: rgba(100, 100, 111, 0.2) 0px 7px 29px 0px;


Loading…
Cancel
Save