page.ts 652 B

123456789101112131415161718192021222324252627282930
  1. import {Alert, pageState} from '~/types/interfaces'
  2. import {defineStore} from "pinia";
  3. import {FORM_FUNCTION, TYPE_ALERT} from "~/types/enums";
  4. export const usePageStore = defineStore('page', {
  5. state: (): pageState => {
  6. return {
  7. alerts: []
  8. }
  9. },
  10. actions: {
  11. removeSlowlyAlert () {
  12. setTimeout(() => {
  13. this.alerts.shift()
  14. }, 300)
  15. },
  16. /**
  17. * Ajout des alerts dans le store
  18. * @param type
  19. * @param alerts
  20. */
  21. addAlerts(type: TYPE_ALERT, alerts: Array<string>){
  22. const alert:Alert = {
  23. type: type,
  24. messages: alerts
  25. }
  26. this.alerts.push(alert)
  27. }
  28. }
  29. })