first styling and store for reactive etape modale
This commit is contained in:
25
web/themes/custom/caravane/assets/js/stores/etape.js
Normal file
25
web/themes/custom/caravane/assets/js/stores/etape.js
Normal file
@@ -0,0 +1,25 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import REST from '../api/rest-axios';
|
||||
|
||||
export const useEtapeStore = defineStore('etape', {
|
||||
state: () => ({
|
||||
etapeData: null,
|
||||
loading: false,
|
||||
error: null,
|
||||
}),
|
||||
actions: {
|
||||
async fetchEtapeData(nid) {
|
||||
this.loading = true;
|
||||
this.error = null;
|
||||
try {
|
||||
const response = await REST.get(`/node/${nid}?_format=json`);
|
||||
this.etapeData = response.data;
|
||||
} catch (error) {
|
||||
this.error = 'Failed to fetch data';
|
||||
console.error('Issue with getNodeData', error);
|
||||
} finally {
|
||||
this.loading = false;
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user