fix delete account

This commit is contained in:
Emily
2024-06-06 15:08:55 +02:00
parent f8a3a5ce68
commit c15e5d966e
8 changed files with 97 additions and 52 deletions

View File

@@ -12,10 +12,7 @@ const eventsStackedSelectIndex = ref<number>(0);
const route = useRoute();
onMounted(async () => {
if (route.query.just_logged) {
return location.href = '/';
}
if (route.query.just_logged) return location.href = '/';
});

View File

@@ -28,14 +28,10 @@ async function handleOnSuccess(response: any) {
console.log('LOGIN DONE - USER', loggedUser.value);
const { refresh } = useProjectsList();
const isFirstTime = await $fetch<boolean>('/api/user/is_first_time', { headers: { 'Authorization': 'Bearer ' + token.value } })
await refresh();
if (isFirstTime === true) {
router.push('/project_creation');
router.push('/project_creation?just_logged=true');
} else {
router.push('/?just_logged=true');
}

View File

@@ -63,7 +63,8 @@ function getPremiumName(type: number) {
<div class="w-full h-full p-8 overflow-y-auto pb-40 lg:pb-0 relative overflow-x-hidden">
<Transition name="pdrawer">
<PricingDrawer @onCloseClick="showPricingDrawer = false" class="bg-black fixed right-0 top-0 w-full xl:w-[60vw] xl:min-w-[65rem] h-full z-[20]"
<PricingDrawer @onCloseClick="showPricingDrawer = false"
class="bg-black fixed right-0 top-0 w-full xl:w-[60vw] xl:min-w-[65rem] h-full z-[20]"
v-if=showPricingDrawer>
</PricingDrawer>
</Transition>
@@ -205,7 +206,6 @@ function getPremiumName(type: number) {
</CardTitled>
</div>
</template>

View File

@@ -13,11 +13,10 @@ const isFirstProject = computed(() => { return projects.value?.length == 0; })
import { Lit } from 'litlyx';
const route = useRoute();
onMounted(() => {
if (projects.value?.length == 0) {
setPageLayout('none');
}
if (route.query.just_logged) return location.href = '/project_creation';
})
@@ -43,7 +42,6 @@ async function createProject() {
await setActiveProject(newActiveProjectId);
}
router.push('/');
} catch (ex: any) {

View File

@@ -35,11 +35,25 @@ async function deleteProject(projectId: string, projectName: string) {
const router = useRouter();
const { setToken } = useAccessToken();
async function onProjectClick(pid: string) {
await setActiveProject(pid)
router.push('/')
}
async function deleteAccount() {
const sure = confirm("Are you sure you want to delete this account ?");
if (!sure) return;
await $fetch("/api/user/delete_account", {
...signHeaders(),
method: "DELETE"
})
setToken('');
location.href = "/login"
}
</script>
@@ -85,39 +99,26 @@ async function onProjectClick(pid: string) {
</div>
</div>
<!--
<div class="bg-blue-500/20 hover:bg-blue-500/30 p-4 w-[20rem] h-[6rem] flex items-center gap-4 rounded-xl cursor-pointer relative"
v-for="e of projects" @click="setActiveProject(e._id.toString())">
<div class="absolute right-2 top-2" v-if="project._id == e._id">
<i class="far fa-circle-check text-green-600"></i>
</div>
<div class="h-full aspect-[1/1]">
<div class="w-full h-full bg-blue-500 rounded-xl"></div>
</div>
<div>
<div class="text-text text-ellipsis line-clamp-1 font-semibold manrope text-[1.1rem]">
{{ e.name }}
</div>
<div class="text-text-sub font-normal lato text-[.9rem]">
{{ e.premium ? 'PREMIUM PLAN' : 'FREE PLAN' }}
</div>
</div>
</div> -->
<!-- <NuxtLink v-if="(projects?.length || 0) < 3" to="/project_creation"
class="bg-blue-500/20 hover:bg-blue-500/30 p-4 w-[20rem] h-[6rem] flex items-center gap-4 rounded-xl cursor-pointer">
<div class="h-full aspect-[1/1] flex items-center justify-center">
<i class="fas fa-plus text-[2rem] text-text-sub/80"></i>
</div>
<div>
<div class="text-text font-semibold manrope text-[1.1rem]"> Create new project</div>
<div class="text-text-sub font-normal lato text-[.9rem]"></div>
</div>
</NuxtLink> -->
</div>
</div>
<div class="px-10">
<CardTitled title="Danger zone" :sub="''" class="p-4 mt-8">
<div
class="outline rounded-lg w-fit px-8 py-4 flex flex-col gap-4 outline-[1px] outline-[#541c15] bg-[#1e1412]">
<div class="poppins font-semibold"> Deleting this account will also remove its projects </div>
<div @click="deleteAccount()"
class="text-[#e95b61] poppins font-semibold cursor-pointer hover:text-black hover:bg-red-700 outline rounded-lg w-fit px-8 py-2 outline-[1px] outline-[#532b26] bg-[#291415]">
Delete account
</div>
</div>
</CardTitled>
</div>
</div>
</template>