From a218d65d932f665112e019c63ba57c5bd626963e Mon Sep 17 00:00:00 2001 From: Alireza khaji Date: Sun, 17 Jul 2022 16:45:11 +0430 Subject: [PATCH] mangement tables, note exam api | 320 --- package.json | 1 + src/App.js | 21 +- src/index.css | 850 ++++++++++++++++++ src/redux/actions/book.js | 24 +- src/redux/actions/index.js | 3 + src/redux/actions/network.js | 27 + src/redux/actions/offCode.js | 26 + src/redux/reducers/book.js | 1 + src/redux/reducers/index.js | 2 + src/redux/reducers/network.js | 40 + src/redux/reducers/offCode.js | 40 + src/view/Exam2/Exam.js | 12 +- src/view/Exam2/NoteContainer.js | 196 ++++ src/view/addExam/views/ViewExamNote.js | 3 +- src/view/disountCode management/index.js | 100 +++ .../disountCode management/layouts/Editor.js | 202 +++++ src/view/product management/index.js | 93 ++ src/view/product management/layouts/Editor.js | 202 +++++ src/view/school management/index.js | 31 +- yarn.lock | 9 +- 20 files changed, 1842 insertions(+), 41 deletions(-) create mode 100644 src/redux/actions/network.js create mode 100644 src/redux/actions/offCode.js create mode 100644 src/redux/reducers/network.js create mode 100644 src/redux/reducers/offCode.js create mode 100644 src/view/Exam2/NoteContainer.js create mode 100644 src/view/disountCode management/index.js create mode 100644 src/view/disountCode management/layouts/Editor.js create mode 100644 src/view/product management/index.js create mode 100644 src/view/product management/layouts/Editor.js diff --git a/package.json b/package.json index 93a44b6..d204ca0 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "private": true, "dependencies": { "@react-pdf-viewer/core": "^3.1.2", + "@react-pdf-viewer/page-navigation": "3.1.2", "@testing-library/jest-dom": "^5.16.1", "@testing-library/react": "^12.1.2", "@testing-library/user-event": "^13.5.0", diff --git a/src/App.js b/src/App.js index 7db8dc3..d0ddc1b 100644 --- a/src/App.js +++ b/src/App.js @@ -47,6 +47,8 @@ import Exam from "./view/Exam2/Exam"; import UserManagement from "./view/user-management"; import AdminNav from "./components/AdminNav"; import SchoolManagement from "./view/school management"; +import ProductManagement from "./view/product management"; +import DisountCodeManagement from "./view/disountCode management"; let data = [ { @@ -631,10 +633,10 @@ let data = [ function App() { let location = window.location.pathname; - const [dontShowNav,setDontShowNav]=useState(false); - useEffect(()=>{ - location = window.location.pathname; - }) + const [dontShowNav, setDontShowNav] = useState(false); + useEffect(() => { + location = window.location.pathname; + }); // const {id} = useParams(); console.log(location); let buyPackagesData = null; @@ -684,7 +686,6 @@ function App() { console.log("hhhhhhhh--------------------"); console.log(location.split("/")); - return (
@@ -753,7 +754,15 @@ function App() { /> } + element={} + /> + } + /> + } /> :not(.Calendar__footer) button { + font-family: inherit; + background: transparent; + cursor: pointer; + -webkit-tap-highlight-color: transparent; + outline: none; +} + +.Calendar__header { + display: flex; + color: var(--cl-color-black); + padding: 2em 2.9em; + align-items: center; + overflow: hidden; +} + +.Calendar__monthArrowWrapper { + line-height: 0; + font-size: 3em; + padding: 3px; + position: relative; + border: none; + z-index: 1; + opacity: 1; + transition: 0.2s; + background-color: #06bace; +} + +.Calendar__monthArrowWrapper:focus { + outline: 1px dashed rgba(0, 0, 0, 0.4); + outline-offset: 2px; +} + +.Calendar__monthArrowWrapper:disabled, +.Calendar__monthArrowWrapper.-hidden { + opacity: 0; + pointer-events: none; +} + +.Calendar__monthArrowWrapper.-left { + transform: rotate(180deg); +} +.Calendar.-rtl .Calendar__monthArrowWrapper.-left { + transform: rotate(-180deg); +} + +.Calendar__monthArrowWrapper.-right { + transform: rotate(-0deg); +} +.Calendar.-rtl .Calendar__monthArrowWrapper.-right { + transform: rotate(0deg); +} + +.Calendar_monthArrowWrapper:active .Calendar_monthArrow { + transform: scale(0.7); +} + +.Calendar__monthArrow { + border-radius: 7px; + padding: 12px; + transition: var(--animation-duration) transform; + pointer-events: none; + background-repeat: no-repeat; + display: block; + width: 0.7em; + height: 0.7em; + background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' width='15' height='15' viewBox='0 0 50 80' xml:space='preserve'%3E%3Cpolyline fill='none' stroke='%23FFFFFF' stroke-width='15' stroke-linecap='round' stroke-linejoin='round' points=' 0.375,0.375 45.63,38.087 0.375,75.8 '/%3E%3C/svg%3E"); + background-size: 100% 100%; + background-color: #06bace; + background-size: 10px; + background-position: center; +} + +.Calendar__monthYearContainer { + flex: 1; + position: relative; +} + +.Calendar__monthYear { + font-size: 2em; + font-weight: 500; + display: flex; + align-items: center; + justify-content: center; + background-color: #fff; + position: absolute; + top: 0; + bottom: 0; + left: 50%; + will-change: transform, opacity; + backface-visibility: hidden; + transform: translateZ(0); + transition: var(--animation-duration); + line-height: 1; + color: #246e8a; +} +.Calendar__monthYear.dashboard { + font-size: 2em; + font-weight: 500; + display: flex; + align-items: center; + position: absolute; + top: 0; + bottom: 0; + left: 50%; + will-change: transform, opacity; + backface-visibility: hidden; + transform: translateZ(0); + transition: var(--animation-duration); + line-height: 1; + color: #65a9ff; +} + +.Calendar__monthYear.-hiddenNext { + opacity: 0; + transform: translateX(50%); +} + +.Calendar.-rtl .Calendar__monthYear.-hiddenNext { + transform: translateX(-150%); +} + +.Calendar__monthYear.-hiddenPrevious { + opacity: 0; + transform: translateX(-150%); +} + +.Calendar.-rtl .Calendar__monthYear.-hiddenPrevious { + transform: translateX(50%); +} + +.Calendar__monthYear.-shown { + opacity: 1; + margin-top: auto; + margin-bottom: auto; + transform: translateX(-50%); +} + +.Calendar__monthYear.-shownAnimated { + animation: var(--animation-duration) fadeTextToCenter forwards; +} + +.Calendar__monthYear > * { + padding: 0.2em 0.5em; + border: 1px solid transparent; + transition: var(--animation-duration); + font-size: 1.05em; + display: flex; + justify-content: center; + align-items: center; + transform: translateX(0) scale(0.95); + will-change: transform; + border-radius: 5px; +} + +.Calendar__monthYear:not(.-shown) > *, +.Calendar__monthYear > *.-hidden { + cursor: default; + pointer-events: none; +} + +.Calendar__monthText { + margin-left: -0.3em; +} +.Calendar__yearText:last-child { + margin-right: -0.3em; +} + +.Calendar__monthYear.-shown > *:hover, +.Calendar:not(.-noFocusOutline) .Calendar__monthYear.-shown > *:focus, +.Calendar__monthYear > *.-activeBackground { + background: #f5f5f5; +} + +.Calendar__monthText:hover { + transform: translateX(-0.2em) scale(0.95); +} +.Calendar.-rtl .Calendar__monthText:hover { + transform: translateX(0.2em) scale(0.95); +} + +.Calendar__yearText:hover { + transform: translateX(0.2em) scale(0.95); +} +.Calendar.-rtl .Calendar__yearText:hover { + transform: translateX(-0.2em) scale(0.95); +} + +.Calendar_monthYear .Calendar_yearText.-hidden { + transform: translateX(50%); + opacity: 0; +} + +.Calendar.-rtl .Calendar_monthYear .Calendar_yearText.-hidden { + transform: translateX(-50%); +} + +.Calendar_monthYear .Calendar_monthText.-hidden { + transform: translateX(-50%); + opacity: 0; +} + +.Calendar.-rtl .Calendar_monthYear .Calendar_monthText.-hidden { + transform: translateX(50%); +} + +.Calendar__monthYear:not(.-shown) > * { + pointer-events: none; +} + +.Calendar__monthSelectorAnimationWrapper, +.Calendar__yearSelectorAnimationWrapper { + position: absolute; + width: 100%; + height: 80%; + bottom: 0; + display: flex; + justify-content: center; + align-items: center; + overflow: hidden; +} + +.Calendar__monthSelectorWrapper { + width: 100%; + height: 100%; + display: flex; + justify-content: center; + align-items: center; +} + +.Calendar__monthSelector { + padding: 0 2.5em; + align-content: center; + padding-bottom: 2em; +} + +.Calendar__monthSelector, +.Calendar__yearSelector { + display: flex; + flex-wrap: wrap; + position: relative; + z-index: 2; + background-color: #fff; + transform: translateY(-150%); + will-change: transform; + transition: 0.6s; + height: 100%; +} + +.Calendar__yearSelectorWrapper { + width: 100%; + height: 100%; +} + +.Calendar__yearSelectorWrapper::after, +.Calendar__yearSelectorWrapper::before { + content: ""; + width: 100%; + height: 5em; + position: absolute; + left: 0; + opacity: 0; + transition: 0.4s; + transition-delay: 0.2s; +} + +.Calendar__yearSelectorWrapper::after { + background-image: linear-gradient( + to bottom, + #fff, + #fff 10%, + rgba(245, 245, 245, 0) + ); + top: -0.1em; +} + +.Calendar__yearSelectorWrapper::before { + background-image: linear-gradient( + to top, + #fff, + #fff 10%, + rgba(245, 245, 245, 0) + ); + bottom: 0; +} + +.Calendar__yearSelectorWrapper.-faded::after, +.Calendar__yearSelectorWrapper.-faded::before { + opacity: 1; + z-index: 3; +} + +.Calendar__yearSelector { + align-content: flex-start; + scrollbar-width: 0; + overflow: scroll; + position: relative; + width: 100%; + padding: 5em 2em; + -ms-overflow-style: none; +} + +.Calendar__yearSelector::-webkit-scrollbar { + display: none; +} + +.Calendar__yearSelectorItem { + width: 25%; + display: flex; + justify-content: center; +} + +.Calendar__yearSelectorItem:not(:nth-child(-n + 4)) { + margin-top: 1.5em; +} + +.Calendar__yearSelectorText { + border: none; + font-size: 1.4em; + min-width: 85%; + padding: 0.2em 0.5em; + border-radius: 5px; +} + +.Calendar__monthSelector.-open, +.Calendar__yearSelector.-open { + transform: translateY(0); +} + +.Calendar__yearSelectorText:focus, +.Calendar__monthSelectorItemText:focus { + outline: 1px dashed rgba(0, 0, 0, 0.4); + outline-offset: 2px; +} + +.Calendar__monthSelectorItem { + width: calc(100% / 3); + display: flex; + justify-content: center; +} + +.Calendar__monthSelectorItem:not(:nth-child(-n + 3)) { + margin-top: 2em; +} + +.Calendar__monthSelectorItemText { + border: none; + padding: 0.4em 0.4em; + border-radius: 8.5px; + font-size: 1.3em; + min-width: 70%; + transition: 0.3s; +} + +.Calendar__monthSelectorItem:not(.-active) + .Calendar__monthSelectorItemText:not(:disabled):hover, +.Calendar__yearSelectorItem:not(.-active) + .Calendar__yearSelectorText:not(:disabled):hover { + background: #f5f5f5; +} + +.Calendar__monthSelectorItemText:disabled, +.Calendar__yearSelectorText:disabled { + opacity: 0.5; + cursor: default; +} + +.Calendar_monthSelectorItem.-active .Calendar_monthSelectorItemText, +.Calendar_yearSelectorItem.-active .Calendar_yearSelectorText { + background-color: #006c94; + color: #fff; +} + +.Calendar__weekDays { + display: flex; + justify-content: space-between; + color: var(--cl-color-disabled); + font-size: 1.2em; + margin-bottom: 0.7em; + padding: 0 2.6em; + position: relative; +} +.Calendar__weekDays.dashboard { + display: flex; + justify-content: space-between; + color: var(--cl-color-disabled); + font-size: 1.2em; + margin-bottom: 0.7em; + padding: 0.75em 2.6em; + position: relative; + background-color: transparent; + /* background-color: #444444 !important; */ +} + +.Calendar__weekDay { + display: block; + width: calc(100% / 7); + background-color: transparent !important; + text-align: center; + text-decoration: none; + border: 0px; + color: #06bace; + margin: 0.2em; + white-space: nowrap; +} +.Calendar__weekDay.dashboard { + color: #a2b4cb; +} +.Calendar__weekDay[title] { + text-decoration: none; +} + +.Calendar__sectionWrapper { + position: relative; + min-height: 25.8em; + overflow: hidden; +} + +.Calendar__section { + display: flex; + flex-direction: column; + padding: 0 3.2em; + position: absolute; + color: var(--cl-color-black); + top: 0; + padding-top: 0.5em; + left: 0; + width: 100%; + will-change: transform, opacity; + transform: translateZ(0); + backface-visibility: hidden; + transition: var(--animation-duration); +} + +.Calendar__section.-hiddenPrevious { + opacity: 0.5; + transform: translateX(-90%); +} + +.Calendar.-rtl .Calendar__section.-hiddenPrevious { + transform: translateX(90%); +} + +.Calendar__section.-hiddenNext { + opacity: 0.5; + transform: translateX(90%); +} + +.Calendar.-rtl .Calendar__section.-hiddenNext { + transform: translateX(-90%); +} + +.Calendar__section.-shown { + opacity: 1; + transform: translateX(0); +} + +.Calendar__section.-shownAnimated { + animation: var(--animation-duration) FadeContentToCenter forwards; +} + +.Calendar__weekRow { + display: flex; + width: 100%; +} + +.Calendar__day { + width: calc(100% / 7 - 6px); + text-align: center; + padding: calc(0.25em - 1px); + font-size: 1.6em; + border-radius: 7px; + transition: 0.2s; + border: 1px solid transparent; + margin: 3px; + color: rgba(0, 0, 0, 0.8); + display: flex; + align-items: center; + + cursor: pointer; + vertical-align: middle; + background-color: #f3f3f3; + color: #06bace; +} +.Calendar__day.dashboard { + width: calc(100% / 7 - 6px); + text-align: center; + padding: calc(0.25em - 1px); + font-size: 1.6em; + border-radius: 7px; + transition: 0.2s; + border: 1px solid transparent; + margin: 3px; + color: rgba(0, 0, 0, 0.8); + display: flex; + align-items: center; + + cursor: pointer; + vertical-align: middle; + background-color: transparent; + color: #00253a; +} +.Calendar__day span { + padding: -10px; + margin-top: -30px; + font-size: 28px; +} + +.Calendar__day:focus { + outline: 1px dashed rgba(0, 0, 0, 0.4); + outline-offset: 2px; +} + +.Calendar__day.-ltr { + min-height: 2.6em; + font-size: 1.45em; +} + +.Calendar__day.-rtl { + font-size: 1.55em; + height: 2.45em; +} + +.Calendar__day:not(.-blank):not(.-selectedStart):not(.-selectedEnd):not(.-selectedBetween):not(.-selected):hover { + background-color: #dafbff; + color: #06bace; + border: 1px solid #06bace; +} + +.Calendar__day.-selected, +.Calendar__day.-selectedStart, +.Calendar__day.-selectedEnd { + background: #006c94; + color: #fff; +} + +.Calendar__day.-ltr.-selectedStart { + border-radius: 0; + border-top-left-radius: 7px; + border-bottom-left-radius: 7px; +} + +.Calendar__day.-rtl.-selectedStart { + border-radius: 0; + border-top-right-radius: 7px; + border-bottom-right-radius: 7px; +} + +.Calendar__day.-selectedBetween { + background: rgba(0, 108, 148, 0.07); + + border-radius: 0; +} + +.Calendar__day.-ltr.-selectedEnd { + border-radius: 0; + border-top-right-radius: 7px; + border-bottom-right-radius: 7px; +} + +.Calendar__day.-rtl.-selectedEnd { + border-radius: 0; + border-top-left-radius: 7px; + border-bottom-left-radius: 7px; +} + +.Calendar__day.-weekend:not(.-selected):not(.-blank):not(.-selectedStart):not(.-selectedEnd):not(.-selectedBetween) { + color: var(--cl-color-error); +} + +.Calendar__day.-weekend.-today:not(.-selectedStart):not(.-selectedEnd):not(.-selectedBetween)::after { + background: var(--cl-color-error); +} + +.Calendar__day.-disabled { + color: var(--cl-color-disabled) !important; + background: transparent !important; + cursor: default !important; +} +.Calendar__day.-selected { +} +.Calendar__day.-today:not(.-selectedStart):not(.-selectedEnd):not(.-selectedBetween) { + font-weight: 600; + color: var(--cl-color-black); + color: #000; + position: relative; +} + +.Calendar__day.-today:not(.-selectedStart):not(.-selectedEnd):not(.-selectedBetween)::after { + content: ""; + position: absolute; + bottom: 0.2em; + display: block; + width: 0.6em; + height: 1px; + background: #000; + left: 50%; + opacity: 0.5; + transform: translateX(-50%); + transition: 0.2s; +} + +.Calendar__day.-today:hover:not(.-selectedStart):not(.-selectedEnd):not(.-selectedBetween)::after { + opacity: 0; +} + +.Calendar__day.-blank { + color: transparent; + cursor: default; + pointer-events: none; +} + +.Calendar__footer { + position: relative; + z-index: 1; +} +.Calendar_footer .footer_Events { + display: flex; + flex-direction: column; + align-items: center; + font-size: 12px; + font-family: "IranSans"; + padding: 3px; +} +.Calendar_footer .footer_Events.dashboard { + display: flex; + justify-content: start; + width: 100%; + align-items: flex-start; + font-size: 12px; + font-family: "IranSans"; + margin-top: 10px; + padding: 1em 2em; + border-top: 1px solid #edf2fb; +} + +.Calendar_footer .footer_Events.dashboard p { + font-size: 15px; + margin: 2.5px 0px; +} + +.Calendar .holiday span { + color: #ff2929; +} +.Calendar .DayNumDiv { + display: flex; + flex-direction: column; +} +.Calendar .DayNumDiv span { + margin: 0; + padding: 0; + margin-bottom: -5px; +} +.Calendar .DayNumDiv .eventDots { + margin-top: -10px; + font-size: 20px; +} +.GoToTodayButton { + background-color: #006c94; + padding: 7.5px; + font-size: 12px; + color: white; + font-family: "iranSans"; + border-radius: 50%; + float: left; + margin: 15px; +} +@keyframes fadeCalendar { + from { + opacity: 0; + } + + to { + opacity: 1; + transform: translateY(0); + } +} + +@keyframes fadeArrowFlipped { + from { + opacity: 0; + } + + to { + opacity: 1; + transform: translateY(0) rotate(180deg); + } +} + +@keyframes fadeTextToCenter { + to { + opacity: 1; + transform: translateX(-50%); + } +} + +@keyframes FadeContentToCenter { + to { + opacity: 1; + transform: translateX(0); + } +} + diff --git a/src/redux/actions/book.js b/src/redux/actions/book.js index a7dd6f9..2c8f7f3 100644 --- a/src/redux/actions/book.js +++ b/src/redux/actions/book.js @@ -23,18 +23,18 @@ const book = { sortFilter: (data) => async (dispatch) => await dispatch({ type: "book/sortFilter", data: data }), - // update: - // (data = {}, data2 = {}) => - // async (dispatch : Dispatch) => { - // await proxy.put("book/update", data); - // await proxy.get("book/list", data2, { dispatch }); - // }, - // add: - // (data = {}, data2 = {}) => - // async (dispatch) => { - // await proxy.post("book/add", data); - // await proxy.get("book/list", data2, { dispatch }); - // }, + update: + (data = {}, data2 = {}) => + async (dispatch) => { + await proxy.put("book/update", data); + await proxy.get("book/list", data2, { dispatch }); + }, + add: + (data = {}, data2 = {}) => + async (dispatch) => { + await proxy.post("book/add", data); + await proxy.get("book/list", data2, { dispatch }); + }, // del: // (data = {}, data2 = {}) => // async (dispatch) => { diff --git a/src/redux/actions/index.js b/src/redux/actions/index.js index 1c703ca..be01edd 100644 --- a/src/redux/actions/index.js +++ b/src/redux/actions/index.js @@ -21,6 +21,9 @@ export { default as category } from "./category"; export { default as examQuestion } from "./examQuestion"; export { default as note } from "./note"; export { default as table } from "./table"; +export { default as network } from "./network"; +export { default as offCode } from "./offCode"; + diff --git a/src/redux/actions/network.js b/src/redux/actions/network.js new file mode 100644 index 0000000..69c481c --- /dev/null +++ b/src/redux/actions/network.js @@ -0,0 +1,27 @@ + + +import proxy from "../proxy"; +const network = { + info: + (data = {}) => + async (dispatch) => + await proxy.get("network/info", data, { dispatch }), + schoolList: + (data = {}) => + async (dispatch) => + await proxy.get("network/schoolList", data, { dispatch }), + add: + (data = {}) => + async (dispatch) => + await proxy.post("network/add", data, { dispatch }), + update: + (data = {}) => + async (dispatch) => + await proxy.put("network/update", data, { dispatch }), + delete: + (data = {}) => + async (dispatch) => + await proxy.delete("network/delete", data, { dispatch }), +}; + +export default network; \ No newline at end of file diff --git a/src/redux/actions/offCode.js b/src/redux/actions/offCode.js new file mode 100644 index 0000000..67e00b0 --- /dev/null +++ b/src/redux/actions/offCode.js @@ -0,0 +1,26 @@ + +import proxy from "../proxy"; +const offCode = { + info: + (data = {}) => + async (dispatch) => + await proxy.get("offCode/info", data, { dispatch }), + schoolList: + (data = {}) => + async (dispatch) => + await proxy.get("offCode/list", data, { dispatch }), + add: + (data = {}) => + async (dispatch) => + await proxy.post("offCode/add", data, { dispatch }), + update: + (data = {}) => + async (dispatch) => + await proxy.put("offCode/update", data, { dispatch }), + delete: + (data = {}) => + async (dispatch) => + await proxy.delete("offCode/delete", data, { dispatch }), +}; + +export default offCode; \ No newline at end of file diff --git a/src/redux/reducers/book.js b/src/redux/reducers/book.js index e8b1cb4..716c7d2 100644 --- a/src/redux/reducers/book.js +++ b/src/redux/reducers/book.js @@ -57,6 +57,7 @@ export default function book(state = initialState, action) { ...state, loading: false, list: data, + schema:schema, subjects: Array.from(new Set(itemsSubject)), levels: Array.from(new Set(itemsLevel)), filterResult: data, diff --git a/src/redux/reducers/index.js b/src/redux/reducers/index.js index 2eded10..0e95276 100644 --- a/src/redux/reducers/index.js +++ b/src/redux/reducers/index.js @@ -21,5 +21,7 @@ export { default as category } from "./category"; export { default as examQuestion } from "./examQuestion"; export { default as note } from "./note"; export { default as table } from "./table"; +export { default as network } from "./network"; +export { default as offCode } from "./offCode"; diff --git a/src/redux/reducers/network.js b/src/redux/reducers/network.js new file mode 100644 index 0000000..fb34eca --- /dev/null +++ b/src/redux/reducers/network.js @@ -0,0 +1,40 @@ + + +import { toast } from "react-toastify"; + +const initialState = { + loading: false, + error: null, + info: null, + list: null, + lastAdd: null, + schema: [], +}; +export default function network(state = initialState, action) { + let { type, data, schema } = action; + switch (type) { + case "network/info": + return { ...state, loading: false, info: data, error: null }; + case "network/add": + toast.success("درخواست با موفقیت انجام شد"); + return { ...state, loading: false, error: null, lastAdd: data.id }; + case "network/update": + toast.success("درخواست با موفقیت انجام شد"); + return { ...state, loading: false, error: null }; + case "network/schoolList": + return { + ...state, + loading: false, + error: null, + list: data, + schema: schema, + }; + case "network/loading": + return { ...state, loading: true }; + case "network/error": + toast.error(data.message); + return { ...state, loading: false, error: data.message }; + default: + return state; + } +} \ No newline at end of file diff --git a/src/redux/reducers/offCode.js b/src/redux/reducers/offCode.js new file mode 100644 index 0000000..253d3d4 --- /dev/null +++ b/src/redux/reducers/offCode.js @@ -0,0 +1,40 @@ + + +import { toast } from "react-toastify"; + +const initialState = { + loading: false, + error: null, + info: null, + list: null, + lastAdd: null, + schema: [], +}; +export default function offCode(state = initialState, action) { + let { type, data, schema } = action; + switch (type) { + case "offCode/info": + return { ...state, loading: false, info: data, error: null }; + case "offCode/add": + toast.success("درخواست با موفقیت انجام شد"); + return { ...state, loading: false, error: null, lastAdd: data.id }; + case "offCode/update": + toast.success("درخواست با موفقیت انجام شد"); + return { ...state, loading: false, error: null }; + case "offCode/list": + return { + ...state, + loading: false, + error: null, + list: data, + schema: schema, + }; + case "offCode/loading": + return { ...state, loading: true }; + case "offCode/error": + toast.error(data.message); + return { ...state, loading: false, error: data.message }; + default: + return state; + } +} \ No newline at end of file diff --git a/src/view/Exam2/Exam.js b/src/view/Exam2/Exam.js index 6b6acec..3cc5f27 100644 --- a/src/view/Exam2/Exam.js +++ b/src/view/Exam2/Exam.js @@ -6,6 +6,7 @@ import { exam } from "../../redux/actions"; import { Link, useParams } from "react-router-dom"; import { useEffect } from "react"; import { useState } from "react"; +import NoteContainer from "./NoteContainer"; let loadingCondition = false; const Exam = ({ @@ -44,7 +45,7 @@ const Exam = ({ style={{ width: "calc(100vw - 5px)" }} > {examData &&
} - {examData && examData ( + {examData && examData?.exam?.examInfo?.type !== 2 && ( )} + {examData && examData?.exam?.examInfo?.type === 2 && ( + + )} {examLoading && !examData && (
در حال گرفتن اطلاعات.. diff --git a/src/view/Exam2/NoteContainer.js b/src/view/Exam2/NoteContainer.js new file mode 100644 index 0000000..1b8599f --- /dev/null +++ b/src/view/Exam2/NoteContainer.js @@ -0,0 +1,196 @@ +import React, { useEffect } from "react"; +import { useState } from "react"; +// import { Document, Page } from "react-pdf"; +import { Viewer, Worker } from "@react-pdf-viewer/core"; +import { pageNavigationPlugin } from "@react-pdf-viewer/page-navigation"; +// Import the styles +import "@react-pdf-viewer/core/lib/styles/index.css"; +import "@react-pdf-viewer/page-navigation/lib/styles/index.css"; +import { RenderCurrentPageInputProps } from "@react-pdf-viewer/page-navigation"; + + + +const optionNum = ["", "الف", "ب", "پ", "ت", "ث", "ج", "چ", "ح"]; + +const NoteContainer = ({ notes, questions, setAnswer, endExam, info }) => { + const [activeNote, setActiveNote] = useState(0); + const [activeFileId, setActiveFileId] = useState(null); + const changeNoteHandler = (index, fileId) => { + setActiveNote(index); + setActiveFileId(fileId); + }; + + const [answerList, setAnswerList] = useState([]); + const [fake, setFake] = useState(0); + + useEffect(() => { + setActiveFileId(notes[0].fileId); + let newlist = []; + for (let i = 0; i < questions?.length; i++) { + newlist.push(0); + } + setAnswerList(newlist); + }, [notes]); + + const chooseOption = (index, answer, id) => { + let newlist = answerList; + if (newlist[index] === answer) { + newlist[index] = 0; + setAnswer({ + userAnswerId: id, + answer: "0", + }); + } else { + newlist[index] = answer; + setAnswer({ + userAnswerId: id, + answer: String(answer), + }); + } + setAnswerList(newlist); + setFake(Math.random() * 1000); + }; + console.log(answerList); + + //================================ + const pageNavigationPluginInstance = pageNavigationPlugin(); + const { CurrentPageInput } = pageNavigationPluginInstance; + + //end exam ============================ + const endExamHandler = () => { + endExam({ + userExamId: info.id, + }); + }; + return ( +
+
+ {/* -----notes--------- */} +
+
+ {notes?.map((item, index) => ( +
changeNoteHandler(index, item.fileId)} + > + {item?.name} +
+ ))} +
+ +
+
+ +
+
+ {activeFileId && ( +
+ + + +
+ )} +
+ {/* -----answers----------- */} +
+
پاسخنامه
+
+ {questions?.map((item, index) => ( +
+
+ {item?.questionNumber} +
+
+
+
chooseOption(index, 1, item.id)} + style={ + answerList[index] === 1 + ? { backgroundColor: "#5ec427" } + : null + } + >
+
+
+
chooseOption(index, 2, item.id)} + style={ + answerList[index] === 2 + ? { backgroundColor: "#5ec427" } + : null + } + >
+
+ {item["question.type"] > 2 && ( +
+
chooseOption(index, 3, item.id)} + style={ + answerList[index] === 3 + ? { backgroundColor: "#5ec427" } + : null + } + >
+
+ )} + {item["question.type"] > 3 && ( +
+
chooseOption(index, 4, item.id)} + style={ + answerList[index] === 4 + ? { backgroundColor: "#5ec427" } + : null + } + >
+
+ )} + {item["question.type"] > 4 && ( +
+
chooseOption(index, 5, item.id)} + style={ + answerList[index] === 5 + ? { backgroundColor: "#5ec427" } + : null + } + >
+
+ )} +
+
+ ))} +
+
+ ثبت و اتمام آزمون +
+
+
+
+ ); +}; + +export default NoteContainer; diff --git a/src/view/addExam/views/ViewExamNote.js b/src/view/addExam/views/ViewExamNote.js index 1dd4821..1d58a2e 100644 --- a/src/view/addExam/views/ViewExamNote.js +++ b/src/view/addExam/views/ViewExamNote.js @@ -1,5 +1,4 @@ -import React, { useEffect } from "react"; -import { useState } from "react"; +import { useState, useEffect } from "react"; // import { Document, Page } from "react-pdf"; import { Viewer, Worker } from "@react-pdf-viewer/core"; diff --git a/src/view/disountCode management/index.js b/src/view/disountCode management/index.js new file mode 100644 index 0000000..cc1cab6 --- /dev/null +++ b/src/view/disountCode management/index.js @@ -0,0 +1,100 @@ + + +import React, { useMemo, useState } from "react"; +import { useEffect } from "react"; +import { connect } from "react-redux"; +import Table from "../../components/Table"; +import * as actions from "../../redux/actions"; +import Editor from "./layouts/Editor"; + +const source = "offCode"; +const title = " مدیریت کدهای تخفیف"; + +const DisCountCodeManagements = ({ + info, + getData, + tabs, + setTabs, + add, + update, + CodeList, + schema, +}) => { + useMemo(() => { + // getData({ num: 1000 }); + // getSchoolList(); + getData({ num: 1000 }); + }, []); + // console.log(info); + console.log("SchoolManagement render---------------------------------"); + console.log(info); + console.log(CodeList); + console.log(schema); + // console.log("==============^tabs^=============="); + // console.log(tabs); + useEffect(() => { + setTabs([ + { + id: 0, + name: title, + isActive: true, + element: "table", + }, + ]); + }, []); + // console.log(tabs); + // const [tabs, setTabs] = useState([ + // { + // id: 0, + // name: title, + // isActive: true, + // }, + // ]); + const [activeOtherTab, setActiveOtherTab] = useState(false); + const [fake, setFake] = useState(0); + + return ( +
+
+ + + + ); +}; +const mapStateToProps = (state) => ({ + info: state[source], + tabs: state.table.tabs, + CodeList: state.offCode.list, + schema: state.offCode.schema, +}); + +const mapDispatchToProps = { + // getData: actions[source].list, + getData: actions[source].schoolList, + setTabs: actions.table.setTab, + update: actions[source].update, + add: actions[source].add, +}; + +export default connect( + mapStateToProps, + mapDispatchToProps +)(DisCountCodeManagements); \ No newline at end of file diff --git a/src/view/disountCode management/layouts/Editor.js b/src/view/disountCode management/layouts/Editor.js new file mode 100644 index 0000000..ad6833d --- /dev/null +++ b/src/view/disountCode management/layouts/Editor.js @@ -0,0 +1,202 @@ +import React, { useEffect, useState } from "react"; +import { connect } from "react-redux"; +import { file } from "../../../redux/actions"; +import loadingGiff from "../../../assets/img/Rolling-1s-200px.gif"; +import SimpleDatePicker from "../../../components/SimpleDatePicker"; +import moment from "jalali-moment"; +const baseUrl = "https://api.andishmand.ir/api/v1"; +const components = (props) => ({ + text: ( + + ), + string: ( +