73 lines
1.3 KiB
TypeScript
73 lines
1.3 KiB
TypeScript
import { defineStore } from 'pinia'
|
|
import { ref } from 'vue'
|
|
|
|
export interface FlowBuilderState {
|
|
flowData: any
|
|
agentId: string
|
|
isActive: boolean
|
|
}
|
|
|
|
export const useFlowBuilderStore = defineStore('flowBuilder', () => {
|
|
// State
|
|
const flowData = ref<any>({})
|
|
const agentId = ref<string>('')
|
|
const isActive = ref<boolean>(false)
|
|
|
|
// Actions
|
|
const setFlowData = (data: any) => {
|
|
flowData.value = data
|
|
}
|
|
|
|
const setAgentId = (id: string) => {
|
|
agentId.value = id
|
|
}
|
|
|
|
const activateFlowBuilder = (data: any, id: string) => {
|
|
flowData.value = data
|
|
agentId.value = id
|
|
isActive.value = true
|
|
}
|
|
|
|
const deactivateFlowBuilder = () => {
|
|
flowData.value = {}
|
|
agentId.value = ''
|
|
isActive.value = false
|
|
}
|
|
|
|
const updateFlowData = (data: any) => {
|
|
flowData.value = data
|
|
}
|
|
|
|
// Getters
|
|
const hasFlowData = () => {
|
|
return Object.keys(flowData.value).length > 0
|
|
}
|
|
|
|
const getFlowData = () => {
|
|
return flowData.value
|
|
}
|
|
|
|
const getAgentId = () => {
|
|
return agentId.value
|
|
}
|
|
|
|
return {
|
|
// State
|
|
flowData,
|
|
agentId,
|
|
isActive,
|
|
|
|
// Actions
|
|
setFlowData,
|
|
setAgentId,
|
|
activateFlowBuilder,
|
|
deactivateFlowBuilder,
|
|
updateFlowData,
|
|
|
|
// Getters
|
|
hasFlowData,
|
|
getFlowData,
|
|
getAgentId
|
|
}
|
|
})
|