diff --git a/src/Hooks/useKeyPress.tsx b/src/Hooks/useKeyPress.tsx index 64f6bea..9e9cbd9 100644 --- a/src/Hooks/useKeyPress.tsx +++ b/src/Hooks/useKeyPress.tsx @@ -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) { diff --git a/src/Pages/question/EditPage.tsx b/src/Pages/question/EditPage.tsx index fa8a300..e875791 100644 --- a/src/Pages/question/EditPage.tsx +++ b/src/Pages/question/EditPage.tsx @@ -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 diff --git a/src/Pages/question/Model/Add.tsx b/src/Pages/question/Model/Add.tsx index 6d7dbed..68290e8 100644 --- a/src/Pages/question/Model/Add.tsx +++ b/src/Pages/question/Model/Add.tsx @@ -13,7 +13,7 @@ import { useGetAllQuestion } from "../../../api/Question"; import useKeyPress from "../../../Hooks/useKeyPress"; const Form = () => { - const formik = useFormikContext(); + const formik = useFormikContext(); 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,9 +44,18 @@ 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 ( @@ -67,9 +78,13 @@ const Form = () => { } ) } - - {t("header.add_new_choice")} - + {formik?.values?.QuestionOptions?.length < 4 && ( + + {t("header.add_new_choice")} + + + )} + diff --git a/src/Pages/question/Model/Delete.tsx b/src/Pages/question/Model/Delete.tsx index b9c413b..87f5deb 100644 --- a/src/Pages/question/Model/Delete.tsx +++ b/src/Pages/question/Model/Delete.tsx @@ -37,7 +37,8 @@ const ModalForm: React.FC = () => { setInputValue(e.target.value); }; const [t] = useTranslation(); - + console.log(object_to_edit?.id); + return ( <> { onCancel={handleCancel} > - {t("practical.delete")} ({object_to_edit?.max_mark}){" "} + {t("practical.delete")} {t("input.id")} ({object_to_edit?.id}){" "} {t("practical.to_confirm_deletion_please_re_enter")}{" "} - {t("input.max_mark")} {t("models.Question")} + {t("input.id")} {t("models.Question")} @@ -71,9 +72,9 @@ const ModalForm: React.FC = () => { {t("practical.cancel")} {t("practical.delete")} diff --git a/src/Pages/question/Model/Edit.tsx b/src/Pages/question/Model/Edit.tsx index 1244a5a..565a5dc 100644 --- a/src/Pages/question/Model/Edit.tsx +++ b/src/Pages/question/Model/Edit.tsx @@ -65,9 +65,12 @@ const Form = () => { } ) } - - {t("header.add_new_choice")} - + {formik?.values?.QuestionOptions?.length < 4 && ( + + {t("header.add_new_choice")} + + + )} diff --git a/src/Pages/question/Model/Field/ChoiceFields.tsx b/src/Pages/question/Model/Field/ChoiceFields.tsx index a44d61f..864c0e3 100644 --- a/src/Pages/question/Model/Field/ChoiceFields.tsx +++ b/src/Pages/question/Model/Field/ChoiceFields.tsx @@ -16,7 +16,7 @@ const ChoiceFields = ({index,data}:{index:number , data :Choice }) => { - + diff --git a/src/Pages/question/useTableColumns.tsx b/src/Pages/question/useTableColumns.tsx index 3e881cb..08ad6f4 100644 --- a/src/Pages/question/useTableColumns.tsx +++ b/src/Pages/question/useTableColumns.tsx @@ -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", diff --git a/src/translate/ar.json b/src/translate/ar.json index 932fd6a..e6b6499 100644 --- a/src/translate/ar.json +++ b/src/translate/ar.json @@ -341,7 +341,8 @@ "min_mark_to_pass" : "علامة النجاح", "isBase":"سؤال رئيسي", "main_question":"النص الأساسي ", - "question":"السؤال" + "question":"السؤال", + "id":"الرقم التعريفي" },
- {t("header.add_new_choice")} -
+ {t("header.add_new_choice")} +