fix: correct API method calls in AdminTrainingProfiles (#15)
Fixed "U.get is not a function" error: - Added missing API methods to api.js: - getProfileStats() - getProfileTemplates() - applyProfileTemplate() - getTrainingParameters() - batchEvaluateActivities() - Updated AdminTrainingProfiles.jsx to use correct methods - Replaced api.get/post/put with specific named methods Error resolved. Page should now load correctly. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
1d252b5299
commit
2abaac22cf
|
|
@ -21,9 +21,9 @@ export default function AdminTrainingProfiles() {
|
||||||
try {
|
try {
|
||||||
setLoading(true)
|
setLoading(true)
|
||||||
const [typesData, statsData, templatesData] = await Promise.all([
|
const [typesData, statsData, templatesData] = await Promise.all([
|
||||||
api.get('/admin/training-types'),
|
api.adminListTrainingTypes(),
|
||||||
api.get('/admin/training-types/profiles/stats'),
|
api.getProfileStats(),
|
||||||
api.get('/admin/training-types/profiles/templates')
|
api.getProfileTemplates()
|
||||||
])
|
])
|
||||||
setTrainingTypes(typesData)
|
setTrainingTypes(typesData)
|
||||||
setStats(statsData)
|
setStats(statsData)
|
||||||
|
|
@ -55,7 +55,7 @@ export default function AdminTrainingProfiles() {
|
||||||
const profile = JSON.parse(profileJson)
|
const profile = JSON.parse(profileJson)
|
||||||
|
|
||||||
// Update training type
|
// Update training type
|
||||||
await api.put(`/admin/training-types/${selectedType.id}`, { profile })
|
await api.adminUpdateTrainingType(selectedType.id, { profile })
|
||||||
|
|
||||||
setSuccess(`Profil für "${selectedType.name_de}" gespeichert`)
|
setSuccess(`Profil für "${selectedType.name_de}" gespeichert`)
|
||||||
closeEditor()
|
closeEditor()
|
||||||
|
|
@ -69,9 +69,7 @@ export default function AdminTrainingProfiles() {
|
||||||
if (!confirm(`Template "${templateKey}" auf diesen Trainingstyp anwenden?`)) return
|
if (!confirm(`Template "${templateKey}" auf diesen Trainingstyp anwenden?`)) return
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await api.post(`/admin/training-types/${typeId}/profile/apply-template`, {
|
await api.applyProfileTemplate(typeId, templateKey)
|
||||||
template_key: templateKey
|
|
||||||
})
|
|
||||||
setSuccess('Template erfolgreich angewendet')
|
setSuccess('Template erfolgreich angewendet')
|
||||||
load()
|
load()
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
@ -83,7 +81,7 @@ export default function AdminTrainingProfiles() {
|
||||||
if (!confirm('Alle Aktivitäten neu evaluieren? Das kann einige Sekunden dauern.')) return
|
if (!confirm('Alle Aktivitäten neu evaluieren? Das kann einige Sekunden dauern.')) return
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const result = await api.post('/evaluation/batch')
|
const result = await api.batchEvaluateActivities()
|
||||||
setSuccess(
|
setSuccess(
|
||||||
`Batch-Evaluation abgeschlossen: ${result.stats.evaluated} evaluiert, ` +
|
`Batch-Evaluation abgeschlossen: ${result.stats.evaluated} evaluiert, ` +
|
||||||
`${result.stats.skipped} übersprungen, ${result.stats.errors} Fehler`
|
`${result.stats.skipped} übersprungen, ${result.stats.errors} Fehler`
|
||||||
|
|
|
||||||
|
|
@ -214,6 +214,14 @@ export const api = {
|
||||||
adminDeleteTrainingType: (id) => req(`/admin/training-types/${id}`, {method:'DELETE'}),
|
adminDeleteTrainingType: (id) => req(`/admin/training-types/${id}`, {method:'DELETE'}),
|
||||||
getAbilitiesTaxonomy: () => req('/admin/training-types/taxonomy/abilities'),
|
getAbilitiesTaxonomy: () => req('/admin/training-types/taxonomy/abilities'),
|
||||||
|
|
||||||
|
// Admin: Training Type Profiles (Phase 2 #15)
|
||||||
|
getProfileStats: () => req('/admin/training-types/profiles/stats'),
|
||||||
|
getProfileTemplates: () => req('/admin/training-types/profiles/templates'),
|
||||||
|
getProfileTemplate: (key) => req(`/admin/training-types/profiles/templates/${key}`),
|
||||||
|
applyProfileTemplate: (id,templateKey) => req(`/admin/training-types/${id}/profile/apply-template`, json({template_key: templateKey})),
|
||||||
|
getTrainingParameters: () => req('/evaluation/parameters'),
|
||||||
|
batchEvaluateActivities: () => req('/evaluation/batch', {method:'POST'}),
|
||||||
|
|
||||||
// Admin: Activity Type Mappings (v9d Phase 1b - Learnable System)
|
// Admin: Activity Type Mappings (v9d Phase 1b - Learnable System)
|
||||||
adminListActivityMappings: (profileId, globalOnly) => req(`/admin/activity-mappings${profileId?'?profile_id='+profileId:''}${globalOnly?'?global_only=true':''}`),
|
adminListActivityMappings: (profileId, globalOnly) => req(`/admin/activity-mappings${profileId?'?profile_id='+profileId:''}${globalOnly?'?global_only=true':''}`),
|
||||||
adminGetActivityMapping: (id) => req(`/admin/activity-mappings/${id}`),
|
adminGetActivityMapping: (id) => req(`/admin/activity-mappings/${id}`),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user