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