Compare commits

..

2 Commits

Author SHA1 Message Date
karimaldeen
45a960bce3 fix 2024-10-08 09:19:37 +03:00
karimaldeen
1556648532 remove dummy 2024-10-02 17:15:08 +03:00
12 changed files with 59 additions and 21 deletions

View File

@ -9,7 +9,7 @@ const LatexPreview = ({ latex }: { latex: string }) => {
// const sanitizedLatex = latex.replace(/\\_/g, '_'); // const sanitizedLatex = latex.replace(/\\_/g, '_');
return ( return (
<div> <div >
<BlockMath> <BlockMath>

View File

@ -17,12 +17,13 @@ const EditLazyModal = React.lazy(() => import("./EditLaTexModal"));
const LaTeXInputMemo: React.FC<any> = React.memo(({ field ,form, label, ...props }) => { const LaTeXInputMemo: React.FC<any> = React.memo(({ field ,form, label, ...props }) => {
const { name ,value} = field; const { name ,value} = field;
const { setFieldValue ,touched ,errors } = form; const { setFieldValue ,touched ,errors ,getFieldProps,values} = form;
const { ShowLatexOption, Success } = useObjectToEdit(); const { ShowLatexOption, Success } = useObjectToEdit();
const [showPreview, setShowPreview] = useState(false); const [showPreview, setShowPreview] = useState(false);
const Preview = parseTextAndLatex(value ?? ""); const Preview = parseTextAndLatex(value ?? "");
const onPreviewChange: CheckboxProps['onChange'] = (e) => { const onPreviewChange: CheckboxProps['onChange'] = (e) => {
setShowPreview(e.target.checked); setShowPreview(e.target.checked);
}; };
@ -68,6 +69,31 @@ const LaTeXInputMemo: React.FC<any> = React.memo(({ field ,form, label, ...prop
const isError = !!touched?.[name] && !!errors?.[name]; const isError = !!touched?.[name] && !!errors?.[name];
const errorMessage = isError ? errors?.[name] as string ?? "" : "" ; const errorMessage = isError ? errors?.[name] as string ?? "" : "" ;
console.log(values);
let metaName = name.substring(0, name.lastIndexOf('.'));
if (metaName.includes('.')) { metaName += ".meta";} else {metaName += "meta"}
console.log(metaName);
const meta = getFieldProps(metaName).value ;
console.log(meta);
const direction = meta?.direction === "ltr" ? "ltr" : "rtl"
const [Dir, setDir] = useState<"ltr" | "rtl">(direction)
const handleChangeDirection = ()=>{
if(Dir === "ltr"){
setDir("rtl")
setFieldValue(metaName,{...(meta ?? {}), direction:"rtl"})
}else{
setDir("ltr")
setFieldValue(metaName,{...(meta ?? {}), direction:"ltr"})
}
}
return ( return (
<div className='LaTeXInput'> <div className='LaTeXInput'>
<label htmlFor={name} className="text"> <label htmlFor={name} className="text">
@ -84,17 +110,24 @@ const LaTeXInputMemo: React.FC<any> = React.memo(({ field ,form, label, ...prop
onChange={handleChangeInput} onChange={handleChangeInput}
value={curCentValue} value={curCentValue}
onBlur={onBlur} onBlur={onBlur}
dir={Dir}
{...props} {...props}
/> />
<div className='LaTeXInputOptions'>
<Checkbox onChange={handleChangeDirection} checked={direction === "ltr"} >{t("header.change_direction")}</Checkbox>
{ShowLatexOption && ( {ShowLatexOption && (
<div className='LaTeXInputOptions'> <>
<Checkbox onChange={onPreviewChange}>{t("header.show_preview")}</Checkbox> <Checkbox onChange={onPreviewChange}>{t("header.show_preview")}</Checkbox>
<button type='button' className='addMML' onClick={showModal}> <button type='button' className='addMML' onClick={showModal}>
<FaPlus/> {t("MML")} <FaPlus/> {t("MML")}
</button> </button>
</div>
)} </>
)}
</div>
{showPreview && ( {showPreview && (
<div className='showPreviewInput'> <div className='showPreviewInput'>

View File

@ -15,9 +15,6 @@ export const areFieldPropsEqual = (
const nextValue = nextProps.field.value; const nextValue = nextProps.field.value;
return ( return (
prevValue === nextValue false
&&
prevError === nextError &&
prevTouched === nextTouched
); );
}; };

View File

@ -32,6 +32,8 @@ const AddPage: React.FC = () => {
lessons_ids: [lesson_id], lessons_ids: [lesson_id],
canAnswersBeShuffled, canAnswersBeShuffled,
hint: DataToSend?.hint, hint: DataToSend?.hint,
meta : DataToSend?.meta
}; };
mutateAsync(newBseQuestion).then((data: any) => { mutateAsync(newBseQuestion).then((data: any) => {
@ -56,6 +58,8 @@ const AddPage: React.FC = () => {
tags, tags,
lessons_ids: [lesson_id], lessons_ids: [lesson_id],
answers, answers,
meta : item?.meta
}); });
}); });
console.log(newBseQuestionId, "newBseQuestionId"); console.log(newBseQuestionId, "newBseQuestionId");

View File

@ -15,8 +15,6 @@ import { useObjectToEdit } from "../../../zustand/ObjectToEditState";
import { removeStringKeys } from "../../../utils/removeStringKeys"; import { removeStringKeys } from "../../../utils/removeStringKeys";
import SpinContainer from "../../../Components/Layout/SpinContainer"; import SpinContainer from "../../../Components/Layout/SpinContainer";
import { Question } from "../../../types/Item"; import { Question } from "../../../types/Item";
import { toast } from "react-toastify";
import { deletePathSegments } from "../../../utils/deletePathSegments";
import BaseFormContainer from "./Model/EditForm/BaseFormContainer"; import BaseFormContainer from "./Model/EditForm/BaseFormContainer";
import FormContainer from "./Model/EditForm/FormContainer"; import FormContainer from "./Model/EditForm/FormContainer";
import { handleValidateBaseQuestion, handleValidateSingleQuestion } from "./Model/ValidationFn"; import { handleValidateBaseQuestion, handleValidateSingleQuestion } from "./Model/ValidationFn";
@ -61,6 +59,7 @@ const EditPage: React.FC = () => {
id: DataToSend?.id, id: DataToSend?.id,
content: DataToSend?.content, content: DataToSend?.content,
content_image: DataToSend?.content_image ?? "", content_image: DataToSend?.content_image ?? "",
meta : DataToSend?.meta
}; };
if ( if (
typeof UpdateBseQuestion?.content_image === "string" && typeof UpdateBseQuestion?.content_image === "string" &&

View File

@ -59,7 +59,6 @@ const TableHeader = () => {
setObjectToEdit(null) setObjectToEdit(null)
} }
}, []) }, [])
console.log(objectToEdit);
return ( return (
<div className="TableWithHeader"> <div className="TableWithHeader">

View File

@ -6,7 +6,9 @@ export const getInitialValues = (objectToEdit: Question): any => {
return { ...item }; return { ...item };
}); });
return { return {
id: objectToEdit?.id ?? null, id: objectToEdit?.id ?? null,
content: objectToEdit?.content ?? "", content: objectToEdit?.content ?? "",
content_image: objectToEdit?.content_image ?? "", content_image: objectToEdit?.content_image ?? "",
@ -17,6 +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 ?? { direction : "rtl" }
}; };
}; };
@ -83,6 +86,8 @@ export const getInitialValuesBase = (objectToEdit: Question): any => {
hint: objectToEdit?.hint ?? "", hint: objectToEdit?.hint ?? "",
isBase: 0, isBase: 0,
tags, tags,
meta : objectToEdit?.meta ?? { direction : "rtl" }
}; };
}); });
@ -98,6 +103,8 @@ export const getInitialValuesBase = (objectToEdit: Question): any => {
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 ?? { direction : "rtl" }
}; };
}; };

View File

@ -1,13 +1,9 @@
import { HaveDuplicatedArrayValue } from "../../utils/hasDuplicateArrayValue";
const Dummy = () => { const Dummy = () => {
const isDuplicated = HaveDuplicatedArrayValue([{name:"name"},{name:"name3"},{name:"nam"}],"name")
console.log(isDuplicated,"isDuplicated");
return ( return (
<div className="DummyHomePage"> <div className="DummyHomePage">
<div>asd</div> <div>mohammed karim -_- </div>
<div> asd </div>
</div> </div>
); );
}; };

View File

@ -73,6 +73,7 @@
.LaTeXInputOptions{ .LaTeXInputOptions{
display: flex; display: flex;
padding: 10px; padding: 10px;
} }
.text{ .text{
margin-bottom: 7px !important; margin-bottom: 7px !important;

View File

@ -153,7 +153,8 @@
"add_MML":"إضافة MML", "add_MML":"إضافة MML",
"show_preview":"عرض المعاينة", "show_preview":"عرض المعاينة",
"show_MMl":" MML عرض", "show_MMl":" MML عرض",
"financial_collection":"التحصيلات" "financial_collection":"التحصيلات",
"change_direction":"تغيير الاتجاه"
}, },
"columns": { "columns": {
"id": "الرقم التعريفي", "id": "الرقم التعريفي",

View File

@ -317,6 +317,7 @@ export interface Question {
hint?: string; hint?: string;
tags: tags[]; tags: tags[];
lessons:any lessons:any
meta?:{}
} }
export type report = { export type report = {