fix
This commit is contained in:
parent
a8967b62f2
commit
dbdaa04fde
1
.vscode/settings.json
vendored
1
.vscode/settings.json
vendored
|
|
@ -10,6 +10,7 @@
|
||||||
"Groupbutton",
|
"Groupbutton",
|
||||||
"handelnavigate",
|
"handelnavigate",
|
||||||
"Karim",
|
"Karim",
|
||||||
|
"Popconfirm",
|
||||||
"queryqlent",
|
"queryqlent",
|
||||||
"registraion",
|
"registraion",
|
||||||
"SENDNOTIFICATION",
|
"SENDNOTIFICATION",
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ const ImageBoxField = ({ name }: any) => {
|
||||||
</div>
|
</div>
|
||||||
<div className="ImageBox">
|
<div className="ImageBox">
|
||||||
{imagePreview ? (
|
{imagePreview ? (
|
||||||
<img src={imagePreview} alt="Preview" className="imagePreview" />
|
<img src={imagePreview} onClick={handleButtonClick} alt="Preview" className="imagePreview" />
|
||||||
) : (
|
) : (
|
||||||
<ImageIcon onClick={handleButtonClick} className="ImageBoxIcon" />
|
<ImageIcon onClick={handleButtonClick} className="ImageBoxIcon" />
|
||||||
)}
|
)}
|
||||||
|
|
|
||||||
|
|
@ -14,10 +14,10 @@ const TextField = ({
|
||||||
placeholder,
|
placeholder,
|
||||||
isDisabled,
|
isDisabled,
|
||||||
onChange,
|
onChange,
|
||||||
props,
|
|
||||||
no_label,
|
no_label,
|
||||||
label_icon,
|
label_icon,
|
||||||
className,
|
className,
|
||||||
|
...props
|
||||||
}: any) => {
|
}: any) => {
|
||||||
const { formik, isError, errorMsg, t } = useFormField(name, props);
|
const { formik, isError, errorMsg, t } = useFormField(name, props);
|
||||||
const TextFilehandleChange = (
|
const TextFilehandleChange = (
|
||||||
|
|
@ -48,6 +48,7 @@ const TextField = ({
|
||||||
onChange={onChange || TextFilehandleChange}
|
onChange={onChange || TextFilehandleChange}
|
||||||
style={{ height: 120 }}
|
style={{ height: 120 }}
|
||||||
id={name}
|
id={name}
|
||||||
|
{...props}
|
||||||
/>
|
/>
|
||||||
</ValidationFieldContainer>
|
</ValidationFieldContainer>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -174,7 +174,7 @@ const AddPage: React.FC = () => {
|
||||||
<div className="exercise_add">
|
<div className="exercise_add">
|
||||||
<Formik
|
<Formik
|
||||||
onSubmit={handleSubmit}
|
onSubmit={handleSubmit}
|
||||||
initialValues={getInitialValuesBase(objectToEdit)}
|
initialValues={getInitialValuesBase({} as any)}
|
||||||
validationSchema={getValidationSchemaBase}
|
validationSchema={getValidationSchemaBase}
|
||||||
enableReinitialize
|
enableReinitialize
|
||||||
>
|
>
|
||||||
|
|
@ -214,7 +214,7 @@ const AddPage: React.FC = () => {
|
||||||
<div className="exercise_add">
|
<div className="exercise_add">
|
||||||
<Formik
|
<Formik
|
||||||
enableReinitialize={true}
|
enableReinitialize={true}
|
||||||
initialValues={getInitialValues(objectToEdit)}
|
initialValues={getInitialValues({} as any)}
|
||||||
validationSchema={getValidationSchema}
|
validationSchema={getValidationSchema}
|
||||||
onSubmit={(values) => {
|
onSubmit={(values) => {
|
||||||
handleSubmit(values);
|
handleSubmit(values);
|
||||||
|
|
|
||||||
|
|
@ -67,8 +67,9 @@ const ChoiceFields = ({ index, data }: { index: number; data: Choice }) => {
|
||||||
placeholder="_"
|
placeholder="_"
|
||||||
name={`answers.${index}.hint`}
|
name={`answers.${index}.hint`}
|
||||||
label="hint"
|
label="hint"
|
||||||
type="text"
|
type="TextArea"
|
||||||
style={{ width: "100%" }}
|
style={{ width: "100%" , height: 60,resize:"none" }}
|
||||||
|
showCount={false}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
|
|
|
||||||
|
|
@ -89,8 +89,9 @@ const ChoiceFields = ({
|
||||||
placeholder="_"
|
placeholder="_"
|
||||||
name={`Questions.${parent_index}.answers.${index}.hint`}
|
name={`Questions.${parent_index}.answers.${index}.hint`}
|
||||||
label="hint"
|
label="hint"
|
||||||
type="text"
|
type="TextArea"
|
||||||
style={{ width: "100%" }}
|
style={{ width: "100%" , height: 60,resize:"none" }}
|
||||||
|
showCount={false}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
|
|
|
||||||
|
|
@ -134,8 +134,9 @@ const Form = () => {
|
||||||
placeholder="_"
|
placeholder="_"
|
||||||
name={`Questions.${parent_index}.hint`}
|
name={`Questions.${parent_index}.hint`}
|
||||||
label="hint_question"
|
label="hint_question"
|
||||||
type="text"
|
type="TextArea"
|
||||||
style={{ width: "100%" }}
|
style={{ width: "100%" , height: 60,resize:"none" }}
|
||||||
|
showCount={false}
|
||||||
/>
|
/>
|
||||||
<MaltySelectTag parent_index={parent_index} />
|
<MaltySelectTag parent_index={parent_index} />
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -74,8 +74,10 @@ const Form = () => {
|
||||||
placeholder="_"
|
placeholder="_"
|
||||||
name="hint"
|
name="hint"
|
||||||
label="hint_question"
|
label="hint_question"
|
||||||
type="text"
|
type="TextArea"
|
||||||
style={{ width: "100%" }}
|
style={{ width: "100%" , height: 60,resize:"none" }}
|
||||||
|
showCount={false}
|
||||||
|
|
||||||
/>
|
/>
|
||||||
<SelectTag />
|
<SelectTag />
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ export const getValidationSchema = () => {
|
||||||
content_image: Yup.string().nullable(),
|
content_image: Yup.string().nullable(),
|
||||||
isCorrect: Yup.boolean(),
|
isCorrect: Yup.boolean(),
|
||||||
}),
|
}),
|
||||||
).min(2).nullable().test(
|
).min(2).test(
|
||||||
"at-least-one-correct",
|
"at-least-one-correct",
|
||||||
"At least one answer must be correct",
|
"At least one answer must be correct",
|
||||||
(answers: any) => {
|
(answers: any) => {
|
||||||
|
|
@ -111,6 +111,10 @@ export const getValidationSchemaBase = () => {
|
||||||
"At least one answer must be correct",
|
"At least one answer must be correct",
|
||||||
(answers: any) => {
|
(answers: any) => {
|
||||||
|
|
||||||
|
if(answers === null){
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
return answers.some(
|
return answers.some(
|
||||||
(answer: any) =>
|
(answer: any) =>
|
||||||
answer.isCorrect === true || answer.isCorrect === 1,
|
answer.isCorrect === true || answer.isCorrect === 1,
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,6 @@ import DeleteModels from "../../../Layout/Dashboard/DeleteModels";
|
||||||
import { ModalEnum } from "../../../enums/Model";
|
import { ModalEnum } from "../../../enums/Model";
|
||||||
import { useGetAllSubject } from "../../../api/subject";
|
import { useGetAllSubject } from "../../../api/subject";
|
||||||
import { useGetAllGrade } from "../../../api/grade";
|
import { useGetAllGrade } from "../../../api/grade";
|
||||||
import { useGetAllCurriculum } from "../../../api/curriculum";
|
|
||||||
import PageHeader from "../../../Layout/Dashboard/PageHeader";
|
import PageHeader from "../../../Layout/Dashboard/PageHeader";
|
||||||
import { ABILITIES_ENUM } from "../../../enums/abilities";
|
import { ABILITIES_ENUM } from "../../../enums/abilities";
|
||||||
import { canAddQuestion } from "../../../utils/hasAbilityFn";
|
import { canAddQuestion } from "../../../utils/hasAbilityFn";
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user