This commit is contained in:
karimalden 2024-06-26 16:19:54 +03:00
parent 9ff014dff9
commit 6c82ce644e
8 changed files with 40 additions and 24 deletions

View File

@ -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) {

View File

@ -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/>

View File

@ -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,9 +44,18 @@ 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">
<div className="exercise_form"> <div className="exercise_form">
@ -67,9 +78,13 @@ const Form = () => {
} }
) )
} }
<p className="add_new_button" > {formik?.values?.QuestionOptions?.length < 4 && (
<FaCirclePlus onClick={handleAddChoice} size={23} /> {t("header.add_new_choice")} <p className="add_new_button" >
</p> <FaCirclePlus onClick={handleAddChoice} size={23} /> {t("header.add_new_choice")}
</p>
)}
<DynamicTags/> <DynamicTags/>

View File

@ -37,7 +37,8 @@ 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 (
<> <>
<Modal <Modal
@ -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")}

View File

@ -65,9 +65,12 @@ const Form = () => {
} }
) )
} }
<p className="add_new_button" > {formik?.values?.QuestionOptions?.length < 4 && (
<FaCirclePlus onClick={handleAddChoice} size={23} /> {t("header.add_new_choice")} <p className="add_new_button" >
</p> <FaCirclePlus onClick={handleAddChoice} size={23} /> {t("header.add_new_choice")}
</p>
)}
<DynamicTags/> <DynamicTags/>

View File

@ -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" />

View File

@ -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",

View File

@ -341,7 +341,8 @@
"min_mark_to_pass" : "علامة النجاح", "min_mark_to_pass" : "علامة النجاح",
"isBase":"سؤال رئيسي", "isBase":"سؤال رئيسي",
"main_question":"النص الأساسي ", "main_question":"النص الأساسي ",
"question":"السؤال" "question":"السؤال",
"id":"الرقم التعريفي"
}, },