page.ts 695 B

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