fix: wire up maintenance flow creation, editing, and navigation in frontend
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -64,6 +64,7 @@ function createDefaultField(index: number, existingFields: IntakeFormField[]): I
|
||||
interface ProceduralEditorState {
|
||||
// Tree metadata
|
||||
treeId: string | null
|
||||
treeType: TreeType
|
||||
name: string
|
||||
description: string
|
||||
categoryId: string | null
|
||||
@@ -83,11 +84,12 @@ interface ProceduralEditorState {
|
||||
isSaving: boolean
|
||||
|
||||
// Actions - Init
|
||||
initNew: () => void
|
||||
initNew: (type?: TreeType) => void
|
||||
loadTree: (tree: Tree) => void
|
||||
reset: () => void
|
||||
|
||||
// Actions - Metadata
|
||||
setTreeType: (treeType: TreeType) => void
|
||||
setName: (name: string) => void
|
||||
setDescription: (description: string) => void
|
||||
setCategoryId: (categoryId: string | null) => void
|
||||
@@ -131,6 +133,7 @@ export const useProceduralEditorStore = create<ProceduralEditorState>()(
|
||||
immer((set, get) => ({
|
||||
// Initial state
|
||||
treeId: null,
|
||||
treeType: 'procedural' as TreeType,
|
||||
name: '',
|
||||
description: '',
|
||||
categoryId: null,
|
||||
@@ -146,9 +149,10 @@ export const useProceduralEditorStore = create<ProceduralEditorState>()(
|
||||
isSaving: false,
|
||||
|
||||
// Init
|
||||
initNew: () => {
|
||||
initNew: (type?: TreeType) => {
|
||||
set((state) => {
|
||||
state.treeId = null
|
||||
state.treeType = type || 'procedural'
|
||||
state.name = ''
|
||||
state.description = ''
|
||||
state.categoryId = null
|
||||
@@ -169,6 +173,7 @@ export const useProceduralEditorStore = create<ProceduralEditorState>()(
|
||||
const structure = tree.tree_structure as unknown as ProceduralTreeStructure
|
||||
set((state) => {
|
||||
state.treeId = tree.id
|
||||
state.treeType = tree.tree_type
|
||||
state.name = tree.name
|
||||
state.description = tree.description || ''
|
||||
state.categoryId = tree.category_id
|
||||
@@ -188,6 +193,7 @@ export const useProceduralEditorStore = create<ProceduralEditorState>()(
|
||||
reset: () => {
|
||||
set((state) => {
|
||||
state.treeId = null
|
||||
state.treeType = 'procedural'
|
||||
state.name = ''
|
||||
state.description = ''
|
||||
state.categoryId = null
|
||||
@@ -205,6 +211,7 @@ export const useProceduralEditorStore = create<ProceduralEditorState>()(
|
||||
},
|
||||
|
||||
// Metadata
|
||||
setTreeType: (treeType) => set((state) => { state.treeType = treeType }),
|
||||
setName: (name) => set((state) => { state.name = name; state.isDirty = true }),
|
||||
setDescription: (description) => set((state) => { state.description = description; state.isDirty = true }),
|
||||
setCategoryId: (categoryId) => set((state) => { state.categoryId = categoryId; state.isDirty = true }),
|
||||
@@ -343,7 +350,7 @@ export const useProceduralEditorStore = create<ProceduralEditorState>()(
|
||||
return {
|
||||
name: state.name,
|
||||
description: state.description,
|
||||
tree_type: 'procedural' as TreeType,
|
||||
tree_type: state.treeType,
|
||||
tree_structure: { steps: state.steps },
|
||||
intake_form: state.intakeForm.length > 0 ? state.intakeForm : undefined,
|
||||
category_id: state.categoryId,
|
||||
|
||||
Reference in New Issue
Block a user