Compare commits

..

No commits in common. "9f05382d6cc1d9a75debc7856c5c7abd6e5664e0" and "45a960bce3f55108e95d2662e76db46808e131c6" have entirely different histories.

4 changed files with 14 additions and 17 deletions

View File

@ -75,9 +75,10 @@ const LaTeXInputMemo: React.FC<any> = React.memo(({ field ,form, label, ...prop
console.log(values); console.log(values);
let metaName = name.substring(0, name.lastIndexOf('.')); let metaName = name.substring(0, name.lastIndexOf('.'));
if (metaName.includes('.') || metaName.includes('[')) { metaName += ".meta";} else {metaName += "meta"} if (metaName.includes('.')) { metaName += ".meta";} else {metaName += "meta"}
console.log(metaName);
const meta = getFieldProps(metaName).value ; const meta = getFieldProps(metaName).value ;
console.log(metaName,meta); console.log(meta);
const direction = meta?.direction === "ltr" ? "ltr" : "rtl" const direction = meta?.direction === "ltr" ? "ltr" : "rtl"
const [Dir, setDir] = useState<"ltr" | "rtl">(direction) const [Dir, setDir] = useState<"ltr" | "rtl">(direction)

View File

@ -7,8 +7,7 @@ export const handleValidateSingleQuestion = (values:any,isValid:boolean,handleSu
const haveImageOrContent = haveOneAnswerRight && values?.answers?.some((item:any)=> !(item?.content) && !(item.content_image) ) const haveImageOrContent = haveOneAnswerRight && values?.answers?.some((item:any)=> !(item?.content) && !(item.content_image) )
const haveDuplicatedContent = hasDuplicateArrayValue(values?.answers,"content") const haveDuplicatedContent = hasDuplicateArrayValue(values?.answers,"content")
console.log("karim","karim");
const content = values.content ; const content = values.content ;
const content_image = values.content_image ; const content_image = values.content_image ;
const haveContentOrContentImage = !!content || !!content_image ; const haveContentOrContentImage = !!content || !!content_image ;
@ -46,8 +45,7 @@ export const handleValidateBaseQuestion = (values: any,isValid:boolean,handleSub
const content_image = values.content_image ; const content_image = values.content_image ;
const haveContentOrContentImage = !!content || !!content_image ; const haveContentOrContentImage = !!content || !!content_image ;
const haveDuplicatedContent = hasDuplicateArrayValue(values?.Questions,"content") const haveDuplicatedContent = hasDuplicateArrayValue(values?.Questions,"content")
console.log(1);
if(!haveContentOrContentImage){ if(!haveContentOrContentImage){
toast.error(`${t("validation.one_of_image_and_content_should_be_enter_in_question")}`); toast.error(`${t("validation.one_of_image_and_content_should_be_enter_in_question")}`);
return false; return false;

View File

@ -19,7 +19,7 @@ export const getInitialValues = (objectToEdit: Question): any => {
parent_id: objectToEdit?.parent_id ?? "", parent_id: objectToEdit?.parent_id ?? "",
answers: objectToEdit?.answers ?? null, answers: objectToEdit?.answers ?? null,
tags: tags ?? [], tags: tags ?? [],
meta : objectToEdit?.meta meta : objectToEdit?.meta ?? { direction : "rtl" }
}; };
}; };
@ -78,34 +78,32 @@ export const getInitialValuesBase = (objectToEdit: Question): any => {
} }
}) })
console.log(objectToEdit?.meta );
return { return {
...item, ...item,
answer:newAnswers, answer:newAnswers,
hint: item?.hint ?? "", canAnswersBeShuffled: objectToEdit?.canAnswersBeShuffled ? 1 : 0,
canAnswersBeShuffled:0, hint: objectToEdit?.hint ?? "",
isBase: 0, isBase: 0,
tags, tags,
meta : item?.meta meta : objectToEdit?.meta ?? { direction : "rtl" }
}; };
}); });
const questions = newQuestions ?? [{answers:[]}]; const questions = newQuestions ?? [{answers:[]}];
console.log(questions?.[0]?.meta,"questions");
return { return {
id: objectToEdit?.id ?? null, id: objectToEdit?.id ?? null,
content: objectToEdit?.content ?? null, content: objectToEdit?.content ?? null,
content_image: objectToEdit?.content_image ?? null, content_image: objectToEdit?.content_image ?? "",
subject_id: objectToEdit?.subject_id ?? "", subject_id: objectToEdit?.subject_id ?? "",
isBase: 1, isBase: 1,
parent_id: objectToEdit?.parent_id ?? "", parent_id: objectToEdit?.parent_id ?? "",
canAnswersBeShuffled: objectToEdit?.canAnswersBeShuffled ? 1 : 0, canAnswersBeShuffled: objectToEdit?.canAnswersBeShuffled ? 1 : 0,
hint: objectToEdit?.hint ?? null, hint: objectToEdit?.hint ?? null,
Questions: questions, Questions: questions,
meta : objectToEdit?.meta meta : objectToEdit?.meta ?? { direction : "rtl" }
}; };
}; };
@ -114,7 +112,7 @@ export const getValidationSchemaBase = () => {
// validate input // validate input
return Yup.object().shape({ return Yup.object().shape({
content_image: Yup.string().nullable(), content_image: Yup.string().nullable(),
content: Yup.string().nullable(), content: Yup.string(),
Questions: Yup.array().of( Questions: Yup.array().of(
Yup.object().shape({ Yup.object().shape({
content_image: Yup.string().nullable(), content_image: Yup.string().nullable(),

View File

@ -11,7 +11,7 @@ export const hasDuplicateArrayValue = <T>(data: T[], key: keyof T): boolean => {
for (const item of data) { for (const item of data) {
const value = item[key]; // Accessing the value using the key const value = item[key]; // Accessing the value using the key
if (hashMap.has(value) && value !== null ) { if (hashMap.has(value)) {
return true; // Duplicate found return true; // Duplicate found
} else { } else {
hashMap.set(value, true); // Store the value as a key in the map hashMap.set(value, true); // Store the value as a key in the map