Refactor Exercise Creation Components to Utilize Custom Hook for Quick Create Fields
Deploy Development / deploy (push) Successful in 44s
Test Suite / pytest-backend (push) Successful in 40s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 14s
Test Suite / k6 /health Baseline (push) Successful in 33s
Test Suite / playwright-tests (push) Successful in 1m20s
Deploy Development / deploy (push) Successful in 44s
Test Suite / pytest-backend (push) Successful in 40s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 14s
Test Suite / k6 /health Baseline (push) Successful in 33s
Test Suite / playwright-tests (push) Successful in 1m20s
- Updated ExerciseAiQuickCreateOffer to set showSketchField to true by default and introduced sketchOptional prop for improved flexibility in exercise creation. - Refactored ExercisePickerModal and ExercisesListPageRoot to leverage useExerciseAiQuickCreateFields hook, simplifying state management for quick create fields. - Removed deprecated parsing logic and streamlined error handling for sketch input, enhancing user experience during exercise creation. - Improved placeholder text and labels for clarity, ensuring better guidance for users when providing input for AI-generated exercises.
This commit is contained in:
1 parent
294740b780
commit
c816e50c68
4 files changed
+108
-59
No files matched your search
@@ -18,8 +18,8 @@ import {
|
||||
buildQuickCreateAiPreview,
|
||||
buildQuickCreateExercisePayloadFromDraft,
|
||||
aiPreviewToQuickCreateDraft,
|
||||
parseSearchQueryForQuickCreate,
|
||||
} from '../../utils/exerciseAiQuickCreate'
|
||||
import { useExerciseAiQuickCreateFields } from '../../hooks/useExerciseAiQuickCreateFields'
|
||||
import { buildExercisesListReturnContext } from '../../utils/navReturnContext'
|
||||
import { buildExerciseListFilterChips } from '../../utils/exerciseListFilterChips'
|
||||
import { skillCatalogPathLabel } from '../../utils/skillCatalogTree'
|
||||
@@ -89,13 +89,21 @@ function ExercisesListPageRoot() {
|
||||
const [peekExercise, setPeekExercise] = useState(null)
|
||||
const [saveModuleModalOpen, setSaveModuleModalOpen] = useState(false)
|
||||
const [aiQuickCreateEnabled, setAiQuickCreateEnabled] = useState(false)
|
||||
const [quickTitle, setQuickTitle] = useState('')
|
||||
const [quickSketch, setQuickSketch] = useState('')
|
||||
const [quickFocusAreaId, setQuickFocusAreaId] = useState('')
|
||||
const [quickSaving, setQuickSaving] = useState(false)
|
||||
const [quickAiError, setQuickAiError] = useState('')
|
||||
const [quickCreateDraft, setQuickCreateDraft] = useState(null)
|
||||
|
||||
const {
|
||||
title: quickTitle,
|
||||
sketch: quickSketch,
|
||||
focusAreaId: quickFocusAreaId,
|
||||
setTitle: setQuickTitle,
|
||||
setSketch: setQuickSketch,
|
||||
setFocusAreaId: setQuickFocusAreaId,
|
||||
} = useExerciseAiQuickCreateFields(debouncedSearch, {
|
||||
enabled: pageTab === 'list' && (aiQuickCreateEnabled || debouncedSearch.length >= 3),
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
if (!user?.id) return
|
||||
if (prefsAppliedRef.current) return
|
||||
@@ -143,18 +151,6 @@ function ExercisesListPageRoot() {
|
||||
return () => clearTimeout(t)
|
||||
}, [aiSearchInput])
|
||||
|
||||
const parsedQuickCreate = useMemo(
|
||||
() => parseSearchQueryForQuickCreate(debouncedSearch),
|
||||
[debouncedSearch],
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
if (!debouncedSearch) return
|
||||
setQuickTitle(parsedQuickCreate.title)
|
||||
setQuickSketch(parsedQuickCreate.sketch || debouncedSearch)
|
||||
setQuickAiError('')
|
||||
}, [debouncedSearch, parsedQuickCreate.title, parsedQuickCreate.sketch])
|
||||
|
||||
useEffect(() => {
|
||||
if (!filterModalOpen) return
|
||||
const onKey = (e) => {
|
||||
@@ -347,10 +343,7 @@ function ExercisesListPageRoot() {
|
||||
return
|
||||
}
|
||||
const sketch = (quickSketch || '').trim()
|
||||
if (!sketch) {
|
||||
alert('Bitte Suchtext oder Skizze eingeben.')
|
||||
return
|
||||
}
|
||||
|
||||
const focusId = parseInt(String(quickFocusAreaId).trim(), 10)
|
||||
if (!Number.isFinite(focusId) || focusId < 1) {
|
||||
alert('Bitte einen Fokusbereich wählen.')
|
||||
@@ -366,7 +359,7 @@ function ExercisesListPageRoot() {
|
||||
try {
|
||||
const aiRes = await api.suggestExerciseAi({
|
||||
title,
|
||||
goal: sketch,
|
||||
goal: sketch || undefined,
|
||||
execution: '',
|
||||
preparation: '',
|
||||
trainer_notes: '',
|
||||
@@ -668,10 +661,9 @@ function ExercisesListPageRoot() {
|
||||
busy={quickSaving}
|
||||
error={quickAiError}
|
||||
onRunAi={runQuickCreateAiSuggest}
|
||||
showSketchField={aiQuickCreateEnabled}
|
||||
hint={
|
||||
aiQuickCreateEnabled
|
||||
? 'KI-Anlage: Suchtext oder eigene Skizze als Ausgang — Fokusbereich wählen, dann KI-Vorschlag erzeugen und bearbeiten.'
|
||||
? 'KI-Anlage: Titel aus Suche oder manuell; Kurzbeschreibung optional — leer für freien KI-Vorschlag, ausgefüllt als Ausgangsidee.'
|
||||
: undefined
|
||||
}
|
||||
/>
|
||||
|
||||
Reference in new issue
Block a user