Done
This commit is contained in:
parent
9ff014dff9
commit
6c82ce644e
|
|
@ -2,7 +2,7 @@ import { useEffect } from 'react';
|
||||||
|
|
||||||
type ModifierKey = 'ctrlKey' | 'shiftKey' | 'altKey' | 'metaKey';
|
type ModifierKey = 'ctrlKey' | 'shiftKey' | 'altKey' | 'metaKey';
|
||||||
|
|
||||||
const useKeyPress = (targetKey: string, modifierKey: ModifierKey, callback: () => void) => {
|
const useKeyPress = (targetKey: string, modifierKey: ModifierKey, callback:any) => {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const handleKeyDown = (event: KeyboardEvent) => {
|
const handleKeyDown = (event: KeyboardEvent) => {
|
||||||
if (event[modifierKey] && event.key === targetKey) {
|
if (event[modifierKey] && event.key === targetKey) {
|
||||||
|
|
|
||||||
|
|
@ -120,10 +120,6 @@ const EditPage: React.FC = () => {
|
||||||
}, [isSuccess])
|
}, [isSuccess])
|
||||||
|
|
||||||
|
|
||||||
console.log(object_to_edit);
|
|
||||||
|
|
||||||
console.log(object_to_edit?.isBase && object_to_edit?.isBase === 0);
|
|
||||||
|
|
||||||
|
|
||||||
if(dataLoading && !!(object_to_edit?.isBase) && QuestionsDataLoading){
|
if(dataLoading && !!(object_to_edit?.isBase) && QuestionsDataLoading){
|
||||||
return <SpinContainer/>
|
return <SpinContainer/>
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ import { useGetAllQuestion } from "../../../api/Question";
|
||||||
import useKeyPress from "../../../Hooks/useKeyPress";
|
import useKeyPress from "../../../Hooks/useKeyPress";
|
||||||
|
|
||||||
const Form = () => {
|
const Form = () => {
|
||||||
const formik = useFormikContext();
|
const formik = useFormikContext<any>();
|
||||||
const { isOpen } = useModalState((state) => state);
|
const { isOpen } = useModalState((state) => state);
|
||||||
// const {data} = useGetAllQuestion();
|
// const {data} = useGetAllQuestion();
|
||||||
|
|
||||||
|
|
@ -28,6 +28,8 @@ const Form = () => {
|
||||||
|
|
||||||
|
|
||||||
const handleAddChoice = () => {
|
const handleAddChoice = () => {
|
||||||
|
console.log(formik?.values?.QuestionOptions?.length);
|
||||||
|
|
||||||
formik.setFieldValue('QuestionOptions', [...(formik?.values as any)?.QuestionOptions as Choice[],
|
formik.setFieldValue('QuestionOptions', [...(formik?.values as any)?.QuestionOptions as Choice[],
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
@ -42,8 +44,17 @@ const Form = () => {
|
||||||
|
|
||||||
|
|
||||||
useKeyPress('q', 'ctrlKey', handleAddChoice);
|
useKeyPress('q', 'ctrlKey', handleAddChoice);
|
||||||
const selectedInput = document.getElementById("choice_1")
|
|
||||||
console.log(selectedInput,"selectedInput");
|
|
||||||
|
const handleFocusChoice = (index:number) => {
|
||||||
|
const selectedInput = document.getElementById(`choice_${index}`);
|
||||||
|
if (selectedInput) {
|
||||||
|
selectedInput.focus();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// useKeyPress('1', 'ctrlKey', handleFocusChoice(1));
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Row className="w-100">
|
<Row className="w-100">
|
||||||
|
|
@ -67,10 +78,14 @@ const Form = () => {
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
{formik?.values?.QuestionOptions?.length < 4 && (
|
||||||
<p className="add_new_button" >
|
<p className="add_new_button" >
|
||||||
<FaCirclePlus onClick={handleAddChoice} size={23} /> {t("header.add_new_choice")}
|
<FaCirclePlus onClick={handleAddChoice} size={23} /> {t("header.add_new_choice")}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
)}
|
||||||
|
|
||||||
|
|
||||||
<DynamicTags/>
|
<DynamicTags/>
|
||||||
|
|
||||||
</Row>
|
</Row>
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ const ModalForm: React.FC = () => {
|
||||||
setInputValue(e.target.value);
|
setInputValue(e.target.value);
|
||||||
};
|
};
|
||||||
const [t] = useTranslation();
|
const [t] = useTranslation();
|
||||||
|
console.log(object_to_edit?.id);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|
@ -49,19 +50,19 @@ const ModalForm: React.FC = () => {
|
||||||
onCancel={handleCancel}
|
onCancel={handleCancel}
|
||||||
>
|
>
|
||||||
<header>
|
<header>
|
||||||
{t("practical.delete")} ({object_to_edit?.max_mark}){" "}
|
{t("practical.delete")} {t("input.id")} ({object_to_edit?.id}){" "}
|
||||||
</header>
|
</header>
|
||||||
<main className="main_modal">
|
<main className="main_modal">
|
||||||
<div className="ValidationField w-100 mb-5">
|
<div className="ValidationField w-100 mb-5">
|
||||||
<label className="text ">
|
<label className="text ">
|
||||||
{t("practical.to_confirm_deletion_please_re_enter")}{" "}
|
{t("practical.to_confirm_deletion_please_re_enter")}{" "}
|
||||||
{t("input.max_mark")} {t("models.Question")}
|
{t("input.id")} {t("models.Question")}
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<Input
|
<Input
|
||||||
size="large"
|
size="large"
|
||||||
type="text"
|
type="text"
|
||||||
placeholder={`${t("practical.enter")} ${t("input.max_mark")} ${t("models.Question")} `}
|
placeholder={`${t("practical.enter")} ${t("input.id")} ${t("models.Question")} `}
|
||||||
value={inputValue}
|
value={inputValue}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
/>
|
/>
|
||||||
|
|
@ -71,9 +72,9 @@ const ModalForm: React.FC = () => {
|
||||||
<div onClick={handleCancel}>{t("practical.cancel")}</div>
|
<div onClick={handleCancel}>{t("practical.cancel")}</div>
|
||||||
<button
|
<button
|
||||||
className={
|
className={
|
||||||
object_to_edit?.max_mark !== inputValue ? "disabled_button" : ""
|
object_to_edit?.id !== inputValue ? "disabled_button" : ""
|
||||||
}
|
}
|
||||||
disabled={object_to_edit?.max_mark !== inputValue || isLoading}
|
disabled={Number(object_to_edit?.id) !== Number(inputValue) || isLoading}
|
||||||
onClick={handleSubmit}
|
onClick={handleSubmit}
|
||||||
>
|
>
|
||||||
{t("practical.delete")}
|
{t("practical.delete")}
|
||||||
|
|
|
||||||
|
|
@ -65,10 +65,13 @@ const Form = () => {
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
{formik?.values?.QuestionOptions?.length < 4 && (
|
||||||
<p className="add_new_button" >
|
<p className="add_new_button" >
|
||||||
<FaCirclePlus onClick={handleAddChoice} size={23} /> {t("header.add_new_choice")}
|
<FaCirclePlus onClick={handleAddChoice} size={23} /> {t("header.add_new_choice")}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
)}
|
||||||
|
|
||||||
<DynamicTags/>
|
<DynamicTags/>
|
||||||
|
|
||||||
</Row>
|
</Row>
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ const ChoiceFields = ({index,data}:{index:number , data :Choice }) => {
|
||||||
<div className='ChoiceFields'>
|
<div className='ChoiceFields'>
|
||||||
|
|
||||||
|
|
||||||
<TextField className="textarea_exercise" placeholder={"choice"} label2={t(`input.choice`) + ` ` + `(${(getCharFromNumber(index))})` } name={index} id={`choice_${index}`} type="TextArea" />
|
<TextField className="textarea_exercise" placeholder={"choice"} label2={t(`input.choice`) + ` ` + `(${(getCharFromNumber(index))})` } name={index} id={`choice_${index + 1}`} type="TextArea" />
|
||||||
<File className="file_exercise" label={"attachment"} name={index} type="File" />
|
<File className="file_exercise" label={"attachment"} name={index} type="File" />
|
||||||
|
|
||||||
<CheckboxField className="" label="The_correct_answer" name={index} type="Checkbox" />
|
<CheckboxField className="" label="The_correct_answer" name={index} type="Checkbox" />
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ export const useColumns = () => {
|
||||||
render: (text, record) => record?.id,
|
render: (text, record) => record?.id,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: `${t("columns.name")}`,
|
title: `${t("columns.content")}`,
|
||||||
dataIndex: "name",
|
dataIndex: "name",
|
||||||
key: "name",
|
key: "name",
|
||||||
align: "center",
|
align: "center",
|
||||||
|
|
|
||||||
|
|
@ -341,7 +341,8 @@
|
||||||
"min_mark_to_pass" : "علامة النجاح",
|
"min_mark_to_pass" : "علامة النجاح",
|
||||||
"isBase":"سؤال رئيسي",
|
"isBase":"سؤال رئيسي",
|
||||||
"main_question":"النص الأساسي ",
|
"main_question":"النص الأساسي ",
|
||||||
"question":"السؤال"
|
"question":"السؤال",
|
||||||
|
"id":"الرقم التعريفي"
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user