From 34909190570df2be877eedca2729fd6009742779 Mon Sep 17 00:00:00 2001 From: Pkpedram Date: Wed, 16 Mar 2022 10:44:41 +0330 Subject: [PATCH] various changes + cart Number In Mobile Version --- src/App.js | 6 +- src/components/Checkbox/index.css | 6 +- src/components/header/Header.js | 226 +++++++++--------- .../addExam/views/AddQuestionsFromBank.js | 33 ++- 4 files changed, 146 insertions(+), 125 deletions(-) diff --git a/src/App.js b/src/App.js index 331956d..469ec74 100644 --- a/src/App.js +++ b/src/App.js @@ -632,19 +632,19 @@ function App() { let loginStorage = localStorage.getItem('login') const [LOGIN,setLOGIN]=useState(true); const activeLogin=()=>{ - + setLOGIN(true) localStorage.setItem('login', true) } const logOut = () => { - + setLOGIN(false) localStorage.setItem('login', false) }; useEffect(() => { - setLOGIN(loginStorage); + setLOGIN(true); }, [loginStorage]) //--UserFullInfo--------------------- diff --git a/src/components/Checkbox/index.css b/src/components/Checkbox/index.css index 7fecbcd..9ae0e16 100644 --- a/src/components/Checkbox/index.css +++ b/src/components/Checkbox/index.css @@ -77,12 +77,12 @@ } .checkbox:hover span:first-child { - border-color: #06BAC0; + border-color: #df1452; } .checkbox-input:checked + .checkbox span:first-child { - background: #06BAC0; - border-color: #06BAC0; + background: #df1452; + border-color: #df1452; animation: zoom-in-out 0.3s ease; } diff --git a/src/components/header/Header.js b/src/components/header/Header.js index f628b6f..084d5f8 100644 --- a/src/components/header/Header.js +++ b/src/components/header/Header.js @@ -1,3 +1,5 @@ +import React from 'react'; +import { useLocation } from 'react-router-dom'; import './Header.scss'; import searchIcon from "../../assets/img/Group 1148.svg"; import moment from "jalali-moment"; @@ -11,7 +13,7 @@ import arrowIcon from './MobileSideMenu/arrow-down.svg' import exitIcon from '../../assets/img/group-9.svg' const Header = ({ - isMobile + isMobile, cart }) => { let today = moment().locale("fa").format("YYYY/M/D"); console.log("today:"); @@ -22,96 +24,97 @@ const Header = ({ console.log(weekday); const [menuPopup, setMenuPopup] = useState(false); const [subMenu, setSubMenu] = useState(false); - + const location = useLocation(); return ( <> - -
- { - subMenu &&
- - ورود به پنل ادمین - - - ورود به صفحه افزودن آزمون - - - ورود به صفحه افزودن محصول - -
- } - { - isMobile ? -
-
setMenuPopup(!menuPopup)}> - - - - - - -
- - -
- - - - - - +
+ { + subMenu &&
+ setSubMenu(false)} className='w-full text-right border-b border-gray-200 py-2'> + ورود به پنل ادمین + + setSubMenu(false)} className='w-full text-right border-b border-gray-200 py-2'> + ورود به صفحه افزودن آزمون + + setSubMenu(false)} className='w-full text-right border-b border-gray-200 py-2'> + ورود به صفحه افزودن محصول + +
+ } + { + isMobile ? +
+
setMenuPopup(!menuPopup)}> + + + + + +
- -
: - <> - {window.location.pathname.includes('adminpanel') ?
: - <> -
- setSubMenu(!subMenu)}/> -
- avatar1 -
-
-
- کوروش زراندوز -
-
- پایه ششم -
-
+ + +
+
{cart?.length}
+ + + + + + -
- -
-
- - -
- - {weekdayList[weekday]} - - - {today} - - - روز ملی صنعت نفت - -
-
-
- +
+ +
: + <> + {location.pathname.includes('adminpanel') ?
: + <> +
+ setSubMenu(!subMenu)} /> +
+ avatar1 +
+
+
+ کوروش زراندوز +
+
+ پایه ششم +
+
+ +
+ +
+
+ + +
+ + {weekdayList[weekday]} + + + {today} + + + روز ملی صنعت نفت + +
+
+
+ } - - } + + } - {/*
+ {/*
searchIcon
*/} -
- { - isMobile && menuPopup && - <> -
-
- setMenuPopup(false)} - /> -
- - } + { + isMobile && menuPopup && + <> +
+
+ setMenuPopup(false)} + /> + +
+ + } ); } const mapStateToProps = (state) => ({ isMobile: state.publicApi.isMobile, + cart: state.userProduct.list }); const mapDispatchToProps = { }; diff --git a/src/view/addExam/views/AddQuestionsFromBank.js b/src/view/addExam/views/AddQuestionsFromBank.js index 92fc067..fc078c2 100644 --- a/src/view/addExam/views/AddQuestionsFromBank.js +++ b/src/view/addExam/views/AddQuestionsFromBank.js @@ -88,7 +88,11 @@ const AddQuestionsFromBank = ({ grades, addExamState, dispatch, stepClick, backS } + const [sortedQuestionBank, setSortedQuestionBank] = useState(addExamState.questionBank); + useEffect(() => { + setSortedQuestionBank(addExamState.questionBank) + }, [addExamState]) const [numberOfOptions, setNumberOfOptions] = useState(null); const [options, setOptions] = useState([]) @@ -147,7 +151,7 @@ const AddQuestionsFromBank = ({ grades, addExamState, dispatch, stepClick, backS addExamState.courseBank.map( (item, index) => ( <> -
+
e.target.checked ? @@ -161,7 +165,7 @@ const AddQuestionsFromBank = ({ grades, addExamState, dispatch, stepClick, backS } /> -

{item.title}

+

{item.title}

{/*

تعداد سوالات: {item.numberOfQuestions}

تعداد دروس: {item.courses.length}

*/} {/*

{ @@ -251,16 +255,27 @@ const AddQuestionsFromBank = ({ grades, addExamState, dispatch, stepClick, backS {(provided) => (

setSelectedCourse(item)} > -

- { dispatch({ type: 'REMOVE_EXAM_COURSE', payload: item }); setSelectedCourse(null); setFakeState(fakeState + 24) }}> x -

+
+
+ {item.selectedQuestions.length} سوال +
+ { + selectedCourse.id == item.id &&

+ { dispatch({ type: 'REMOVE_EXAM_COURSE', payload: item }); setSelectedCourse(null); setFakeState(fakeState + 24) }}> x +

+ } +

{item.title}

+
+

ضریب {item.coefficient}

+

{item.numberOfOptions} گزینه

+
)} @@ -469,7 +484,9 @@ const AddQuestionsFromBank = ({ grades, addExamState, dispatch, stepClick, backS
- console.log(e.target.value)} + { + + }} className="w-full h-10 flex px-4 items-center pt-1 outline-none rounded-md border border-gray-300 text-sm text-gray-600 mr-2" />
@@ -484,7 +501,7 @@ const AddQuestionsFromBank = ({ grades, addExamState, dispatch, stepClick, backS
{ - addExamState.questionBank?.filter(itm => itm.courseId == selectedCourse.id)?.map( + sortedQuestionBank?.filter(itm => itm.courseId == selectedCourse.id)?.map( (course, index) => ( {(provided) => (