feat: Script Generator Phase 1 — backend models, engine, API, and AD templates #105
@@ -65,6 +65,7 @@ export const useScriptGeneratorStore = create<ScriptGeneratorState>()((set, get)
|
||||
|
||||
loadTemplates: async () => {
|
||||
set({ isLoadingTemplates: true })
|
||||
try {
|
||||
const { activeCategoryId, categories, searchQuery } = get()
|
||||
const category = categories.find(c => c.id === activeCategoryId)
|
||||
const params: { category_slug?: string; search?: string } = {}
|
||||
@@ -72,10 +73,14 @@ export const useScriptGeneratorStore = create<ScriptGeneratorState>()((set, get)
|
||||
if (searchQuery) params.search = searchQuery
|
||||
const templates = await scriptsApi.getTemplates(params)
|
||||
set({ templates, isLoadingTemplates: false })
|
||||
} catch {
|
||||
set({ isLoadingTemplates: false })
|
||||
}
|
||||
},
|
||||
|
||||
selectTemplate: async (id: string) => {
|
||||
set({ isLoadingDetail: true })
|
||||
try {
|
||||
const detail = await scriptsApi.getTemplateDetail(id)
|
||||
// Populate paramValues from parameter defaults
|
||||
const schema = detail.parameters_schema as ScriptParametersSchema
|
||||
@@ -97,6 +102,9 @@ export const useScriptGeneratorStore = create<ScriptGeneratorState>()((set, get)
|
||||
generateError: null,
|
||||
isLoadingDetail: false,
|
||||
})
|
||||
} catch {
|
||||
set({ isLoadingDetail: false })
|
||||
}
|
||||
},
|
||||
|
||||
setCategory: (id: string | null) => {
|
||||
|
||||
Reference in New Issue
Block a user