Skip to content
This repository has been archived by the owner on Jun 10, 2024. It is now read-only.

Commit

Permalink
feat/35: componente notificador (#47)
Browse files Browse the repository at this point in the history
Signed-off-by: GitHub <[email protected]>
Co-authored-by: Fernando Fernández <[email protected]>
  • Loading branch information
paupenfer1 and ferferga committed Mar 9, 2024
1 parent f3a75b8 commit 51a0658
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 4 deletions.
8 changes: 7 additions & 1 deletion locales/en.json
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
{}
{
"¡Notificación Exitosa!" : "Success Notification!",
"¡Notificación de Errónea!" : "Error Notification!",
"¡Notificación de Advertencia!" : "Warning Notification!",
"¡Notificación de Información!" : "Info Notification!",
"Notificación" : "Notification"
}
8 changes: 7 additions & 1 deletion locales/es.json
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
{}
{
"¡Notificación Exitosa!" : "¡Notificación Exitosa!",
"¡Notificación de Errónea!" : "¡Notificación de Errónea!",
"¡Notificación de Advertencia!" : "¡Notificación de Advertencia!",
"¡Notificación de Información!" : "¡Notificación de Información!",
"Notificación" : "Notificación"
}
20 changes: 19 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
"radix-vue": "1.5.0",
"vue": "3.4.21",
"vue-i18n": "9.10.1",
"vue-router": "4.3.0"
"vue-router": "4.3.0",
"vue3-toastify": "0.2.1"
},
"devDependencies": {
"@iconify/json": "2.2.188",
Expand Down
43 changes: 43 additions & 0 deletions src/composables/use-toast.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { toast } from 'vue3-toastify';
import { i18n } from '@/plugins/i18n';

type NotificationTypes = 'warning' | 'success' | 'error' | 'info';

/**
* Muestra una notificación en la aplicación
*/
export function useToast(message?: string, type?: NotificationTypes): void {
const { t } = i18n;

switch (type) {
case 'success': {
toast.success(message ?? t('¡Notificación Exitosa!') , {
position: toast.POSITION.TOP_CENTER
});
break;
}
case 'error': {
toast.error(message ?? t('¡Notificación de Errónea!'), {
position: toast.POSITION.TOP_LEFT
});
break;
}
case 'warning': {
toast.warn(message ?? t('¡Notificación de Advertencia!'), {
position: toast.POSITION.BOTTOM_LEFT
});
break;
}
case 'info': {
toast.info(message ?? t('¡Notificación de Información!'), {
position: toast.POSITION.BOTTOM_CENTER
});
break;
}
default: {
toast(message ?? t('Notificación'), {
position: toast.POSITION.BOTTOM_RIGHT
});
}
}
}
1 change: 1 addition & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { hideDirective } from '@/plugins/directives';
import { vuePlugin as i18n } from '@/plugins/i18n';
import { router } from '@/plugins/router';


/**
* - ESTILOS GLOBALES -
*/
Expand Down

0 comments on commit 51a0658

Please sign in to comment.