Skip to content

Commit

Permalink
update closing alerts
Browse files Browse the repository at this point in the history
  • Loading branch information
Sun-Mountain committed Jun 14, 2023
1 parent cff807c commit 722a26d
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 21 deletions.
4 changes: 0 additions & 4 deletions frontend/src/components/auth/LoginForm.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
<template>
<v-container>
<v-container>
<Alert />
</v-container>
<v-card
class="form-container"
title="Login"
Expand Down Expand Up @@ -40,7 +37,6 @@
import { Form, Field } from 'vee-validate';
import * as Yup from 'yup';
import { Alert } from '@/components';
import { useAuthStore } from '@/store';
import { getSubmitFn } from '@/helpers';
import { Login } from "@/models/user.model";
Expand Down
4 changes: 0 additions & 4 deletions frontend/src/components/auth/UserForm.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
<template>
<v-container>
<v-container>
<Alert />
</v-container>
<v-card
class="form-container"
:title="formTitle"
Expand Down Expand Up @@ -94,7 +91,6 @@ import { PropType, toRefs } from 'vue';
import { Form, Field } from 'vee-validate';
import * as Yup from 'yup';
import { Alert } from '@/components';
import { getSubmitFn } from '@/helpers';
import { User } from "@/models/user.model";
import { useAuthStore, useUsersStore } from "@/store"
Expand Down
16 changes: 14 additions & 2 deletions frontend/src/components/shared/AlertItem.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<template>
<template v-slot:close="{toggle}">
<v-alert
v-if="alert"
border="start"
Expand All @@ -9,7 +9,15 @@
:text="alert?.message"
:type="alert?.type"
:icon="alert?.icon"
/>
>
<!-- Close slot for custom close behavior -->
<template v-slot:close="{toggle}">
<v-btn @click="closeAlert(toggle)">
<v-icon size="22px" icon="mdi:mdiClose" />
</v-btn>
</template>
<!-- -->
</v-alert>
</template>

<script lang="ts" setup>
Expand All @@ -18,4 +26,8 @@ import { useAlertStore } from "@/store";
const alertStore = useAlertStore();
const { alert } = storeToRefs(alertStore);
const closeAlert = (toggle) => {
alertStore.clear();
}
</script>
21 changes: 13 additions & 8 deletions frontend/src/layouts/Event.vue
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
<template>
<v-container class="layout-with-subnav main-content-container">
<EventSubNav />
<div class="sub-content-container">
<EventHeader />
<v-container>
<router-view />
</v-container>
<v-container>
<v-container>
<Alert />
</v-container>
<div class="layout-with-subnav main-content-container">
<EventSubNav />
<div class="sub-content-container">
<EventHeader />
<v-container>
<router-view />
</v-container>
</div>
</div>
</v-container>
</template>

<script lang="ts" setup>
import { EventHeader, EventSubNav } from '@/components';
import { Alert, EventHeader, EventSubNav } from '@/components';
</script>
5 changes: 4 additions & 1 deletion frontend/src/layouts/View.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
<template>
<v-container>
<v-container>
<Alert />
</v-container>
<router-view />
</v-container>
</template>

<script lang="ts" setup>
//
import { Alert } from '@/components';
</script>
8 changes: 6 additions & 2 deletions frontend/src/store/users.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const useUsersStore = defineStore({
}
},
async updateAccount(user: User, userId: number) {
const alertStore = useAlertStore();
const authStore = useAuthStore();
const updates = { user };
const currentUser = authStore.currentUser;
Expand All @@ -35,13 +36,15 @@ export const useUsersStore = defineStore({
if (currentUser.id === userId) {
const response = await fetchWrapper.put(`${BASE_URL}signup`, updates);
authStore.updateCurrentUser(response.data);
alertStore.success("Your account was successfully updated.")
router.push("/account");
}
} catch (err) {
console.log(err);
alertStore.error(err);
}
},
async deleteAccount(value: string) {
const alertStore = useAlertStore();
const authStore = useAuthStore();
const currentUser = authStore.currentUser;

Expand All @@ -53,8 +56,9 @@ export const useUsersStore = defineStore({
});
authStore.logout();
router.push("/login")
alertStore.success("Your account was successfully deleted.")
} catch (err) {
console.log(err);
alertStore.error(err);
}
}
}
Expand Down

0 comments on commit 722a26d

Please sign in to comment.