Compare commits

...

55 Commits

Author SHA1 Message Date
59b085dd34 Merge pull request 'logo' (#67) from statistics into master
Reviewed-on: http://git.plannaplan.pl/y0rune/frontend/pulls/67
2021-01-25 19:46:13 +01:00
wrzesinski-hubert
3eaaa2ef10 logo 2021-01-25 19:44:47 +01:00
wrzesinski-hubert
4091525f61 logo 2021-01-25 19:09:41 +01:00
67a8281aa1 Merge pull request 'logo' (#66) from statistics into master
Reviewed-on: http://git.plannaplan.pl/y0rune/frontend/pulls/66
2021-01-25 19:08:34 +01:00
wrzesinski-hubert
4ac917649a console.log 2021-01-25 18:54:10 +01:00
c83f839705 Merge pull request 'console.log' (#65) from statistics into master
Reviewed-on: http://git.plannaplan.pl/y0rune/frontend/pulls/65
2021-01-25 18:52:45 +01:00
wrzesinski-hubert
f319e022fe priviligies 2021-01-25 18:37:47 +01:00
filipizydorczyk
62d73fcbe3 Merge pull request 'priviligies' (#64) from statistics into master
Reviewed-on: http://git.plannaplan.pl/y0rune/frontend/pulls/64
Reviewed-by: filipizydorczyk <filip.izydorczyk@protonmail.com>
2021-01-25 18:36:40 +01:00
wrzesinski-hubert
0ecdc6db20 saving fix 2021-01-25 17:43:02 +01:00
filipizydorczyk
a229f0cd6d Merge pull request 'saving fix' (#63) from statistics into master
Reviewed-on: http://git.plannaplan.pl/y0rune/frontend/pulls/63
Reviewed-by: filipizydorczyk <filip.izydorczyk@protonmail.com>
2021-01-25 17:41:49 +01:00
wrzesinski-hubert
a72fb6b12c transfer fix 2021-01-25 17:34:52 +01:00
filipizydorczyk
8ff51a6598 Merge pull request 'transfer fix' (#62) from statistics into master
Reviewed-on: http://git.plannaplan.pl/y0rune/frontend/pulls/62
Reviewed-by: filipizydorczyk <filip.izydorczyk@protonmail.com>
2021-01-25 17:34:14 +01:00
wrzesinski-hubert
49d9c6acdd Merge branch 'statistics' of git.plannaplan.pl:y0rune/frontend into statistics 2021-01-23 23:08:36 +01:00
wrzesinski-hubert
cf042413d6 ... 2021-01-23 23:08:18 +01:00
Maciej
954e0a751f Merge pull request 'statistics' (#61) from statistics into master
Reviewed-on: http://git.plannaplan.pl/y0rune/frontend/pulls/61
Reviewed-by: Maciej <glowackimaciej97@gmail.com>
2021-01-23 23:07:44 +01:00
Maciej
52d4a384d9 Merge pull request '...' (#60) from statistics into master
Reviewed-on: http://git.plannaplan.pl/y0rune/frontend/pulls/60
Reviewed-by: Maciej <glowackimaciej97@gmail.com>
2021-01-23 22:14:09 +01:00
Maciej
2c77eb47a9 Merge branch 'master' into statistics 2021-01-23 22:12:55 +01:00
wrzesinski-hubert
d1fb48f7fe ... 2021-01-23 22:02:41 +01:00
Maciej
a5d3beddb5 Merge pull request 'statistics' (#59) from statistics into master
Reviewed-on: http://git.plannaplan.pl/y0rune/frontend/pulls/59
Reviewed-by: Maciej <glowackimaciej97@gmail.com>
2021-01-23 19:05:41 +01:00
wrzesinski-hubert
adaf44f2f7 Merge branch 'statistics' of git.plannaplan.pl:y0rune/frontend into statistics 2021-01-23 18:55:18 +01:00
wrzesinski-hubert
f013ef54ee push to master 2021-01-23 18:54:20 +01:00
Maciej
084fe15d38 Merge pull request 'statistics' (#58) from statistics into master
Reviewed-on: http://git.plannaplan.pl/y0rune/frontend/pulls/58
Reviewed-by: Maciej <glowackimaciej97@gmail.com>
2021-01-23 15:22:54 +01:00
Maciej
13fce200bf Merge branch 'master' into statistics 2021-01-23 15:22:27 +01:00
Maciej
4d5c2f8d28 Update 'src/contexts/CoursesProvider.tsx' 2021-01-23 15:14:01 +01:00
wrzesinski-hubert
ec1012b3a0 fix something 2021-01-22 22:31:52 +01:00
wrzesinski-hubert
e16caff82f stats 2021-01-22 21:28:17 +01:00
wrzesinski-hubert
62f50cc9a6 tours and css changes 2021-01-22 19:52:31 +01:00
wrzesinski-hubert
1235484538 Merge branch 'statistics' of git.plannaplan.pl:y0rune/frontend into statistics 2021-01-19 21:37:59 +01:00
wrzesinski-hubert
b2e5a16e7d clean 2021-01-19 21:37:11 +01:00
Maciej
69d05b7a78 Merge pull request 'statistics' (#57) from statistics into master
Reviewed-on: http://git.plannaplan.pl/y0rune/frontend/pulls/57
Reviewed-by: Maciej <glowackimaciej97@gmail.com>
2021-01-19 21:36:53 +01:00
wrzesinski-hubert
34f85561c3 Merge branch 'master' into statistics 2021-01-19 21:33:04 +01:00
wrzesinski-hubert
edda909c66 go to master 2021-01-19 21:32:43 +01:00
wrzesinski-hubert
aedc0ea708 ... 2021-01-19 17:47:19 +01:00
wrzesinski-hubert
135deb56c6 transfer c.d 2021-01-19 17:46:14 +01:00
wrzesinski-hubert
6748309fbd transfer 2021-01-19 17:04:07 +01:00
wrzesinski-hubert
f9fa6412ef downloading file 2021-01-19 16:10:43 +01:00
Maciek Głowacki
26a54912cd changes 2021-01-19 07:23:35 +01:00
Maciek Głowacki
df1d26f653 changes 2021-01-18 22:37:31 +01:00
Maciek Głowacki
8b563d3e70 modal setup 2021-01-18 00:57:01 +01:00
wrzesinski-hubert
429c58befb ... 2021-01-17 22:24:44 +01:00
wrzesinski-hubert
31a85db790 statistics 2021-01-17 19:03:54 +01:00
wrzesinski-hubert
b7424826ad console logi 2021-01-14 15:32:50 +01:00
Maciej
6db69f95fb Merge pull request 'console logi' (#56) from idk into master
Reviewed-on: http://git.plannaplan.pl/y0rune/frontend/pulls/56
Reviewed-by: Maciej <glowackimaciej97@gmail.com>
2021-01-14 15:32:33 +01:00
Maciej
88899d9703 Merge branch 'master' into idk 2021-01-14 15:32:20 +01:00
wrzesinski-hubert
0d433c12ad date-fns 2021-01-14 15:30:18 +01:00
Maciej
64869bbd51 Merge pull request 'date-fns' (#55) from idk into master
Reviewed-on: http://git.plannaplan.pl/y0rune/frontend/pulls/55
Reviewed-by: Maciej <glowackimaciej97@gmail.com>
2021-01-14 15:29:22 +01:00
7fbf7e3fad
Merge from plan-hisotry 2021-01-14 15:22:23 +01:00
wrzesinski-hubert
93107fcd0b ... 2021-01-14 15:14:54 +01:00
wrzesinski-hubert
bcd8a62d4e ... 2021-01-14 15:09:51 +01:00
wrzesinski-hubert
e8580c6a75 ... 2021-01-14 15:08:25 +01:00
Maciej
80672b24d7 Merge pull request 'unit-tests' (#50) from unit-tests into master
Reviewed-on: http://git.plannaplan.pl/y0rune/frontend/pulls/50
Reviewed-by: Maciej <glowackimaciej97@gmail.com>
2021-01-14 15:02:39 +01:00
wrzesinski-hubert
1930b80cd8 admin panel API connected 2021-01-13 19:05:11 +01:00
wrzesinski-hubert
1c7888a478 fixed hover 2021-01-12 22:59:12 +01:00
wrzesinski-hubert
d4f7ad341a plan history is working correctly (i think) 2021-01-07 19:57:06 +01:00
Maciek Głowacki
0b10ed05d6 history first draft 2021-01-05 23:46:51 +01:00
33 changed files with 1612 additions and 208 deletions

61
package-lock.json generated
View File

@ -4510,6 +4510,12 @@
"to-regex-range": "^5.0.1" "to-regex-range": "^5.0.1"
} }
}, },
"fsevents": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.1.3.tgz",
"integrity": "sha512-Auw9a4AxqWpa9GUfj370BMPzzyncfBABW8Mab7BGWBYDj4Isgq+cDKtx0i6u9jcX9pQDnswsaaOTgTmA5pEjuQ==",
"optional": true
},
"is-number": { "is-number": {
"version": "7.0.0", "version": "7.0.0",
"resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz",
@ -5382,6 +5388,11 @@
} }
} }
}, },
"date-fns": {
"version": "2.16.1",
"resolved": "https://registry.npmjs.org/date-fns/-/date-fns-2.16.1.tgz",
"integrity": "sha512-sAJVKx/FqrLYHAQeN7VpJrPhagZc9R4ImZIWYRFZaaohR3KzmuK88touwsSwSVT8Qcbd4zoDsnGfX4GFB4imyQ=="
},
"debug": { "debug": {
"version": "4.3.1", "version": "4.3.1",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz",
@ -7295,10 +7306,14 @@
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8="
}, },
"fsevents": { "fsevents": {
"version": "2.1.2", "version": "1.2.13",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.1.2.tgz", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz",
"integrity": "sha512-R4wDiBwZ0KzpgOWetKDug1FZcYhqYnUYKtfZYt4mD5SBz76q0KR4Q9o7GIPamsVPGmW3EYPPJ0dOOjvx32ldZA==", "integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==",
"optional": true "optional": true,
"requires": {
"bindings": "^1.5.0",
"nan": "^2.12.1"
}
}, },
"function-bind": { "function-bind": {
"version": "1.1.1", "version": "1.1.1",
@ -8627,18 +8642,6 @@
"micromatch": "^3.1.10", "micromatch": "^3.1.10",
"sane": "^4.0.3", "sane": "^4.0.3",
"walker": "^1.0.7" "walker": "^1.0.7"
},
"dependencies": {
"fsevents": {
"version": "1.2.13",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz",
"integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==",
"optional": true,
"requires": {
"bindings": "^1.5.0",
"nan": "^2.12.1"
}
}
} }
}, },
"jest-jasmine2": { "jest-jasmine2": {
@ -12338,6 +12341,12 @@
"pinkie-promise": "^2.0.0" "pinkie-promise": "^2.0.0"
} }
}, },
"fsevents": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.1.2.tgz",
"integrity": "sha512-R4wDiBwZ0KzpgOWetKDug1FZcYhqYnUYKtfZYt4mD5SBz76q0KR4Q9o7GIPamsVPGmW3EYPPJ0dOOjvx32ldZA==",
"optional": true
},
"path-exists": { "path-exists": {
"version": "2.1.0", "version": "2.1.0",
"resolved": "https://registry.npmjs.org/path-exists/-/path-exists-2.1.0.tgz", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-2.1.0.tgz",
@ -14890,16 +14899,6 @@
"upath": "^1.1.1" "upath": "^1.1.1"
} }
}, },
"fsevents": {
"version": "1.2.13",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz",
"integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==",
"optional": true,
"requires": {
"bindings": "^1.5.0",
"nan": "^2.12.1"
}
},
"glob-parent": { "glob-parent": {
"version": "3.1.0", "version": "3.1.0",
"resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz",
@ -15207,16 +15206,6 @@
} }
} }
}, },
"fsevents": {
"version": "1.2.13",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz",
"integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==",
"optional": true,
"requires": {
"bindings": "^1.5.0",
"nan": "^2.12.1"
}
},
"get-caller-file": { "get-caller-file": {
"version": "1.0.3", "version": "1.0.3",
"resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-1.0.3.tgz", "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-1.0.3.tgz",

View File

@ -7,6 +7,7 @@
"@material-ui/icons": "^4.9.1", "@material-ui/icons": "^4.9.1",
"@material-ui/lab": "^4.0.0-alpha.56", "@material-ui/lab": "^4.0.0-alpha.56",
"axios": "^0.19.2", "axios": "^0.19.2",
"date-fns": "^2.16.1",
"notistack": "^1.0.1", "notistack": "^1.0.1",
"react": "16.9.0", "react": "16.9.0",
"react-click-away-listener": "^1.4.3", "react-click-away-listener": "^1.4.3",

View File

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- Generator: Adobe Illustrator 18.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 330 330" style="enable-background:new 0 0 330 330;" xml:space="preserve">
<g>
<path d="M165,0C74.019,0,0,74.02,0,165.001C0,255.982,74.019,330,165,330s165-74.018,165-164.999C330,74.02,255.981,0,165,0z
M165,300c-74.44,0-135-60.56-135-134.999C30,90.562,90.56,30,165,30s135,60.562,135,135.001C300,239.44,239.439,300,165,300z"/>
<path d="M164.998,70c-11.026,0-19.996,8.976-19.996,20.009c0,11.023,8.97,19.991,19.996,19.991
c11.026,0,19.996-8.968,19.996-19.991C184.994,78.976,176.024,70,164.998,70z"/>
<path d="M165,140c-8.284,0-15,6.716-15,15v90c0,8.284,6.716,15,15,15c8.284,0,15-6.716,15-15v-90C180,146.716,173.284,140,165,140z
"/>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

43
src/assets/left-arrow.svg Normal file
View File

@ -0,0 +1,43 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 492 492" style="enable-background:new 0 0 492 492;" xml:space="preserve">
<g>
<g>
<path d="M198.608,246.104L382.664,62.04c5.068-5.056,7.856-11.816,7.856-19.024c0-7.212-2.788-13.968-7.856-19.032l-16.128-16.12
C361.476,2.792,354.712,0,347.504,0s-13.964,2.792-19.028,7.864L109.328,227.008c-5.084,5.08-7.868,11.868-7.848,19.084
c-0.02,7.248,2.76,14.028,7.848,19.112l218.944,218.932c5.064,5.072,11.82,7.864,19.032,7.864c7.208,0,13.964-2.792,19.032-7.864
l16.124-16.12c10.492-10.492,10.492-27.572,0-38.06L198.608,246.104z"/>
</g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 964 B

51
src/assets/logout.svg Normal file
View File

@ -0,0 +1,51 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 512 512" style="enable-background:new 0 0 512 512;" xml:space="preserve">
<g>
<g>
<path d="M255.15,468.625H63.787c-11.737,0-21.262-9.526-21.262-21.262V64.638c0-11.737,9.526-21.262,21.262-21.262H255.15
c11.758,0,21.262-9.504,21.262-21.262S266.908,0.85,255.15,0.85H63.787C28.619,0.85,0,29.47,0,64.638v382.724
c0,35.168,28.619,63.787,63.787,63.787H255.15c11.758,0,21.262-9.504,21.262-21.262
C276.412,478.129,266.908,468.625,255.15,468.625z"/>
</g>
</g>
<g>
<g>
<path d="M505.664,240.861L376.388,113.286c-8.335-8.25-21.815-8.143-30.065,0.213s-8.165,21.815,0.213,30.065l92.385,91.173
H191.362c-11.758,0-21.262,9.504-21.262,21.262c0,11.758,9.504,21.263,21.262,21.263h247.559l-92.385,91.173
c-8.377,8.25-8.441,21.709-0.213,30.065c4.167,4.21,9.653,6.336,15.139,6.336c5.401,0,10.801-2.041,14.926-6.124l129.276-127.575
c4.04-3.997,6.336-9.441,6.336-15.139C512,250.302,509.725,244.88,505.664,240.861z"/>
</g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -0,0 +1,43 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 492.004 492.004" style="enable-background:new 0 0 492.004 492.004;" xml:space="preserve">
<g>
<g>
<path d="M382.678,226.804L163.73,7.86C158.666,2.792,151.906,0,144.698,0s-13.968,2.792-19.032,7.86l-16.124,16.12
c-10.492,10.504-10.492,27.576,0,38.064L293.398,245.9l-184.06,184.06c-5.064,5.068-7.86,11.824-7.86,19.028
c0,7.212,2.796,13.968,7.86,19.04l16.124,16.116c5.068,5.068,11.824,7.86,19.032,7.86s13.968-2.792,19.032-7.86L382.678,265
c5.076-5.084,7.864-11.872,7.848-19.088C390.542,238.668,387.754,231.884,382.678,226.804z"/>
</g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 971 B

1
src/assets/switch.svg Normal file
View File

@ -0,0 +1 @@
<svg id="bold" enable-background="new 0 0 24 24" height="512" viewBox="0 0 24 24" width="512" xmlns="http://www.w3.org/2000/svg"><path d="m23.25 15c-.414 0-.75-.336-.75-.75 0-2.895-2.355-5.25-5.25-5.25h-7.25v3.25c0 .66-.794.994-1.268.542l-5.5-5.25c-.148-.141-.232-.337-.232-.542s.084-.401.232-.542l5.5-5.25c.476-.454 1.268-.116 1.268.542v3.25h6.25c4.273 0 7.75 3.477 7.75 7.75v1.5c0 .414-.336.75-.75.75z"/><path d="m14 22.25v-3.25h-6.25c-4.273 0-7.75-3.477-7.75-7.75v-1.5c0-.414.336-.75.75-.75s.75.336.75.75c0 2.895 2.355 5.25 5.25 5.25h7.25v-3.25c0-.657.791-.998 1.268-.542l5.5 5.25c.148.141.232.337.232.542s-.084.401-.232.542l-5.5 5.25c-.477.454-1.268.116-1.268-.542z"/></svg>

After

Width:  |  Height:  |  Size: 678 B

38
src/assets/tick.svg Normal file
View File

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 468.293 468.293" style="enable-background:new 0 0 468.293 468.293;" xml:space="preserve">
<circle style="fill:#44C4A1;" cx="234.146" cy="234.146" r="234.146"/>
<polygon style="fill:#EBF0F3;" points="357.52,110.145 191.995,275.67 110.773,194.451 69.534,235.684 191.995,358.148
398.759,151.378 "/>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 719 B

1
src/assets/transfer.svg Normal file
View File

@ -0,0 +1 @@
<svg id="bold" enable-background="new 0 0 24 24" height="512" viewBox="0 0 24 24" width="512" xmlns="http://www.w3.org/2000/svg"><path d="m20.25 11c-.414 0-.75-.336-.75-.75v-4.5c0-.689-.561-1.25-1.25-1.25h-7.5c-.414 0-.75-.336-.75-.75s.336-.75.75-.75h7.5c1.517 0 2.75 1.233 2.75 2.75v4.5c0 .414-.336.75-.75.75z"/><path d="m20.25 11c-.192 0-.384-.073-.53-.22l-1.75-1.75c-.214-.214-.279-.537-.163-.817s.39-.463.693-.463h3.5c.303 0 .577.183.693.463s.052.603-.163.817l-1.75 1.75c-.146.147-.338.22-.53.22z"/><path d="m11.25 21h-5.5c-1.517 0-2.75-1.233-2.75-2.75v-4.5c0-.414.336-.75.75-.75s.75.336.75.75v4.5c0 .689.561 1.25 1.25 1.25h5.5c.414 0 .75.336.75.75s-.336.75-.75.75z"/><path d="m5.5 16.25h-3.5c-.303 0-.577-.183-.693-.463s-.052-.603.163-.817l1.75-1.75c.293-.293.768-.293 1.061 0l1.75 1.75c.214.214.279.537.163.817s-.391.463-.694.463z"/><circle cx="5" cy="2.5" r="2.5"/><path d="m7.25 6h-4.5c-1.517 0-2.75 1.233-2.75 2.75v.5c0 .414.336.75.75.75h8.5c.414 0 .75-.336.75-.75v-.5c0-1.517-1.233-2.75-2.75-2.75z"/><path d="m19 19c-1.378 0-2.5-1.122-2.5-2.5s1.122-2.5 2.5-2.5 2.5 1.122 2.5 2.5-1.122 2.5-2.5 2.5z"/><path d="m23.25 24h-8.5c-.414 0-.75-.336-.75-.75v-.5c0-1.517 1.233-2.75 2.75-2.75h4.5c1.517 0 2.75 1.233 2.75 2.75v.5c0 .414-.336.75-.75.75z"/></svg>

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -0,0 +1,266 @@
import { format } from 'date-fns';
import React, { useEffect, useState, useContext } from 'react';
import styled from 'styled-components/macro';
import { axiosInstance } from '../utils/axiosInstance';
import { useSnackbar } from 'notistack';
import CloseIcon from '@material-ui/icons/Close';
import { SyncLoader } from 'react-spinners';
import { CASContext } from '../contexts/CASProvider';
import LogoutIcon from '../assets/logout.svg';
import LogoPlanNaPlan from '../assets/logo.svg';
const StyledCloseIcon = styled(CloseIcon)`
color: #000000;
&:hover {
color: white;
cursor: pointer;
}
`;
const Icon = styled.img`
width: 40px;
margin-left: 40px;
cursor: pointer;
@media only screen and (max-width: 670px) {
width: 35px;
}
position:absolute;
top:10px;
right:10px;
`;
const SaveButton = styled.button`
display: flex;
justify-content: center;
align-items: center;
user-select: none;
background-color: #c7a424;
border: none;
font-weight: bold;
cursor: pointer;
height: 40px;
margin:10px;
&:hover {
color: #ffffff;
box-shadow: 0px 5px 4px 0px rgba(0, 0, 0, 0.24);
}
width: 150px;
`;
const AdministratorWrapper = styled.div`
display: flex;
flex-direction: column;
margin: 0 auto;
height: 100vh;
`;
const Wrap = styled.div`
display: flex;
flex: 1;
flex-direction: column;
justify-content: center;
align-items: center;
margin:20px;
`;
const LogoWrapper = styled.div`
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
margin-top:-50px;
`;
const Text = styled.div`
font-family: 'Roboto', sans-serif;
font-size: 5rem;
user-select: none;
margin-bottom:60px;
`;
const Logo = styled.img`
width: 400px;
height: 400px;
`;
const Form = styled.form`
flex: 1;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
input {
padding: 5px;
margin-top: 10px;
margin-bottom: 10px;
width: 210px;
}
`;
const DownloadSection = styled.div`
flex: 1;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
input {
padding: 5px;
margin-top: 10px;
margin-bottom: 10px;
width: 210px;
}
`;
export const Administrator = () => {
const { logout } = useContext(CASContext)!;
const { enqueueSnackbar } = useSnackbar();
const { closeSnackbar } = useSnackbar();
const today = new Date();
const dd = String(today.getDate()).padStart(2, '0');
const mm = String(today.getMonth() + 1).padStart(2, '0');
const yyyy = today.getFullYear();
const date = yyyy + '-' + mm + '-' + dd;
const [selectedFile, setSelectedFile] = useState<File | null>(null);
const [startFirstDate, setStartFirstDate] = useState<Date | null>(null);
const [endFirstDate, setEndFirstDate] = useState<Date | null>(null);
const [startSecondDate, setStartSecondDate] = useState<Date | null>(null);
const [endSecondDate, setEndSecondDate] = useState<Date | null>(null);
const [loading, setLoading] = useState(false);
const downloadFile = async () => {
const {data} = await axiosInstance.get(`${process.env.REACT_APP_API_URL}/api/v1/commisions/export/csv`,{responseType:"blob"});
const downloadUrl = window.URL.createObjectURL(new Blob([data]));
const link = document.createElement('a');
link.href = downloadUrl;
link.setAttribute('download', 'file.csv');
document.body.appendChild(link);
link.click();
link.remove();
};
const uploadFile = async (event: React.FormEvent<HTMLFormElement>) => {
const action = (key: any) => (
<>
<StyledCloseIcon
onClick={() => {
closeSnackbar(key);
}}
></StyledCloseIcon>
</>
);
event.preventDefault();
const formData = new FormData();
formData.append('file', selectedFile as Blob);
if (startFirstDate !== null) {
formData.append('firstTourBegin', format(startFirstDate, 'dd.MM.yyyy'));
}
if (endFirstDate !== null) {
formData.append('firstTourEnd', format(endFirstDate, 'dd.MM.yyyy'));
}
if (startSecondDate !== null) {
formData.append('secondTourBegin', format(startSecondDate, 'dd.MM.yyyy'));
}
if (endSecondDate !== null) {
formData.append('secondTourEnd', format(endSecondDate, 'dd.MM.yyyy'));
}
const config = {
headers: {
'content-type': 'multipart/form-data',
},
};
try {
setLoading(true);
const response = await axiosInstance.post(
`${process.env.REACT_APP_API_URL}/api/v1/configurator/config/`,
formData,
config,
);
enqueueSnackbar('Ustawienia zostały zapisane', {
variant: 'success',
action,
});
} catch (e) {
enqueueSnackbar('Ustawienia nie zostały zapisane', {
variant: 'error',
action,
});
console.log(e);
}
setLoading(false);
};
const xd = true;
return (
<AdministratorWrapper>
<Icon alt="logout" src={LogoutIcon} onClick={logout}/>
<Wrap>
<LogoWrapper>
<Logo alt="logo" src={LogoPlanNaPlan} />
<Text> plan na plan </Text>
</LogoWrapper>
{xd === true ? (
<div>
<Form onSubmit={uploadFile}>
<div>
<div>Start pierwszej tury:</div>{' '}
<div>
<input type="date" min={date} onChange={(e) => setStartFirstDate(e.target.valueAsDate)} />
</div>
<div>Koniec pierwszej tury:</div>{' '}
<div>
<input type="date" min={date} onChange={(e) => setEndFirstDate(e.target.valueAsDate)} />
</div>
</div>
<div>
<div>Start drugiej tury:</div>{' '}
<div>
<input type="date" min={date} onChange={(e) => setStartSecondDate(e.target.valueAsDate)} />
</div>
</div>
<div>
<div>Koniec drugiej tury:</div>{' '}
<div>
<input type="date" min={date} onChange={(e) => setEndSecondDate(e.target.valueAsDate)} />
</div>
</div>
<div>
<input
type="file"
onChange={(e) => {
if (e.target.files && e.target.files[0]) {
const file = e.target.files[0];
setSelectedFile(file);
}
}}
/>
</div>
<div>
<SaveButton type="submit">{loading === false ? 'Zapisz' : <SyncLoader />} </SaveButton>
</div>
</Form>
<DownloadSection>
<SaveButton onClick={downloadFile}>Pobierz dane.csv</SaveButton>
</DownloadSection>
</div>
) : (<div></div>
)}
</Wrap>
</AdministratorWrapper>
);
};

View File

@ -1,14 +1,15 @@
import React, { ElementType, useContext, useEffect, useState } from 'react'; import React, { useContext, useState } from 'react';
import Topbar from './Topbar'; import Topbar from './Topbar';
import { Transfer } from './Transfer'; import { Transfer } from './Transfer';
import { Admin } from './Admin'; import { Deanery } from './DeaneryPanel';
import { Scheduler } from './Scheduler'; import { Scheduler } from './Scheduler';
import { Rightbar } from './Rightbar'; import { Rightbar } from './Rightbar';
import { Administrator } from './Administrator';
import styled from 'styled-components'; import styled from 'styled-components';
import { coursesContext } from '../contexts/CoursesProvider';
import LoadingOverlay from 'react-loading-overlay'; import LoadingOverlay from 'react-loading-overlay';
import { SyncLoader } from 'react-spinners'; import { SyncLoader } from 'react-spinners';
import { CASContext } from '../contexts/CASProvider'; import { CASContext } from '../contexts/CASProvider';
import { coursesContext } from '../contexts/CoursesProvider';
const Wrapper = styled.div` const Wrapper = styled.div`
display: flex; display: flex;
height: calc(100vh - 80px); height: calc(100vh - 80px);
@ -19,33 +20,36 @@ const Wrapper = styled.div`
`; `;
export const App = () => { export const App = () => {
const { isDataLoading } = useContext(coursesContext)!; const { role } = useContext(CASContext)!;
const { isFetchingToken, user, role } = useContext(CASContext)!;
const [isOpenTransfer, setOpenTransfer] = useState(false); const [isOpenTransfer, setOpenTransfer] = useState(false);
const { selectSchedulerEvents } = useContext(coursesContext)!;
const schedulerEvents = selectSchedulerEvents();
const handleTransfer = () => { const handleTransfer = () => {
setOpenTransfer(!isOpenTransfer); setOpenTransfer(!isOpenTransfer);
}; };
const userPrivilige = localStorage.getItem('userPrivilige'); const userPrivilige = localStorage.getItem('userPrivilige');
console.log('role of that user is: ', role);
useEffect(() => {
console.log('is fetching token: ', isFetchingToken);
}, [isFetchingToken]);
return ( return (
<> <>
<LoadingOverlay active={role === undefined} spinner={<SyncLoader />}> <LoadingOverlay active={role === undefined} spinner={<SyncLoader />}>
<Topbar handleTransfer={handleTransfer} /> {userPrivilige !== 'ADMIN' && (
<Transfer isOpen={isOpenTransfer} handleClose={handleTransfer} /> <>
<Wrapper> <Topbar handleTransfer={handleTransfer} />
{userPrivilige === 'STUDENT' && ( <Transfer isTransferOpen={isOpenTransfer} handleClose={handleTransfer} />
<> <Wrapper>
<Scheduler /> {userPrivilige === 'STUDENT' && (
<Rightbar /> <>
</> <Scheduler schedulerEvents={schedulerEvents} />
)}{' '} <Rightbar />
{userPrivilige === 'DEANERY' && <Admin />} </>
</Wrapper> )}
{userPrivilige === 'DEANERY' && <Deanery schedulerEvents={schedulerEvents} />}
</Wrapper>
</>
)}
{userPrivilige === 'ADMIN' && <Administrator></Administrator>}
</LoadingOverlay> </LoadingOverlay>
</> </>
); );

View File

@ -21,7 +21,7 @@ const CourseCardWrapper = styled.div`
border-radius: 10px; border-radius: 10px;
cursor: pointer; cursor: pointer;
align-items: stretch; align-items: stretch;
box-shadow: 3px 3px 3px 0px rgba(0, 0, 0, 0.75); box-shadow: 3px 3px 5px 0px rgba(189,189,189,1);
`; `;
const TitleWrapper = styled.div` const TitleWrapper = styled.div`
@ -158,12 +158,11 @@ export const CourseCard = ({ course }: CourseCardProps) => {
} = useContext(coursesContext)!; } = useContext(coursesContext)!;
const [isSelected, setSelected] = useState(true); const [isSelected, setSelected] = useState(true);
const groups = [...course.lectures!, ...course.classes!]; const groups = [...course.lectures!, ...course.classes!];
const basketCourseGroups = useMemo(() => selectBasketCourseGroups(course.id), []); const basketCourseGroups = useMemo(() => selectBasketCourseGroups(course.name), []);
const [previous, setPrevious] = useState(basketCourseGroups); const [previous, setPrevious] = useState(basketCourseGroups);
console.log('course is: ', course);
const onGroupClick = (group: Group, courseId: number) => { const onGroupClick = (group: Group, courseId: number) => {
setPrevious((prev) => (group.type === GroupType.CLASS ? { ...prev, classes: group } : { ...prev, lecture: group })); setPrevious((prev) => (group.type === GroupType.CLASS ? { ...prev, classes: group, prev:"classes" } : { ...prev, lecture: group,prev:"lecture" }));
changeGroupInBasket(group, courseId); changeGroupInBasket(group, courseId);
}; };
@ -188,22 +187,17 @@ export const CourseCard = ({ course }: CourseCardProps) => {
onClick={() => onGroupClick(group, course.id)} onClick={() => onGroupClick(group, course.id)}
onMouseEnter={() => { onMouseEnter={() => {
if (group.type === GroupType.CLASS) { if (group.type === GroupType.CLASS) {
changeGroupInBasket(group, course.id); changeGroupInBasket({classes: group,lecture:previous.lecture}, course.id);
} }
if (group.type === GroupType.LECTURE) { if (group.type === GroupType.LECTURE) {
changeGroupInBasket(group, course.id); changeGroupInBasket({lecture: group,classes:previous.classes}, course.id);
} }
}} }}
onMouseLeave={() => { onMouseLeave={() => {
if (hoveredGroup) { if (hoveredGroup) {
if (hoveredGroup.type === GroupType.CLASS && previous.classes !== undefined) { changeGroupInBasket(previous, course.id);
changeGroupInBasket(previous.classes, course.id);
}
if (hoveredGroup.type === GroupType.LECTURE && previous.lecture !== undefined) {
changeGroupInBasket(previous.lecture, course.id);
}
changeHoveredGroup(null);
} }
changeHoveredGroup(null);
}} }}
> >
<StyledGroupType groupType={group.type}>{group.type === 'CLASS' ? 'ĆW' : 'WYK'}</StyledGroupType> <StyledGroupType groupType={group.type}>{group.type === 'CLASS' ? 'ĆW' : 'WYK'}</StyledGroupType>

View File

@ -1,10 +1,14 @@
import React, { useState, MouseEvent } from 'react'; import React, { useState, MouseEvent,useContext } from 'react';
import styled from 'styled-components/macro'; import styled from 'styled-components/macro';
import Plan from '../assets/plan.svg'; import Plan from '../assets/plan.svg';
import History from '../assets/history.svg'; import History from '../assets/history.svg';
import Statistics from '../assets/statistics.svg'; import StatisticsIcon from '../assets/statistics.svg';
import { Statistics } from './Statistics';
import { Scheduler } from './Scheduler'; import { Scheduler } from './Scheduler';
import { Rightbar } from './Rightbar'; import { Rightbar } from './Rightbar';
import { SchedulerHistory } from './SchedulerHistory';
import { coursesContext } from '../contexts/CoursesProvider';
import { SchedulerEvent } from '../types';
const LeftSide = styled.div` const LeftSide = styled.div`
height: 100%; height: 100%;
@ -13,7 +17,7 @@ const LeftSide = styled.div`
flex-direction: column; flex-direction: column;
background-color: white; background-color: white;
text-align: center; text-align: center;
border-radius:5px; border-radius: 5px;
`; `;
const Wrap = styled.div` const Wrap = styled.div`
@ -45,11 +49,11 @@ const LeftPanelElement = styled.div<LeftPanelElement>`
cursor: pointer; cursor: pointer;
box-shadow: ${({ isCurrentTab }) => (isCurrentTab === true ? `inset 0px 0px 11px 0px rgba(0,0,0,0.30)` : '')}; box-shadow: ${({ isCurrentTab }) => (isCurrentTab === true ? `inset 0px 0px 11px 0px rgba(0,0,0,0.30)` : '')};
border-bottom: 1px solid #979797; border-bottom: 1px solid #979797;
:first-child{ :first-child {
border-radius:0px 5px 0px 0px; border-radius: 0px 5px 0px 0px;
} }
:last-child{ :last-child {
border-radius:0px 0px 5px 0px; border-radius: 0px 0px 5px 0px;
} }
`; `;
@ -94,11 +98,19 @@ const Icon = styled.img`
margin: 5px; margin: 5px;
`; `;
export const Admin = () => { interface Deanery {
schedulerEvents: Array<SchedulerEvent>;
}
export const Deanery = ({ schedulerEvents }: Deanery) => {
const [currentTab, setCurrentTab] = useState<null | number>(1); const [currentTab, setCurrentTab] = useState<null | number>(1);
const { getNewestStudentTimetable,userID } = useContext(coursesContext)!;
const { selectHistorySchedulerEvents } = useContext(coursesContext)!;
const schedulerHistoryEvents = selectHistorySchedulerEvents();
const handleClick = (e: MouseEvent<HTMLDivElement>) => { const handleClick = (e: MouseEvent<HTMLDivElement>) => {
setCurrentTab(Number(e.currentTarget.id)); setCurrentTab(Number(e.currentTarget.id));
getNewestStudentTimetable(userID);
}; };
return ( return (
@ -113,20 +125,20 @@ export const Admin = () => {
Historia Zmian Historia Zmian
</LeftPanelElement> </LeftPanelElement>
<LeftPanelElement id={'3'} isCurrentTab={currentTab === 3} onClick={handleClick}> <LeftPanelElement id={'3'} isCurrentTab={currentTab === 3} onClick={handleClick}>
<Icon alt="statistics" src={Statistics} /> <Icon alt="statistics" src={StatisticsIcon} />
Statystyki Statystyki
</LeftPanelElement> </LeftPanelElement>
</LeftSide> </LeftSide>
<Wrapper> <Wrapper>
{currentTab === 1 ? ( {currentTab === 1 ? (
<> <>
<Scheduler /> <Scheduler schedulerEvents={schedulerEvents}/>
<Rightbar /> <Rightbar />
</> </>
) : currentTab === 2 ? ( ) : currentTab === 2 ? (
<HistoryDiv /> <SchedulerHistory schedulerHistoryEvents={schedulerHistoryEvents}/>
) : currentTab === 3 ? ( ) : currentTab === 3 ? (
<StatsDiv /> <StatsDiv><Statistics/></StatsDiv>
) : ( ) : (
<LogoWrapper> <LogoWrapper>
<Logo alt="logo" src="https://plannaplan.pl/img/logo.svg" /> <Logo alt="logo" src="https://plannaplan.pl/img/logo.svg" />

View File

@ -50,7 +50,7 @@ interface DropdownProps {
} }
export const Dropdown = ({ open, input, handleCloseDropdown, selectedOption }: DropdownProps) => { export const Dropdown = ({ open, input, handleCloseDropdown, selectedOption }: DropdownProps) => {
const { courses, selectBasketNames, addCourseToBasket, changeStudent } = useContext(coursesContext)!; const { courses, selectBasketNames, addCourseToBasket, changeStudent, getStudentTimetablesHistory } = useContext(coursesContext)!;
const { students, changeSelectedStudent } = useContext(studentsContext)!; const { students, changeSelectedStudent } = useContext(studentsContext)!;
const basketNames = useMemo(() => selectBasketNames(), [selectBasketNames]); const basketNames = useMemo(() => selectBasketNames(), [selectBasketNames]);
const [filteredCourses, setFilteredCourses] = useState<Array<Course>>([]); const [filteredCourses, setFilteredCourses] = useState<Array<Course>>([]);
@ -67,10 +67,10 @@ export const Dropdown = ({ open, input, handleCloseDropdown, selectedOption }: D
const onUserClick = (event: MouseEvent) => { const onUserClick = (event: MouseEvent) => {
const target = event.currentTarget; const target = event.currentTarget;
console.log('target: ', target);
//to be moved to students provider //to be moved to students provider
changeStudent(target.id); changeStudent(target.id);
changeSelectedStudent(Number(target.id)); changeSelectedStudent(Number(target.id));
handleCloseDropdown(); handleCloseDropdown();
}; };
@ -105,7 +105,8 @@ export const Dropdown = ({ open, input, handleCloseDropdown, selectedOption }: D
input input
.toLowerCase() .toLowerCase()
.normalize('NFD') .normalize('NFD')
.replace(/[\u0300-\u036f]/g, ''), .replace(/[\u0300-\u036f]/g, '')
.replace(/\s/g, ''),
), ),
); );
setFilteredStudents(filteredUsers); setFilteredStudents(filteredUsers);
@ -119,9 +120,10 @@ export const Dropdown = ({ open, input, handleCloseDropdown, selectedOption }: D
<> <>
{selectedOption === 'studenci' ? ( {selectedOption === 'studenci' ? (
<div> <div>
{filteredStudents.map(({ email, id }, index) => ( {filteredStudents.map(({ surname, name, email, id }, index) => (
<CourseContainer key={index} id={id.toString()} onClick={onUserClick}> <CourseContainer key={index} id={id.toString()} onClick={onUserClick}>
<p>{email}</p> {name=== ''? <p>{email}</p> :<p>{name} {surname}</p>}
</CourseContainer> </CourseContainer>
))} ))}
</div> </div>

View File

@ -0,0 +1,111 @@
import React, { useState, useContext, useEffect, MouseEvent, useMemo } from 'react';
import { coursesContext } from '../contexts/CoursesProvider';
import { studentsContext } from '../contexts/StudentsProvider';
import { Course, Student } from '../types';
import styled from 'styled-components';
const DropdownContainer = styled.div`
position: relative;
z-index: 99999999;
max-height: 396px;
border-radius: 3px;
overflow-y: auto;
opacity: 0.97;
box-shadow: 0.05em 0.2em 0.6em rgba(0, 0, 0, 0.2);
scroll-snap-type: y mandatory;
scroll-behavior: smooth;
::-webkit-scrollbar-track {
background-color: #f2f4f7;
border-radius: 10px;
}
::-webkit-scrollbar {
background-color: #f2f4f7;
width: 5px;
border-style: none;
}
::-webkit-scrollbar-thumb {
border-radius: 10px;
background-color: #4b4b4b;
}
`;
const CourseContainer = styled.div`
padding: 5px;
padding-left: 20px;
background-color: #f2f4f7;
font-size: 16px;
font-weight: 500;
scroll-snap-align: end;
:hover {
background-color: #eceef4;
cursor: pointer;
}
`;
interface DropdownProps {
open: boolean;
input: string;
handleCloseDropdown: () => void;
handleSelectedGroupChange: (event: React.ChangeEvent<{ value: unknown }>) => void;
selectedOption: string;
}
export const DropdownModal = ({
open,
input,
handleCloseDropdown,
selectedOption,
handleSelectedGroupChange,
}: DropdownProps) => {
const { courses, selectBasketNames } = useContext(coursesContext)!;
const basketNames = useMemo(() => selectBasketNames(), [selectBasketNames]);
const [filteredCourses, setFilteredCourses] = useState<Array<Course>>([]);
const onCourseClick = (event: MouseEvent) => {
const target = event.currentTarget;
if (target.id && target.textContent) {
const course = filteredCourses.find(({ id }) => id.toString() === target.id)!;
handleSelectedGroupChange((course as unknown) as any);
handleCloseDropdown();
}
};
useEffect(() => {
const filterCourses = (input: string) => {
const filteredCourses = courses.filter(
({ name }) =>
name
.toLowerCase()
.normalize('NFD')
.replace(/[\u0300-\u036f]/g, '')
.includes(
input
.toLowerCase()
.normalize('NFD')
.replace(/[\u0300-\u036f]/g, ''),
) && !basketNames.includes(name),
);
setFilteredCourses(filteredCourses);
};
filterCourses(input);
}, [basketNames, courses, input]);
return (
<DropdownContainer>
{open && (
<>
{
<div>
{filteredCourses.map(({ name, id }, index) => (
<CourseContainer key={index} id={id.toString()} onClick={onCourseClick}>
<p>{name} </p>
</CourseContainer>
))}
</div>
}
</>
)}
</DropdownContainer>
);
};

View File

@ -3,6 +3,7 @@ import { CourseCard } from './CourseCard';
import { coursesContext } from '../contexts/CoursesProvider'; import { coursesContext } from '../contexts/CoursesProvider';
import styled from 'styled-components'; import styled from 'styled-components';
import { debounce } from '../utils/index'; import { debounce } from '../utils/index';
import { SyncLoader } from 'react-spinners';
const RightbarWrapper = styled.div` const RightbarWrapper = styled.div`
padding: 15px; padding: 15px;
@ -37,24 +38,22 @@ const SaveButton = styled.div`
margin-bottom: 10px; margin-bottom: 10px;
&:hover { &:hover {
color: #ffffff; color: #ffffff;
box-shadow: 0px 5px 4px 0px rgba(0, 0, 0, 0.24);
} }
&:active { &:active {
background-color: #54c457; background-color: #54c457;
} }
box-shadow: 3px 3px 3px 0px rgba(0, 0, 0, 0.75); box-shadow: 3px 3px 5px 0px rgba(189,189,189,1);
`; `;
export const Rightbar = () => { export const Rightbar = () => {
const { selectBasketCourses, saveBasket, userID } = useContext(coursesContext)!; const { selectBasketCourses, saveBasket, userID, isSavingLoading } = useContext(coursesContext)!;
const basketCourses = selectBasketCourses(); const basketCourses = selectBasketCourses();
const handleSave = debounce(() => saveBasket(userID), 500); const handleSave = debounce(() => saveBasket(userID), 500);
return ( return (
<RightbarWrapper> <RightbarWrapper>
<SaveButton onClick={handleSave}>ZAPISZ</SaveButton> <SaveButton onClick={()=> {!isSavingLoading && handleSave() }}> {isSavingLoading ? <SyncLoader size={9}/> : "ZAPISZ"}</SaveButton>
{basketCourses.map((course) => ( {basketCourses.map((course) => (
<CourseCard course={course} key={course.id} /> <CourseCard course={course} key={course.id} />
))} ))}

View File

@ -1,8 +1,11 @@
import React, { useEffect, useLayoutEffect, useRef } from 'react'; import React, { useContext, useLayoutEffect, useRef } from 'react';
import { useState } from 'react'; import { useState } from 'react';
import { SchedulerEvents } from './SchedulerEvents'; import { SchedulerEvents } from './SchedulerEvents';
import { days, hours } from '../constants/index'; import { days, hours } from '../constants/index';
import styled from 'styled-components/macro'; import styled from 'styled-components/macro';
import { SchedulerEvent } from '../types';
import { coursesContext } from '../contexts/CoursesProvider';
import Tooltip from '@material-ui/core/Tooltip';
const SchedulerWrapper = styled.div` const SchedulerWrapper = styled.div`
border-collapse: collapse; border-collapse: collapse;
@ -16,6 +19,7 @@ const SchedulerWrapper = styled.div`
justify-content: center; justify-content: center;
align-items: center; align-items: center;
box-shadow: 3px 3px 3px -2px rgba(0, 0, 0, 0.59); box-shadow: 3px 3px 3px -2px rgba(0, 0, 0, 0.59);
position:relative;
`; `;
const TableBody = styled.div` const TableBody = styled.div`
@ -61,11 +65,37 @@ const TableCell = styled.div<TableCellProps>`
font-weight: bold; font-weight: bold;
`; `;
export const Scheduler = () => { const TourWrapper = styled.div`
display: flex;
justify-content:center;
align-items:center;
position:absolute;
top:8px;
right:8px;
min-width: 10px;
padding: 3px 7px;
font-size: 12px;
font-weight: 700;
color: black;
line-height: 1;
vertical-align: middle;
white-space: nowrap;
text-align: center;
background-color: #FFDC61;
border-radius: 10px;
font-size:18px;
`;
interface SchedulerProps {
schedulerEvents: Array<SchedulerEvent>;
}
export const Scheduler = ({ schedulerEvents }: SchedulerProps) => {
const cellRef = useRef<HTMLDivElement>(null); const cellRef = useRef<HTMLDivElement>(null);
const [cellWidth, setCellWidth] = useState(0); const [cellWidth, setCellWidth] = useState(0);
const [cellHeight, setCellHeight] = useState(0); const [cellHeight, setCellHeight] = useState(0);
const { tour } = useContext(coursesContext)!;
useLayoutEffect(() => { useLayoutEffect(() => {
const handleResize = () => { const handleResize = () => {
if (cellRef.current) { if (cellRef.current) {
@ -123,8 +153,21 @@ export const Scheduler = () => {
)} )}
</TableRow> </TableRow>
))} ))}
<SchedulerEvents cellWidth={cellWidth} cellHeight={cellHeight} /> <SchedulerEvents cellWidth={cellWidth} cellHeight={cellHeight} schedulerEvents={schedulerEvents} />
</TableBody> </TableBody>
<TourWrapper>
<Tooltip title="Pierwsza Tura Zapisów">
<div style={{cursor: 'help'}}>{tour === 'FIRST_TOUR' && '1'}</div>
</Tooltip>
<Tooltip title="Druga Tura Zapisów">
<div style={{cursor: 'help'}}>{tour === 'SECOND_TOUR' && '2'}</div>
</Tooltip>
<Tooltip title="Zapisywanie wyłączone">
<div style={{cursor: 'help'}}>{tour === 'NO_TOUR' && 'X'}</div>
</Tooltip>
</TourWrapper>
</SchedulerWrapper> </SchedulerWrapper>
); );
}; };

View File

@ -3,15 +3,15 @@ import { SchedulerRow } from './SchedulerRow';
import { coursesContext } from '../contexts/CoursesProvider'; import { coursesContext } from '../contexts/CoursesProvider';
import { selectGroupsToShow } from '../utils/index'; import { selectGroupsToShow } from '../utils/index';
import { ROWS_COUNT } from '../constants'; import { ROWS_COUNT } from '../constants';
import { SchedulerEvent } from '../types';
interface SchedulerEventsProps { interface SchedulerEventsProps {
cellWidth: number; cellWidth: number;
cellHeight: number; cellHeight: number;
schedulerEvents: Array<SchedulerEvent>;
} }
export const SchedulerEvents = ({ cellWidth, cellHeight }: SchedulerEventsProps) => { export const SchedulerEvents = ({ cellWidth, cellHeight,schedulerEvents }: SchedulerEventsProps) => {
const { selectSchedulerEvents } = useContext(coursesContext)!;
const schedulerEvents = selectSchedulerEvents();
return ( return (
<div> <div>

View File

@ -0,0 +1,54 @@
import React, { useContext, useEffect, useState } from 'react';
import styled from 'styled-components';
import { coursesContext } from '../contexts/CoursesProvider';
import { SchedulerEvent } from '../types';
import { Scheduler } from './Scheduler';
import { SchedulerHistoryNavigation } from './SchedulerHistoryNavigation';
const Wrapper = styled.div`
display: flex;
flex-direction: column;
width: 100%;
`;
interface SchedulerHistoryProps {
schedulerHistoryEvents: Array<SchedulerEvent>;
}
export const SchedulerHistory = ({schedulerHistoryEvents}:SchedulerHistoryProps) => {
const { timetableHistory, setHistoryBasketFromHistoryGroups } = useContext(coursesContext)!;
const [currentTimetable, setCurrentTimetable] = useState(timetableHistory.length===0 ? 0 : timetableHistory.length - 1);
let commisionDate = timetableHistory[currentTimetable]?.commisionDate;
const SubstractCurrentTimetable = (value: number) => {
if (currentTimetable > 0) {
setCurrentTimetable((currentTimetable) => currentTimetable + value);
}
};
const AddCurrentTimetable = (value: number) => {
if (currentTimetable < timetableHistory.length - 1) {
setCurrentTimetable((currentTimetable) => currentTimetable + value);
}
};
useEffect(() => {
const timetable = timetableHistory[currentTimetable];
if (timetable) {
const { groups } = timetable;
setHistoryBasketFromHistoryGroups(groups);
}
else{
setHistoryBasketFromHistoryGroups([]);
}
}, [currentTimetable,timetableHistory]);
return (
<Wrapper>
{timetableHistory.length > 0 && (
<SchedulerHistoryNavigation commisionDate={commisionDate} SubstractCurrentTimetable={SubstractCurrentTimetable} AddCurrentTimetable={AddCurrentTimetable} />
)}
<Scheduler schedulerEvents={schedulerHistoryEvents}/>
</Wrapper>
);
};

View File

@ -0,0 +1,89 @@
import React, { useContext } from 'react';
import styled from 'styled-components';
import { coursesContext } from '../contexts/CoursesProvider';
import RightArrow from '../assets/right-arrow.svg';
import LeftArrow from '../assets/left-arrow.svg';
type ButtonProps = {
direction: 'left' | 'right';
};
const Wrapper = styled.div`
display: flex;
justify-content: center;
align-items: center;
margin-top:-15px;
`;
const StyledButton = styled.div<ButtonProps>`
cursor:pointer;
user-select: none;
margin:10px;
border-radius:5px;
border-radius: 15px;
background-color: #9ed3ff;
border: 2px solid white;
min-width: 45px;
color: black;
display:flex;
align-items:center;
justify-content:center;
padding: 12px;
:hover{
background-color:#85c8ff;
}
transition: color 0.3s, background-color 0.3s;
`;
const StyledArrow = styled.img`
width:20px;
`;
const StyledDate = styled.div`
user-select: none;
margin:10px;
border-radius:5px;
border-radius: 15px;
background-color: #FFDC61;
border: 2px solid white;
min-width: 45px;
text-align:center;
color: black;
padding: 10px;
`;
type SchedulerHistoryNavigationProps = {
commisionDate?: Date;
SubstractCurrentTimetable: (value: number) => void;
AddCurrentTimetable: (value: number) => void;
};
export const SchedulerHistoryNavigation = ({
commisionDate,
SubstractCurrentTimetable,
AddCurrentTimetable,
}: SchedulerHistoryNavigationProps) => {
return (
<Wrapper>
<StyledButton
direction="left"
onClick={() => {
SubstractCurrentTimetable(-1);
}}
>
<StyledArrow src={LeftArrow}></StyledArrow>
</StyledButton>
<StyledDate>{commisionDate}</StyledDate>
<StyledButton
direction="right"
onClick={() => {
AddCurrentTimetable(1);
}}
>
<StyledArrow src={RightArrow}></StyledArrow>
</StyledButton>
</Wrapper>
);
};

View File

@ -5,6 +5,7 @@ import Popover from '@material-ui/core/Popover';
import { makeStyles, createStyles, Theme } from '@material-ui/core/styles'; import { makeStyles, createStyles, Theme } from '@material-ui/core/styles';
import { MONDAY_TO_FRIDAY } from '../constants'; import { MONDAY_TO_FRIDAY } from '../constants';
import { coursesContext } from '../contexts/CoursesProvider'; import { coursesContext } from '../contexts/CoursesProvider';
import TickIcon from '../assets/tick.svg';
const useStyles = makeStyles((theme: Theme) => const useStyles = makeStyles((theme: Theme) =>
createStyles({ createStyles({
@ -57,7 +58,7 @@ const StyledSchedulerEvent = styled.div<SchedulerEventProps>`
z-index: 20000; z-index: 20000;
font-size: 0.65vw; font-size: 0.65vw;
line-height: normal; line-height: normal;
border-radius: 10px; border-radius: 2px;
height: ${({ cellHeight }) => cellHeight * 3}px; height: ${({ cellHeight }) => cellHeight * 3}px;
width: ${({ cellWidth }) => (cellWidth * 3) / 4}px; width: ${({ cellWidth }) => (cellWidth * 3) / 4}px;
margin-right: 5px; margin-right: 5px;
@ -75,8 +76,10 @@ const StyledSchedulerEvent = styled.div<SchedulerEventProps>`
css` css`
transition: background-color ease-in 0.4s; transition: background-color ease-in 0.4s;
`} `}
transition: background-color ease-out 0.4s; transition: background-color ease-out 0.4s;
box-shadow: 3px 3px 3px 0px rgba(0, 0, 0, 0.75); box-shadow: 3px 3px 5px 0px rgba(189,189,189,1);
cursor: pointer; cursor: pointer;
`; `;
@ -125,6 +128,13 @@ interface SchedulerRowProps {
cellHeight: number; cellHeight: number;
} }
const Icon = styled.img`
width: 15px;
position:absolute;
top:5px;
left:15px;
`;
const getGroupsPerDay = (groups: Array<SchedulerEvent>) => { const getGroupsPerDay = (groups: Array<SchedulerEvent>) => {
const groupsPerDay: any = { 0: 0, 1: 0, 2: 0, 3: 0, 4: 0 }; const groupsPerDay: any = { 0: 0, 1: 0, 2: 0, 3: 0, 4: 0 };
for (const group of groups) { for (const group of groups) {
@ -146,14 +156,10 @@ export const SchedulerRow = ({ groups, indexRow, rowTop, cellWidth, cellHeight }
}; };
const handlePopoverClose = (e: MouseEvent<any>) => { const handlePopoverClose = (e: MouseEvent<any>) => {
console.log('current target:', e.currentTarget);
console.log(' target:', e.target);
setPopoverId(null); setPopoverId(null);
setAnchorEl(null); setAnchorEl(null);
console.log('click awayyy');
}; };
useEffect(() => { useEffect(() => {
console.log('anchorEl: ', anchorEl);
}, [anchorEl]); }, [anchorEl]);
const open = Boolean(anchorEl); const open = Boolean(anchorEl);
const id = open ? 'simple-popover' : undefined; const id = open ? 'simple-popover' : undefined;
@ -189,13 +195,16 @@ export const SchedulerRow = ({ groups, indexRow, rowTop, cellWidth, cellHeight }
<BoldParagraph isThree={groupsPerDay[group.day] >= 3}>{groups[index].name}</BoldParagraph> <BoldParagraph isThree={groupsPerDay[group.day] >= 3}>{groups[index].name}</BoldParagraph>
{groupsPerDay[group.day] < 3 ? ( {groupsPerDay[group.day] < 3 ? (
<TextWrapper> <TextWrapper>
{groups[index].isAccepted===true && <Icon alt="transfer" src={TickIcon} />}
<div>{`${groups[index].time}-${groups[index].endTime}`}</div> <div>{`${groups[index].time}-${groups[index].endTime}`}</div>
<div> <div>
{groups[index].takenPlaces}/{groups[index].capacity} {groups[index].takenPlaces}/{groups[index].capacity}
</div> </div>
</TextWrapper> </TextWrapper>
) : ( ) : (
<TextWrapper style={{ flexDirection: 'column' }}> <TextWrapper style={{ flexDirection: 'column' }}>
{groups[index].isAccepted===true && <Icon alt="transfer" src={TickIcon} />}
<div style={{ alignSelf: 'flex-end' }}> <div style={{ alignSelf: 'flex-end' }}>
{groups[index].takenPlaces}/{groups[index].capacity} {groups[index].takenPlaces}/{groups[index].capacity}
</div> </div>
@ -231,14 +240,15 @@ export const SchedulerRow = ({ groups, indexRow, rowTop, cellWidth, cellHeight }
<PopoverSpan>Sala zajęć</PopoverSpan>: {groups[index].room} <PopoverSpan>Sala zajęć</PopoverSpan>: {groups[index].room}
</p> </p>
<p style={{ margin: '2px 0 2px 0' }}> <p style={{ margin: '2px 0 2px 0' }}>
<PopoverSpan>Kod przedmiotu: </PopoverSpan>ACB129 <PopoverSpan>Kod przedmiotu: </PopoverSpan> {groups[index].symbol}
</p> </p>
<p style={{ margin: '2px 0 2px 0' }}> <p style={{ margin: '2px 0 2px 0' }}>
<PopoverSpan>Kod grupy: </PopoverSpan>FVJ753 <PopoverSpan>Numer grupy: </PopoverSpan> {groups[index].grNr}
</p>
<p style={{ margin: '2px 0 2px 0' }}>
<PopoverSpan>Punkty ECTS:</PopoverSpan> 2
</p> </p>
<p style={{ margin: '2px 0 2px 0', color:"green"}}>
<b>{groups[index].isAccepted===true && "Przedmiot został zaakceptowany"}</b>
</p>
</div> </div>
</Popover> </Popover>
</Fragment> </Fragment>

View File

@ -24,6 +24,7 @@ const Wrapper = styled.div`
border-top-left-radius: 6px; border-top-left-radius: 6px;
border-bottom-left-radius: 6px; border-bottom-left-radius: 6px;
user-select: none; user-select: none;
z-index:100;
`; `;
const Header = styled.div` const Header = styled.div`
display: flex; display: flex;
@ -84,7 +85,6 @@ export const SelectMenu = ({changeSelectedOption,changeDropdownOpen, selectedOpt
<Wrapper onClick={() => {changeDropdownOpen(false)}}> <Wrapper onClick={() => {changeDropdownOpen(false)}}>
<Header <Header
onClick={() => { onClick={() => {
console.log('clicked');
setIsOpen(!isOpen); setIsOpen(!isOpen);
}} }}
> >

View File

@ -0,0 +1,170 @@
import React, { useState, useContext, useEffect } from 'react';
import Collapse from '@material-ui/core/Collapse';
import { ReactComponent as Expand } from '../assets/expand.svg';
import { Course, Group, GroupType } from '../types/index';
import { coursesContext } from '../contexts/CoursesProvider';
import styled, { css } from 'styled-components';
import { makeStyles } from '@material-ui/core/styles';
import DeleteIcon from '@material-ui/icons/Delete';
import { useMemo } from 'react';
import { dayMapping } from '../constants';
import { axiosInstance } from '../utils/axiosInstance';
import { SyncLoader } from 'react-spinners';
const StatisticsWrapper = styled.div`
display: flex;
flex-direction: column;
width: 100%;
justify-content: center;
align-items: center;
`;
const Row = styled.div`
display: flex;
width: 100%;
justify-content: center;
align-items: center;
`;
const StatisticBox = styled.div`
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
z-index: 20000;
font-size: 0.65vw;
line-height: normal;
border-radius: 2px;
width: 200px;
height: 200px;
margin: 5px;
padding: 5px 5px 0 5px;
text-align: center;
background-color: #ffe485;
box-shadow: 3px 3px 5px 0px rgba(189, 189, 189, 1);
`;
const StatisticNumber = styled.p`
font-size: 52px;
margin-top: 40px;
margin-bottom: 0px;
`;
const StatisticText = styled.p`
font-size: 18px;
text-align: center;
align-items: center;
justify-content: center;
`;
export const Statistics = () => {
const [createdGroupsNumber, setCreatedGroupsNumber] = useState('');
const [fullGroupsNumber, setFullGroupsNumber] = useState('');
const [registeredStudentsNumber, setRegisteredStudentsNumber] = useState('');
const [notRegisteredStudentsNumber, setNotRegisteredStudentsNumber] = useState('');
const [acceptedStudentsNumber, setAcceptedStudentsNumber] = useState('');
const [partlyAcceptedStudentsNumber, setPartlyAcceptedStudentsNumber] = useState('');
const [loaded, setLoaded] = useState(false);
const getCreatedGroupsNumber = async () => {
try {
const { data } = await axiosInstance.get(`${process.env.REACT_APP_API_URL}/api/v1/statistics/groups/created`);
setCreatedGroupsNumber(data.ammount);
} catch (e) {
console.log(e);
}
};
const getFullGroupsNumber = async () => {
try {
const { data } = await axiosInstance.get(`${process.env.REACT_APP_API_URL}/api/v1/statistics/groups/full`);
setFullGroupsNumber(data.ammount);
} catch (e) {
console.log(e);
}
};
const getRegisteredStudentsNumber = async () => {
try {
const { data } = await axiosInstance.get(`${process.env.REACT_APP_API_URL}/api/v1/statistics/groups/full`);
setRegisteredStudentsNumber(data.ammount);
} catch (e) {
console.log(e);
}
};
const getNotRegisteredStudentsNumber = async () => {
try {
const { data } = await axiosInstance.get(`${process.env.REACT_APP_API_URL}/api/v1/statistics/groups/full`);
setNotRegisteredStudentsNumber(data.ammount);
} catch (e) {
console.log(e);
}
};
const getAcceptedStudentsNumber = async () => {
try {
const { data } = await axiosInstance.get(`${process.env.REACT_APP_API_URL}/api/v1/statistics/groups/full`);
setAcceptedStudentsNumber(data.ammount);
} catch (e) {
console.log(e);
}
};
const getPartlyAcceptedStudentsNumber = async () => {
try {
const { data } = await axiosInstance.get(`${process.env.REACT_APP_API_URL}/api/v1/statistics/groups/full`);
setPartlyAcceptedStudentsNumber(data.ammount);
} catch (e) {
console.log(e);
}
};
useEffect(() => {
Promise.all([
getCreatedGroupsNumber(),
getFullGroupsNumber(),
getRegisteredStudentsNumber(),
getNotRegisteredStudentsNumber(),
getAcceptedStudentsNumber(),
getPartlyAcceptedStudentsNumber(),
]).then(()=>{setLoaded(true);});
}, []);
return <StatisticsWrapper>{loaded === false ? <SyncLoader />:<><Row>
<StatisticBox>
<StatisticNumber>{createdGroupsNumber}</StatisticNumber>
<StatisticText>Utworzonych grup</StatisticText>
</StatisticBox>
<StatisticBox>
{' '}
<StatisticNumber>{registeredStudentsNumber}</StatisticNumber>
<StatisticText>Zapisanych studentów do grup</StatisticText>
</StatisticBox>
<StatisticBox>
{' '}
<StatisticNumber>{notRegisteredStudentsNumber}</StatisticNumber>
<StatisticText>Studentów niezapisanych do żadnej grupy</StatisticText>
</StatisticBox>
</Row>
<Row>
<StatisticBox>
{' '}
<StatisticNumber>{acceptedStudentsNumber}</StatisticNumber>
<StatisticText>Studentów z zaakceptowanym planem</StatisticText>
</StatisticBox>
<StatisticBox>
{' '}
<StatisticNumber>{partlyAcceptedStudentsNumber}</StatisticNumber>
<StatisticText>Studentów bez zaakceptowanego pełengo planu</StatisticText>
</StatisticBox>
<StatisticBox>
{' '}
<StatisticNumber>{fullGroupsNumber}</StatisticNumber>
<StatisticText>Grup z zajętymi wszystkimi miejscami</StatisticText>
</StatisticBox>
</Row></>}
</StatisticsWrapper>;
};

View File

@ -1,6 +1,7 @@
import React, { useState, MouseEvent, ChangeEvent, useEffect, useCallback, useContext, useRef } from 'react'; import React, { useState, MouseEvent, ChangeEvent, useEffect, useCallback, useContext, useRef } from 'react';
import { ReactComponent as Close } from '../assets/close.svg'; import { ReactComponent as Close } from '../assets/close.svg';
import ProfileIcon from '../assets/account.svg'; import LogoutIcon from '../assets/logout.svg';
import TransferIcon from '../assets/transfer.svg';
import { Profile } from './Profile'; import { Profile } from './Profile';
import { Dropdown } from './Dropdown'; import { Dropdown } from './Dropdown';
import styled from 'styled-components/macro'; import styled from 'styled-components/macro';
@ -8,7 +9,8 @@ import ClickAwayListener from 'react-click-away-listener';
import { SelectMenu } from './SelectMenu'; import { SelectMenu } from './SelectMenu';
import { studentsContext } from '../contexts/StudentsProvider'; import { studentsContext } from '../contexts/StudentsProvider';
import { CASContext } from '../contexts/CASProvider'; import { CASContext } from '../contexts/CASProvider';
import { render } from 'react-dom'; import Tooltip from '@material-ui/core/Tooltip';
import LogoPlanNaPlan from '../assets/logo.svg';
const Topbar = styled.div` const Topbar = styled.div`
background-color: #e3e5ed; background-color: #e3e5ed;
@ -113,7 +115,7 @@ const IconWrapper = styled.div`
const Icon = styled.img` const Icon = styled.img`
width: 40px; width: 40px;
margin: 5px; margin-left: 40px;
cursor: pointer; cursor: pointer;
@media only screen and (max-width: 670px) { @media only screen and (max-width: 670px) {
width: 35px; width: 35px;
@ -137,6 +139,7 @@ interface TopbarProps {
} }
export default function ({ handleTransfer }: TopbarProps) { export default function ({ handleTransfer }: TopbarProps) {
const { logout } = useContext(CASContext)!;
const { selectedStudent } = useContext(studentsContext)!; const { selectedStudent } = useContext(studentsContext)!;
const { role } = useContext(CASContext)!; const { role } = useContext(CASContext)!;
const [clearInput, setClearInput] = useState(false); const [clearInput, setClearInput] = useState(false);
@ -173,10 +176,12 @@ export default function ({ handleTransfer }: TopbarProps) {
} }
}, [clearInput, handleClearInput]); }, [clearInput, handleClearInput]);
const userPrivilige = localStorage.getItem('userPrivilige');
return ( return (
<Topbar> <Topbar>
<LogoWrapper> <LogoWrapper>
<Logo alt="logo" src="https://plannaplan.pl/img/logo.svg" /> <Logo alt="logo" src={LogoPlanNaPlan} />
<Text> plan na plan </Text> <Text> plan na plan </Text>
</LogoWrapper> </LogoWrapper>
<FlexboxColumn> <FlexboxColumn>
@ -210,13 +215,19 @@ export default function ({ handleTransfer }: TopbarProps) {
</ClickAwayListener> </ClickAwayListener>
</FlexboxColumn> </FlexboxColumn>
<IconWrapper> <IconWrapper>
<SelectedStudent>{selectedStudent?.email.replace(/@st.amu.edu.pl/, '')}</SelectedStudent> <SelectedStudent>{selectedStudent?.surname === '' ? selectedStudent?.email.replace(/@st.amu.edu.pl/, '') : selectedStudent?.surname}</SelectedStudent>
{/* <Text>Maciej Głowacki</Text> */} {/* <Text>Maciej Głowacki</Text> */}
{/* <Icon alt="transfer" src={Transfer} onClick={handleTransfer} /> */} {userPrivilige === 'STUDENT' && (
<Tooltip title="Wymiana grupami">
<Icon alt="transfer" src={TransferIcon} onClick={handleTransfer} />
</Tooltip>
)}
{/* <Icon alt="change_language" src={isPolish ? EnglishIcon : PolishIcon} onClick={onLangChange} /> */} {/* <Icon alt="change_language" src={isPolish ? EnglishIcon : PolishIcon} onClick={onLangChange} /> */}
<Icon alt="profile" src={ProfileIcon} onClick={handleProfile} /> <Tooltip title="Wyloguj">
<Profile anchorEl={anchorEl} handleClose={handleCloseProfile} /> <Icon alt="logout" src={LogoutIcon} onClick={logout} />
</Tooltip>
{/* <Profile anchorEl={anchorEl} handleClose={handleCloseProfile} /> */}
</IconWrapper> </IconWrapper>
</Topbar> </Topbar>
); );

View File

@ -1,13 +1,22 @@
import React from 'react'; import React, { ChangeEvent, useContext, useEffect, MouseEvent, useState } from 'react';
import Modal from '@material-ui/core/Modal'; import Modal from '@material-ui/core/Modal';
import Fade from '@material-ui/core/Fade'; import Fade from '@material-ui/core/Fade';
import Input from '@material-ui/core/Input';
import { makeStyles } from '@material-ui/core/styles'; import { makeStyles } from '@material-ui/core/styles';
import styled from 'styled-components'; import styled from 'styled-components';
import { FormControl, MenuItem, Select, useControlled, useEventCallback } from '@material-ui/core';
import { axiosInstance } from '../utils/axiosInstance';
import { Group } from '../types';
import { coursesContext } from '../contexts/CoursesProvider';
import { Dropdown } from './Dropdown';
import { DropdownModal } from './DropdownModal';
import { dayMapping } from '../constants';
import TransferIcon from '../assets/switch.svg';
import DeleteIcon from '@material-ui/icons/Delete';
import InformationIcon from '../assets/information.svg';
interface TransferProps { interface TransferProps {
handleClose: (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void; handleClose: (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
isOpen: boolean; isTransferOpen: boolean;
} }
const useStyles = makeStyles({ const useStyles = makeStyles({
@ -21,35 +30,47 @@ const useStyles = makeStyles({
const TransferStyled = styled.div` const TransferStyled = styled.div`
display: flex; display: flex;
flex-direction: column;
flex-direction: row; justify-content: center;
align-items: center;
outline: none; outline: none;
min-width: 35%; min-width: 35%;
height: 70%; height: 70%;
padding-top: 40px; background: white;
background: #006b96;
box-shadow: 0px 0px 0px 4px #006b96;
border: 4px solid #ffc400;
margin: 0 auto; margin: 0 auto;
border-top-left-radius: 5px; border-radius: 5px;
border-bottom-right-radius: 5px; `;
text-transform: uppercase;
letter-spacing: 0.3ch; const BinIcon = styled(DeleteIcon)`
max-width: 30px;
min-width: 30px;
cursor: pointer;
&:hover {
fill: white;
}
`;
const InputWrapper = styled.div`
display: flex;
flex-direction: row;
flex: 1;
margin-top:40px;
`; `;
const TransferGiveStyled = styled.div` const TransferGiveStyled = styled.div`
flex-grow: 1; flex: 1;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
text-transform: uppercase;
`; `;
const TransferReceiveStyled = styled.div` const TransferReceiveStyled = styled.div`
flex-grow: 1; flex: 1;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
text-transform: uppercase;
`; `;
const TransferTextStyled = styled.div` const TransferTextStyled = styled.div`
@ -68,45 +89,323 @@ const TransferInputStyled = styled.div`
font-weight: bold; font-weight: bold;
text-align: center; text-align: center;
} }
text-transform: none;
`; `;
export const Transfer = ({ handleClose, isOpen }: TransferProps) => { const SaveWrapper = styled.div`
margin-top: 40px;
`;
const SaveButton = styled.div`
display: flex;
justify-content: center;
align-items: center;
user-select: none;
background-color: #43a047;
border-radius: 10px;
cursor: pointer;
height: 40px;
width: 150px;
font-size: 12px;
letter-spacing: 0.1ch;
line-height: normal;
&:hover {
color: #ffffff;
}
&:active {
background-color: #54c457;
}
text-transform: uppercase;
box-shadow: 3px 3px 5px 0px rgba(189,189,189,1);
`;
const ExchangesWrapper = styled.div`
flex: 4;
overflow-y: scroll;
width: 100%;
::-webkit-scrollbar-track {
border-radius: 10px;
}
::-webkit-scrollbar {
width: 5px;
border-style: none;
}
::-webkit-scrollbar-thumb {
border-radius: 10px;
background-color: #4b4b4b;
}
border-top: 1px solid #b8b8b8;
`;
const ExchangesRow = styled.div`
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
`;
const Icon = styled.img`
width: 20px;
`;
const Information = styled.img`
width: 35px;
`;
const Exchange = styled.div`
display: flex;
flex-direction: column;
background-color: #b5d2e0;
border-radius: 2px;
width: 280px;
margin: 10px;
display: flex;
align-items: center;
justify-content: center;
padding: 0.5rem;
line-height:2;
`;
const ExchangeTitle = styled.p`
font-size: 16px;
font-weight: bold;
margin:0;
`;
const ExchangeParagraph = styled.p`
font-size: 13px;
color: #1a1a1a;
margin:0;
`;
export const Transfer = ({ handleClose, isTransferOpen }: TransferProps) => {
const { basket, tour, selectBasketCourses } = useContext(coursesContext)!;
// const basketCourseGroups = useMemo(() => selectBasketCourseGroups(course.name), []);
const basketCourses = selectBasketCourses();
const classes = useStyles(); const classes = useStyles();
// const groups = selectGroups();
const [input, setInput] = useState('');
const [open, setOpen] = useState(false);
const [assignmentsClasses, setAssignmentsClasses] = useState<Array<any>>([]);
const [selectedAssignmentsClasses, setSelectedAssignmentsClasses] = useState<any>('');
const [selectedGroup, setSelectedGroup] = useState<any>('');
const [groups, setGroups] = useState<any>([]);
const [exchanges, setExchanges] = useState<any>(null);
const [save, setSave] = useState(false);
// const allGroups
const handleSelectedAssignmentsGroupChange = (event: React.ChangeEvent<{ value: unknown }>) => {
setSelectedAssignmentsClasses(event.target.value as any);
};
const handleGroupsChange = (event: React.ChangeEvent<{ value: unknown }>) => {
setSelectedGroup(event.target.value as any);
};
const handleChange = (event: ChangeEvent<HTMLInputElement>) => setInput(event.target.value);
const handleShowDropdown = () => setOpen(true);
const handleCloseDropdown = () => setOpen(false);
useEffect(() => {
if (selectedAssignmentsClasses) {
const allGroups = basketCourses.filter((el) => el.name === selectedAssignmentsClasses.name);
const allClasses = allGroups[0]?.classes;
if (allClasses) {
const filteredClasses = allClasses.filter((el: any) => {
return el.time !== selectedAssignmentsClasses.time;
});
setGroups(filteredClasses);
}
}
}, [selectedAssignmentsClasses]);
const getExchanges = async () => {
try {
const { data } = await axiosInstance.get(`${process.env.REACT_APP_API_URL}/api/v1/exchanges/exchange/all`);
setExchanges(data);
} catch (e) {
console.log(e);
}
};
useEffect(() => {
const getAssignmentsGroups = async () => {
try {
const { data } = await axiosInstance.get(`${process.env.REACT_APP_API_URL}/api/v1/commisions/user/assignments`);
const classes = data.filter((el: any) => el.type === 'CLASS');
setAssignmentsClasses(classes);
} catch (e) {
console.log(e);
}
};
getExchanges();
getAssignmentsGroups();
}, [isTransferOpen, save]);
const createExchange = async (groupsIds: Array<number>) => {
try {
const response = await axiosInstance.post(
`${process.env.REACT_APP_API_URL}/api/v1/exchanges/exchange`,
JSON.stringify({ assignment: groupsIds[0], group: groupsIds[1] }),
);
} catch (e) {
console.log(e);
}
setSelectedGroup('');
setSelectedAssignmentsClasses('');
setSave(!save);
};
const deleteExchange = async (id: number) => {
try {
const response = await axiosInstance.delete(`${process.env.REACT_APP_API_URL}/api/v1/exchanges/exchange/${id}`);
getExchanges();
} catch (e) {
console.log(e);
}
};
return ( return (
<div> <div>
<Modal <Modal
className={classes.wrapper} className={classes.wrapper}
open={isOpen} open={isTransferOpen}
onClose={handleClose} onClose={handleClose}
aria-labelledby="simple-modal-title" aria-labelledby="simple-modal-title"
aria-describedby="simple-modal-description" aria-describedby="simple-modal-description"
> >
<Fade in={isOpen}> <Fade in={isTransferOpen}>
<TransferStyled> {tour === 'FIRST_TOUR' ? (
<TransferGiveStyled> <TransferStyled>
<TransferTextStyled>Oddam</TransferTextStyled> <Information src={InformationIcon}></Information>
<TransferInputStyled> <p>Wymiana przedmiotami jest dostępna dopiero podczas drugiej tury</p>
{' '} <p>Wymianie podlegają tylko zaakceptowane grupy przedmiotów</p>
<Input <p>Wymiana grupami odbywa się tylko w obrębie danego przedmiotu</p></TransferStyled>
placeholder="Wyszukaj..." ) : (
inputProps={{ 'aria-label': 'description' }} <TransferStyled>
className="top-bar__input-field" <InputWrapper>
/> <TransferGiveStyled>
</TransferInputStyled> <TransferTextStyled>Oddam</TransferTextStyled>
</TransferGiveStyled> <TransferInputStyled>
<TransferReceiveStyled> <FormControl>
<TransferTextStyled>Przyjmę</TransferTextStyled> <Select
<TransferInputStyled> labelId="demo-simple-select-label"
{' '} id="assignments-groups"
<Input value={selectedAssignmentsClasses}
placeholder="Wyszukaj..." onChange={handleSelectedAssignmentsGroupChange}
inputProps={{ 'aria-label': 'description' }} placeholder="Wyszukaj..."
className="top-bar__input-field" style={{ width: '200px' }}
/> >
</TransferInputStyled> {assignmentsClasses.map((el: any, index: number) => {
</TransferReceiveStyled> return (
</TransferStyled> <MenuItem
key={index}
value={el}
style={{
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
textAlign: 'center',
}}
>
{`${el.name} `}
<br></br>
{`(${dayMapping[el.day]} ${el.time} - ${el.endTime})`}
</MenuItem>
);
})}
</Select>
</FormControl>
</TransferInputStyled>
</TransferGiveStyled>
<SaveWrapper>
{' '}
<SaveButton
onClick={() => {
createExchange([selectedAssignmentsClasses.id, selectedGroup.id]);
}}
>
Zaproponuj wymianę
</SaveButton>
</SaveWrapper>
<TransferReceiveStyled>
<TransferTextStyled>Przyjmę</TransferTextStyled>
<TransferInputStyled>
<FormControl disabled={selectedAssignmentsClasses ? false : true}>
<Select
labelId="demo-simple-select-label"
id="assignments-groups"
value={selectedGroup}
onChange={handleGroupsChange}
placeholder="Wyszukaj..."
style={{ width: '200px' }}
>
{groups.map((el: any, index: number) => {
return (
<MenuItem
key={index}
value={el}
style={{
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
textAlign: 'center',
}}
>
{`${selectedAssignmentsClasses.name} `}
<br></br>
{`(${dayMapping[el.day]} ${el.time} - ${el.endTime})`}
</MenuItem>
);
})}
</Select>
</FormControl>
</TransferInputStyled>
</TransferReceiveStyled>
</InputWrapper>
<ExchangesWrapper>
{exchanges ? (
exchanges.map((name: any, index: number) => (
<ExchangesRow key={index}>
{' '}
<Exchange>
<ExchangeTitle>{name.courseName}</ExchangeTitle>
<ExchangeParagraph>{name.ownedAssignment.lecturer} </ExchangeParagraph>
<ExchangeParagraph> {dayMapping[name.ownedAssignment.day]} </ExchangeParagraph>
<ExchangeParagraph>
{name.ownedAssignment.time} - {name.ownedAssignment.endTime}
</ExchangeParagraph>
</Exchange>
<Icon alt="transfer" src={TransferIcon} />
<Exchange>
<ExchangeTitle>{name.courseName}</ExchangeTitle>
<ExchangeParagraph>{name.desiredGroup.lecturer} </ExchangeParagraph>
<ExchangeParagraph> {dayMapping[name.desiredGroup.day]} </ExchangeParagraph>
<ExchangeParagraph>
{name.desiredGroup.time} - {name.desiredGroup.endTime}
</ExchangeParagraph>
</Exchange>{' '}
<BinIcon
onClick={(e) => {
e.stopPropagation();
const id = Number(e.currentTarget.id);
deleteExchange(id);
}}
id={name.id}
></BinIcon>
</ExchangesRow>
))
) : (
<div></div>
)}
</ExchangesWrapper>
</TransferStyled>
)}
</Fade> </Fade>
</Modal> </Modal>
</div> </div>

View File

@ -0,0 +1,26 @@
import React from 'react';
import { cleanup, fireEvent, waitForElement, screen } from '@testing-library/react';
import '@testing-library/jest-dom/extend-expect';
import { customRender } from '../../customRender';
import Topbar from '../Topbar';
import { Statistics } from '../Statistics';
beforeAll(() => {
delete window.location;
window.location = { replace: jest.fn() };
});
afterAll(() => {
window.location = location;
});
test('renders component', async () => {
customRender(<Statistics/>);
expect(screen.getByText(/Studentów bez zaakceptowanego pełengo planu/i)).toBeInTheDocument();
});
test('renders component', async () => {
customRender(<Statistics/>);
expect(screen.getByText(/Zapisanych sutdentów do grup/i)).toBeInTheDocument();
});

View File

@ -22,20 +22,10 @@ test('input should display default placeholder for student', async () => {
const { getByPlaceholderText, getByText, debug } = customRender(<Topbar handleTransfer={() => {}} />); const { getByPlaceholderText, getByText, debug } = customRender(<Topbar handleTransfer={() => {}} />);
setTimeout(()=>{const input = getByPlaceholderText('Wyszukaj przedmioty...'); setTimeout(()=>{const input = getByPlaceholderText('Wyszukaj przedmioty...');
expect(input).toBeInTheDocument();},2000); expect(input).toBeInTheDocument();},2000);
// fireEvent.change(input, { target: { value: '122' } });
// console.log(debug());
// const textNode = await waitForElement(() => getByText('asdasdsa'));
// console.log(debug());
}); });
test('input should display changed value', async () => { test('input should display changed value', async () => {
const { getByPlaceholderText, getByText, debug } = customRender(<Topbar handleTransfer={() => {}} />); const { getByPlaceholderText, getByText, debug } = customRender(<Topbar handleTransfer={() => {}} />);
setTimeout(()=>{ const input = getByPlaceholderText('Wyszukaj przedmioty...'); setTimeout(()=>{ const input = getByPlaceholderText('Wyszukaj przedmioty...');
fireEvent.change(input, { target: { value: '122' } });expect(input.value).toBe("122");},2000); fireEvent.change(input, { target: { value: '122' } });expect(input.value).toBe("122");},2000);
// console.log(debug());
// console.log(debug());
}); });

View File

@ -1,6 +1,7 @@
import React, { useState, useEffect, createContext, ReactNode } from 'react'; import React, { useState, useEffect, createContext, ReactNode } from 'react';
import { LoggedUser } from '../types'; import { LoggedUser } from '../types';
import { axiosInstance } from '../utils/axiosInstance'; import { axiosInstance, getNewTokens } from '../utils/axiosInstance';
export interface CASContext { export interface CASContext {
user: LoggedUser | undefined; user: LoggedUser | undefined;
@ -36,13 +37,15 @@ export const CASProvider = ({ children }: CASProviderProps) => {
const { data: user } = await axiosInstance.get<LoggedUser & { token: string; refreshToken: string }>( const { data: user } = await axiosInstance.get<LoggedUser & { token: string; refreshToken: string }>(
`${process.env.REACT_APP_API_URL}/token?ticket=${ticket}`, `${process.env.REACT_APP_API_URL}/token?ticket=${ticket}`,
); );
console.log('token response: ', user);
setUser({ authorityRole: user.authorityRole, email: user.email, id: user.id }); setUser({ authorityRole: user.authorityRole, email: user.email, id: user.id });
localStorage.setItem('userToken', user.token); localStorage.setItem('userToken', user.token);
localStorage.setItem('userPrivilige', user.authorityRole); localStorage.setItem('userPrivilige', user.authorityRole);
localStorage.setItem('refreshToken', user.refreshToken); localStorage.setItem('refreshToken', user.refreshToken);
setIsFetchingToken(false); setIsFetchingToken(false);
} }
else{
getNewTokens();
}
const token = localStorage.getItem('userToken'); const token = localStorage.getItem('userToken');
const refreshToken = localStorage.getItem('refreshToken'); const refreshToken = localStorage.getItem('refreshToken');
const role = localStorage.getItem('userPrivilige'); const role = localStorage.getItem('userPrivilige');

View File

@ -1,5 +1,5 @@
import React, { useState, createContext, useEffect, ReactNode } from 'react'; import React, { useState, createContext, useEffect, ReactNode } from 'react';
import { Course, Group, Basket, GroupType, SchedulerEvent } from '../types'; import { Course, Group, Basket, GroupType, SchedulerEvent, TimetableHistory } from '../types';
import { useSnackbar } from 'notistack'; import { useSnackbar } from 'notistack';
import { axiosInstance } from '../utils/axiosInstance'; import { axiosInstance } from '../utils/axiosInstance';
import CloseIcon from '@material-ui/icons/Close'; import CloseIcon from '@material-ui/icons/Close';
@ -16,22 +16,31 @@ const StyledCloseIcon = styled(CloseIcon)`
interface CourseContext { interface CourseContext {
courses: Array<Course>; courses: Array<Course>;
basket: Array<Basket>; basket: Array<Basket>;
timetableHistory: Array<TimetableHistory>;
hoveredGroup: Group | undefined | null; hoveredGroup: Group | undefined | null;
userID: string; userID: string;
isDataLoading: boolean; isDataLoading: boolean;
historyBasket: Array<Basket>;
tour: string;
isSavingLoading: boolean;
getCurrentTour: () => void;
addCourseToBasket: (courses: Course) => void; addCourseToBasket: (courses: Course) => void;
changeHoveredGroup: (group: Group | null) => void; changeHoveredGroup: (group: Group | null) => void;
changeGroupInBasket: (group: Group, courseId: number) => void; changeGroupInBasket: (group: any, courseId: number) => void;
restoreGroupInBasket: (restoreGroup: Group, courseId: number) => void; restoreGroupInBasket: (restoreGroup: Group, courseId: number) => void;
deleteFromBasket: (id: number) => void; deleteFromBasket: (id: number) => void;
saveBasket: (userID: string) => Promise<void>; saveBasket: (userID: string) => Promise<void>;
changeStudent: (studentId: string) => void; changeStudent: (studentId: string) => void;
selectSchedulerEvents: () => Array<SchedulerEvent>; selectSchedulerEvents: () => Array<SchedulerEvent>;
selectHistorySchedulerEvents: () => Array<SchedulerEvent>;
selectBasketNames: () => Array<string>; selectBasketNames: () => Array<string>;
selectBasketCourses: () => Array<Course>; selectBasketCourses: () => Array<Course>;
selectBasketCourseGroups: (courseId: number) => { lecture: Group | undefined; classes: Group | undefined }; selectBasketCourseGroups: (courseName: string) => { lecture: Group | undefined; classes: Group | undefined };
selectGroups: () => Array<Group>;
getNewestStudentTimetable: (studentId: string) => void; getNewestStudentTimetable: (studentId: string) => void;
getStudentTimetablesHistory: (studentId: string) => void;
changeDataLoading: (isLoading: boolean) => void; changeDataLoading: (isLoading: boolean) => void;
setHistoryBasketFromHistoryGroups: (groupsIds: Array<number>) => void;
} }
export const coursesContext = createContext<CourseContext | undefined>(undefined); export const coursesContext = createContext<CourseContext | undefined>(undefined);
@ -46,9 +55,13 @@ export const CoursesProvider = ({ children }: CoursesProviderProps) => {
//fetch courses with groups //fetch courses with groups
const [courses, setCourses] = useState<Array<Course>>([]); const [courses, setCourses] = useState<Array<Course>>([]);
const [basket, setBasket] = useState<Array<Basket>>([]); const [basket, setBasket] = useState<Array<Basket>>([]);
const [historyBasket, setHistoryBasket] = useState<Array<Basket>>([]);
const [timetableHistory, setTimetableHistory] = useState<Array<TimetableHistory>>([]);
const [userID, setUserID] = useState(''); const [userID, setUserID] = useState('');
const [hoveredGroup, setHoveredGroup] = useState<Group | undefined | null>(null); const [hoveredGroup, setHoveredGroup] = useState<Group | undefined | null>(null);
const [isDataLoading, setIsDataLoading] = useState(false); const [isDataLoading, setIsDataLoading] = useState(false);
const [tour, setTour] = useState('');
const [isSavingLoading, setIsSavingLoading] = useState(false);
const selectBasketIds = () => { const selectBasketIds = () => {
const classesIds = basket.map((course) => course?.classes?.id).filter((course) => course !== undefined); const classesIds = basket.map((course) => course?.classes?.id).filter((course) => course !== undefined);
@ -68,22 +81,32 @@ export const CoursesProvider = ({ children }: CoursesProviderProps) => {
const selectSchedulerEvents = () => { const selectSchedulerEvents = () => {
return basket.reduce((res, el) => { return basket.reduce((res, el) => {
const { name, symbol } = el;
if (el.classes) {
res.push({ ...el.classes, name, symbol});
}
if (el.lecture) {
res.push({ ...el.lecture, name, symbol });
}
return res;
}, [] as Array<SchedulerEvent>);
};
const selectHistorySchedulerEvents = () => {
return historyBasket.reduce((res, el) => {
const { name } = el; const { name } = el;
if (el.classes) { if (el.classes) {
console.log('element kurwa is: ', el);
res.push({ ...el.classes, name }); res.push({ ...el.classes, name });
} }
if (el.lecture) { if (el.lecture) {
console.log('element kurwa is: ', el);
res.push({ ...el.lecture, name }); res.push({ ...el.lecture, name });
} }
return res; return res;
}, [] as Array<SchedulerEvent>); }, [] as Array<SchedulerEvent>);
}; };
const selectBasketCourseGroups = (courseId: number) => { const selectBasketCourseGroups = (courseName: string) => {
const course = basket.find(({ id }) => id === courseId); const course = basket.find(({ name }) => name === courseName);
if (course !== undefined) { if (course !== undefined) {
return { lecture: course.lecture, classes: course.classes }; return { lecture: course.lecture, classes: course.classes };
} else { } else {
@ -91,6 +114,11 @@ export const CoursesProvider = ({ children }: CoursesProviderProps) => {
} }
}; };
const selectGroups = () => {
const groups = [];
return (courses as unknown) as Array<Group>;
};
const changeHoveredGroup = (group: Group | null) => setHoveredGroup(group); const changeHoveredGroup = (group: Group | null) => setHoveredGroup(group);
const changeDataLoading = (isLoading: boolean) => setIsDataLoading(isLoading); const changeDataLoading = (isLoading: boolean) => setIsDataLoading(isLoading);
@ -99,6 +127,7 @@ export const CoursesProvider = ({ children }: CoursesProviderProps) => {
const courseToBasket: Basket = { const courseToBasket: Basket = {
name: course.name, name: course.name,
id: course.id, id: course.id,
symbol: course.symbol,
classes: course.classes !== undefined ? course.classes[0] : undefined, classes: course.classes !== undefined ? course.classes[0] : undefined,
lecture: course.lectures !== undefined ? course.lectures[0] : undefined, lecture: course.lectures !== undefined ? course.lectures[0] : undefined,
}; };
@ -111,10 +140,12 @@ export const CoursesProvider = ({ children }: CoursesProviderProps) => {
setUserID(studentId); setUserID(studentId);
setTimeout(() => { setTimeout(() => {
getNewestStudentTimetable(studentId); getNewestStudentTimetable(studentId);
getStudentTimetablesHistory(studentId);
}, 100); }, 100);
}; };
const saveBasket = async (userID: string) => { const saveBasket = async (userID: string) => {
setIsSavingLoading(true);
const basketIds = selectBasketIds(); const basketIds = selectBasketIds();
const action = (key: any) => ( const action = (key: any) => (
<> <>
@ -137,26 +168,28 @@ export const CoursesProvider = ({ children }: CoursesProviderProps) => {
}); });
} catch (e) { } catch (e) {
console.log('error: ', e); console.log('error: ', e);
enqueueSnackbar('Zapisywanie planu nie powiodło się', { enqueueSnackbar('Zapisywanie niemożliwe w czasie bezturowym', {
variant: 'error', variant: 'error',
action, action,
}); });
} }
getStudentTimetablesHistory(userID);
setIsSavingLoading(false);
}; };
const changeGroupInBasket = (choosenGroup: Group, courseId: number) => { const changeGroupInBasket = (choosenGroup: any, courseId: number) => {
const basketCourse = basket.filter((course) => course.id === courseId)[0]; const basketCourse = basket.filter((course) => course.id === courseId)[0];
const { type } = choosenGroup; if (choosenGroup.lecture && choosenGroup.classes) {
if (type === GroupType.CLASS) { const prev = choosenGroup.prev === 'lecture' ? choosenGroup.lecture : choosenGroup.classes;
setBasket( setBasket(
basket.map((basket) => (basket.id === basketCourse.id ? { ...basket, classes: choosenGroup } : basket)), basket.map((basket) =>
); basket.id === basketCourse.id
} else if (type === GroupType.LECTURE) { ? { ...basket, lecture: choosenGroup.lecture, classes: choosenGroup.classes }
setBasket( : basket,
basket.map((basket) => (basket.id === basketCourse.id ? { ...basket, lecture: choosenGroup } : basket)), ),
); );
changeHoveredGroup(prev);
} }
changeHoveredGroup(choosenGroup);
}; };
const restoreGroupInBasket = (restoreGroup: Group, courseId: number) => { const restoreGroupInBasket = (restoreGroup: Group, courseId: number) => {
@ -179,8 +212,6 @@ export const CoursesProvider = ({ children }: CoursesProviderProps) => {
`${process.env.REACT_APP_API_URL}/api/v1/commisions/user/schedule`, `${process.env.REACT_APP_API_URL}/api/v1/commisions/user/schedule`,
); );
const basket = data === '' ? [] : data; const basket = data === '' ? [] : data;
console.log('basket is: ', basket);
console.log('mordo weź');
setBasket(basket); setBasket(basket);
} catch (e) { } catch (e) {
console.log(e); console.log(e);
@ -200,30 +231,76 @@ export const CoursesProvider = ({ children }: CoursesProviderProps) => {
} }
}; };
const getStudentTimetablesHistory = async (studentId: string) => {
try {
const { data } = await axiosInstance.get<Array<TimetableHistory> | []>(
`${process.env.REACT_APP_API_URL}/api/v1/commisions/user/${studentId}?groups=true`,
);
setTimetableHistory(data);
} catch (e) {
console.log(e);
}
};
const fetchCourses = async () => { const fetchCourses = async () => {
try { try {
const { data: courses } = await axiosInstance.get<Array<Course>>( const { data: courses } = await axiosInstance.get<Array<Course>>(
`${process.env.REACT_APP_API_URL}/api/v1/courses/all?groups=true&takenPlaces=true`, `${process.env.REACT_APP_API_URL}/api/v1/courses/all?groups=true&takenPlaces=true`,
); );
const sortedCourses = courses.sort((a, b) => (a.name > b.name ? 1 : -1)); const sortedCourses = courses.sort((a, b) => (a.name > b.name ? 1 : -1));
console.log('sortedCourses: ', sortedCourses);
setCourses(sortedCourses); setCourses(sortedCourses);
} catch (e) { } catch (e) {
console.log(e); console.log(e);
} }
};
const setHistoryBasketFromHistoryGroups = (groupsIds: Array<number>) => {
const basket: Array<Basket> = [];
for (const groupId of groupsIds) {
for (const course of courses) {
const { lectures, classes, name, id } = course;
let basketElement: Basket = { name: name, id: id };
if (lectures) {
for (const lecture of lectures) {
if (groupId === lecture.id) {
basketElement = { ...basketElement, lecture: lecture };
}
}
}
if (classes) {
for (const singleClass of classes) {
if (groupId === singleClass.id) {
basketElement = { ...basketElement, classes: singleClass };
}
}
}
if (basketElement.classes !== undefined || basketElement.lecture !== undefined) {
basket.push(basketElement);
}
}
}
setHistoryBasket(basket);
};
const getCurrentTour = async () => {
try {
const { data } = await axiosInstance.get(`${process.env.REACT_APP_API_URL}/api/v1/configurator/config/tour`);
setTour(data.currentTour);
} catch (e) {
console.log(e);
}
}; };
useEffect(() => { useEffect(() => {
setIsDataLoading(true); setIsDataLoading(true);
setTimeout(() => { setTimeout(() => {
getCurrentTour();
fetchCourses(); fetchCourses();
getNewestTimetable(); getNewestTimetable();
setIsDataLoading(false); setIsDataLoading(false);
}, 600); }, 600);
}, []); }, []);
console.log("123,",userID,courses,basket)
return ( return (
<coursesContext.Provider <coursesContext.Provider
value={{ value={{
@ -231,7 +308,12 @@ export const CoursesProvider = ({ children }: CoursesProviderProps) => {
courses, courses,
basket, basket,
hoveredGroup, hoveredGroup,
timetableHistory,
isDataLoading, isDataLoading,
historyBasket,
tour,
isSavingLoading,
getCurrentTour,
addCourseToBasket, addCourseToBasket,
changeHoveredGroup, changeHoveredGroup,
changeGroupInBasket, changeGroupInBasket,
@ -239,11 +321,15 @@ export const CoursesProvider = ({ children }: CoursesProviderProps) => {
restoreGroupInBasket, restoreGroupInBasket,
saveBasket, saveBasket,
selectSchedulerEvents, selectSchedulerEvents,
selectHistorySchedulerEvents,
selectBasketNames, selectBasketNames,
selectBasketCourses, selectBasketCourses,
selectBasketCourseGroups, selectBasketCourseGroups,
selectGroups,
getNewestStudentTimetable, getNewestStudentTimetable,
changeStudent, changeStudent,
getStudentTimetablesHistory,
setHistoryBasketFromHistoryGroups,
changeDataLoading, changeDataLoading,
}} }}
> >

View File

@ -1,7 +1,6 @@
import React, { useState, createContext, useEffect, ReactNode, useRef, useContext } from 'react'; import React, { useState, createContext, useEffect, ReactNode, useRef, useContext } from 'react';
import { Student } from '../types'; import { Student } from '../types';
import { axiosInstance } from '../utils/axiosInstance'; import { axiosInstance } from '../utils/axiosInstance';
import { CASContext } from './CASProvider';
interface StudentContext { interface StudentContext {
students: Array<Student>; students: Array<Student>;
@ -19,15 +18,12 @@ export const StudentsProvider = ({ children }: StudentsProviderProps) => {
const [students, setStudents] = useState<Array<Student>>([]); const [students, setStudents] = useState<Array<Student>>([]);
const [selectedStudent, setSelectedStudent] = useState<Student | null>(null); const [selectedStudent, setSelectedStudent] = useState<Student | null>(null);
//not working currently
const getStudents = async () => { const getStudents = async () => {
try { try {
const { data } = await axiosInstance.get<Array<Student>>( const { data } = await axiosInstance.get<Array<Student>>(
`${process.env.REACT_APP_API_URL}/api/v1/users/students`, `${process.env.REACT_APP_API_URL}/api/v1/users/students`,
); );
setStudents(data); setStudents(data);
console.log(data);
} catch (e) { } catch (e) {
console.log(e); console.log(e);
} }
@ -40,7 +36,6 @@ export const StudentsProvider = ({ children }: StudentsProviderProps) => {
useEffect(() => { useEffect(() => {
setTimeout(() => { setTimeout(() => {
const userPrivilige = localStorage.getItem('userPrivilige'); const userPrivilige = localStorage.getItem('userPrivilige');
console.log('mordo privilidż: ', userPrivilige);
userPrivilige === 'DEANERY' && getStudents(); userPrivilige === 'DEANERY' && getStudents();
}, 500); }, 500);
}, []); }, []);

View File

@ -6,6 +6,7 @@ export enum GroupType {
export interface Basket { export interface Basket {
id: number; id: number;
name: string; name: string;
symbol?:string;
lecture?: Group; lecture?: Group;
classes?: Group; classes?: Group;
} }
@ -20,11 +21,14 @@ export interface Group {
type: GroupType; type: GroupType;
capacity?: number; capacity?: number;
takenPlaces: number; takenPlaces: number;
isAccepted:boolean;
grNr: number;
} }
export interface Course { export interface Course {
id: number; id: number;
name: string; name: string;
symbol:string;
lectures?: Array<Group>; lectures?: Array<Group>;
classes?: Array<Group>; classes?: Array<Group>;
} }
@ -53,4 +57,24 @@ export interface SchedulerEvent {
capacity?: number; capacity?: number;
takenPlaces: number; takenPlaces: number;
name: string; name: string;
isAccepted:boolean;
grNr?: number;
symbol?:string;
}
export interface TimetableHistory {
commisionDate: Date;
commiter: {
id: number;
name: string;
surname: string;
email: string;
};
groups: Array<number>;
owner: {
id: number;
name: string;
surname: string;
email: string;
};
} }

View File

@ -3,12 +3,13 @@ import axios from 'axios';
export const axiosInstance = axios.create(); export const axiosInstance = axios.create();
//getting new tokens //getting new tokens
const getNewTokens = async () => { export const getNewTokens = async () => {
try { try {
const refreshToken = localStorage.getItem('refreshToken'); const refreshToken = localStorage.getItem('refreshToken');
const { data } = await axiosInstance.get( const { data } = await axiosInstance.get(
`${process.env.REACT_APP_API_URL}/token/refresh?refreshToken=${refreshToken}`, `${process.env.REACT_APP_API_URL}/token/refresh?refreshToken=${refreshToken}`,
); );
localStorage.setItem('userPrivilige',data.authorityRole);
localStorage.setItem('userToken', data.token); localStorage.setItem('userToken', data.token);
localStorage.setItem('refreshToken', data.refreshToken); localStorage.setItem('refreshToken', data.refreshToken);
return data.token; return data.token;
@ -37,7 +38,6 @@ axiosInstance.interceptors.response.use(
}, },
async (error) => { async (error) => {
const originalRequest = error.config; const originalRequest = error.config;
console.log("original request is: ", originalRequest)
if (error.response.status === 403 && !originalRequest._retry) { if (error.response.status === 403 && !originalRequest._retry) {
originalRequest._retry = true; originalRequest._retry = true;
const access_token = await getNewTokens(); const access_token = await getNewTokens();

View File

@ -4130,6 +4130,11 @@ data-urls@^1.0.0, data-urls@^1.1.0:
whatwg-mimetype "^2.2.0" whatwg-mimetype "^2.2.0"
whatwg-url "^7.0.0" whatwg-url "^7.0.0"
date-fns@^2.16.1:
version "2.16.1"
resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-2.16.1.tgz#05775792c3f3331da812af253e1a935851d3834b"
integrity sha512-sAJVKx/FqrLYHAQeN7VpJrPhagZc9R4ImZIWYRFZaaohR3KzmuK88touwsSwSVT8Qcbd4zoDsnGfX4GFB4imyQ==
debug@2.6.9, debug@^2.2.0, debug@^2.3.3, debug@^2.6.0, debug@^2.6.9: debug@2.6.9, debug@^2.2.0, debug@^2.3.3, debug@^2.6.0, debug@^2.6.9:
version "2.6.9" version "2.6.9"
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f"