From 18f35755238e33ebf0fb6985bbd81afa296edff7 Mon Sep 17 00:00:00 2001 From: "iamgabrielsoft@gmail.com" Date: Thu, 15 Aug 2024 17:19:38 +0100 Subject: [PATCH] removed unecessaru styles --- .../src/vue/components/alert/core/useAlert.ts | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/codex-ui/src/vue/components/alert/core/useAlert.ts b/codex-ui/src/vue/components/alert/core/useAlert.ts index 5f7d91de..42089289 100644 --- a/codex-ui/src/vue/components/alert/core/useAlert.ts +++ b/codex-ui/src/vue/components/alert/core/useAlert.ts @@ -1,8 +1,10 @@ import { ref } from 'vue'; import type { AlertInterface, AlertOptions, AlertType } from './types'; -import { createSharedComposable, useStepper } from '@vueuse/core'; -import { getId } from './constant'; +import { createSharedComposable } from '@vueuse/core'; +/** + * Store alert state + */ const useStore = createSharedComposable(() => { const alertStore = ref([]); @@ -11,9 +13,8 @@ const useStore = createSharedComposable(() => { * @param type - type of alert (success, error, warning, info and default) * @param opt - alert options */ - function createAlertHandler(type: AlertType, opt?: Pick): void { - opt!.id = getId(); - const alert = alertStore.value.findIndex((idx: AlertOptions) => idx.id === opt.id); + function createAlertHandler(type: AlertType, opt?: Pick): void { + const alert = alertStore.value.findIndex((idx: AlertOptions) => idx.timeout === opt?.timeout); alertStore.value.push({ type, ...opt }); @@ -23,23 +24,23 @@ const useStore = createSharedComposable(() => { }, opt?.timeout); } - function success(opt: Pick): void { + function success(opt?: Pick): void { createAlertHandler('success', opt); } - function error(opt: Pick): void { + function error(opt?: Pick): void { createAlertHandler('error', opt); } - function warning(opt: Pick): void { + function warning(opt?: Pick): void { createAlertHandler('warning', opt); } - function info(opt: Pick): void { + function info(opt?: Pick): void { createAlertHandler('info', opt); } - function defaultAlert(opt: Pick): void { + function defaultAlert(opt?: Pick): void { createAlertHandler('default', opt); } @@ -55,11 +56,11 @@ const useStore = createSharedComposable(() => { /** * Alert service - * @param type - + * @param type - alert type (success, error, warning, info and default) * @param options - alert options */ -export const useAlert = (type?: AlertType, opt?: Pick) => { +export const useAlert = (type?: AlertType, opt?: Pick): AlertInterface => { const alertRef = ref(); const { alertStore, @@ -92,6 +93,7 @@ export const useAlert = (type?: AlertType, opt?: Pick