• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

wger-project / react / 18075690066

28 Sep 2025 02:32PM UTC coverage: 75.232% (-0.4%) from 75.672%
18075690066

push

github

web-flow
Merge pull request #1126 from wger-project/feature/exercise-submission

Use new endpoint for exercise submission

1723 of 2590 branches covered (66.53%)

Branch coverage included in aggregate %.

64 of 120 new or added lines in 14 files covered. (53.33%)

6 existing lines in 1 file now uncovered.

5500 of 7011 relevant lines covered (78.45%)

28.07 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

58.82
/src/components/Exercises/Add/Step3Description.tsx
1
import { Box, Button, Stack } from "@mui/material";
2✔
2
import Grid from '@mui/material/Grid';
2✔
3
import { useLanguageCheckQuery } from "components/Core/queries";
2✔
4
import { StepProps } from "components/Exercises/Add/AddExerciseStepper";
5
import { PaddingBox } from "components/Exercises/Detail/ExerciseDetails";
2✔
6
import { ExerciseDescription } from "components/Exercises/forms/ExerciseDescription";
2✔
7
import { ExerciseNotes } from "components/Exercises/forms/ExerciseNotes";
2✔
8
import { descriptionValidator, noteValidator } from "components/Exercises/forms/yupValidators";
2✔
9
import { Form, Formik } from "formik";
2✔
10
import React from "react";
2✔
11
import { useTranslation } from "react-i18next";
2✔
12
import { useExerciseSubmissionStateValue } from "state";
2✔
13
import { setDescriptionEn, setNotesEn } from "state/exerciseSubmissionReducer";
2✔
14
import { ENGLISH_LANGUAGE_ID } from "utils/consts";
2✔
15
import * as yup from "yup";
2✔
16

17

18
export const Step3Description = ({ onContinue, onBack }: StepProps) => {
2✔
19
    const [t] = useTranslation();
2✔
20
    const [state, dispatch] = useExerciseSubmissionStateValue();
2✔
21
    const languageCheckQuery = useLanguageCheckQuery();
2✔
22

23
    const validationSchema = yup.object({
2✔
24
        description: descriptionValidator(),
25
        notes: noteValidator()
26
    });
27

28
    return (
2✔
29
        (<Formik
30
            initialValues={{
31
                description: state.descriptionEn,
32
                notes: state.notesEn,
33
            }}
34
            validationSchema={validationSchema}
35
            onSubmit={async (values, { setFieldError }) => {
NEW
36
                let canContinue = false;
×
37

NEW
38
                const validationResult = await languageCheckQuery.mutateAsync({
×
39
                    input: values.description,
40
                    languageId: ENGLISH_LANGUAGE_ID
41
                });
42

43
                // @ts-ignore - validationResult contains the message from the backend
NEW
44
                if ("success" in validationResult) {
×
NEW
45
                    canContinue = true;
×
46
                } else {
NEW
47
                    canContinue = false;
×
48

49
                    // @ts-ignore - validationResult contains the message from the backend
NEW
50
                    setFieldError('description', validationResult.check.message);
×
51
                }
52

53
                dispatch(setDescriptionEn(values.description));
×
54
                dispatch(setNotesEn(values.notes));
×
55

NEW
56
                if (canContinue) {
×
NEW
57
                    onContinue!();
×
58
                }
59

60
            }}
61
        >
62
            <Form>
63
                <Stack>
64
                    <ExerciseDescription fieldName={"description"} />
65

66
                    <PaddingBox />
67

68
                    <ExerciseNotes fieldName={'notes'} />
69

70
                    <Grid container>
71
                        <Grid display="flex" justifyContent={"end"} size={12}>
72
                            <Box sx={{ mb: 2 }}>
73
                                <div>
74
                                    <Button
75
                                        onClick={onBack}
76
                                        sx={{ mt: 1, mr: 1 }}
77
                                    >
78
                                        {t('goBack')}
79
                                    </Button>
80
                                    <Button
81
                                        variant="contained"
82
                                        type="submit"
83
                                        disabled={languageCheckQuery.isPending}
84
                                        sx={{ mt: 1, mr: 1 }}
85
                                    >
86
                                        {t('continue')}
87
                                    </Button>
88
                                </div>
89
                            </Box>
90
                        </Grid>
91
                    </Grid>
92
                </Stack>
93
            </Form>
94
        </Formik>)
95
    );
96
};
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc