parent
a6478f5679
commit
093924033b
12 changed files with 876 additions and 537 deletions
@ -0,0 +1,22 @@ |
|||||||
|
|
||||||
|
import proxy from "../proxy"; |
||||||
|
const examQuestion = { |
||||||
|
info: |
||||||
|
(data = {}) => |
||||||
|
async (dispatch) => |
||||||
|
await proxy.get("examQuestion/info", data, { dispatch }), |
||||||
|
list: |
||||||
|
(data = {}) => |
||||||
|
async (dispatch) => |
||||||
|
await proxy.get("examQuestion/list", data, { dispatch }), |
||||||
|
add: |
||||||
|
(data = {}) => |
||||||
|
async (dispatch) => |
||||||
|
await proxy.post("examQuestion/add", data, { dispatch }), |
||||||
|
delete: |
||||||
|
(data = {}) => |
||||||
|
async (dispatch) => |
||||||
|
await proxy.delete("examQuestion/delete", data, { dispatch }), |
||||||
|
}; |
||||||
|
|
||||||
|
export default examQuestion; |
@ -0,0 +1,30 @@ |
|||||||
|
|
||||||
|
|
||||||
|
import { toast } from "react-toastify"; |
||||||
|
|
||||||
|
const initialState = { |
||||||
|
loading: false, |
||||||
|
error: null, |
||||||
|
info: null, |
||||||
|
list: null, |
||||||
|
lastAdd: null, |
||||||
|
}; |
||||||
|
export default function examQuestion(state = initialState, action) { |
||||||
|
let { type, data } = action; |
||||||
|
switch (type) { |
||||||
|
case "examQuestion/info": |
||||||
|
return { ...state, loading: false, info: data, error: null }; |
||||||
|
case "examQuestion/add": |
||||||
|
// toast.success("درخواست با موفقیت انجام شد");
|
||||||
|
return { ...state, loading: false, error: null, lastAdd: data }; |
||||||
|
case "examQuestion/list": |
||||||
|
return { ...state, loading: false, error: null, list: data }; |
||||||
|
case "examQuestion/loading": |
||||||
|
return { ...state, loading: true }; |
||||||
|
case "examQuestion/error": |
||||||
|
toast.error(data.message); |
||||||
|
return { ...state, loading: false, error: data.message }; |
||||||
|
default: |
||||||
|
return state; |
||||||
|
} |
||||||
|
} |
@ -1,89 +1,153 @@ |
|||||||
import React, { useEffect, useState } from "react"; |
import React, { useEffect, useState } from "react"; |
||||||
import attachIcon from '../../../assets/img/attach-circle.svg'; |
import { connect } from "react-redux"; |
||||||
const AddQuestionPopUp = ({ titlePass, scorePass, submitOnClick, cancelOnClick, passOptionTitle, setAsAnswer, options }) => { |
import attachIcon from "../../../assets/img/attach-circle.svg"; |
||||||
|
import { question } from "../../../redux/actions"; |
||||||
|
const AddQuestionPopUp = ({ |
||||||
const gozine = [ |
titlePass, |
||||||
'الف', |
scorePass, |
||||||
'ب', |
submitOnClick, |
||||||
'ج', |
cancelOnClick, |
||||||
'د', |
passOptionTitle, |
||||||
'ه', |
setAsAnswer, |
||||||
'ز', |
options, |
||||||
] |
submitQuestion, |
||||||
|
}) => { |
||||||
|
const gozine = ["الف", "ب", "ج", "د", "ه", "ز"]; |
||||||
|
|
||||||
return ( |
return ( |
||||||
<div className="w-full z-10 fixed bg-black bg-opacity-20 h-screen backdrop-blur flex flex-col items-center top-0 left-0 justify-center"> |
<div className="w-full z-10 fixed bg-black bg-opacity-20 h-screen backdrop-blur flex flex-col items-center top-0 left-0 justify-center"> |
||||||
<div className="w-1/2 flex flex-col items-center bg-white p-6 py-10 rounded-xl shadow-lg"> |
<div className="w-1/2 flex flex-col items-center bg-white p-6 py-10 rounded-xl shadow-lg"> |
||||||
<div className="w-full"> |
<div className="w-full"> |
||||||
<div className="w-8 h-8 text-white text-sm rounded-full cursor-pointer flex justify-center items-center bg-red52" onClick={cancelOnClick}> |
<div |
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 15.044 15.044"> |
className="w-8 h-8 text-white text-sm rounded-full cursor-pointer flex justify-center items-center bg-red52" |
||||||
<g id="vuesax_linear_card-remove" data-name="vuesax/linear/card-remove" transform="translate(-252.46 -511.461)"> |
onClick={cancelOnClick} |
||||||
|
> |
||||||
|
<svg |
||||||
|
xmlns="http://www.w3.org/2000/svg" |
||||||
|
width="12" |
||||||
|
height="12" |
||||||
|
viewBox="0 0 15.044 15.044" |
||||||
|
> |
||||||
|
<g |
||||||
|
id="vuesax_linear_card-remove" |
||||||
|
data-name="vuesax/linear/card-remove" |
||||||
|
transform="translate(-252.46 -511.461)" |
||||||
|
> |
||||||
<g id="card-remove" transform="translate(253.309 512.31)"> |
<g id="card-remove" transform="translate(253.309 512.31)"> |
||||||
<path id="Vector" d="M0,13.347,13.347,0" fill="none" stroke="#fff" strokeLinecap="round" strokeWidth="2" /> |
<path |
||||||
<path id="Vector-2" data-name="Vector" d="M13.347,13.347,0,0" fill="none" stroke="#fff" strokeLinecap="round" strokeWidth="2" /> |
id="Vector" |
||||||
|
d="M0,13.347,13.347,0" |
||||||
|
fill="none" |
||||||
|
stroke="#fff" |
||||||
|
strokeLinecap="round" |
||||||
|
strokeWidth="2" |
||||||
|
/> |
||||||
|
<path |
||||||
|
id="Vector-2" |
||||||
|
data-name="Vector" |
||||||
|
d="M13.347,13.347,0,0" |
||||||
|
fill="none" |
||||||
|
stroke="#fff" |
||||||
|
strokeLinecap="round" |
||||||
|
strokeWidth="2" |
||||||
|
/> |
||||||
</g> |
</g> |
||||||
</g> |
</g> |
||||||
</svg> |
</svg> |
||||||
</div> |
</div> |
||||||
</div> |
</div> |
||||||
<div className='w-4/5 flex flex-col text-blue3A mt-4 mb-2 font-bold justify-between items-center'> |
<div className="w-4/5 flex flex-col text-blue3A mt-4 mb-2 font-bold justify-between items-center"> |
||||||
<div className='w-11/12 flex flex-col bg-white rounded-xl border border-gray-300 shadow-sm'> |
<div className="w-11/12 flex flex-col bg-white rounded-xl border border-gray-300 shadow-sm"> |
||||||
<textarea className='w-full border-b border-gray-300 rounded-t-xl p-4 text-blue3A overflow-hideen text-right outline-none' placeholder="صورت سوال..." rows={1} |
<textarea |
||||||
|
className="w-full border-b border-gray-300 rounded-t-xl p-4 text-blue3A overflow-hideen text-right outline-none" |
||||||
|
placeholder="صورت سوال..." |
||||||
|
rows={1} |
||||||
onChange={(e) => titlePass(e.target.value)} |
onChange={(e) => titlePass(e.target.value)} |
||||||
/> |
/> |
||||||
|
|
||||||
<div className='w-full p-3 px-4 h-12 flex justify-between items-center'> |
<div className="w-full p-3 px-4 h-12 flex justify-between items-center"> |
||||||
<div> |
<div> |
||||||
<p className='text-xs'>نمره :
|
<p className="text-xs"> |
||||||
<input type='number' className="w-6 h-6 border border-gray-200 mr-1 rounded"
|
نمره : |
||||||
|
<input |
||||||
|
type="number" |
||||||
|
className="w-6 h-6 border border-gray-200 mr-1 rounded" |
||||||
onChange={(e) => scorePass(e.target.value)} |
onChange={(e) => scorePass(e.target.value)} |
||||||
/> |
/> |
||||||
</p> |
</p> |
||||||
</div> |
</div> |
||||||
<input type='file' className="hidden" id="Add_Question_Add_Image" /> |
<input |
||||||
<label htmlFor="Add_Question_Add_Image" className="flex items-center"> |
type="file" |
||||||
|
className="hidden" |
||||||
|
id="Add_Question_Add_Image" |
||||||
|
/> |
||||||
|
<label |
||||||
|
htmlFor="Add_Question_Add_Image" |
||||||
|
className="flex items-center" |
||||||
|
> |
||||||
<p className="text-gray-500 ml-1">آپلود</p> |
<p className="text-gray-500 ml-1">آپلود</p> |
||||||
<img src={attachIcon} className="h-full w-10" /> |
<img src={attachIcon} className="h-full w-10" /> |
||||||
</label> |
</label> |
||||||
</div> |
</div> |
||||||
</div> |
</div> |
||||||
<div className='w-11/12 justify-between mt-4 flex flex-wrap'> |
<div className="w-11/12 justify-between mt-4 flex flex-wrap"> |
||||||
{ |
{options?.map((item) => ( |
||||||
options?.map( |
<div |
||||||
(item) => ( |
className="my-2 flex items-center justify-center shadow-sm" |
||||||
<div className='my-2 flex items-center justify-center shadow-sm' style={{width: 'calc(50% - 10px)'}} onClick={() => setAsAnswer(item.id) }> |
style={{ width: "calc(50% - 10px)" }} |
||||||
<p className={` h-12 flex items-center justify-center w-16 rounded-lg rounded-l-none ${item.isAnswer ? 'text-white bg-green-400' : 'bg-gray-200 border border-gray-300'}`}>{gozine[item.id - 1]}</p> |
onClick={() => setAsAnswer(item.id)} |
||||||
<input className={` h-12 outline-none flex items-center justify-center p-2 w-full rounded-lg rounded-r-none ${item.isAnswer ? 'bg-green-200' : 'bg-white border border-gray-300'}`} |
> |
||||||
onChange={e => passOptionTitle(e.target.value, item.id)} |
<p |
||||||
placeholder={`گزینه ${item.id}`}/> |
className={` h-12 flex items-center justify-center w-16 rounded-lg rounded-l-none ${ |
||||||
|
item.isAnswer |
||||||
|
? "text-white bg-green-400" |
||||||
|
: "bg-gray-200 border border-gray-300" |
||||||
|
}`}
|
||||||
|
> |
||||||
|
{gozine[item.id - 1]} |
||||||
|
</p> |
||||||
|
<input |
||||||
|
className={` h-12 outline-none flex items-center justify-center p-2 w-full rounded-lg rounded-r-none ${ |
||||||
|
item.isAnswer |
||||||
|
? "bg-green-200" |
||||||
|
: "bg-white border border-gray-300" |
||||||
|
}`}
|
||||||
|
onChange={(e) => passOptionTitle(e.target.value, item.id)} |
||||||
|
placeholder={`گزینه ${item.id}`} |
||||||
|
/> |
||||||
</div> |
</div> |
||||||
) |
))} |
||||||
) |
|
||||||
} |
|
||||||
</div> |
</div> |
||||||
<div className="w-11/12 flex justify-end"> |
<div className="w-11/12 flex justify-end"> |
||||||
<div className="w-1/3 mt-5 flex justify-between items-center"> |
<div className="w-1/3 mt-5 flex justify-between items-center"> |
||||||
<button className=" bg-white text-xl text-red-500 border-red-500 w-full h-12 mx-1 rounded-md border" onClick={cancelOnClick |
<button |
||||||
|
className=" bg-white text-xl text-red-500 border-red-500 w-full h-12 mx-1 rounded-md border" |
||||||
}> |
onClick={cancelOnClick} |
||||||
|
> |
||||||
انصراف |
انصراف |
||||||
</button> |
</button> |
||||||
|
|
||||||
<button className=" bg-green-500 text-xl text-white border-green-500 w-full ml-0 mx-3 h-12 rounded-md border" onClick={ |
<button |
||||||
submitOnClick |
className=" bg-green-500 text-xl text-white border-green-500 w-full ml-0 mx-3 h-12 rounded-md border" |
||||||
}> |
onClick={submitOnClick} |
||||||
|
> |
||||||
ثبت سوال |
ثبت سوال |
||||||
</button> |
</button> |
||||||
|
|
||||||
|
|
||||||
</div> |
</div> |
||||||
</div> |
</div> |
||||||
</div> |
</div> |
||||||
</div> |
</div> |
||||||
</div> |
</div> |
||||||
|
); |
||||||
|
}; |
||||||
|
|
||||||
|
|
||||||
|
const mapStateToProps = (state) => ({ |
||||||
|
|
||||||
|
}); |
||||||
|
|
||||||
) |
const mapDispatchToProps = { |
||||||
} |
submitQuestion:question.add |
||||||
|
}; |
||||||
|
|
||||||
export default AddQuestionPopUp; |
export default connect(mapStateToProps, mapDispatchToProps)(AddQuestionPopUp); |
||||||
|
Loading…
Reference in new issue