1
0

system.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import { defineStore } from 'pinia'
  2. /**
  3. * System Store
  4. */
  5. export const useSystemStore = defineStore('system', {
  6. state: () => ({
  7. /* Error messages holder. */
  8. errors: [],
  9. /* Notification messages holder. */
  10. notifications: [],
  11. /* Initialize API Endpoint (constant). */
  12. apiEndpoint: 'https://api.apecs.dev/v1',
  13. /* Initialize price quotes. */
  14. quotes: {},
  15. // TBD
  16. }),
  17. getters: {
  18. //
  19. },
  20. actions: {
  21. /**
  22. * Set Error Message
  23. */
  24. _setError (_error) {
  25. /* Update error message. */
  26. this.state.errors.push(_error)
  27. },
  28. /**
  29. * Set Notification
  30. */
  31. _setNotification (_notifications) {
  32. /* Update notification message. */
  33. this.state.notifications.push(_notification)
  34. },
  35. setError (_error) {
  36. /* Commit error message. */
  37. _setError(_error)
  38. /* Set automatic dismiss delay. */
  39. setTimeout(() => {
  40. _setError(null)
  41. }, 3000)
  42. },
  43. setNotification (_notification) {
  44. /* Commit notification message. */
  45. _setNotification(notification)
  46. /* Set automatic dismiss delay. */
  47. setTimeout(() => {
  48. _setNotification(null)
  49. }, 3000)
  50. },
  51. },
  52. })