Skip to content

Commit 6761962

Browse files
committed
chore: move alert initialization inside functions to improve encapsulation
1 parent 6ede2ec commit 6761962

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

adminforth/spa/src/composables/useFrontendApi.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
import { useAdminforth } from '@/adminforth';
22

3-
const { alert } = useAdminforth();
43

54
export function showSuccesTost(message: string) {
5+
const { alert } = useAdminforth();
66
alert({ message, variant: 'success' });
77
return message;
88
}
99

1010
export function showWarningTost(message: string) {
11+
const { alert } = useAdminforth();
1112
alert({ message, variant: 'warning' });
1213
return message;
1314
}
1415

1516
export function showErrorTost(message: string, timeout?: number) {
17+
const { alert } = useAdminforth();
1618
alert({ message, variant: 'danger', timeout: timeout || 30});
1719
return message;
1820
}

adminforth/spa/src/stores/core.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@ import { useAdminforth } from '@/adminforth';
77
import type { AdminForthResourceCommon, AdminForthResourceColumnCommon, GetBaseConfigResponse, ResourceVeryShort, AdminUser, UserData, AdminForthConfigMenuItem, AdminForthConfigForFrontend } from '@/types/Common';
88
import type { Ref } from 'vue'
99

10-
const { alert } = useAdminforth();
11-
1210
export const useCoreStore = defineStore('core', () => {
11+
const { alert } = useAdminforth();
1312
const resourceById: Ref<Record<string, ResourceVeryShort>> = ref({});
1413
const theme: Ref<'light'| 'dark'> = ref(window.localStorage.getItem('af__theme') as ('light'|'dark') || 'light');
1514

adminforth/spa/src/views/ListView.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ import {
225225
} from '@iconify-prerendered/vue-flowbite';
226226
227227
import Filters from '@/components/Filters.vue';
228-
import adminforth, { useAdminforth } from '@/adminforth';
228+
import { useAdminforth } from '@/adminforth';
229229
230230
const filtersShow = ref(false);
231231
const { confirm, alert, list } = useAdminforth();

0 commit comments

Comments
 (0)